@sproutsocial/seeds-react-modal 2.5.10 → 2.5.22
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/.turbo/turbo-build.log +16 -16
- package/CHANGELOG.md +119 -0
- package/dist/{ModalExternalTrigger-BnbJk9zY.d.mts → ModalExternalTrigger-Bciv1N-P.d.mts} +0 -1
- package/dist/{ModalExternalTrigger-BnbJk9zY.d.ts → ModalExternalTrigger-Bciv1N-P.d.ts} +0 -1
- package/dist/esm/{chunk-XQ2A6HDC.js → chunk-KZ6XTIWT.js} +47 -157
- package/dist/esm/chunk-KZ6XTIWT.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/v2/index.js +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +50 -160
- package/dist/index.js.map +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.d.ts +1 -1
- package/dist/v2/index.js +50 -160
- package/dist/v2/index.js.map +1 -1
- package/package.json +9 -9
- package/src/shared/constants.ts +0 -3
- package/src/v2/Modal.tsx +14 -5
- package/src/v2/ModalV2.stories.tsx +10 -27
- package/src/v2/MotionConfig.ts +5 -97
- package/src/v2/components/ModalAction.tsx +1 -1
- package/src/v2/components/ModalContent.tsx +11 -58
- package/src/v2/components/ModalFooter.tsx +0 -7
- package/src/v2/components/ModalRail.tsx +1 -13
- package/dist/esm/chunk-XQ2A6HDC.js.map +0 -1
package/dist/v2/index.js
CHANGED
|
@@ -51,12 +51,12 @@ __export(v2_exports, {
|
|
|
51
51
|
module.exports = __toCommonJS(v2_exports);
|
|
52
52
|
|
|
53
53
|
// src/v2/Modal.tsx
|
|
54
|
-
var
|
|
54
|
+
var React11 = __toESM(require("react"));
|
|
55
55
|
var Dialog6 = __toESM(require("@radix-ui/react-dialog"));
|
|
56
56
|
var import_react4 = require("motion/react");
|
|
57
57
|
|
|
58
58
|
// src/v2/components/ModalHeader.tsx
|
|
59
|
-
var
|
|
59
|
+
var React2 = require("react");
|
|
60
60
|
var Dialog2 = __toESM(require("@radix-ui/react-dialog"));
|
|
61
61
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
62
62
|
var import_seeds_react_box = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
@@ -64,7 +64,7 @@ var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"))
|
|
|
64
64
|
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
65
65
|
|
|
66
66
|
// src/v2/components/ModalContent.tsx
|
|
67
|
-
var
|
|
67
|
+
var React = __toESM(require("react"));
|
|
68
68
|
var Dialog = __toESM(require("@radix-ui/react-dialog"));
|
|
69
69
|
var import_react = require("motion/react");
|
|
70
70
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -80,7 +80,6 @@ var MODAL_SIZE_PRESETS = {
|
|
|
80
80
|
large: "800px",
|
|
81
81
|
full: "90vw"
|
|
82
82
|
};
|
|
83
|
-
var MOBILE_BREAKPOINT = "780px";
|
|
84
83
|
var RAIL_BUTTON_SIZE = 44;
|
|
85
84
|
var RAIL_OFFSET = 12;
|
|
86
85
|
var RAIL_GAP = 12;
|
|
@@ -90,17 +89,11 @@ var RAIL_EXTRA_SPACE = RAIL_BUTTON_SIZE + RAIL_OFFSET;
|
|
|
90
89
|
var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
|
|
91
90
|
|
|
92
91
|
// src/v2/MotionConfig.ts
|
|
93
|
-
var React = __toESM(require("react"));
|
|
94
|
-
var DURATION_MOBILE = 0.6;
|
|
95
92
|
var DURATION_DESKTOP = 0.3;
|
|
96
93
|
var desktopTransition = {
|
|
97
94
|
duration: DURATION_DESKTOP,
|
|
98
95
|
ease: "easeInOut"
|
|
99
96
|
};
|
|
100
|
-
var mobileTransition = {
|
|
101
|
-
duration: DURATION_MOBILE,
|
|
102
|
-
ease: "easeInOut"
|
|
103
|
-
};
|
|
104
97
|
var desktopModalVariants = {
|
|
105
98
|
initial: {
|
|
106
99
|
opacity: 0,
|
|
@@ -138,40 +131,6 @@ var desktopOverlayVariants = {
|
|
|
138
131
|
transition: desktopTransition
|
|
139
132
|
}
|
|
140
133
|
};
|
|
141
|
-
var mobileDrawerVariants = {
|
|
142
|
-
initial: {
|
|
143
|
-
opacity: 0,
|
|
144
|
-
x: "-50%",
|
|
145
|
-
y: "100%",
|
|
146
|
-
transition: mobileTransition
|
|
147
|
-
},
|
|
148
|
-
animate: {
|
|
149
|
-
opacity: 1,
|
|
150
|
-
x: "-50%",
|
|
151
|
-
y: 0,
|
|
152
|
-
transition: mobileTransition
|
|
153
|
-
},
|
|
154
|
-
exit: {
|
|
155
|
-
opacity: 0,
|
|
156
|
-
x: "-50%",
|
|
157
|
-
y: "100%",
|
|
158
|
-
transition: mobileTransition
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var mobileOverlayVariants = {
|
|
162
|
-
initial: {
|
|
163
|
-
opacity: 0,
|
|
164
|
-
transition: mobileTransition
|
|
165
|
-
},
|
|
166
|
-
animate: {
|
|
167
|
-
opacity: 1,
|
|
168
|
-
transition: mobileTransition
|
|
169
|
-
},
|
|
170
|
-
exit: {
|
|
171
|
-
opacity: 0,
|
|
172
|
-
transition: mobileTransition
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
134
|
var draggableModalVariants = {
|
|
176
135
|
initial: {
|
|
177
136
|
opacity: 0,
|
|
@@ -186,42 +145,19 @@ var draggableModalVariants = {
|
|
|
186
145
|
transition: desktopTransition
|
|
187
146
|
}
|
|
188
147
|
};
|
|
189
|
-
function getContentVariants(
|
|
190
|
-
|
|
191
|
-
return draggableModalVariants;
|
|
192
|
-
}
|
|
193
|
-
return isMobile ? mobileDrawerVariants : desktopModalVariants;
|
|
148
|
+
function getContentVariants(isDraggable) {
|
|
149
|
+
return isDraggable ? draggableModalVariants : desktopModalVariants;
|
|
194
150
|
}
|
|
195
|
-
function getOverlayVariants(
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
function useIsMobile() {
|
|
199
|
-
const [isMobile, setIsMobile] = React.useState(() => {
|
|
200
|
-
if (typeof window === "undefined") return false;
|
|
201
|
-
return window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT})`).matches;
|
|
202
|
-
});
|
|
203
|
-
React.useEffect(() => {
|
|
204
|
-
if (typeof window === "undefined") return;
|
|
205
|
-
const mediaQuery = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT})`);
|
|
206
|
-
const handler = (e) => setIsMobile(e.matches);
|
|
207
|
-
if (mediaQuery.addEventListener) {
|
|
208
|
-
mediaQuery.addEventListener("change", handler);
|
|
209
|
-
return () => mediaQuery.removeEventListener("change", handler);
|
|
210
|
-
} else if (mediaQuery.addListener) {
|
|
211
|
-
mediaQuery.addListener(handler);
|
|
212
|
-
return () => mediaQuery.removeListener(handler);
|
|
213
|
-
}
|
|
214
|
-
}, []);
|
|
215
|
-
return isMobile;
|
|
151
|
+
function getOverlayVariants() {
|
|
152
|
+
return desktopOverlayVariants;
|
|
216
153
|
}
|
|
217
154
|
|
|
218
155
|
// src/v2/components/ModalContent.tsx
|
|
219
156
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
220
157
|
var StyledMotionWrapper = (0, import_styled_components.default)(import_react.motion.div)`
|
|
221
158
|
position: fixed;
|
|
222
|
-
top:
|
|
159
|
+
top: 50%;
|
|
223
160
|
left: 50%;
|
|
224
|
-
bottom: ${(props) => props.$isMobile ? 0 : "auto"};
|
|
225
161
|
z-index: ${(props) => props.$zIndex ? props.$zIndex + 1 : 7};
|
|
226
162
|
`;
|
|
227
163
|
var StyledContent = import_styled_components.default.div.withConfig({
|
|
@@ -236,33 +172,10 @@ var StyledContent = import_styled_components.default.div.withConfig({
|
|
|
236
172
|
color: ${(props) => props.theme.colors.text.body};
|
|
237
173
|
outline: none;
|
|
238
174
|
width: ${DEFAULT_MODAL_WIDTH};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}};
|
|
175
|
+
/* Account for rail space on the side; shrinks to fit small viewports */
|
|
176
|
+
max-width: calc(100vw - ${BODY_PADDING} - ${RAIL_EXTRA_SPACE}px);
|
|
242
177
|
max-height: calc(100vh - ${BODY_PADDING});
|
|
243
178
|
|
|
244
|
-
/* Mobile styles for viewport <= ${MOBILE_BREAKPOINT} */
|
|
245
|
-
@media (max-width: ${MOBILE_BREAKPOINT}) {
|
|
246
|
-
/* Full viewport width - edge to edge */
|
|
247
|
-
width: 100vw;
|
|
248
|
-
max-width: 100vw;
|
|
249
|
-
min-width: 100vw;
|
|
250
|
-
|
|
251
|
-
/* Height hugs content, with increased max-height to get closer to top */
|
|
252
|
-
/* Subtract space for rail + comfortable gap (44px rail + ~40px gap) */
|
|
253
|
-
height: auto;
|
|
254
|
-
max-height: calc(95vh - 84px);
|
|
255
|
-
|
|
256
|
-
/* Adjust border radius for mobile - rounded top, flat bottom to blend with device */
|
|
257
|
-
border-top-left-radius: ${(props) => props.theme.radii[800]};
|
|
258
|
-
border-top-right-radius: ${(props) => props.theme.radii[800]};
|
|
259
|
-
border-bottom-left-radius: 0;
|
|
260
|
-
border-bottom-right-radius: 0;
|
|
261
|
-
|
|
262
|
-
/* Mobile shadow - appears to cast upward (high-reverse) */
|
|
263
|
-
box-shadow: 0px -16px 32px 0px rgba(39, 51, 51, 0.24);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
179
|
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
267
180
|
height: calc(100vh - ${BODY_PADDING});
|
|
268
181
|
}
|
|
@@ -273,9 +186,9 @@ var StyledContent = import_styled_components.default.div.withConfig({
|
|
|
273
186
|
${import_seeds_react_system_props.LAYOUT}
|
|
274
187
|
`;
|
|
275
188
|
StyledContent.displayName = "ModalContent";
|
|
276
|
-
var DragContext =
|
|
189
|
+
var DragContext = React.createContext(null);
|
|
277
190
|
var useDragContext = () => {
|
|
278
|
-
const context =
|
|
191
|
+
const context = React.useContext(DragContext);
|
|
279
192
|
return context;
|
|
280
193
|
};
|
|
281
194
|
var StaticModalContent = ({
|
|
@@ -286,12 +199,10 @@ var StaticModalContent = ({
|
|
|
286
199
|
rest,
|
|
287
200
|
dialogContentProps
|
|
288
201
|
}) => {
|
|
289
|
-
const
|
|
290
|
-
const contentVariants = getContentVariants(isMobile, false);
|
|
202
|
+
const contentVariants = getContentVariants(false);
|
|
291
203
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragContext.Provider, { value: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog.Content, { asChild: true, "aria-label": label, ...dialogContentProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
292
204
|
StyledMotionWrapper,
|
|
293
205
|
{
|
|
294
|
-
$isMobile: isMobile,
|
|
295
206
|
$zIndex: zIndex,
|
|
296
207
|
variants: contentVariants,
|
|
297
208
|
initial: "initial",
|
|
@@ -318,11 +229,10 @@ var DraggableModalContent = ({
|
|
|
318
229
|
rest,
|
|
319
230
|
dialogContentProps
|
|
320
231
|
}) => {
|
|
321
|
-
const [position, setPosition] =
|
|
322
|
-
const [isDragging, setIsDragging] =
|
|
323
|
-
const contentRef =
|
|
324
|
-
const
|
|
325
|
-
const handleHeaderMouseDown = React2.useCallback((e) => {
|
|
232
|
+
const [position, setPosition] = React.useState({ x: 0, y: 0 });
|
|
233
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
234
|
+
const contentRef = React.useRef(null);
|
|
235
|
+
const handleHeaderMouseDown = React.useCallback((e) => {
|
|
326
236
|
const target = e.target;
|
|
327
237
|
if (target.tagName === "BUTTON" || target.tagName === "INPUT" || target.closest("button")) {
|
|
328
238
|
return;
|
|
@@ -337,18 +247,12 @@ var DraggableModalContent = ({
|
|
|
337
247
|
e2.preventDefault();
|
|
338
248
|
const newX = e2.clientX - offsetX;
|
|
339
249
|
const newY = e2.clientY - offsetY;
|
|
340
|
-
const isRailOnSide = window.innerWidth > 780;
|
|
341
250
|
const modalWidth = rect.width;
|
|
342
251
|
const modalHeight = rect.height;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (isRailOnSide) {
|
|
348
|
-
maxX = window.innerWidth - modalWidth - RAIL_EXTRA_SPACE;
|
|
349
|
-
} else {
|
|
350
|
-
minY = RAIL_BUTTON_SIZE + RAIL_OFFSET;
|
|
351
|
-
}
|
|
252
|
+
const minX = 0;
|
|
253
|
+
const maxX = window.innerWidth - modalWidth - RAIL_EXTRA_SPACE;
|
|
254
|
+
const minY = 0;
|
|
255
|
+
const maxY = window.innerHeight - modalHeight;
|
|
352
256
|
const constrainedX = Math.max(minX, Math.min(maxX, newX));
|
|
353
257
|
const constrainedY = Math.max(minY, Math.min(maxY, newY));
|
|
354
258
|
const centerX = window.innerWidth / 2 - modalWidth / 2;
|
|
@@ -366,7 +270,7 @@ var DraggableModalContent = ({
|
|
|
366
270
|
document.addEventListener("mousemove", handleMouseMove);
|
|
367
271
|
document.addEventListener("mouseup", handleMouseUp);
|
|
368
272
|
}, []);
|
|
369
|
-
const dragContextValue =
|
|
273
|
+
const dragContextValue = React.useMemo(
|
|
370
274
|
() => ({
|
|
371
275
|
position,
|
|
372
276
|
isDragging,
|
|
@@ -376,10 +280,10 @@ var DraggableModalContent = ({
|
|
|
376
280
|
}),
|
|
377
281
|
[position, isDragging, handleHeaderMouseDown]
|
|
378
282
|
);
|
|
379
|
-
const handleInteractOutside =
|
|
283
|
+
const handleInteractOutside = React.useCallback((e) => {
|
|
380
284
|
e.preventDefault();
|
|
381
285
|
}, []);
|
|
382
|
-
const contentVariants = getContentVariants(
|
|
286
|
+
const contentVariants = getContentVariants(true);
|
|
383
287
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragContext.Provider, { value: dragContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
384
288
|
Dialog.Content,
|
|
385
289
|
{
|
|
@@ -390,7 +294,6 @@ var DraggableModalContent = ({
|
|
|
390
294
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
391
295
|
StyledMotionWrapper,
|
|
392
296
|
{
|
|
393
|
-
$isMobile: isMobile,
|
|
394
297
|
$zIndex: zIndex,
|
|
395
298
|
variants: contentVariants,
|
|
396
299
|
initial: "initial",
|
|
@@ -475,13 +378,13 @@ var ModalHeader = (props) => {
|
|
|
475
378
|
ModalHeader.displayName = "ModalHeader";
|
|
476
379
|
|
|
477
380
|
// src/v2/components/ModalFooter.tsx
|
|
478
|
-
var
|
|
381
|
+
var React4 = require("react");
|
|
479
382
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
480
383
|
var import_seeds_react_box2 = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
481
384
|
var import_seeds_react_system_props3 = require("@sproutsocial/seeds-react-system-props");
|
|
482
385
|
|
|
483
386
|
// src/v2/components/ModalCloseWrapper.tsx
|
|
484
|
-
var
|
|
387
|
+
var React3 = __toESM(require("react"));
|
|
485
388
|
var Dialog3 = __toESM(require("@radix-ui/react-dialog"));
|
|
486
389
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
487
390
|
var ModalCloseWrapper = (props) => {
|
|
@@ -489,7 +392,7 @@ var ModalCloseWrapper = (props) => {
|
|
|
489
392
|
const handleClick = (e) => {
|
|
490
393
|
onClick?.(e);
|
|
491
394
|
};
|
|
492
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dialog3.Close, { asChild, onClick: handleClick, ...rest, children:
|
|
395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dialog3.Close, { asChild, onClick: handleClick, ...rest, children: React3.isValidElement(children) ? React3.cloneElement(children, {
|
|
493
396
|
"data-slot": "modal-close-wrapper",
|
|
494
397
|
"data-qa-modal-close-wrapper": "",
|
|
495
398
|
...children.props || {}
|
|
@@ -511,12 +414,6 @@ var ModalCustomFooter = (0, import_styled_components3.default)(import_seeds_reac
|
|
|
511
414
|
justify-content: flex-end;
|
|
512
415
|
gap: ${(props) => props.theme.space[100]};
|
|
513
416
|
|
|
514
|
-
/* Flat bottom corners to blend with device edge on mobile */
|
|
515
|
-
@media (max-width: ${MOBILE_BREAKPOINT}) {
|
|
516
|
-
border-bottom-right-radius: 0;
|
|
517
|
-
border-bottom-left-radius: 0;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
417
|
${import_seeds_react_system_props3.COMMON}
|
|
521
418
|
${import_seeds_react_system_props3.FLEXBOX}
|
|
522
419
|
${import_seeds_react_system_props3.BORDER}
|
|
@@ -546,7 +443,7 @@ var ModalFooter = (props) => {
|
|
|
546
443
|
ModalFooter.displayName = "ModalFooter";
|
|
547
444
|
|
|
548
445
|
// src/v2/components/ModalBody.tsx
|
|
549
|
-
var
|
|
446
|
+
var React5 = __toESM(require("react"));
|
|
550
447
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
551
448
|
var import_seeds_react_box3 = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
552
449
|
var import_seeds_react_system_props4 = require("@sproutsocial/seeds-react-system-props");
|
|
@@ -568,7 +465,7 @@ var StyledModalBody = (0, import_styled_components4.default)(import_seeds_react_
|
|
|
568
465
|
${import_seeds_react_system_props4.LAYOUT}
|
|
569
466
|
`;
|
|
570
467
|
StyledModalBody.displayName = "ModalBody";
|
|
571
|
-
var ModalBody =
|
|
468
|
+
var ModalBody = React5.forwardRef(
|
|
572
469
|
({ children, ...rest }, ref) => {
|
|
573
470
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
574
471
|
StyledModalBody,
|
|
@@ -585,11 +482,11 @@ var ModalBody = React6.forwardRef(
|
|
|
585
482
|
ModalBody.displayName = "ModalBody";
|
|
586
483
|
|
|
587
484
|
// src/v2/components/ModalDescription.tsx
|
|
588
|
-
var
|
|
485
|
+
var React6 = __toESM(require("react"));
|
|
589
486
|
var Dialog4 = __toESM(require("@radix-ui/react-dialog"));
|
|
590
487
|
var import_seeds_react_box4 = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
591
488
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
592
|
-
var ModalDescription =
|
|
489
|
+
var ModalDescription = React6.forwardRef(({ children, descriptionProps = {}, ...rest }, ref) => {
|
|
593
490
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog4.Description, { asChild: true, ...descriptionProps, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
594
491
|
import_seeds_react_box4.default,
|
|
595
492
|
{
|
|
@@ -604,7 +501,7 @@ var ModalDescription = React7.forwardRef(({ children, descriptionProps = {}, ...
|
|
|
604
501
|
ModalDescription.displayName = "ModalDescription";
|
|
605
502
|
|
|
606
503
|
// src/v2/components/ModalRail.tsx
|
|
607
|
-
var
|
|
504
|
+
var React7 = require("react");
|
|
608
505
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
609
506
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
610
507
|
var Rail = import_styled_components5.default.div`
|
|
@@ -615,16 +512,6 @@ var Rail = import_styled_components5.default.div`
|
|
|
615
512
|
flex-direction: column;
|
|
616
513
|
gap: ${RAIL_GAP}px;
|
|
617
514
|
z-index: 1;
|
|
618
|
-
|
|
619
|
-
@media (max-width: ${MOBILE_BREAKPOINT}) {
|
|
620
|
-
/* Move rail above the modal on the right side */
|
|
621
|
-
top: auto;
|
|
622
|
-
bottom: calc(100% + ${RAIL_OFFSET}px);
|
|
623
|
-
right: ${RAIL_OFFSET}px;
|
|
624
|
-
left: auto;
|
|
625
|
-
/* Change to horizontal layout with reversed order */
|
|
626
|
-
flex-direction: row-reverse;
|
|
627
|
-
}
|
|
628
515
|
`;
|
|
629
516
|
var ModalRail = ({ children }) => {
|
|
630
517
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -640,7 +527,7 @@ var ModalRail = ({ children }) => {
|
|
|
640
527
|
ModalRail.displayName = "ModalRail";
|
|
641
528
|
|
|
642
529
|
// src/v2/components/ModalAction.tsx
|
|
643
|
-
var
|
|
530
|
+
var React8 = require("react");
|
|
644
531
|
var Dialog5 = __toESM(require("@radix-ui/react-dialog"));
|
|
645
532
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
646
533
|
var import_seeds_react_icon = __toESM(require("@sproutsocial/seeds-react-icon"));
|
|
@@ -766,11 +653,11 @@ var ModalAction = ({
|
|
|
766
653
|
ModalAction.displayName = "ModalAction";
|
|
767
654
|
|
|
768
655
|
// src/v2/components/ModalExternalTrigger.tsx
|
|
769
|
-
var
|
|
656
|
+
var React9 = __toESM(require("react"));
|
|
770
657
|
var import_seeds_react_button = require("@sproutsocial/seeds-react-button");
|
|
771
658
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
772
|
-
var ModalExternalTrigger =
|
|
773
|
-
const handleClick =
|
|
659
|
+
var ModalExternalTrigger = React9.forwardRef(({ isOpen, onTrigger, modalId, onClick, ...buttonProps }, ref) => {
|
|
660
|
+
const handleClick = React9.useCallback(
|
|
774
661
|
(e) => {
|
|
775
662
|
onClick?.(e);
|
|
776
663
|
if (!e.defaultPrevented) {
|
|
@@ -857,15 +744,15 @@ var Modal = (props) => {
|
|
|
857
744
|
disableEscapeKeyClose = false,
|
|
858
745
|
...rest
|
|
859
746
|
} = props;
|
|
860
|
-
const [isOpen, setIsOpen] =
|
|
861
|
-
const handleOpenChange =
|
|
747
|
+
const [isOpen, setIsOpen] = React11.useState(defaultOpen ?? false);
|
|
748
|
+
const handleOpenChange = React11.useCallback(
|
|
862
749
|
(newOpen) => {
|
|
863
750
|
setIsOpen(newOpen);
|
|
864
751
|
onOpenChange?.(newOpen);
|
|
865
752
|
},
|
|
866
753
|
[onOpenChange]
|
|
867
754
|
);
|
|
868
|
-
const dataAttributes =
|
|
755
|
+
const dataAttributes = React11.useMemo(() => {
|
|
869
756
|
const attrs = {};
|
|
870
757
|
Object.entries(data).forEach(([key, value]) => {
|
|
871
758
|
attrs[`data-${key}`] = String(value);
|
|
@@ -877,10 +764,9 @@ var Modal = (props) => {
|
|
|
877
764
|
return attrs;
|
|
878
765
|
}, [data, open]);
|
|
879
766
|
const shouldRenderHeader = Boolean(title || subtitle);
|
|
880
|
-
const
|
|
881
|
-
const overlayVariants = getOverlayVariants(isMobile);
|
|
767
|
+
const overlayVariants = getOverlayVariants();
|
|
882
768
|
const ModalContentComponent = draggable ? DraggableModalContent : StaticModalContent;
|
|
883
|
-
const wrappedOnInteractOutside =
|
|
769
|
+
const wrappedOnInteractOutside = React11.useCallback(
|
|
884
770
|
(e) => {
|
|
885
771
|
if (disableOutsideClickClose) {
|
|
886
772
|
e.preventDefault();
|
|
@@ -889,12 +775,16 @@ var Modal = (props) => {
|
|
|
889
775
|
},
|
|
890
776
|
[disableOutsideClickClose, onInteractOutside]
|
|
891
777
|
);
|
|
892
|
-
const wrappedOnEscapeKeyDown =
|
|
778
|
+
const wrappedOnEscapeKeyDown = React11.useCallback(
|
|
893
779
|
(e) => {
|
|
894
780
|
const hasOpenPopout = document.querySelector("[data-qa-popout]") !== null;
|
|
895
781
|
if (hasOpenPopout) {
|
|
896
782
|
e.preventDefault();
|
|
897
783
|
}
|
|
784
|
+
const hasOpenBaseUIPopup = document.querySelector("[role='dialog'] [data-open]") !== null;
|
|
785
|
+
if (hasOpenBaseUIPopup) {
|
|
786
|
+
e.preventDefault();
|
|
787
|
+
}
|
|
898
788
|
if (disableEscapeKeyClose) {
|
|
899
789
|
e.preventDefault();
|
|
900
790
|
}
|
|
@@ -972,7 +862,7 @@ var Modal = (props) => {
|
|
|
972
862
|
);
|
|
973
863
|
};
|
|
974
864
|
function useModalTriggerProps(isOpen, modalId) {
|
|
975
|
-
return
|
|
865
|
+
return React11.useMemo(
|
|
976
866
|
() => ({
|
|
977
867
|
"aria-haspopup": "dialog",
|
|
978
868
|
"aria-expanded": isOpen,
|
|
@@ -982,8 +872,8 @@ function useModalTriggerProps(isOpen, modalId) {
|
|
|
982
872
|
);
|
|
983
873
|
}
|
|
984
874
|
function useModalExternalTrigger(modalId) {
|
|
985
|
-
const triggerRef =
|
|
986
|
-
const triggerProps =
|
|
875
|
+
const triggerRef = React11.useRef(null);
|
|
876
|
+
const triggerProps = React11.useCallback(
|
|
987
877
|
(isOpen) => ({
|
|
988
878
|
"aria-haspopup": "dialog",
|
|
989
879
|
"aria-expanded": isOpen,
|
|
@@ -991,7 +881,7 @@ function useModalExternalTrigger(modalId) {
|
|
|
991
881
|
}),
|
|
992
882
|
[modalId]
|
|
993
883
|
);
|
|
994
|
-
const onCloseAutoFocus =
|
|
884
|
+
const onCloseAutoFocus = React11.useCallback((e) => {
|
|
995
885
|
e.preventDefault();
|
|
996
886
|
triggerRef.current?.focus();
|
|
997
887
|
}, []);
|