@sproutsocial/seeds-react-modal 1.1.1 → 2.0.1

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 (45) hide show
  1. package/.turbo/turbo-build.log +23 -23
  2. package/CHANGELOG.md +182 -0
  3. package/dist/ModalAction-BB7qJtQj.d.mts +445 -0
  4. package/dist/ModalAction-BB7qJtQj.d.ts +445 -0
  5. package/dist/esm/chunk-ETVICNHP.js +1353 -0
  6. package/dist/esm/chunk-ETVICNHP.js.map +1 -0
  7. package/dist/esm/index.js +11 -11
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/v2/index.js +12 -20
  10. package/dist/index.d.mts +2 -1
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.js +1154 -546
  13. package/dist/index.js.map +1 -1
  14. package/dist/v2/index.d.mts +4 -11
  15. package/dist/v2/index.d.ts +4 -11
  16. package/dist/v2/index.js +1152 -545
  17. package/dist/v2/index.js.map +1 -1
  18. package/package.json +8 -7
  19. package/src/index.ts +11 -12
  20. package/src/shared/constants.ts +11 -7
  21. package/src/v2/Modal.tsx +169 -0
  22. package/src/v2/ModalTypes.ts +343 -0
  23. package/src/v2/ModalV2.stories.tsx +413 -128
  24. package/src/v2/MotionConfig.ts +185 -0
  25. package/src/v2/components/ModalAction.tsx +94 -0
  26. package/src/v2/components/ModalBody.tsx +54 -0
  27. package/src/v2/components/ModalCloseWrapper.tsx +35 -0
  28. package/src/v2/components/ModalContent.tsx +288 -11
  29. package/src/v2/components/ModalDescription.tsx +14 -2
  30. package/src/v2/components/ModalFooter.tsx +94 -13
  31. package/src/v2/components/ModalHeader.tsx +77 -34
  32. package/src/v2/components/ModalOverlay.tsx +52 -0
  33. package/src/v2/components/ModalRail.tsx +35 -99
  34. package/src/v2/components/index.ts +11 -7
  35. package/src/v2/index.ts +13 -16
  36. package/dist/ModalRail-5PeilhW7.d.mts +0 -186
  37. package/dist/ModalRail-5PeilhW7.d.ts +0 -186
  38. package/dist/esm/chunk-4ITF4DBY.js +0 -717
  39. package/dist/esm/chunk-4ITF4DBY.js.map +0 -1
  40. package/src/v2/ModalV2.tsx +0 -388
  41. package/src/v2/ModalV2Styles.tsx +0 -180
  42. package/src/v2/ModalV2Types.ts +0 -154
  43. package/src/v2/components/ModalClose.tsx +0 -29
  44. package/src/v2/components/ModalCloseButton.tsx +0 -100
  45. package/src/v2/components/ModalTrigger.tsx +0 -39
@@ -1,186 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import * as Dialog from '@radix-ui/react-dialog';
4
- import { TypeContainerProps, TypeBoxProps } from '@sproutsocial/seeds-react-box';
5
- import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
6
- import { TypeIconName } from '@sproutsocial/seeds-react-icon';
7
-
8
- interface TypeModalV2TriggerProps extends TypeButtonProps {
9
- /** The content to display inside the trigger button */
10
- children: React.ReactNode;
11
- /** Custom click handler - will be called before the modal opens */
12
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
13
- /** Use asChild to render a custom trigger element */
14
- asChild?: boolean;
15
- }
16
- interface TypeModalV2CloseButtonProps extends Omit<TypeButtonProps, "children" | "size"> {
17
- children?: React.ReactNode;
18
- /** Custom click handler - will be called before the modal closes */
19
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
20
- /** Use asChild to render a custom close element */
21
- asChild?: boolean;
22
- /** aria-label for modal close button */
23
- closeButtonLabel?: string;
24
- /** Size of the close button in pixels */
25
- size?: number;
26
- /** Position type - absolute (outside modal) or relative (inside modal) */
27
- position?: "absolute" | "relative";
28
- /** Which side to position the button on (for absolute positioning) */
29
- side?: "right" | "left";
30
- /** Offset from the modal edge in pixels (for absolute positioning) */
31
- offset?: number;
32
- }
33
- interface TypeModalV2HeaderProps extends TypeBoxProps {
34
- title?: string;
35
- subtitle?: string;
36
- /** Passing children will override the default modal header */
37
- children?: React.ReactNode;
38
- /** Additional props for the Dialog.Title when title is provided */
39
- titleProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Title>, "asChild" | "children">;
40
- /** Additional props for the Dialog.Description when subtitle is provided */
41
- subtitleProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Description>, "asChild" | "children">;
42
- /** Opt-in inline close inside header; default is floating rail */
43
- showInlineClose?: boolean;
44
- }
45
- interface TypeModalV2FooterProps extends TypeBoxProps {
46
- bg?: string;
47
- children: React.ReactNode;
48
- }
49
- interface TypeModalV2ContentProps extends TypeBoxProps {
50
- children?: React.ReactNode;
51
- }
52
- interface TypeModalV2DescriptionProps extends TypeBoxProps {
53
- children: React.ReactNode;
54
- /** Additional props for the Dialog.Description */
55
- descriptionProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Description>, "asChild" | "children">;
56
- }
57
- interface TypeModalV2Props extends TypeContainerProps, Omit<React.ComponentPropsWithoutRef<"div">, keyof TypeContainerProps> {
58
- /** Controls whether the modal is open (controlled mode) */
59
- open?: boolean;
60
- /** Default open state for uncontrolled mode */
61
- defaultOpen?: boolean;
62
- /** body content of the modal */
63
- children: React.ReactNode;
64
- /** Callback when open state changes */
65
- onOpenChange?: (open: boolean) => void;
66
- /** The element that will trigger the modal when clicked.
67
- * Can be any React element like a button, link, or custom component. */
68
- modalTrigger?: React.ReactElement<any>;
69
- /** Enable draggable functionality using react-dnd */
70
- draggable?: boolean;
71
- /** Simplified API: Modal title (creates ModalHeader automatically) */
72
- title?: string;
73
- /** Simplified API: Modal subtitle (creates ModalHeader automatically) */
74
- subtitle?: string;
75
- /** Simplified API: Modal description (automatically wrapped in Dialog.Description) */
76
- description?: string;
77
- /** Modal size preset or custom width */
78
- size?: "small" | "medium" | "large" | "full" | string | number;
79
- /** Priority level that maps to z-index presets */
80
- priority?: "low" | "medium" | "high";
81
- /**
82
- * Custom attributes to be added to the modals container
83
- * Each key will be prepended with "data-" when rendered in the DOM
84
- */
85
- data?: Record<string, string | boolean | number>;
86
- /** Whether to show the background overlay (defaults to true) */
87
- showOverlay?: boolean;
88
- /** Optional quick actions to render on a modal side rail */
89
- actions?: TypeModalActionProps[];
90
- /** Optional props to customize the side rail position/size */
91
- railProps?: Partial<TypeModalRailProps>;
92
- }
93
- type TypeModalRailProps = {
94
- side?: "right" | "left";
95
- offset?: number;
96
- gap?: number;
97
- size?: number;
98
- children?: React.ReactNode;
99
- };
100
- type ModalActionBase = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> & {
101
- /** Icon name from the Seeds icon set */
102
- iconName?: TypeIconName;
103
- /** Optional click handler; ignored for type "close" */
104
- onClick?: () => void;
105
- /** Accessible name for the action button */
106
- "aria-label": string;
107
- };
108
- type TypeModalActionProps = (ModalActionBase & {
109
- actionType: "close";
110
- }) | (ModalActionBase & {
111
- actionType?: "button";
112
- });
113
-
114
- interface DragContextValue {
115
- position: {
116
- x: number;
117
- y: number;
118
- };
119
- isDragging: boolean;
120
- onHeaderMouseDown: (e: React.MouseEvent) => void;
121
- contentRef: React.RefObject<HTMLDivElement>;
122
- draggable: boolean;
123
- }
124
- declare const useDragContext: () => DragContextValue | null;
125
- /**
126
- * The modal you want - with Radix UI Dialog
127
- *
128
- * Features:
129
- * - Built with Radix UI Dialog for superior accessibility
130
- * - Same API as the original Modal component
131
- * - Automatic focus management and keyboard navigation
132
- * - Portal rendering for proper z-index layering
133
- * - Customizable styling through system props
134
- * - Optional draggable functionality using react-dnd
135
- */
136
- declare const Modal: (props: TypeModalV2Props) => react_jsx_runtime.JSX.Element;
137
-
138
- declare const ModalHeader: {
139
- (props: TypeModalV2HeaderProps): react_jsx_runtime.JSX.Element;
140
- displayName: string;
141
- };
142
-
143
- declare const ModalFooter: {
144
- (props: TypeModalV2FooterProps): react_jsx_runtime.JSX.Element;
145
- displayName: string;
146
- };
147
-
148
- declare const ModalContent: React.ForwardRefExoticComponent<Omit<TypeModalV2ContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
149
-
150
- declare const ModalDescription: React.ForwardRefExoticComponent<Omit<TypeModalV2DescriptionProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
151
-
152
- declare const ModalCloseButton: {
153
- (props: TypeModalV2CloseButtonProps): react_jsx_runtime.JSX.Element;
154
- displayName: string;
155
- };
156
-
157
- /**
158
- * A trigger button that opens the modal when clicked.
159
- * Must be used inside a Modal component's Dialog.Root context.
160
- * Uses Seeds Button by default but supports asChild for custom elements.
161
- */
162
- declare const ModalTrigger: {
163
- (props: TypeModalV2TriggerProps): react_jsx_runtime.JSX.Element;
164
- displayName: string;
165
- };
166
-
167
- interface ModalCloseProps {
168
- children: React.ReactNode;
169
- onClick?: (e: React.MouseEvent) => void;
170
- asChild?: boolean;
171
- }
172
- /**
173
- * A component that closes the modal when clicked.
174
- * Uses asChild pattern like Radix primitives.
175
- */
176
- declare const ModalClose: {
177
- (props: ModalCloseProps): react_jsx_runtime.JSX.Element;
178
- displayName: string;
179
- };
180
-
181
- declare const ModalRail: React.FC<TypeModalRailProps>;
182
- declare const ModalAction: React.FC<TypeModalActionProps & {
183
- size?: number;
184
- }>;
185
-
186
- export { Modal as M, type TypeModalV2Props as T, ModalTrigger as a, ModalDescription as b, ModalHeader as c, ModalFooter as d, ModalContent as e, ModalCloseButton as f, ModalClose as g, ModalRail as h, ModalAction as i, type TypeModalV2TriggerProps as j, type TypeModalV2CloseButtonProps as k, type TypeModalV2HeaderProps as l, type TypeModalV2FooterProps as m, type TypeModalV2ContentProps as n, type TypeModalV2DescriptionProps as o, type TypeModalRailProps as p, type TypeModalActionProps as q, useDragContext as u };
@@ -1,186 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import * as Dialog from '@radix-ui/react-dialog';
4
- import { TypeContainerProps, TypeBoxProps } from '@sproutsocial/seeds-react-box';
5
- import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
6
- import { TypeIconName } from '@sproutsocial/seeds-react-icon';
7
-
8
- interface TypeModalV2TriggerProps extends TypeButtonProps {
9
- /** The content to display inside the trigger button */
10
- children: React.ReactNode;
11
- /** Custom click handler - will be called before the modal opens */
12
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
13
- /** Use asChild to render a custom trigger element */
14
- asChild?: boolean;
15
- }
16
- interface TypeModalV2CloseButtonProps extends Omit<TypeButtonProps, "children" | "size"> {
17
- children?: React.ReactNode;
18
- /** Custom click handler - will be called before the modal closes */
19
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
20
- /** Use asChild to render a custom close element */
21
- asChild?: boolean;
22
- /** aria-label for modal close button */
23
- closeButtonLabel?: string;
24
- /** Size of the close button in pixels */
25
- size?: number;
26
- /** Position type - absolute (outside modal) or relative (inside modal) */
27
- position?: "absolute" | "relative";
28
- /** Which side to position the button on (for absolute positioning) */
29
- side?: "right" | "left";
30
- /** Offset from the modal edge in pixels (for absolute positioning) */
31
- offset?: number;
32
- }
33
- interface TypeModalV2HeaderProps extends TypeBoxProps {
34
- title?: string;
35
- subtitle?: string;
36
- /** Passing children will override the default modal header */
37
- children?: React.ReactNode;
38
- /** Additional props for the Dialog.Title when title is provided */
39
- titleProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Title>, "asChild" | "children">;
40
- /** Additional props for the Dialog.Description when subtitle is provided */
41
- subtitleProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Description>, "asChild" | "children">;
42
- /** Opt-in inline close inside header; default is floating rail */
43
- showInlineClose?: boolean;
44
- }
45
- interface TypeModalV2FooterProps extends TypeBoxProps {
46
- bg?: string;
47
- children: React.ReactNode;
48
- }
49
- interface TypeModalV2ContentProps extends TypeBoxProps {
50
- children?: React.ReactNode;
51
- }
52
- interface TypeModalV2DescriptionProps extends TypeBoxProps {
53
- children: React.ReactNode;
54
- /** Additional props for the Dialog.Description */
55
- descriptionProps?: Omit<React.ComponentPropsWithoutRef<typeof Dialog.Description>, "asChild" | "children">;
56
- }
57
- interface TypeModalV2Props extends TypeContainerProps, Omit<React.ComponentPropsWithoutRef<"div">, keyof TypeContainerProps> {
58
- /** Controls whether the modal is open (controlled mode) */
59
- open?: boolean;
60
- /** Default open state for uncontrolled mode */
61
- defaultOpen?: boolean;
62
- /** body content of the modal */
63
- children: React.ReactNode;
64
- /** Callback when open state changes */
65
- onOpenChange?: (open: boolean) => void;
66
- /** The element that will trigger the modal when clicked.
67
- * Can be any React element like a button, link, or custom component. */
68
- modalTrigger?: React.ReactElement<any>;
69
- /** Enable draggable functionality using react-dnd */
70
- draggable?: boolean;
71
- /** Simplified API: Modal title (creates ModalHeader automatically) */
72
- title?: string;
73
- /** Simplified API: Modal subtitle (creates ModalHeader automatically) */
74
- subtitle?: string;
75
- /** Simplified API: Modal description (automatically wrapped in Dialog.Description) */
76
- description?: string;
77
- /** Modal size preset or custom width */
78
- size?: "small" | "medium" | "large" | "full" | string | number;
79
- /** Priority level that maps to z-index presets */
80
- priority?: "low" | "medium" | "high";
81
- /**
82
- * Custom attributes to be added to the modals container
83
- * Each key will be prepended with "data-" when rendered in the DOM
84
- */
85
- data?: Record<string, string | boolean | number>;
86
- /** Whether to show the background overlay (defaults to true) */
87
- showOverlay?: boolean;
88
- /** Optional quick actions to render on a modal side rail */
89
- actions?: TypeModalActionProps[];
90
- /** Optional props to customize the side rail position/size */
91
- railProps?: Partial<TypeModalRailProps>;
92
- }
93
- type TypeModalRailProps = {
94
- side?: "right" | "left";
95
- offset?: number;
96
- gap?: number;
97
- size?: number;
98
- children?: React.ReactNode;
99
- };
100
- type ModalActionBase = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> & {
101
- /** Icon name from the Seeds icon set */
102
- iconName?: TypeIconName;
103
- /** Optional click handler; ignored for type "close" */
104
- onClick?: () => void;
105
- /** Accessible name for the action button */
106
- "aria-label": string;
107
- };
108
- type TypeModalActionProps = (ModalActionBase & {
109
- actionType: "close";
110
- }) | (ModalActionBase & {
111
- actionType?: "button";
112
- });
113
-
114
- interface DragContextValue {
115
- position: {
116
- x: number;
117
- y: number;
118
- };
119
- isDragging: boolean;
120
- onHeaderMouseDown: (e: React.MouseEvent) => void;
121
- contentRef: React.RefObject<HTMLDivElement>;
122
- draggable: boolean;
123
- }
124
- declare const useDragContext: () => DragContextValue | null;
125
- /**
126
- * The modal you want - with Radix UI Dialog
127
- *
128
- * Features:
129
- * - Built with Radix UI Dialog for superior accessibility
130
- * - Same API as the original Modal component
131
- * - Automatic focus management and keyboard navigation
132
- * - Portal rendering for proper z-index layering
133
- * - Customizable styling through system props
134
- * - Optional draggable functionality using react-dnd
135
- */
136
- declare const Modal: (props: TypeModalV2Props) => react_jsx_runtime.JSX.Element;
137
-
138
- declare const ModalHeader: {
139
- (props: TypeModalV2HeaderProps): react_jsx_runtime.JSX.Element;
140
- displayName: string;
141
- };
142
-
143
- declare const ModalFooter: {
144
- (props: TypeModalV2FooterProps): react_jsx_runtime.JSX.Element;
145
- displayName: string;
146
- };
147
-
148
- declare const ModalContent: React.ForwardRefExoticComponent<Omit<TypeModalV2ContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
149
-
150
- declare const ModalDescription: React.ForwardRefExoticComponent<Omit<TypeModalV2DescriptionProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
151
-
152
- declare const ModalCloseButton: {
153
- (props: TypeModalV2CloseButtonProps): react_jsx_runtime.JSX.Element;
154
- displayName: string;
155
- };
156
-
157
- /**
158
- * A trigger button that opens the modal when clicked.
159
- * Must be used inside a Modal component's Dialog.Root context.
160
- * Uses Seeds Button by default but supports asChild for custom elements.
161
- */
162
- declare const ModalTrigger: {
163
- (props: TypeModalV2TriggerProps): react_jsx_runtime.JSX.Element;
164
- displayName: string;
165
- };
166
-
167
- interface ModalCloseProps {
168
- children: React.ReactNode;
169
- onClick?: (e: React.MouseEvent) => void;
170
- asChild?: boolean;
171
- }
172
- /**
173
- * A component that closes the modal when clicked.
174
- * Uses asChild pattern like Radix primitives.
175
- */
176
- declare const ModalClose: {
177
- (props: ModalCloseProps): react_jsx_runtime.JSX.Element;
178
- displayName: string;
179
- };
180
-
181
- declare const ModalRail: React.FC<TypeModalRailProps>;
182
- declare const ModalAction: React.FC<TypeModalActionProps & {
183
- size?: number;
184
- }>;
185
-
186
- export { Modal as M, type TypeModalV2Props as T, ModalTrigger as a, ModalDescription as b, ModalHeader as c, ModalFooter as d, ModalContent as e, ModalCloseButton as f, ModalClose as g, ModalRail as h, ModalAction as i, type TypeModalV2TriggerProps as j, type TypeModalV2CloseButtonProps as k, type TypeModalV2HeaderProps as l, type TypeModalV2FooterProps as m, type TypeModalV2ContentProps as n, type TypeModalV2DescriptionProps as o, type TypeModalRailProps as p, type TypeModalActionProps as q, useDragContext as u };