@sproutsocial/seeds-react-modal 2.5.9 → 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/dist/index.js CHANGED
@@ -297,12 +297,12 @@ var Modal_default = Modal;
297
297
  var v1_default = Modal_default;
298
298
 
299
299
  // src/v2/Modal.tsx
300
- var React14 = __toESM(require("react"));
300
+ var React13 = __toESM(require("react"));
301
301
  var Dialog6 = __toESM(require("@radix-ui/react-dialog"));
302
302
  var import_react6 = require("motion/react");
303
303
 
304
304
  // src/v2/components/ModalHeader.tsx
305
- var React5 = require("react");
305
+ var React4 = require("react");
306
306
  var Dialog2 = __toESM(require("@radix-ui/react-dialog"));
307
307
  var import_styled_components3 = __toESM(require("styled-components"));
308
308
  var import_seeds_react_box3 = __toESM(require("@sproutsocial/seeds-react-box"));
@@ -310,7 +310,7 @@ var import_seeds_react_text2 = __toESM(require("@sproutsocial/seeds-react-text")
310
310
  var import_seeds_react_system_props3 = require("@sproutsocial/seeds-react-system-props");
311
311
 
312
312
  // src/v2/components/ModalContent.tsx
313
- var React4 = __toESM(require("react"));
313
+ var React3 = __toESM(require("react"));
314
314
  var Dialog = __toESM(require("@radix-ui/react-dialog"));
315
315
  var import_react3 = require("motion/react");
316
316
  var import_styled_components2 = __toESM(require("styled-components"));
@@ -319,7 +319,6 @@ var import_seeds_react_portal = require("@sproutsocial/seeds-react-portal");
319
319
  // src/shared/constants.ts
320
320
  var DEFAULT_MODAL_WIDTH = "800px";
321
321
  var BODY_PADDING2 = "64px";
322
- var MOBILE_BREAKPOINT = "780px";
323
322
  var RAIL_BUTTON_SIZE = 44;
324
323
  var RAIL_OFFSET = 12;
325
324
  var RAIL_GAP = 12;
@@ -329,17 +328,11 @@ var RAIL_EXTRA_SPACE = RAIL_BUTTON_SIZE + RAIL_OFFSET;
329
328
  var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
330
329
 
331
330
  // src/v2/MotionConfig.ts
332
- var React3 = __toESM(require("react"));
333
- var DURATION_MOBILE = 0.6;
334
331
  var DURATION_DESKTOP = 0.3;
335
332
  var desktopTransition = {
336
333
  duration: DURATION_DESKTOP,
337
334
  ease: "easeInOut"
338
335
  };
339
- var mobileTransition = {
340
- duration: DURATION_MOBILE,
341
- ease: "easeInOut"
342
- };
343
336
  var desktopModalVariants = {
344
337
  initial: {
345
338
  opacity: 0,
@@ -377,40 +370,6 @@ var desktopOverlayVariants = {
377
370
  transition: desktopTransition
378
371
  }
379
372
  };
380
- var mobileDrawerVariants = {
381
- initial: {
382
- opacity: 0,
383
- x: "-50%",
384
- y: "100%",
385
- transition: mobileTransition
386
- },
387
- animate: {
388
- opacity: 1,
389
- x: "-50%",
390
- y: 0,
391
- transition: mobileTransition
392
- },
393
- exit: {
394
- opacity: 0,
395
- x: "-50%",
396
- y: "100%",
397
- transition: mobileTransition
398
- }
399
- };
400
- var mobileOverlayVariants = {
401
- initial: {
402
- opacity: 0,
403
- transition: mobileTransition
404
- },
405
- animate: {
406
- opacity: 1,
407
- transition: mobileTransition
408
- },
409
- exit: {
410
- opacity: 0,
411
- transition: mobileTransition
412
- }
413
- };
414
373
  var draggableModalVariants = {
415
374
  initial: {
416
375
  opacity: 0,
@@ -425,42 +384,19 @@ var draggableModalVariants = {
425
384
  transition: desktopTransition
426
385
  }
427
386
  };
428
- function getContentVariants(isMobile, isDraggable) {
429
- if (isDraggable) {
430
- return draggableModalVariants;
431
- }
432
- return isMobile ? mobileDrawerVariants : desktopModalVariants;
433
- }
434
- function getOverlayVariants(isMobile) {
435
- return isMobile ? mobileOverlayVariants : desktopOverlayVariants;
387
+ function getContentVariants(isDraggable) {
388
+ return isDraggable ? draggableModalVariants : desktopModalVariants;
436
389
  }
437
- function useIsMobile() {
438
- const [isMobile, setIsMobile] = React3.useState(() => {
439
- if (typeof window === "undefined") return false;
440
- return window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT})`).matches;
441
- });
442
- React3.useEffect(() => {
443
- if (typeof window === "undefined") return;
444
- const mediaQuery = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT})`);
445
- const handler = (e) => setIsMobile(e.matches);
446
- if (mediaQuery.addEventListener) {
447
- mediaQuery.addEventListener("change", handler);
448
- return () => mediaQuery.removeEventListener("change", handler);
449
- } else if (mediaQuery.addListener) {
450
- mediaQuery.addListener(handler);
451
- return () => mediaQuery.removeListener(handler);
452
- }
453
- }, []);
454
- return isMobile;
390
+ function getOverlayVariants() {
391
+ return desktopOverlayVariants;
455
392
  }
456
393
 
457
394
  // src/v2/components/ModalContent.tsx
458
395
  var import_jsx_runtime3 = require("react/jsx-runtime");
459
396
  var StyledMotionWrapper = (0, import_styled_components2.default)(import_react3.motion.div)`
460
397
  position: fixed;
461
- top: ${(props) => props.$isMobile ? "auto" : "50%"};
398
+ top: 50%;
462
399
  left: 50%;
463
- bottom: ${(props) => props.$isMobile ? 0 : "auto"};
464
400
  z-index: ${(props) => props.$zIndex ? props.$zIndex + 1 : 7};
465
401
  `;
466
402
  var StyledContent = import_styled_components2.default.div.withConfig({
@@ -475,33 +411,10 @@ var StyledContent = import_styled_components2.default.div.withConfig({
475
411
  color: ${(props) => props.theme.colors.text.body};
476
412
  outline: none;
477
413
  width: ${DEFAULT_MODAL_WIDTH};
478
- max-width: ${(props) => {
479
- return `calc(100vw - ${BODY_PADDING2} - ${RAIL_EXTRA_SPACE}px)`;
480
- }};
414
+ /* Account for rail space on the side; shrinks to fit small viewports */
415
+ max-width: calc(100vw - ${BODY_PADDING2} - ${RAIL_EXTRA_SPACE}px);
481
416
  max-height: calc(100vh - ${BODY_PADDING2});
482
417
 
483
- /* Mobile styles for viewport <= ${MOBILE_BREAKPOINT} */
484
- @media (max-width: ${MOBILE_BREAKPOINT}) {
485
- /* Full viewport width - edge to edge */
486
- width: 100vw;
487
- max-width: 100vw;
488
- min-width: 100vw;
489
-
490
- /* Height hugs content, with increased max-height to get closer to top */
491
- /* Subtract space for rail + comfortable gap (44px rail + ~40px gap) */
492
- height: auto;
493
- max-height: calc(95vh - 84px);
494
-
495
- /* Adjust border radius for mobile - rounded top, flat bottom to blend with device */
496
- border-top-left-radius: ${(props) => props.theme.radii[800]};
497
- border-top-right-radius: ${(props) => props.theme.radii[800]};
498
- border-bottom-left-radius: 0;
499
- border-bottom-right-radius: 0;
500
-
501
- /* Mobile shadow - appears to cast upward (high-reverse) */
502
- box-shadow: 0px -16px 32px 0px rgba(39, 51, 51, 0.24);
503
- }
504
-
505
418
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
506
419
  height: calc(100vh - ${BODY_PADDING2});
507
420
  }
@@ -512,9 +425,9 @@ var StyledContent = import_styled_components2.default.div.withConfig({
512
425
  ${import_seeds_react_system_props2.LAYOUT}
513
426
  `;
514
427
  StyledContent.displayName = "ModalContent";
515
- var DragContext = React4.createContext(null);
428
+ var DragContext = React3.createContext(null);
516
429
  var useDragContext = () => {
517
- const context = React4.useContext(DragContext);
430
+ const context = React3.useContext(DragContext);
518
431
  return context;
519
432
  };
520
433
  var StaticModalContent = ({
@@ -525,12 +438,10 @@ var StaticModalContent = ({
525
438
  rest,
526
439
  dialogContentProps
527
440
  }) => {
528
- const isMobile = useIsMobile();
529
- const contentVariants = getContentVariants(isMobile, false);
441
+ const contentVariants = getContentVariants(false);
530
442
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DragContext.Provider, { value: null, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dialog.Content, { asChild: true, "aria-label": label, ...dialogContentProps, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
531
443
  StyledMotionWrapper,
532
444
  {
533
- $isMobile: isMobile,
534
445
  $zIndex: zIndex2,
535
446
  variants: contentVariants,
536
447
  initial: "initial",
@@ -557,11 +468,10 @@ var DraggableModalContent = ({
557
468
  rest,
558
469
  dialogContentProps
559
470
  }) => {
560
- const [position, setPosition] = React4.useState({ x: 0, y: 0 });
561
- const [isDragging, setIsDragging] = React4.useState(false);
562
- const contentRef = React4.useRef(null);
563
- const isMobile = useIsMobile();
564
- const handleHeaderMouseDown = React4.useCallback((e) => {
471
+ const [position, setPosition] = React3.useState({ x: 0, y: 0 });
472
+ const [isDragging, setIsDragging] = React3.useState(false);
473
+ const contentRef = React3.useRef(null);
474
+ const handleHeaderMouseDown = React3.useCallback((e) => {
565
475
  const target = e.target;
566
476
  if (target.tagName === "BUTTON" || target.tagName === "INPUT" || target.closest("button")) {
567
477
  return;
@@ -576,18 +486,12 @@ var DraggableModalContent = ({
576
486
  e2.preventDefault();
577
487
  const newX = e2.clientX - offsetX;
578
488
  const newY = e2.clientY - offsetY;
579
- const isRailOnSide = window.innerWidth > 780;
580
489
  const modalWidth = rect.width;
581
490
  const modalHeight = rect.height;
582
- let maxX = window.innerWidth - modalWidth;
583
- let minX = 0;
584
- let maxY = window.innerHeight - modalHeight;
585
- let minY = 0;
586
- if (isRailOnSide) {
587
- maxX = window.innerWidth - modalWidth - RAIL_EXTRA_SPACE;
588
- } else {
589
- minY = RAIL_BUTTON_SIZE + RAIL_OFFSET;
590
- }
491
+ const minX = 0;
492
+ const maxX = window.innerWidth - modalWidth - RAIL_EXTRA_SPACE;
493
+ const minY = 0;
494
+ const maxY = window.innerHeight - modalHeight;
591
495
  const constrainedX = Math.max(minX, Math.min(maxX, newX));
592
496
  const constrainedY = Math.max(minY, Math.min(maxY, newY));
593
497
  const centerX = window.innerWidth / 2 - modalWidth / 2;
@@ -605,7 +509,7 @@ var DraggableModalContent = ({
605
509
  document.addEventListener("mousemove", handleMouseMove);
606
510
  document.addEventListener("mouseup", handleMouseUp);
607
511
  }, []);
608
- const dragContextValue = React4.useMemo(
512
+ const dragContextValue = React3.useMemo(
609
513
  () => ({
610
514
  position,
611
515
  isDragging,
@@ -615,10 +519,10 @@ var DraggableModalContent = ({
615
519
  }),
616
520
  [position, isDragging, handleHeaderMouseDown]
617
521
  );
618
- const handleInteractOutside = React4.useCallback((e) => {
522
+ const handleInteractOutside = React3.useCallback((e) => {
619
523
  e.preventDefault();
620
524
  }, []);
621
- const contentVariants = getContentVariants(isMobile, true);
525
+ const contentVariants = getContentVariants(true);
622
526
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DragContext.Provider, { value: dragContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
623
527
  Dialog.Content,
624
528
  {
@@ -629,7 +533,6 @@ var DraggableModalContent = ({
629
533
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
630
534
  StyledMotionWrapper,
631
535
  {
632
- $isMobile: isMobile,
633
536
  $zIndex: zIndex2,
634
537
  variants: contentVariants,
635
538
  initial: "initial",
@@ -714,13 +617,13 @@ var ModalHeader2 = (props) => {
714
617
  ModalHeader2.displayName = "ModalHeader";
715
618
 
716
619
  // src/v2/components/ModalFooter.tsx
717
- var React7 = require("react");
620
+ var React6 = require("react");
718
621
  var import_styled_components4 = __toESM(require("styled-components"));
719
622
  var import_seeds_react_box4 = __toESM(require("@sproutsocial/seeds-react-box"));
720
623
  var import_seeds_react_system_props4 = require("@sproutsocial/seeds-react-system-props");
721
624
 
722
625
  // src/v2/components/ModalCloseWrapper.tsx
723
- var React6 = __toESM(require("react"));
626
+ var React5 = __toESM(require("react"));
724
627
  var Dialog3 = __toESM(require("@radix-ui/react-dialog"));
725
628
  var import_jsx_runtime5 = require("react/jsx-runtime");
726
629
  var ModalCloseWrapper = (props) => {
@@ -728,7 +631,7 @@ var ModalCloseWrapper = (props) => {
728
631
  const handleClick = (e) => {
729
632
  onClick?.(e);
730
633
  };
731
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Dialog3.Close, { asChild, onClick: handleClick, ...rest, children: React6.isValidElement(children) ? React6.cloneElement(children, {
634
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Dialog3.Close, { asChild, onClick: handleClick, ...rest, children: React5.isValidElement(children) ? React5.cloneElement(children, {
732
635
  "data-slot": "modal-close-wrapper",
733
636
  "data-qa-modal-close-wrapper": "",
734
637
  ...children.props || {}
@@ -750,12 +653,6 @@ var ModalCustomFooter = (0, import_styled_components4.default)(import_seeds_reac
750
653
  justify-content: flex-end;
751
654
  gap: ${(props) => props.theme.space[100]};
752
655
 
753
- /* Flat bottom corners to blend with device edge on mobile */
754
- @media (max-width: ${MOBILE_BREAKPOINT}) {
755
- border-bottom-right-radius: 0;
756
- border-bottom-left-radius: 0;
757
- }
758
-
759
656
  ${import_seeds_react_system_props4.COMMON}
760
657
  ${import_seeds_react_system_props4.FLEXBOX}
761
658
  ${import_seeds_react_system_props4.BORDER}
@@ -785,7 +682,7 @@ var ModalFooter2 = (props) => {
785
682
  ModalFooter2.displayName = "ModalFooter";
786
683
 
787
684
  // src/v2/components/ModalBody.tsx
788
- var React8 = __toESM(require("react"));
685
+ var React7 = __toESM(require("react"));
789
686
  var import_styled_components5 = __toESM(require("styled-components"));
790
687
  var import_seeds_react_box5 = __toESM(require("@sproutsocial/seeds-react-box"));
791
688
  var import_seeds_react_system_props5 = require("@sproutsocial/seeds-react-system-props");
@@ -807,7 +704,7 @@ var StyledModalBody = (0, import_styled_components5.default)(import_seeds_react_
807
704
  ${import_seeds_react_system_props5.LAYOUT}
808
705
  `;
809
706
  StyledModalBody.displayName = "ModalBody";
810
- var ModalBody = React8.forwardRef(
707
+ var ModalBody = React7.forwardRef(
811
708
  ({ children, ...rest }, ref) => {
812
709
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
813
710
  StyledModalBody,
@@ -824,11 +721,11 @@ var ModalBody = React8.forwardRef(
824
721
  ModalBody.displayName = "ModalBody";
825
722
 
826
723
  // src/v2/components/ModalDescription.tsx
827
- var React9 = __toESM(require("react"));
724
+ var React8 = __toESM(require("react"));
828
725
  var Dialog4 = __toESM(require("@radix-ui/react-dialog"));
829
726
  var import_seeds_react_box6 = __toESM(require("@sproutsocial/seeds-react-box"));
830
727
  var import_jsx_runtime8 = require("react/jsx-runtime");
831
- var ModalDescription = React9.forwardRef(({ children, descriptionProps = {}, ...rest }, ref) => {
728
+ var ModalDescription = React8.forwardRef(({ children, descriptionProps = {}, ...rest }, ref) => {
832
729
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Dialog4.Description, { asChild: true, ...descriptionProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
833
730
  import_seeds_react_box6.default,
834
731
  {
@@ -843,7 +740,7 @@ var ModalDescription = React9.forwardRef(({ children, descriptionProps = {}, ...
843
740
  ModalDescription.displayName = "ModalDescription";
844
741
 
845
742
  // src/v2/components/ModalRail.tsx
846
- var React10 = require("react");
743
+ var React9 = require("react");
847
744
  var import_styled_components6 = __toESM(require("styled-components"));
848
745
  var import_jsx_runtime9 = require("react/jsx-runtime");
849
746
  var Rail = import_styled_components6.default.div`
@@ -854,16 +751,6 @@ var Rail = import_styled_components6.default.div`
854
751
  flex-direction: column;
855
752
  gap: ${RAIL_GAP}px;
856
753
  z-index: 1;
857
-
858
- @media (max-width: ${MOBILE_BREAKPOINT}) {
859
- /* Move rail above the modal on the right side */
860
- top: auto;
861
- bottom: calc(100% + ${RAIL_OFFSET}px);
862
- right: ${RAIL_OFFSET}px;
863
- left: auto;
864
- /* Change to horizontal layout with reversed order */
865
- flex-direction: row-reverse;
866
- }
867
754
  `;
868
755
  var ModalRail = ({ children }) => {
869
756
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -879,7 +766,7 @@ var ModalRail = ({ children }) => {
879
766
  ModalRail.displayName = "ModalRail";
880
767
 
881
768
  // src/v2/components/ModalAction.tsx
882
- var React11 = require("react");
769
+ var React10 = require("react");
883
770
  var Dialog5 = __toESM(require("@radix-ui/react-dialog"));
884
771
  var import_styled_components8 = __toESM(require("styled-components"));
885
772
  var import_seeds_react_icon2 = __toESM(require("@sproutsocial/seeds-react-icon"));
@@ -1005,11 +892,11 @@ var ModalAction = ({
1005
892
  ModalAction.displayName = "ModalAction";
1006
893
 
1007
894
  // src/v2/components/ModalExternalTrigger.tsx
1008
- var React12 = __toESM(require("react"));
895
+ var React11 = __toESM(require("react"));
1009
896
  var import_seeds_react_button2 = require("@sproutsocial/seeds-react-button");
1010
897
  var import_jsx_runtime11 = require("react/jsx-runtime");
1011
- var ModalExternalTrigger = React12.forwardRef(({ isOpen, onTrigger, modalId, onClick, ...buttonProps }, ref) => {
1012
- const handleClick = React12.useCallback(
898
+ var ModalExternalTrigger = React11.forwardRef(({ isOpen, onTrigger, modalId, onClick, ...buttonProps }, ref) => {
899
+ const handleClick = React11.useCallback(
1013
900
  (e) => {
1014
901
  onClick?.(e);
1015
902
  if (!e.defaultPrevented) {
@@ -1096,15 +983,15 @@ var Modal2 = (props) => {
1096
983
  disableEscapeKeyClose = false,
1097
984
  ...rest
1098
985
  } = props;
1099
- const [isOpen, setIsOpen] = React14.useState(defaultOpen ?? false);
1100
- const handleOpenChange = React14.useCallback(
986
+ const [isOpen, setIsOpen] = React13.useState(defaultOpen ?? false);
987
+ const handleOpenChange = React13.useCallback(
1101
988
  (newOpen) => {
1102
989
  setIsOpen(newOpen);
1103
990
  onOpenChange?.(newOpen);
1104
991
  },
1105
992
  [onOpenChange]
1106
993
  );
1107
- const dataAttributes = React14.useMemo(() => {
994
+ const dataAttributes = React13.useMemo(() => {
1108
995
  const attrs = {};
1109
996
  Object.entries(data).forEach(([key, value]) => {
1110
997
  attrs[`data-${key}`] = String(value);
@@ -1116,10 +1003,9 @@ var Modal2 = (props) => {
1116
1003
  return attrs;
1117
1004
  }, [data, open]);
1118
1005
  const shouldRenderHeader = Boolean(title || subtitle);
1119
- const isMobile = useIsMobile();
1120
- const overlayVariants = getOverlayVariants(isMobile);
1006
+ const overlayVariants = getOverlayVariants();
1121
1007
  const ModalContentComponent = draggable ? DraggableModalContent : StaticModalContent;
1122
- const wrappedOnInteractOutside = React14.useCallback(
1008
+ const wrappedOnInteractOutside = React13.useCallback(
1123
1009
  (e) => {
1124
1010
  if (disableOutsideClickClose) {
1125
1011
  e.preventDefault();
@@ -1128,12 +1014,16 @@ var Modal2 = (props) => {
1128
1014
  },
1129
1015
  [disableOutsideClickClose, onInteractOutside]
1130
1016
  );
1131
- const wrappedOnEscapeKeyDown = React14.useCallback(
1017
+ const wrappedOnEscapeKeyDown = React13.useCallback(
1132
1018
  (e) => {
1133
1019
  const hasOpenPopout = document.querySelector("[data-qa-popout]") !== null;
1134
1020
  if (hasOpenPopout) {
1135
1021
  e.preventDefault();
1136
1022
  }
1023
+ const hasOpenBaseUIPopup = document.querySelector("[role='dialog'] [data-open]") !== null;
1024
+ if (hasOpenBaseUIPopup) {
1025
+ e.preventDefault();
1026
+ }
1137
1027
  if (disableEscapeKeyClose) {
1138
1028
  e.preventDefault();
1139
1029
  }
@@ -1211,7 +1101,7 @@ var Modal2 = (props) => {
1211
1101
  );
1212
1102
  };
1213
1103
  function useModalTriggerProps(isOpen, modalId) {
1214
- return React14.useMemo(
1104
+ return React13.useMemo(
1215
1105
  () => ({
1216
1106
  "aria-haspopup": "dialog",
1217
1107
  "aria-expanded": isOpen,
@@ -1221,8 +1111,8 @@ function useModalTriggerProps(isOpen, modalId) {
1221
1111
  );
1222
1112
  }
1223
1113
  function useModalExternalTrigger(modalId) {
1224
- const triggerRef = React14.useRef(null);
1225
- const triggerProps = React14.useCallback(
1114
+ const triggerRef = React13.useRef(null);
1115
+ const triggerProps = React13.useCallback(
1226
1116
  (isOpen) => ({
1227
1117
  "aria-haspopup": "dialog",
1228
1118
  "aria-expanded": isOpen,
@@ -1230,7 +1120,7 @@ function useModalExternalTrigger(modalId) {
1230
1120
  }),
1231
1121
  [modalId]
1232
1122
  );
1233
- const onCloseAutoFocus = React14.useCallback((e) => {
1123
+ const onCloseAutoFocus = React13.useCallback((e) => {
1234
1124
  e.preventDefault();
1235
1125
  triggerRef.current?.focus();
1236
1126
  }, []);