@sproutsocial/seeds-react-modal 2.2.5 → 2.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/.turbo/turbo-build.log +19 -19
- package/CHANGELOG.md +41 -0
- package/dist/{ModalAction-gIgCE73I.d.mts → ModalAction-BHG3Zbd9.d.mts} +151 -6
- package/dist/{ModalAction-gIgCE73I.d.ts → ModalAction-BHG3Zbd9.d.ts} +151 -6
- package/dist/esm/{chunk-UP2XQN57.js → chunk-TQ44T5IM.js} +114 -17
- package/dist/esm/chunk-TQ44T5IM.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/v2/index.js +9 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +87 -19
- package/dist/index.js.map +1 -1
- package/dist/v2/index.d.mts +77 -3
- package/dist/v2/index.d.ts +77 -3
- package/dist/v2/index.js +121 -21
- package/dist/v2/index.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/v2/Modal.test.tsx +972 -0
- package/src/v2/Modal.tsx +189 -0
- package/src/v2/ModalTypes.ts +57 -10
- package/src/v2/ModalV2.stories.tsx +278 -3
- package/src/v2/components/ModalContent.tsx +13 -1
- package/src/v2/components/ModalExternalTrigger.tsx +104 -0
- package/src/v2/components/index.ts +1 -0
- package/src/v2/index.ts +7 -1
- package/dist/esm/chunk-UP2XQN57.js.map +0 -1
package/dist/v2/index.d.mts
CHANGED
|
@@ -1,11 +1,85 @@
|
|
|
1
|
-
export { M as Modal, g as ModalAction, d as ModalBody, e as ModalCloseWrapper, p as ModalCloseWrapperProps, i as ModalCustomFooter, h as ModalCustomHeader, a as ModalDescription, c as ModalFooter, b as ModalHeader, f as ModalRail, o as TypeModalActionProps, l as TypeModalBodyProps, m as TypeModalDescriptionProps, k as TypeModalFooterProps, j as TypeModalHeaderProps, T as TypeModalProps, n as TypeModalRailProps } from '../ModalAction-
|
|
1
|
+
export { M as Modal, g as ModalAction, d as ModalBody, e as ModalCloseWrapper, p as ModalCloseWrapperProps, i as ModalCustomFooter, h as ModalCustomHeader, a as ModalDescription, c as ModalFooter, b as ModalHeader, f as ModalRail, o as TypeModalActionProps, l as TypeModalBodyProps, m as TypeModalDescriptionProps, k as TypeModalFooterProps, j as TypeModalHeaderProps, T as TypeModalProps, n as TypeModalRailProps, q as useModalExternalTrigger, u as useModalTriggerProps } from '../ModalAction-BHG3Zbd9.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
|
|
2
4
|
import 'react/jsx-runtime';
|
|
3
5
|
import 'styled-components';
|
|
4
6
|
import '@sproutsocial/seeds-react-box';
|
|
5
|
-
import 'react';
|
|
6
7
|
import '@radix-ui/react-dialog';
|
|
7
8
|
import '@sproutsocial/seeds-react-icon';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Props for ModalExternalTrigger component.
|
|
12
|
+
*/
|
|
13
|
+
interface ModalExternalTriggerProps extends Omit<TypeButtonProps, "onClick"> {
|
|
14
|
+
/** Callback when button is clicked to trigger modal open */
|
|
15
|
+
onTrigger: () => void;
|
|
16
|
+
/** Whether the modal is currently open (for ARIA expanded state) */
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
/** Optional modal ID for aria-controls attribute */
|
|
19
|
+
modalId?: string;
|
|
20
|
+
/** Optional onClick handler (called before onTrigger) */
|
|
21
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Button component pre-configured for triggering modals from outside the Modal component tree.
|
|
25
|
+
*
|
|
26
|
+
* ⚠️ **NOT RECOMMENDED** - Prefer using modalTrigger prop or ModalTrigger component.
|
|
27
|
+
* Use this component ONLY as a last resort when architectural constraints prevent keeping
|
|
28
|
+
* the trigger inside the Modal component tree.
|
|
29
|
+
*
|
|
30
|
+
* This component wraps the Seeds Button with automatic ARIA attributes for modal triggers.
|
|
31
|
+
* However, focus restoration still requires manual handling via onCloseAutoFocus callback
|
|
32
|
+
* due to Radix UI's architectural limitations with external triggers.
|
|
33
|
+
*
|
|
34
|
+
* **Why modalTrigger prop is better:**
|
|
35
|
+
* - Automatic ARIA attributes
|
|
36
|
+
* - Automatic focus restoration (no onCloseAutoFocus needed)
|
|
37
|
+
* - Better touch device support
|
|
38
|
+
* - Follows WAI-ARIA Dialog best practices
|
|
39
|
+
*
|
|
40
|
+
* **When to use ModalExternalTrigger:**
|
|
41
|
+
* - Trigger must live outside Modal component tree (e.g., in a page header)
|
|
42
|
+
* - Using Seeds Button as the trigger
|
|
43
|
+
* - Want automatic ARIA attributes without manual hook usage
|
|
44
|
+
*
|
|
45
|
+
* **Usage pattern with focus restoration:**
|
|
46
|
+
* You must still handle focus restoration manually by passing a ref and implementing
|
|
47
|
+
* onCloseAutoFocus on the Modal component.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
* const triggerRef = useRef<HTMLButtonElement>(null);
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <>
|
|
56
|
+
* <ModalExternalTrigger
|
|
57
|
+
* ref={triggerRef}
|
|
58
|
+
* isOpen={isOpen}
|
|
59
|
+
* onTrigger={() => setIsOpen(true)}
|
|
60
|
+
* appearance="primary"
|
|
61
|
+
* >
|
|
62
|
+
* Open Modal
|
|
63
|
+
* </ModalExternalTrigger>
|
|
64
|
+
*
|
|
65
|
+
* <Modal
|
|
66
|
+
* open={isOpen}
|
|
67
|
+
* onOpenChange={setIsOpen}
|
|
68
|
+
* onCloseAutoFocus={(e) => {
|
|
69
|
+
* e.preventDefault();
|
|
70
|
+
* triggerRef.current?.focus();
|
|
71
|
+
* }}
|
|
72
|
+
* >
|
|
73
|
+
* <ModalBody>Content</ModalBody>
|
|
74
|
+
* </Modal>
|
|
75
|
+
* </>
|
|
76
|
+
* );
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @see useModalExternalTrigger - Hook alternative for non-Button triggers
|
|
80
|
+
*/
|
|
81
|
+
declare const ModalExternalTrigger: React.ForwardRefExoticComponent<Omit<ModalExternalTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
82
|
+
|
|
9
83
|
declare const DEFAULT_MODAL_WIDTH = "600px";
|
|
10
84
|
declare const DEFAULT_MODAL_BG = "container.background.base";
|
|
11
85
|
declare const BODY_PADDING = "64px";
|
|
@@ -16,4 +90,4 @@ declare const MODAL_SIZE_PRESETS: {
|
|
|
16
90
|
readonly full: "90vw";
|
|
17
91
|
};
|
|
18
92
|
|
|
19
|
-
export { BODY_PADDING, DEFAULT_MODAL_BG, DEFAULT_MODAL_WIDTH, MODAL_SIZE_PRESETS };
|
|
93
|
+
export { BODY_PADDING, DEFAULT_MODAL_BG, DEFAULT_MODAL_WIDTH, MODAL_SIZE_PRESETS, ModalExternalTrigger, type ModalExternalTriggerProps };
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -1,11 +1,85 @@
|
|
|
1
|
-
export { M as Modal, g as ModalAction, d as ModalBody, e as ModalCloseWrapper, p as ModalCloseWrapperProps, i as ModalCustomFooter, h as ModalCustomHeader, a as ModalDescription, c as ModalFooter, b as ModalHeader, f as ModalRail, o as TypeModalActionProps, l as TypeModalBodyProps, m as TypeModalDescriptionProps, k as TypeModalFooterProps, j as TypeModalHeaderProps, T as TypeModalProps, n as TypeModalRailProps } from '../ModalAction-
|
|
1
|
+
export { M as Modal, g as ModalAction, d as ModalBody, e as ModalCloseWrapper, p as ModalCloseWrapperProps, i as ModalCustomFooter, h as ModalCustomHeader, a as ModalDescription, c as ModalFooter, b as ModalHeader, f as ModalRail, o as TypeModalActionProps, l as TypeModalBodyProps, m as TypeModalDescriptionProps, k as TypeModalFooterProps, j as TypeModalHeaderProps, T as TypeModalProps, n as TypeModalRailProps, q as useModalExternalTrigger, u as useModalTriggerProps } from '../ModalAction-BHG3Zbd9.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
|
|
2
4
|
import 'react/jsx-runtime';
|
|
3
5
|
import 'styled-components';
|
|
4
6
|
import '@sproutsocial/seeds-react-box';
|
|
5
|
-
import 'react';
|
|
6
7
|
import '@radix-ui/react-dialog';
|
|
7
8
|
import '@sproutsocial/seeds-react-icon';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Props for ModalExternalTrigger component.
|
|
12
|
+
*/
|
|
13
|
+
interface ModalExternalTriggerProps extends Omit<TypeButtonProps, "onClick"> {
|
|
14
|
+
/** Callback when button is clicked to trigger modal open */
|
|
15
|
+
onTrigger: () => void;
|
|
16
|
+
/** Whether the modal is currently open (for ARIA expanded state) */
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
/** Optional modal ID for aria-controls attribute */
|
|
19
|
+
modalId?: string;
|
|
20
|
+
/** Optional onClick handler (called before onTrigger) */
|
|
21
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Button component pre-configured for triggering modals from outside the Modal component tree.
|
|
25
|
+
*
|
|
26
|
+
* ⚠️ **NOT RECOMMENDED** - Prefer using modalTrigger prop or ModalTrigger component.
|
|
27
|
+
* Use this component ONLY as a last resort when architectural constraints prevent keeping
|
|
28
|
+
* the trigger inside the Modal component tree.
|
|
29
|
+
*
|
|
30
|
+
* This component wraps the Seeds Button with automatic ARIA attributes for modal triggers.
|
|
31
|
+
* However, focus restoration still requires manual handling via onCloseAutoFocus callback
|
|
32
|
+
* due to Radix UI's architectural limitations with external triggers.
|
|
33
|
+
*
|
|
34
|
+
* **Why modalTrigger prop is better:**
|
|
35
|
+
* - Automatic ARIA attributes
|
|
36
|
+
* - Automatic focus restoration (no onCloseAutoFocus needed)
|
|
37
|
+
* - Better touch device support
|
|
38
|
+
* - Follows WAI-ARIA Dialog best practices
|
|
39
|
+
*
|
|
40
|
+
* **When to use ModalExternalTrigger:**
|
|
41
|
+
* - Trigger must live outside Modal component tree (e.g., in a page header)
|
|
42
|
+
* - Using Seeds Button as the trigger
|
|
43
|
+
* - Want automatic ARIA attributes without manual hook usage
|
|
44
|
+
*
|
|
45
|
+
* **Usage pattern with focus restoration:**
|
|
46
|
+
* You must still handle focus restoration manually by passing a ref and implementing
|
|
47
|
+
* onCloseAutoFocus on the Modal component.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
* const triggerRef = useRef<HTMLButtonElement>(null);
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <>
|
|
56
|
+
* <ModalExternalTrigger
|
|
57
|
+
* ref={triggerRef}
|
|
58
|
+
* isOpen={isOpen}
|
|
59
|
+
* onTrigger={() => setIsOpen(true)}
|
|
60
|
+
* appearance="primary"
|
|
61
|
+
* >
|
|
62
|
+
* Open Modal
|
|
63
|
+
* </ModalExternalTrigger>
|
|
64
|
+
*
|
|
65
|
+
* <Modal
|
|
66
|
+
* open={isOpen}
|
|
67
|
+
* onOpenChange={setIsOpen}
|
|
68
|
+
* onCloseAutoFocus={(e) => {
|
|
69
|
+
* e.preventDefault();
|
|
70
|
+
* triggerRef.current?.focus();
|
|
71
|
+
* }}
|
|
72
|
+
* >
|
|
73
|
+
* <ModalBody>Content</ModalBody>
|
|
74
|
+
* </Modal>
|
|
75
|
+
* </>
|
|
76
|
+
* );
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @see useModalExternalTrigger - Hook alternative for non-Button triggers
|
|
80
|
+
*/
|
|
81
|
+
declare const ModalExternalTrigger: React.ForwardRefExoticComponent<Omit<ModalExternalTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
82
|
+
|
|
9
83
|
declare const DEFAULT_MODAL_WIDTH = "600px";
|
|
10
84
|
declare const DEFAULT_MODAL_BG = "container.background.base";
|
|
11
85
|
declare const BODY_PADDING = "64px";
|
|
@@ -16,4 +90,4 @@ declare const MODAL_SIZE_PRESETS: {
|
|
|
16
90
|
readonly full: "90vw";
|
|
17
91
|
};
|
|
18
92
|
|
|
19
|
-
export { BODY_PADDING, DEFAULT_MODAL_BG, DEFAULT_MODAL_WIDTH, MODAL_SIZE_PRESETS };
|
|
93
|
+
export { BODY_PADDING, DEFAULT_MODAL_BG, DEFAULT_MODAL_WIDTH, MODAL_SIZE_PRESETS, ModalExternalTrigger, type ModalExternalTriggerProps };
|
package/dist/v2/index.js
CHANGED
|
@@ -41,14 +41,17 @@ __export(v2_exports, {
|
|
|
41
41
|
ModalCustomFooter: () => ModalCustomFooter,
|
|
42
42
|
ModalCustomHeader: () => ModalCustomHeader,
|
|
43
43
|
ModalDescription: () => ModalDescription,
|
|
44
|
+
ModalExternalTrigger: () => ModalExternalTrigger,
|
|
44
45
|
ModalFooter: () => ModalFooter,
|
|
45
46
|
ModalHeader: () => ModalHeader,
|
|
46
|
-
ModalRail: () => ModalRail
|
|
47
|
+
ModalRail: () => ModalRail,
|
|
48
|
+
useModalExternalTrigger: () => useModalExternalTrigger,
|
|
49
|
+
useModalTriggerProps: () => useModalTriggerProps
|
|
47
50
|
});
|
|
48
51
|
module.exports = __toCommonJS(v2_exports);
|
|
49
52
|
|
|
50
53
|
// src/v2/Modal.tsx
|
|
51
|
-
var
|
|
54
|
+
var React12 = __toESM(require("react"));
|
|
52
55
|
var Dialog6 = __toESM(require("@radix-ui/react-dialog"));
|
|
53
56
|
var import_react4 = require("motion/react");
|
|
54
57
|
|
|
@@ -279,11 +282,12 @@ var StaticModalContent = ({
|
|
|
279
282
|
label,
|
|
280
283
|
dataAttributes,
|
|
281
284
|
zIndex,
|
|
282
|
-
rest
|
|
285
|
+
rest,
|
|
286
|
+
dialogContentProps
|
|
283
287
|
}) => {
|
|
284
288
|
const isMobile = useIsMobile();
|
|
285
289
|
const contentVariants = getContentVariants(isMobile, false);
|
|
286
|
-
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, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
290
|
+
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)(
|
|
287
291
|
StyledMotionWrapper,
|
|
288
292
|
{
|
|
289
293
|
$isMobile: isMobile,
|
|
@@ -310,7 +314,8 @@ var DraggableModalContent = ({
|
|
|
310
314
|
label,
|
|
311
315
|
dataAttributes,
|
|
312
316
|
zIndex,
|
|
313
|
-
rest
|
|
317
|
+
rest,
|
|
318
|
+
dialogContentProps
|
|
314
319
|
}) => {
|
|
315
320
|
const [position, setPosition] = React2.useState({ x: 0, y: 0 });
|
|
316
321
|
const [isDragging, setIsDragging] = React2.useState(false);
|
|
@@ -379,6 +384,7 @@ var DraggableModalContent = ({
|
|
|
379
384
|
{
|
|
380
385
|
asChild: true,
|
|
381
386
|
"aria-label": label,
|
|
387
|
+
...dialogContentProps,
|
|
382
388
|
onInteractOutside: handleInteractOutside,
|
|
383
389
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
384
390
|
StyledMotionWrapper,
|
|
@@ -731,6 +737,34 @@ var ModalAction = ({
|
|
|
731
737
|
};
|
|
732
738
|
ModalAction.displayName = "ModalAction";
|
|
733
739
|
|
|
740
|
+
// src/v2/components/ModalExternalTrigger.tsx
|
|
741
|
+
var React10 = __toESM(require("react"));
|
|
742
|
+
var import_seeds_react_button = require("@sproutsocial/seeds-react-button");
|
|
743
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
744
|
+
var ModalExternalTrigger = React10.forwardRef(({ isOpen, onTrigger, modalId, onClick, ...buttonProps }, ref) => {
|
|
745
|
+
const handleClick = React10.useCallback(
|
|
746
|
+
(e) => {
|
|
747
|
+
onClick?.(e);
|
|
748
|
+
if (!e.defaultPrevented) {
|
|
749
|
+
onTrigger();
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
[onClick, onTrigger]
|
|
753
|
+
);
|
|
754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
755
|
+
import_seeds_react_button.Button,
|
|
756
|
+
{
|
|
757
|
+
ref,
|
|
758
|
+
onClick: handleClick,
|
|
759
|
+
"aria-haspopup": "dialog",
|
|
760
|
+
"aria-expanded": isOpen,
|
|
761
|
+
"aria-controls": modalId,
|
|
762
|
+
...buttonProps
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
});
|
|
766
|
+
ModalExternalTrigger.displayName = "ModalExternalTrigger";
|
|
767
|
+
|
|
734
768
|
// src/v2/components/ModalOverlay.tsx
|
|
735
769
|
var import_react2 = require("react");
|
|
736
770
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
@@ -764,7 +798,7 @@ var StyledOverlay = import_styled_components8.default.div.withConfig({
|
|
|
764
798
|
StyledOverlay.displayName = "ModalOverlay";
|
|
765
799
|
|
|
766
800
|
// src/v2/Modal.tsx
|
|
767
|
-
var
|
|
801
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
768
802
|
var Modal = (props) => {
|
|
769
803
|
const {
|
|
770
804
|
children,
|
|
@@ -783,17 +817,27 @@ var Modal = (props) => {
|
|
|
783
817
|
closeButtonAriaLabel = "Close",
|
|
784
818
|
closeButtonProps,
|
|
785
819
|
zIndex = 6,
|
|
820
|
+
// Extract Dialog.Content event handlers
|
|
821
|
+
onOpenAutoFocus,
|
|
822
|
+
onCloseAutoFocus,
|
|
823
|
+
onEscapeKeyDown,
|
|
824
|
+
onPointerDownOutside,
|
|
825
|
+
onFocusOutside,
|
|
826
|
+
onInteractOutside,
|
|
827
|
+
// Extract convenience boolean props
|
|
828
|
+
disableOutsideClickClose = false,
|
|
829
|
+
disableEscapeKeyClose = false,
|
|
786
830
|
...rest
|
|
787
831
|
} = props;
|
|
788
|
-
const [isOpen, setIsOpen] =
|
|
789
|
-
const handleOpenChange =
|
|
832
|
+
const [isOpen, setIsOpen] = React12.useState(defaultOpen ?? false);
|
|
833
|
+
const handleOpenChange = React12.useCallback(
|
|
790
834
|
(newOpen) => {
|
|
791
835
|
setIsOpen(newOpen);
|
|
792
836
|
onOpenChange?.(newOpen);
|
|
793
837
|
},
|
|
794
838
|
[onOpenChange]
|
|
795
839
|
);
|
|
796
|
-
const dataAttributes =
|
|
840
|
+
const dataAttributes = React12.useMemo(() => {
|
|
797
841
|
const attrs = {};
|
|
798
842
|
Object.entries(data).forEach(([key, value]) => {
|
|
799
843
|
attrs[`data-${key}`] = String(value);
|
|
@@ -808,7 +852,25 @@ var Modal = (props) => {
|
|
|
808
852
|
const isMobile = useIsMobile();
|
|
809
853
|
const overlayVariants = getOverlayVariants(isMobile);
|
|
810
854
|
const ModalContentComponent = draggable ? DraggableModalContent : StaticModalContent;
|
|
811
|
-
|
|
855
|
+
const wrappedOnInteractOutside = React12.useCallback(
|
|
856
|
+
(e) => {
|
|
857
|
+
if (disableOutsideClickClose) {
|
|
858
|
+
e.preventDefault();
|
|
859
|
+
}
|
|
860
|
+
onInteractOutside?.(e);
|
|
861
|
+
},
|
|
862
|
+
[disableOutsideClickClose, onInteractOutside]
|
|
863
|
+
);
|
|
864
|
+
const wrappedOnEscapeKeyDown = React12.useCallback(
|
|
865
|
+
(e) => {
|
|
866
|
+
if (disableEscapeKeyClose) {
|
|
867
|
+
e.preventDefault();
|
|
868
|
+
}
|
|
869
|
+
onEscapeKeyDown?.(e);
|
|
870
|
+
},
|
|
871
|
+
[disableEscapeKeyClose, onEscapeKeyDown]
|
|
872
|
+
);
|
|
873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
812
874
|
Dialog6.Root,
|
|
813
875
|
{
|
|
814
876
|
open,
|
|
@@ -816,9 +878,9 @@ var Modal = (props) => {
|
|
|
816
878
|
onOpenChange: handleOpenChange,
|
|
817
879
|
modal: !draggable,
|
|
818
880
|
children: [
|
|
819
|
-
modalTrigger && /* @__PURE__ */ (0,
|
|
820
|
-
/* @__PURE__ */ (0,
|
|
821
|
-
showOverlay && /* @__PURE__ */ (0,
|
|
881
|
+
modalTrigger && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Dialog6.Trigger, { asChild: true, children: modalTrigger }),
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Dialog6.Portal, { forceMount: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react4.AnimatePresence, { mode: "wait", children: (open ?? isOpen) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
883
|
+
showOverlay && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Dialog6.Overlay, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
822
884
|
StyledMotionOverlay,
|
|
823
885
|
{
|
|
824
886
|
$zIndex: zIndex,
|
|
@@ -826,17 +888,18 @@ var Modal = (props) => {
|
|
|
826
888
|
initial: "initial",
|
|
827
889
|
animate: "animate",
|
|
828
890
|
exit: "exit",
|
|
829
|
-
children: /* @__PURE__ */ (0,
|
|
891
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
830
892
|
StyledOverlay,
|
|
831
893
|
{
|
|
832
894
|
"data-slot": "modal-overlay",
|
|
833
895
|
"data-qa-modal-overlay": true,
|
|
896
|
+
"data-testid": "modal-overlay",
|
|
834
897
|
allowInteraction: draggable
|
|
835
898
|
}
|
|
836
899
|
)
|
|
837
900
|
}
|
|
838
901
|
) }),
|
|
839
|
-
/* @__PURE__ */ (0,
|
|
902
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
840
903
|
ModalContentComponent,
|
|
841
904
|
{
|
|
842
905
|
label,
|
|
@@ -844,9 +907,17 @@ var Modal = (props) => {
|
|
|
844
907
|
draggable,
|
|
845
908
|
zIndex,
|
|
846
909
|
rest,
|
|
910
|
+
dialogContentProps: {
|
|
911
|
+
onOpenAutoFocus,
|
|
912
|
+
onCloseAutoFocus,
|
|
913
|
+
onEscapeKeyDown: wrappedOnEscapeKeyDown,
|
|
914
|
+
onPointerDownOutside,
|
|
915
|
+
onFocusOutside,
|
|
916
|
+
onInteractOutside: wrappedOnInteractOutside
|
|
917
|
+
},
|
|
847
918
|
children: [
|
|
848
|
-
/* @__PURE__ */ (0,
|
|
849
|
-
/* @__PURE__ */ (0,
|
|
919
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ModalRail, { children: [
|
|
920
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
850
921
|
ModalAction,
|
|
851
922
|
{
|
|
852
923
|
actionType: "close",
|
|
@@ -855,10 +926,10 @@ var Modal = (props) => {
|
|
|
855
926
|
"aria-label": closeButtonProps?.["aria-label"] ?? closeButtonAriaLabel
|
|
856
927
|
}
|
|
857
928
|
),
|
|
858
|
-
actions?.map((action, idx) => /* @__PURE__ */ (0,
|
|
929
|
+
actions?.map((action, idx) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalAction, { ...action }, idx))
|
|
859
930
|
] }),
|
|
860
|
-
shouldRenderHeader && /* @__PURE__ */ (0,
|
|
861
|
-
description && /* @__PURE__ */ (0,
|
|
931
|
+
shouldRenderHeader && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalHeader, { title, subtitle }),
|
|
932
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalDescription, { children: description }),
|
|
862
933
|
children
|
|
863
934
|
]
|
|
864
935
|
}
|
|
@@ -868,6 +939,32 @@ var Modal = (props) => {
|
|
|
868
939
|
}
|
|
869
940
|
);
|
|
870
941
|
};
|
|
942
|
+
function useModalTriggerProps(isOpen, modalId) {
|
|
943
|
+
return React12.useMemo(
|
|
944
|
+
() => ({
|
|
945
|
+
"aria-haspopup": "dialog",
|
|
946
|
+
"aria-expanded": isOpen,
|
|
947
|
+
...modalId ? { "aria-controls": modalId } : {}
|
|
948
|
+
}),
|
|
949
|
+
[isOpen, modalId]
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
function useModalExternalTrigger(modalId) {
|
|
953
|
+
const triggerRef = React12.useRef(null);
|
|
954
|
+
const triggerProps = React12.useCallback(
|
|
955
|
+
(isOpen) => ({
|
|
956
|
+
"aria-haspopup": "dialog",
|
|
957
|
+
"aria-expanded": isOpen,
|
|
958
|
+
...modalId ? { "aria-controls": modalId } : {}
|
|
959
|
+
}),
|
|
960
|
+
[modalId]
|
|
961
|
+
);
|
|
962
|
+
const onCloseAutoFocus = React12.useCallback((e) => {
|
|
963
|
+
e.preventDefault();
|
|
964
|
+
triggerRef.current?.focus();
|
|
965
|
+
}, []);
|
|
966
|
+
return { triggerRef, triggerProps, onCloseAutoFocus };
|
|
967
|
+
}
|
|
871
968
|
var Modal_default = Modal;
|
|
872
969
|
// Annotate the CommonJS export names for ESM import in node:
|
|
873
970
|
0 && (module.exports = {
|
|
@@ -882,8 +979,11 @@ var Modal_default = Modal;
|
|
|
882
979
|
ModalCustomFooter,
|
|
883
980
|
ModalCustomHeader,
|
|
884
981
|
ModalDescription,
|
|
982
|
+
ModalExternalTrigger,
|
|
885
983
|
ModalFooter,
|
|
886
984
|
ModalHeader,
|
|
887
|
-
ModalRail
|
|
985
|
+
ModalRail,
|
|
986
|
+
useModalExternalTrigger,
|
|
987
|
+
useModalTriggerProps
|
|
888
988
|
});
|
|
889
989
|
//# sourceMappingURL=index.js.map
|