@uxland/primary-shell 3.2.6 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +101 -58
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.umd.cjs +23 -25
  5. package/dist/index.umd.cjs.map +1 -1
  6. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +3 -4
  7. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +4 -9
  8. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm.d.ts +2 -2
  9. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/index.d.ts +1 -0
  10. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/open-dialog.d.ts +3 -0
  11. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/shared.d.ts +3 -0
  12. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/typings.d.ts +11 -2
  13. package/dist/primary/shell/src/UI/shared-components/{primaria-menu-with-submenu/primaria-menu-with-submenu.d.ts → primaria-nav-menu/primaria-nav-menu.d.ts} +1 -1
  14. package/dist/primary/shell/src/UI/shared-components/primaria-nav-menu/template.d.ts +3 -0
  15. package/dist/primary/shell/src/api/api.d.ts +2 -0
  16. package/dist/primary/shell/src/api/ecap-event-manager/ecap-event-manager.d.ts +16 -0
  17. package/dist/primary/shell/src/api/ecap-event-manager/typings.d.ts +5 -0
  18. package/dist/primary/shell/src/api/interaction-manager/interaction.d.ts +5 -4
  19. package/dist/primary/shell/src/index.d.ts +3 -1
  20. package/dist/primary/shell/src/internal-plugins/activity-history/components/activity-history/activity-history.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/UI/components/poc-events-ecap/poc-events-ecap.ts +4 -10
  23. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.css +5 -2
  24. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +47 -37
  25. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +9 -13
  26. package/src/UI/shared-components/primaria-interaction/confirm.ts +5 -26
  27. package/src/UI/shared-components/primaria-interaction/index.ts +1 -0
  28. package/src/UI/shared-components/primaria-interaction/open-dialog.ts +8 -0
  29. package/src/UI/shared-components/primaria-interaction/shared.ts +29 -0
  30. package/src/UI/shared-components/primaria-interaction/typings.ts +13 -2
  31. package/src/UI/shared-components/{primaria-menu-with-submenu/primaria-menu-with-submenu.ts → primaria-nav-menu/primaria-nav-menu.ts} +2 -2
  32. package/src/UI/shared-components/{primaria-menu-with-submenu → primaria-nav-menu}/styles.css +1 -1
  33. package/src/UI/shared-components/{primaria-menu-with-submenu → primaria-nav-menu}/template.ts +3 -3
  34. package/src/api/api.ts +4 -0
  35. package/src/api/ecap-event-manager/ecap-event-manager.ts +34 -0
  36. package/src/api/ecap-event-manager/typings.ts +5 -0
  37. package/src/api/interaction-manager/interaction.ts +11 -6
  38. package/src/api/region-manager/region-manager.ts +8 -0
  39. package/src/index.ts +6 -4
  40. package/src/internal-plugins/activity-history/components/activity-history/activity-history.ts +17 -5
  41. package/src/internal-plugins/activity-history/components/activity-history/template.ts +2 -3
  42. package/src/internal-plugins/activity-history/features/export-to-pdf/handler.ts +1 -2
  43. package/dist/primary/shell/src/UI/shared-components/primaria-menu-with-submenu/template.d.ts +0 -3
@@ -1,6 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
- import { IConfirmMixin } from '../confirm-mixin';
3
- import { ConfirmOptions, CustomConfirmOptions } from '../typings';
2
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions } from '../typings';
4
3
 
5
4
  export declare class DialogComponent extends LitElement {
6
5
  render(): import('lit').TemplateResult<1>;
@@ -10,8 +9,8 @@ export declare class DialogComponent extends LitElement {
10
9
  _cancel(e: any): void;
11
10
  _accept(e: any): void;
12
11
  componentCloseRequest(e: CustomEvent): void;
13
- close(result: boolean): Promise<void>;
14
- getCustomComponent(): IConfirmMixin | any;
12
+ close(result: ConfirmResult): Promise<void>;
13
+ getCustomComponent(): any;
15
14
  acceptButton: HTMLElement;
16
15
  actionsContainer: HTMLElement;
17
16
  header: HTMLElement;
@@ -1,16 +1,11 @@
1
1
  import { LitElement } from 'lit';
2
- import { Constructor } from './typings';
2
+ import { ConfirmResult, Constructor } from './typings';
3
3
 
4
- export interface IConfirmMixin {
5
- model: any;
6
- close(result: boolean): void;
7
- canAccept(): Promise<boolean> | boolean;
8
- accept(): Promise<void> | void;
9
- }
10
4
  export declare class ConfirmMixinBase {
11
5
  model: any;
12
- close(result: boolean): void;
6
+ outputModel: any;
7
+ close(result: ConfirmResult): void;
13
8
  canAccept(): Promise<boolean> | boolean;
14
- accept(): Promise<void> | void;
9
+ accept(result: ConfirmResult): Promise<ConfirmResult>;
15
10
  }
16
11
  export declare function confirmMixin<T extends Constructor<LitElement>>(superClass: T): Constructor<ConfirmMixinBase> & T;
@@ -1,3 +1,3 @@
1
- import { ConfirmOptions, CustomConfirmOptions } from './typings';
1
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions } from './typings';
2
2
 
3
- export declare const doConfirm: (options: (ConfirmOptions & CustomConfirmOptions) | any) => Promise<any>;
3
+ export declare const confirm: (options: (ConfirmOptions & CustomConfirmOptions) | any) => Promise<ConfirmResult>;
@@ -1,4 +1,5 @@
1
1
  export * from './confirm';
2
2
  export * from './notify';
3
+ export * from './open-dialog';
3
4
  export * from './confirm-mixin';
4
5
  export * from './typings';
@@ -0,0 +1,3 @@
1
+ import { DialogOptions } from './typings';
2
+
3
+ export declare const openDialog: (options: DialogOptions | any) => void;
@@ -0,0 +1,3 @@
1
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions, DialogOptions } from './typings';
2
+
3
+ export declare const buildDialogComponent: (options: DialogOptions & ConfirmOptions & CustomConfirmOptions) => Promise<ConfirmResult>;
@@ -7,18 +7,23 @@ export interface ConfirmOptions {
7
7
  type: ConfirmType;
8
8
  acceptLabel: string;
9
9
  cancelLabel: string;
10
- modal?: boolean;
11
10
  }
12
11
  export interface CustomConfirmOptions<T = any> {
13
12
  title: string;
14
13
  componentConstructor: Constructor<LitElement | any>;
15
14
  type: ConfirmType;
16
- modal?: boolean;
17
15
  acceptLabel?: string;
18
16
  cancelLabel?: string;
19
17
  model?: T;
20
18
  fullCustomization?: boolean;
21
19
  }
20
+ export interface DialogOptions<T = any> {
21
+ title: string;
22
+ componentConstructor: Constructor<LitElement | any>;
23
+ model?: T;
24
+ showCloseButton?: boolean;
25
+ fullCustomization?: boolean;
26
+ }
22
27
  export type ConfirmType = "danger" | "warning" | "info" | "success";
23
28
  export interface NotifyOptions {
24
29
  message?: string;
@@ -26,6 +31,10 @@ export interface NotifyOptions {
26
31
  position?: NotifyPosition;
27
32
  order?: string;
28
33
  }
34
+ export interface ConfirmResult<T = any> {
35
+ confirmed: boolean;
36
+ outputModel?: T;
37
+ }
29
38
  export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
30
39
  export type NotifyPosition = "bottom" | "center" | "top";
31
40
  export type NotifyType = "danger" | "warning" | "info" | "success" | "error";
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit';
2
2
 
3
- export declare class PrimariaMenuWithSubmenu extends LitElement {
3
+ export declare class PrimariaNavMenu extends LitElement {
4
4
  constructor(icon: string, label: string, subItems: {
5
5
  icon?: string;
6
6
  label: string;
@@ -0,0 +1,3 @@
1
+ import { PrimariaNavMenu } from './primaria-nav-menu';
2
+
3
+ export declare const template: (props: PrimariaNavMenu) => import('lit').TemplateResult<1>;
@@ -5,6 +5,7 @@ import { PrimariaGlobalStateManager } from './global-state/global-state';
5
5
  import { HttpClient } from './http-client/http-client';
6
6
  import { PrimariaInteractionManager } from './interaction-manager/interaction';
7
7
  import { TokenManager } from './token-manager/token-manager';
8
+ import { EcapEventManager } from './ecap-event-manager/ecap-event-manager';
8
9
 
9
10
  export interface PrimariaApi extends HarmonixApi {
10
11
  httpClient: HttpClient;
@@ -13,6 +14,7 @@ export interface PrimariaApi extends HarmonixApi {
13
14
  regionManager: PrimariaRegionManager;
14
15
  globalStateManager: PrimariaGlobalStateManager;
15
16
  tokenManager: TokenManager;
17
+ ecapEventManager: EcapEventManager;
16
18
  }
17
19
  export declare const PrimariaRegionHost: any;
18
20
  /**
@@ -0,0 +1,16 @@
1
+ export declare abstract class EcapEventManager {
2
+ /**
3
+ * Publish an Ecap event.
4
+ * @param event - Event name.
5
+ * @param eventType - Event type.
6
+ * @param url - Asociated URL to event.
7
+ */
8
+ abstract publish(event: string, eventType: string, url: string): void;
9
+ }
10
+ declare class EcapEventManagerImpl implements EcapEventManager {
11
+ publish(event: string, eventType: string, url: string): void;
12
+ private createEcapEvent;
13
+ private raiseEcapEvent;
14
+ }
15
+ export declare const createEcapEventManager: () => EcapEventManagerImpl;
16
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface IEcapEvent {
2
+ event: string;
3
+ eventType: string;
4
+ url: string;
5
+ }
@@ -1,8 +1,9 @@
1
- import { ConfirmOptions, CustomConfirmOptions, NotifyOptions } from '../../UI/shared-components/primaria-interaction';
1
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions, DialogOptions, NotifyOptions } from '../../UI/shared-components/primaria-interaction';
2
2
 
3
3
  export interface PrimariaInteractionManager {
4
- notify(options: NotifyOptions): Promise<any>;
5
- doConfirm(options: ConfirmOptions): Promise<boolean>;
6
- doCustomConfirm(options: CustomConfirmOptions): Promise<boolean>;
4
+ notify(options: NotifyOptions): void;
5
+ confirm(options: ConfirmOptions): Promise<ConfirmResult>;
6
+ customConfirm(options: CustomConfirmOptions): Promise<ConfirmResult>;
7
+ openDialog(options: DialogOptions): void;
7
8
  }
8
9
  export declare const createInteractionManager: () => PrimariaInteractionManager;
@@ -6,6 +6,8 @@ export * from './api/api';
6
6
  export * from './api/broker/primaria-broker';
7
7
  export { PrimariaMenuItem } from './UI/shared-components/primaria-menu-item/primaria-menu-item';
8
8
  export { confirmMixin } from './UI/shared-components/primaria-interaction';
9
- export type { IConfirmMixin, CustomConfirmOptions, } from './UI/shared-components/primaria-interaction';
9
+ export type { CustomConfirmOptions } from './UI/shared-components/primaria-interaction';
10
+ export { EcapEventManager, createEcapEventManager, } from './api/ecap-event-manager/ecap-event-manager';
11
+ export type { IEcapEvent } from './api/ecap-event-manager/typings';
10
12
  export * from './internal-plugins';
11
13
  export * from '@uxland/harmonix-adapters';
@@ -17,7 +17,7 @@ export declare class ActivityHistory extends ActivityHistory_base {
17
17
  _toggleFilters(): void;
18
18
  _maximize(): void;
19
19
  _minimize(): void;
20
- _handleSearch(value: string): void;
20
+ _handleSearchChange(event: any): void;
21
21
  _handleSelectDate(date: string): void;
22
22
  selectedDate: Date;
23
23
  scrollToClosestDate(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "3.2.6",
3
+ "version": "3.3.0",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -1,5 +1,6 @@
1
1
  import { LitElement, css, html } from "lit";
2
2
  import { customElement } from "lit/decorators.js";
3
+ import { shellApi } from "../../../api/api";
3
4
 
4
5
  //@ts-ignore
5
6
  @customElement("poc-events-ecap")
@@ -25,16 +26,9 @@ export class PocEventsEcap extends LitElement {
25
26
  goToLinkOnEcap(url?: string, accio?: string) {
26
27
  const finalUrl = url || (this as any).shadowRoot?.getElementById("url")?.value;
27
28
  const finalAccio = accio || (this as any).shadowRoot?.getElementById("accio")?.value;
28
- if (window.parent) {
29
- const ecapEvent = {
30
- TipusEvent: "URL_EXTERNA",
31
- Accio: finalAccio,
32
- URL_LLAMADA: finalUrl,
33
- };
34
- console.log(JSON.stringify(ecapEvent));
35
- //sending data to parent window if opened inside iframe
36
- window.parent.postMessage(JSON.stringify(ecapEvent), "*");
37
- }
29
+
30
+ //sending data to parent window if opened inside iframe
31
+ shellApi.ecapEventManager.publish(finalAccio, "URL_EXTERNA", finalUrl);
38
32
  }
39
33
 
40
34
  static styles = css`
@@ -34,12 +34,15 @@
34
34
  .dialog__header {
35
35
  display: flex;
36
36
  flex-direction: row;
37
- justify-content: space-between;
37
+ justify-content: center;
38
38
  padding: 24px;
39
39
  border-top-left-radius: 8px;
40
40
  border-top-right-radius: 8px;
41
- justify-content: center;
42
41
  align-items: center;
42
+
43
+ &.with-close{
44
+ justify-content: space-between;
45
+ }
43
46
  h2 {
44
47
  color: var(--color-neutral-900);
45
48
  padding: 0;
@@ -1,7 +1,13 @@
1
1
  import { LitElement, css, html, nothing, unsafeCSS } from "lit";
2
+ import { when } from "lit/directives/when.js";
2
3
  import { customElement, property, query } from "lit/decorators.js";
3
- import { IConfirmMixin } from "../confirm-mixin";
4
- import { ConfirmOptions, ConfirmType, CustomConfirmOptions } from "../typings";
4
+ import {
5
+ ConfirmOptions,
6
+ ConfirmResult,
7
+ ConfirmType,
8
+ CustomConfirmOptions,
9
+ DialogOptions,
10
+ } from "../typings";
5
11
  import styles from "./dialog-component-styles.css?inline";
6
12
 
7
13
  const dssToConfirmTypeClass = (type: ConfirmType) => {
@@ -28,9 +34,9 @@ const renderActions = (props: DialogComponent) => {
28
34
  const renderMessage = (options: ConfirmOptions) =>
29
35
  html` <div id="message">${options.message || ""}</div> `;
30
36
 
31
- function renderCustomContent(options: CustomConfirmOptions, props: DialogComponent) {
32
- if (options.componentConstructor) {
33
- const component = new options.componentConstructor() as LitElement;
37
+ function renderCustomContent(props: DialogComponent) {
38
+ if (props.options.componentConstructor) {
39
+ const component = new props.options.componentConstructor() as LitElement;
34
40
  component.setAttribute("id", "__custom-element__");
35
41
  component.addEventListener("closed", props.componentCloseRequest.bind(props));
36
42
  return html`${component}`;
@@ -38,33 +44,36 @@ function renderCustomContent(options: CustomConfirmOptions, props: DialogCompone
38
44
  return nothing;
39
45
  }
40
46
 
47
+ function renderDefaultContent(props: DialogComponent) {
48
+ const showClose = (props.options as DialogOptions).showCloseButton;
49
+ return html`<div class="dialog__header ${props.options.type} ${showClose ? "with-close" : ""}">
50
+ <h2 part="title">${props.options.title || ""}</h2>
51
+ ${when(
52
+ showClose,
53
+ () =>
54
+ html`<dss-icon-button size="md" icon="cancel" @click="${
55
+ props._cancel
56
+ }"></dss-icon-button>`,
57
+ () => nothing,
58
+ )}
59
+ </div>
60
+ <div class="dialog__content">
61
+ ${when(
62
+ props.options.message,
63
+ () => renderMessage(props.options),
64
+ () => renderCustomContent(props),
65
+ )}
66
+ </div>
67
+ ${renderActions(props)}`;
68
+ }
69
+
41
70
  @customElement("dialog-component")
42
71
  export class DialogComponent extends LitElement {
43
72
  render() {
44
73
  return html`
45
- <div
46
- class="modal"
47
- @click=${(e) => e.target === this.modal && !this.options.modal && this.close(false)}
48
- >
49
- <div
50
- class="dialog"
51
- >
52
- ${
53
- this.options.fullCustomization
54
- ? renderCustomContent(this.options, this)
55
- : html`<div class="dialog__header ${this.options.type}">
56
- <h2 part="title">${this.options.title || ""}</h2>
57
- </div>
58
- <div class="dialog__content">
59
- ${
60
- this.options.message
61
- ? renderMessage(this.options)
62
- : renderCustomContent(this.options, this)
63
- }
64
- </div>
65
- ${renderActions(this)}`
66
- }
67
-
74
+ <div class="modal">
75
+ <div class="dialog">
76
+ ${this.options.fullCustomization ? renderCustomContent(this) : renderDefaultContent(this)}
68
77
  </div>
69
78
  </div>
70
79
  `;
@@ -83,33 +92,34 @@ export class DialogComponent extends LitElement {
83
92
  modal: any;
84
93
 
85
94
  _cancel(e) {
86
- console.log("canceling modal");
87
- this.close(false);
95
+ this.close({ confirmed: false });
88
96
  }
89
97
 
90
98
  _accept(e) {
91
- console.log("accepting modal");
92
- this.close(true);
99
+ this.close({ confirmed: true });
93
100
  }
94
101
 
95
102
  componentCloseRequest(e: CustomEvent) {
96
103
  this.close(e.detail);
97
104
  }
98
105
 
99
- async close(result: boolean) {
100
- if (result) {
106
+ async close(result: ConfirmResult) {
107
+ let finalResult = result;
108
+ if (finalResult?.confirmed) {
101
109
  const component = this.getCustomComponent();
102
110
  if (component?.canAccept) {
103
111
  const canAccept = await component.canAccept();
104
112
  if (!canAccept) return;
105
- if (component.accept) await component.accept();
113
+ }
114
+ if (component?.accept) {
115
+ finalResult = await component.accept(finalResult);
106
116
  }
107
117
  }
118
+ this.dispatchEvent(new CustomEvent("closed", { detail: finalResult }));
108
119
  this.modal.style.display = "none";
109
- this.dispatchEvent(new CustomEvent("closed", { detail: result }));
110
120
  }
111
121
 
112
- getCustomComponent(): IConfirmMixin | any {
122
+ getCustomComponent(): any {
113
123
  return this.shadowRoot?.querySelector("#__custom-element__");
114
124
  }
115
125
 
@@ -1,34 +1,30 @@
1
1
  import { dedupeMixin } from "@uxland/lit-utilities";
2
2
  import { LitElement } from "lit";
3
3
  import { property } from "lit/decorators.js";
4
- import { Constructor } from "./typings";
5
-
6
- export interface IConfirmMixin {
7
- model: any;
8
- close(result: boolean): void;
9
- canAccept(): Promise<boolean> | boolean;
10
- accept(): Promise<void> | void;
11
- }
4
+ import { ConfirmResult, Constructor } from "./typings";
12
5
 
13
6
  export declare class ConfirmMixinBase {
14
7
  model: any;
15
- close(result: boolean): void;
8
+ outputModel: any;
9
+ close(result: ConfirmResult): void;
16
10
  canAccept(): Promise<boolean> | boolean;
17
- accept(): Promise<void> | void;
11
+ accept(result: ConfirmResult): Promise<ConfirmResult>;
18
12
  }
19
13
 
20
14
  const ConfirmMixin = dedupeMixin(<T extends Constructor<LitElement>>(superClass: T) => {
21
15
  class ConfirmMixinClass extends superClass implements ConfirmMixinBase {
22
16
  @property()
23
17
  model: T;
24
- close(result: boolean) {
18
+ @property()
19
+ outputModel: T;
20
+ close(result: ConfirmResult) {
25
21
  (this as any).dispatchEvent(new CustomEvent("closed", { detail: result }));
26
22
  }
27
23
  canAccept(): Promise<boolean> | boolean {
28
24
  return Promise.resolve(true);
29
25
  }
30
- accept(): Promise<void> | void {
31
- return Promise.resolve();
26
+ accept(result: ConfirmResult): Promise<ConfirmResult> {
27
+ return Promise.resolve(result);
32
28
  }
33
29
  }
34
30
  return ConfirmMixinClass as Constructor<ConfirmMixinBase> & T;
@@ -1,30 +1,9 @@
1
1
  import "./components/dialog-component";
2
- import { ConfirmOptions, CustomConfirmOptions } from "./typings";
2
+ import { buildDialogComponent } from "./shared";
3
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions } from "./typings";
3
4
 
4
- export const doConfirm = async (
5
+ export const confirm = async (
5
6
  options: (ConfirmOptions & CustomConfirmOptions) | any,
6
- ): Promise<any> => {
7
- if (!options.message && !options.componentConstructor) {
8
- throw new Error("message, componentConstructor options properties are required");
9
- }
10
- return new Promise((resolve) => {
11
- const component: any = document.body.appendChild(document.createElement("dialog-component"));
12
-
13
- component.options = options;
14
- const result = component.updateComplete;
15
-
16
- result.then(() => {
17
- if (options.componentConstructor) {
18
- const customComponent = component.shadowRoot.querySelector(`#__custom-element__`);
19
- customComponent.model = options.model;
20
- }
21
- component.addEventListener("closed", closeComponent);
22
- component.options && component.show();
23
- });
24
-
25
- function closeComponent(e: { detail: any }) {
26
- component.remove();
27
- resolve(e.detail);
28
- }
29
- });
7
+ ): Promise<ConfirmResult> => {
8
+ return buildDialogComponent(options);
30
9
  };
@@ -1,4 +1,5 @@
1
1
  export * from "./confirm";
2
2
  export * from "./notify";
3
+ export * from "./open-dialog";
3
4
  export * from "./confirm-mixin";
4
5
  export * from "./typings";
@@ -0,0 +1,8 @@
1
+ import "./components/dialog-component";
2
+ import { buildDialogComponent } from "./shared";
3
+ import { DialogOptions } from "./typings";
4
+
5
+ export const openDialog = (options: DialogOptions | any): void => {
6
+ options.showCloseButton = "showCloseButton" in options ? options.showCloseButton : true;
7
+ buildDialogComponent(options);
8
+ };
@@ -0,0 +1,29 @@
1
+ import { ConfirmOptions, ConfirmResult, CustomConfirmOptions, DialogOptions } from "./typings";
2
+
3
+ export const buildDialogComponent = (
4
+ options: DialogOptions & ConfirmOptions & CustomConfirmOptions,
5
+ ): Promise<ConfirmResult> => {
6
+ if (!options.message && !options.componentConstructor) {
7
+ throw new Error("message, componentConstructor options properties are required");
8
+ }
9
+ return new Promise((resolve) => {
10
+ const component: any = document.body.appendChild(document.createElement("dialog-component"));
11
+
12
+ component.options = options;
13
+ const result = component.updateComplete;
14
+
15
+ result.then(() => {
16
+ if (options.componentConstructor) {
17
+ const customComponent = component.shadowRoot.querySelector("#__custom-element__");
18
+ customComponent.model = options.model;
19
+ }
20
+ component.addEventListener("closed", closeComponent);
21
+ component.options && component.show();
22
+ });
23
+
24
+ function closeComponent(e: { detail: ConfirmResult }) {
25
+ component.remove();
26
+ resolve(e.detail);
27
+ }
28
+ });
29
+ };
@@ -7,20 +7,26 @@ export interface ConfirmOptions {
7
7
  type: ConfirmType;
8
8
  acceptLabel: string;
9
9
  cancelLabel: string;
10
- modal?: boolean;
11
10
  }
12
11
 
13
12
  export interface CustomConfirmOptions<T = any> {
14
13
  title: string;
15
14
  componentConstructor: Constructor<LitElement | any>;
16
15
  type: ConfirmType;
17
- modal?: boolean;
18
16
  acceptLabel?: string;
19
17
  cancelLabel?: string;
20
18
  model?: T;
21
19
  fullCustomization?: boolean;
22
20
  }
23
21
 
22
+ export interface DialogOptions<T = any> {
23
+ title: string;
24
+ componentConstructor: Constructor<LitElement | any>;
25
+ model?: T;
26
+ showCloseButton?: boolean;
27
+ fullCustomization?: boolean;
28
+ }
29
+
24
30
  export type ConfirmType = "danger" | "warning" | "info" | "success";
25
31
 
26
32
  export interface NotifyOptions {
@@ -30,6 +36,11 @@ export interface NotifyOptions {
30
36
  order?: string;
31
37
  }
32
38
 
39
+ export interface ConfirmResult<T = any> {
40
+ confirmed: boolean;
41
+ outputModel?: T;
42
+ }
43
+
33
44
  export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
34
45
  export type NotifyPosition = "bottom" | "center" | "top";
35
46
  export type NotifyType = "danger" | "warning" | "info" | "success" | "error";
@@ -3,8 +3,8 @@ import { template } from "./template";
3
3
  import styles from "./styles.css?inline";
4
4
  import { customElement, property, state } from "lit/decorators.js";
5
5
 
6
- @customElement("primaria-menu-with-submenu")
7
- export class PrimariaMenuWithSubmenu extends LitElement {
6
+ @customElement("primaria-nav-menu")
7
+ export class PrimariaNavMenu extends LitElement {
8
8
  constructor(
9
9
  icon: string,
10
10
  label: string,
@@ -1,4 +1,4 @@
1
- .item {
1
+ .nav-menu {
2
2
  position: relative;
3
3
  display: flex;
4
4
  flex-direction: row;
@@ -1,11 +1,11 @@
1
1
  import { html } from "lit";
2
- import { PrimariaMenuWithSubmenu } from "./primaria-menu-with-submenu";
2
+ import { PrimariaNavMenu } from "./primaria-nav-menu";
3
3
 
4
- export const template = (props: PrimariaMenuWithSubmenu) => {
4
+ export const template = (props: PrimariaNavMenu) => {
5
5
  const actionMenuStyle = `left: ${props.parentWidth}px`;
6
6
 
7
7
  return html`
8
- <div class="item" @click="${props.toggleMenu}" ?expanded=${props.showText}>
8
+ <div class="nav-menu" @click="${props.toggleMenu}" ?expanded=${props.showText}>
9
9
  <dss-container><i class="dss-icon dss-icon--md">${props.icon}</i></dss-container>
10
10
  ${props.showText ? html`<span>${props.label}</span>` : ""}
11
11
  ${
package/src/api/api.ts CHANGED
@@ -17,6 +17,8 @@ import {
17
17
  } from "./interaction-manager/interaction";
18
18
  import { createLocaleManager } from "./localization/localization";
19
19
  import { TokenManager, createTokenManager } from "./token-manager/token-manager";
20
+ import { EcapEventManager, createEcapEventManager } from "./ecap-event-manager/ecap-event-manager";
21
+
20
22
  const broker = createBroker();
21
23
 
22
24
  export interface PrimariaApi extends HarmonixApi {
@@ -26,6 +28,7 @@ export interface PrimariaApi extends HarmonixApi {
26
28
  regionManager: PrimariaRegionManager;
27
29
  globalStateManager: PrimariaGlobalStateManager;
28
30
  tokenManager: TokenManager;
31
+ ecapEventManager: EcapEventManager;
29
32
  }
30
33
 
31
34
  const regionManager: IRegionManager = createRegionManager("primaria");
@@ -51,6 +54,7 @@ export const primariaApiFactory: ApiFactory<PrimariaApi> = (
51
54
  createLocaleManager: createLocaleManager(pluginInfo.pluginId) as any,
52
55
  globalStateManager,
53
56
  tokenManager,
57
+ ecapEventManager: createEcapEventManager(),
54
58
  };
55
59
  };
56
60
 
@@ -0,0 +1,34 @@
1
+ import { IEcapEvent } from "./typings";
2
+
3
+ export abstract class EcapEventManager {
4
+ /**
5
+ * Publish an Ecap event.
6
+ * @param event - Event name.
7
+ * @param eventType - Event type.
8
+ * @param url - Asociated URL to event.
9
+ */
10
+ abstract publish(event: string, eventType: string, url: string): void;
11
+ }
12
+
13
+ class EcapEventManagerImpl implements EcapEventManager {
14
+ publish(event: string, eventType: string, url: string) {
15
+ const ecapEvent = this.createEcapEvent(event, eventType, url);
16
+ this.raiseEcapEvent(ecapEvent);
17
+ }
18
+
19
+ private createEcapEvent(event: string, eventType: string, url: string) {
20
+ return {
21
+ event,
22
+ eventType,
23
+ url,
24
+ } as IEcapEvent;
25
+ }
26
+ private raiseEcapEvent(ecapEvent: IEcapEvent) {
27
+ if (window.parent) window.parent.postMessage(JSON.stringify(ecapEvent), "*");
28
+ console.log("metod", JSON.stringify(ecapEvent));
29
+ }
30
+ }
31
+
32
+ const ecapEventManager = new EcapEventManagerImpl();
33
+
34
+ export const createEcapEventManager = () => ecapEventManager;
@@ -0,0 +1,5 @@
1
+ export interface IEcapEvent {
2
+ event: string;
3
+ eventType: string;
4
+ url: string;
5
+ }