@uxland/primary-shell 7.46.4 → 7.46.6
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/{component-BDnhxP4N.js → component-DZpJPqmp.js} +2 -2
- package/dist/{component-BDnhxP4N.js.map → component-DZpJPqmp.js.map} +1 -1
- package/dist/{index-D9vfVpB7.js → index-DhJhlKAy.js} +717 -711
- package/dist/index-DhJhlKAy.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +33 -33
- package/dist/index.umd.cjs.map +1 -1
- package/dist/{plugin-C76XiACG.js → plugin-DPSai4gO.js} +249 -249
- package/dist/{plugin-C76XiACG.js.map → plugin-DPSai4gO.js.map} +1 -1
- package/dist/primary/shell/src/api/interaction-service/interaction-service-impl.d.ts +1 -0
- package/package.json +1 -1
- package/src/api/interaction-service/interaction-service-impl.tsx +22 -5
- package/dist/index-D9vfVpB7.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfirmationOptions, ConfirmationResult, ConfirmComponentUI, PrimariaInteractionService } from './interaction-service';
|
|
2
2
|
export declare class ParimariaInteractionServiceImpl extends PrimariaInteractionService {
|
|
3
|
+
private readonly openDialogCancellers;
|
|
3
4
|
confirm<TData = undefined, TResult = undefined>(data: TData | undefined, componentUI: ConfirmComponentUI<TData, TResult>, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult<TResult | undefined>>;
|
|
4
5
|
confirmMessage(message: string, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult>;
|
|
5
6
|
dispose(): void;
|
package/package.json
CHANGED
|
@@ -23,13 +23,17 @@ const defaultOptions: ConfirmationOptions = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export class ParimariaInteractionServiceImpl extends PrimariaInteractionService {
|
|
26
|
+
private readonly openDialogCancellers = new Set<() => void>();
|
|
27
|
+
|
|
26
28
|
confirm<TData = undefined, TResult = undefined>(
|
|
27
29
|
data: TData | undefined,
|
|
28
30
|
componentUI: ConfirmComponentUI<TData, TResult>,
|
|
29
31
|
options?: ConfirmationOptions | undefined
|
|
30
32
|
): Promise<ConfirmationResult<TResult | undefined>> {
|
|
31
33
|
const finalOptions: ConfirmationOptions = { ...defaultOptions, ...(options || {}) };
|
|
34
|
+
const { openDialogCancellers } = this;
|
|
32
35
|
return new Promise((resolve) => {
|
|
36
|
+
let isClosing = false;
|
|
33
37
|
const div = document.createElement("div");
|
|
34
38
|
document.body.appendChild(div);
|
|
35
39
|
const wrapperHeadStyles = document.createElement("style");
|
|
@@ -56,6 +60,18 @@ export class ParimariaInteractionServiceImpl extends PrimariaInteractionService
|
|
|
56
60
|
|
|
57
61
|
useEffect(() => {
|
|
58
62
|
window.addEventListener('keydown', handleKeydown);
|
|
63
|
+
|
|
64
|
+
return () => window.removeEventListener('keydown', handleKeydown);
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const cancelDialog = () => handleClose(false);
|
|
69
|
+
|
|
70
|
+
openDialogCancellers.add(cancelDialog);
|
|
71
|
+
|
|
72
|
+
return () => {
|
|
73
|
+
openDialogCancellers.delete(cancelDialog);
|
|
74
|
+
};
|
|
59
75
|
}, []);
|
|
60
76
|
|
|
61
77
|
const handleKeydown = (event: KeyboardEvent) => {
|
|
@@ -104,17 +120,20 @@ export class ParimariaInteractionServiceImpl extends PrimariaInteractionService
|
|
|
104
120
|
};
|
|
105
121
|
|
|
106
122
|
const resolvePromise = (finalResult: TResult, confirmed: boolean) => {
|
|
123
|
+
if (isClosing) return;
|
|
124
|
+
|
|
125
|
+
isClosing = true;
|
|
107
126
|
setTimeout(() => {
|
|
108
127
|
const confirmationResult = {
|
|
109
128
|
result: confirmed ? finalResult : undefined,
|
|
110
129
|
confirmed: confirmed,
|
|
111
130
|
};
|
|
112
131
|
resolve(confirmationResult);
|
|
132
|
+
root.unmount();
|
|
113
133
|
document.body.removeChild(div);
|
|
114
134
|
document.head.removeChild(wrapperHeadStyles);
|
|
115
135
|
if (DialogComponentStyles)
|
|
116
136
|
document.head.removeChild(componentHeadStyles);
|
|
117
|
-
window.removeEventListener('keydown', handleKeydown);
|
|
118
137
|
}, 300);
|
|
119
138
|
};
|
|
120
139
|
|
|
@@ -233,10 +252,8 @@ export class ParimariaInteractionServiceImpl extends PrimariaInteractionService
|
|
|
233
252
|
}
|
|
234
253
|
|
|
235
254
|
dispose(): void {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
for (const modal of modals) {
|
|
239
|
-
modal.remove();
|
|
255
|
+
for (const cancelDialog of [...this.openDialogCancellers]) {
|
|
256
|
+
cancelDialog();
|
|
240
257
|
}
|
|
241
258
|
}
|
|
242
259
|
}
|