@uxland/primary-shell 4.3.1 → 5.1.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 (83) hide show
  1. package/dist/index.js +13397 -12875
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.umd.cjs +1748 -1506
  4. package/dist/index.umd.cjs.map +1 -1
  5. package/dist/primary/shell/src/UI/components/primaria-shell/primaria-shell.d.ts +4 -0
  6. package/dist/primary/shell/src/UI/components/quick-actions-menu/quick-actions-menu.d.ts +1 -0
  7. package/dist/primary/shell/src/UI/shared-components/index.d.ts +0 -1
  8. package/dist/primary/shell/src/api/api.d.ts +4 -2
  9. package/dist/primary/shell/src/api/http-client/http-client.d.ts +7 -1
  10. package/dist/primary/shell/src/api/interaction-service/confirmation-message.d.ts +3 -0
  11. package/dist/primary/shell/src/api/interaction-service/index.d.ts +1 -0
  12. package/dist/primary/shell/src/api/interaction-service/interaction-service-impl.d.ts +7 -0
  13. package/dist/primary/shell/src/api/interaction-service/interaction-service.d.ts +32 -0
  14. package/dist/primary/shell/src/api/notification-service/notification-service.d.ts +6 -0
  15. package/dist/primary/shell/src/api/notification-service/notification.service-impl.d.ts +9 -0
  16. package/dist/primary/shell/src/api/plugin-busy-manager/plugin-busy-list/component.d.ts +2 -4
  17. package/dist/primary/shell/src/api/plugin-busy-manager/plugin-busy-manager.d.ts +17 -1
  18. package/dist/primary/shell/src/api/region-manager/region-manager.d.ts +1 -0
  19. package/dist/primary/shell/src/events.d.ts +2 -0
  20. package/dist/primary/shell/src/features/bootstrapper.d.ts +1 -1
  21. package/dist/primary/shell/src/index.d.ts +1 -2
  22. package/dist/primary/shell/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/export-pdf-modal.d.ts +1 -5
  23. package/dist/primary/shell/src/internal-plugins/activity-history/localization.d.ts +0 -1
  24. package/dist/primary/shell/src/locales.d.ts +4 -0
  25. package/dist/style.css +1 -1
  26. package/package.json +5 -2
  27. package/src/UI/components/clinical-monitoring/styles.css +4 -2
  28. package/src/UI/components/primaria-shell/primaria-shell.ts +33 -7
  29. package/src/UI/components/primaria-shell/styles.css +15 -2
  30. package/src/UI/components/primaria-shell/template.ts +7 -3
  31. package/src/UI/components/quick-actions-menu/quick-actions-menu.ts +13 -3
  32. package/src/UI/components/shell-header/template.ts +1 -1
  33. package/src/UI/shared-components/index.ts +0 -1
  34. package/src/api/api.ts +12 -9
  35. package/src/api/http-client/http-client.test.ts +188 -76
  36. package/src/api/http-client/http-client.ts +62 -11
  37. package/src/api/interaction-service/confirmation-message.tsx +5 -0
  38. package/src/api/interaction-service/index.ts +1 -0
  39. package/src/api/interaction-service/interaction-service-impl.tsx +203 -0
  40. package/src/api/interaction-service/interaction-service.ts +46 -0
  41. package/src/api/interaction-service/modal-styles.css +69 -0
  42. package/src/api/notification-service/notification-service.ts +6 -0
  43. package/src/api/notification-service/notification.service-impl.ts +45 -0
  44. package/src/api/plugin-busy-manager/plugin-busy-list/component.ts +3 -4
  45. package/src/api/plugin-busy-manager/plugin-busy-list/template.ts +1 -1
  46. package/src/api/plugin-busy-manager/plugin-busy-manager.test.ts +93 -31
  47. package/src/api/plugin-busy-manager/plugin-busy-manager.ts +44 -1
  48. package/src/api/region-manager/region-manager.ts +5 -0
  49. package/src/disposer.ts +1 -1
  50. package/src/events.ts +2 -0
  51. package/src/features/bootstrapper.ts +6 -3
  52. package/src/features/exit/handler.ts +7 -12
  53. package/src/features/get-user-info/handler.ts +3 -4
  54. package/src/index.ts +1 -2
  55. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/export-pdf-modal.ts +1 -10
  56. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/template.ts +0 -7
  57. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/handler.ts +8 -8
  58. package/src/internal-plugins/activity-history/activity-history-item/list/UI/main-view/template.ts +1 -1
  59. package/src/internal-plugins/activity-history/activity-history-item/search/handler.ts +5 -3
  60. package/src/internal-plugins/activity-history/localization.ts +0 -1
  61. package/src/locales.ts +5 -0
  62. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +0 -19
  63. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +0 -12
  64. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +0 -11
  65. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm.d.ts +0 -3
  66. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/index.d.ts +0 -5
  67. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/notify.d.ts +0 -4
  68. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/open-dialog.d.ts +0 -3
  69. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/shared.d.ts +0 -3
  70. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/typings.d.ts +0 -40
  71. package/dist/primary/shell/src/api/interaction-manager/interaction.d.ts +0 -9
  72. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.css +0 -104
  73. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +0 -138
  74. package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.css +0 -136
  75. package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +0 -69
  76. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +0 -35
  77. package/src/UI/shared-components/primaria-interaction/confirm.ts +0 -9
  78. package/src/UI/shared-components/primaria-interaction/index.ts +0 -5
  79. package/src/UI/shared-components/primaria-interaction/notify.ts +0 -153
  80. package/src/UI/shared-components/primaria-interaction/open-dialog.ts +0 -8
  81. package/src/UI/shared-components/primaria-interaction/shared.ts +0 -29
  82. package/src/UI/shared-components/primaria-interaction/typings.ts +0 -46
  83. package/src/api/interaction-manager/interaction.ts +0 -26
@@ -1,138 +0,0 @@
1
- import { LitElement, css, html, nothing, unsafeCSS } from "lit";
2
- import { when } from "lit/directives/when.js";
3
- import { customElement, property, query } from "lit/decorators.js";
4
- import {
5
- ConfirmOptions,
6
- ConfirmResult,
7
- ConfirmType,
8
- CustomConfirmOptions,
9
- DialogOptions,
10
- } from "../typings";
11
- import styles from "./dialog-component-styles.css?inline";
12
-
13
- const dssToConfirmType = (type: ConfirmType) => {
14
- return type === "danger" ? "error" : type;
15
- };
16
-
17
- const renderActions = (props: DialogComponent) => {
18
- if (!props.options.acceptLabel && !props.options.cancelLabel) return nothing;
19
- const optionsType = dssToConfirmType(props.options.type);
20
-
21
- return html`
22
- <div class="dialog__actions">
23
- <dss-button label=${props.options.cancelLabel} size="lg" variant="secondary" @click="${props._cancel}" ?hidden=${!props.options.cancelLabel} id="cancel-btn"></dss-button>
24
- <dss-button label=${props.options.acceptLabel} size="lg" variant=${optionsType} @click="${props._accept}" ?hidden=${!props.options.acceptLabel} id="accept-btn"></dss-button>
25
- </div>
26
- `;
27
- };
28
-
29
- const renderMessage = (options: ConfirmOptions) =>
30
- html`<div id="message">${options.message || ""}</div>`;
31
-
32
- function renderCustomContent(props: DialogComponent) {
33
- if (props.options.componentConstructor) {
34
- const component = new props.options.componentConstructor() as LitElement;
35
- component.setAttribute("id", "__custom-element__");
36
- component.addEventListener("closed", props.componentCloseRequest.bind(props));
37
- return html`${component}`;
38
- }
39
- return nothing;
40
- }
41
-
42
- function renderDefaultContent(props: DialogComponent) {
43
- const showClose = (props.options as DialogOptions).showCloseButton;
44
- return html`
45
- <div class="dialog__header ${props.options.type} ${showClose ? "with-close" : ""}">
46
- <h2 part="title">${props.options.title || ""}</h2>
47
- ${when(
48
- showClose,
49
- () =>
50
- html`<dss-icon-button size="md" icon="close" @click="${
51
- props._cancel
52
- }"></dss-icon-button>`,
53
- () => nothing,
54
- )}
55
- </div>
56
- <div class="dialog__content">
57
- ${when(
58
- props.options.message,
59
- () => renderMessage(props.options),
60
- () => renderCustomContent(props),
61
- )}
62
- </div>
63
- ${renderActions(props)}
64
- `;
65
- }
66
-
67
- @customElement("dialog-component")
68
- export class DialogComponent extends LitElement {
69
- render() {
70
- return html`
71
- <div class="modal">
72
- <div class="dialog">
73
- ${this.options.fullCustomization ? renderCustomContent(this) : renderDefaultContent(this)}
74
- </div>
75
- </div>
76
- `;
77
- }
78
-
79
- static get styles() {
80
- return css`
81
- ${unsafeCSS(styles)}
82
- `;
83
- }
84
-
85
- @property()
86
- options: ConfirmOptions & CustomConfirmOptions;
87
-
88
- @query(".modal")
89
- modal: any;
90
-
91
- _cancel(e) {
92
- this.close({ confirmed: false });
93
- }
94
-
95
- _accept(e) {
96
- this.close({ confirmed: true });
97
- }
98
-
99
- componentCloseRequest(e: CustomEvent) {
100
- this.close(e.detail);
101
- }
102
-
103
- async close(result: ConfirmResult) {
104
- let finalResult = result;
105
- if (finalResult?.confirmed) {
106
- const component = this.getCustomComponent();
107
- if (component?.canAccept) {
108
- const canAccept = await component.canAccept();
109
- if (!canAccept) return;
110
- }
111
- if (component?.accept) {
112
- finalResult = await component.accept(finalResult);
113
- }
114
- }
115
- this.dispatchEvent(new CustomEvent("closed", { detail: finalResult }));
116
- this.modal.style.display = "none";
117
- }
118
-
119
- getCustomComponent(): any {
120
- return this.shadowRoot?.querySelector("#__custom-element__");
121
- }
122
-
123
- @query("#accept-btn")
124
- acceptButton: HTMLElement;
125
-
126
- @query("#actions")
127
- actionsContainer: HTMLElement;
128
-
129
- @query("#header")
130
- header: HTMLElement;
131
-
132
- @query("#content")
133
- content: HTMLElement;
134
-
135
- show() {
136
- this.modal.style.display = "block";
137
- }
138
- }
@@ -1,136 +0,0 @@
1
- .snackbar {
2
- display: flex;
3
- align-items: center;
4
- flex-direction: row;
5
- justify-content: space-between;
6
- gap: 10px;
7
- visibility: hidden; /* Hidden by default. Visible on click */
8
- min-width: 250px; /* Set a default minimum width */
9
- width: 417px;
10
- height: 56px;
11
- background-color: #333;
12
- color: #fff;
13
- text-align: center;
14
- border-radius: 10px;
15
- font-weight: 500;
16
- padding: 12px 16px;
17
- position: fixed;
18
- z-index: 500;
19
- left: 24px;
20
- box-shadow:
21
- 0 0px 2px rgba(0, 0, 0, 0.16),
22
- 0 0px 5px rgba(0, 0, 0, 0.23);
23
- border: 2px solid;
24
- border-color: transparent;
25
-
26
- .snackbar__message {
27
- text-align: left;
28
- margin-right: 24px;
29
- flex: 1;
30
- }
31
-
32
- &.show {
33
- visibility: visible; /* Show the snackbar */
34
- }
35
- &.success {
36
- background-color: var(--color-green-500);
37
- color: white;
38
- box-shadow:
39
- rgb(67 160 71 / 30%) 0px 0px 2px,
40
- rgb(67 160 71 / 22%) 0px 0px 5px;
41
- }
42
- &.error {
43
- background-color: var(--color-red-500);
44
- color: white;
45
- box-shadow:
46
- rgb(229 57 53 / 30%) 0px 0px 2px,
47
- rgb(229 57 53 / 22%) 0px 0px 5px;
48
- }
49
- &.warning {
50
- background-color: var(--color-yellow-500);
51
- color: black;
52
- box-shadow:
53
- rgb(251 140 0 / 30%) 0px 0px 2px,
54
- rgb(251 140 0 / 22%) 0px 0px 5px;
55
- }
56
- &.info {
57
- background-color: var(--color-primary-500);
58
- color: white;
59
- box-shadow:
60
- rgb(14 80 138 / 30%) 0px 0px 2px,
61
- rgb(14 80 138 / 22%) 0px 0px 5px;
62
- }
63
-
64
- &.notification-1 {
65
- -webkit-animation:
66
- fadein 0.3s,
67
- fadeout 0.55s 6s;
68
- animation:
69
- fadein 0.3s,
70
- fadeout 0.55s 6s;
71
- bottom: 72px;
72
- }
73
-
74
- &.notification-2 {
75
- -webkit-animation:
76
- fadein 0.3s,
77
- fadeout 0.55s 6s;
78
- animation:
79
- fadein 0.3s,
80
- fadeout 0.55s 6s;
81
- bottom: 132px;
82
- }
83
- &.notification-3 {
84
- -webkit-animation:
85
- fadein 0.3s,
86
- fadeout 0.55s 6s;
87
- animation:
88
- fadein 0.3s,
89
- fadeout 0.55s 6s;
90
- bottom: 192px;
91
- }
92
-
93
- @-webkit-keyframes fadein {
94
- from {
95
- bottom: 0;
96
- opacity: 0;
97
- }
98
- to {
99
- opacity: 1;
100
- }
101
- }
102
-
103
- @keyframes fadein {
104
- from {
105
- bottom: 0;
106
- opacity: 0;
107
- }
108
- to {
109
- opacity: 1;
110
- }
111
- }
112
-
113
- @-webkit-keyframes fadeout {
114
- from {
115
- opacity: 1;
116
- }
117
- to {
118
- bottom: 0;
119
- opacity: 0;
120
- }
121
- }
122
-
123
- @keyframes fadeout {
124
- from {
125
- opacity: 1;
126
- }
127
- to {
128
- bottom: 0;
129
- opacity: 0;
130
- }
131
- }
132
-
133
- #close-btn {
134
- cursor: pointer;
135
- }
136
- }
@@ -1,69 +0,0 @@
1
- import { LitElement, css, html, unsafeCSS } from "lit";
2
- import { customElement, property, query } from "lit/decorators.js";
3
- import { ifDefined } from "lit/directives/if-defined.js";
4
- import { NotifyOptions, NotifyType } from "../typings";
5
- import styles from "./notifier-component-styles.css?inline";
6
-
7
- function getIcon(type: NotifyType | undefined) {
8
- if (!type) return;
9
-
10
- const types = new Map<NotifyType, string>([
11
- ["error", "error"],
12
- ["info", "info"],
13
- ["warning", "warning"],
14
- ["success", "check_circle"],
15
- ]);
16
-
17
- return types.get(type) as string;
18
- }
19
-
20
- @customElement("notifier-component")
21
- export class NotifierComponent extends LitElement {
22
- render() {
23
- return html`
24
- <div class="snackbar ${this.options.type}">
25
- <dss-icon icon=${ifDefined(getIcon(this.options.type))} size="md"></dss-icon>
26
- <div class="snackbar__message">${this.options.message ?? ""}</div>
27
- <div class="snackbar__action">
28
- <dss-icon @click="${this.close}" id="close-btn" icon="close" size="md"></dss-icon>
29
- </div>
30
- </div>
31
- `;
32
- }
33
-
34
- static get styles() {
35
- return css`
36
- ${unsafeCSS(styles)}
37
- `;
38
- }
39
-
40
- @property({ type: Object })
41
- options: NotifyOptions;
42
-
43
- @query(".snackbar")
44
- snackbar: HTMLElement;
45
-
46
- show() {
47
- this.snackbar.classList.add("show");
48
- }
49
-
50
- clearAndUpdateOrder(order: string) {
51
- const classListValues = this.snackbar.classList.values();
52
-
53
- for (const singleClass of classListValues) {
54
- if (!singleClass.startsWith("notification")) continue;
55
-
56
- this.snackbar.classList.remove(singleClass);
57
- }
58
-
59
- this.snackbar.classList.add(order);
60
-
61
- this.requestUpdate();
62
- }
63
-
64
- close() {
65
- this.snackbar.classList.remove("show");
66
-
67
- this.dispatchEvent(new CustomEvent("closed"));
68
- }
69
- }
@@ -1,35 +0,0 @@
1
- import { dedupeMixin } from "@uxland/lit-utilities";
2
- import { LitElement } from "lit";
3
- import { property } from "lit/decorators.js";
4
- import { ConfirmResult, Constructor } from "./typings";
5
-
6
- export declare class ConfirmMixinBase {
7
- model: any;
8
- outputModel: any;
9
- close(result: ConfirmResult): void;
10
- canAccept(): Promise<boolean> | boolean;
11
- accept(result: ConfirmResult): Promise<ConfirmResult>;
12
- }
13
-
14
- const ConfirmMixin = dedupeMixin(<T extends Constructor<LitElement>>(superClass: T) => {
15
- class ConfirmMixinClass extends superClass implements ConfirmMixinBase {
16
- @property()
17
- model: T;
18
- @property()
19
- outputModel: T;
20
- close(result: ConfirmResult) {
21
- (this as any).dispatchEvent(new CustomEvent("closed", { detail: result }));
22
- }
23
- canAccept(): Promise<boolean> | boolean {
24
- return Promise.resolve(true);
25
- }
26
- accept(result: ConfirmResult): Promise<ConfirmResult> {
27
- return Promise.resolve(result);
28
- }
29
- }
30
- return ConfirmMixinClass as Constructor<ConfirmMixinBase> & T;
31
- });
32
-
33
- export function confirmMixin<T extends Constructor<LitElement>>(superClass: T) {
34
- return ConfirmMixin(superClass as any) as unknown as Constructor<ConfirmMixinBase> & T;
35
- }
@@ -1,9 +0,0 @@
1
- import "./components/dialog-component";
2
- import { buildDialogComponent } from "./shared";
3
- import { ConfirmOptions, ConfirmResult, CustomConfirmOptions } from "./typings";
4
-
5
- export const confirm = async (
6
- options: (ConfirmOptions & CustomConfirmOptions) | any,
7
- ): Promise<ConfirmResult> => {
8
- return buildDialogComponent(options);
9
- };
@@ -1,5 +0,0 @@
1
- export * from "./confirm";
2
- export * from "./notify";
3
- export * from "./open-dialog";
4
- export * from "./confirm-mixin";
5
- export * from "./typings";
@@ -1,153 +0,0 @@
1
- import "./components/notifier-component";
2
- import { NotifierComponent } from "./components/notifier-component";
3
- import { NotifyOptions } from "./typings";
4
-
5
- function rand(c: "x" | "y") {
6
- const r = (Math.random() * 16) | 0;
7
- const v = c === "x" ? r : (r & 0x3) | 0x8;
8
- return v.toString(16);
9
- }
10
-
11
- export function generateId() {
12
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, rand);
13
- }
14
-
15
- type NotifyOptionsWithId = NotifyOptions & { id: string };
16
-
17
- const notificationStack: NotifyOptionsWithId[] = [];
18
-
19
- const displayNotifications: NotifyOptionsWithId[] = [];
20
-
21
- const stackLimit = 10;
22
-
23
- const timeToCloseNotification = 5;
24
-
25
- const updateNotificationOptsOrder = () => {
26
- for (const [idx, notification] of displayNotifications.entries()) {
27
- notification.order = `notification-${idx + 1}`;
28
- }
29
- };
30
-
31
- const getComponentById = (id: string | undefined) =>
32
- id ? (document.getElementById(id) as NotifierComponent | undefined) : undefined;
33
-
34
- const showAndSetTimeOutClose = (component: NotifierComponent, timeInSeconds: number) => {
35
- if (!getComponentById(component.id)) return;
36
-
37
- component.show();
38
-
39
- setTimeout(() => {
40
- component.close();
41
- }, timeInSeconds * 1000);
42
- };
43
-
44
- const removeCurrentComponent = (id: string) => {
45
- const currentComponentIdx = displayNotifications.findIndex((n) => n.id === id);
46
-
47
- const currentComponent = getComponentById(displayNotifications[currentComponentIdx]?.id);
48
-
49
- if (!currentComponent) return;
50
-
51
- currentComponent.remove();
52
-
53
- displayNotifications.splice(currentComponentIdx, 1);
54
- };
55
-
56
- const removeFromStackAndAddToDisplay = () => {
57
- const nextNotificationOpts = notificationStack[0];
58
-
59
- const nextNotificationIsVisible =
60
- nextNotificationOpts && displayNotifications.find((n) => n.id === nextNotificationOpts.id);
61
-
62
- if (nextNotificationOpts && !nextNotificationIsVisible) {
63
- displayNotifications.push(nextNotificationOpts);
64
-
65
- notificationStack.shift();
66
- }
67
- };
68
-
69
- const refreshAllComponentsOrder = () => {
70
- for (const notification of displayNotifications) {
71
- if (!notification.order) continue;
72
-
73
- const notificationComponent = getComponentById(notification.id);
74
-
75
- if (!notificationComponent) continue;
76
-
77
- notificationComponent.clearAndUpdateOrder(notification.order);
78
- }
79
- };
80
-
81
- const setNewDisplayNotification = () => {
82
- const lastNotificationIdx = displayNotifications.length - 1;
83
-
84
- const lastDisplayNotification = displayNotifications[lastNotificationIdx];
85
-
86
- if (!lastDisplayNotification) return;
87
-
88
- const lastComponent = getComponentById(lastDisplayNotification.id);
89
-
90
- if (!lastComponent) return;
91
-
92
- showAndSetTimeOutClose(lastComponent, timeToCloseNotification);
93
- };
94
-
95
- const closeAndUpdateStack = (id: string) => {
96
- removeCurrentComponent(id);
97
-
98
- removeFromStackAndAddToDisplay();
99
-
100
- updateNotificationOptsOrder();
101
-
102
- refreshAllComponentsOrder();
103
-
104
- setNewDisplayNotification();
105
- };
106
-
107
- const createNotifyComponent = (options: NotifyOptions, id: string) => {
108
- const notifierComponentName = "notifier-component";
109
-
110
- const component = document.body.appendChild(
111
- document.createElement(notifierComponentName),
112
- ) as NotifierComponent;
113
-
114
- component.options = options;
115
-
116
- component.id = id;
117
-
118
- return component;
119
- };
120
-
121
- export const notify = (options: NotifyOptions) => {
122
- const id = `${generateId()}`;
123
-
124
- const optionWithId = { ...options, id };
125
-
126
- if (displayNotifications.length < stackLimit) {
127
- displayNotifications.push(optionWithId);
128
- } else {
129
- notificationStack.push(optionWithId);
130
- }
131
-
132
- if (!options.message) throw new Error("message is required");
133
-
134
- const component = createNotifyComponent(options, id);
135
-
136
- component.addEventListener("closed", () => closeAndUpdateStack(id));
137
-
138
- const componentIsReady = component.updateComplete;
139
-
140
- componentIsReady.then(() => {
141
- if (!notificationStack.length && displayNotifications.length <= stackLimit) {
142
- updateNotificationOptsOrder();
143
-
144
- const order = displayNotifications.find((n) => n.id === id)?.order;
145
-
146
- if (!order) return;
147
-
148
- component.clearAndUpdateOrder(order);
149
-
150
- showAndSetTimeOutClose(component, timeToCloseNotification);
151
- }
152
- });
153
- };
@@ -1,8 +0,0 @@
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
- };
@@ -1,29 +0,0 @@
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
- };
@@ -1,46 +0,0 @@
1
- import { LitElement } from "lit";
2
- export declare type Constructor<T = Record<string, unknown>> = new (...args: any[]) => T;
3
-
4
- export interface ConfirmOptions {
5
- title: string;
6
- message: string;
7
- type: ConfirmType;
8
- acceptLabel: string;
9
- cancelLabel: string;
10
- }
11
-
12
- export interface CustomConfirmOptions<T = any> {
13
- title: string;
14
- componentConstructor: Constructor<LitElement | any>;
15
- type: ConfirmType;
16
- acceptLabel?: string;
17
- cancelLabel?: string;
18
- model?: T;
19
- fullCustomization?: boolean;
20
- }
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
-
30
- export type ConfirmType = "danger" | "warning" | "info" | "success";
31
-
32
- export interface NotifyOptions {
33
- message?: string;
34
- type?: NotifyType;
35
- position?: NotifyPosition;
36
- order?: string;
37
- }
38
-
39
- export interface ConfirmResult<T = any> {
40
- confirmed: boolean;
41
- outputModel?: T;
42
- }
43
-
44
- export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
45
- export type NotifyPosition = "bottom" | "center" | "top";
46
- export type NotifyType = "warning" | "info" | "success" | "error";
@@ -1,26 +0,0 @@
1
- import {
2
- ConfirmOptions,
3
- ConfirmResult,
4
- CustomConfirmOptions,
5
- DialogOptions,
6
- NotifyOptions,
7
- confirm,
8
- notify,
9
- openDialog,
10
- } from "../../UI/shared-components/primaria-interaction";
11
-
12
- export interface PrimariaInteractionManager {
13
- notify(options: NotifyOptions): void;
14
- confirm(options: ConfirmOptions): Promise<ConfirmResult>;
15
- customConfirm(options: CustomConfirmOptions): Promise<ConfirmResult>;
16
- openDialog(options: DialogOptions): void;
17
- }
18
-
19
- export const createInteractionManager: () => PrimariaInteractionManager = () => {
20
- return {
21
- notify: (options: NotifyOptions) => notify(options),
22
- confirm: (options: ConfirmOptions) => confirm(options),
23
- customConfirm: (options: CustomConfirmOptions) => confirm(options),
24
- openDialog: (options: DialogOptions) => openDialog(options),
25
- } as PrimariaInteractionManager;
26
- };