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