@uxland/primary-shell 4.3.0 → 5.0.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 (75) hide show
  1. package/dist/index.js +19094 -19009
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.umd.cjs +1673 -1567
  4. package/dist/index.umd.cjs.map +1 -1
  5. package/dist/primary/shell/src/UI/components/primaria-shell/primaria-shell.d.ts +3 -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/region-manager/region-manager.d.ts +1 -0
  18. package/dist/primary/shell/src/events.d.ts +1 -0
  19. package/dist/primary/shell/src/features/bootstrapper.d.ts +1 -1
  20. package/dist/primary/shell/src/index.d.ts +1 -2
  21. 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
  22. package/dist/primary/shell/src/internal-plugins/activity-history/localization.d.ts +0 -1
  23. package/dist/primary/shell/src/locales.d.ts +4 -0
  24. package/dist/style.css +1 -1
  25. package/package.json +5 -2
  26. package/src/UI/components/primaria-shell/primaria-shell.ts +24 -7
  27. package/src/UI/components/quick-actions-menu/quick-actions-menu.ts +13 -3
  28. package/src/UI/shared-components/index.ts +0 -1
  29. package/src/api/api.ts +11 -8
  30. package/src/api/http-client/http-client.test.ts +188 -76
  31. package/src/api/http-client/http-client.ts +62 -11
  32. package/src/api/interaction-service/confirmation-message.tsx +5 -0
  33. package/src/api/interaction-service/index.ts +1 -0
  34. package/src/api/interaction-service/interaction-service-impl.tsx +225 -0
  35. package/src/api/interaction-service/interaction-service.ts +46 -0
  36. package/src/api/notification-service/notification-service.ts +6 -0
  37. package/src/api/notification-service/notification.service-impl.ts +45 -0
  38. package/src/api/plugin-busy-manager/plugin-busy-list/component.ts +3 -4
  39. package/src/api/plugin-busy-manager/plugin-busy-list/template.ts +1 -1
  40. package/src/api/region-manager/region-manager.ts +5 -0
  41. package/src/disposer.ts +1 -1
  42. package/src/events.ts +1 -0
  43. package/src/features/bootstrapper.ts +6 -3
  44. package/src/features/exit/handler.ts +8 -11
  45. package/src/features/get-user-info/handler.ts +3 -4
  46. package/src/index.ts +1 -2
  47. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/export-pdf-modal.ts +1 -10
  48. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/export-pdf-modal/template.ts +0 -7
  49. package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/handler.ts +8 -8
  50. package/src/internal-plugins/activity-history/activity-history-item/list/UI/main-view/template.ts +1 -1
  51. package/src/internal-plugins/activity-history/activity-history-item/search/handler.ts +5 -3
  52. package/src/internal-plugins/activity-history/localization.ts +0 -1
  53. package/src/locales.ts +5 -0
  54. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +0 -19
  55. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +0 -12
  56. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +0 -11
  57. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/confirm.d.ts +0 -3
  58. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/index.d.ts +0 -5
  59. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/notify.d.ts +0 -4
  60. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/open-dialog.d.ts +0 -3
  61. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/shared.d.ts +0 -3
  62. package/dist/primary/shell/src/UI/shared-components/primaria-interaction/typings.d.ts +0 -40
  63. package/dist/primary/shell/src/api/interaction-manager/interaction.d.ts +0 -9
  64. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.css +0 -104
  65. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +0 -138
  66. package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.css +0 -136
  67. package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +0 -69
  68. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +0 -35
  69. package/src/UI/shared-components/primaria-interaction/confirm.ts +0 -9
  70. package/src/UI/shared-components/primaria-interaction/index.ts +0 -5
  71. package/src/UI/shared-components/primaria-interaction/notify.ts +0 -153
  72. package/src/UI/shared-components/primaria-interaction/open-dialog.ts +0 -8
  73. package/src/UI/shared-components/primaria-interaction/shared.ts +0 -29
  74. package/src/UI/shared-components/primaria-interaction/typings.ts +0 -46
  75. package/src/api/interaction-manager/interaction.ts +0 -26
@@ -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
- };