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