@omerdlw/base-framework 1.0.6 → 2.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.
- package/dist/atoms/index.js +1 -103
- package/dist/atoms/index.js.map +1 -1
- package/dist/chunk-3BUP64Q6.js +105 -0
- package/dist/chunk-3BUP64Q6.js.map +1 -0
- package/dist/chunk-3MSK4XGK.js +9888 -0
- package/dist/chunk-3MSK4XGK.js.map +1 -0
- package/dist/chunk-4GMQKD6F.js +353 -0
- package/dist/chunk-4GMQKD6F.js.map +1 -0
- package/dist/chunk-65ZB4QTQ.js +888 -0
- package/dist/chunk-65ZB4QTQ.js.map +1 -0
- package/dist/chunk-6SG7V77J.js +577 -0
- package/dist/chunk-6SG7V77J.js.map +1 -0
- package/dist/chunk-7HQMXTNP.js +419 -0
- package/dist/chunk-7HQMXTNP.js.map +1 -0
- package/dist/chunk-7TAVYJ3A.js +371 -0
- package/dist/chunk-7TAVYJ3A.js.map +1 -0
- package/dist/chunk-AQ4BNXA2.js +349 -0
- package/dist/chunk-AQ4BNXA2.js.map +1 -0
- package/dist/chunk-CGHZSSFR.js +2166 -0
- package/dist/chunk-CGHZSSFR.js.map +1 -0
- package/dist/chunk-DGCQWQLZ.js +61 -0
- package/dist/chunk-DGCQWQLZ.js.map +1 -0
- package/dist/chunk-FIMPHODX.js +67 -0
- package/dist/chunk-FIMPHODX.js.map +1 -0
- package/dist/chunk-GF7TUX5I.js +1889 -0
- package/dist/chunk-GF7TUX5I.js.map +1 -0
- package/dist/chunk-JELG4JLT.js +454 -0
- package/dist/chunk-JELG4JLT.js.map +1 -0
- package/dist/chunk-K676GL7Z.js +51 -0
- package/dist/chunk-K676GL7Z.js.map +1 -0
- package/dist/chunk-KKQT46TP.js +26 -0
- package/dist/chunk-KKQT46TP.js.map +1 -0
- package/dist/chunk-QI3ALLIB.js +38 -0
- package/dist/chunk-QI3ALLIB.js.map +1 -0
- package/dist/chunk-QXR55VVS.js +1139 -0
- package/dist/chunk-QXR55VVS.js.map +1 -0
- package/dist/chunk-R2YGFJDJ.js +408 -0
- package/dist/chunk-R2YGFJDJ.js.map +1 -0
- package/dist/chunk-RFZQWLC5.js +27 -0
- package/dist/chunk-RFZQWLC5.js.map +1 -0
- package/dist/chunk-SYAVGTOX.js +521 -0
- package/dist/chunk-SYAVGTOX.js.map +1 -0
- package/dist/chunk-TV3WEF5G.js +784 -0
- package/dist/chunk-TV3WEF5G.js.map +1 -0
- package/dist/chunk-XASQT4CQ.js +280 -0
- package/dist/chunk-XASQT4CQ.js.map +1 -0
- package/dist/error/index.js +5 -682
- package/dist/error/index.js.map +1 -1
- package/dist/error/reporter.d.ts.map +1 -1
- package/dist/error/theme.d.ts +1 -1
- package/dist/error/theme.d.ts.map +1 -1
- package/dist/events.js +1 -7
- package/dist/events.js.map +1 -1
- package/dist/hooks/index.js +1 -358
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-global-event.d.ts +1 -1
- package/dist/index.js +18 -20029
- package/dist/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2035
- package/dist/kernel/index.js.map +1 -1
- package/dist/kernel/types.d.ts +1 -1
- package/dist/modules/ambient/analyze.d.ts +46 -0
- package/dist/modules/ambient/analyze.d.ts.map +1 -0
- package/dist/modules/ambient/constants.d.ts +1 -5
- package/dist/modules/ambient/constants.d.ts.map +1 -1
- package/dist/modules/ambient/context.d.ts.map +1 -1
- package/dist/modules/ambient/dom.d.ts +11 -12
- package/dist/modules/ambient/dom.d.ts.map +1 -1
- package/dist/modules/ambient/extractor.d.ts +10 -10
- package/dist/modules/ambient/extractor.d.ts.map +1 -1
- package/dist/modules/ambient/hooks.d.ts +1 -1
- package/dist/modules/ambient/hooks.d.ts.map +1 -1
- package/dist/modules/ambient/index.d.ts +6 -4
- package/dist/modules/ambient/index.d.ts.map +1 -1
- package/dist/modules/ambient/index.js +7 -762
- package/dist/modules/ambient/index.js.map +1 -1
- package/dist/modules/ambient/module.d.ts +1 -1
- package/dist/modules/ambient/module.d.ts.map +1 -1
- package/dist/modules/ambient/oklab.d.ts +36 -0
- package/dist/modules/ambient/oklab.d.ts.map +1 -0
- package/dist/modules/ambient/pipeline.d.ts +28 -0
- package/dist/modules/ambient/pipeline.d.ts.map +1 -0
- package/dist/modules/ambient/quantize.d.ts +22 -0
- package/dist/modules/ambient/quantize.d.ts.map +1 -0
- package/dist/modules/ambient/server/address.d.ts +8 -0
- package/dist/modules/ambient/server/address.d.ts.map +1 -0
- package/dist/modules/ambient/server/index.d.ts +53 -0
- package/dist/modules/ambient/server/index.d.ts.map +1 -0
- package/dist/modules/ambient/server/index.js +221 -0
- package/dist/modules/ambient/server/index.js.map +1 -0
- package/dist/modules/ambient/settings.d.ts +19 -0
- package/dist/modules/ambient/settings.d.ts.map +1 -0
- package/dist/modules/ambient/types.d.ts +105 -9
- package/dist/modules/ambient/types.d.ts.map +1 -1
- package/dist/modules/ambient/worker/index.d.ts +15 -0
- package/dist/modules/ambient/worker/index.d.ts.map +1 -0
- package/dist/modules/ambient/worker/index.js +114 -0
- package/dist/modules/ambient/worker/index.js.map +1 -0
- package/dist/modules/background/constants.d.ts +2 -2
- package/dist/modules/background/constants.d.ts.map +1 -1
- package/dist/modules/background/hooks.d.ts +1 -1
- package/dist/modules/background/index.js +6 -3078
- package/dist/modules/background/index.js.map +1 -1
- package/dist/modules/background/motion.d.ts +9 -7
- package/dist/modules/background/motion.d.ts.map +1 -1
- package/dist/modules/background/overlay.d.ts +3 -8
- package/dist/modules/background/overlay.d.ts.map +1 -1
- package/dist/modules/background/types.d.ts +16 -2
- package/dist/modules/background/types.d.ts.map +1 -1
- package/dist/modules/context-menu/constants.d.ts +2 -2
- package/dist/modules/context-menu/constants.d.ts.map +1 -1
- package/dist/modules/context-menu/hooks.d.ts +1 -1
- package/dist/modules/context-menu/index.js +10 -1896
- package/dist/modules/context-menu/index.js.map +1 -1
- package/dist/modules/context-menu/motion.d.ts +1 -8
- package/dist/modules/context-menu/motion.d.ts.map +1 -1
- package/dist/modules/context-menu/overlay.d.ts.map +1 -1
- package/dist/modules/context-menu/types.d.ts +16 -2
- package/dist/modules/context-menu/types.d.ts.map +1 -1
- package/dist/modules/controls/constants.d.ts +1 -1
- package/dist/modules/controls/constants.d.ts.map +1 -1
- package/dist/modules/controls/entries.d.ts +1 -1
- package/dist/modules/controls/hooks.d.ts +1 -1
- package/dist/modules/controls/index.js +4 -1110
- package/dist/modules/controls/index.js.map +1 -1
- package/dist/modules/controls/overlay.d.ts +1 -1
- package/dist/modules/controls/types.d.ts +2 -2
- package/dist/modules/dock/cards.d.ts +708 -24
- package/dist/modules/dock/cards.d.ts.map +1 -1
- package/dist/modules/dock/constants.d.ts +2 -2
- package/dist/modules/dock/constants.d.ts.map +1 -1
- package/dist/modules/dock/helpers.d.ts +2 -2
- package/dist/modules/dock/hooks.d.ts +2 -2
- package/dist/modules/dock/index.d.ts +1 -1
- package/dist/modules/dock/index.d.ts.map +1 -1
- package/dist/modules/dock/index.js +9 -12132
- package/dist/modules/dock/index.js.map +1 -1
- package/dist/modules/dock/module.d.ts +1 -1
- package/dist/modules/dock/motion.d.ts +41 -915
- package/dist/modules/dock/motion.d.ts.map +1 -1
- package/dist/modules/dock/overlay.d.ts.map +1 -1
- package/dist/modules/dock/runtime/dock.d.ts +1 -23
- package/dist/modules/dock/runtime/dock.d.ts.map +1 -1
- package/dist/modules/dock/styles.d.ts +4 -4
- package/dist/modules/dock/surface/hooks.d.ts +5 -20
- package/dist/modules/dock/surface/hooks.d.ts.map +1 -1
- package/dist/modules/dock/surface/machine.d.ts +4 -3
- package/dist/modules/dock/surface/machine.d.ts.map +1 -1
- package/dist/modules/dock/surface/stack.d.ts.map +1 -1
- package/dist/modules/dock/types.d.ts +158 -3
- package/dist/modules/dock/types.d.ts.map +1 -1
- package/dist/modules/index.js +16 -17883
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/loading/constants.d.ts +1 -1
- package/dist/modules/loading/constants.d.ts.map +1 -1
- package/dist/modules/loading/context.d.ts +1 -1
- package/dist/modules/loading/hooks.d.ts +1 -1
- package/dist/modules/loading/index.js +5 -1153
- package/dist/modules/loading/index.js.map +1 -1
- package/dist/modules/loading/types.d.ts +2 -2
- package/dist/modules/media/context.d.ts +1 -1
- package/dist/modules/media/index.js +3 -570
- package/dist/modules/media/index.js.map +1 -1
- package/dist/modules/media/types.d.ts +2 -2
- package/dist/modules/modal/constants.d.ts +2 -2
- package/dist/modules/modal/constants.d.ts.map +1 -1
- package/dist/modules/modal/context.d.ts +1 -1
- package/dist/modules/modal/hooks.d.ts +3 -3
- package/dist/modules/modal/index.js +8 -2355
- package/dist/modules/modal/index.js.map +1 -1
- package/dist/modules/modal/motion.d.ts +3 -8
- package/dist/modules/modal/motion.d.ts.map +1 -1
- package/dist/modules/modal/overlay.d.ts.map +1 -1
- package/dist/modules/modal/types.d.ts +21 -0
- package/dist/modules/modal/types.d.ts.map +1 -1
- package/dist/modules/notification/constants.d.ts +2 -2
- package/dist/modules/notification/constants.d.ts.map +1 -1
- package/dist/modules/notification/context.d.ts +1 -1
- package/dist/modules/notification/hooks.d.ts +1 -1
- package/dist/modules/notification/index.js +4 -828
- package/dist/modules/notification/index.js.map +1 -1
- package/dist/modules/notification/motion.d.ts +1 -7
- package/dist/modules/notification/motion.d.ts.map +1 -1
- package/dist/modules/notification/overlay.d.ts.map +1 -1
- package/dist/modules/notification/types.d.ts +9 -1
- package/dist/modules/notification/types.d.ts.map +1 -1
- package/dist/overlay-TZ6L52A5.js +9 -0
- package/dist/overlay-TZ6L52A5.js.map +1 -0
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +6 -1968
- package/dist/provider.js.map +1 -1
- package/dist/result.js +2 -63
- package/dist/result.js.map +1 -1
- package/dist/theme.d.ts +45 -8
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +3 -41
- package/dist/theme.js.map +1 -1
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +126 -155
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/motion-config.d.ts +44 -0
- package/dist/tokens/motion-config.d.ts.map +1 -0
- package/dist/tokens/motion.d.ts +23 -174
- package/dist/tokens/motion.d.ts.map +1 -1
- package/dist/utils/index.js +4 -82
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/report.d.ts.map +1 -1
- package/docs/README.md +1 -0
- package/docs/architecture-and-rules.md +4 -3
- package/docs/core-engine.md +7 -10
- package/docs/getting-started.md +4 -2
- package/docs/modules/ambient.md +194 -80
- package/docs/modules/background.md +3 -3
- package/docs/modules/context-menu.md +2 -2
- package/docs/modules/dock.md +8 -5
- package/docs/modules/modal.md +2 -2
- package/docs/modules/notification.md +2 -2
- package/docs/theming.md +81 -9
- package/package.json +22 -5
- package/templates/AGENTS.md +1 -1
- package/templates/motion/background.ts +17 -0
- package/templates/motion/context-menu.ts +63 -0
- package/templates/motion/dock.ts +327 -0
- package/templates/motion/modal.ts +79 -0
- package/templates/motion/notification.ts +27 -0
- package/templates/motion/tokens.ts +47 -0
- package/templates/tsconfig.json +7 -0
- package/dist/modules/ambient/color.d.ts +0 -21
- package/dist/modules/ambient/color.d.ts.map +0 -1
|
@@ -1,2358 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import dynamic from 'next/dynamic';
|
|
11
|
-
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __esm = (fn, res) => function __init() {
|
|
15
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
-
};
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
function Icon({
|
|
22
|
-
className = "center",
|
|
23
|
-
color,
|
|
24
|
-
icon,
|
|
25
|
-
onClick,
|
|
26
|
-
size = 20,
|
|
27
|
-
style,
|
|
28
|
-
...props
|
|
29
|
-
}) {
|
|
30
|
-
return /* @__PURE__ */ jsx(
|
|
31
|
-
Icon$1,
|
|
32
|
-
{
|
|
33
|
-
className,
|
|
34
|
-
height: size,
|
|
35
|
-
icon,
|
|
36
|
-
onClick,
|
|
37
|
-
style: { color, ...style },
|
|
38
|
-
width: size,
|
|
39
|
-
...props
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
var init_icon = __esm({
|
|
44
|
-
"src/atoms/icon.tsx"() {
|
|
45
|
-
"use client";
|
|
46
|
-
Icon.displayName = "Icon";
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
function Button({
|
|
50
|
-
ref,
|
|
51
|
-
children,
|
|
52
|
-
className,
|
|
53
|
-
disabled = false,
|
|
54
|
-
loading = false,
|
|
55
|
-
type = "button",
|
|
56
|
-
...props
|
|
57
|
-
}) {
|
|
58
|
-
return /* @__PURE__ */ jsx(
|
|
59
|
-
"button",
|
|
60
|
-
{
|
|
61
|
-
ref,
|
|
62
|
-
type,
|
|
63
|
-
disabled: disabled || loading,
|
|
64
|
-
"aria-busy": loading ? true : void 0,
|
|
65
|
-
className,
|
|
66
|
-
...props,
|
|
67
|
-
children
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
var init_button = __esm({
|
|
72
|
-
"src/atoms/button.tsx"() {
|
|
73
|
-
"use client";
|
|
74
|
-
Button.displayName = "Button";
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// src/atoms/index.ts
|
|
79
|
-
var init_atoms = __esm({
|
|
80
|
-
"src/atoms/index.ts"() {
|
|
81
|
-
"use client";
|
|
82
|
-
init_icon();
|
|
83
|
-
init_button();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// src/tokens/tokens.ts
|
|
88
|
-
var Z_INDEX;
|
|
89
|
-
var init_tokens = __esm({
|
|
90
|
-
"src/tokens/tokens.ts"() {
|
|
91
|
-
Z_INDEX = Object.freeze({
|
|
92
|
-
BACKGROUND: 0,
|
|
93
|
-
DOCK_BACKDROP: 100,
|
|
94
|
-
DOCK: 110,
|
|
95
|
-
NOTIFICATION: 120,
|
|
96
|
-
MODAL_BACKDROP: 130,
|
|
97
|
-
MODAL: 140,
|
|
98
|
-
SELECT: 150,
|
|
99
|
-
LOADING: 160,
|
|
100
|
-
ERROR_OVERLAY: 170,
|
|
101
|
-
CONTEXT_MENU_BACKDROP: 180,
|
|
102
|
-
CONTEXT_MENU: 190,
|
|
103
|
-
TOOLTIP: 200,
|
|
104
|
-
UI_ELEMENT: 10,
|
|
105
|
-
DOCK_CARD_BACKGROUND: 0,
|
|
106
|
-
DOCK_CARD_CONTENT: 10,
|
|
107
|
-
DOCK_CARD_STACK_BASE: 10,
|
|
108
|
-
DOCK_CARD_BADGE: 20,
|
|
109
|
-
DOCK_CARD_MEDIA: 30,
|
|
110
|
-
DOCK_BREADCRUMBS: 10,
|
|
111
|
-
DOCK_SURFACE_CONTROL: 10,
|
|
112
|
-
DOCK_SURFACE_POPOVER: 30,
|
|
113
|
-
DOCK_SURFACE_CENTER: 0,
|
|
114
|
-
MODAL_FRAME: 1,
|
|
115
|
-
MODAL_STICKY_HEADER: 10
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// src/tokens/motion.ts
|
|
121
|
-
var DURATION_TOKENS, EASING_CURVES, MOTION_EASINGS, MOTION_TIERS;
|
|
122
|
-
var init_motion = __esm({
|
|
123
|
-
"src/tokens/motion.ts"() {
|
|
124
|
-
DURATION_TOKENS = Object.freeze({
|
|
125
|
-
INSTANT: 0.08,
|
|
126
|
-
MICRO: 0.18,
|
|
127
|
-
FAST: 0.28,
|
|
128
|
-
BASE: 0.36,
|
|
129
|
-
MODERATE: 0.44,
|
|
130
|
-
SLOW: 0.58,
|
|
131
|
-
CINEMATIC: 0.86
|
|
132
|
-
});
|
|
133
|
-
EASING_CURVES = Object.freeze({
|
|
134
|
-
OUT_EXPO: [0.16, 1, 0.3, 1],
|
|
135
|
-
OUT_QUART: [0.25, 1, 0.5, 1],
|
|
136
|
-
OUT_QUINT: [0.22, 1, 0.36, 1],
|
|
137
|
-
IN_OUT_CUBIC: [0.65, 0, 0.35, 1],
|
|
138
|
-
IN_CUBIC: [0.5, 0, 1, 1],
|
|
139
|
-
OUT_BACK: [0.34, 1.56, 0.64, 1]
|
|
140
|
-
});
|
|
141
|
-
MOTION_EASINGS = Object.freeze({
|
|
142
|
-
ENTER: EASING_CURVES.OUT_QUART,
|
|
143
|
-
ENTER_EMPHASIZED: EASING_CURVES.OUT_EXPO,
|
|
144
|
-
EXIT: EASING_CURVES.IN_CUBIC
|
|
145
|
-
});
|
|
146
|
-
MOTION_TIERS = Object.freeze({
|
|
147
|
-
MICRO: Object.freeze({
|
|
148
|
-
distance: 4,
|
|
149
|
-
duration: DURATION_TOKENS.MICRO,
|
|
150
|
-
ease: MOTION_EASINGS.ENTER_EMPHASIZED,
|
|
151
|
-
scaleDelta: 8e-3
|
|
152
|
-
}),
|
|
153
|
-
FAST: Object.freeze({
|
|
154
|
-
distance: 9,
|
|
155
|
-
duration: DURATION_TOKENS.FAST,
|
|
156
|
-
ease: MOTION_EASINGS.ENTER_EMPHASIZED,
|
|
157
|
-
scaleDelta: 0.012
|
|
158
|
-
}),
|
|
159
|
-
STANDARD: Object.freeze({
|
|
160
|
-
distance: 18,
|
|
161
|
-
duration: DURATION_TOKENS.MODERATE,
|
|
162
|
-
ease: MOTION_EASINGS.ENTER,
|
|
163
|
-
scaleDelta: 0.018
|
|
164
|
-
}),
|
|
165
|
-
SURFACE: Object.freeze({
|
|
166
|
-
distance: 28,
|
|
167
|
-
duration: DURATION_TOKENS.SLOW,
|
|
168
|
-
ease: MOTION_EASINGS.ENTER_EMPHASIZED,
|
|
169
|
-
scaleDelta: 0.024
|
|
170
|
-
})
|
|
171
|
-
});
|
|
172
|
-
Object.freeze({
|
|
173
|
-
duration: DURATION_TOKENS.INSTANT,
|
|
174
|
-
ease: "linear"
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// src/tokens/index.ts
|
|
180
|
-
var init_tokens2 = __esm({
|
|
181
|
-
"src/tokens/index.ts"() {
|
|
182
|
-
init_tokens();
|
|
183
|
-
init_motion();
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
function cn(...inputs) {
|
|
187
|
-
return twMerge(clsx(inputs));
|
|
188
|
-
}
|
|
189
|
-
var init_cn = __esm({
|
|
190
|
-
"src/utils/cn.ts"() {
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// src/utils/string.ts
|
|
195
|
-
function trimToNull(value) {
|
|
196
|
-
if (value === null || value === void 0) return null;
|
|
197
|
-
const trimmed = String(value).trim();
|
|
198
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
199
|
-
}
|
|
200
|
-
var init_string = __esm({
|
|
201
|
-
"src/utils/string.ts"() {
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
// src/utils/dom.ts
|
|
206
|
-
function acquireGlobalScrollLock() {
|
|
207
|
-
if (typeof document === "undefined") return () => {
|
|
208
|
-
};
|
|
209
|
-
if (globalScrollLockCount === 0) {
|
|
210
|
-
globalScrollLockStyles = {
|
|
211
|
-
bodyOverflow: document.body.style.overflow,
|
|
212
|
-
bodyOverscrollBehavior: document.body.style.overscrollBehavior,
|
|
213
|
-
htmlOverflow: document.documentElement.style.overflow,
|
|
214
|
-
htmlOverscrollBehavior: document.documentElement.style.overscrollBehavior
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
globalScrollLockCount += 1;
|
|
218
|
-
document.body.style.overflow = "hidden";
|
|
219
|
-
document.body.style.overscrollBehavior = "none";
|
|
220
|
-
document.documentElement.style.overflow = "hidden";
|
|
221
|
-
document.documentElement.style.overscrollBehavior = "none";
|
|
222
|
-
let released = false;
|
|
223
|
-
return () => {
|
|
224
|
-
if (released) return;
|
|
225
|
-
released = true;
|
|
226
|
-
globalScrollLockCount = Math.max(0, globalScrollLockCount - 1);
|
|
227
|
-
if (globalScrollLockCount > 0 || !globalScrollLockStyles) return;
|
|
228
|
-
document.body.style.overflow = globalScrollLockStyles.bodyOverflow;
|
|
229
|
-
document.body.style.overscrollBehavior = globalScrollLockStyles.bodyOverscrollBehavior;
|
|
230
|
-
document.documentElement.style.overflow = globalScrollLockStyles.htmlOverflow;
|
|
231
|
-
document.documentElement.style.overscrollBehavior = globalScrollLockStyles.htmlOverscrollBehavior;
|
|
232
|
-
globalScrollLockStyles = null;
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
var isBrowser, globalScrollLockCount, globalScrollLockStyles;
|
|
236
|
-
var init_dom = __esm({
|
|
237
|
-
"src/utils/dom.ts"() {
|
|
238
|
-
isBrowser = typeof window !== "undefined";
|
|
239
|
-
globalScrollLockCount = 0;
|
|
240
|
-
globalScrollLockStyles = null;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// src/utils/object.ts
|
|
245
|
-
function isObject(value) {
|
|
246
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
247
|
-
}
|
|
248
|
-
function isPlainObject(value) {
|
|
249
|
-
if (!isObject(value)) return false;
|
|
250
|
-
const proto = Object.getPrototypeOf(value);
|
|
251
|
-
return proto === Object.prototype || proto === null;
|
|
252
|
-
}
|
|
253
|
-
var init_object = __esm({
|
|
254
|
-
"src/utils/object.ts"() {
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// src/utils/report.ts
|
|
259
|
-
function report(scope, error, level = "error") {
|
|
260
|
-
if (sink) {
|
|
261
|
-
try {
|
|
262
|
-
sink(scope, error, level);
|
|
263
|
-
return;
|
|
264
|
-
} catch {
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (process.env.NODE_ENV === "production" && typeof window !== "undefined") {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
console[level](`[${scope}]`, error);
|
|
271
|
-
}
|
|
272
|
-
var sink;
|
|
273
|
-
var init_report = __esm({
|
|
274
|
-
"src/utils/report.ts"() {
|
|
275
|
-
sink = null;
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// src/utils/store.ts
|
|
280
|
-
function freezeStoreSnapshot(state) {
|
|
281
|
-
if (process.env.NODE_ENV === "production" || !state || typeof state !== "object") {
|
|
282
|
-
return state;
|
|
283
|
-
}
|
|
284
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
285
|
-
const freeze = (value) => {
|
|
286
|
-
if (seen.has(value) || Object.isFrozen(value)) return;
|
|
287
|
-
seen.add(value);
|
|
288
|
-
const prototype = Object.getPrototypeOf(value);
|
|
289
|
-
if (Array.isArray(value) || prototype === Object.prototype || prototype === null) {
|
|
290
|
-
for (const key of Reflect.ownKeys(value)) {
|
|
291
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
292
|
-
if (descriptor && "value" in descriptor && descriptor.value !== null) {
|
|
293
|
-
if (typeof descriptor.value === "object") freeze(descriptor.value);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
Object.freeze(value);
|
|
298
|
-
};
|
|
299
|
-
freeze(state);
|
|
300
|
-
return state;
|
|
301
|
-
}
|
|
302
|
-
function createStore(initialState, { freezeSnapshots = true } = {}) {
|
|
303
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
304
|
-
const prepare = freezeSnapshots ? freezeStoreSnapshot : (state) => state;
|
|
305
|
-
let snapshot = prepare(initialState);
|
|
306
|
-
const publish = (nextStateOrUpdater) => {
|
|
307
|
-
const nextState = typeof nextStateOrUpdater === "function" ? nextStateOrUpdater(snapshot) : nextStateOrUpdater;
|
|
308
|
-
if (Object.is(snapshot, nextState)) return false;
|
|
309
|
-
snapshot = prepare(nextState);
|
|
310
|
-
for (const listener of listeners) {
|
|
311
|
-
try {
|
|
312
|
-
listener();
|
|
313
|
-
} catch (error) {
|
|
314
|
-
report("CoreStore subscriber", error, "warn");
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return true;
|
|
318
|
-
};
|
|
319
|
-
const setState = (updater) => {
|
|
320
|
-
if (typeof updater === "function") {
|
|
321
|
-
return publish(updater);
|
|
322
|
-
}
|
|
323
|
-
if (snapshot && typeof snapshot === "object" && updater && typeof updater === "object") {
|
|
324
|
-
return publish({ ...snapshot, ...updater });
|
|
325
|
-
}
|
|
326
|
-
return publish(updater);
|
|
327
|
-
};
|
|
328
|
-
return Object.freeze({
|
|
329
|
-
getSnapshot() {
|
|
330
|
-
return snapshot;
|
|
331
|
-
},
|
|
332
|
-
publish,
|
|
333
|
-
setState,
|
|
334
|
-
subscribe(listener) {
|
|
335
|
-
if (typeof listener !== "function") return () => {
|
|
336
|
-
};
|
|
337
|
-
listeners.add(listener);
|
|
338
|
-
return () => listeners.delete(listener);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
var init_store = __esm({
|
|
343
|
-
"src/utils/store.ts"() {
|
|
344
|
-
init_report();
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// src/utils/index.ts
|
|
349
|
-
var init_utils = __esm({
|
|
350
|
-
"src/utils/index.ts"() {
|
|
351
|
-
init_cn();
|
|
352
|
-
init_dom();
|
|
353
|
-
init_string();
|
|
354
|
-
init_object();
|
|
355
|
-
init_report();
|
|
356
|
-
init_store();
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
// src/kernel/types.ts
|
|
361
|
-
var init_types = __esm({
|
|
362
|
-
"src/kernel/types.ts"() {
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
// src/kernel/constants.ts
|
|
367
|
-
var DEFAULT_SOURCE, REGISTRY_SOURCES, REGISTRY_LIFECYCLES, REGISTRY_VALIDATION_MODES, REGISTRY_METADATA_KEYS, REGISTRY_LIFECYCLE_VALUES, REGISTRY_METADATA_KEY_SET, REGISTRY_SCOPE_KINDS;
|
|
368
|
-
var init_constants = __esm({
|
|
369
|
-
"src/kernel/constants.ts"() {
|
|
370
|
-
DEFAULT_SOURCE = "dynamic";
|
|
371
|
-
REGISTRY_SOURCES = Object.freeze({
|
|
372
|
-
STATIC: "static",
|
|
373
|
-
DYNAMIC: "dynamic",
|
|
374
|
-
USER: "user"
|
|
375
|
-
});
|
|
376
|
-
REGISTRY_LIFECYCLES = Object.freeze({
|
|
377
|
-
IMMEDIATE: "immediate",
|
|
378
|
-
GRACEFUL: "graceful",
|
|
379
|
-
PERSISTENT: "persistent",
|
|
380
|
-
ROUTE: "route"
|
|
381
|
-
});
|
|
382
|
-
REGISTRY_VALIDATION_MODES = Object.freeze({
|
|
383
|
-
WARN: "warn",
|
|
384
|
-
STRICT: "strict"
|
|
385
|
-
});
|
|
386
|
-
REGISTRY_METADATA_KEYS = Object.freeze([
|
|
387
|
-
"cleanup",
|
|
388
|
-
"cleanupDelayMs",
|
|
389
|
-
"instanceId",
|
|
390
|
-
"lifecycle",
|
|
391
|
-
"priority",
|
|
392
|
-
"source",
|
|
393
|
-
"scope",
|
|
394
|
-
"validation"
|
|
395
|
-
]);
|
|
396
|
-
Object.freeze({
|
|
397
|
-
[REGISTRY_SOURCES.STATIC]: 100,
|
|
398
|
-
[REGISTRY_SOURCES.DYNAMIC]: 200,
|
|
399
|
-
[REGISTRY_SOURCES.USER]: 300
|
|
400
|
-
});
|
|
401
|
-
Object.freeze({
|
|
402
|
-
[REGISTRY_SOURCES.STATIC]: 10,
|
|
403
|
-
[REGISTRY_SOURCES.DYNAMIC]: 20,
|
|
404
|
-
[REGISTRY_SOURCES.USER]: 30
|
|
405
|
-
});
|
|
406
|
-
REGISTRY_LIFECYCLE_VALUES = new Set(
|
|
407
|
-
Object.values(REGISTRY_LIFECYCLES)
|
|
408
|
-
);
|
|
409
|
-
REGISTRY_METADATA_KEY_SET = new Set(
|
|
410
|
-
REGISTRY_METADATA_KEYS
|
|
411
|
-
);
|
|
412
|
-
REGISTRY_SCOPE_KINDS = Object.freeze({
|
|
413
|
-
APP: "app",
|
|
414
|
-
SESSION: "session",
|
|
415
|
-
ROUTE: "route",
|
|
416
|
-
INSTANCE: "instance",
|
|
417
|
-
WORKSPACE: "workspace"
|
|
418
|
-
});
|
|
419
|
-
REGISTRY_SCOPE_KINDS.APP;
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
function getOrCreateGlobalContext(name, defaultValue) {
|
|
423
|
-
const sym = /* @__PURE__ */ Symbol.for(`@omerdlw/base-framework/context/${name}`);
|
|
424
|
-
const store = globalThis;
|
|
425
|
-
if (!store[sym]) {
|
|
426
|
-
store[sym] = createContext(defaultValue);
|
|
427
|
-
}
|
|
428
|
-
return store[sym];
|
|
429
|
-
}
|
|
430
|
-
var init_context_registry = __esm({
|
|
431
|
-
"src/kernel/context-registry.ts"() {
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
// src/kernel/utils.ts
|
|
436
|
-
function parseFiniteNumber(value) {
|
|
437
|
-
const parsed = Number(value);
|
|
438
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
439
|
-
}
|
|
440
|
-
function getValidString(value, fallback = null) {
|
|
441
|
-
return trimToNull(value) ?? fallback;
|
|
442
|
-
}
|
|
443
|
-
var init_utils2 = __esm({
|
|
444
|
-
"src/kernel/utils.ts"() {
|
|
445
|
-
init_utils();
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
// src/kernel/schema.ts
|
|
450
|
-
function resolveLifecycle(metadata, fallback) {
|
|
451
|
-
const lifecycle = metadata?.lifecycle ?? metadata?.cleanup;
|
|
452
|
-
return lifecycle && REGISTRY_LIFECYCLE_VALUES.has(lifecycle) ? lifecycle : fallback;
|
|
453
|
-
}
|
|
454
|
-
function validateRegistryMetadata(metadata) {
|
|
455
|
-
if (metadata === void 0 || metadata === null)
|
|
456
|
-
return { issues: [], valid: true };
|
|
457
|
-
if (!isObject(metadata))
|
|
458
|
-
return { issues: ["registry metadata must be an object"], valid: false };
|
|
459
|
-
const issues = [];
|
|
460
|
-
Object.keys(metadata).forEach((key) => {
|
|
461
|
-
if (!REGISTRY_METADATA_KEY_SET.has(key))
|
|
462
|
-
issues.push(`unknown registry metadata field: ${key}`);
|
|
463
|
-
});
|
|
464
|
-
if (metadata.source !== void 0 && !getValidString(metadata.source))
|
|
465
|
-
issues.push("source must be a non-empty string");
|
|
466
|
-
if (metadata.instanceId !== void 0 && !getValidString(metadata.instanceId))
|
|
467
|
-
issues.push("instanceId must be a non-empty string");
|
|
468
|
-
if (metadata.scope !== void 0 && !getValidString(metadata.scope))
|
|
469
|
-
issues.push("scope must be a non-empty string");
|
|
470
|
-
if (metadata.priority !== void 0 && parseFiniteNumber(metadata.priority) === null)
|
|
471
|
-
issues.push("priority must be a finite number");
|
|
472
|
-
if (metadata.cleanupDelayMs !== void 0) {
|
|
473
|
-
const delay = parseFiniteNumber(metadata.cleanupDelayMs);
|
|
474
|
-
if (delay === null || delay < 0)
|
|
475
|
-
issues.push("cleanupDelayMs must be a non-negative finite number");
|
|
476
|
-
}
|
|
477
|
-
const lifecycle = metadata.lifecycle ?? metadata.cleanup;
|
|
478
|
-
if (lifecycle !== void 0 && !REGISTRY_LIFECYCLE_VALUES.has(String(lifecycle))) {
|
|
479
|
-
issues.push(
|
|
480
|
-
`lifecycle must be one of: ${[...REGISTRY_LIFECYCLE_VALUES].join(", ")}`
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
if (metadata.validation !== void 0 && !Object.values(REGISTRY_VALIDATION_MODES).includes(
|
|
484
|
-
metadata.validation
|
|
485
|
-
)) {
|
|
486
|
-
issues.push(
|
|
487
|
-
`validation must be one of: ${Object.values(REGISTRY_VALIDATION_MODES).join(", ")}`
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
return { issues, valid: issues.length === 0 };
|
|
491
|
-
}
|
|
492
|
-
function normalizeRegistryMetadata(metadata, {
|
|
493
|
-
defaultCleanupDelayMs = null,
|
|
494
|
-
defaultLifecycle = null,
|
|
495
|
-
defaultSource = DEFAULT_SOURCE
|
|
496
|
-
} = {}) {
|
|
497
|
-
const registryMeta = isObject(metadata) ? metadata : {};
|
|
498
|
-
const normalizedDefaultDelay = parseFiniteNumber(defaultCleanupDelayMs);
|
|
499
|
-
const fallbackCleanupDelayMs = normalizedDefaultDelay !== null && normalizedDefaultDelay >= 0 ? normalizedDefaultDelay : null;
|
|
500
|
-
const fallbackLifecycle = defaultLifecycle && REGISTRY_LIFECYCLE_VALUES.has(defaultLifecycle) ? defaultLifecycle : null;
|
|
501
|
-
const source = getValidString(registryMeta.source) || getValidString(defaultSource, DEFAULT_SOURCE) || DEFAULT_SOURCE;
|
|
502
|
-
const scope = getValidString(registryMeta.scope);
|
|
503
|
-
const priority = parseFiniteNumber(registryMeta.priority);
|
|
504
|
-
const lifecycle = resolveLifecycle(registryMeta, fallbackLifecycle);
|
|
505
|
-
const validation = isValidationMode(registryMeta.validation) ? registryMeta.validation : null;
|
|
506
|
-
const cleanupDelayCandidate = parseFiniteNumber(registryMeta.cleanupDelayMs);
|
|
507
|
-
let cleanupDelayMs = cleanupDelayCandidate !== null && cleanupDelayCandidate >= 0 ? cleanupDelayCandidate : fallbackCleanupDelayMs;
|
|
508
|
-
if (lifecycle === REGISTRY_LIFECYCLES.IMMEDIATE) {
|
|
509
|
-
cleanupDelayMs = 0;
|
|
510
|
-
} else if ((lifecycle === REGISTRY_LIFECYCLES.GRACEFUL || lifecycle === REGISTRY_LIFECYCLES.ROUTE) && cleanupDelayMs === null) {
|
|
511
|
-
cleanupDelayMs = fallbackCleanupDelayMs;
|
|
512
|
-
}
|
|
513
|
-
return {
|
|
514
|
-
cleanupDelayMs,
|
|
515
|
-
lifecycle,
|
|
516
|
-
priority,
|
|
517
|
-
registerOptions: {
|
|
518
|
-
...priority !== null && { priority },
|
|
519
|
-
...validation === REGISTRY_VALIDATION_MODES.STRICT && { validation },
|
|
520
|
-
...scope && { scope }
|
|
521
|
-
},
|
|
522
|
-
source,
|
|
523
|
-
...scope && { scope },
|
|
524
|
-
...validation && { validation }
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
function isValidationMode(value) {
|
|
528
|
-
return Object.values(REGISTRY_VALIDATION_MODES).includes(value);
|
|
529
|
-
}
|
|
530
|
-
function pickRegistryMetadata(options) {
|
|
531
|
-
if (!isObject(options)) return {};
|
|
532
|
-
return Object.fromEntries(
|
|
533
|
-
REGISTRY_METADATA_KEYS.filter((key) => options[key] !== void 0).map(
|
|
534
|
-
(key) => [key, options[key]]
|
|
535
|
-
)
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
var init_schema = __esm({
|
|
539
|
-
"src/kernel/schema.ts"() {
|
|
540
|
-
init_constants();
|
|
541
|
-
init_utils();
|
|
542
|
-
init_utils2();
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
function useRequiredContext(context, hookName, providerName) {
|
|
546
|
-
const value = use(context);
|
|
547
|
-
if (value === null) {
|
|
548
|
-
throw new Error(`${hookName} must be used within ${providerName}`);
|
|
549
|
-
}
|
|
550
|
-
return value;
|
|
551
|
-
}
|
|
552
|
-
var init_use_required_context = __esm({
|
|
553
|
-
"src/hooks/use-required-context.ts"() {
|
|
554
|
-
"use client";
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
function useStore(store, selector = (state) => state, isEqual = Object.is) {
|
|
558
|
-
const cacheRef = useRef({
|
|
559
|
-
isEqual: null,
|
|
560
|
-
selected: void 0,
|
|
561
|
-
selector: null,
|
|
562
|
-
snapshot: null
|
|
563
|
-
});
|
|
564
|
-
const getSelectedSnapshot = useCallback(() => {
|
|
565
|
-
const snapshot = store.getSnapshot();
|
|
566
|
-
const cache = cacheRef.current;
|
|
567
|
-
if (cache.snapshot === snapshot && cache.selector === selector && cache.isEqual === isEqual) {
|
|
568
|
-
return cache.selected;
|
|
569
|
-
}
|
|
570
|
-
const selected = selector(snapshot);
|
|
571
|
-
if (cache.snapshot !== null && cache.isEqual === isEqual && isEqual(cache.selected, selected)) {
|
|
572
|
-
cache.snapshot = snapshot;
|
|
573
|
-
cache.selector = selector;
|
|
574
|
-
return cache.selected;
|
|
575
|
-
}
|
|
576
|
-
cacheRef.current = {
|
|
577
|
-
isEqual,
|
|
578
|
-
selected,
|
|
579
|
-
selector,
|
|
580
|
-
snapshot
|
|
581
|
-
};
|
|
582
|
-
return selected;
|
|
583
|
-
}, [isEqual, selector, store]);
|
|
584
|
-
return useSyncExternalStore(
|
|
585
|
-
store.subscribe,
|
|
586
|
-
getSelectedSnapshot,
|
|
587
|
-
getSelectedSnapshot
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
var init_use_store = __esm({
|
|
591
|
-
"src/hooks/use-store.ts"() {
|
|
592
|
-
"use client";
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
var useIsomorphicLayoutEffect;
|
|
596
|
-
var init_use_isomorphic_layout_effect = __esm({
|
|
597
|
-
"src/hooks/use-isomorphic-layout-effect.ts"() {
|
|
598
|
-
"use client";
|
|
599
|
-
init_utils();
|
|
600
|
-
useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
// src/hooks/index.ts
|
|
605
|
-
var init_hooks = __esm({
|
|
606
|
-
"src/hooks/index.ts"() {
|
|
607
|
-
"use client";
|
|
608
|
-
init_use_required_context();
|
|
609
|
-
init_use_store();
|
|
610
|
-
init_use_isomorphic_layout_effect();
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
function useRegistryActions() {
|
|
614
|
-
return useRequiredContext(
|
|
615
|
-
RegistryContext,
|
|
616
|
-
"useRegistryActions",
|
|
617
|
-
"RegistryProvider"
|
|
618
|
-
).actions;
|
|
619
|
-
}
|
|
620
|
-
function useRegistrySubscription() {
|
|
621
|
-
return useRequiredContext(
|
|
622
|
-
RegistryContext,
|
|
623
|
-
"useRegistrySubscription",
|
|
624
|
-
"RegistryProvider"
|
|
625
|
-
).subscription;
|
|
626
|
-
}
|
|
627
|
-
function useRegistryEntries(type) {
|
|
628
|
-
const { getEntriesSnapshot, subscribe } = useRegistrySubscription();
|
|
629
|
-
const subscribeToType = useCallback(
|
|
630
|
-
(listener) => subscribe(type, null, listener),
|
|
631
|
-
[subscribe, type]
|
|
632
|
-
);
|
|
633
|
-
const getEntries = useCallback(
|
|
634
|
-
() => getEntriesSnapshot(type),
|
|
635
|
-
[getEntriesSnapshot, type]
|
|
636
|
-
);
|
|
637
|
-
return useSyncExternalStore(subscribeToType, getEntries, getEntries);
|
|
638
|
-
}
|
|
639
|
-
var RegistryContext;
|
|
640
|
-
var init_provider = __esm({
|
|
641
|
-
"src/kernel/provider.tsx"() {
|
|
642
|
-
"use client";
|
|
643
|
-
init_hooks();
|
|
644
|
-
init_context_registry();
|
|
645
|
-
RegistryContext = getOrCreateGlobalContext(
|
|
646
|
-
"RegistryContext",
|
|
647
|
-
null
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
function selectModuleSlice(coreModule, config) {
|
|
652
|
-
const slice = coreModule.page?.select ? coreModule.page.select(config) : config[coreModule.id];
|
|
653
|
-
return slice ?? null;
|
|
654
|
-
}
|
|
655
|
-
function createModulePayload(modules, config, metadata = {}) {
|
|
656
|
-
const payload = {};
|
|
657
|
-
let hasSlices = false;
|
|
658
|
-
for (const coreModule of modules) {
|
|
659
|
-
if (!coreModule.page?.entries) continue;
|
|
660
|
-
const slice = selectModuleSlice(coreModule, config);
|
|
661
|
-
if (slice === null) continue;
|
|
662
|
-
payload[coreModule.id] = slice;
|
|
663
|
-
hasSlices = true;
|
|
664
|
-
}
|
|
665
|
-
if (!hasSlices) return null;
|
|
666
|
-
return {
|
|
667
|
-
...payload,
|
|
668
|
-
registry: {
|
|
669
|
-
...metadata,
|
|
670
|
-
...isObject(config.registry) ? config.registry : {}
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
function useInstalledModules() {
|
|
675
|
-
return use(ModuleHostContext)?.modules ?? EMPTY_MODULES;
|
|
676
|
-
}
|
|
677
|
-
var EMPTY_MODULES, PassthroughBoundary, ModuleHostContext;
|
|
678
|
-
var init_installed = __esm({
|
|
679
|
-
"src/kernel/installed.ts"() {
|
|
680
|
-
"use client";
|
|
681
|
-
init_utils();
|
|
682
|
-
init_context_registry();
|
|
683
|
-
EMPTY_MODULES = Object.freeze([]);
|
|
684
|
-
PassthroughBoundary = ({ children }) => children;
|
|
685
|
-
ModuleHostContext = getOrCreateGlobalContext("ModuleHostContext", null);
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
// src/kernel/handlers.ts
|
|
690
|
-
function isPersistentLifecycle(lifecycle) {
|
|
691
|
-
return lifecycle === REGISTRY_LIFECYCLES.PERSISTENT;
|
|
692
|
-
}
|
|
693
|
-
function runRegistrationBatch(context, executor) {
|
|
694
|
-
return typeof context.batch === "function" ? context.batch(executor) : executor(context);
|
|
695
|
-
}
|
|
696
|
-
function createEntryCleanupKey(type, key, source, instanceId, scope) {
|
|
697
|
-
return JSON.stringify([
|
|
698
|
-
"entry",
|
|
699
|
-
type,
|
|
700
|
-
key,
|
|
701
|
-
scope ?? null,
|
|
702
|
-
source,
|
|
703
|
-
instanceId
|
|
704
|
-
]);
|
|
705
|
-
}
|
|
706
|
-
function getCleanupScope(context) {
|
|
707
|
-
return context?.cleanupScope || /* @__PURE__ */ new Map();
|
|
708
|
-
}
|
|
709
|
-
function clearCleanupTimer(scope, cleanupKey) {
|
|
710
|
-
const lifecycle = scope.get(cleanupKey);
|
|
711
|
-
if (!lifecycle) return;
|
|
712
|
-
lifecycle.cancelled = true;
|
|
713
|
-
if (lifecycle.timerId !== null) clearTimeout(lifecycle.timerId);
|
|
714
|
-
scope.delete(cleanupKey);
|
|
715
|
-
}
|
|
716
|
-
function scheduleCleanup(scope, cleanupKey, callback, delayMs) {
|
|
717
|
-
clearCleanupTimer(scope, cleanupKey);
|
|
718
|
-
const lifecycle = {
|
|
719
|
-
cancelled: false,
|
|
720
|
-
timerId: null
|
|
721
|
-
};
|
|
722
|
-
lifecycle.timerId = setTimeout(() => {
|
|
723
|
-
if (lifecycle.cancelled || scope.get(cleanupKey) !== lifecycle) return;
|
|
724
|
-
scope.delete(cleanupKey);
|
|
725
|
-
callback();
|
|
726
|
-
}, delayMs);
|
|
727
|
-
scope.set(cleanupKey, lifecycle);
|
|
728
|
-
}
|
|
729
|
-
function collectModuleRegistrations(coreModule, slice, pageMetadata, context) {
|
|
730
|
-
const definition = coreModule.registry;
|
|
731
|
-
const toEntries = coreModule.page?.entries;
|
|
732
|
-
if (!definition || !toEntries || slice == null || slice === false) return [];
|
|
733
|
-
const type = coreModule.id;
|
|
734
|
-
const items = Array.isArray(slice) ? slice : [slice];
|
|
735
|
-
const registrations = [];
|
|
736
|
-
for (const item of items) {
|
|
737
|
-
if (item == null || item === false) continue;
|
|
738
|
-
const itemMetadata = isObject(item) && isObject(item.registry) ? item.registry : {};
|
|
739
|
-
const metadata = { ...pageMetadata, ...itemMetadata };
|
|
740
|
-
if (metadata.validation === "strict" && !validateRegistryMetadata(metadata).valid) {
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
743
|
-
const payload = isObject(item) ? Object.fromEntries(
|
|
744
|
-
Object.entries(item).filter(([key]) => key !== "registry")
|
|
745
|
-
) : item;
|
|
746
|
-
const { cleanupDelayMs, lifecycle, registerOptions, scope, source } = normalizeRegistryMetadata(metadata, {
|
|
747
|
-
defaultCleanupDelayMs: definition.cleanupDelayMs ?? null,
|
|
748
|
-
defaultLifecycle: definition.lifecycle,
|
|
749
|
-
defaultSource: DEFAULT_SOURCE
|
|
750
|
-
});
|
|
751
|
-
for (const { key, value } of toEntries(payload, context) ?? []) {
|
|
752
|
-
const validation = definition.validate?.(value);
|
|
753
|
-
if (validation && !validation.valid) {
|
|
754
|
-
report(`Registry ${type} config is invalid`, validation.issues, "warn");
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
registrations.push({
|
|
758
|
-
cleanupDelayMs,
|
|
759
|
-
cleanupKey: createEntryCleanupKey(
|
|
760
|
-
type,
|
|
761
|
-
key,
|
|
762
|
-
source,
|
|
763
|
-
context.instanceId,
|
|
764
|
-
scope
|
|
765
|
-
),
|
|
766
|
-
key,
|
|
767
|
-
lifecycle,
|
|
768
|
-
registerOptions,
|
|
769
|
-
scope,
|
|
770
|
-
source,
|
|
771
|
-
type,
|
|
772
|
-
value
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
return registrations;
|
|
777
|
-
}
|
|
778
|
-
function applyRegistryConfig(config, context) {
|
|
779
|
-
const modules = context.modules ?? [];
|
|
780
|
-
if (!config || modules.length === 0) return NO_CLEANUP;
|
|
781
|
-
const pageMetadata = isObject(config.registry) ? config.registry : {};
|
|
782
|
-
const slices = config;
|
|
783
|
-
const registrations = modules.flatMap((coreModule) => {
|
|
784
|
-
try {
|
|
785
|
-
return collectModuleRegistrations(
|
|
786
|
-
coreModule,
|
|
787
|
-
slices[coreModule.id],
|
|
788
|
-
pageMetadata,
|
|
789
|
-
context
|
|
790
|
-
);
|
|
791
|
-
} catch (error) {
|
|
792
|
-
report(`Registry apply (${coreModule.id})`, error);
|
|
793
|
-
return [];
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
if (registrations.length === 0) return NO_CLEANUP;
|
|
797
|
-
const cleanupScope = getCleanupScope(context);
|
|
798
|
-
const owner = (registration) => ({
|
|
799
|
-
instanceId: context.instanceId,
|
|
800
|
-
scope: registration.scope,
|
|
801
|
-
source: registration.source
|
|
802
|
-
});
|
|
803
|
-
runRegistrationBatch(context, (queue) => {
|
|
804
|
-
registrations.forEach(
|
|
805
|
-
({ cleanupKey, key, registerOptions, source, type, value }) => {
|
|
806
|
-
clearCleanupTimer(cleanupScope, cleanupKey);
|
|
807
|
-
queue.register(type, key, value, source, registerOptions);
|
|
808
|
-
}
|
|
809
|
-
);
|
|
810
|
-
});
|
|
811
|
-
return () => {
|
|
812
|
-
const immediate = [];
|
|
813
|
-
registrations.forEach((registration) => {
|
|
814
|
-
if (isPersistentLifecycle(registration.lifecycle)) return;
|
|
815
|
-
const { cleanupDelayMs, cleanupKey, key, type } = registration;
|
|
816
|
-
if (typeof cleanupDelayMs === "number" && cleanupDelayMs > 0) {
|
|
817
|
-
scheduleCleanup(
|
|
818
|
-
cleanupScope,
|
|
819
|
-
cleanupKey,
|
|
820
|
-
() => context.unregister(type, key, owner(registration)),
|
|
821
|
-
cleanupDelayMs
|
|
822
|
-
);
|
|
823
|
-
} else {
|
|
824
|
-
immediate.push(registration);
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
if (immediate.length === 0) return;
|
|
828
|
-
runRegistrationBatch(context, (queue) => {
|
|
829
|
-
immediate.forEach(
|
|
830
|
-
(registration) => queue.unregister(
|
|
831
|
-
registration.type,
|
|
832
|
-
registration.key,
|
|
833
|
-
owner(registration)
|
|
834
|
-
)
|
|
835
|
-
);
|
|
836
|
-
});
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
var NO_CLEANUP;
|
|
840
|
-
var init_handlers = __esm({
|
|
841
|
-
"src/kernel/handlers.ts"() {
|
|
842
|
-
init_constants();
|
|
843
|
-
init_schema();
|
|
844
|
-
init_utils();
|
|
845
|
-
NO_CLEANUP = () => {
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
});
|
|
849
|
-
function withInstanceId(instanceId, sourceOrOptions, optionsArg) {
|
|
850
|
-
if (typeof sourceOrOptions === "string") {
|
|
851
|
-
return {
|
|
852
|
-
optionsArg: { ...isObject(optionsArg) ? optionsArg : {}, instanceId },
|
|
853
|
-
sourceOrOptions
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
if (isObject(sourceOrOptions)) {
|
|
857
|
-
return {
|
|
858
|
-
optionsArg,
|
|
859
|
-
sourceOrOptions: { ...sourceOrOptions, instanceId }
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
return {
|
|
863
|
-
optionsArg: void 0,
|
|
864
|
-
sourceOrOptions: {
|
|
865
|
-
...isObject(optionsArg) ? optionsArg : {},
|
|
866
|
-
instanceId
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
function withInstanceIdForUnregister(instanceId, sourceOrOptions) {
|
|
871
|
-
if (typeof sourceOrOptions === "string") {
|
|
872
|
-
return { instanceId, source: sourceOrOptions };
|
|
873
|
-
}
|
|
874
|
-
if (isObject(sourceOrOptions)) {
|
|
875
|
-
return { ...sourceOrOptions, instanceId };
|
|
876
|
-
}
|
|
877
|
-
return { instanceId };
|
|
878
|
-
}
|
|
879
|
-
function resolveRegisterArgsWithInstance(instanceId, sourceOrOptions, optionsArg) {
|
|
880
|
-
const input = withInstanceId(instanceId, sourceOrOptions, optionsArg);
|
|
881
|
-
return [input.sourceOrOptions, input.optionsArg];
|
|
882
|
-
}
|
|
883
|
-
function createStableFunctionEntry(fn) {
|
|
884
|
-
const entry = {
|
|
885
|
-
current: fn,
|
|
886
|
-
stable(...args) {
|
|
887
|
-
return entry.current?.apply(this, args);
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
return entry;
|
|
891
|
-
}
|
|
892
|
-
function isDirectRegistryComponentPath(path, componentSlices) {
|
|
893
|
-
const match = /^config\.([^.[]+)\.[^.[]+$/.exec(path);
|
|
894
|
-
return Boolean(match && componentSlices.has(match[1]));
|
|
895
|
-
}
|
|
896
|
-
function isReactNodeLike(value) {
|
|
897
|
-
return value === null || value === void 0 || typeof value === "boolean" || typeof value === "string" || typeof value === "number" || isValidElement(value);
|
|
898
|
-
}
|
|
899
|
-
function isStabilizableObject(value) {
|
|
900
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && !isValidElement(value);
|
|
901
|
-
}
|
|
902
|
-
function hasSameObjectKeys(previousValue, nextValue) {
|
|
903
|
-
if (!isStabilizableObject(previousValue) || !isStabilizableObject(nextValue)) {
|
|
904
|
-
return false;
|
|
905
|
-
}
|
|
906
|
-
const previousKeys = Object.keys(previousValue);
|
|
907
|
-
const nextKeys = Object.keys(nextValue);
|
|
908
|
-
if (previousKeys.length !== nextKeys.length) return false;
|
|
909
|
-
return nextKeys.every(
|
|
910
|
-
(key) => Object.prototype.hasOwnProperty.call(previousValue, key)
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
function stabilizeRegistryValue(value, path, scope, previousValue, seen = /* @__PURE__ */ new WeakSet(), depth = 0) {
|
|
914
|
-
if (depth > MAX_STABILIZATION_DEPTH) return value;
|
|
915
|
-
if (typeof value === "function") {
|
|
916
|
-
const isComponent = value.name && /^[A-Z]/.test(value.name);
|
|
917
|
-
if (isComponent || isDirectRegistryComponentPath(path, scope.componentSlices)) {
|
|
918
|
-
return value;
|
|
919
|
-
}
|
|
920
|
-
scope.usedPaths.add(path);
|
|
921
|
-
let entry = scope.functionEntries.get(path);
|
|
922
|
-
if (!entry) {
|
|
923
|
-
entry = createStableFunctionEntry(value);
|
|
924
|
-
scope.functionEntries.set(path, entry);
|
|
925
|
-
} else {
|
|
926
|
-
entry.current = value;
|
|
927
|
-
}
|
|
928
|
-
return entry.stable;
|
|
929
|
-
}
|
|
930
|
-
if (value && typeof value === "object") {
|
|
931
|
-
if (seen.has(value)) return value;
|
|
932
|
-
seen.add(value);
|
|
933
|
-
}
|
|
934
|
-
if (isValidElement(value)) {
|
|
935
|
-
const nextProps = stabilizeRegistryValue(
|
|
936
|
-
value.props,
|
|
937
|
-
`${path}.props`,
|
|
938
|
-
scope,
|
|
939
|
-
isValidElement(previousValue) ? previousValue.props : void 0,
|
|
940
|
-
seen,
|
|
941
|
-
depth + 1
|
|
942
|
-
);
|
|
943
|
-
if (isValidElement(previousValue) && previousValue.type === value.type && previousValue.key === value.key && previousValue.props === nextProps) {
|
|
944
|
-
return previousValue;
|
|
945
|
-
}
|
|
946
|
-
return cloneElement(value, nextProps);
|
|
947
|
-
}
|
|
948
|
-
if (Array.isArray(value)) {
|
|
949
|
-
const nextValue = value.every(isReactNodeLike) ? Children.toArray(value) : value;
|
|
950
|
-
const previousArray = Array.isArray(previousValue) ? previousValue : null;
|
|
951
|
-
let hasChanged2 = !previousArray || previousArray.length !== nextValue.length;
|
|
952
|
-
const stabilizedValue2 = nextValue.map((item, index) => {
|
|
953
|
-
const nextItem = stabilizeRegistryValue(
|
|
954
|
-
item,
|
|
955
|
-
`${path}[${index}]`,
|
|
956
|
-
scope,
|
|
957
|
-
previousArray?.[index],
|
|
958
|
-
seen,
|
|
959
|
-
depth + 1
|
|
960
|
-
);
|
|
961
|
-
if (!previousArray || nextItem !== previousArray[index]) {
|
|
962
|
-
hasChanged2 = true;
|
|
963
|
-
}
|
|
964
|
-
return nextItem;
|
|
965
|
-
});
|
|
966
|
-
return !hasChanged2 ? previousArray : stabilizedValue2;
|
|
967
|
-
}
|
|
968
|
-
if (typeof value !== "object" || value === null) {
|
|
969
|
-
return value;
|
|
970
|
-
}
|
|
971
|
-
const source = value;
|
|
972
|
-
const previousRecord = previousValue;
|
|
973
|
-
const stabilizedValue = {};
|
|
974
|
-
const canReusePrevious = hasSameObjectKeys(previousValue, value);
|
|
975
|
-
let hasChanged = !canReusePrevious;
|
|
976
|
-
Object.keys(source).forEach((key) => {
|
|
977
|
-
const nextValue = stabilizeRegistryValue(
|
|
978
|
-
source[key],
|
|
979
|
-
`${path}.${key}`,
|
|
980
|
-
scope,
|
|
981
|
-
previousRecord?.[key],
|
|
982
|
-
seen,
|
|
983
|
-
depth + 1
|
|
984
|
-
);
|
|
985
|
-
stabilizedValue[key] = nextValue;
|
|
986
|
-
if (!canReusePrevious || nextValue !== previousRecord?.[key]) {
|
|
987
|
-
hasChanged = true;
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
return !hasChanged ? previousValue : stabilizedValue;
|
|
991
|
-
}
|
|
992
|
-
function useAppliedRegistryConfig(payload, context, componentSlices) {
|
|
993
|
-
const functionEntriesRef = useRef(/* @__PURE__ */ new Map());
|
|
994
|
-
const appliedRef = useRef(null);
|
|
995
|
-
useIsomorphicLayoutEffect(() => {
|
|
996
|
-
const previous = appliedRef.current;
|
|
997
|
-
if (previous && previous.payload === payload && previous.context === context) {
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
const functionEntries = functionEntriesRef.current;
|
|
1001
|
-
const usedPaths = /* @__PURE__ */ new Set();
|
|
1002
|
-
const config = stabilizeRegistryValue(
|
|
1003
|
-
payload,
|
|
1004
|
-
"config",
|
|
1005
|
-
{ componentSlices, functionEntries, usedPaths },
|
|
1006
|
-
previous?.config
|
|
1007
|
-
);
|
|
1008
|
-
functionEntries.forEach((_entry, path) => {
|
|
1009
|
-
if (!usedPaths.has(path)) functionEntries.delete(path);
|
|
1010
|
-
});
|
|
1011
|
-
if (previous && previous.config === config && previous.context === context) {
|
|
1012
|
-
previous.payload = payload;
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
previous?.cleanup();
|
|
1016
|
-
appliedRef.current = {
|
|
1017
|
-
cleanup: applyRegistryConfig(config, context),
|
|
1018
|
-
config,
|
|
1019
|
-
context,
|
|
1020
|
-
payload
|
|
1021
|
-
};
|
|
1022
|
-
});
|
|
1023
|
-
useIsomorphicLayoutEffect(
|
|
1024
|
-
() => () => {
|
|
1025
|
-
appliedRef.current?.cleanup();
|
|
1026
|
-
appliedRef.current = null;
|
|
1027
|
-
},
|
|
1028
|
-
[]
|
|
1029
|
-
);
|
|
1030
|
-
}
|
|
1031
|
-
function createRegistryApplyContext(actions, {
|
|
1032
|
-
cleanupScope = /* @__PURE__ */ new Map(),
|
|
1033
|
-
instanceId,
|
|
1034
|
-
modules = [],
|
|
1035
|
-
pathname
|
|
1036
|
-
}) {
|
|
1037
|
-
const stamp = (queue) => ({
|
|
1038
|
-
register: (type, key, item, sourceOrOptions, optionsArg) => queue.register(
|
|
1039
|
-
type,
|
|
1040
|
-
key,
|
|
1041
|
-
item,
|
|
1042
|
-
...resolveRegisterArgsWithInstance(
|
|
1043
|
-
instanceId,
|
|
1044
|
-
sourceOrOptions,
|
|
1045
|
-
optionsArg
|
|
1046
|
-
)
|
|
1047
|
-
),
|
|
1048
|
-
unregister: (type, key, sourceOrOptions) => queue.unregister(
|
|
1049
|
-
type,
|
|
1050
|
-
key,
|
|
1051
|
-
withInstanceIdForUnregister(instanceId, sourceOrOptions)
|
|
1052
|
-
)
|
|
1053
|
-
});
|
|
1054
|
-
return {
|
|
1055
|
-
...stamp(actions),
|
|
1056
|
-
batch: (executor) => typeof executor === "function" ? actions.batch((queue) => executor(stamp(queue))) : 0,
|
|
1057
|
-
cleanupScope,
|
|
1058
|
-
instanceId,
|
|
1059
|
-
modules,
|
|
1060
|
-
pathname
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
function useRegistry(config, metadata) {
|
|
1064
|
-
const { batch, register, unregister } = useRegistryActions();
|
|
1065
|
-
const pathname = usePathname();
|
|
1066
|
-
const modules = useInstalledModules();
|
|
1067
|
-
const instanceId = `registry-instance-${useId()}`;
|
|
1068
|
-
const [cleanupScope] = useState(
|
|
1069
|
-
() => /* @__PURE__ */ new Map()
|
|
1070
|
-
);
|
|
1071
|
-
const context = useMemo(
|
|
1072
|
-
() => createRegistryApplyContext(
|
|
1073
|
-
{ batch, register, unregister },
|
|
1074
|
-
{
|
|
1075
|
-
cleanupScope,
|
|
1076
|
-
instanceId,
|
|
1077
|
-
modules,
|
|
1078
|
-
pathname
|
|
1079
|
-
}
|
|
1080
|
-
),
|
|
1081
|
-
[batch, cleanupScope, instanceId, modules, pathname, register, unregister]
|
|
1082
|
-
);
|
|
1083
|
-
const payload = useMemo(
|
|
1084
|
-
() => config ? createModulePayload(modules, config, metadata) : null,
|
|
1085
|
-
[config, metadata, modules]
|
|
1086
|
-
);
|
|
1087
|
-
const componentSlices = useMemo(
|
|
1088
|
-
() => new Set(
|
|
1089
|
-
modules.filter(
|
|
1090
|
-
(coreModule) => coreModule.registry?.valueKind === "component"
|
|
1091
|
-
).map((coreModule) => coreModule.id)
|
|
1092
|
-
),
|
|
1093
|
-
[modules]
|
|
1094
|
-
);
|
|
1095
|
-
useAppliedRegistryConfig(payload, context, componentSlices);
|
|
1096
|
-
}
|
|
1097
|
-
var MAX_STABILIZATION_DEPTH;
|
|
1098
|
-
var init_hooks2 = __esm({
|
|
1099
|
-
"src/kernel/hooks.ts"() {
|
|
1100
|
-
"use client";
|
|
1101
|
-
init_hooks();
|
|
1102
|
-
init_handlers();
|
|
1103
|
-
init_installed();
|
|
1104
|
-
init_provider();
|
|
1105
|
-
init_utils();
|
|
1106
|
-
MAX_STABILIZATION_DEPTH = 64;
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
function defineModule(coreModule) {
|
|
1110
|
-
return Object.freeze({ ...coreModule });
|
|
1111
|
-
}
|
|
1112
|
-
function ModuleBoundary({
|
|
1113
|
-
children,
|
|
1114
|
-
name
|
|
1115
|
-
}) {
|
|
1116
|
-
const Boundary = use(ModuleHostContext)?.Boundary ?? PassthroughBoundary;
|
|
1117
|
-
return createElement(Boundary, { name }, children);
|
|
1118
|
-
}
|
|
1119
|
-
var init_module = __esm({
|
|
1120
|
-
"src/kernel/module.tsx"() {
|
|
1121
|
-
"use client";
|
|
1122
|
-
init_utils();
|
|
1123
|
-
init_installed();
|
|
1124
|
-
createStore(void 0);
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
// src/kernel/adapters.ts
|
|
1129
|
-
function useModuleRegistration(id, value, options) {
|
|
1130
|
-
const coreModule = useInstalledModules().find(
|
|
1131
|
-
(candidate) => candidate.id === id
|
|
1132
|
-
);
|
|
1133
|
-
const config = coreModule && options?.enabled !== false && value != null ? { [id]: value } : null;
|
|
1134
|
-
useRegistry(config, pickRegistryMetadata(options));
|
|
1135
|
-
}
|
|
1136
|
-
var init_adapters = __esm({
|
|
1137
|
-
"src/kernel/adapters.ts"() {
|
|
1138
|
-
"use client";
|
|
1139
|
-
init_schema();
|
|
1140
|
-
init_hooks2();
|
|
1141
|
-
init_installed();
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1144
|
-
|
|
1145
|
-
// src/kernel/index.ts
|
|
1146
|
-
var init_kernel = __esm({
|
|
1147
|
-
"src/kernel/index.ts"() {
|
|
1148
|
-
"use client";
|
|
1149
|
-
init_types();
|
|
1150
|
-
init_context_registry();
|
|
1151
|
-
init_provider();
|
|
1152
|
-
init_module();
|
|
1153
|
-
init_adapters();
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
function defineThemeSpec(id) {
|
|
1157
|
-
return Object.freeze({ id });
|
|
1158
|
-
}
|
|
1159
|
-
function useTheme(spec) {
|
|
1160
|
-
const config = useContext(ThemeContext).get(spec.id);
|
|
1161
|
-
if (!config) {
|
|
1162
|
-
throw new Error(
|
|
1163
|
-
`Theme "${spec.id}" is missing. Ensure its theme configuration is provided to <ThemeProvider themes={[...]}> (e.g. in src/config/ or your theme setup).`
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
return {
|
|
1167
|
-
slots: config.slots,
|
|
1168
|
-
styles: config.styles ?? {}
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
var EMPTY, ThemeContext;
|
|
1172
|
-
var init_theme = __esm({
|
|
1173
|
-
"src/theme.tsx"() {
|
|
1174
|
-
"use client";
|
|
1175
|
-
init_kernel();
|
|
1176
|
-
EMPTY = /* @__PURE__ */ new Map();
|
|
1177
|
-
ThemeContext = getOrCreateGlobalContext("ThemeContext", EMPTY);
|
|
1178
|
-
}
|
|
1179
|
-
});
|
|
1180
|
-
|
|
1181
|
-
// src/modules/modal/constants.ts
|
|
1182
|
-
var MODAL_POSITIONS, MODAL_CHROME, MODAL_BREAKPOINTS, SMOOTH_SCROLL_LOCK_EVENT, FOCUSABLE_SELECTOR, HEIGHT_CONSTRAINT_PATTERN, modalTheme;
|
|
1183
|
-
var init_constants2 = __esm({
|
|
1184
|
-
"src/modules/modal/constants.ts"() {
|
|
1185
|
-
init_theme();
|
|
1186
|
-
MODAL_POSITIONS = Object.freeze({
|
|
1187
|
-
BOTTOM: "bottom",
|
|
1188
|
-
CENTER: "center",
|
|
1189
|
-
LEFT: "left",
|
|
1190
|
-
RIGHT: "right",
|
|
1191
|
-
TOP: "top"
|
|
1192
|
-
});
|
|
1193
|
-
MODAL_CHROME = Object.freeze({
|
|
1194
|
-
BARE: "bare",
|
|
1195
|
-
PANEL: "panel"
|
|
1196
|
-
});
|
|
1197
|
-
MODAL_BREAKPOINTS = Object.freeze({
|
|
1198
|
-
MOBILE_MAX_WIDTH: 639
|
|
1199
|
-
});
|
|
1200
|
-
SMOOTH_SCROLL_LOCK_EVENT = "modal:smooth-scroll-lock";
|
|
1201
|
-
FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])';
|
|
1202
|
-
HEIGHT_CONSTRAINT_PATTERN = /(\s|^)(?:[\w-]+:)*(?:h|max-h)-/;
|
|
1203
|
-
modalTheme = defineThemeSpec("modal");
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
// src/modules/modal/motion.ts
|
|
1208
|
-
function toCssDistance(value = 0) {
|
|
1209
|
-
return typeof value === "number" ? `${Math.round(value)}px` : value;
|
|
1210
|
-
}
|
|
1211
|
-
function toGpuTransform(yOrConfig, scaleValue = 1) {
|
|
1212
|
-
if (typeof yOrConfig === "object" && yOrConfig !== null) {
|
|
1213
|
-
const xVal = yOrConfig.x ?? 0;
|
|
1214
|
-
const yVal = yOrConfig.y ?? 0;
|
|
1215
|
-
const sVal = yOrConfig.scale ?? 1;
|
|
1216
|
-
const safeScale2 = Number.parseFloat(String(sVal));
|
|
1217
|
-
const roundedScale2 = Number.isFinite(safeScale2) ? Math.round(safeScale2 * 1e3) / 1e3 : 1;
|
|
1218
|
-
return `translate3d(${toCssDistance(xVal)}, ${toCssDistance(yVal)}, 0) scale(${roundedScale2})`;
|
|
1219
|
-
}
|
|
1220
|
-
const safeY = Number.parseFloat(String(yOrConfig));
|
|
1221
|
-
const safeScale = Number.parseFloat(String(scaleValue));
|
|
1222
|
-
const roundedY = Number.isFinite(safeY) ? Math.round(safeY) : 0;
|
|
1223
|
-
const roundedScale = Number.isFinite(safeScale) ? Math.round(safeScale * 1e3) / 1e3 : 1;
|
|
1224
|
-
return `translate3d(0, ${roundedY}px, 0) scale(${roundedScale})`;
|
|
1225
|
-
}
|
|
1226
|
-
function buildVariants(tierName, {
|
|
1227
|
-
axis,
|
|
1228
|
-
direction = 1,
|
|
1229
|
-
fullSlide = false
|
|
1230
|
-
}) {
|
|
1231
|
-
const tier = MODAL_TIERS[tierName];
|
|
1232
|
-
const distance = fullSlide ? "100%" : tier.distance;
|
|
1233
|
-
const signedDistance = direction < 0 ? fullSlide ? "-100%" : -Number(distance) : distance;
|
|
1234
|
-
const transform = axis === "x" ? {
|
|
1235
|
-
x: signedDistance
|
|
1236
|
-
} : {
|
|
1237
|
-
y: signedDistance
|
|
1238
|
-
};
|
|
1239
|
-
return Object.freeze({
|
|
1240
|
-
exit: {
|
|
1241
|
-
opacity: 0,
|
|
1242
|
-
transform: toGpuTransform(transform),
|
|
1243
|
-
transition: MODAL_SURFACE_EXIT_TRANSITION
|
|
1244
|
-
},
|
|
1245
|
-
hidden: {
|
|
1246
|
-
opacity: 0,
|
|
1247
|
-
transform: toGpuTransform(transform)
|
|
1248
|
-
},
|
|
1249
|
-
visible: {
|
|
1250
|
-
opacity: 1,
|
|
1251
|
-
transform: toGpuTransform(),
|
|
1252
|
-
transition: MODAL_SURFACE_ENTER_TRANSITION
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
function getModalPositionVariants(position) {
|
|
1257
|
-
switch (position) {
|
|
1258
|
-
case MODAL_POSITIONS.BOTTOM:
|
|
1259
|
-
return BOTTOM_VARIANTS;
|
|
1260
|
-
case MODAL_POSITIONS.RIGHT:
|
|
1261
|
-
return RIGHT_VARIANTS;
|
|
1262
|
-
case MODAL_POSITIONS.LEFT:
|
|
1263
|
-
return LEFT_VARIANTS;
|
|
1264
|
-
case MODAL_POSITIONS.TOP:
|
|
1265
|
-
return TOP_VARIANTS;
|
|
1266
|
-
case MODAL_POSITIONS.CENTER:
|
|
1267
|
-
default:
|
|
1268
|
-
return CENTER_VARIANTS;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
function getModalTransition(position) {
|
|
1272
|
-
return position === MODAL_POSITIONS.CENTER ? MODAL_PANEL_SPRING : void 0;
|
|
1273
|
-
}
|
|
1274
|
-
var MODAL_EASINGS, MODAL_TIERS, MODAL_DURATIONS, MODAL_SPRINGS, MODAL_COMPOSITOR_STYLE, MODAL_PANEL_SPRING, MODAL_BACKDROP_TRANSITION, MODAL_BACKDROP_EXIT_TRANSITION, MODAL_SURFACE_ENTER_TRANSITION, MODAL_SURFACE_EXIT_TRANSITION, MODAL_BODY_ENTER_TRANSITION, MODAL_BODY_EXIT_TRANSITION, MODAL_CONTENT_VARIANTS, MODAL_HEADER_VARIANTS, MODAL_FOOTER_VARIANTS, modalBackdropVariants, CENTER_VARIANTS, BOTTOM_VARIANTS, RIGHT_VARIANTS, LEFT_VARIANTS, TOP_VARIANTS;
|
|
1275
|
-
var init_motion2 = __esm({
|
|
1276
|
-
"src/modules/modal/motion.ts"() {
|
|
1277
|
-
init_tokens2();
|
|
1278
|
-
init_constants2();
|
|
1279
|
-
MODAL_EASINGS = Object.freeze({
|
|
1280
|
-
CINEMATIC: EASING_CURVES.OUT_EXPO,
|
|
1281
|
-
EMPHASIZED: EASING_CURVES.OUT_EXPO,
|
|
1282
|
-
EXIT: EASING_CURVES.IN_CUBIC,
|
|
1283
|
-
FLUID: EASING_CURVES.OUT_QUART,
|
|
1284
|
-
FLUID_RESIZE: EASING_CURVES.OUT_QUART,
|
|
1285
|
-
PROGRESSIVE_EXIT: EASING_CURVES.IN_CUBIC,
|
|
1286
|
-
SOFT: EASING_CURVES.OUT_QUART,
|
|
1287
|
-
SOFT_EXIT: EASING_CURVES.IN_CUBIC
|
|
1288
|
-
});
|
|
1289
|
-
MODAL_TIERS = MOTION_TIERS;
|
|
1290
|
-
MODAL_DURATIONS = Object.freeze({
|
|
1291
|
-
BACKDROP_EXIT: DURATION_TOKENS.FAST,
|
|
1292
|
-
BODY: DURATION_TOKENS.BASE,
|
|
1293
|
-
BODY_EXIT: DURATION_TOKENS.FAST,
|
|
1294
|
-
EDGE_EXIT: DURATION_TOKENS.FAST,
|
|
1295
|
-
FAST: DURATION_TOKENS.FAST,
|
|
1296
|
-
MODERATE: DURATION_TOKENS.MODERATE,
|
|
1297
|
-
SLOT: DURATION_TOKENS.BASE,
|
|
1298
|
-
SLOT_EXIT: DURATION_TOKENS.MICRO,
|
|
1299
|
-
SLOW: DURATION_TOKENS.SLOW
|
|
1300
|
-
});
|
|
1301
|
-
MODAL_SPRINGS = Object.freeze({
|
|
1302
|
-
DECK: Object.freeze({
|
|
1303
|
-
damping: 28,
|
|
1304
|
-
mass: 0.85,
|
|
1305
|
-
stiffness: 240,
|
|
1306
|
-
type: "spring"
|
|
1307
|
-
}),
|
|
1308
|
-
MICRO: Object.freeze({
|
|
1309
|
-
damping: 32,
|
|
1310
|
-
mass: 0.3,
|
|
1311
|
-
stiffness: 480,
|
|
1312
|
-
type: "spring"
|
|
1313
|
-
}),
|
|
1314
|
-
PANEL: Object.freeze({
|
|
1315
|
-
damping: 28,
|
|
1316
|
-
mass: 0.85,
|
|
1317
|
-
stiffness: 240,
|
|
1318
|
-
type: "spring"
|
|
1319
|
-
})
|
|
1320
|
-
});
|
|
1321
|
-
MODAL_COMPOSITOR_STYLE = Object.freeze({
|
|
1322
|
-
WebkitBackfaceVisibility: "hidden",
|
|
1323
|
-
WebkitFontSmoothing: "antialiased",
|
|
1324
|
-
backfaceVisibility: "hidden",
|
|
1325
|
-
transform: "translateZ(0)",
|
|
1326
|
-
willChange: "transform, opacity"
|
|
1327
|
-
});
|
|
1328
|
-
MODAL_PANEL_SPRING = MODAL_SPRINGS.PANEL;
|
|
1329
|
-
MODAL_BACKDROP_TRANSITION = Object.freeze({
|
|
1330
|
-
duration: MODAL_DURATIONS.SLOW,
|
|
1331
|
-
ease: MODAL_EASINGS.FLUID,
|
|
1332
|
-
type: "tween"
|
|
1333
|
-
});
|
|
1334
|
-
MODAL_BACKDROP_EXIT_TRANSITION = Object.freeze({
|
|
1335
|
-
duration: MODAL_DURATIONS.BACKDROP_EXIT,
|
|
1336
|
-
ease: MODAL_EASINGS.FLUID,
|
|
1337
|
-
type: "tween"
|
|
1338
|
-
});
|
|
1339
|
-
MODAL_SURFACE_ENTER_TRANSITION = Object.freeze({
|
|
1340
|
-
duration: MODAL_DURATIONS.SLOW,
|
|
1341
|
-
ease: MODAL_EASINGS.FLUID,
|
|
1342
|
-
type: "tween"
|
|
1343
|
-
});
|
|
1344
|
-
MODAL_SURFACE_EXIT_TRANSITION = Object.freeze({
|
|
1345
|
-
duration: MODAL_DURATIONS.EDGE_EXIT,
|
|
1346
|
-
ease: MODAL_EASINGS.EXIT,
|
|
1347
|
-
type: "tween"
|
|
1348
|
-
});
|
|
1349
|
-
MODAL_BODY_ENTER_TRANSITION = Object.freeze({
|
|
1350
|
-
delay: 0.04,
|
|
1351
|
-
duration: MODAL_DURATIONS.BODY,
|
|
1352
|
-
ease: MODAL_EASINGS.FLUID,
|
|
1353
|
-
type: "tween"
|
|
1354
|
-
});
|
|
1355
|
-
MODAL_BODY_EXIT_TRANSITION = Object.freeze({
|
|
1356
|
-
duration: MODAL_DURATIONS.BODY_EXIT,
|
|
1357
|
-
ease: MODAL_EASINGS.EXIT,
|
|
1358
|
-
type: "tween"
|
|
1359
|
-
});
|
|
1360
|
-
MODAL_CONTENT_VARIANTS = Object.freeze({
|
|
1361
|
-
exit: {
|
|
1362
|
-
opacity: 0,
|
|
1363
|
-
transform: toGpuTransform({
|
|
1364
|
-
scale: 0.98,
|
|
1365
|
-
y: 12
|
|
1366
|
-
}),
|
|
1367
|
-
transition: MODAL_BODY_EXIT_TRANSITION
|
|
1368
|
-
},
|
|
1369
|
-
hidden: {
|
|
1370
|
-
opacity: 0,
|
|
1371
|
-
transform: toGpuTransform({
|
|
1372
|
-
scale: 0.98,
|
|
1373
|
-
y: 12
|
|
1374
|
-
})
|
|
1375
|
-
},
|
|
1376
|
-
visible: {
|
|
1377
|
-
opacity: 1,
|
|
1378
|
-
transform: toGpuTransform(),
|
|
1379
|
-
transition: MODAL_BODY_ENTER_TRANSITION
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
MODAL_HEADER_VARIANTS = Object.freeze({
|
|
1383
|
-
exit: {
|
|
1384
|
-
opacity: 0,
|
|
1385
|
-
transform: toGpuTransform({
|
|
1386
|
-
scale: 0.99,
|
|
1387
|
-
y: -6
|
|
1388
|
-
}),
|
|
1389
|
-
transition: {
|
|
1390
|
-
duration: MODAL_DURATIONS.SLOT_EXIT,
|
|
1391
|
-
ease: MODAL_EASINGS.EXIT
|
|
1392
|
-
}
|
|
1393
|
-
},
|
|
1394
|
-
hidden: {
|
|
1395
|
-
opacity: 0,
|
|
1396
|
-
transform: toGpuTransform({
|
|
1397
|
-
scale: 0.99,
|
|
1398
|
-
y: -6
|
|
1399
|
-
})
|
|
1400
|
-
},
|
|
1401
|
-
visible: {
|
|
1402
|
-
opacity: 1,
|
|
1403
|
-
transform: toGpuTransform(),
|
|
1404
|
-
transition: {
|
|
1405
|
-
delay: 0.02,
|
|
1406
|
-
duration: MODAL_DURATIONS.SLOT,
|
|
1407
|
-
ease: MODAL_EASINGS.FLUID
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
});
|
|
1411
|
-
MODAL_FOOTER_VARIANTS = Object.freeze({
|
|
1412
|
-
exit: {
|
|
1413
|
-
opacity: 0,
|
|
1414
|
-
transform: toGpuTransform({
|
|
1415
|
-
scale: 0.99,
|
|
1416
|
-
y: 6
|
|
1417
|
-
}),
|
|
1418
|
-
transition: {
|
|
1419
|
-
duration: MODAL_DURATIONS.SLOT_EXIT,
|
|
1420
|
-
ease: MODAL_EASINGS.EXIT
|
|
1421
|
-
}
|
|
1422
|
-
},
|
|
1423
|
-
hidden: {
|
|
1424
|
-
opacity: 0,
|
|
1425
|
-
transform: toGpuTransform({
|
|
1426
|
-
scale: 0.99,
|
|
1427
|
-
y: 6
|
|
1428
|
-
})
|
|
1429
|
-
},
|
|
1430
|
-
visible: {
|
|
1431
|
-
opacity: 1,
|
|
1432
|
-
transform: toGpuTransform(),
|
|
1433
|
-
transition: {
|
|
1434
|
-
delay: 0.06,
|
|
1435
|
-
duration: MODAL_DURATIONS.SLOT,
|
|
1436
|
-
ease: MODAL_EASINGS.FLUID
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
modalBackdropVariants = Object.freeze({
|
|
1441
|
-
exit: {
|
|
1442
|
-
opacity: 0,
|
|
1443
|
-
transition: MODAL_BACKDROP_EXIT_TRANSITION
|
|
1444
|
-
},
|
|
1445
|
-
hidden: {
|
|
1446
|
-
opacity: 0
|
|
1447
|
-
},
|
|
1448
|
-
visible: {
|
|
1449
|
-
opacity: 1,
|
|
1450
|
-
transition: MODAL_BACKDROP_TRANSITION
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
CENTER_VARIANTS = Object.freeze({
|
|
1454
|
-
exit: {
|
|
1455
|
-
opacity: 0,
|
|
1456
|
-
transform: toGpuTransform({
|
|
1457
|
-
scale: 0.96,
|
|
1458
|
-
y: 8
|
|
1459
|
-
}),
|
|
1460
|
-
transition: {
|
|
1461
|
-
duration: MODAL_DURATIONS.FAST,
|
|
1462
|
-
ease: MODAL_EASINGS.EXIT
|
|
1463
|
-
}
|
|
1464
|
-
},
|
|
1465
|
-
hidden: {
|
|
1466
|
-
opacity: 0,
|
|
1467
|
-
transform: toGpuTransform({
|
|
1468
|
-
scale: 0.95,
|
|
1469
|
-
y: 12
|
|
1470
|
-
})
|
|
1471
|
-
},
|
|
1472
|
-
visible: {
|
|
1473
|
-
opacity: 1,
|
|
1474
|
-
transform: toGpuTransform(),
|
|
1475
|
-
transition: {
|
|
1476
|
-
duration: MODAL_TIERS.STANDARD.duration,
|
|
1477
|
-
ease: MODAL_EASINGS.FLUID
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1481
|
-
BOTTOM_VARIANTS = buildVariants("SURFACE", {
|
|
1482
|
-
axis: "y",
|
|
1483
|
-
fullSlide: true
|
|
1484
|
-
});
|
|
1485
|
-
RIGHT_VARIANTS = buildVariants("SURFACE", {
|
|
1486
|
-
axis: "x",
|
|
1487
|
-
fullSlide: true
|
|
1488
|
-
});
|
|
1489
|
-
LEFT_VARIANTS = buildVariants("SURFACE", {
|
|
1490
|
-
axis: "x",
|
|
1491
|
-
direction: -1,
|
|
1492
|
-
fullSlide: true
|
|
1493
|
-
});
|
|
1494
|
-
TOP_VARIANTS = buildVariants("SURFACE", {
|
|
1495
|
-
axis: "y",
|
|
1496
|
-
direction: -1,
|
|
1497
|
-
fullSlide: true
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
});
|
|
1501
|
-
|
|
1502
|
-
// src/modules/modal/layout.ts
|
|
1503
|
-
function hasHeightConstraint(className) {
|
|
1504
|
-
return typeof className === "string" && HEIGHT_CONSTRAINT_PATTERN.test(className);
|
|
1505
|
-
}
|
|
1506
|
-
function isSidePosition(position) {
|
|
1507
|
-
return position === MODAL_POSITIONS.LEFT || position === MODAL_POSITIONS.RIGHT;
|
|
1508
|
-
}
|
|
1509
|
-
function isVerticalEdgePosition(position) {
|
|
1510
|
-
return position === MODAL_POSITIONS.TOP || position === MODAL_POSITIONS.BOTTOM;
|
|
1511
|
-
}
|
|
1512
|
-
function getModalPosition(position) {
|
|
1513
|
-
return position === MODAL_POSITIONS.TOP || position === MODAL_POSITIONS.BOTTOM || position === MODAL_POSITIONS.LEFT || position === MODAL_POSITIONS.RIGHT ? position : MODAL_POSITIONS.CENTER;
|
|
1514
|
-
}
|
|
1515
|
-
function getModalLayout(position, isMobile) {
|
|
1516
|
-
const resolved = getModalPosition(position);
|
|
1517
|
-
if (!isMobile) return resolved;
|
|
1518
|
-
if (resolved === MODAL_POSITIONS.TOP || resolved === MODAL_POSITIONS.BOTTOM)
|
|
1519
|
-
return `${resolved}-mobile`;
|
|
1520
|
-
if (resolved === MODAL_POSITIONS.LEFT || resolved === MODAL_POSITIONS.RIGHT)
|
|
1521
|
-
return "side-mobile";
|
|
1522
|
-
return resolved;
|
|
1523
|
-
}
|
|
1524
|
-
function getViewportIsMobile() {
|
|
1525
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
1526
|
-
return false;
|
|
1527
|
-
}
|
|
1528
|
-
return window.matchMedia(
|
|
1529
|
-
`(max-width: ${MODAL_BREAKPOINTS.MOBILE_MAX_WIDTH}px)`
|
|
1530
|
-
).matches;
|
|
1531
|
-
}
|
|
1532
|
-
function resolveActivePosition(position, responsivePosition, isMobileViewport) {
|
|
1533
|
-
if (!isPlainObject(responsivePosition)) return position;
|
|
1534
|
-
const responsive = isMobileViewport ? responsivePosition.mobile : responsivePosition.desktop;
|
|
1535
|
-
return responsive || position;
|
|
1536
|
-
}
|
|
1537
|
-
function normalizePosition(input) {
|
|
1538
|
-
if (typeof input === "string") {
|
|
1539
|
-
return { position: input, responsivePosition: null };
|
|
1540
|
-
}
|
|
1541
|
-
if (!isPlainObject(input)) {
|
|
1542
|
-
return { position: MODAL_POSITIONS.CENTER, responsivePosition: null };
|
|
1543
|
-
}
|
|
1544
|
-
return {
|
|
1545
|
-
position: resolveActivePosition(
|
|
1546
|
-
MODAL_POSITIONS.CENTER,
|
|
1547
|
-
input,
|
|
1548
|
-
getViewportIsMobile()
|
|
1549
|
-
),
|
|
1550
|
-
responsivePosition: input
|
|
1551
|
-
};
|
|
1552
|
-
}
|
|
1553
|
-
var init_layout = __esm({
|
|
1554
|
-
"src/modules/modal/layout.ts"() {
|
|
1555
|
-
init_utils();
|
|
1556
|
-
init_constants2();
|
|
1557
|
-
}
|
|
1558
|
-
});
|
|
1559
|
-
function hasSlotContent(value) {
|
|
1560
|
-
return value !== null && value !== void 0 && value !== false && value !== "";
|
|
1561
|
-
}
|
|
1562
|
-
function isHeaderConfig(value) {
|
|
1563
|
-
return Boolean(
|
|
1564
|
-
value && typeof value === "object" && !Array.isArray(value) && !isValidElement(value)
|
|
1565
|
-
);
|
|
1566
|
-
}
|
|
1567
|
-
function resolveHeaderActions(actions, close) {
|
|
1568
|
-
return typeof actions === "function" ? actions({ close }) : actions || null;
|
|
1569
|
-
}
|
|
1570
|
-
var init_header = __esm({
|
|
1571
|
-
"src/modules/modal/header.ts"() {
|
|
1572
|
-
}
|
|
1573
|
-
});
|
|
1574
|
-
|
|
1575
|
-
// src/modules/modal/identity.ts
|
|
1576
|
-
function getModalIdentity(input) {
|
|
1577
|
-
if (typeof input === "string") return { component: null, type: input };
|
|
1578
|
-
const options = typeof input === "function" ? { component: input } : input;
|
|
1579
|
-
const component = options.component ?? null;
|
|
1580
|
-
return {
|
|
1581
|
-
component,
|
|
1582
|
-
type: "type" in options && options.type || "id" in options && options.id || component?.displayName || component?.name || "modal"
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
|
-
function getModalLabel(modalType) {
|
|
1586
|
-
if (typeof modalType !== "string" || !modalType.trim()) return "Modal";
|
|
1587
|
-
return modalType.trim().toLowerCase().split(/[_-]+/).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
1588
|
-
}
|
|
1589
|
-
var init_identity = __esm({
|
|
1590
|
-
"src/modules/modal/identity.ts"() {
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
|
-
|
|
1594
|
-
// src/modules/modal/state.ts
|
|
1595
|
-
function createModalState(modalStack = []) {
|
|
1596
|
-
const activeModal = modalStack[modalStack.length - 1] || null;
|
|
1597
|
-
return {
|
|
1598
|
-
activeModalId: activeModal?.id || null,
|
|
1599
|
-
chrome: activeModal?.chrome || MODAL_CHROME.PANEL,
|
|
1600
|
-
headerActions: activeModal?.headerActions || null,
|
|
1601
|
-
isOpen: modalStack.length > 0,
|
|
1602
|
-
modalStack,
|
|
1603
|
-
modalType: activeModal?.modalType || null,
|
|
1604
|
-
position: activeModal?.position || MODAL_POSITIONS.CENTER,
|
|
1605
|
-
props: activeModal?.props || {},
|
|
1606
|
-
responsivePosition: activeModal?.responsivePosition || null,
|
|
1607
|
-
showClose: activeModal?.showClose ?? true,
|
|
1608
|
-
title: activeModal?.title || null
|
|
1609
|
-
};
|
|
1610
|
-
}
|
|
1611
|
-
var INITIAL_MODAL_STATE;
|
|
1612
|
-
var init_state = __esm({
|
|
1613
|
-
"src/modules/modal/state.ts"() {
|
|
1614
|
-
init_constants2();
|
|
1615
|
-
INITIAL_MODAL_STATE = createModalState([]);
|
|
1616
|
-
}
|
|
1617
|
-
});
|
|
1618
|
-
function ModalProvider({
|
|
1619
|
-
children,
|
|
1620
|
-
modalRenderer: ModalRenderer = null
|
|
1621
|
-
}) {
|
|
1622
|
-
const [store] = useState(
|
|
1623
|
-
() => createStore(INITIAL_MODAL_STATE, { freezeSnapshots: false })
|
|
1624
|
-
);
|
|
1625
|
-
const modalStackRef = useRef([]);
|
|
1626
|
-
const pendingRef = useRef(/* @__PURE__ */ new Map());
|
|
1627
|
-
const modalIdRef = useRef(0);
|
|
1628
|
-
const syncModalStack = useCallback(
|
|
1629
|
-
(nextStack) => {
|
|
1630
|
-
modalStackRef.current = nextStack;
|
|
1631
|
-
store.publish(createModalState(nextStack));
|
|
1632
|
-
},
|
|
1633
|
-
[store]
|
|
1634
|
-
);
|
|
1635
|
-
const settleModal = useCallback((modalId, result) => {
|
|
1636
|
-
const pending = pendingRef.current.get(modalId);
|
|
1637
|
-
if (!pending) return;
|
|
1638
|
-
pendingRef.current.delete(modalId);
|
|
1639
|
-
try {
|
|
1640
|
-
const outcome = pending.onClose?.(result);
|
|
1641
|
-
if (outcome instanceof Promise) {
|
|
1642
|
-
outcome.catch((error) => report("Modal onClose", error));
|
|
1643
|
-
}
|
|
1644
|
-
} catch (error) {
|
|
1645
|
-
report("Modal onClose", error);
|
|
1646
|
-
}
|
|
1647
|
-
pending.resolve(result);
|
|
1648
|
-
}, []);
|
|
1649
|
-
const openModal = useCallback(
|
|
1650
|
-
(modalInput, options = {}) => {
|
|
1651
|
-
if (!modalInput) return Promise.resolve(null);
|
|
1652
|
-
const stack = modalStackRef.current;
|
|
1653
|
-
const { component, type } = getModalIdentity(modalInput);
|
|
1654
|
-
const topEntry = stack[stack.length - 1];
|
|
1655
|
-
if (topEntry && (topEntry.modalType === type || component && topEntry.component === component)) {
|
|
1656
|
-
return Promise.resolve(null);
|
|
1657
|
-
}
|
|
1658
|
-
const definition = typeof modalInput === "object" ? modalInput : void 0;
|
|
1659
|
-
const merged = {
|
|
1660
|
-
...definition,
|
|
1661
|
-
...options
|
|
1662
|
-
};
|
|
1663
|
-
const data = { ...definition?.defaultData, ...options.data };
|
|
1664
|
-
const modalId = ++modalIdRef.current;
|
|
1665
|
-
const entry = {
|
|
1666
|
-
chrome: merged.chrome || MODAL_CHROME.PANEL,
|
|
1667
|
-
component,
|
|
1668
|
-
headerActions: merged.actions || null,
|
|
1669
|
-
id: modalId,
|
|
1670
|
-
modalType: type,
|
|
1671
|
-
props: data,
|
|
1672
|
-
showClose: merged.showClose ?? true,
|
|
1673
|
-
title: typeof merged.title === "function" ? merged.title(data) : merged.title ?? null,
|
|
1674
|
-
...normalizePosition(merged.position)
|
|
1675
|
-
};
|
|
1676
|
-
return new Promise((resolve) => {
|
|
1677
|
-
pendingRef.current.set(modalId, { onClose: merged.onClose, resolve });
|
|
1678
|
-
syncModalStack([...stack, entry]);
|
|
1679
|
-
});
|
|
1680
|
-
},
|
|
1681
|
-
[syncModalStack]
|
|
1682
|
-
);
|
|
1683
|
-
const closeModal = useCallback(
|
|
1684
|
-
(result = null, targetModalId = null) => {
|
|
1685
|
-
const stack = modalStackRef.current;
|
|
1686
|
-
const modalId = targetModalId || stack[stack.length - 1]?.id;
|
|
1687
|
-
if (!modalId || !stack.some((entry) => entry.id === modalId)) return;
|
|
1688
|
-
syncModalStack(stack.filter((entry) => entry.id !== modalId));
|
|
1689
|
-
settleModal(modalId, result);
|
|
1690
|
-
},
|
|
1691
|
-
[settleModal, syncModalStack]
|
|
1692
|
-
);
|
|
1693
|
-
const closeAllModals = useCallback(
|
|
1694
|
-
(result = null) => {
|
|
1695
|
-
const stack = modalStackRef.current;
|
|
1696
|
-
if (stack.length === 0) return;
|
|
1697
|
-
syncModalStack([]);
|
|
1698
|
-
stack.forEach((entry) => settleModal(entry.id, result));
|
|
1699
|
-
},
|
|
1700
|
-
[settleModal, syncModalStack]
|
|
1701
|
-
);
|
|
1702
|
-
const actionsValue = useMemo(
|
|
1703
|
-
() => ({ closeAllModals, closeModal, openModal }),
|
|
1704
|
-
[openModal, closeModal, closeAllModals]
|
|
1705
|
-
);
|
|
1706
|
-
const contextValue = useMemo(
|
|
1707
|
-
() => ({ actions: actionsValue, store }),
|
|
1708
|
-
[actionsValue, store]
|
|
1709
|
-
);
|
|
1710
|
-
return /* @__PURE__ */ jsxs(ModalContext, { value: contextValue, children: [
|
|
1711
|
-
ModalRenderer && /* @__PURE__ */ jsx(ModalRenderer, {}),
|
|
1712
|
-
children
|
|
1713
|
-
] });
|
|
1714
|
-
}
|
|
1715
|
-
var ModalContext;
|
|
1716
|
-
var init_context = __esm({
|
|
1717
|
-
"src/modules/modal/context.tsx"() {
|
|
1718
|
-
"use client";
|
|
1719
|
-
init_kernel();
|
|
1720
|
-
init_utils();
|
|
1721
|
-
init_constants2();
|
|
1722
|
-
init_state();
|
|
1723
|
-
init_identity();
|
|
1724
|
-
init_layout();
|
|
1725
|
-
ModalContext = getOrCreateGlobalContext(
|
|
1726
|
-
"ModalContext",
|
|
1727
|
-
null
|
|
1728
|
-
);
|
|
1729
|
-
}
|
|
1730
|
-
});
|
|
1731
|
-
|
|
1732
|
-
// src/modules/modal/dom.ts
|
|
1733
|
-
function dispatchSmoothScrollLock(locked) {
|
|
1734
|
-
if (typeof window === "undefined") return;
|
|
1735
|
-
window.dispatchEvent(
|
|
1736
|
-
new CustomEvent(SMOOTH_SCROLL_LOCK_EVENT, {
|
|
1737
|
-
detail: { locked, source: "modal" }
|
|
1738
|
-
})
|
|
1739
|
-
);
|
|
1740
|
-
}
|
|
1741
|
-
function getFocusableElements(container) {
|
|
1742
|
-
if (!container || typeof container.querySelectorAll !== "function") return [];
|
|
1743
|
-
return Array.from(
|
|
1744
|
-
container.querySelectorAll(FOCUSABLE_SELECTOR)
|
|
1745
|
-
).filter(
|
|
1746
|
-
(element) => !element.hasAttribute("disabled") && element.getAttribute("aria-hidden") !== "true"
|
|
1747
|
-
);
|
|
1748
|
-
}
|
|
1749
|
-
function trapFocus(event, container) {
|
|
1750
|
-
if (event.key !== "Tab" || !container) return;
|
|
1751
|
-
const elements = getFocusableElements(container);
|
|
1752
|
-
if (elements.length === 0) return;
|
|
1753
|
-
const firstElement = elements[0];
|
|
1754
|
-
const lastElement = elements[elements.length - 1];
|
|
1755
|
-
if (event.shiftKey) {
|
|
1756
|
-
if (document.activeElement === firstElement) {
|
|
1757
|
-
event.preventDefault();
|
|
1758
|
-
lastElement?.focus();
|
|
1759
|
-
}
|
|
1760
|
-
} else {
|
|
1761
|
-
if (document.activeElement === lastElement) {
|
|
1762
|
-
event.preventDefault();
|
|
1763
|
-
firstElement?.focus();
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
var init_dom2 = __esm({
|
|
1768
|
-
"src/modules/modal/dom.ts"() {
|
|
1769
|
-
init_constants2();
|
|
1770
|
-
}
|
|
1771
|
-
});
|
|
1772
|
-
function useModalRegistration(config, options) {
|
|
1773
|
-
useModuleRegistration("modal", config, options);
|
|
1774
|
-
}
|
|
1775
|
-
function useModalRegistryEntries() {
|
|
1776
|
-
const entries = useRegistryEntries("modal");
|
|
1777
|
-
return useMemo(() => ({ get: (type) => entries[type] }), [entries]);
|
|
1778
|
-
}
|
|
1779
|
-
function useModalActions() {
|
|
1780
|
-
return useRequiredContext(ModalContext, "useModalActions", "ModalProvider").actions;
|
|
1781
|
-
}
|
|
1782
|
-
function useModalState() {
|
|
1783
|
-
const { store } = useRequiredContext(
|
|
1784
|
-
ModalContext,
|
|
1785
|
-
"useModalState",
|
|
1786
|
-
"ModalProvider"
|
|
1787
|
-
);
|
|
1788
|
-
return useStore(store);
|
|
1789
|
-
}
|
|
1790
|
-
function useModal(modalInput) {
|
|
1791
|
-
const actions = useModalActions();
|
|
1792
|
-
const state = useModalState();
|
|
1793
|
-
return useMemo(() => {
|
|
1794
|
-
if (!modalInput) return { ...actions, ...state };
|
|
1795
|
-
const { component, type } = getModalIdentity(modalInput);
|
|
1796
|
-
const isOpen = state.modalStack.some(
|
|
1797
|
-
(entry) => entry.modalType === type || component && entry.component === component
|
|
1798
|
-
);
|
|
1799
|
-
const open = (data, overrides) => actions.openModal(modalInput, { ...overrides, data });
|
|
1800
|
-
const controls = {
|
|
1801
|
-
close: actions.closeModal,
|
|
1802
|
-
closeAll: actions.closeAllModals,
|
|
1803
|
-
isOpen,
|
|
1804
|
-
state
|
|
1805
|
-
};
|
|
1806
|
-
return Object.assign([open, controls], controls, { open });
|
|
1807
|
-
}, [actions, modalInput, state]);
|
|
1808
|
-
}
|
|
1809
|
-
function useModalLayerModel({
|
|
1810
|
-
closeModal,
|
|
1811
|
-
entry,
|
|
1812
|
-
isMobileViewport,
|
|
1813
|
-
isTopModal,
|
|
1814
|
-
modalStack,
|
|
1815
|
-
registry,
|
|
1816
|
-
stackIndex
|
|
1817
|
-
}) {
|
|
1818
|
-
const modalRef = useRef(null);
|
|
1819
|
-
const activePosition = useMemo(
|
|
1820
|
-
() => resolveActivePosition(
|
|
1821
|
-
entry.position,
|
|
1822
|
-
entry.responsivePosition,
|
|
1823
|
-
isMobileViewport
|
|
1824
|
-
),
|
|
1825
|
-
[entry.position, entry.responsivePosition, isMobileViewport]
|
|
1826
|
-
);
|
|
1827
|
-
const ActiveModalComponent = entry.component || registry.get(entry.modalType);
|
|
1828
|
-
const isPanelChrome = entry.chrome !== MODAL_CHROME.BARE;
|
|
1829
|
-
const isLeftModal = activePosition === MODAL_POSITIONS.LEFT;
|
|
1830
|
-
const isSide = isSidePosition(activePosition);
|
|
1831
|
-
const isVerticalEdge = isVerticalEdgePosition(activePosition);
|
|
1832
|
-
const previousEntry = modalStack[stackIndex - 1] || null;
|
|
1833
|
-
const baseZIndex = Z_INDEX.MODAL;
|
|
1834
|
-
useEffect(() => {
|
|
1835
|
-
if (!isTopModal || !modalRef.current) return;
|
|
1836
|
-
const previouslyFocusedElement = document.activeElement;
|
|
1837
|
-
const initialElements = getFocusableElements(modalRef.current);
|
|
1838
|
-
if (initialElements.length > 0) initialElements[0].focus();
|
|
1839
|
-
const handleKeyDown = (event) => {
|
|
1840
|
-
if (event.key === "Escape") closeModal(null, entry.id);
|
|
1841
|
-
else trapFocus(event, modalRef.current);
|
|
1842
|
-
};
|
|
1843
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
1844
|
-
return () => {
|
|
1845
|
-
window.removeEventListener("keydown", handleKeyDown);
|
|
1846
|
-
if (previouslyFocusedElement?.isConnected)
|
|
1847
|
-
previouslyFocusedElement.focus();
|
|
1848
|
-
};
|
|
1849
|
-
}, [closeModal, entry.id, isTopModal]);
|
|
1850
|
-
return {
|
|
1851
|
-
modalRef,
|
|
1852
|
-
activePosition,
|
|
1853
|
-
ActiveModalComponent,
|
|
1854
|
-
isPanelChrome,
|
|
1855
|
-
isLeftModal,
|
|
1856
|
-
isSide,
|
|
1857
|
-
isVerticalEdge,
|
|
1858
|
-
previousEntry,
|
|
1859
|
-
baseZIndex
|
|
1860
|
-
};
|
|
1861
|
-
}
|
|
1862
|
-
function useModalContainerModel() {
|
|
1863
|
-
return { theme: useTheme(modalTheme) };
|
|
1864
|
-
}
|
|
1865
|
-
function useModalModel() {
|
|
1866
|
-
const { modalStack = [], isOpen, closeModal } = useModal();
|
|
1867
|
-
const registry = useModalRegistryEntries();
|
|
1868
|
-
const visibleModalStack = useMemo(
|
|
1869
|
-
() => modalStack.filter(
|
|
1870
|
-
(entry) => Boolean(entry.component || registry.get(entry.modalType))
|
|
1871
|
-
),
|
|
1872
|
-
[modalStack, registry]
|
|
1873
|
-
);
|
|
1874
|
-
const topModalEntry = visibleModalStack[visibleModalStack.length - 1] || null;
|
|
1875
|
-
const isModalVisible = Boolean(isOpen && topModalEntry);
|
|
1876
|
-
const mounted = useSyncExternalStore(
|
|
1877
|
-
emptySubscribe,
|
|
1878
|
-
() => true,
|
|
1879
|
-
() => false
|
|
1880
|
-
);
|
|
1881
|
-
const [isMobileViewport, setIsMobileViewport] = useState(getViewportIsMobile);
|
|
1882
|
-
const [isTopExitSettling, setIsTopExitSettling] = useState(false);
|
|
1883
|
-
const previousTopModalIdRef = useRef(null);
|
|
1884
|
-
const releaseScrollLockRef = useRef(null);
|
|
1885
|
-
useLayoutEffect(() => {
|
|
1886
|
-
const currentTopModalId = topModalEntry?.id || null;
|
|
1887
|
-
const previousTopModalId = previousTopModalIdRef.current;
|
|
1888
|
-
const previousTopStillMounted = visibleModalStack.some(
|
|
1889
|
-
(entry) => entry.id === previousTopModalId
|
|
1890
|
-
);
|
|
1891
|
-
if (previousTopModalId && previousTopModalId !== currentTopModalId && !previousTopStillMounted) {
|
|
1892
|
-
setIsTopExitSettling(true);
|
|
1893
|
-
}
|
|
1894
|
-
previousTopModalIdRef.current = currentTopModalId;
|
|
1895
|
-
}, [topModalEntry?.id, visibleModalStack]);
|
|
1896
|
-
useEffect(() => {
|
|
1897
|
-
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
1898
|
-
const mediaQuery = window.matchMedia(
|
|
1899
|
-
`(max-width: ${MODAL_BREAKPOINTS.MOBILE_MAX_WIDTH}px)`
|
|
1900
|
-
);
|
|
1901
|
-
const handleViewportChange = (e) => setIsMobileViewport(e.matches);
|
|
1902
|
-
mediaQuery.addEventListener("change", handleViewportChange);
|
|
1903
|
-
return () => mediaQuery.removeEventListener("change", handleViewportChange);
|
|
1904
|
-
}, []);
|
|
1905
|
-
useEffect(() => {
|
|
1906
|
-
if (typeof document === "undefined") return;
|
|
1907
|
-
if (isModalVisible) {
|
|
1908
|
-
releaseScrollLockRef.current ??= acquireGlobalScrollLock();
|
|
1909
|
-
} else if (releaseScrollLockRef.current) {
|
|
1910
|
-
releaseScrollLockRef.current();
|
|
1911
|
-
releaseScrollLockRef.current = null;
|
|
1912
|
-
}
|
|
1913
|
-
dispatchSmoothScrollLock(isModalVisible);
|
|
1914
|
-
}, [isModalVisible]);
|
|
1915
|
-
useEffect(() => {
|
|
1916
|
-
return () => {
|
|
1917
|
-
releaseScrollLockRef.current?.();
|
|
1918
|
-
releaseScrollLockRef.current = null;
|
|
1919
|
-
dispatchSmoothScrollLock(false);
|
|
1920
|
-
};
|
|
1921
|
-
}, []);
|
|
1922
|
-
return {
|
|
1923
|
-
modalStack,
|
|
1924
|
-
closeModal,
|
|
1925
|
-
registry,
|
|
1926
|
-
visibleModalStack,
|
|
1927
|
-
topModalEntry,
|
|
1928
|
-
isModalVisible,
|
|
1929
|
-
mounted,
|
|
1930
|
-
isMobileViewport,
|
|
1931
|
-
isTopExitSettling,
|
|
1932
|
-
setIsTopExitSettling,
|
|
1933
|
-
theme: useTheme(modalTheme)
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
var emptySubscribe;
|
|
1937
|
-
var init_hooks3 = __esm({
|
|
1938
|
-
"src/modules/modal/hooks.ts"() {
|
|
1939
|
-
"use client";
|
|
1940
|
-
init_hooks();
|
|
1941
|
-
init_kernel();
|
|
1942
|
-
init_tokens2();
|
|
1943
|
-
init_utils();
|
|
1944
|
-
init_theme();
|
|
1945
|
-
init_constants2();
|
|
1946
|
-
init_context();
|
|
1947
|
-
init_identity();
|
|
1948
|
-
init_dom2();
|
|
1949
|
-
init_layout();
|
|
1950
|
-
emptySubscribe = () => () => {
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
});
|
|
1954
|
-
|
|
1955
|
-
// src/modules/modal/overlay.tsx
|
|
1956
|
-
var overlay_exports = {};
|
|
1957
|
-
__export(overlay_exports, {
|
|
1958
|
-
Modal: () => Modal,
|
|
1959
|
-
ModalContainer: () => ModalContainer
|
|
1960
|
-
});
|
|
1961
|
-
function CloseButton({
|
|
1962
|
-
close,
|
|
1963
|
-
theme
|
|
1964
|
-
}) {
|
|
1965
|
-
if (typeof close !== "function") return null;
|
|
1966
|
-
return /* @__PURE__ */ jsx(
|
|
1967
|
-
Button,
|
|
1968
|
-
{
|
|
1969
|
-
type: "button",
|
|
1970
|
-
"aria-label": "Close modal",
|
|
1971
|
-
onClick: close,
|
|
1972
|
-
className: theme.slots.closeButton,
|
|
1973
|
-
children: /* @__PURE__ */ jsx(Icon, { icon: "solar:close-bold", size: 16 })
|
|
1974
|
-
}
|
|
1975
|
-
);
|
|
1976
|
-
}
|
|
1977
|
-
function SlotRow({
|
|
1978
|
-
center,
|
|
1979
|
-
left,
|
|
1980
|
-
right,
|
|
1981
|
-
sticky,
|
|
1982
|
-
theme,
|
|
1983
|
-
variants
|
|
1984
|
-
}) {
|
|
1985
|
-
const hasCenter = hasSlotContent(center);
|
|
1986
|
-
return /* @__PURE__ */ jsxs(
|
|
1987
|
-
motion.div,
|
|
1988
|
-
{
|
|
1989
|
-
variants,
|
|
1990
|
-
initial: "hidden",
|
|
1991
|
-
animate: "visible",
|
|
1992
|
-
"data-columns": hasCenter ? 3 : 2,
|
|
1993
|
-
"data-sticky": sticky,
|
|
1994
|
-
className: theme.slots.row,
|
|
1995
|
-
style: sticky ? theme.styles.row : void 0,
|
|
1996
|
-
children: [
|
|
1997
|
-
/* @__PURE__ */ jsx("div", { className: theme.slots.rowStart, children: left }),
|
|
1998
|
-
hasCenter && /* @__PURE__ */ jsx("div", { className: theme.slots.rowCenter, children: center }),
|
|
1999
|
-
/* @__PURE__ */ jsx("div", { className: theme.slots.rowEnd, children: right })
|
|
2000
|
-
]
|
|
2001
|
-
}
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
function resolveHeader(header, close, theme) {
|
|
2005
|
-
const config = isHeaderConfig(header) ? header : {};
|
|
2006
|
-
const customNode = typeof header !== "boolean" && !isHeaderConfig(header) && hasSlotContent(header) ? header : null;
|
|
2007
|
-
const actions = resolveHeaderActions(config.actions, close);
|
|
2008
|
-
const showClose = config.showClose === true;
|
|
2009
|
-
const left = customNode !== null ? null : config.left ?? (config.title ? /* @__PURE__ */ jsx("h2", { id: config.titleId, className: theme.slots.title, children: config.title }) : null);
|
|
2010
|
-
const right = customNode !== null ? null : config.right ?? (hasSlotContent(actions) || showClose ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2011
|
-
actions,
|
|
2012
|
-
showClose && /* @__PURE__ */ jsx(CloseButton, { close, theme })
|
|
2013
|
-
] }) : null);
|
|
2014
|
-
return { center: customNode ?? config.center ?? null, config, left, right };
|
|
2015
|
-
}
|
|
2016
|
-
function ModalContainer({
|
|
2017
|
-
bodyClassName,
|
|
2018
|
-
children,
|
|
2019
|
-
className,
|
|
2020
|
-
close,
|
|
2021
|
-
footer,
|
|
2022
|
-
header = {},
|
|
2023
|
-
position = null
|
|
2024
|
-
}) {
|
|
2025
|
-
const { theme } = useModalContainerModel();
|
|
2026
|
-
const headerRow = header === false ? null : resolveHeader(header, close, theme);
|
|
2027
|
-
const shouldRenderHeader = headerRow && [headerRow.left, headerRow.center, headerRow.right].some(hasSlotContent);
|
|
2028
|
-
const footerConfig = footer && typeof footer === "object" ? footer : {};
|
|
2029
|
-
const {
|
|
2030
|
-
center: footerCenter = null,
|
|
2031
|
-
left: footerLeft = null,
|
|
2032
|
-
right: footerRight = null
|
|
2033
|
-
} = footerConfig;
|
|
2034
|
-
const shouldRenderFooter = footer !== false && [footerLeft, footerCenter, footerRight].some(hasSlotContent);
|
|
2035
|
-
const resolvedPosition = position || headerRow?.config.position || null;
|
|
2036
|
-
return /* @__PURE__ */ jsxs(
|
|
2037
|
-
"div",
|
|
2038
|
-
{
|
|
2039
|
-
"data-height": isSidePosition(resolvedPosition) ? "full" : hasHeightConstraint(className) ? void 0 : "capped",
|
|
2040
|
-
className: cn(theme.slots.content, className),
|
|
2041
|
-
children: [
|
|
2042
|
-
shouldRenderHeader && /* @__PURE__ */ jsx(
|
|
2043
|
-
SlotRow,
|
|
2044
|
-
{
|
|
2045
|
-
variants: MODAL_HEADER_VARIANTS,
|
|
2046
|
-
left: headerRow.left,
|
|
2047
|
-
center: headerRow.center,
|
|
2048
|
-
right: headerRow.right,
|
|
2049
|
-
theme,
|
|
2050
|
-
sticky: headerRow.config.sticky ? "top" : void 0
|
|
2051
|
-
}
|
|
2052
|
-
),
|
|
2053
|
-
/* @__PURE__ */ jsx(
|
|
2054
|
-
motion.div,
|
|
2055
|
-
{
|
|
2056
|
-
variants: MODAL_CONTENT_VARIANTS,
|
|
2057
|
-
initial: "hidden",
|
|
2058
|
-
animate: "visible",
|
|
2059
|
-
"data-lenis-prevent": true,
|
|
2060
|
-
"data-lenis-prevent-wheel": true,
|
|
2061
|
-
className: cn(theme.slots.body, bodyClassName),
|
|
2062
|
-
children
|
|
2063
|
-
}
|
|
2064
|
-
),
|
|
2065
|
-
shouldRenderFooter && /* @__PURE__ */ jsx(
|
|
2066
|
-
SlotRow,
|
|
2067
|
-
{
|
|
2068
|
-
variants: MODAL_FOOTER_VARIANTS,
|
|
2069
|
-
left: footerLeft,
|
|
2070
|
-
center: footerCenter,
|
|
2071
|
-
right: footerRight,
|
|
2072
|
-
theme,
|
|
2073
|
-
sticky: footerConfig.sticky ? "bottom" : void 0
|
|
2074
|
-
}
|
|
2075
|
-
)
|
|
2076
|
-
]
|
|
2077
|
-
}
|
|
2078
|
-
);
|
|
2079
|
-
}
|
|
2080
|
-
function ModalLayerSwitcher({
|
|
2081
|
-
currentEntry,
|
|
2082
|
-
onSwitchToPrevious,
|
|
2083
|
-
previousEntry,
|
|
2084
|
-
theme
|
|
2085
|
-
}) {
|
|
2086
|
-
return /* @__PURE__ */ jsxs("div", { className: theme.slots.switcher, children: [
|
|
2087
|
-
/* @__PURE__ */ jsxs(
|
|
2088
|
-
Button,
|
|
2089
|
-
{
|
|
2090
|
-
type: "button",
|
|
2091
|
-
onClick: onSwitchToPrevious,
|
|
2092
|
-
className: theme.slots.switcherButton,
|
|
2093
|
-
children: [
|
|
2094
|
-
/* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsx(
|
|
2095
|
-
"path",
|
|
2096
|
-
{
|
|
2097
|
-
d: "M7.5 2.5L4 6l3.5 3.5",
|
|
2098
|
-
stroke: "currentColor",
|
|
2099
|
-
strokeWidth: "1.5",
|
|
2100
|
-
strokeLinecap: "round",
|
|
2101
|
-
strokeLinejoin: "round"
|
|
2102
|
-
}
|
|
2103
|
-
) }),
|
|
2104
|
-
getModalLabel(previousEntry.modalType)
|
|
2105
|
-
]
|
|
2106
|
-
}
|
|
2107
|
-
),
|
|
2108
|
-
/* @__PURE__ */ jsx("span", { className: theme.slots.switcherDivider, children: "/" }),
|
|
2109
|
-
/* @__PURE__ */ jsx("span", { className: theme.slots.switcherCurrent, children: getModalLabel(currentEntry.modalType) })
|
|
2110
|
-
] });
|
|
2111
|
-
}
|
|
2112
|
-
function ModalLayer({
|
|
2113
|
-
closeModal,
|
|
2114
|
-
entry,
|
|
2115
|
-
isMobileViewport,
|
|
2116
|
-
isTopModal,
|
|
2117
|
-
modalStack,
|
|
2118
|
-
registry,
|
|
2119
|
-
stackIndex,
|
|
2120
|
-
theme
|
|
2121
|
-
}) {
|
|
2122
|
-
const {
|
|
2123
|
-
modalRef,
|
|
2124
|
-
activePosition,
|
|
2125
|
-
ActiveModalComponent,
|
|
2126
|
-
isPanelChrome,
|
|
2127
|
-
previousEntry,
|
|
2128
|
-
baseZIndex
|
|
2129
|
-
} = useModalLayerModel({
|
|
2130
|
-
closeModal,
|
|
2131
|
-
entry,
|
|
2132
|
-
isMobileViewport,
|
|
2133
|
-
isTopModal,
|
|
2134
|
-
modalStack,
|
|
2135
|
-
registry,
|
|
2136
|
-
stackIndex
|
|
2137
|
-
});
|
|
2138
|
-
if (!ActiveModalComponent) return null;
|
|
2139
|
-
const layout = getModalLayout(activePosition, isMobileViewport);
|
|
2140
|
-
return /* @__PURE__ */ jsx(
|
|
2141
|
-
"div",
|
|
2142
|
-
{
|
|
2143
|
-
role: "dialog",
|
|
2144
|
-
"aria-modal": isTopModal,
|
|
2145
|
-
"aria-labelledby": entry.title ? `modal-title-${entry.id}` : void 0,
|
|
2146
|
-
style: { zIndex: baseZIndex },
|
|
2147
|
-
"data-position": getModalPosition(activePosition),
|
|
2148
|
-
"data-inset": activePosition === MODAL_POSITIONS.CENTER && !isMobileViewport ? true : void 0,
|
|
2149
|
-
className: theme.slots.layer,
|
|
2150
|
-
children: /* @__PURE__ */ jsx(
|
|
2151
|
-
motion.div,
|
|
2152
|
-
{
|
|
2153
|
-
ref: modalRef,
|
|
2154
|
-
variants: getModalPositionVariants(activePosition),
|
|
2155
|
-
initial: "hidden",
|
|
2156
|
-
animate: "visible",
|
|
2157
|
-
exit: "exit",
|
|
2158
|
-
transition: getModalTransition(activePosition),
|
|
2159
|
-
"data-active": isTopModal,
|
|
2160
|
-
"data-layout": layout,
|
|
2161
|
-
className: theme.slots.frame,
|
|
2162
|
-
style: { zIndex: Z_INDEX.MODAL_FRAME, ...MODAL_COMPOSITOR_STYLE },
|
|
2163
|
-
onClick: (e) => e.stopPropagation(),
|
|
2164
|
-
children: /* @__PURE__ */ jsxs(
|
|
2165
|
-
"div",
|
|
2166
|
-
{
|
|
2167
|
-
"data-layout": layout,
|
|
2168
|
-
className: cn(
|
|
2169
|
-
theme.slots.panel,
|
|
2170
|
-
isPanelChrome ? theme.slots.panelChrome : theme.slots.panelBare
|
|
2171
|
-
),
|
|
2172
|
-
children: [
|
|
2173
|
-
/* @__PURE__ */ jsx(ModuleBoundary, { name: entry.modalType, children: createElement(ActiveModalComponent, {
|
|
2174
|
-
close: (result) => closeModal(result, entry.id),
|
|
2175
|
-
data: entry.props,
|
|
2176
|
-
header: {
|
|
2177
|
-
actions: entry.headerActions,
|
|
2178
|
-
position: activePosition,
|
|
2179
|
-
showClose: entry.showClose,
|
|
2180
|
-
title: entry.title,
|
|
2181
|
-
titleId: `modal-title-${entry.id}`
|
|
2182
|
-
}
|
|
2183
|
-
}) }),
|
|
2184
|
-
!isTopModal && /* @__PURE__ */ jsx(
|
|
2185
|
-
"div",
|
|
2186
|
-
{
|
|
2187
|
-
onClick: (e) => {
|
|
2188
|
-
e.stopPropagation();
|
|
2189
|
-
const topModal = modalStack[modalStack.length - 1];
|
|
2190
|
-
if (topModal) closeModal(null, topModal.id);
|
|
2191
|
-
},
|
|
2192
|
-
className: theme.slots.dim,
|
|
2193
|
-
style: theme.styles.dim,
|
|
2194
|
-
"aria-label": "Close active top modal"
|
|
2195
|
-
}
|
|
2196
|
-
),
|
|
2197
|
-
isTopModal && stackIndex > 0 && previousEntry && /* @__PURE__ */ jsx(
|
|
2198
|
-
ModalLayerSwitcher,
|
|
2199
|
-
{
|
|
2200
|
-
currentEntry: entry,
|
|
2201
|
-
previousEntry,
|
|
2202
|
-
theme,
|
|
2203
|
-
onSwitchToPrevious: () => closeModal(null, entry.id)
|
|
2204
|
-
}
|
|
2205
|
-
)
|
|
2206
|
-
]
|
|
2207
|
-
}
|
|
2208
|
-
)
|
|
2209
|
-
}
|
|
2210
|
-
)
|
|
2211
|
-
}
|
|
2212
|
-
);
|
|
2213
|
-
}
|
|
2214
|
-
function Modal() {
|
|
2215
|
-
const {
|
|
2216
|
-
closeModal,
|
|
2217
|
-
registry,
|
|
2218
|
-
visibleModalStack,
|
|
2219
|
-
topModalEntry,
|
|
2220
|
-
isModalVisible,
|
|
2221
|
-
mounted,
|
|
2222
|
-
isMobileViewport,
|
|
2223
|
-
isTopExitSettling,
|
|
2224
|
-
setIsTopExitSettling,
|
|
2225
|
-
theme
|
|
2226
|
-
} = useModalModel();
|
|
2227
|
-
if (!mounted) return null;
|
|
2228
|
-
return createPortal(
|
|
2229
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2230
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: isModalVisible && /* @__PURE__ */ jsx(
|
|
2231
|
-
motion.div,
|
|
2232
|
-
{
|
|
2233
|
-
variants: modalBackdropVariants,
|
|
2234
|
-
initial: "hidden",
|
|
2235
|
-
animate: "visible",
|
|
2236
|
-
exit: "exit",
|
|
2237
|
-
className: theme.slots.backdrop,
|
|
2238
|
-
style: theme.styles.backdrop,
|
|
2239
|
-
onClick: () => {
|
|
2240
|
-
if (!isTopExitSettling) closeModal(null, topModalEntry.id);
|
|
2241
|
-
}
|
|
2242
|
-
},
|
|
2243
|
-
"global-modal-backdrop"
|
|
2244
|
-
) }),
|
|
2245
|
-
/* @__PURE__ */ jsx(AnimatePresence, { onExitComplete: () => setIsTopExitSettling(false), children: visibleModalStack.map((entry, index) => /* @__PURE__ */ jsx(
|
|
2246
|
-
ModalLayer,
|
|
2247
|
-
{
|
|
2248
|
-
entry,
|
|
2249
|
-
stackIndex: index,
|
|
2250
|
-
isTopModal: index === visibleModalStack.length - 1 && !isTopExitSettling,
|
|
2251
|
-
isMobileViewport,
|
|
2252
|
-
closeModal,
|
|
2253
|
-
registry,
|
|
2254
|
-
modalStack: visibleModalStack,
|
|
2255
|
-
theme
|
|
2256
|
-
},
|
|
2257
|
-
entry.id
|
|
2258
|
-
)) })
|
|
2259
|
-
] }),
|
|
2260
|
-
document.body
|
|
2261
|
-
);
|
|
2262
|
-
}
|
|
2263
|
-
var init_overlay = __esm({
|
|
2264
|
-
"src/modules/modal/overlay.tsx"() {
|
|
2265
|
-
"use client";
|
|
2266
|
-
init_atoms();
|
|
2267
|
-
init_tokens2();
|
|
2268
|
-
init_utils();
|
|
2269
|
-
init_kernel();
|
|
2270
|
-
init_constants2();
|
|
2271
|
-
init_motion2();
|
|
2272
|
-
init_layout();
|
|
2273
|
-
init_header();
|
|
2274
|
-
init_identity();
|
|
2275
|
-
init_hooks3();
|
|
2276
|
-
}
|
|
2277
|
-
});
|
|
2278
|
-
|
|
2279
|
-
// src/modules/modal/index.ts
|
|
2280
|
-
init_overlay();
|
|
2281
|
-
init_context();
|
|
2282
|
-
init_hooks3();
|
|
2283
|
-
|
|
2284
|
-
// src/modules/modal/module.tsx
|
|
2285
|
-
init_hooks();
|
|
2286
|
-
init_kernel();
|
|
2287
|
-
init_context();
|
|
2288
|
-
init_hooks3();
|
|
2289
|
-
init_identity();
|
|
2290
|
-
var LazyModal = dynamic(
|
|
2291
|
-
() => Promise.resolve().then(() => (init_overlay(), overlay_exports)).then((view) => view.Modal),
|
|
2292
|
-
{
|
|
2293
|
-
ssr: false
|
|
2294
|
-
}
|
|
2295
|
-
);
|
|
2296
|
-
function selectPageModals(config) {
|
|
2297
|
-
return config.modal ?? null;
|
|
2298
|
-
}
|
|
2299
|
-
function useModalPage(slice, page) {
|
|
2300
|
-
const actions = useModalActions();
|
|
2301
|
-
const sliceRef = useRef(slice);
|
|
2302
|
-
useIsomorphicLayoutEffect(() => {
|
|
2303
|
-
sliceRef.current = slice;
|
|
2304
|
-
}, [slice]);
|
|
2305
|
-
return useMemo(
|
|
2306
|
-
() => ({
|
|
2307
|
-
...actions,
|
|
2308
|
-
open: (modal, data = {}) => {
|
|
2309
|
-
const own = typeof modal === "string" && modal !== "registry" ? sliceRef.current?.[modal] : void 0;
|
|
2310
|
-
return actions.openModal(own ?? modal, { data });
|
|
2311
|
-
},
|
|
2312
|
-
set: (modal) => page.set({ modal })
|
|
2313
|
-
}),
|
|
2314
|
-
[actions, page]
|
|
2315
|
-
);
|
|
2316
|
-
}
|
|
2317
|
-
var modalModule = defineModule({
|
|
2318
|
-
id: "modal",
|
|
2319
|
-
context: ModalContext,
|
|
2320
|
-
Provider: ModalProvider,
|
|
2321
|
-
Overlay: LazyModal,
|
|
2322
|
-
registry: {
|
|
2323
|
-
cleanupDelayMs: 600,
|
|
2324
|
-
keyPolicy: "named",
|
|
2325
|
-
lifecycle: "immediate",
|
|
2326
|
-
valueKind: "component"
|
|
2327
|
-
},
|
|
2328
|
-
page: {
|
|
2329
|
-
select: selectPageModals,
|
|
2330
|
-
entries: (slice) => Object.entries(slice).map(([key, value]) => ({ key, value })),
|
|
2331
|
-
use: useModalPage
|
|
2332
|
-
}
|
|
2333
|
-
});
|
|
2334
|
-
function defineModal(definition = {}) {
|
|
2335
|
-
const { type } = getModalIdentity(definition);
|
|
2336
|
-
const modalDefinition = Object.freeze({
|
|
2337
|
-
...definition,
|
|
2338
|
-
id: definition.id || type,
|
|
2339
|
-
isModalDefinition: true,
|
|
2340
|
-
type,
|
|
2341
|
-
use: function useDefinedModal() {
|
|
2342
|
-
return useModal(modalDefinition);
|
|
2343
|
-
}
|
|
2344
|
-
});
|
|
2345
|
-
return modalDefinition;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
// src/modules/modal/index.ts
|
|
2349
|
-
init_constants2();
|
|
2350
|
-
init_state();
|
|
2351
|
-
init_identity();
|
|
2352
|
-
init_layout();
|
|
2353
|
-
init_dom2();
|
|
2354
|
-
init_header();
|
|
2355
|
-
|
|
2356
|
-
export { INITIAL_MODAL_STATE, MODAL_BREAKPOINTS, MODAL_CHROME, MODAL_POSITIONS, Modal, ModalContainer, ModalContext, ModalProvider, SMOOTH_SCROLL_LOCK_EVENT, createModalState, defineModal, dispatchSmoothScrollLock, getFocusableElements, getModalIdentity, getModalLabel, getModalLayout, getModalPosition, getViewportIsMobile, hasHeightConstraint, hasSlotContent, isHeaderConfig, isSidePosition, isVerticalEdgePosition, modalModule, modalTheme, normalizePosition, resolveActivePosition, resolveHeaderActions, trapFocus, useModal, useModalActions, useModalContainerModel, useModalLayerModel, useModalModel, useModalRegistration, useModalRegistryEntries, useModalState };
|
|
2
|
+
export { Modal, ModalContainer, hasSlotContent, isHeaderConfig, resolveHeaderActions } from '../../chunk-AQ4BNXA2.js';
|
|
3
|
+
export { defineModal, modalModule } from '../../chunk-FIMPHODX.js';
|
|
4
|
+
export { INITIAL_MODAL_STATE, MODAL_BREAKPOINTS, MODAL_CHROME, MODAL_POSITIONS, ModalContext, ModalProvider, SMOOTH_SCROLL_LOCK_EVENT, createModalState, dispatchSmoothScrollLock, getFocusableElements, getModalIdentity, getModalLabel, getModalLayout, getModalPosition, getViewportIsMobile, hasHeightConstraint, isSidePosition, isVerticalEdgePosition, modalTheme, normalizePosition, resolveActivePosition, trapFocus, useModal, useModalActions, useModalContainerModel, useModalLayerModel, useModalModel, useModalRegistration, useModalRegistryEntries, useModalState } from '../../chunk-7HQMXTNP.js';
|
|
5
|
+
import '../../chunk-QI3ALLIB.js';
|
|
6
|
+
import '../../chunk-7TAVYJ3A.js';
|
|
7
|
+
import '../../chunk-GF7TUX5I.js';
|
|
8
|
+
import '../../chunk-TV3WEF5G.js';
|
|
9
|
+
import '../../chunk-3BUP64Q6.js';
|
|
2357
10
|
//# sourceMappingURL=index.js.map
|
|
2358
11
|
//# sourceMappingURL=index.js.map
|