@wallarm-org/design-system 4.19.3-rc-fix-table-header-focus-scroll.2 → 4.20.0-rc-feat-modal-manager.1
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/components/Drawer/Drawer.d.ts +6 -0
- package/dist/components/Drawer/Drawer.js +22 -20
- package/dist/components/Drawer/DrawerRoot.d.ts +1 -0
- package/dist/components/Drawer/DrawerRoot.js +89 -47
- package/dist/components/OverlayManager/InstanceErrorBoundary.d.ts +19 -0
- package/dist/components/OverlayManager/InstanceErrorBoundary.js +18 -0
- package/dist/components/OverlayManager/OverlayProvider.d.ts +7 -0
- package/dist/components/OverlayManager/OverlayProvider.js +202 -0
- package/dist/components/OverlayManager/OverlayStoreContext.d.ts +3 -0
- package/dist/components/OverlayManager/OverlayStoreContext.js +3 -0
- package/dist/components/OverlayManager/defineOverlay.d.ts +13 -0
- package/dist/components/OverlayManager/defineOverlay.js +13 -0
- package/dist/components/OverlayManager/index.d.ts +4 -0
- package/dist/components/OverlayManager/index.js +3 -0
- package/dist/components/OverlayManager/overlayStore.d.ts +39 -0
- package/dist/components/OverlayManager/overlayStore.js +150 -0
- package/dist/components/OverlayManager/types.d.ts +49 -0
- package/dist/components/OverlayManager/types.js +0 -0
- package/dist/components/OverlayManager/useOverlay.d.ts +7 -0
- package/dist/components/OverlayManager/useOverlay.js +23 -0
- package/dist/components/Table/StickyGroupParent.js +0 -3
- package/dist/components/Table/TableBody/TableBodyCell.js +43 -40
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveLeftItem.js +2 -1
- package/dist/components/Table/TableColumnMenu/TableColumnMenuMoveRightItem.js +2 -1
- package/dist/components/Table/TableContext/TableProvider.js +63 -64
- package/dist/components/Table/TableContext/types.d.ts +1 -2
- package/dist/components/Table/TableHeadCell.js +0 -1
- package/dist/components/Table/TableInner/TableInnerWindow.js +25 -37
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenu.js +2 -1
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenuReset.js +19 -30
- package/dist/components/Table/lib/index.d.ts +0 -1
- package/dist/components/Table/lib/index.js +0 -1
- package/dist/components/Table/lib/useColumnDnd.d.ts +1 -2
- package/dist/components/Table/lib/useColumnDnd.js +13 -23
- package/dist/components/Table/primitives/TBody.js +0 -1
- package/dist/components/Table/primitives/THead.js +0 -1
- package/dist/components/Table/primitives/Td.js +0 -1
- package/dist/components/Table/primitives/Th.js +0 -1
- package/dist/components/Table/primitives/Tr.js +0 -1
- package/dist/guidelines/foundations/layering.md +2 -1
- package/dist/guidelines/patterns/confirmation-dialogs.md +64 -2
- package/dist/metadata/components.json +82 -1
- package/dist/metadata/guidelines.json +8 -6
- package/package.json +2 -2
- package/dist/components/Table/lib/columnDndStyles.d.ts +0 -15
- package/dist/components/Table/lib/columnDndStyles.js +0 -38
|
@@ -33,5 +33,11 @@ export interface DrawerProps extends TestableProps {
|
|
|
33
33
|
onInteractOutside?: (event: DrawerInteractOutsideEvent) => void;
|
|
34
34
|
/** Fired when the user presses the Escape key while the drawer is open. */
|
|
35
35
|
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Fires once the drawer has finished closing: after the panel's and the backdrop's exit
|
|
38
|
+
* animations end, or right away when there is no animation. Not fired when the drawer
|
|
39
|
+
* reopens before the exit ends, when it never opened, or when it unmounts while open or closing.
|
|
40
|
+
*/
|
|
41
|
+
onExitComplete?: () => void;
|
|
36
42
|
}
|
|
37
43
|
export declare const Drawer: FC<DrawerProps>;
|
|
@@ -4,8 +4,8 @@ import { TestIdProvider } from "../../utils/testId.js";
|
|
|
4
4
|
import { DrawerProvider } from "./DrawerContext/index.js";
|
|
5
5
|
import { DrawerRoot } from "./DrawerRoot.js";
|
|
6
6
|
const Drawer = (t0)=>{
|
|
7
|
-
const $ = c(
|
|
8
|
-
const { children, kind: t1, open, onOpenChange, closeOnEscape: t2, closeOnOutsideClick: t3, overlay: t4, modal: t5, width, minWidth, maxWidth, onInteractOutside, onEscapeKeyDown, "data-testid": testId } = t0;
|
|
7
|
+
const $ = c(22);
|
|
8
|
+
const { children, kind: t1, open, onOpenChange, closeOnEscape: t2, closeOnOutsideClick: t3, overlay: t4, modal: t5, width, minWidth, maxWidth, onInteractOutside, onEscapeKeyDown, onExitComplete, "data-testid": testId } = t0;
|
|
9
9
|
const kind = void 0 === t1 ? "drawer" : t1;
|
|
10
10
|
const closeOnEscape = void 0 === t2 ? true : t2;
|
|
11
11
|
const closeOnOutsideClick = void 0 === t3 ? true : t3;
|
|
@@ -22,25 +22,27 @@ const Drawer = (t0)=>{
|
|
|
22
22
|
$[2] = t6;
|
|
23
23
|
} else t6 = $[2];
|
|
24
24
|
let t7;
|
|
25
|
-
if ($[3] !== closeOnEscape || $[4] !== closeOnOutsideClick || $[5] !== modal || $[6] !== onEscapeKeyDown || $[7] !==
|
|
25
|
+
if ($[3] !== closeOnEscape || $[4] !== closeOnOutsideClick || $[5] !== modal || $[6] !== onEscapeKeyDown || $[7] !== onExitComplete || $[8] !== onInteractOutside || $[9] !== t6) {
|
|
26
26
|
t7 = /*#__PURE__*/ jsx(DrawerRoot, {
|
|
27
27
|
closeOnEscape: closeOnEscape,
|
|
28
28
|
closeOnOutsideClick: closeOnOutsideClick,
|
|
29
29
|
modal: modal,
|
|
30
30
|
onInteractOutside: onInteractOutside,
|
|
31
31
|
onEscapeKeyDown: onEscapeKeyDown,
|
|
32
|
+
onExitComplete: onExitComplete,
|
|
32
33
|
children: t6
|
|
33
34
|
});
|
|
34
35
|
$[3] = closeOnEscape;
|
|
35
36
|
$[4] = closeOnOutsideClick;
|
|
36
37
|
$[5] = modal;
|
|
37
38
|
$[6] = onEscapeKeyDown;
|
|
38
|
-
$[7] =
|
|
39
|
-
$[8] =
|
|
40
|
-
$[9] =
|
|
41
|
-
|
|
39
|
+
$[7] = onExitComplete;
|
|
40
|
+
$[8] = onInteractOutside;
|
|
41
|
+
$[9] = t6;
|
|
42
|
+
$[10] = t7;
|
|
43
|
+
} else t7 = $[10];
|
|
42
44
|
let t8;
|
|
43
|
-
if ($[
|
|
45
|
+
if ($[11] !== closeOnEscape || $[12] !== kind || $[13] !== maxWidth || $[14] !== minWidth || $[15] !== modal || $[16] !== onOpenChange || $[17] !== open || $[18] !== overlay || $[19] !== t7 || $[20] !== width) {
|
|
44
46
|
t8 = /*#__PURE__*/ jsx(DrawerProvider, {
|
|
45
47
|
kind: kind,
|
|
46
48
|
open: open,
|
|
@@ -53,18 +55,18 @@ const Drawer = (t0)=>{
|
|
|
53
55
|
maxWidth: maxWidth,
|
|
54
56
|
children: t7
|
|
55
57
|
});
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
} else t8 = $[
|
|
58
|
+
$[11] = closeOnEscape;
|
|
59
|
+
$[12] = kind;
|
|
60
|
+
$[13] = maxWidth;
|
|
61
|
+
$[14] = minWidth;
|
|
62
|
+
$[15] = modal;
|
|
63
|
+
$[16] = onOpenChange;
|
|
64
|
+
$[17] = open;
|
|
65
|
+
$[18] = overlay;
|
|
66
|
+
$[19] = t7;
|
|
67
|
+
$[20] = width;
|
|
68
|
+
$[21] = t8;
|
|
69
|
+
} else t8 = $[21];
|
|
68
70
|
return t8;
|
|
69
71
|
};
|
|
70
72
|
Drawer.displayName = "Drawer";
|
|
@@ -25,6 +25,7 @@ interface DrawerRootProps {
|
|
|
25
25
|
modal: boolean;
|
|
26
26
|
onInteractOutside?: (event: DrawerInteractOutsideEvent) => void;
|
|
27
27
|
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
28
|
+
onExitComplete?: () => void;
|
|
28
29
|
}
|
|
29
30
|
export declare const DrawerRoot: FC<DrawerRootProps>;
|
|
30
31
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
3
|
+
import { createContext, useContext, useId, useLayoutEffect } from "react";
|
|
4
4
|
import { Dialog } from "@ark-ui/react/dialog";
|
|
5
5
|
import { useDrawerContext } from "./DrawerContext/index.js";
|
|
6
6
|
import { useNonModalFocusReturn } from "./useNonModalFocusReturn.js";
|
|
@@ -42,72 +42,114 @@ const ignoreProgrammaticFocusOutside = (modal)=>(event)=>{
|
|
|
42
42
|
if (modal || target instanceof Element && target.closest(EXITING_DIALOG_LAYER)) event.preventDefault();
|
|
43
43
|
};
|
|
44
44
|
const DrawerRoot = (t0)=>{
|
|
45
|
-
const $ = c(
|
|
46
|
-
const { children, closeOnEscape, closeOnOutsideClick, modal, onInteractOutside, onEscapeKeyDown } = t0;
|
|
45
|
+
const $ = c(30);
|
|
46
|
+
const { children, closeOnEscape, closeOnOutsideClick, modal, onInteractOutside, onEscapeKeyDown, onExitComplete } = t0;
|
|
47
47
|
const { isOpen, onOpenChange, contentId } = useDrawerContext();
|
|
48
48
|
const ancestorIds = useContext(DrawerAncestorIdsContext);
|
|
49
49
|
useNonModalFocusReturn(isOpen, modal, contentId);
|
|
50
|
+
const backdropId = useId();
|
|
50
51
|
let t1;
|
|
51
|
-
if ($[0] !== onOpenChange) {
|
|
52
|
-
t1 = (t2)=>{
|
|
53
|
-
const { open } = t2;
|
|
54
|
-
onOpenChange(open);
|
|
55
|
-
};
|
|
56
|
-
$[0] = onOpenChange;
|
|
57
|
-
$[1] = t1;
|
|
58
|
-
} else t1 = $[1];
|
|
59
|
-
const handleOpenChange = t1;
|
|
60
52
|
let t2;
|
|
61
|
-
if ($[2] !==
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
if ($[0] !== backdropId || $[1] !== contentId || $[2] !== onExitComplete) {
|
|
54
|
+
t1 = ()=>{
|
|
55
|
+
if (!onExitComplete) return;
|
|
56
|
+
const handleBackdropExitComplete = (event)=>{
|
|
57
|
+
const { target } = event;
|
|
58
|
+
if (target instanceof Element && target.id === backdropId && !document.getElementById(contentId)) onExitComplete();
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener("exitcomplete", handleBackdropExitComplete, true);
|
|
61
|
+
return ()=>document.removeEventListener("exitcomplete", handleBackdropExitComplete, true);
|
|
64
62
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
t2 = [
|
|
64
|
+
onExitComplete,
|
|
65
|
+
backdropId,
|
|
66
|
+
contentId
|
|
67
|
+
];
|
|
68
|
+
$[0] = backdropId;
|
|
69
|
+
$[1] = contentId;
|
|
70
|
+
$[2] = onExitComplete;
|
|
71
|
+
$[3] = t1;
|
|
72
|
+
$[4] = t2;
|
|
73
|
+
} else {
|
|
74
|
+
t1 = $[3];
|
|
75
|
+
t2 = $[4];
|
|
76
|
+
}
|
|
77
|
+
useLayoutEffect(t1, t2);
|
|
68
78
|
let t3;
|
|
69
|
-
if ($[
|
|
70
|
-
t3 =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
if ($[5] !== backdropId || $[6] !== onExitComplete) {
|
|
80
|
+
t3 = ()=>{
|
|
81
|
+
if (!document.getElementById(backdropId)) onExitComplete?.();
|
|
82
|
+
};
|
|
83
|
+
$[5] = backdropId;
|
|
84
|
+
$[6] = onExitComplete;
|
|
85
|
+
$[7] = t3;
|
|
86
|
+
} else t3 = $[7];
|
|
87
|
+
const handleContentExitComplete = t3;
|
|
74
88
|
let t4;
|
|
75
|
-
if ($[
|
|
76
|
-
t4 =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
if ($[8] !== onOpenChange) {
|
|
90
|
+
t4 = (t5)=>{
|
|
91
|
+
const { open } = t5;
|
|
92
|
+
onOpenChange(open);
|
|
93
|
+
};
|
|
94
|
+
$[8] = onOpenChange;
|
|
95
|
+
$[9] = t4;
|
|
96
|
+
} else t4 = $[9];
|
|
97
|
+
const handleOpenChange = t4;
|
|
80
98
|
let t5;
|
|
81
|
-
if ($[
|
|
82
|
-
t5 =
|
|
83
|
-
|
|
99
|
+
if ($[10] !== backdropId || $[11] !== contentId) {
|
|
100
|
+
t5 = {
|
|
101
|
+
content: contentId,
|
|
102
|
+
backdrop: backdropId
|
|
103
|
+
};
|
|
104
|
+
$[10] = backdropId;
|
|
105
|
+
$[11] = contentId;
|
|
106
|
+
$[12] = t5;
|
|
107
|
+
} else t5 = $[12];
|
|
108
|
+
let t6;
|
|
109
|
+
if ($[13] !== ancestorIds) {
|
|
110
|
+
t6 = keepOpenUnlessAncestorCloses(ancestorIds);
|
|
111
|
+
$[13] = ancestorIds;
|
|
112
|
+
$[14] = t6;
|
|
113
|
+
} else t6 = $[14];
|
|
114
|
+
let t7;
|
|
115
|
+
if ($[15] !== modal) {
|
|
116
|
+
t7 = ignoreProgrammaticFocusOutside(modal);
|
|
117
|
+
$[15] = modal;
|
|
118
|
+
$[16] = t7;
|
|
119
|
+
} else t7 = $[16];
|
|
120
|
+
let t8;
|
|
121
|
+
if ($[17] !== children || $[18] !== closeOnEscape || $[19] !== closeOnOutsideClick || $[20] !== handleContentExitComplete || $[21] !== handleOpenChange || $[22] !== isOpen || $[23] !== modal || $[24] !== onEscapeKeyDown || $[25] !== onInteractOutside || $[26] !== t5 || $[27] !== t6 || $[28] !== t7) {
|
|
122
|
+
t8 = /*#__PURE__*/ jsx(Dialog.Root, {
|
|
123
|
+
ids: t5,
|
|
84
124
|
open: isOpen,
|
|
85
125
|
onOpenChange: handleOpenChange,
|
|
86
126
|
closeOnEscape: closeOnEscape,
|
|
87
127
|
closeOnInteractOutside: closeOnOutsideClick,
|
|
88
128
|
modal: modal,
|
|
89
|
-
onRequestDismiss:
|
|
90
|
-
onFocusOutside:
|
|
129
|
+
onRequestDismiss: t6,
|
|
130
|
+
onFocusOutside: t7,
|
|
91
131
|
onInteractOutside: onInteractOutside,
|
|
92
132
|
onEscapeKeyDown: onEscapeKeyDown,
|
|
133
|
+
onExitComplete: handleContentExitComplete,
|
|
93
134
|
lazyMount: true,
|
|
94
135
|
unmountOnExit: true,
|
|
95
136
|
children: children
|
|
96
137
|
});
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
|
|
110
|
-
|
|
138
|
+
$[17] = children;
|
|
139
|
+
$[18] = closeOnEscape;
|
|
140
|
+
$[19] = closeOnOutsideClick;
|
|
141
|
+
$[20] = handleContentExitComplete;
|
|
142
|
+
$[21] = handleOpenChange;
|
|
143
|
+
$[22] = isOpen;
|
|
144
|
+
$[23] = modal;
|
|
145
|
+
$[24] = onEscapeKeyDown;
|
|
146
|
+
$[25] = onInteractOutside;
|
|
147
|
+
$[26] = t5;
|
|
148
|
+
$[27] = t6;
|
|
149
|
+
$[28] = t7;
|
|
150
|
+
$[29] = t8;
|
|
151
|
+
} else t8 = $[29];
|
|
152
|
+
return t8;
|
|
111
153
|
};
|
|
112
154
|
DrawerRoot.displayName = "DrawerRoot";
|
|
113
155
|
export { DrawerAncestorIdsContext, DrawerAncestorIdsProvider, DrawerRoot, keepOpenUnlessAncestorCloses };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, type ReactNode } from 'react';
|
|
2
|
+
interface InstanceErrorBoundaryProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
onError: (error: unknown) => void;
|
|
5
|
+
}
|
|
6
|
+
interface InstanceErrorBoundaryState {
|
|
7
|
+
failed: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Keeps a render error inside one overlay instance. A class, because React has no hook for
|
|
11
|
+
* error boundaries; React Compiler skips classes.
|
|
12
|
+
*/
|
|
13
|
+
export declare class InstanceErrorBoundary extends Component<InstanceErrorBoundaryProps, InstanceErrorBoundaryState> {
|
|
14
|
+
state: InstanceErrorBoundaryState;
|
|
15
|
+
static getDerivedStateFromError(): InstanceErrorBoundaryState;
|
|
16
|
+
componentDidCatch(error: unknown): void;
|
|
17
|
+
render(): ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from "react";
|
|
2
|
+
class InstanceErrorBoundary extends Component {
|
|
3
|
+
state = {
|
|
4
|
+
failed: false
|
|
5
|
+
};
|
|
6
|
+
static getDerivedStateFromError() {
|
|
7
|
+
return {
|
|
8
|
+
failed: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
componentDidCatch(error) {
|
|
12
|
+
this.props.onError(error);
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return this.state.failed ? null : this.props.children;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export { InstanceErrorBoundary };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { OverlayProviderProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders its children, then every overlay opened through `useOverlay` below it. Mount one in the
|
|
5
|
+
* root route component of each app and remote, wrapping everything that route renders.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OverlayProvider: FC<OverlayProviderProps>;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Suspense, useEffect, useLayoutEffect, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { InstanceErrorBoundary } from "./InstanceErrorBoundary.js";
|
|
5
|
+
import { OverlayStoreContext } from "./OverlayStoreContext.js";
|
|
6
|
+
import { createOverlayStore, reportOverlayError } from "./overlayStore.js";
|
|
7
|
+
const OverlayInstanceView = (t0)=>{
|
|
8
|
+
const $ = c(26);
|
|
9
|
+
const { store, instance } = t0;
|
|
10
|
+
const { id, Component, payload, open } = instance;
|
|
11
|
+
let t1;
|
|
12
|
+
if ($[0] !== id || $[1] !== store) {
|
|
13
|
+
t1 = (next)=>{
|
|
14
|
+
if (!next) store.close(id);
|
|
15
|
+
};
|
|
16
|
+
$[0] = id;
|
|
17
|
+
$[1] = store;
|
|
18
|
+
$[2] = t1;
|
|
19
|
+
} else t1 = $[2];
|
|
20
|
+
const handleOpenChange = t1;
|
|
21
|
+
let t2;
|
|
22
|
+
if ($[3] !== id || $[4] !== store) {
|
|
23
|
+
t2 = ()=>store.remove(id);
|
|
24
|
+
$[3] = id;
|
|
25
|
+
$[4] = store;
|
|
26
|
+
$[5] = t2;
|
|
27
|
+
} else t2 = $[5];
|
|
28
|
+
const handleExitComplete = t2;
|
|
29
|
+
let t3;
|
|
30
|
+
if ($[6] !== id || $[7] !== store) {
|
|
31
|
+
t3 = (result)=>store.close(id, result);
|
|
32
|
+
$[6] = id;
|
|
33
|
+
$[7] = store;
|
|
34
|
+
$[8] = t3;
|
|
35
|
+
} else t3 = $[8];
|
|
36
|
+
const handleClose = t3;
|
|
37
|
+
let t4;
|
|
38
|
+
if ($[9] !== id || $[10] !== store) {
|
|
39
|
+
t4 = (error)=>store.fail(id, error);
|
|
40
|
+
$[9] = id;
|
|
41
|
+
$[10] = store;
|
|
42
|
+
$[11] = t4;
|
|
43
|
+
} else t4 = $[11];
|
|
44
|
+
const handleError = t4;
|
|
45
|
+
let t5;
|
|
46
|
+
if ($[12] !== handleExitComplete || $[13] !== handleOpenChange || $[14] !== open) {
|
|
47
|
+
t5 = {
|
|
48
|
+
open,
|
|
49
|
+
onOpenChange: handleOpenChange,
|
|
50
|
+
onExitComplete: handleExitComplete
|
|
51
|
+
};
|
|
52
|
+
$[12] = handleExitComplete;
|
|
53
|
+
$[13] = handleOpenChange;
|
|
54
|
+
$[14] = open;
|
|
55
|
+
$[15] = t5;
|
|
56
|
+
} else t5 = $[15];
|
|
57
|
+
let t6;
|
|
58
|
+
if ($[16] !== handleClose || $[17] !== t5) {
|
|
59
|
+
t6 = {
|
|
60
|
+
rootProps: t5,
|
|
61
|
+
close: handleClose
|
|
62
|
+
};
|
|
63
|
+
$[16] = handleClose;
|
|
64
|
+
$[17] = t5;
|
|
65
|
+
$[18] = t6;
|
|
66
|
+
} else t6 = $[18];
|
|
67
|
+
const controller = t6;
|
|
68
|
+
let t7;
|
|
69
|
+
if ($[19] !== Component || $[20] !== controller || $[21] !== payload) {
|
|
70
|
+
t7 = /*#__PURE__*/ jsx(Suspense, {
|
|
71
|
+
fallback: null,
|
|
72
|
+
children: /*#__PURE__*/ jsx(Component, {
|
|
73
|
+
...payload,
|
|
74
|
+
controller: controller
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
$[19] = Component;
|
|
78
|
+
$[20] = controller;
|
|
79
|
+
$[21] = payload;
|
|
80
|
+
$[22] = t7;
|
|
81
|
+
} else t7 = $[22];
|
|
82
|
+
let t8;
|
|
83
|
+
if ($[23] !== handleError || $[24] !== t7) {
|
|
84
|
+
t8 = /*#__PURE__*/ jsx(InstanceErrorBoundary, {
|
|
85
|
+
onError: handleError,
|
|
86
|
+
children: t7
|
|
87
|
+
});
|
|
88
|
+
$[23] = handleError;
|
|
89
|
+
$[24] = t7;
|
|
90
|
+
$[25] = t8;
|
|
91
|
+
} else t8 = $[25];
|
|
92
|
+
return t8;
|
|
93
|
+
};
|
|
94
|
+
const OverlayProvider = (t0)=>{
|
|
95
|
+
const $ = c(24);
|
|
96
|
+
const { children, closeOnChange, onError } = t0;
|
|
97
|
+
const [store] = useState(createOverlayStore);
|
|
98
|
+
const instances = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
99
|
+
let t1;
|
|
100
|
+
let t2;
|
|
101
|
+
if ($[0] !== onError || $[1] !== store) {
|
|
102
|
+
t1 = ()=>{
|
|
103
|
+
store.setOnError(onError ?? reportOverlayError);
|
|
104
|
+
};
|
|
105
|
+
t2 = [
|
|
106
|
+
store,
|
|
107
|
+
onError
|
|
108
|
+
];
|
|
109
|
+
$[0] = onError;
|
|
110
|
+
$[1] = store;
|
|
111
|
+
$[2] = t1;
|
|
112
|
+
$[3] = t2;
|
|
113
|
+
} else {
|
|
114
|
+
t1 = $[2];
|
|
115
|
+
t2 = $[3];
|
|
116
|
+
}
|
|
117
|
+
useLayoutEffect(t1, t2);
|
|
118
|
+
let t3;
|
|
119
|
+
let t4;
|
|
120
|
+
if ($[4] !== closeOnChange || $[5] !== store) {
|
|
121
|
+
t3 = ()=>{
|
|
122
|
+
store.setCloseKey(closeOnChange);
|
|
123
|
+
};
|
|
124
|
+
t4 = [
|
|
125
|
+
store,
|
|
126
|
+
closeOnChange
|
|
127
|
+
];
|
|
128
|
+
$[4] = closeOnChange;
|
|
129
|
+
$[5] = store;
|
|
130
|
+
$[6] = t3;
|
|
131
|
+
$[7] = t4;
|
|
132
|
+
} else {
|
|
133
|
+
t3 = $[6];
|
|
134
|
+
t4 = $[7];
|
|
135
|
+
}
|
|
136
|
+
useLayoutEffect(t3, t4);
|
|
137
|
+
let t5;
|
|
138
|
+
let t6;
|
|
139
|
+
if ($[8] !== store) {
|
|
140
|
+
t5 = ()=>{
|
|
141
|
+
store.attach();
|
|
142
|
+
};
|
|
143
|
+
t6 = [
|
|
144
|
+
store
|
|
145
|
+
];
|
|
146
|
+
$[8] = store;
|
|
147
|
+
$[9] = t5;
|
|
148
|
+
$[10] = t6;
|
|
149
|
+
} else {
|
|
150
|
+
t5 = $[9];
|
|
151
|
+
t6 = $[10];
|
|
152
|
+
}
|
|
153
|
+
useLayoutEffect(t5, t6);
|
|
154
|
+
let t7;
|
|
155
|
+
if ($[11] !== store.release) {
|
|
156
|
+
t7 = ()=>store.release;
|
|
157
|
+
$[11] = store.release;
|
|
158
|
+
$[12] = t7;
|
|
159
|
+
} else t7 = $[12];
|
|
160
|
+
let t8;
|
|
161
|
+
if ($[13] !== store) {
|
|
162
|
+
t8 = [
|
|
163
|
+
store
|
|
164
|
+
];
|
|
165
|
+
$[13] = store;
|
|
166
|
+
$[14] = t8;
|
|
167
|
+
} else t8 = $[14];
|
|
168
|
+
useEffect(t7, t8);
|
|
169
|
+
let t9;
|
|
170
|
+
if ($[15] !== instances || $[16] !== store) {
|
|
171
|
+
let t10;
|
|
172
|
+
if ($[18] !== store) {
|
|
173
|
+
t10 = (instance)=>/*#__PURE__*/ jsx(OverlayInstanceView, {
|
|
174
|
+
store: store,
|
|
175
|
+
instance: instance
|
|
176
|
+
}, instance.id);
|
|
177
|
+
$[18] = store;
|
|
178
|
+
$[19] = t10;
|
|
179
|
+
} else t10 = $[19];
|
|
180
|
+
t9 = instances.map(t10);
|
|
181
|
+
$[15] = instances;
|
|
182
|
+
$[16] = store;
|
|
183
|
+
$[17] = t9;
|
|
184
|
+
} else t9 = $[17];
|
|
185
|
+
let t10;
|
|
186
|
+
if ($[20] !== children || $[21] !== store || $[22] !== t9) {
|
|
187
|
+
t10 = /*#__PURE__*/ jsxs(OverlayStoreContext.Provider, {
|
|
188
|
+
value: store,
|
|
189
|
+
children: [
|
|
190
|
+
children,
|
|
191
|
+
t9
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
$[20] = children;
|
|
195
|
+
$[21] = store;
|
|
196
|
+
$[22] = t9;
|
|
197
|
+
$[23] = t10;
|
|
198
|
+
} else t10 = $[23];
|
|
199
|
+
return t10;
|
|
200
|
+
};
|
|
201
|
+
OverlayProvider.displayName = "OverlayProvider";
|
|
202
|
+
export { OverlayProvider };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { ErasedOverlayComponent, OverlayDefinition, OverlayPayload, OverlayProps, OverlayResult } from './types.js';
|
|
3
|
+
export interface InternalOverlayDefinition<Payload = unknown, Result = unknown> extends OverlayDefinition<Payload, Result> {
|
|
4
|
+
/** Cached per definition; the cache clears on rejection so the next call retries. */
|
|
5
|
+
load: () => Promise<ErasedOverlayComponent>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Describes an overlay once. `load` returns the component itself, never `React.lazy`;
|
|
9
|
+
* importing the definition does not load the overlay's code.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defineOverlay: <Props extends OverlayProps<never>>(load: () => Promise<ComponentType<Props> & {
|
|
12
|
+
readonly _result?: never;
|
|
13
|
+
}>) => OverlayDefinition<OverlayPayload<Props>, OverlayResult<Props>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const defineOverlay = (load)=>{
|
|
2
|
+
let cached;
|
|
3
|
+
const loadOnce = ()=>cached ??= new Promise((resolve)=>resolve(load())).then((component)=>component, (error)=>{
|
|
4
|
+
cached = void 0;
|
|
5
|
+
throw error;
|
|
6
|
+
});
|
|
7
|
+
const definition = {
|
|
8
|
+
load: loadOnce,
|
|
9
|
+
preload: ()=>loadOnce().then(()=>void 0, ()=>void 0)
|
|
10
|
+
};
|
|
11
|
+
return definition;
|
|
12
|
+
};
|
|
13
|
+
export { defineOverlay };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { defineOverlay } from './defineOverlay.js';
|
|
2
|
+
export { OverlayProvider } from './OverlayProvider.js';
|
|
3
|
+
export type { OverlayCloseKey, OverlayController, OverlayDefinition, OverlayPayload, OverlayProps, OverlayProviderProps, OverlayResult, OverlayRootProps, } from './types.js';
|
|
4
|
+
export { type UseOverlayReturn, useOverlay } from './useOverlay.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { InternalOverlayDefinition } from './defineOverlay.js';
|
|
2
|
+
import type { ErasedOverlayComponent, OverlayCloseKey } from './types.js';
|
|
3
|
+
/** How long a closed instance waits for its root's exit signal before it is dropped anyway. */
|
|
4
|
+
export declare const REMOVE_FALLBACK_MS = 1000;
|
|
5
|
+
export interface OverlayInstance {
|
|
6
|
+
readonly id: number;
|
|
7
|
+
readonly Component: ErasedOverlayComponent;
|
|
8
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly open: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface OverlayStore {
|
|
12
|
+
subscribe: (listener: () => void) => () => void;
|
|
13
|
+
/** Same array reference until something changes (useSyncExternalStore). */
|
|
14
|
+
getSnapshot: () => readonly OverlayInstance[];
|
|
15
|
+
open: (definition: InternalOverlayDefinition, payload?: object) => Promise<unknown>;
|
|
16
|
+
/** Settles with `result` (the first settle wins), sets `open: false` and starts the removal fallback. */
|
|
17
|
+
close: (id: number, result?: unknown) => void;
|
|
18
|
+
/** Drops the instance after its exit and clears its fallback timer. */
|
|
19
|
+
remove: (id: number) => void;
|
|
20
|
+
/** Render error: settles `undefined` if still pending, drops the instance, calls onError. */
|
|
21
|
+
fail: (id: number, error: unknown) => void;
|
|
22
|
+
/** The first call records the key; a different key sweeps every instance created before it. */
|
|
23
|
+
setCloseKey: (key: OverlayCloseKey) => void;
|
|
24
|
+
setOnError: (onError: (error: unknown) => void) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Provider mounted or revealed, including the re-run of a StrictMode replay. Cancels a pending
|
|
27
|
+
* `release`.
|
|
28
|
+
*/
|
|
29
|
+
attach: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Provider's passive cleanup: detaches one microtask later unless `attach` runs first. A
|
|
32
|
+
* StrictMode replay re-attaches synchronously, so only a real unmount detaches.
|
|
33
|
+
*/
|
|
34
|
+
release: () => void;
|
|
35
|
+
/** Settles everything `undefined`, drops all, and later open() calls resolve `undefined` at once. */
|
|
36
|
+
detach: () => void;
|
|
37
|
+
}
|
|
38
|
+
export declare const reportOverlayError: (error: unknown) => void;
|
|
39
|
+
export declare const createOverlayStore: () => OverlayStore;
|