@yamada-ui/modal 0.0.0-dev-20230625235915 → 0.0.0-dev-20230702052021

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.
@@ -28,195 +28,28 @@ var import_core8 = require("@yamada-ui/core");
28
28
  var import_utils8 = require("@yamada-ui/utils");
29
29
 
30
30
  // src/modal.tsx
31
- var import_core = require("@yamada-ui/core");
31
+ var import_core7 = require("@yamada-ui/core");
32
32
  var import_focus_lock = require("@yamada-ui/focus-lock");
33
- var import_motion = require("@yamada-ui/motion");
33
+ var import_motion2 = require("@yamada-ui/motion");
34
34
  var import_portal = require("@yamada-ui/portal");
35
- var import_transitions = require("@yamada-ui/transitions");
35
+ var import_transitions3 = require("@yamada-ui/transitions");
36
36
  var import_use_value = require("@yamada-ui/use-value");
37
- var import_utils = require("@yamada-ui/utils");
37
+ var import_utils7 = require("@yamada-ui/utils");
38
38
  var import_react = require("react");
39
39
  var import_react_remove_scroll = require("react-remove-scroll");
40
- var import_jsx_runtime = require("react/jsx-runtime");
41
- var [ModalProvider, useModal] = (0, import_utils.createContext)({
42
- name: `ModalContext`,
43
- errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
44
- });
45
- var Modal = (0, import_core.forwardRef)(({ size, ...props }, ref) => {
46
- const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Modal", { size, ...props });
47
- const {
48
- className,
49
- children,
50
- isOpen,
51
- onClose,
52
- onOverlayClick,
53
- onEsc,
54
- onCloseComplete,
55
- placement: _placement = "center",
56
- outside = "md",
57
- withCloseButton = true,
58
- withOverlay = true,
59
- allowPinchZoom = false,
60
- scrollBehavior = "inside",
61
- autoFocus,
62
- restoreFocus,
63
- initialFocusRef,
64
- finalFocusRef,
65
- blockScrollOnMount = true,
66
- closeOnOverlay = true,
67
- closeOnEsc = true,
68
- lockFocusAcrossFrames = true,
69
- animation = "scale",
70
- duration,
71
- ...rest
72
- } = (0, import_core.omitThemeProps)(mergedProps);
73
- const onKeyDown = (0, import_react.useCallback)(
74
- (event) => {
75
- if (event.key !== "Escape")
76
- return;
77
- event.stopPropagation();
78
- if (closeOnEsc)
79
- onClose == null ? void 0 : onClose();
80
- onEsc == null ? void 0 : onEsc();
81
- },
82
- [closeOnEsc, onClose, onEsc]
83
- );
84
- const validChildren = (0, import_utils.getValidChildren)(children);
85
- const [customModalOverlay, ...cloneChildren] = (0, import_utils.findChildren)(
86
- validChildren,
87
- ModalOverlay,
88
- DialogOverlay,
89
- DrawerOverlay
90
- );
91
- let [drawerContent] = (0, import_utils.findChildren)(validChildren, DrawerContent);
92
- if (drawerContent)
93
- drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
94
- const placement = (0, import_use_value.useValue)(_placement);
95
- const css = {
96
- position: "fixed",
97
- top: 0,
98
- left: 0,
99
- zIndex: "beerus",
100
- w: "100vw",
101
- h: "100vh",
102
- p: size !== "full" ? outside : void 0,
103
- display: "flex",
104
- justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
105
- alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
106
- };
107
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
- ModalProvider,
109
- {
110
- value: {
111
- isOpen,
112
- onClose,
113
- onOverlayClick,
114
- withCloseButton,
115
- scrollBehavior,
116
- closeOnOverlay,
117
- animation,
118
- duration,
119
- styles
120
- },
121
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
122
- import_focus_lock.FocusLock,
123
- {
124
- autoFocus,
125
- initialFocusRef,
126
- finalFocusRef,
127
- restoreFocus,
128
- lockFocusAcrossFrames,
129
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
- import_react_remove_scroll.RemoveScroll,
131
- {
132
- allowPinchZoom,
133
- enabled: blockScrollOnMount,
134
- forwardProps: true,
135
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.ui.div, { __css: css, children: [
136
- customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalOverlay, {}) : null,
137
- drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
138
- ] })
139
- }
140
- )
141
- }
142
- ) }) : null })
143
- }
144
- );
145
- });
146
- var getModalContentProps = (animation = "scale", duration) => {
147
- switch (animation) {
148
- case "scale":
149
- return {
150
- ...import_transitions.scaleFadeProps,
151
- custom: { scale: 0.95, reverse: true, duration }
152
- };
153
- case "top":
154
- return {
155
- ...import_transitions.slideFadeProps,
156
- custom: { offsetY: -16, reverse: true, duration }
157
- };
158
- case "right":
159
- return {
160
- ...import_transitions.slideFadeProps,
161
- custom: { offsetX: 16, reverse: true, duration }
162
- };
163
- case "left":
164
- return {
165
- ...import_transitions.slideFadeProps,
166
- custom: { offsetX: -16, reverse: true, duration }
167
- };
168
- case "bottom":
169
- return {
170
- ...import_transitions.slideFadeProps,
171
- custom: { offsetY: 16, reverse: true, duration }
172
- };
173
- }
174
- };
175
- var ModalContent = (0, import_core.forwardRef)(
176
- ({ className, children, __css, ...rest }, ref) => {
177
- const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
178
- const validChildren = (0, import_utils.getValidChildren)(children);
179
- const [customModalCloseButton, ...cloneChildren] = (0, import_utils.findChildren)(
180
- validChildren,
181
- ModalCloseButton,
182
- DialogCloseButton
183
- );
184
- const props = animation !== "none" ? getModalContentProps(animation, duration) : {};
185
- const css = {
186
- position: "relative",
187
- maxH: "100%",
188
- display: "flex",
189
- flexDirection: "column",
190
- overflow: scrollBehavior === "inside" ? "hidden" : "auto",
191
- outline: 0,
192
- ...__css ? __css : styles.container
193
- };
194
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
195
- import_core.ui.section,
196
- {
197
- as: import_motion.motion.section,
198
- ref,
199
- className: (0, import_utils.cx)("ui-modal", className),
200
- tabIndex: -1,
201
- __css: css,
202
- ...props,
203
- ...rest,
204
- children: [
205
- customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalCloseButton, {}) : null,
206
- cloneChildren
207
- ]
208
- }
209
- );
210
- }
211
- );
212
40
 
213
- // src/modal-overlay.tsx
214
- var import_core2 = require("@yamada-ui/core");
215
- var import_motion2 = require("@yamada-ui/motion");
41
+ // src/drawer.tsx
42
+ var import_core6 = require("@yamada-ui/core");
216
43
  var import_transitions2 = require("@yamada-ui/transitions");
217
- var import_utils2 = require("@yamada-ui/utils");
218
- var import_jsx_runtime2 = require("react/jsx-runtime");
219
- var ModalOverlay = (0, import_core2.forwardRef)(
44
+ var import_utils6 = require("@yamada-ui/utils");
45
+
46
+ // src/modal-overlay.tsx
47
+ var import_core = require("@yamada-ui/core");
48
+ var import_motion = require("@yamada-ui/motion");
49
+ var import_transitions = require("@yamada-ui/transitions");
50
+ var import_utils = require("@yamada-ui/utils");
51
+ var import_jsx_runtime = require("react/jsx-runtime");
52
+ var ModalOverlay = (0, import_core.forwardRef)(
220
53
  ({ className, __css, onClick, ...rest }, ref) => {
221
54
  const { styles, closeOnOverlay, onOverlayClick, onClose, animation, duration } = useModal();
222
55
  const css = {
@@ -227,16 +60,16 @@ var ModalOverlay = (0, import_core2.forwardRef)(
227
60
  h: "100vh",
228
61
  ...__css ? __css : styles.overlay
229
62
  };
230
- const props = animation !== "none" ? import_transitions2.fadeProps : {};
231
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
232
- import_core2.ui.div,
63
+ const props = animation !== "none" ? import_transitions.fadeProps : {};
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_core.ui.div,
233
66
  {
234
- as: import_motion2.motion.div,
67
+ as: import_motion.motion.div,
235
68
  ref,
236
- className: (0, import_utils2.cx)("ui-modal-overlay", className),
69
+ className: (0, import_utils.cx)("ui-modal-overlay", className),
237
70
  custom: { duration },
238
71
  __css: css,
239
- onClick: (0, import_utils2.handlerAll)(onClick, onOverlayClick, (event) => {
72
+ onClick: (0, import_utils.handlerAll)(onClick, onOverlayClick, (event) => {
240
73
  event.stopPropagation();
241
74
  if (closeOnOverlay)
242
75
  onClose == null ? void 0 : onClose();
@@ -249,10 +82,10 @@ var ModalOverlay = (0, import_core2.forwardRef)(
249
82
  );
250
83
 
251
84
  // src/modal-header.tsx
252
- var import_core3 = require("@yamada-ui/core");
253
- var import_utils3 = require("@yamada-ui/utils");
254
- var import_jsx_runtime3 = require("react/jsx-runtime");
255
- var ModalHeader = (0, import_core3.forwardRef)(
85
+ var import_core2 = require("@yamada-ui/core");
86
+ var import_utils2 = require("@yamada-ui/utils");
87
+ var import_jsx_runtime2 = require("react/jsx-runtime");
88
+ var ModalHeader = (0, import_core2.forwardRef)(
256
89
  ({ className, __css, ...rest }, ref) => {
257
90
  const { styles } = useModal();
258
91
  const css = {
@@ -261,15 +94,15 @@ var ModalHeader = (0, import_core3.forwardRef)(
261
94
  justifyContent: "flex-start",
262
95
  ...__css ? __css : styles.header
263
96
  };
264
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.header, { ref, className: (0, import_utils3.cx)("ui-modal-header", className), __css: css, ...rest });
97
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.header, { ref, className: (0, import_utils2.cx)("ui-modal-header", className), __css: css, ...rest });
265
98
  }
266
99
  );
267
100
 
268
101
  // src/modal-body.tsx
269
- var import_core4 = require("@yamada-ui/core");
270
- var import_utils4 = require("@yamada-ui/utils");
271
- var import_jsx_runtime4 = require("react/jsx-runtime");
272
- var ModalBody = (0, import_core4.forwardRef)(
102
+ var import_core3 = require("@yamada-ui/core");
103
+ var import_utils3 = require("@yamada-ui/utils");
104
+ var import_jsx_runtime3 = require("react/jsx-runtime");
105
+ var ModalBody = (0, import_core3.forwardRef)(
273
106
  ({ className, __css, ...rest }, ref) => {
274
107
  const { styles, scrollBehavior } = useModal();
275
108
  const css = {
@@ -279,15 +112,15 @@ var ModalBody = (0, import_core4.forwardRef)(
279
112
  overflow: scrollBehavior === "inside" ? "auto" : void 0,
280
113
  ...__css ? __css : styles.body
281
114
  };
282
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.main, { ref, className: (0, import_utils4.cx)("ui-modal-body", className), __css: css, ...rest });
115
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.main, { ref, className: (0, import_utils3.cx)("ui-modal-body", className), __css: css, ...rest });
283
116
  }
284
117
  );
285
118
 
286
119
  // src/modal-footer.tsx
287
- var import_core5 = require("@yamada-ui/core");
288
- var import_utils5 = require("@yamada-ui/utils");
289
- var import_jsx_runtime5 = require("react/jsx-runtime");
290
- var ModalFooter = (0, import_core5.forwardRef)(
120
+ var import_core4 = require("@yamada-ui/core");
121
+ var import_utils4 = require("@yamada-ui/utils");
122
+ var import_jsx_runtime4 = require("react/jsx-runtime");
123
+ var ModalFooter = (0, import_core4.forwardRef)(
291
124
  ({ className, __css, ...rest }, ref) => {
292
125
  const { styles } = useModal();
293
126
  const css = {
@@ -296,21 +129,21 @@ var ModalFooter = (0, import_core5.forwardRef)(
296
129
  justifyContent: "flex-end",
297
130
  ...__css ? __css : styles.footer
298
131
  };
299
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.footer, { ref, className: (0, import_utils5.cx)("ui-modal-footer", className), __css: css, ...rest });
132
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.footer, { ref, className: (0, import_utils4.cx)("ui-modal-footer", className), __css: css, ...rest });
300
133
  }
301
134
  );
302
135
 
303
136
  // src/dialog.tsx
304
137
  var import_button = require("@yamada-ui/button");
305
- var import_core6 = require("@yamada-ui/core");
306
- var import_utils6 = require("@yamada-ui/utils");
307
- var import_jsx_runtime6 = require("react/jsx-runtime");
308
- var [DialogProvider, useDialog] = (0, import_utils6.createContext)({
138
+ var import_core5 = require("@yamada-ui/core");
139
+ var import_utils5 = require("@yamada-ui/utils");
140
+ var import_jsx_runtime5 = require("react/jsx-runtime");
141
+ var [DialogProvider, useDialog] = (0, import_utils5.createContext)({
309
142
  name: `DialogContext`,
310
143
  errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
311
144
  });
312
- var Dialog = (0, import_core6.forwardRef)(({ size, ...props }, ref) => {
313
- const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("Dialog", { size, ...props });
145
+ var Dialog = (0, import_core5.forwardRef)(({ size, ...props }, ref) => {
146
+ const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("Dialog", { size, ...props });
314
147
  const {
315
148
  className,
316
149
  children,
@@ -326,14 +159,14 @@ var Dialog = (0, import_core6.forwardRef)(({ size, ...props }, ref) => {
326
159
  onOther,
327
160
  onSuccess,
328
161
  ...rest
329
- } = (0, import_core6.omitThemeProps)(mergedProps);
330
- const validChildren = (0, import_utils6.getValidChildren)(children);
331
- const [customDialogOverlay] = (0, import_utils6.findChildren)(validChildren, DialogOverlay);
332
- const [customDialogCloseButton] = (0, import_utils6.findChildren)(validChildren, DialogCloseButton);
333
- const [customDialogHeader] = (0, import_utils6.findChildren)(validChildren, DialogHeader);
334
- const [customDialogBody] = (0, import_utils6.findChildren)(validChildren, DialogBody);
335
- const [customDialogFooter] = (0, import_utils6.findChildren)(validChildren, DialogFooter);
336
- const cloneChildren = !(0, import_utils6.isEmpty)(validChildren) ? (0, import_utils6.omitChildren)(
162
+ } = (0, import_core5.omitThemeProps)(mergedProps);
163
+ const validChildren = (0, import_utils5.getValidChildren)(children);
164
+ const [customDialogOverlay] = (0, import_utils5.findChildren)(validChildren, DialogOverlay);
165
+ const [customDialogCloseButton] = (0, import_utils5.findChildren)(validChildren, DialogCloseButton);
166
+ const [customDialogHeader] = (0, import_utils5.findChildren)(validChildren, DialogHeader);
167
+ const [customDialogBody] = (0, import_utils5.findChildren)(validChildren, DialogBody);
168
+ const [customDialogFooter] = (0, import_utils5.findChildren)(validChildren, DialogFooter);
169
+ const cloneChildren = !(0, import_utils5.isEmpty)(validChildren) ? (0, import_utils5.omitChildren)(
337
170
  validChildren,
338
171
  DialogOverlay,
339
172
  DialogCloseButton,
@@ -342,96 +175,93 @@ var Dialog = (0, import_core6.forwardRef)(({ size, ...props }, ref) => {
342
175
  DialogFooter
343
176
  ) : children;
344
177
  const css = { ...styles.container };
345
- const cancelButtonProps = (0, import_utils6.isValidElement)(cancel) ? { children: cancel } : cancel;
346
- const otherButtonProps = (0, import_utils6.isValidElement)(other) ? { children: other } : other;
347
- const successButtonProps = (0, import_utils6.isValidElement)(success) ? { children: success } : success;
178
+ const cancelButtonProps = (0, import_utils5.isValidElement)(cancel) ? { children: cancel } : cancel;
179
+ const otherButtonProps = (0, import_utils5.isValidElement)(other) ? { children: other } : other;
180
+ const successButtonProps = (0, import_utils5.isValidElement)(success) ? { children: success } : success;
348
181
  if (cancelButtonProps && !cancelButtonProps.variant)
349
182
  cancelButtonProps.variant = "ghost";
350
183
  if (otherButtonProps && !otherButtonProps.colorScheme)
351
184
  otherButtonProps.colorScheme = "secondary";
352
185
  if (successButtonProps && !successButtonProps.colorScheme)
353
186
  successButtonProps.colorScheme = "primary";
354
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
187
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
355
188
  Modal,
356
189
  {
357
190
  ref,
358
191
  __css: css,
359
192
  ...{ size, onClose, withOverlay: false, withCloseButton: false, ...rest },
360
193
  children: [
361
- customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogOverlay, {}) : null,
362
- customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogCloseButton, {}) : null,
363
- customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogHeader, { children: header }) : null,
364
- customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogBody, { children: cloneChildren }) : null,
365
- customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
366
- cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button.Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
367
- otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button.Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
368
- successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button.Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
194
+ customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogOverlay, {}) : null,
195
+ customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogCloseButton, {}) : null,
196
+ customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogHeader, { children: header }) : null,
197
+ customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogBody, { children: cloneChildren }) : null,
198
+ customDialogFooter != null ? customDialogFooter : footer || cancelButtonProps || otherButtonProps || successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogFooter, { children: footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
199
+ cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onCancel == null ? void 0 : onCancel(onClose), ...cancelButtonProps }) : null,
200
+ otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onOther == null ? void 0 : onOther(onClose), ...otherButtonProps }) : null,
201
+ successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_button.Button, { onClick: () => onSuccess == null ? void 0 : onSuccess(onClose), ...successButtonProps }) : null
369
202
  ] }) }) : null
370
203
  ]
371
204
  }
372
205
  ) });
373
206
  });
374
- var DialogOverlay = (0, import_core6.forwardRef)(
207
+ var DialogOverlay = (0, import_core5.forwardRef)(
375
208
  ({ className, ...rest }, ref) => {
376
209
  const styles = useDialog();
377
210
  const css = { ...styles.overlay };
378
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
211
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
379
212
  ModalOverlay,
380
213
  {
381
214
  ref,
382
- className: (0, import_utils6.cx)("ui-dialog-overlay", className),
215
+ className: (0, import_utils5.cx)("ui-dialog-overlay", className),
383
216
  __css: css,
384
217
  ...rest
385
218
  }
386
219
  );
387
220
  }
388
221
  );
389
- var DialogCloseButton = (0, import_core6.forwardRef)(
222
+ var DialogCloseButton = (0, import_core5.forwardRef)(
390
223
  ({ className, ...rest }, ref) => {
391
224
  const styles = useDialog();
392
225
  const css = { ...styles.closeButton };
393
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
226
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
394
227
  ModalCloseButton,
395
228
  {
396
229
  ref,
397
- className: (0, import_utils6.cx)("ui-dialog-close-button", className),
230
+ className: (0, import_utils5.cx)("ui-dialog-close-button", className),
398
231
  __css: css,
399
232
  ...rest
400
233
  }
401
234
  );
402
235
  }
403
236
  );
404
- var DialogHeader = (0, import_core6.forwardRef)(
237
+ var DialogHeader = (0, import_core5.forwardRef)(
405
238
  ({ className, ...rest }, ref) => {
406
239
  const styles = useDialog();
407
240
  const css = { ...styles.header };
408
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalHeader, { ref, className: (0, import_utils6.cx)("ui-dialog-header", className), __css: css, ...rest });
241
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalHeader, { ref, className: (0, import_utils5.cx)("ui-dialog-header", className), __css: css, ...rest });
409
242
  }
410
243
  );
411
- var DialogBody = (0, import_core6.forwardRef)(({ className, ...rest }, ref) => {
244
+ var DialogBody = (0, import_core5.forwardRef)(({ className, ...rest }, ref) => {
412
245
  const styles = useDialog();
413
246
  const css = { ...styles.body };
414
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalBody, { ref, className: (0, import_utils6.cx)("ui-dialog-body", className), __css: css, ...rest });
247
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalBody, { ref, className: (0, import_utils5.cx)("ui-dialog-body", className), __css: css, ...rest });
415
248
  });
416
- var DialogFooter = (0, import_core6.forwardRef)(
249
+ var DialogFooter = (0, import_core5.forwardRef)(
417
250
  ({ className, ...rest }, ref) => {
418
251
  const styles = useDialog();
419
252
  const css = { ...styles.footer };
420
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalFooter, { ref, className: (0, import_utils6.cx)("ui-dialog-footer", className), __css: css, ...rest });
253
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ModalFooter, { ref, className: (0, import_utils5.cx)("ui-dialog-footer", className), __css: css, ...rest });
421
254
  }
422
255
  );
423
256
 
424
257
  // src/drawer.tsx
425
- var import_core7 = require("@yamada-ui/core");
426
- var import_transitions3 = require("@yamada-ui/transitions");
427
- var import_utils7 = require("@yamada-ui/utils");
428
- var import_jsx_runtime7 = require("react/jsx-runtime");
429
- var [DrawerProvider, useDrawer] = (0, import_utils7.createContext)({
258
+ var import_jsx_runtime6 = require("react/jsx-runtime");
259
+ var [DrawerProvider, useDrawer] = (0, import_utils6.createContext)({
430
260
  name: `DrawerContext`,
431
261
  errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
432
262
  });
433
- var Drawer = (0, import_core7.forwardRef)(({ size, ...props }, ref) => {
434
- const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("Drawer", { size, ...props });
263
+ var Drawer = (0, import_core6.forwardRef)(({ size, ...props }, ref) => {
264
+ const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("Drawer", { size, ...props });
435
265
  const {
436
266
  className,
437
267
  children,
@@ -454,10 +284,10 @@ var Drawer = (0, import_core7.forwardRef)(({ size, ...props }, ref) => {
454
284
  lockFocusAcrossFrames,
455
285
  duration = { enter: 0.4, exit: 0.3 },
456
286
  ...rest
457
- } = (0, import_core7.omitThemeProps)(mergedProps);
458
- const validChildren = (0, import_utils7.getValidChildren)(children);
459
- const [customDrawerOverlay, ...cloneChildren] = (0, import_utils7.findChildren)(validChildren, DrawerOverlay);
460
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
287
+ } = (0, import_core6.omitThemeProps)(mergedProps);
288
+ const validChildren = (0, import_utils6.getValidChildren)(children);
289
+ const [customDrawerOverlay, ...cloneChildren] = (0, import_utils6.findChildren)(validChildren, DrawerOverlay);
290
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
461
291
  Modal,
462
292
  {
463
293
  ref,
@@ -481,18 +311,18 @@ var Drawer = (0, import_core7.forwardRef)(({ size, ...props }, ref) => {
481
311
  duration
482
312
  },
483
313
  children: [
484
- customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerOverlay, {}) : null,
485
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
314
+ customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerOverlay, {}) : null,
315
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerContent, { ...{ placement, withCloseButton, ...rest }, children: cloneChildren })
486
316
  ]
487
317
  }
488
318
  ) });
489
319
  });
490
- var DrawerContent = (0, import_core7.forwardRef)(
320
+ var DrawerContent = (0, import_core6.forwardRef)(
491
321
  ({ className, children, placement, withCloseButton, ...rest }, ref) => {
492
322
  const { isOpen, onClose, duration } = useModal();
493
323
  const styles = useDrawer();
494
- const validChildren = (0, import_utils7.getValidChildren)(children);
495
- const [customDrawerCloseButton, ...cloneChildren] = (0, import_utils7.findChildren)(
324
+ const validChildren = (0, import_utils6.getValidChildren)(children);
325
+ const [customDrawerCloseButton, ...cloneChildren] = (0, import_utils6.findChildren)(
496
326
  validChildren,
497
327
  DrawerCloseButton
498
328
  );
@@ -503,11 +333,11 @@ var DrawerContent = (0, import_core7.forwardRef)(
503
333
  outline: 0,
504
334
  ...styles.container
505
335
  };
506
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
507
- import_transitions3.Slide,
336
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
337
+ import_transitions2.Slide,
508
338
  {
509
339
  ref,
510
- className: (0, import_utils7.cx)("ui-drawer", className),
340
+ className: (0, import_utils6.cx)("ui-drawer", className),
511
341
  tabIndex: -1,
512
342
  isOpen,
513
343
  placement,
@@ -515,60 +345,234 @@ var DrawerContent = (0, import_core7.forwardRef)(
515
345
  __css: css,
516
346
  ...rest,
517
347
  children: [
518
- customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerCloseButton, {}) : null,
348
+ customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerCloseButton, {}) : null,
519
349
  cloneChildren
520
350
  ]
521
351
  }
522
352
  );
523
353
  }
524
354
  );
525
- var DrawerOverlay = (0, import_core7.forwardRef)(
355
+ var DrawerOverlay = (0, import_core6.forwardRef)(
526
356
  ({ className, ...rest }, ref) => {
527
357
  const styles = useDrawer();
528
358
  const css = { ...styles.overlay };
529
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
359
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
530
360
  ModalOverlay,
531
361
  {
532
362
  ref,
533
- className: (0, import_utils7.cx)("ui-drawer-overlay", className),
363
+ className: (0, import_utils6.cx)("ui-drawer-overlay", className),
534
364
  __css: css,
535
365
  ...rest
536
366
  }
537
367
  );
538
368
  }
539
369
  );
540
- var DrawerCloseButton = (0, import_core7.forwardRef)(
370
+ var DrawerCloseButton = (0, import_core6.forwardRef)(
541
371
  ({ className, ...rest }, ref) => {
542
372
  const styles = useDrawer();
543
373
  const css = { ...styles.closeButton };
544
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
374
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
545
375
  ModalCloseButton,
546
376
  {
547
377
  ref,
548
- className: (0, import_utils7.cx)("ui-drawer-close-button", className),
378
+ className: (0, import_utils6.cx)("ui-drawer-close-button", className),
549
379
  __css: css,
550
380
  ...rest
551
381
  }
552
382
  );
553
383
  }
554
384
  );
555
- var DrawerHeader = (0, import_core7.forwardRef)(
385
+ var DrawerHeader = (0, import_core6.forwardRef)(
556
386
  ({ className, ...rest }, ref) => {
557
387
  const styles = useDrawer();
558
388
  const css = { ...styles.header };
559
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalHeader, { ref, className: (0, import_utils7.cx)("ui-drawer-header", className), __css: css, ...rest });
389
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalHeader, { ref, className: (0, import_utils6.cx)("ui-drawer-header", className), __css: css, ...rest });
560
390
  }
561
391
  );
562
- var DrawerBody = (0, import_core7.forwardRef)(({ className, ...rest }, ref) => {
392
+ var DrawerBody = (0, import_core6.forwardRef)(({ className, ...rest }, ref) => {
563
393
  const styles = useDrawer();
564
394
  const css = { ...styles.body };
565
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalBody, { ref, className: (0, import_utils7.cx)("ui-drawer-body", className), __css: css, ...rest });
395
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalBody, { ref, className: (0, import_utils6.cx)("ui-drawer-body", className), __css: css, ...rest });
566
396
  });
567
- var DrawerFooter = (0, import_core7.forwardRef)(
397
+ var DrawerFooter = (0, import_core6.forwardRef)(
568
398
  ({ className, ...rest }, ref) => {
569
399
  const styles = useDrawer();
570
400
  const css = { ...styles.footer };
571
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalFooter, { ref, className: (0, import_utils7.cx)("ui-drawer-footer", className), __css: css, ...rest });
401
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModalFooter, { ref, className: (0, import_utils6.cx)("ui-drawer-footer", className), __css: css, ...rest });
402
+ }
403
+ );
404
+
405
+ // src/modal.tsx
406
+ var import_jsx_runtime7 = require("react/jsx-runtime");
407
+ var [ModalProvider, useModal] = (0, import_utils7.createContext)({
408
+ name: `ModalContext`,
409
+ errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
410
+ });
411
+ var Modal = (0, import_core7.forwardRef)(({ size, ...props }, ref) => {
412
+ const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("Modal", { size, ...props });
413
+ const {
414
+ className,
415
+ children,
416
+ isOpen,
417
+ onClose,
418
+ onOverlayClick,
419
+ onEsc,
420
+ onCloseComplete,
421
+ placement: _placement = "center",
422
+ outside = "md",
423
+ withCloseButton = true,
424
+ withOverlay = true,
425
+ allowPinchZoom = false,
426
+ scrollBehavior = "inside",
427
+ autoFocus,
428
+ restoreFocus,
429
+ initialFocusRef,
430
+ finalFocusRef,
431
+ blockScrollOnMount = true,
432
+ closeOnOverlay = true,
433
+ closeOnEsc = true,
434
+ lockFocusAcrossFrames = true,
435
+ animation = "scale",
436
+ duration,
437
+ ...rest
438
+ } = (0, import_core7.omitThemeProps)(mergedProps);
439
+ const onKeyDown = (0, import_react.useCallback)(
440
+ (event) => {
441
+ if (event.key !== "Escape")
442
+ return;
443
+ event.stopPropagation();
444
+ if (closeOnEsc)
445
+ onClose == null ? void 0 : onClose();
446
+ onEsc == null ? void 0 : onEsc();
447
+ },
448
+ [closeOnEsc, onClose, onEsc]
449
+ );
450
+ const validChildren = (0, import_utils7.getValidChildren)(children);
451
+ const [customModalOverlay, ...cloneChildren] = (0, import_utils7.findChildren)(
452
+ validChildren,
453
+ ModalOverlay,
454
+ DialogOverlay,
455
+ DrawerOverlay
456
+ );
457
+ let [drawerContent] = (0, import_utils7.findChildren)(validChildren, DrawerContent);
458
+ if (drawerContent)
459
+ drawerContent = (0, import_react.cloneElement)(drawerContent, { onKeyDown });
460
+ const placement = (0, import_use_value.useValue)(_placement);
461
+ const css = {
462
+ position: "fixed",
463
+ top: 0,
464
+ left: 0,
465
+ zIndex: "beerus",
466
+ w: "100vw",
467
+ h: "100vh",
468
+ p: size !== "full" ? outside : void 0,
469
+ display: "flex",
470
+ justifyContent: placement.includes("right") ? "flex-start" : placement.includes("left") ? "flex-end" : "center",
471
+ alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
472
+ };
473
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
474
+ ModalProvider,
475
+ {
476
+ value: {
477
+ isOpen,
478
+ onClose,
479
+ onOverlayClick,
480
+ withCloseButton,
481
+ scrollBehavior,
482
+ closeOnOverlay,
483
+ animation,
484
+ duration,
485
+ styles
486
+ },
487
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_motion2.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
488
+ import_focus_lock.FocusLock,
489
+ {
490
+ autoFocus,
491
+ initialFocusRef,
492
+ finalFocusRef,
493
+ restoreFocus,
494
+ lockFocusAcrossFrames,
495
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
496
+ import_react_remove_scroll.RemoveScroll,
497
+ {
498
+ allowPinchZoom,
499
+ enabled: blockScrollOnMount,
500
+ forwardProps: true,
501
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { __css: css, children: [
502
+ customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalOverlay, {}) : null,
503
+ drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalContent, { ref, className, onKeyDown, ...rest, children: cloneChildren })
504
+ ] })
505
+ }
506
+ )
507
+ }
508
+ ) }) : null })
509
+ }
510
+ );
511
+ });
512
+ var getModalContentProps = (animation = "scale", duration) => {
513
+ switch (animation) {
514
+ case "scale":
515
+ return {
516
+ ...import_transitions3.scaleFadeProps,
517
+ custom: { scale: 0.95, reverse: true, duration }
518
+ };
519
+ case "top":
520
+ return {
521
+ ...import_transitions3.slideFadeProps,
522
+ custom: { offsetY: -16, reverse: true, duration }
523
+ };
524
+ case "right":
525
+ return {
526
+ ...import_transitions3.slideFadeProps,
527
+ custom: { offsetX: 16, reverse: true, duration }
528
+ };
529
+ case "left":
530
+ return {
531
+ ...import_transitions3.slideFadeProps,
532
+ custom: { offsetX: -16, reverse: true, duration }
533
+ };
534
+ case "bottom":
535
+ return {
536
+ ...import_transitions3.slideFadeProps,
537
+ custom: { offsetY: 16, reverse: true, duration }
538
+ };
539
+ }
540
+ };
541
+ var ModalContent = (0, import_core7.forwardRef)(
542
+ ({ className, children, __css, ...rest }, ref) => {
543
+ const { styles, scrollBehavior, withCloseButton, onClose, animation, duration } = useModal();
544
+ const validChildren = (0, import_utils7.getValidChildren)(children);
545
+ const [customModalCloseButton, ...cloneChildren] = (0, import_utils7.findChildren)(
546
+ validChildren,
547
+ ModalCloseButton,
548
+ DialogCloseButton
549
+ );
550
+ const props = animation !== "none" ? getModalContentProps(animation, duration) : {};
551
+ const css = {
552
+ position: "relative",
553
+ maxH: "100%",
554
+ display: "flex",
555
+ flexDirection: "column",
556
+ overflow: scrollBehavior === "inside" ? "hidden" : "auto",
557
+ outline: 0,
558
+ ...__css ? __css : styles.container
559
+ };
560
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
561
+ import_core7.ui.section,
562
+ {
563
+ as: import_motion2.motion.section,
564
+ ref,
565
+ className: (0, import_utils7.cx)("ui-modal", className),
566
+ tabIndex: -1,
567
+ __css: css,
568
+ ...props,
569
+ ...rest,
570
+ children: [
571
+ customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalCloseButton, {}) : null,
572
+ cloneChildren
573
+ ]
574
+ }
575
+ );
572
576
  }
573
577
  );
574
578