@sproutsocial/seeds-react-modal 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.turbo/turbo-build.log +39 -19
  2. package/CHANGELOG.md +8 -0
  3. package/dist/Modal-ki8oiGbC.d.mts +69 -0
  4. package/dist/Modal-ki8oiGbC.d.ts +69 -0
  5. package/dist/ModalRail-OQ8DZ1vH.d.mts +178 -0
  6. package/dist/ModalRail-OQ8DZ1vH.d.ts +178 -0
  7. package/dist/esm/chunk-GKQRFPCX.js +642 -0
  8. package/dist/esm/chunk-GKQRFPCX.js.map +1 -0
  9. package/dist/esm/chunk-IYDY4OPB.js +237 -0
  10. package/dist/esm/chunk-IYDY4OPB.js.map +1 -0
  11. package/dist/esm/index.js +28 -235
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/v1/index.js +9 -0
  14. package/dist/esm/v1/index.js.map +1 -0
  15. package/dist/esm/v2/index.js +39 -0
  16. package/dist/esm/v2/index.js.map +1 -0
  17. package/dist/index.d.mts +11 -66
  18. package/dist/index.d.ts +11 -66
  19. package/dist/index.js +658 -17
  20. package/dist/index.js.map +1 -1
  21. package/dist/v1/index.d.mts +11 -0
  22. package/dist/v1/index.d.ts +11 -0
  23. package/dist/v1/index.js +273 -0
  24. package/dist/v1/index.js.map +1 -0
  25. package/dist/v2/index.d.mts +26 -0
  26. package/dist/v2/index.d.ts +26 -0
  27. package/dist/v2/index.js +694 -0
  28. package/dist/v2/index.js.map +1 -0
  29. package/package.json +33 -13
  30. package/src/Modal.stories.tsx +1 -1
  31. package/src/__tests__/v1/Modal.test.tsx +134 -0
  32. package/src/__tests__/v1/Modal.typetest.tsx +209 -0
  33. package/src/index.ts +36 -3
  34. package/src/shared/constants.ts +28 -0
  35. package/src/v1/Modal.tsx +159 -0
  36. package/src/v1/ModalTypes.ts +67 -0
  37. package/src/v1/index.ts +14 -0
  38. package/src/v1/styles.tsx +141 -0
  39. package/src/v2/ModalV2.stories.tsx +282 -0
  40. package/src/v2/ModalV2.tsx +306 -0
  41. package/src/v2/ModalV2Styles.tsx +150 -0
  42. package/src/v2/ModalV2Types.ts +158 -0
  43. package/src/v2/components/ModalClose.tsx +29 -0
  44. package/src/v2/components/ModalCloseButton.tsx +100 -0
  45. package/src/v2/components/ModalContent.tsx +16 -0
  46. package/src/v2/components/ModalDescription.tsx +19 -0
  47. package/src/v2/components/ModalFooter.tsx +20 -0
  48. package/src/v2/components/ModalHeader.tsx +52 -0
  49. package/src/v2/components/ModalRail.tsx +121 -0
  50. package/src/v2/components/ModalTrigger.tsx +39 -0
  51. package/src/v2/components/index.ts +8 -0
  52. package/src/v2/index.ts +37 -0
  53. package/tsconfig.json +7 -1
  54. package/tsup.config.ts +5 -1
@@ -0,0 +1,642 @@
1
+ // src/v2/ModalV2.tsx
2
+ import * as React10 from "react";
3
+ import * as Dialog8 from "@radix-ui/react-dialog";
4
+
5
+ // src/v2/ModalV2Styles.tsx
6
+ import "react";
7
+ import styled from "styled-components";
8
+ import { width, zIndex } from "styled-system";
9
+ import * as Dialog from "@radix-ui/react-dialog";
10
+ import { COMMON } from "@sproutsocial/seeds-react-system-props";
11
+ import Box from "@sproutsocial/seeds-react-box";
12
+
13
+ // src/shared/constants.ts
14
+ var DEFAULT_MODAL_Z_INDEX = 6;
15
+ var DEFAULT_OVERLAY_Z_INDEX_OFFSET = -1;
16
+ var DEFAULT_MODAL_WIDTH = "600px";
17
+ var DEFAULT_MODAL_BG = "container.background.base";
18
+ var BODY_PADDING = "64px";
19
+ var MODAL_SIZE_PRESETS = {
20
+ small: "400px",
21
+ medium: "600px",
22
+ large: "800px",
23
+ full: "90vw"
24
+ };
25
+ var MODAL_PRIORITY_Z_INDEX = {
26
+ low: 100,
27
+ medium: 1e3,
28
+ high: 2e3
29
+ };
30
+
31
+ // src/v2/ModalV2Styles.tsx
32
+ var StyledOverlay = styled(Dialog.Overlay)`
33
+ position: fixed;
34
+ top: 0px;
35
+ left: 0px;
36
+ right: 0px;
37
+ bottom: 0px;
38
+ background-color: ${(props) => props.theme.colors.overlay.background.base};
39
+ opacity: 0;
40
+ will-change: opacity;
41
+ transition: opacity ${(props) => props.theme.duration.medium}
42
+ ${(props) => props.theme.easing.ease_inout};
43
+ z-index: ${(props) => props.zIndex ? props.zIndex + DEFAULT_OVERLAY_Z_INDEX_OFFSET : 999};
44
+
45
+ ${zIndex}
46
+
47
+ &[data-state="open"] {
48
+ opacity: 1;
49
+ }
50
+ &[data-state="closed"] {
51
+ opacity: 0;
52
+ }
53
+ `;
54
+ var StyledContent = styled(Dialog.Content)`
55
+ position: fixed;
56
+ ${(props) => props.draggable ? `
57
+ top: 50%;
58
+ left: 50%;
59
+ transform: translate(-50%, -50%);
60
+ ` : `
61
+ top: 50%;
62
+ left: 50%;
63
+ transform: translate(-50%, -50%);
64
+ `}
65
+ display: flex;
66
+ flex-direction: column;
67
+ border-radius: ${(props) => props.theme.radii[600]};
68
+ box-shadow: ${(props) => props.theme.shadows.medium};
69
+ filter: blur(0);
70
+ color: ${(props) => props.theme.colors.text.body};
71
+ outline: none;
72
+ max-width: calc(100vw - ${BODY_PADDING});
73
+ max-height: calc(100vh - ${BODY_PADDING});
74
+ z-index: ${(props) => props.zIndex || 1e3};
75
+
76
+ /* Draggable styling */
77
+ ${(props) => props.draggable && `
78
+ cursor: ${props.isDragging ? "grabbing" : "grab"};
79
+ user-select: none;
80
+ `}
81
+
82
+ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
83
+ height: calc(100vh - ${BODY_PADDING});
84
+ }
85
+
86
+ ${width}
87
+ ${COMMON}
88
+
89
+ /* Enhanced Radix Dialog animations */
90
+ opacity: 0;
91
+ ${(props) => !props.draggable ? `
92
+ transform: translate(-50%, -50%) scale(0.95);
93
+ transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout},
94
+ transform ${props.theme.duration.medium} ${props.theme.easing.ease_inout};
95
+ ` : `
96
+ transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout};
97
+ `}
98
+
99
+ &[data-state="open"] {
100
+ opacity: 1;
101
+ ${(props) => !props.draggable ? `transform: translate(-50%, -50%) scale(1);` : ``}
102
+ }
103
+ &[data-state="closed"] {
104
+ opacity: 0;
105
+ ${(props) => !props.draggable ? `transform: translate(-50%, -50%) scale(0.95);` : ``}
106
+ }
107
+ `;
108
+ var Content2 = styled(Box)`
109
+ font-family: ${(props) => props.theme.fontFamily};
110
+ min-height: 80px;
111
+ overflow-y: auto;
112
+ flex: 1 1 auto;
113
+ padding: 0 ${(props) => props.theme.space[300]}
114
+ ${(props) => props.theme.space[300]} ${(props) => props.theme.space[300]};
115
+ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
116
+ flex-basis: 100%;
117
+ }
118
+ `;
119
+ var Header = styled(Box)`
120
+ font-family: ${(props) => props.theme.fontFamily};
121
+ padding: ${(props) => props.theme.space[400]}
122
+ ${(props) => props.theme.space[300]};
123
+ display: flex;
124
+ align-items: center;
125
+ justify-content: space-between;
126
+ flex: 0 0 auto;
127
+ `;
128
+ var Footer = styled(Box)`
129
+ flex: 0 0 auto;
130
+ font-family: ${(props) => props.theme.fontFamily};
131
+ padding: ${(props) => props.theme.space[400]}
132
+ ${(props) => props.theme.space[300]};
133
+ border-bottom-right-radius: ${(props) => props.theme.radii[500]};
134
+ border-bottom-left-radius: ${(props) => props.theme.radii[500]};
135
+ display: flex;
136
+ align-items: center;
137
+ justify-content: flex-end;
138
+ gap: ${(props) => props.theme.space[100]};
139
+ `;
140
+ StyledOverlay.displayName = "ModalOverlay";
141
+ StyledContent.displayName = "ModalContent";
142
+ Content2.displayName = "ModalContent";
143
+ Header.displayName = "ModalHeader";
144
+ Footer.displayName = "ModalFooter";
145
+
146
+ // src/v2/components/ModalHeader.tsx
147
+ import * as React3 from "react";
148
+ import * as Dialog3 from "@radix-ui/react-dialog";
149
+ import Box2 from "@sproutsocial/seeds-react-box";
150
+ import Text from "@sproutsocial/seeds-react-text";
151
+
152
+ // src/v2/components/ModalCloseButton.tsx
153
+ import * as React2 from "react";
154
+ import * as Dialog2 from "@radix-ui/react-dialog";
155
+ import styled2 from "styled-components";
156
+ import Icon from "@sproutsocial/seeds-react-icon";
157
+ import { jsx } from "react/jsx-runtime";
158
+ var CloseButtonWrapper = styled2.button`
159
+ width: ${(p) => p.size || 44}px;
160
+ height: ${(p) => p.size || 44}px;
161
+ display: inline-grid;
162
+ place-items: center;
163
+ border-radius: 8px;
164
+ border: none;
165
+ background: rgba(22, 32, 32, 0.56);
166
+ color: #ffffff;
167
+ cursor: pointer;
168
+ outline: none;
169
+ transition: all 0.2s ease;
170
+
171
+ ${(p) => p.position === "absolute" && `
172
+ position: absolute;
173
+ top: 0px;
174
+ ${p.side || "right"}: ${p.offset || -48}px;
175
+ z-index: 1;
176
+ `}
177
+
178
+ &:hover {
179
+ background: rgba(22, 32, 32, 0.7);
180
+ transform: translateY(-1px);
181
+ }
182
+
183
+ &:active {
184
+ transform: translateY(0);
185
+ }
186
+
187
+ &:focus-visible {
188
+ box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #205bc3;
189
+ }
190
+
191
+ &:disabled {
192
+ opacity: 0.5;
193
+ cursor: not-allowed;
194
+ }
195
+ `;
196
+ var ModalCloseButton = (props) => {
197
+ const {
198
+ children,
199
+ onClick,
200
+ asChild,
201
+ closeButtonLabel = "Close modal",
202
+ size = 44,
203
+ position = "absolute",
204
+ side = "right",
205
+ offset = -48,
206
+ ...rest
207
+ } = props;
208
+ const handleClick = (e) => {
209
+ onClick?.(e);
210
+ };
211
+ if (asChild) {
212
+ return /* @__PURE__ */ jsx(Dialog2.Close, { asChild: true, children: React2.cloneElement(children, {
213
+ onClick: handleClick,
214
+ ...rest
215
+ }) });
216
+ }
217
+ return /* @__PURE__ */ jsx(Dialog2.Close, { asChild: true, children: /* @__PURE__ */ jsx(
218
+ CloseButtonWrapper,
219
+ {
220
+ onClick: handleClick,
221
+ size,
222
+ position,
223
+ side,
224
+ offset,
225
+ "aria-label": closeButtonLabel,
226
+ title: closeButtonLabel,
227
+ ...rest,
228
+ children: children || /* @__PURE__ */ jsx(Icon, { name: "x-outline", size: "small" })
229
+ }
230
+ ) });
231
+ };
232
+ ModalCloseButton.displayName = "ModalCloseButton";
233
+
234
+ // src/v2/components/ModalHeader.tsx
235
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
236
+ var ModalHeader = (props) => {
237
+ const {
238
+ title,
239
+ subtitle,
240
+ children,
241
+ bordered,
242
+ titleProps = {},
243
+ subtitleProps = {},
244
+ showInlineClose,
245
+ ...rest
246
+ } = props;
247
+ return /* @__PURE__ */ jsx2(Header, { ...rest, children: children ? children : /* @__PURE__ */ jsxs(React3.Fragment, { children: [
248
+ /* @__PURE__ */ jsxs(Box2, { children: [
249
+ title && /* @__PURE__ */ jsx2(Dialog3.Title, { asChild: true, ...titleProps, children: /* @__PURE__ */ jsx2(Text.Headline, { children: title }) }),
250
+ subtitle && /* @__PURE__ */ jsx2(Dialog3.Description, { asChild: true, ...subtitleProps, children: /* @__PURE__ */ jsx2(Text, { as: "div", fontSize: 200, children: subtitle }) })
251
+ ] }),
252
+ showInlineClose && /* @__PURE__ */ jsx2(Box2, { display: "flex", alignItems: "center", justifyContent: "flex-end", children: /* @__PURE__ */ jsx2(ModalCloseButton, { position: "relative", offset: 0 }) })
253
+ ] }) });
254
+ };
255
+ ModalHeader.displayName = "ModalHeader";
256
+
257
+ // src/v2/components/ModalFooter.tsx
258
+ import "react";
259
+ import { jsx as jsx3 } from "react/jsx-runtime";
260
+ var ModalFooter = (props) => {
261
+ const { bg = DEFAULT_MODAL_BG, children, ...rest } = props;
262
+ return /* @__PURE__ */ jsx3(
263
+ Footer,
264
+ {
265
+ bg,
266
+ borderTop: 500,
267
+ borderColor: "container.border.base",
268
+ ...rest,
269
+ children
270
+ }
271
+ );
272
+ };
273
+ ModalFooter.displayName = "ModalFooter";
274
+
275
+ // src/v2/components/ModalContent.tsx
276
+ import * as React5 from "react";
277
+ import { jsx as jsx4 } from "react/jsx-runtime";
278
+ var ModalContent = React5.forwardRef(({ children, ...rest }, ref) => {
279
+ return /* @__PURE__ */ jsx4(Content2, { "data-qa-modal": true, ref, ...rest, children });
280
+ });
281
+ ModalContent.displayName = "ModalContent";
282
+
283
+ // src/v2/components/ModalDescription.tsx
284
+ import * as React6 from "react";
285
+ import * as Dialog4 from "@radix-ui/react-dialog";
286
+ import Box3 from "@sproutsocial/seeds-react-box";
287
+ import { jsx as jsx5 } from "react/jsx-runtime";
288
+ var ModalDescription = React6.forwardRef(({ children, descriptionProps = {}, ...rest }, ref) => {
289
+ return /* @__PURE__ */ jsx5(Dialog4.Description, { asChild: true, ...descriptionProps, children: /* @__PURE__ */ jsx5(Box3, { ref, ...rest, children }) });
290
+ });
291
+ ModalDescription.displayName = "ModalDescription";
292
+
293
+ // src/v2/components/ModalTrigger.tsx
294
+ import * as React7 from "react";
295
+ import * as Dialog5 from "@radix-ui/react-dialog";
296
+ import Button from "@sproutsocial/seeds-react-button";
297
+ import { jsx as jsx6 } from "react/jsx-runtime";
298
+ var ModalTrigger = (props) => {
299
+ const { children, onClick, asChild, ...rest } = props;
300
+ const handleClick = (e) => {
301
+ onClick?.(e);
302
+ };
303
+ if (asChild) {
304
+ return /* @__PURE__ */ jsx6(Dialog5.Trigger, { asChild: true, children: React7.cloneElement(children, {
305
+ onClick: handleClick,
306
+ ...rest
307
+ }) });
308
+ }
309
+ return /* @__PURE__ */ jsx6(Dialog5.Trigger, { asChild: true, children: /* @__PURE__ */ jsx6(Button, { onClick: handleClick, ...rest, children }) });
310
+ };
311
+ ModalTrigger.displayName = "ModalTrigger";
312
+
313
+ // src/v2/components/ModalClose.tsx
314
+ import "react";
315
+ import * as Dialog6 from "@radix-ui/react-dialog";
316
+ import { jsx as jsx7 } from "react/jsx-runtime";
317
+ var ModalClose = (props) => {
318
+ const { children, onClick, asChild = false, ...rest } = props;
319
+ const handleClick = (e) => {
320
+ onClick?.(e);
321
+ };
322
+ return /* @__PURE__ */ jsx7(Dialog6.Close, { asChild, onClick: handleClick, ...rest, children });
323
+ };
324
+ ModalClose.displayName = "ModalClose";
325
+
326
+ // src/v2/components/ModalRail.tsx
327
+ import * as React9 from "react";
328
+ import * as Dialog7 from "@radix-ui/react-dialog";
329
+ import styled3 from "styled-components";
330
+ import Icon2 from "@sproutsocial/seeds-react-icon";
331
+ import { jsx as jsx8 } from "react/jsx-runtime";
332
+ var Rail = styled3.div`
333
+ position: absolute;
334
+ top: ${(p) => p.offset}px;
335
+ ${(p) => p.side === "right" ? `right: calc(-1 * (${p.size}px + ${p.offset}px));` : `left: calc(-1 * (${p.size}px + ${p.offset}px));`}
336
+ display: grid;
337
+ grid-auto-flow: row;
338
+ gap: ${(p) => p.gap}px;
339
+ z-index: 1;
340
+
341
+ @media (max-width: ${(p) => p.collapseAt}px) {
342
+ ${(p) => p.side === "right" ? `right: ${p.offset}px;` : `left: ${p.offset}px;`}
343
+ }
344
+ `;
345
+ var RailBtn = styled3.button`
346
+ width: ${(p) => p.size}px;
347
+ height: ${(p) => p.size}px;
348
+ display: inline-grid;
349
+ place-items: center;
350
+ border-radius: 8px;
351
+ border: none;
352
+ background: rgba(22, 32, 32, 0.56);
353
+ color: #ffffff;
354
+ cursor: pointer;
355
+ outline: none;
356
+ transition: all 0.2s ease;
357
+
358
+ &:hover {
359
+ background: rgba(22, 32, 32, 0.7);
360
+ transform: translateY(-1px);
361
+ }
362
+
363
+ &:active {
364
+ transform: translateY(0);
365
+ }
366
+
367
+ &:focus-visible {
368
+ box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #205bc3;
369
+ }
370
+
371
+ &:disabled {
372
+ opacity: 0.5;
373
+ cursor: not-allowed;
374
+ }
375
+ `;
376
+ var ModalRail = ({
377
+ side = "right",
378
+ offset = 12,
379
+ gap = 12,
380
+ size = 44,
381
+ collapseAt = 640,
382
+ children
383
+ }) => {
384
+ return /* @__PURE__ */ jsx8(
385
+ Rail,
386
+ {
387
+ "data-slot": "modal-rail",
388
+ side,
389
+ offset,
390
+ gap,
391
+ size,
392
+ collapseAt,
393
+ "aria-label": "Modal quick actions",
394
+ children: React9.Children.map(
395
+ children,
396
+ (child) => React9.isValidElement(child) ? React9.cloneElement(child, { size }) : child
397
+ )
398
+ }
399
+ );
400
+ };
401
+ var ModalAction = ({
402
+ "aria-label": ariaLabel,
403
+ iconName,
404
+ disabled,
405
+ size = 44,
406
+ actionType,
407
+ onClick,
408
+ ...rest
409
+ }) => {
410
+ const Btn = /* @__PURE__ */ jsx8(
411
+ RailBtn,
412
+ {
413
+ size,
414
+ "aria-label": ariaLabel,
415
+ title: ariaLabel,
416
+ disabled,
417
+ ...rest,
418
+ children: iconName ? /* @__PURE__ */ jsx8(Icon2, { name: iconName, size: "small" }) : ariaLabel
419
+ }
420
+ );
421
+ return actionType === "close" ? /* @__PURE__ */ jsx8(Dialog7.Close, { asChild: true, children: Btn }) : React9.cloneElement(Btn, { onClick });
422
+ };
423
+
424
+ // src/v2/ModalV2.tsx
425
+ import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
426
+ var DraggableModalContent = ({
427
+ children,
428
+ computedWidth,
429
+ bg,
430
+ computedZIndex,
431
+ label,
432
+ dataAttributes,
433
+ draggable,
434
+ rest
435
+ }) => {
436
+ const [position, setPosition] = React10.useState({ x: 0, y: 0 });
437
+ const [isDragging, setIsDragging] = React10.useState(false);
438
+ const contentRef = React10.useRef(null);
439
+ const handleMouseDown = React10.useCallback(
440
+ (e) => {
441
+ if (!draggable) return;
442
+ const target = e.target;
443
+ if (target.tagName === "BUTTON" || target.tagName === "INPUT" || target.closest("button")) {
444
+ return;
445
+ }
446
+ e.preventDefault();
447
+ setIsDragging(true);
448
+ const rect = contentRef.current?.getBoundingClientRect();
449
+ if (!rect) return;
450
+ const offsetX = e.clientX - rect.left;
451
+ const offsetY = e.clientY - rect.top;
452
+ const handleMouseMove = (e2) => {
453
+ e2.preventDefault();
454
+ const newX = e2.clientX - offsetX;
455
+ const newY = e2.clientY - offsetY;
456
+ const modalWidth = rect.width;
457
+ const modalHeight = rect.height;
458
+ const maxX = window.innerWidth - modalWidth;
459
+ const minX = 0;
460
+ const maxY = window.innerHeight - modalHeight;
461
+ const minY = 0;
462
+ const constrainedX = Math.max(minX, Math.min(maxX, newX));
463
+ const constrainedY = Math.max(minY, Math.min(maxY, newY));
464
+ const centerX = window.innerWidth / 2 - modalWidth / 2;
465
+ const centerY = window.innerHeight / 2 - modalHeight / 2;
466
+ setPosition({
467
+ x: constrainedX - centerX,
468
+ y: constrainedY - centerY
469
+ });
470
+ };
471
+ const handleMouseUp = () => {
472
+ setIsDragging(false);
473
+ document.removeEventListener("mousemove", handleMouseMove);
474
+ document.removeEventListener("mouseup", handleMouseUp);
475
+ };
476
+ document.addEventListener("mousemove", handleMouseMove);
477
+ document.addEventListener("mouseup", handleMouseUp);
478
+ },
479
+ [draggable]
480
+ );
481
+ return /* @__PURE__ */ jsx9(
482
+ StyledContent,
483
+ {
484
+ ref: contentRef,
485
+ width: computedWidth,
486
+ bg,
487
+ zIndex: computedZIndex,
488
+ "aria-label": label,
489
+ draggable,
490
+ isDragging,
491
+ onMouseDown: handleMouseDown,
492
+ style: draggable ? {
493
+ transform: `translate(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px))`,
494
+ transition: isDragging ? "none" : void 0
495
+ } : void 0,
496
+ ...dataAttributes,
497
+ ...rest,
498
+ children
499
+ }
500
+ );
501
+ };
502
+ var Modal = (props) => {
503
+ const {
504
+ children,
505
+ modalTrigger,
506
+ draggable = false,
507
+ open,
508
+ defaultOpen,
509
+ onOpenChange,
510
+ "aria-label": label,
511
+ title,
512
+ subtitle,
513
+ description,
514
+ size,
515
+ priority,
516
+ data = {},
517
+ bg = DEFAULT_MODAL_BG,
518
+ showOverlay = true,
519
+ actions,
520
+ railProps,
521
+ ...rest
522
+ } = props;
523
+ const handleOpenChange = React10.useCallback(
524
+ (newOpen) => {
525
+ onOpenChange?.(newOpen);
526
+ },
527
+ [onOpenChange]
528
+ );
529
+ const computedWidth = React10.useMemo(() => {
530
+ if (size) {
531
+ if (typeof size === "string" && size in MODAL_SIZE_PRESETS) {
532
+ return MODAL_SIZE_PRESETS[size];
533
+ }
534
+ return size;
535
+ }
536
+ return DEFAULT_MODAL_WIDTH;
537
+ }, [size]);
538
+ const computedZIndex = React10.useMemo(() => {
539
+ if (priority) {
540
+ return MODAL_PRIORITY_Z_INDEX[priority];
541
+ }
542
+ return DEFAULT_MODAL_Z_INDEX;
543
+ }, [priority]);
544
+ const dataAttributes = React10.useMemo(() => {
545
+ const attrs = {};
546
+ Object.entries(data).forEach(([key, value]) => {
547
+ attrs[`data-${key}`] = String(value);
548
+ });
549
+ attrs["data-qa-modal"] = "";
550
+ if (open !== void 0) {
551
+ attrs["data-qa-modal-open"] = String(open);
552
+ }
553
+ return attrs;
554
+ }, [data, open]);
555
+ const shouldRenderHeader = Boolean(title || subtitle);
556
+ const dialogRootProps = React10.useMemo(() => {
557
+ const props2 = {};
558
+ if (open !== void 0) {
559
+ props2.open = open;
560
+ } else if (defaultOpen !== void 0) {
561
+ props2.defaultOpen = defaultOpen;
562
+ } else {
563
+ props2.defaultOpen = false;
564
+ }
565
+ if (onOpenChange) {
566
+ props2.onOpenChange = handleOpenChange;
567
+ }
568
+ return props2;
569
+ }, [open, defaultOpen, handleOpenChange, onOpenChange]);
570
+ const triggers = [];
571
+ const content = [];
572
+ if (modalTrigger) {
573
+ triggers.push(
574
+ /* @__PURE__ */ jsx9(Dialog8.Trigger, { asChild: true, children: modalTrigger }, "modal-trigger")
575
+ );
576
+ content.push(children);
577
+ } else {
578
+ React10.Children.forEach(children, (child) => {
579
+ if (React10.isValidElement(child) && child.type === ModalTrigger) {
580
+ triggers.push(child);
581
+ } else {
582
+ content.push(child);
583
+ }
584
+ });
585
+ }
586
+ return /* @__PURE__ */ jsxs2(Dialog8.Root, { ...dialogRootProps, children: [
587
+ triggers,
588
+ /* @__PURE__ */ jsxs2(Dialog8.Portal, { children: [
589
+ showOverlay && /* @__PURE__ */ jsx9(StyledOverlay, { zIndex: computedZIndex }),
590
+ /* @__PURE__ */ jsxs2(
591
+ DraggableModalContent,
592
+ {
593
+ computedWidth,
594
+ bg,
595
+ computedZIndex,
596
+ label,
597
+ dataAttributes,
598
+ draggable,
599
+ rest,
600
+ children: [
601
+ /* @__PURE__ */ jsxs2(ModalRail, { ...railProps, children: [
602
+ /* @__PURE__ */ jsx9(
603
+ ModalAction,
604
+ {
605
+ actionType: "close",
606
+ "aria-label": "Close",
607
+ iconName: "x-outline"
608
+ }
609
+ ),
610
+ actions?.map((action, idx) => /* @__PURE__ */ jsx9(ModalAction, { ...action }, idx))
611
+ ] }),
612
+ shouldRenderHeader && /* @__PURE__ */ jsx9(ModalHeader, { title, subtitle }),
613
+ description && /* @__PURE__ */ jsx9(ModalDescription, { children: description }),
614
+ content
615
+ ]
616
+ }
617
+ )
618
+ ] })
619
+ ] });
620
+ };
621
+ var ModalV2_default = Modal;
622
+
623
+ export {
624
+ DEFAULT_MODAL_Z_INDEX,
625
+ DEFAULT_OVERLAY_Z_INDEX_OFFSET,
626
+ DEFAULT_MODAL_WIDTH,
627
+ DEFAULT_MODAL_BG,
628
+ BODY_PADDING,
629
+ MODAL_SIZE_PRESETS,
630
+ MODAL_PRIORITY_Z_INDEX,
631
+ ModalCloseButton,
632
+ ModalHeader,
633
+ ModalFooter,
634
+ ModalContent,
635
+ ModalDescription,
636
+ ModalTrigger,
637
+ ModalClose,
638
+ ModalRail,
639
+ ModalAction,
640
+ ModalV2_default
641
+ };
642
+ //# sourceMappingURL=chunk-GKQRFPCX.js.map