@mehdashti/modals 0.2.0 → 0.4.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/README.md +8 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +70 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,7 +183,7 @@ function CreateUserModal({ open, onClose }) {
|
|
|
183
183
|
|
|
184
184
|
### Modal Stacking
|
|
185
185
|
|
|
186
|
-
Multiple modals can be opened simultaneously:
|
|
186
|
+
Multiple modals can be opened simultaneously with automatic z-index management:
|
|
187
187
|
|
|
188
188
|
```tsx
|
|
189
189
|
function App() {
|
|
@@ -215,6 +215,13 @@ function Component() {
|
|
|
215
215
|
}
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
+
**Z-Index Management:**
|
|
219
|
+
- Each modal/drawer automatically gets the correct z-index
|
|
220
|
+
- First modal: z-50 (overlay), z-51 (content)
|
|
221
|
+
- Second modal: z-60 (overlay), z-61 (content)
|
|
222
|
+
- Third modal: z-70 (overlay), z-71 (content)
|
|
223
|
+
- Supports unlimited stacking without conflicts
|
|
224
|
+
|
|
218
225
|
## API
|
|
219
226
|
|
|
220
227
|
### Modal Props
|
package/dist/index.d.ts
CHANGED
|
@@ -50,8 +50,12 @@ interface DrawerProps {
|
|
|
50
50
|
* Footer content
|
|
51
51
|
*/
|
|
52
52
|
footer?: React.ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Z-index for drawer stacking (managed automatically by ModalProvider)
|
|
55
|
+
*/
|
|
56
|
+
zIndex?: number;
|
|
53
57
|
}
|
|
54
|
-
declare function Drawer({ open, onClose, title, description, children, side, size, showClose, dismissable, className, header, footer, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
declare function Drawer({ open, onClose, title, description, children, side, size, showClose, dismissable, className, header, footer, zIndex, }: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
55
59
|
|
|
56
60
|
/**
|
|
57
61
|
* Modal Types
|
|
@@ -96,12 +100,16 @@ interface ModalProps {
|
|
|
96
100
|
* Whether the modal can be dismissed by clicking outside or pressing Escape
|
|
97
101
|
*/
|
|
98
102
|
dismissable?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Z-index for modal stacking (managed automatically by ModalProvider)
|
|
105
|
+
*/
|
|
106
|
+
zIndex?: number;
|
|
99
107
|
}
|
|
100
108
|
interface ModalContextValue {
|
|
101
109
|
/**
|
|
102
110
|
* Open a modal
|
|
103
111
|
*/
|
|
104
|
-
openModal: (id: string, props: Omit<ModalProps, "open"
|
|
112
|
+
openModal: (id: string, props: Omit<ModalProps, "open">) => void;
|
|
105
113
|
/**
|
|
106
114
|
* Close a modal
|
|
107
115
|
*/
|
|
@@ -155,7 +163,7 @@ interface ConfirmModalProps {
|
|
|
155
163
|
*
|
|
156
164
|
* Accessible modal dialog with stacking support.
|
|
157
165
|
*/
|
|
158
|
-
declare function Modal({ open, onClose, title, description, children, size, showClose, className, dismissable, }: ModalProps): react_jsx_runtime.JSX.Element;
|
|
166
|
+
declare function Modal({ open, onClose, title, description, children, size, showClose, className, dismissable, zIndex, }: ModalProps): react_jsx_runtime.JSX.Element;
|
|
159
167
|
|
|
160
168
|
/**
|
|
161
169
|
* Confirm Modal
|
|
@@ -227,7 +235,7 @@ interface PromptOptions {
|
|
|
227
235
|
* Hook providing global modal utilities
|
|
228
236
|
*/
|
|
229
237
|
declare function useModals(): {
|
|
230
|
-
openModal: (id: string, props: Omit<ModalProps, "open"
|
|
238
|
+
openModal: (id: string, props: Omit<ModalProps, "open">) => void;
|
|
231
239
|
closeModal: (id: string) => void;
|
|
232
240
|
closeAllModals: () => void;
|
|
233
241
|
isModalOpen: (id: string) => boolean;
|
package/dist/index.js
CHANGED
|
@@ -18,15 +18,24 @@ function Modal({
|
|
|
18
18
|
size = "md",
|
|
19
19
|
showClose = true,
|
|
20
20
|
className,
|
|
21
|
-
dismissable = true
|
|
21
|
+
dismissable = true,
|
|
22
|
+
zIndex = 50
|
|
22
23
|
}) {
|
|
24
|
+
const overlayZIndex = zIndex;
|
|
25
|
+
const contentZIndex = zIndex + 1;
|
|
23
26
|
return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange: (open2) => !open2 && onClose?.(), children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [
|
|
24
|
-
/* @__PURE__ */ jsx(
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
Dialog.Overlay,
|
|
29
|
+
{
|
|
30
|
+
className: "fixed inset-0 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
31
|
+
style: { zIndex: overlayZIndex }
|
|
32
|
+
}
|
|
33
|
+
),
|
|
25
34
|
/* @__PURE__ */ jsxs(
|
|
26
35
|
Dialog.Content,
|
|
27
36
|
{
|
|
28
37
|
className: clsx(
|
|
29
|
-
"fixed left-[50%] top-[50%]
|
|
38
|
+
"fixed left-[50%] top-[50%] w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200",
|
|
30
39
|
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
31
40
|
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
32
41
|
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
@@ -36,6 +45,7 @@ function Modal({
|
|
|
36
45
|
sizeClasses[size],
|
|
37
46
|
className
|
|
38
47
|
),
|
|
48
|
+
style: { zIndex: contentZIndex },
|
|
39
49
|
onEscapeKeyDown: (e) => {
|
|
40
50
|
if (!dismissable) {
|
|
41
51
|
e.preventDefault();
|
|
@@ -173,21 +183,31 @@ function Drawer({
|
|
|
173
183
|
dismissable = true,
|
|
174
184
|
className,
|
|
175
185
|
header,
|
|
176
|
-
footer
|
|
186
|
+
footer,
|
|
187
|
+
zIndex = 50
|
|
177
188
|
}) {
|
|
189
|
+
const overlayZIndex = zIndex;
|
|
190
|
+
const contentZIndex = zIndex + 1;
|
|
178
191
|
return /* @__PURE__ */ jsx3(Dialog2.Root, { open, onOpenChange: (open2) => !open2 && onClose?.(), children: /* @__PURE__ */ jsxs3(Dialog2.Portal, { children: [
|
|
179
|
-
/* @__PURE__ */ jsx3(
|
|
192
|
+
/* @__PURE__ */ jsx3(
|
|
193
|
+
Dialog2.Overlay,
|
|
194
|
+
{
|
|
195
|
+
className: "fixed inset-0 bg-black/50 backdrop-blur-sm animate-fade-in",
|
|
196
|
+
style: { zIndex: overlayZIndex }
|
|
197
|
+
}
|
|
198
|
+
),
|
|
180
199
|
/* @__PURE__ */ jsxs3(
|
|
181
200
|
Dialog2.Content,
|
|
182
201
|
{
|
|
183
202
|
className: clsx2(
|
|
184
|
-
"fixed
|
|
203
|
+
"fixed bg-white dark:bg-gray-900 shadow-xl",
|
|
185
204
|
"flex flex-col",
|
|
186
205
|
sideClasses[side],
|
|
187
206
|
(side === "left" || side === "right") && sizeClasses2[size],
|
|
188
207
|
(side === "top" || side === "bottom") && "h-auto",
|
|
189
208
|
className
|
|
190
209
|
),
|
|
210
|
+
style: { zIndex: contentZIndex },
|
|
191
211
|
onEscapeKeyDown: (e) => !dismissable && e.preventDefault(),
|
|
192
212
|
onPointerDownOutside: (e) => !dismissable && e.preventDefault(),
|
|
193
213
|
children: [
|
|
@@ -271,15 +291,19 @@ function ModalProvider({ children }) {
|
|
|
271
291
|
};
|
|
272
292
|
return /* @__PURE__ */ jsxs4(ModalContext.Provider, { value, children: [
|
|
273
293
|
children,
|
|
274
|
-
modals.map((modal) =>
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
294
|
+
modals.map((modal, index) => {
|
|
295
|
+
const baseZIndex = 50 + index * 10;
|
|
296
|
+
return /* @__PURE__ */ jsx4(
|
|
297
|
+
Modal,
|
|
298
|
+
{
|
|
299
|
+
open: true,
|
|
300
|
+
onClose: () => closeModal(modal.id),
|
|
301
|
+
zIndex: baseZIndex,
|
|
302
|
+
...modal.props
|
|
303
|
+
},
|
|
304
|
+
modal.id
|
|
305
|
+
);
|
|
306
|
+
})
|
|
283
307
|
] });
|
|
284
308
|
}
|
|
285
309
|
function useModalContext() {
|
|
@@ -318,19 +342,30 @@ function useModals() {
|
|
|
318
342
|
(options) => {
|
|
319
343
|
return new Promise((resolve) => {
|
|
320
344
|
const modalId = `confirm-${Date.now()}`;
|
|
345
|
+
let resolved = false;
|
|
321
346
|
const handleConfirm = () => {
|
|
347
|
+
if (resolved) return;
|
|
348
|
+
resolved = true;
|
|
322
349
|
context.closeModal(modalId);
|
|
323
350
|
resolve(true);
|
|
324
351
|
};
|
|
325
352
|
const handleCancel = () => {
|
|
353
|
+
if (resolved) return;
|
|
354
|
+
resolved = true;
|
|
326
355
|
context.closeModal(modalId);
|
|
327
356
|
resolve(false);
|
|
328
357
|
};
|
|
358
|
+
const handleDismiss = () => {
|
|
359
|
+
if (resolved) return;
|
|
360
|
+
resolved = true;
|
|
361
|
+
resolve(false);
|
|
362
|
+
};
|
|
329
363
|
context.openModal(modalId, {
|
|
330
364
|
title: options.title,
|
|
331
365
|
size: "sm",
|
|
332
366
|
dismissable: true,
|
|
333
367
|
showClose: false,
|
|
368
|
+
onClose: handleDismiss,
|
|
334
369
|
children: /* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
|
|
335
370
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: options.message }),
|
|
336
371
|
/* @__PURE__ */ jsxs5("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -361,15 +396,24 @@ function useModals() {
|
|
|
361
396
|
(options) => {
|
|
362
397
|
return new Promise((resolve) => {
|
|
363
398
|
const modalId = `alert-${Date.now()}`;
|
|
399
|
+
let resolved = false;
|
|
364
400
|
const handleOk = () => {
|
|
401
|
+
if (resolved) return;
|
|
402
|
+
resolved = true;
|
|
365
403
|
context.closeModal(modalId);
|
|
366
404
|
resolve();
|
|
367
405
|
};
|
|
406
|
+
const handleDismiss = () => {
|
|
407
|
+
if (resolved) return;
|
|
408
|
+
resolved = true;
|
|
409
|
+
resolve();
|
|
410
|
+
};
|
|
368
411
|
context.openModal(modalId, {
|
|
369
412
|
title: options.title,
|
|
370
413
|
size: "sm",
|
|
371
414
|
dismissable: true,
|
|
372
415
|
showClose: false,
|
|
416
|
+
onClose: handleDismiss,
|
|
373
417
|
children: /* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
|
|
374
418
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: options.message }),
|
|
375
419
|
/* @__PURE__ */ jsx5("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx5(
|
|
@@ -392,6 +436,12 @@ function useModals() {
|
|
|
392
436
|
const modalId = `prompt-${Date.now()}`;
|
|
393
437
|
let inputValue = options.defaultValue || "";
|
|
394
438
|
let errorMessage = "";
|
|
439
|
+
let resolved = false;
|
|
440
|
+
const handleDismiss = () => {
|
|
441
|
+
if (resolved) return;
|
|
442
|
+
resolved = true;
|
|
443
|
+
resolve(null);
|
|
444
|
+
};
|
|
395
445
|
const PromptContent = () => {
|
|
396
446
|
const [value, setValue] = React3.useState(inputValue);
|
|
397
447
|
const [error, setError] = React3.useState("");
|
|
@@ -403,10 +453,14 @@ function useModals() {
|
|
|
403
453
|
return;
|
|
404
454
|
}
|
|
405
455
|
}
|
|
456
|
+
if (resolved) return;
|
|
457
|
+
resolved = true;
|
|
406
458
|
context.closeModal(modalId);
|
|
407
459
|
resolve(value);
|
|
408
460
|
};
|
|
409
461
|
const handleCancel = () => {
|
|
462
|
+
if (resolved) return;
|
|
463
|
+
resolved = true;
|
|
410
464
|
context.closeModal(modalId);
|
|
411
465
|
resolve(null);
|
|
412
466
|
};
|
|
@@ -458,6 +512,7 @@ function useModals() {
|
|
|
458
512
|
size: "sm",
|
|
459
513
|
dismissable: true,
|
|
460
514
|
showClose: false,
|
|
515
|
+
onClose: handleDismiss,
|
|
461
516
|
children: /* @__PURE__ */ jsx5(PromptContent, {})
|
|
462
517
|
});
|
|
463
518
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/modal.tsx","../src/components/confirm-modal.tsx","../src/components/drawer.tsx","../src/context/modal-context.tsx","../src/hooks/use-modal.ts","../src/hooks/use-modals.tsx"],"sourcesContent":["/**\n * Modal Component\n *\n * Modal dialog with Radix UI.\n */\n\nimport * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { clsx } from \"clsx\";\nimport type { ModalProps } from \"../types/index.js\";\n\nconst sizeClasses = {\n sm: \"max-w-md\",\n md: \"max-w-lg\",\n lg: \"max-w-2xl\",\n xl: \"max-w-4xl\",\n full: \"max-w-full\",\n};\n\n/**\n * Modal Component\n *\n * Accessible modal dialog with stacking support.\n */\nexport function Modal({\n open = false,\n onClose,\n title,\n description,\n children,\n size = \"md\",\n showClose = true,\n className,\n dismissable = true,\n}: ModalProps) {\n return (\n <Dialog.Root open={open} onOpenChange={(open) => !open && onClose?.()}>\n <Dialog.Portal>\n <Dialog.Overlay className=\"fixed inset-0 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\" />\n <Dialog.Content\n className={clsx(\n \"fixed left-[50%] top-[50%] z-50 w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200\",\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]\",\n \"data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]\",\n \"sm:rounded-lg\",\n sizeClasses[size],\n className\n )}\n onEscapeKeyDown={(e) => {\n if (!dismissable) {\n e.preventDefault();\n }\n }}\n onPointerDownOutside={(e) => {\n if (!dismissable) {\n e.preventDefault();\n }\n }}\n >\n {(title || description) && (\n <div className=\"space-y-2\">\n {title && (\n <Dialog.Title className=\"text-lg font-semibold leading-none tracking-tight\">\n {title}\n </Dialog.Title>\n )}\n {description && (\n <Dialog.Description className=\"text-sm text-muted-foreground\">\n {description}\n </Dialog.Description>\n )}\n </div>\n )}\n\n <div className=\"mt-4\">{children}</div>\n\n {showClose && (\n <Dialog.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n <span className=\"sr-only\">Close</span>\n </Dialog.Close>\n )}\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n","/**\n * Confirm Modal Component\n *\n * Confirmation dialog with confirm/cancel actions.\n */\n\nimport * as React from \"react\";\nimport { Modal } from \"./modal.js\";\nimport type { ConfirmModalProps } from \"../types/index.js\";\n\n/**\n * Confirm Modal\n *\n * Modal for confirming user actions.\n */\nexport function ConfirmModal({\n title,\n message,\n confirmText = \"Confirm\",\n cancelText = \"Cancel\",\n onConfirm,\n onCancel,\n variant = \"default\",\n}: ConfirmModalProps & { open?: boolean; onClose?: () => void }) {\n const [isLoading, setIsLoading] = React.useState(false);\n const [isOpen, setIsOpen] = React.useState(true);\n\n const handleConfirm = async () => {\n setIsLoading(true);\n try {\n await onConfirm();\n setIsOpen(false);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleCancel = () => {\n onCancel?.();\n setIsOpen(false);\n };\n\n return (\n <Modal\n open={isOpen}\n onClose={handleCancel}\n title={title}\n size=\"sm\"\n dismissable={!isLoading}\n >\n <div className=\"space-y-4\">\n <p className=\"text-sm text-muted-foreground\">{message}</p>\n\n <div className=\"flex justify-end space-x-2\">\n <button\n type=\"button\"\n onClick={handleCancel}\n disabled={isLoading}\n className=\"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2\"\n >\n {cancelText}\n </button>\n <button\n type=\"button\"\n onClick={handleConfirm}\n disabled={isLoading}\n className={`inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 ${\n variant === \"destructive\"\n ? \"bg-destructive text-destructive-foreground hover:bg-destructive/90\"\n : \"bg-primary text-primary-foreground hover:bg-primary/90\"\n }`}\n >\n {isLoading ? \"Loading...\" : confirmText}\n </button>\n </div>\n </div>\n </Modal>\n );\n}\n","/**\n * Drawer Component\n *\n * Side panel that slides in from left, right, top, or bottom.\n * Built on Radix UI Dialog for accessibility.\n */\n\nimport * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { clsx } from \"clsx\";\n\nexport interface DrawerProps {\n /**\n * Whether the drawer is open\n */\n open?: boolean;\n\n /**\n * Callback when drawer should close\n */\n onClose?: () => void;\n\n /**\n * Drawer title\n */\n title?: string;\n\n /**\n * Drawer description (for accessibility)\n */\n description?: string;\n\n /**\n * Drawer content\n */\n children: React.ReactNode;\n\n /**\n * Side to slide from\n */\n side?: \"left\" | \"right\" | \"top\" | \"bottom\";\n\n /**\n * Drawer size\n */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\n /**\n * Show close button\n */\n showClose?: boolean;\n\n /**\n * Allow dismissing by clicking outside or pressing Escape\n */\n dismissable?: boolean;\n\n /**\n * Custom className\n */\n className?: string;\n\n /**\n * Header content (overrides title)\n */\n header?: React.ReactNode;\n\n /**\n * Footer content\n */\n footer?: React.ReactNode;\n}\n\nconst sizeClasses = {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n xl: \"max-w-xl\",\n full: \"max-w-full\",\n};\n\nconst sideClasses = {\n left: \"left-0 top-0 h-full animate-slide-in-from-left\",\n right: \"right-0 top-0 h-full animate-slide-in-from-right\",\n top: \"top-0 left-0 w-full animate-slide-in-from-top\",\n bottom: \"bottom-0 left-0 w-full animate-slide-in-from-bottom\",\n};\n\nexport function Drawer({\n open = false,\n onClose,\n title,\n description,\n children,\n side = \"right\",\n size = \"md\",\n showClose = true,\n dismissable = true,\n className,\n header,\n footer,\n}: DrawerProps) {\n return (\n <Dialog.Root open={open} onOpenChange={(open) => !open && onClose?.()}>\n <Dialog.Portal>\n {/* Overlay */}\n <Dialog.Overlay className=\"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 animate-fade-in\" />\n\n {/* Drawer Content */}\n <Dialog.Content\n className={clsx(\n \"fixed z-50 bg-white dark:bg-gray-900 shadow-xl\",\n \"flex flex-col\",\n sideClasses[side],\n (side === \"left\" || side === \"right\") && sizeClasses[size],\n (side === \"top\" || side === \"bottom\") && \"h-auto\",\n className\n )}\n onEscapeKeyDown={(e) => !dismissable && e.preventDefault()}\n onPointerDownOutside={(e) => !dismissable && e.preventDefault()}\n >\n {/* Header */}\n {(header || title || description) && (\n <div className=\"flex-shrink-0 border-b border-gray-200 dark:border-gray-800 p-6\">\n {header ? (\n header\n ) : (\n <>\n <div className=\"flex items-start justify-between\">\n {title && (\n <Dialog.Title className=\"text-lg font-semibold text-gray-900 dark:text-gray-100\">\n {title}\n </Dialog.Title>\n )}\n {showClose && (\n <Dialog.Close\n className=\"rounded-md p-1 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors\"\n aria-label=\"Close\"\n >\n <svg\n className=\"h-5 w-5 text-gray-500\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </Dialog.Close>\n )}\n </div>\n {description && (\n <Dialog.Description className=\"mt-2 text-sm text-gray-600 dark:text-gray-400\">\n {description}\n </Dialog.Description>\n )}\n </>\n )}\n </div>\n )}\n\n {/* Body */}\n <div className=\"flex-1 overflow-y-auto p-6\">{children}</div>\n\n {/* Footer */}\n {footer && (\n <div className=\"flex-shrink-0 border-t border-gray-200 dark:border-gray-800 p-6\">\n {footer}\n </div>\n )}\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n","/**\n * Modal Context\n *\n * Context for managing multiple modals with stacking support.\n */\n\nimport * as React from \"react\";\nimport type { ModalContextValue, ModalProps } from \"../types/index.js\";\nimport { Modal } from \"../components/modal.js\";\n\nconst ModalContext = React.createContext<ModalContextValue | undefined>(\n undefined\n);\n\ninterface ModalState {\n id: string;\n props: Omit<ModalProps, \"open\" | \"onClose\">;\n}\n\nexport interface ModalProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Modal Provider\n *\n * Provides modal management functionality to the app.\n */\nexport function ModalProvider({ children }: ModalProviderProps) {\n const [modals, setModals] = React.useState<ModalState[]>([]);\n\n const openModal = React.useCallback(\n (id: string, props: Omit<ModalProps, \"open\" | \"onClose\">) => {\n setModals((prev) => {\n // If modal already exists, update it\n const existing = prev.find((m) => m.id === id);\n if (existing) {\n return prev.map((m) => (m.id === id ? { id, props } : m));\n }\n // Otherwise add new modal\n return [...prev, { id, props }];\n });\n },\n []\n );\n\n const closeModal = React.useCallback((id: string) => {\n setModals((prev) => prev.filter((m) => m.id !== id));\n }, []);\n\n const closeAllModals = React.useCallback(() => {\n setModals([]);\n }, []);\n\n const isModalOpen = React.useCallback(\n (id: string) => {\n return modals.some((m) => m.id === id);\n },\n [modals]\n );\n\n const value: ModalContextValue = {\n openModal,\n closeModal,\n closeAllModals,\n isModalOpen,\n openModals: modals.map((m) => m.id),\n };\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {modals.map((modal) => (\n <Modal\n key={modal.id}\n open={true}\n onClose={() => closeModal(modal.id)}\n {...modal.props}\n />\n ))}\n </ModalContext.Provider>\n );\n}\n\n/**\n * Use Modal Context\n *\n * Access modal management functions.\n */\nexport function useModalContext(): ModalContextValue {\n const context = React.useContext(ModalContext);\n\n if (!context) {\n throw new Error(\"useModalContext must be used within ModalProvider\");\n }\n\n return context;\n}\n","/**\n * useModal Hook\n *\n * Hook for programmatic modal control.\n */\n\nimport { useModalContext } from \"../context/modal-context.js\";\nimport type { ModalProps } from \"../types/index.js\";\n\n/**\n * Use Modal\n *\n * Get modal control functions for a specific modal ID.\n */\nexport function useModal(id: string) {\n const { openModal, closeModal, isModalOpen } = useModalContext();\n\n return {\n /**\n * Open this modal\n */\n open: (props: Omit<ModalProps, \"open\" | \"onClose\">) =>\n openModal(id, props),\n\n /**\n * Close this modal\n */\n close: () => closeModal(id),\n\n /**\n * Check if this modal is open\n */\n isOpen: isModalOpen(id),\n };\n}\n","/**\n * Global Modal Utilities Hook\n *\n * Provides convenient methods for common modal patterns:\n * - confirm(): Confirmation dialogs\n * - alert(): Alert dialogs\n * - prompt(): Input dialogs\n */\n\nimport * as React from \"react\";\nimport { useModalContext } from \"../context/index.js\";\nimport type { ModalProps } from \"../types/index.js\";\n\nexport interface ConfirmOptions {\n title: string;\n message: string;\n confirmText?: string;\n cancelText?: string;\n variant?: \"default\" | \"destructive\";\n}\n\nexport interface AlertOptions {\n title: string;\n message: string;\n okText?: string;\n}\n\nexport interface PromptOptions {\n title: string;\n message?: string;\n placeholder?: string;\n defaultValue?: string;\n confirmText?: string;\n cancelText?: string;\n validate?: (value: string) => boolean | string;\n}\n\n/**\n * Hook providing global modal utilities\n */\nexport function useModals() {\n const context = useModalContext();\n\n /**\n * Show confirmation dialog\n * @returns Promise that resolves to true if confirmed, false if cancelled\n */\n const confirm = React.useCallback(\n (options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n const modalId = `confirm-${Date.now()}`;\n\n const handleConfirm = () => {\n context.closeModal(modalId);\n resolve(true);\n };\n\n const handleCancel = () => {\n context.closeModal(modalId);\n resolve(false);\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n children: (\n <div className=\"space-y-4\">\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n <div className=\"flex justify-end gap-2\">\n <button\n onClick={handleCancel}\n className=\"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700\"\n >\n {options.cancelText || \"Cancel\"}\n </button>\n <button\n onClick={handleConfirm}\n className={`px-4 py-2 text-sm font-medium text-white rounded-md ${\n options.variant === \"destructive\"\n ? \"bg-red-600 hover:bg-red-700\"\n : \"bg-blue-600 hover:bg-blue-700\"\n }`}\n >\n {options.confirmText || \"Confirm\"}\n </button>\n </div>\n </div>\n ),\n });\n });\n },\n [context]\n );\n\n /**\n * Show alert dialog\n * @returns Promise that resolves when dismissed\n */\n const alert = React.useCallback(\n (options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n const modalId = `alert-${Date.now()}`;\n\n const handleOk = () => {\n context.closeModal(modalId);\n resolve();\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n children: (\n <div className=\"space-y-4\">\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n <div className=\"flex justify-end\">\n <button\n onClick={handleOk}\n className=\"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700\"\n >\n {options.okText || \"OK\"}\n </button>\n </div>\n </div>\n ),\n });\n });\n },\n [context]\n );\n\n /**\n * Show prompt dialog\n * @returns Promise that resolves to the input value if confirmed, null if cancelled\n */\n const prompt = React.useCallback(\n (options: PromptOptions): Promise<string | null> => {\n return new Promise((resolve) => {\n const modalId = `prompt-${Date.now()}`;\n let inputValue = options.defaultValue || \"\";\n let errorMessage = \"\";\n\n const PromptContent = () => {\n const [value, setValue] = React.useState(inputValue);\n const [error, setError] = React.useState(\"\");\n\n const handleConfirm = () => {\n if (options.validate) {\n const validation = options.validate(value);\n if (validation === false || typeof validation === \"string\") {\n setError(typeof validation === \"string\" ? validation : \"Invalid input\");\n return;\n }\n }\n context.closeModal(modalId);\n resolve(value);\n };\n\n const handleCancel = () => {\n context.closeModal(modalId);\n resolve(null);\n };\n\n return (\n <div className=\"space-y-4\">\n {options.message && (\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n )}\n <div>\n <input\n type=\"text\"\n value={value}\n onChange={(e) => {\n setValue(e.target.value);\n setError(\"\");\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleConfirm();\n if (e.key === \"Escape\") handleCancel();\n }}\n placeholder={options.placeholder}\n autoFocus\n className=\"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-600 dark:text-white\"\n />\n {error && (\n <p className=\"mt-1 text-xs text-red-600 dark:text-red-400\">\n {error}\n </p>\n )}\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n onClick={handleCancel}\n className=\"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700\"\n >\n {options.cancelText || \"Cancel\"}\n </button>\n <button\n onClick={handleConfirm}\n className=\"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700\"\n >\n {options.confirmText || \"OK\"}\n </button>\n </div>\n </div>\n );\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n children: <PromptContent />,\n });\n });\n },\n [context]\n );\n\n return {\n confirm,\n alert,\n prompt,\n ...context,\n };\n}\n"],"mappings":";AAOA,YAAY,YAAY;AACxB,SAAS,YAAY;AA8Bb,cAyBI,YAzBJ;AA3BR,IAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAOO,SAAS,MAAM;AAAA,EACpB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,YAAY;AAAA,EACZ;AAAA,EACA,cAAc;AAChB,GAAe;AACb,SACE,oBAAQ,aAAP,EAAY,MAAY,cAAc,CAACA,UAAS,CAACA,SAAQ,UAAU,GAClE,+BAAQ,eAAP,EACC;AAAA,wBAAQ,gBAAP,EAAe,WAAU,qJAAoJ;AAAA,IAC9K;AAAA,MAAQ;AAAA,MAAP;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,IAAI;AAAA,UAChB;AAAA,QACF;AAAA,QACA,iBAAiB,CAAC,MAAM;AACtB,cAAI,CAAC,aAAa;AAChB,cAAE,eAAe;AAAA,UACnB;AAAA,QACF;AAAA,QACA,sBAAsB,CAAC,MAAM;AAC3B,cAAI,CAAC,aAAa;AAChB,cAAE,eAAe;AAAA,UACnB;AAAA,QACF;AAAA,QAEE;AAAA,oBAAS,gBACT,qBAAC,SAAI,WAAU,aACZ;AAAA,qBACC,oB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,UACzB,OAAO,QAAQ;AAAA,UACf,MAAM;AAAA,UACN,aAAa;AAAA,UACb,WAAW;AAAA,UACX,UAAU,gBAAAA,KAAC,iBAAc;AAAA,QAC3B,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":["open","jsx","jsxs","Dialog","clsx","jsx","jsxs","sizeClasses","open","React","jsx","jsxs","React","jsx","jsxs"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/modal.tsx","../src/components/confirm-modal.tsx","../src/components/drawer.tsx","../src/context/modal-context.tsx","../src/hooks/use-modal.ts","../src/hooks/use-modals.tsx"],"sourcesContent":["/**\n * Modal Component\n *\n * Modal dialog with Radix UI.\n */\n\nimport * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { clsx } from \"clsx\";\nimport type { ModalProps } from \"../types/index.js\";\n\nconst sizeClasses = {\n sm: \"max-w-md\",\n md: \"max-w-lg\",\n lg: \"max-w-2xl\",\n xl: \"max-w-4xl\",\n full: \"max-w-full\",\n};\n\n/**\n * Modal Component\n *\n * Accessible modal dialog with stacking support.\n */\nexport function Modal({\n open = false,\n onClose,\n title,\n description,\n children,\n size = \"md\",\n showClose = true,\n className,\n dismissable = true,\n zIndex = 50,\n}: ModalProps) {\n // Calculate z-index for overlay and content\n // Overlay should be below content: overlay = zIndex, content = zIndex + 1\n const overlayZIndex = zIndex;\n const contentZIndex = zIndex + 1;\n\n return (\n <Dialog.Root open={open} onOpenChange={(open) => !open && onClose?.()}>\n <Dialog.Portal>\n <Dialog.Overlay\n className=\"fixed inset-0 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\"\n style={{ zIndex: overlayZIndex }}\n />\n <Dialog.Content\n className={clsx(\n \"fixed left-[50%] top-[50%] w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200\",\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]\",\n \"data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]\",\n \"sm:rounded-lg\",\n sizeClasses[size],\n className\n )}\n style={{ zIndex: contentZIndex }}\n onEscapeKeyDown={(e) => {\n if (!dismissable) {\n e.preventDefault();\n }\n }}\n onPointerDownOutside={(e) => {\n if (!dismissable) {\n e.preventDefault();\n }\n }}\n >\n {(title || description) && (\n <div className=\"space-y-2\">\n {title && (\n <Dialog.Title className=\"text-lg font-semibold leading-none tracking-tight\">\n {title}\n </Dialog.Title>\n )}\n {description && (\n <Dialog.Description className=\"text-sm text-muted-foreground\">\n {description}\n </Dialog.Description>\n )}\n </div>\n )}\n\n <div className=\"mt-4\">{children}</div>\n\n {showClose && (\n <Dialog.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"h-4 w-4\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n <span className=\"sr-only\">Close</span>\n </Dialog.Close>\n )}\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n","/**\n * Confirm Modal Component\n *\n * Confirmation dialog with confirm/cancel actions.\n */\n\nimport * as React from \"react\";\nimport { Modal } from \"./modal.js\";\nimport type { ConfirmModalProps } from \"../types/index.js\";\n\n/**\n * Confirm Modal\n *\n * Modal for confirming user actions.\n */\nexport function ConfirmModal({\n title,\n message,\n confirmText = \"Confirm\",\n cancelText = \"Cancel\",\n onConfirm,\n onCancel,\n variant = \"default\",\n}: ConfirmModalProps & { open?: boolean; onClose?: () => void }) {\n const [isLoading, setIsLoading] = React.useState(false);\n const [isOpen, setIsOpen] = React.useState(true);\n\n const handleConfirm = async () => {\n setIsLoading(true);\n try {\n await onConfirm();\n setIsOpen(false);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleCancel = () => {\n onCancel?.();\n setIsOpen(false);\n };\n\n return (\n <Modal\n open={isOpen}\n onClose={handleCancel}\n title={title}\n size=\"sm\"\n dismissable={!isLoading}\n >\n <div className=\"space-y-4\">\n <p className=\"text-sm text-muted-foreground\">{message}</p>\n\n <div className=\"flex justify-end space-x-2\">\n <button\n type=\"button\"\n onClick={handleCancel}\n disabled={isLoading}\n className=\"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2\"\n >\n {cancelText}\n </button>\n <button\n type=\"button\"\n onClick={handleConfirm}\n disabled={isLoading}\n className={`inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 ${\n variant === \"destructive\"\n ? \"bg-destructive text-destructive-foreground hover:bg-destructive/90\"\n : \"bg-primary text-primary-foreground hover:bg-primary/90\"\n }`}\n >\n {isLoading ? \"Loading...\" : confirmText}\n </button>\n </div>\n </div>\n </Modal>\n );\n}\n","/**\n * Drawer Component\n *\n * Side panel that slides in from left, right, top, or bottom.\n * Built on Radix UI Dialog for accessibility.\n */\n\nimport * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { clsx } from \"clsx\";\n\nexport interface DrawerProps {\n /**\n * Whether the drawer is open\n */\n open?: boolean;\n\n /**\n * Callback when drawer should close\n */\n onClose?: () => void;\n\n /**\n * Drawer title\n */\n title?: string;\n\n /**\n * Drawer description (for accessibility)\n */\n description?: string;\n\n /**\n * Drawer content\n */\n children: React.ReactNode;\n\n /**\n * Side to slide from\n */\n side?: \"left\" | \"right\" | \"top\" | \"bottom\";\n\n /**\n * Drawer size\n */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\n /**\n * Show close button\n */\n showClose?: boolean;\n\n /**\n * Allow dismissing by clicking outside or pressing Escape\n */\n dismissable?: boolean;\n\n /**\n * Custom className\n */\n className?: string;\n\n /**\n * Header content (overrides title)\n */\n header?: React.ReactNode;\n\n /**\n * Footer content\n */\n footer?: React.ReactNode;\n\n /**\n * Z-index for drawer stacking (managed automatically by ModalProvider)\n */\n zIndex?: number;\n}\n\nconst sizeClasses = {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n xl: \"max-w-xl\",\n full: \"max-w-full\",\n};\n\nconst sideClasses = {\n left: \"left-0 top-0 h-full animate-slide-in-from-left\",\n right: \"right-0 top-0 h-full animate-slide-in-from-right\",\n top: \"top-0 left-0 w-full animate-slide-in-from-top\",\n bottom: \"bottom-0 left-0 w-full animate-slide-in-from-bottom\",\n};\n\nexport function Drawer({\n open = false,\n onClose,\n title,\n description,\n children,\n side = \"right\",\n size = \"md\",\n showClose = true,\n dismissable = true,\n className,\n header,\n footer,\n zIndex = 50,\n}: DrawerProps) {\n // Calculate z-index for overlay and content\n // Overlay should be below content: overlay = zIndex, content = zIndex + 1\n const overlayZIndex = zIndex;\n const contentZIndex = zIndex + 1;\n\n return (\n <Dialog.Root open={open} onOpenChange={(open) => !open && onClose?.()}>\n <Dialog.Portal>\n {/* Overlay */}\n <Dialog.Overlay\n className=\"fixed inset-0 bg-black/50 backdrop-blur-sm animate-fade-in\"\n style={{ zIndex: overlayZIndex }}\n />\n\n {/* Drawer Content */}\n <Dialog.Content\n className={clsx(\n \"fixed bg-white dark:bg-gray-900 shadow-xl\",\n \"flex flex-col\",\n sideClasses[side],\n (side === \"left\" || side === \"right\") && sizeClasses[size],\n (side === \"top\" || side === \"bottom\") && \"h-auto\",\n className\n )}\n style={{ zIndex: contentZIndex }}\n onEscapeKeyDown={(e) => !dismissable && e.preventDefault()}\n onPointerDownOutside={(e) => !dismissable && e.preventDefault()}\n >\n {/* Header */}\n {(header || title || description) && (\n <div className=\"flex-shrink-0 border-b border-gray-200 dark:border-gray-800 p-6\">\n {header ? (\n header\n ) : (\n <>\n <div className=\"flex items-start justify-between\">\n {title && (\n <Dialog.Title className=\"text-lg font-semibold text-gray-900 dark:text-gray-100\">\n {title}\n </Dialog.Title>\n )}\n {showClose && (\n <Dialog.Close\n className=\"rounded-md p-1 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors\"\n aria-label=\"Close\"\n >\n <svg\n className=\"h-5 w-5 text-gray-500\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </Dialog.Close>\n )}\n </div>\n {description && (\n <Dialog.Description className=\"mt-2 text-sm text-gray-600 dark:text-gray-400\">\n {description}\n </Dialog.Description>\n )}\n </>\n )}\n </div>\n )}\n\n {/* Body */}\n <div className=\"flex-1 overflow-y-auto p-6\">{children}</div>\n\n {/* Footer */}\n {footer && (\n <div className=\"flex-shrink-0 border-t border-gray-200 dark:border-gray-800 p-6\">\n {footer}\n </div>\n )}\n </Dialog.Content>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n","/**\n * Modal Context\n *\n * Context for managing multiple modals with stacking support.\n */\n\nimport * as React from \"react\";\nimport type { ModalContextValue, ModalProps } from \"../types/index.js\";\nimport { Modal } from \"../components/modal.js\";\n\nconst ModalContext = React.createContext<ModalContextValue | undefined>(\n undefined\n);\n\ninterface ModalState {\n id: string;\n props: Omit<ModalProps, \"open\" | \"onClose\">;\n}\n\nexport interface ModalProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Modal Provider\n *\n * Provides modal management functionality to the app.\n */\nexport function ModalProvider({ children }: ModalProviderProps) {\n const [modals, setModals] = React.useState<ModalState[]>([]);\n\n const openModal = React.useCallback(\n (id: string, props: Omit<ModalProps, \"open\" | \"onClose\">) => {\n setModals((prev) => {\n // If modal already exists, update it\n const existing = prev.find((m) => m.id === id);\n if (existing) {\n return prev.map((m) => (m.id === id ? { id, props } : m));\n }\n // Otherwise add new modal\n return [...prev, { id, props }];\n });\n },\n []\n );\n\n const closeModal = React.useCallback((id: string) => {\n setModals((prev) => prev.filter((m) => m.id !== id));\n }, []);\n\n const closeAllModals = React.useCallback(() => {\n setModals([]);\n }, []);\n\n const isModalOpen = React.useCallback(\n (id: string) => {\n return modals.some((m) => m.id === id);\n },\n [modals]\n );\n\n const value: ModalContextValue = {\n openModal,\n closeModal,\n closeAllModals,\n isModalOpen,\n openModals: modals.map((m) => m.id),\n };\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n {modals.map((modal, index) => {\n // Calculate z-index for stacking\n // Base z-index is 50, each modal gets +10 for overlay and content spacing\n // Modal 0: z-50 (overlay), z-51 (content)\n // Modal 1: z-60 (overlay), z-61 (content)\n // Modal 2: z-70 (overlay), z-71 (content)\n const baseZIndex = 50 + index * 10;\n\n return (\n <Modal\n key={modal.id}\n open={true}\n onClose={() => closeModal(modal.id)}\n zIndex={baseZIndex}\n {...modal.props}\n />\n );\n })}\n </ModalContext.Provider>\n );\n}\n\n/**\n * Use Modal Context\n *\n * Access modal management functions.\n */\nexport function useModalContext(): ModalContextValue {\n const context = React.useContext(ModalContext);\n\n if (!context) {\n throw new Error(\"useModalContext must be used within ModalProvider\");\n }\n\n return context;\n}\n","/**\n * useModal Hook\n *\n * Hook for programmatic modal control.\n */\n\nimport { useModalContext } from \"../context/modal-context.js\";\nimport type { ModalProps } from \"../types/index.js\";\n\n/**\n * Use Modal\n *\n * Get modal control functions for a specific modal ID.\n */\nexport function useModal(id: string) {\n const { openModal, closeModal, isModalOpen } = useModalContext();\n\n return {\n /**\n * Open this modal\n */\n open: (props: Omit<ModalProps, \"open\" | \"onClose\">) =>\n openModal(id, props),\n\n /**\n * Close this modal\n */\n close: () => closeModal(id),\n\n /**\n * Check if this modal is open\n */\n isOpen: isModalOpen(id),\n };\n}\n","/**\n * Global Modal Utilities Hook\n *\n * Provides convenient methods for common modal patterns:\n * - confirm(): Confirmation dialogs\n * - alert(): Alert dialogs\n * - prompt(): Input dialogs\n */\n\nimport * as React from \"react\";\nimport { useModalContext } from \"../context/index.js\";\nimport type { ModalProps } from \"../types/index.js\";\n\nexport interface ConfirmOptions {\n title: string;\n message: string;\n confirmText?: string;\n cancelText?: string;\n variant?: \"default\" | \"destructive\";\n}\n\nexport interface AlertOptions {\n title: string;\n message: string;\n okText?: string;\n}\n\nexport interface PromptOptions {\n title: string;\n message?: string;\n placeholder?: string;\n defaultValue?: string;\n confirmText?: string;\n cancelText?: string;\n validate?: (value: string) => boolean | string;\n}\n\n/**\n * Hook providing global modal utilities\n */\nexport function useModals() {\n const context = useModalContext();\n\n /**\n * Show confirmation dialog\n * @returns Promise that resolves to true if confirmed, false if cancelled\n */\n const confirm = React.useCallback(\n (options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n const modalId = `confirm-${Date.now()}`;\n let resolved = false;\n\n const handleConfirm = () => {\n if (resolved) return;\n resolved = true;\n context.closeModal(modalId);\n resolve(true);\n };\n\n const handleCancel = () => {\n if (resolved) return;\n resolved = true;\n context.closeModal(modalId);\n resolve(false);\n };\n\n const handleDismiss = () => {\n if (resolved) return;\n resolved = true;\n resolve(false);\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n onClose: handleDismiss,\n children: (\n <div className=\"space-y-4\">\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n <div className=\"flex justify-end gap-2\">\n <button\n onClick={handleCancel}\n className=\"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700\"\n >\n {options.cancelText || \"Cancel\"}\n </button>\n <button\n onClick={handleConfirm}\n className={`px-4 py-2 text-sm font-medium text-white rounded-md ${\n options.variant === \"destructive\"\n ? \"bg-red-600 hover:bg-red-700\"\n : \"bg-blue-600 hover:bg-blue-700\"\n }`}\n >\n {options.confirmText || \"Confirm\"}\n </button>\n </div>\n </div>\n ),\n });\n });\n },\n [context]\n );\n\n /**\n * Show alert dialog\n * @returns Promise that resolves when dismissed\n */\n const alert = React.useCallback(\n (options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n const modalId = `alert-${Date.now()}`;\n let resolved = false;\n\n const handleOk = () => {\n if (resolved) return;\n resolved = true;\n context.closeModal(modalId);\n resolve();\n };\n\n const handleDismiss = () => {\n if (resolved) return;\n resolved = true;\n resolve();\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n onClose: handleDismiss,\n children: (\n <div className=\"space-y-4\">\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n <div className=\"flex justify-end\">\n <button\n onClick={handleOk}\n className=\"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700\"\n >\n {options.okText || \"OK\"}\n </button>\n </div>\n </div>\n ),\n });\n });\n },\n [context]\n );\n\n /**\n * Show prompt dialog\n * @returns Promise that resolves to the input value if confirmed, null if cancelled\n */\n const prompt = React.useCallback(\n (options: PromptOptions): Promise<string | null> => {\n return new Promise((resolve) => {\n const modalId = `prompt-${Date.now()}`;\n let inputValue = options.defaultValue || \"\";\n let errorMessage = \"\";\n let resolved = false;\n\n const handleDismiss = () => {\n if (resolved) return;\n resolved = true;\n resolve(null);\n };\n\n const PromptContent = () => {\n const [value, setValue] = React.useState(inputValue);\n const [error, setError] = React.useState(\"\");\n\n const handleConfirm = () => {\n if (options.validate) {\n const validation = options.validate(value);\n if (validation === false || typeof validation === \"string\") {\n setError(typeof validation === \"string\" ? validation : \"Invalid input\");\n return;\n }\n }\n if (resolved) return;\n resolved = true;\n context.closeModal(modalId);\n resolve(value);\n };\n\n const handleCancel = () => {\n if (resolved) return;\n resolved = true;\n context.closeModal(modalId);\n resolve(null);\n };\n\n return (\n <div className=\"space-y-4\">\n {options.message && (\n <p className=\"text-sm text-gray-600 dark:text-gray-400\">\n {options.message}\n </p>\n )}\n <div>\n <input\n type=\"text\"\n value={value}\n onChange={(e) => {\n setValue(e.target.value);\n setError(\"\");\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleConfirm();\n if (e.key === \"Escape\") handleCancel();\n }}\n placeholder={options.placeholder}\n autoFocus\n className=\"w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-600 dark:text-white\"\n />\n {error && (\n <p className=\"mt-1 text-xs text-red-600 dark:text-red-400\">\n {error}\n </p>\n )}\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n onClick={handleCancel}\n className=\"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700\"\n >\n {options.cancelText || \"Cancel\"}\n </button>\n <button\n onClick={handleConfirm}\n className=\"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700\"\n >\n {options.confirmText || \"OK\"}\n </button>\n </div>\n </div>\n );\n };\n\n context.openModal(modalId, {\n title: options.title,\n size: \"sm\",\n dismissable: true,\n showClose: false,\n onClose: handleDismiss,\n children: <PromptContent />,\n });\n });\n },\n [context]\n );\n\n return {\n confirm,\n alert,\n prompt,\n ...context,\n };\n}\n"],"mappings":";AAOA,YAAY,YAAY;AACxB,SAAS,YAAY;AAoCb,cA6BI,YA7BJ;AAjCR,IAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAOO,SAAS,MAAM;AAAA,EACpB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,YAAY;AAAA,EACZ;AAAA,EACA,cAAc;AAAA,EACd,SAAS;AACX,GAAe;AAGb,QAAM,gBAAgB;AACtB,QAAM,gBAAgB,SAAS;AAE/B,SACE,oBAAQ,aAAP,EAAY,MAAY,cAAc,CAACA,UAAS,CAACA,SAAQ,UAAU,GAClE,+BAAQ,eAAP,EACC;AAAA;AAAA,MAAQ;AAAA,MAAP;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,QAAQ,cAAc;AAAA;AAAA,IACjC;AAAA,IACA;AAAA,MAAQ;AAAA,MAAP;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,IAAI;AAAA,UAChB;AAAA,QACF;AAAA,QACA,OAAO,EAAE,QAAQ,cAAc;AAAA,QAC/B,iBAAiB,CAAC,MAAM;AACtB,cAAI,CAAC,aAAa;AAChB,cAAE,eAAe;AAAA,UACnB;AAAA,QACF;AAAA,QACA,sBAAsB,CAAC,MAAM;AAC3B,cAAI,CAAC,aAAa;AAChB,cAAE,eAAe;AAAA,UACnB;AAAA,QACF;AAAA,QAEE;AAAA,oBAAS,gBACT,qBAAC,SAAI,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