@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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -58
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +23 -25
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +3 -4
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +4 -9
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm.d.ts +2 -2
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/index.d.ts +1 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/open-dialog.d.ts +3 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/shared.d.ts +3 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-interaction/typings.d.ts +11 -2
- 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
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-menu/template.d.ts +3 -0
- package/dist/primary/shell/src/api/api.d.ts +2 -0
- package/dist/primary/shell/src/api/ecap-event-manager/ecap-event-manager.d.ts +16 -0
- package/dist/primary/shell/src/api/ecap-event-manager/typings.d.ts +5 -0
- package/dist/primary/shell/src/api/interaction-manager/interaction.d.ts +5 -4
- package/dist/primary/shell/src/index.d.ts +3 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/components/activity-history/activity-history.d.ts +1 -1
- package/package.json +1 -1
- package/src/UI/components/poc-events-ecap/poc-events-ecap.ts +4 -10
- package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.css +5 -2
- package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +47 -37
- package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +9 -13
- package/src/UI/shared-components/primaria-interaction/confirm.ts +5 -26
- package/src/UI/shared-components/primaria-interaction/index.ts +1 -0
- package/src/UI/shared-components/primaria-interaction/open-dialog.ts +8 -0
- package/src/UI/shared-components/primaria-interaction/shared.ts +29 -0
- package/src/UI/shared-components/primaria-interaction/typings.ts +13 -2
- package/src/UI/shared-components/{primaria-menu-with-submenu/primaria-menu-with-submenu.ts → primaria-nav-menu/primaria-nav-menu.ts} +2 -2
- package/src/UI/shared-components/{primaria-menu-with-submenu → primaria-nav-menu}/styles.css +1 -1
- package/src/UI/shared-components/{primaria-menu-with-submenu → primaria-nav-menu}/template.ts +3 -3
- package/src/api/api.ts +4 -0
- package/src/api/ecap-event-manager/ecap-event-manager.ts +34 -0
- package/src/api/ecap-event-manager/typings.ts +5 -0
- package/src/api/interaction-manager/interaction.ts +11 -6
- package/src/api/region-manager/region-manager.ts +8 -0
- package/src/index.ts +6 -4
- package/src/internal-plugins/activity-history/components/activity-history/activity-history.ts +17 -5
- package/src/internal-plugins/activity-history/components/activity-history/template.ts +2 -3
- package/src/internal-plugins/activity-history/features/export-to-pdf/handler.ts +1 -2
- 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 {
|
|
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:
|
|
14
|
-
getCustomComponent():
|
|
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
|
-
|
|
6
|
+
outputModel: any;
|
|
7
|
+
close(result: ConfirmResult): void;
|
|
13
8
|
canAccept(): Promise<boolean> | boolean;
|
|
14
|
-
accept(): Promise<
|
|
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
|
|
3
|
+
export declare const confirm: (options: (ConfirmOptions & CustomConfirmOptions) | any) => 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";
|
|
@@ -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 {};
|
|
@@ -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):
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
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
|
-
|
|
20
|
+
_handleSearchChange(event: any): void;
|
|
21
21
|
_handleSelectDate(date: string): void;
|
|
22
22
|
selectedDate: Date;
|
|
23
23
|
scrollToClosestDate(): void;
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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`
|
package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.css
CHANGED
|
@@ -34,12 +34,15 @@
|
|
|
34
34
|
.dialog__header {
|
|
35
35
|
display: flex;
|
|
36
36
|
flex-direction: row;
|
|
37
|
-
justify-content:
|
|
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 {
|
|
4
|
-
|
|
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(
|
|
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="
|
|
47
|
-
|
|
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
|
-
|
|
87
|
-
this.close(false);
|
|
95
|
+
this.close({ confirmed: false });
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
_accept(e) {
|
|
91
|
-
|
|
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:
|
|
100
|
-
|
|
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
|
-
|
|
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():
|
|
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
|
-
|
|
8
|
+
outputModel: any;
|
|
9
|
+
close(result: ConfirmResult): void;
|
|
16
10
|
canAccept(): Promise<boolean> | boolean;
|
|
17
|
-
accept(): Promise<
|
|
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
|
-
|
|
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<
|
|
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 {
|
|
2
|
+
import { buildDialogComponent } from "./shared";
|
|
3
|
+
import { ConfirmOptions, ConfirmResult, CustomConfirmOptions } from "./typings";
|
|
3
4
|
|
|
4
|
-
export const
|
|
5
|
+
export const confirm = async (
|
|
5
6
|
options: (ConfirmOptions & CustomConfirmOptions) | any,
|
|
6
|
-
): Promise<
|
|
7
|
-
|
|
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
|
};
|
|
@@ -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
|
|
7
|
-
export class
|
|
6
|
+
@customElement("primaria-nav-menu")
|
|
7
|
+
export class PrimariaNavMenu extends LitElement {
|
|
8
8
|
constructor(
|
|
9
9
|
icon: string,
|
|
10
10
|
label: string,
|
package/src/UI/shared-components/{primaria-menu-with-submenu → primaria-nav-menu}/template.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { html } from "lit";
|
|
2
|
-
import {
|
|
2
|
+
import { PrimariaNavMenu } from "./primaria-nav-menu";
|
|
3
3
|
|
|
4
|
-
export const template = (props:
|
|
4
|
+
export const template = (props: PrimariaNavMenu) => {
|
|
5
5
|
const actionMenuStyle = `left: ${props.parentWidth}px`;
|
|
6
6
|
|
|
7
7
|
return html`
|
|
8
|
-
<div class="
|
|
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;
|