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