@yamada-ui/modal 1.3.9 → 1.3.10-dev-20240917033401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/chunk-2EF6C34T.mjs +35 -0
  2. package/dist/chunk-2EF6C34T.mjs.map +1 -0
  3. package/dist/chunk-2GGZOTUT.mjs +32 -0
  4. package/dist/chunk-2GGZOTUT.mjs.map +1 -0
  5. package/dist/chunk-2UHL64SV.mjs +150 -0
  6. package/dist/chunk-2UHL64SV.mjs.map +1 -0
  7. package/dist/chunk-2XQPQIQG.mjs +32 -0
  8. package/dist/chunk-2XQPQIQG.mjs.map +1 -0
  9. package/dist/chunk-3CPIBNSS.mjs +32 -0
  10. package/dist/chunk-3CPIBNSS.mjs.map +1 -0
  11. package/dist/chunk-3S4JQQU3.mjs +32 -0
  12. package/dist/chunk-3S4JQQU3.mjs.map +1 -0
  13. package/dist/chunk-4G6PCQ4G.mjs +51 -0
  14. package/dist/chunk-4G6PCQ4G.mjs.map +1 -0
  15. package/dist/chunk-4J4ISPN7.mjs +26 -0
  16. package/dist/chunk-4J4ISPN7.mjs.map +1 -0
  17. package/dist/chunk-5OKOSAXO.mjs +37 -0
  18. package/dist/chunk-5OKOSAXO.mjs.map +1 -0
  19. package/dist/chunk-B2LUOR6L.mjs +32 -0
  20. package/dist/chunk-B2LUOR6L.mjs.map +1 -0
  21. package/dist/chunk-B436JYPR.mjs +34 -0
  22. package/dist/chunk-B436JYPR.mjs.map +1 -0
  23. package/dist/chunk-CW5ZZAAV.mjs +34 -0
  24. package/dist/chunk-CW5ZZAAV.mjs.map +1 -0
  25. package/dist/chunk-DV6BTDBZ.mjs +32 -0
  26. package/dist/chunk-DV6BTDBZ.mjs.map +1 -0
  27. package/dist/chunk-G646NVHY.mjs +176 -0
  28. package/dist/chunk-G646NVHY.mjs.map +1 -0
  29. package/dist/chunk-HM447TIY.mjs +32 -0
  30. package/dist/chunk-HM447TIY.mjs.map +1 -0
  31. package/dist/chunk-I6LPF3F6.mjs +95 -0
  32. package/dist/chunk-I6LPF3F6.mjs.map +1 -0
  33. package/dist/chunk-OFDDT2JT.mjs +32 -0
  34. package/dist/chunk-OFDDT2JT.mjs.map +1 -0
  35. package/dist/chunk-RSAJUBWR.mjs +32 -0
  36. package/dist/chunk-RSAJUBWR.mjs.map +1 -0
  37. package/dist/chunk-WEDZHILB.mjs +29 -0
  38. package/dist/chunk-WEDZHILB.mjs.map +1 -0
  39. package/dist/chunk-Y2QXIJZA.mjs +138 -0
  40. package/dist/chunk-Y2QXIJZA.mjs.map +1 -0
  41. package/dist/chunk-Y5NCRCDU.mjs +32 -0
  42. package/dist/chunk-Y5NCRCDU.mjs.map +1 -0
  43. package/dist/chunk-ZR2AEIGZ.mjs +116 -0
  44. package/dist/chunk-ZR2AEIGZ.mjs.map +1 -0
  45. package/dist/dialog-body.d.mts +8 -0
  46. package/dist/dialog-body.d.ts +8 -0
  47. package/dist/dialog-body.js +94 -0
  48. package/dist/dialog-body.js.map +1 -0
  49. package/dist/dialog-body.mjs +10 -0
  50. package/dist/dialog-body.mjs.map +1 -0
  51. package/dist/dialog-close-button.d.mts +8 -0
  52. package/dist/dialog-close-button.d.ts +8 -0
  53. package/dist/dialog-close-button.js +96 -0
  54. package/dist/dialog-close-button.js.map +1 -0
  55. package/dist/dialog-close-button.mjs +10 -0
  56. package/dist/dialog-close-button.mjs.map +1 -0
  57. package/dist/dialog-footer.d.mts +8 -0
  58. package/dist/dialog-footer.d.ts +8 -0
  59. package/dist/dialog-footer.js +91 -0
  60. package/dist/dialog-footer.js.map +1 -0
  61. package/dist/dialog-footer.mjs +10 -0
  62. package/dist/dialog-footer.mjs.map +1 -0
  63. package/dist/dialog-header.d.mts +8 -0
  64. package/dist/dialog-header.d.ts +8 -0
  65. package/dist/dialog-header.js +91 -0
  66. package/dist/dialog-header.js.map +1 -0
  67. package/dist/dialog-header.mjs +10 -0
  68. package/dist/dialog-header.mjs.map +1 -0
  69. package/dist/dialog-overlay.d.mts +8 -0
  70. package/dist/dialog-overlay.d.ts +8 -0
  71. package/dist/dialog-overlay.js +108 -0
  72. package/dist/dialog-overlay.js.map +1 -0
  73. package/dist/dialog-overlay.mjs +10 -0
  74. package/dist/dialog-overlay.mjs.map +1 -0
  75. package/dist/dialog.d.mts +7 -21
  76. package/dist/dialog.d.ts +7 -21
  77. package/dist/dialog.js +593 -678
  78. package/dist/dialog.js.map +1 -1
  79. package/dist/dialog.mjs +20 -13
  80. package/dist/drawer-body.d.mts +8 -0
  81. package/dist/drawer-body.d.ts +8 -0
  82. package/dist/drawer-body.js +94 -0
  83. package/dist/drawer-body.js.map +1 -0
  84. package/dist/drawer-body.mjs +10 -0
  85. package/dist/drawer-body.mjs.map +1 -0
  86. package/dist/drawer-close-button.d.mts +9 -0
  87. package/dist/drawer-close-button.d.ts +9 -0
  88. package/dist/drawer-close-button.js +96 -0
  89. package/dist/drawer-close-button.js.map +1 -0
  90. package/dist/drawer-close-button.mjs +10 -0
  91. package/dist/drawer-close-button.mjs.map +1 -0
  92. package/dist/drawer-content.d.mts +16 -0
  93. package/dist/drawer-content.d.ts +16 -0
  94. package/dist/drawer-content.js +278 -0
  95. package/dist/drawer-content.js.map +1 -0
  96. package/dist/drawer-content.mjs +12 -0
  97. package/dist/drawer-content.mjs.map +1 -0
  98. package/dist/drawer-drag-bar.d.mts +8 -0
  99. package/dist/drawer-drag-bar.d.ts +8 -0
  100. package/dist/drawer-drag-bar.js +66 -0
  101. package/dist/drawer-drag-bar.js.map +1 -0
  102. package/dist/drawer-drag-bar.mjs +9 -0
  103. package/dist/drawer-drag-bar.mjs.map +1 -0
  104. package/dist/drawer-footer.d.mts +8 -0
  105. package/dist/drawer-footer.d.ts +8 -0
  106. package/dist/drawer-footer.js +91 -0
  107. package/dist/drawer-footer.js.map +1 -0
  108. package/dist/drawer-footer.mjs +10 -0
  109. package/dist/drawer-footer.mjs.map +1 -0
  110. package/dist/drawer-header.d.mts +8 -0
  111. package/dist/drawer-header.d.ts +8 -0
  112. package/dist/drawer-header.js +91 -0
  113. package/dist/drawer-header.js.map +1 -0
  114. package/dist/drawer-header.mjs +10 -0
  115. package/dist/drawer-header.mjs.map +1 -0
  116. package/dist/drawer-overlay.d.mts +8 -0
  117. package/dist/drawer-overlay.d.ts +8 -0
  118. package/dist/drawer-overlay.js +108 -0
  119. package/dist/drawer-overlay.js.map +1 -0
  120. package/dist/drawer-overlay.mjs +10 -0
  121. package/dist/drawer-overlay.mjs.map +1 -0
  122. package/dist/drawer.d.mts +8 -27
  123. package/dist/drawer.d.ts +8 -27
  124. package/dist/drawer.js +405 -640
  125. package/dist/drawer.js.map +1 -1
  126. package/dist/drawer.mjs +14 -17
  127. package/dist/index.d.mts +13 -2
  128. package/dist/index.d.ts +13 -2
  129. package/dist/index.js +492 -413
  130. package/dist/index.js.map +1 -1
  131. package/dist/index.mjs +56 -18
  132. package/dist/modal-body.d.mts +3 -2
  133. package/dist/modal-body.d.ts +3 -2
  134. package/dist/modal-body.js +13 -856
  135. package/dist/modal-body.js.map +1 -1
  136. package/dist/modal-body.mjs +2 -1
  137. package/dist/modal-close-button.d.mts +3 -2
  138. package/dist/modal-close-button.d.ts +3 -2
  139. package/dist/modal-close-button.js +13 -854
  140. package/dist/modal-close-button.js.map +1 -1
  141. package/dist/modal-close-button.mjs +2 -1
  142. package/dist/modal-content.d.mts +9 -0
  143. package/dist/modal-content.d.ts +9 -0
  144. package/dist/modal-content.js +178 -0
  145. package/dist/modal-content.js.map +1 -0
  146. package/dist/modal-content.mjs +11 -0
  147. package/dist/modal-content.mjs.map +1 -0
  148. package/dist/modal-context.d.mts +27 -0
  149. package/dist/modal-context.d.ts +27 -0
  150. package/dist/modal-context.js +54 -0
  151. package/dist/modal-context.js.map +1 -0
  152. package/dist/modal-context.mjs +18 -0
  153. package/dist/modal-context.mjs.map +1 -0
  154. package/dist/modal-footer.d.mts +2 -1
  155. package/dist/modal-footer.d.ts +2 -1
  156. package/dist/modal-footer.js +13 -857
  157. package/dist/modal-footer.js.map +1 -1
  158. package/dist/modal-footer.mjs +2 -1
  159. package/dist/modal-header.d.mts +2 -1
  160. package/dist/modal-header.d.ts +2 -1
  161. package/dist/modal-header.js +13 -857
  162. package/dist/modal-header.js.map +1 -1
  163. package/dist/modal-header.mjs +2 -1
  164. package/dist/modal-overlay.d.mts +2 -1
  165. package/dist/modal-overlay.d.ts +2 -1
  166. package/dist/modal-overlay.js +16 -843
  167. package/dist/modal-overlay.js.map +1 -1
  168. package/dist/modal-overlay.mjs +2 -1
  169. package/dist/modal.d.mts +10 -14
  170. package/dist/modal.d.ts +10 -14
  171. package/dist/modal.js +183 -508
  172. package/dist/modal.js.map +1 -1
  173. package/dist/modal.mjs +13 -5
  174. package/package.json +10 -10
  175. package/dist/chunk-7PS3HWMF.mjs +0 -938
  176. package/dist/chunk-7PS3HWMF.mjs.map +0 -1
@@ -24,855 +24,28 @@ __export(modal_overlay_exports, {
24
24
  ModalOverlay: () => ModalOverlay
25
25
  });
26
26
  module.exports = __toCommonJS(modal_overlay_exports);
27
- var import_motion4 = require("@yamada-ui/motion");
28
- var import_transitions3 = require("@yamada-ui/transitions");
29
- var import_utils8 = require("@yamada-ui/utils");
30
-
31
- // src/modal.tsx
32
- var import_core7 = require("@yamada-ui/core");
33
- var import_focus_lock = require("@yamada-ui/focus-lock");
34
- var import_motion3 = require("@yamada-ui/motion");
35
- var import_portal = require("@yamada-ui/portal");
36
- var import_transitions2 = require("@yamada-ui/transitions");
37
- var import_use_value2 = require("@yamada-ui/use-value");
38
- var import_utils7 = require("@yamada-ui/utils");
39
- var import_react2 = require("react");
40
- var import_react_remove_scroll = require("react-remove-scroll");
41
-
42
- // src/drawer.tsx
43
- var import_core6 = require("@yamada-ui/core");
44
- var import_motion2 = require("@yamada-ui/motion");
27
+ var import_motion = require("@yamada-ui/motion");
45
28
  var import_transitions = require("@yamada-ui/transitions");
46
- var import_use_value = require("@yamada-ui/use-value");
47
- var import_utils6 = require("@yamada-ui/utils");
48
- var import_react = require("react");
49
-
50
- // src/modal-close-button.tsx
51
- var import_close_button = require("@yamada-ui/close-button");
52
- var import_core = require("@yamada-ui/core");
53
- var import_utils = require("@yamada-ui/utils");
54
- var import_jsx_runtime = require("react/jsx-runtime");
55
- var ModalCloseButton = (0, import_core.forwardRef)(
56
- ({ onClick, __css, ...rest }, ref) => {
57
- const { styles, onClose } = useModal();
58
- const css = {
59
- position: "absolute",
60
- ...__css ? __css : styles.closeButton
61
- };
62
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
- import_close_button.CloseButton,
64
- {
65
- ref,
66
- className: (0, import_utils.cx)("ui-modal__close-button"),
67
- __css: css,
68
- onClick: (0, import_utils.handlerAll)(onClick, (ev) => {
69
- ev.stopPropagation();
70
- onClose == null ? void 0 : onClose();
71
- }),
72
- ...rest
73
- }
74
- );
75
- }
76
- );
77
-
78
- // src/modal-header.tsx
79
- var import_core2 = require("@yamada-ui/core");
80
29
  var import_utils2 = require("@yamada-ui/utils");
81
- var import_jsx_runtime2 = require("react/jsx-runtime");
82
- var ModalHeader = (0, import_core2.forwardRef)(
83
- ({ className, __css, ...rest }, ref) => {
84
- const { styles } = useModal();
85
- const css = {
86
- display: "flex",
87
- alignItems: "center",
88
- justifyContent: "flex-start",
89
- ...__css ? __css : styles.header
90
- };
91
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
92
- import_core2.ui.header,
93
- {
94
- ref,
95
- className: (0, import_utils2.cx)("ui-modal__header", className),
96
- __css: css,
97
- ...rest
98
- }
99
- );
100
- }
101
- );
102
-
103
- // src/modal-body.tsx
104
- var import_core3 = require("@yamada-ui/core");
105
- var import_utils3 = require("@yamada-ui/utils");
106
- var import_jsx_runtime3 = require("react/jsx-runtime");
107
- var ModalBody = (0, import_core3.forwardRef)(
108
- ({ className, __css, ...rest }, ref) => {
109
- const { styles, scrollBehavior } = useModal();
110
- const css = {
111
- display: "flex",
112
- flexDirection: "column",
113
- alignItems: "flex-start",
114
- overflow: scrollBehavior === "inside" ? "auto" : void 0,
115
- ...__css ? __css : styles.body
116
- };
117
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
118
- import_core3.ui.div,
119
- {
120
- ref,
121
- className: (0, import_utils3.cx)("ui-modal__body", className),
122
- __css: css,
123
- ...rest
124
- }
125
- );
126
- }
127
- );
128
30
 
129
- // src/modal-footer.tsx
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)(
134
- ({ className, __css, ...rest }, ref) => {
135
- const { styles } = useModal();
136
- const css = {
137
- display: "flex",
138
- alignItems: "center",
139
- justifyContent: "flex-end",
140
- ...__css ? __css : styles.footer
141
- };
142
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
143
- import_core4.ui.footer,
144
- {
145
- ref,
146
- className: (0, import_utils4.cx)("ui-modal__footer", className),
147
- __css: css,
148
- ...rest
149
- }
150
- );
151
- }
152
- );
153
-
154
- // src/dialog.tsx
155
- var import_button = require("@yamada-ui/button");
156
- var import_core5 = require("@yamada-ui/core");
157
- var import_motion = require("@yamada-ui/motion");
158
- var import_utils5 = require("@yamada-ui/utils");
159
- var import_jsx_runtime5 = require("react/jsx-runtime");
160
- var [DialogProvider, useDialog] = (0, import_utils5.createContext)({
31
+ // src/modal-context.ts
32
+ var import_utils = require("@yamada-ui/utils");
33
+ var [ModalProvider, useModal] = (0, import_utils.createContext)({
34
+ name: `ModalContext`,
35
+ errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
36
+ });
37
+ var [DialogProvider, useDialog] = (0, import_utils.createContext)({
161
38
  name: `DialogContext`,
162
39
  errorMessage: `useDialog returned is 'undefined'. Seems you forgot to wrap the components in "<Dialog />" `
163
40
  });
164
- var Dialog = (0, import_motion.motionForwardRef)(
165
- ({ size, ...props }, ref) => {
166
- const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("Dialog", {
167
- size,
168
- ...props
169
- });
170
- const {
171
- className,
172
- children,
173
- withOverlay = true,
174
- withCloseButton = true,
175
- header,
176
- footer,
177
- cancel,
178
- other,
179
- success,
180
- onClose,
181
- onCancel,
182
- onOther,
183
- onSuccess,
184
- containerProps,
185
- ...rest
186
- } = (0, import_core5.omitThemeProps)(mergedProps);
187
- const validChildren = (0, import_utils5.getValidChildren)(children);
188
- const [customDialogOverlay] = (0, import_utils5.findChildren)(validChildren, DialogOverlay);
189
- const [customDialogCloseButton] = (0, import_utils5.findChildren)(
190
- validChildren,
191
- DialogCloseButton
192
- );
193
- const [customDialogHeader] = (0, import_utils5.findChildren)(validChildren, DialogHeader);
194
- const [customDialogBody] = (0, import_utils5.findChildren)(validChildren, DialogBody);
195
- const [customDialogFooter] = (0, import_utils5.findChildren)(validChildren, DialogFooter);
196
- const cloneChildren = !(0, import_utils5.isEmpty)(validChildren) ? (0, import_utils5.omitChildren)(
197
- validChildren,
198
- DialogOverlay,
199
- DialogCloseButton,
200
- DialogHeader,
201
- DialogBody,
202
- DialogFooter
203
- ) : children;
204
- const css = { ...styles.container };
205
- const cancelButtonProps = (0, import_utils5.isValidElement)(cancel) ? { children: cancel } : cancel;
206
- const otherButtonProps = (0, import_utils5.isValidElement)(other) ? { children: other } : other;
207
- const successButtonProps = (0, import_utils5.isValidElement)(success) ? { children: success } : success;
208
- if (cancelButtonProps && !cancelButtonProps.variant)
209
- cancelButtonProps.variant = "ghost";
210
- if (otherButtonProps && !otherButtonProps.colorScheme)
211
- otherButtonProps.colorScheme = "secondary";
212
- if (successButtonProps && !successButtonProps.colorScheme)
213
- successButtonProps.colorScheme = "primary";
214
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
215
- Modal,
216
- {
217
- ref,
218
- className: (0, import_utils5.cx)("ui-dialog", className),
219
- __css: css,
220
- ...{
221
- onClose,
222
- withOverlay: false,
223
- withCloseButton: false,
224
- containerProps,
225
- ...rest,
226
- size
227
- },
228
- children: [
229
- customDialogOverlay != null ? customDialogOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogOverlay, {}) : null,
230
- customDialogCloseButton != null ? customDialogCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogCloseButton, {}) : null,
231
- customDialogHeader != null ? customDialogHeader : header ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogHeader, { children: header }) : null,
232
- customDialogBody != null ? customDialogBody : cloneChildren ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DialogBody, { children: cloneChildren }) : null,
233
- 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: [
234
- cancelButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
235
- import_button.Button,
236
- {
237
- onClick: () => onCancel == null ? void 0 : onCancel(onClose),
238
- ...cancelButtonProps
239
- }
240
- ) : null,
241
- otherButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
242
- import_button.Button,
243
- {
244
- onClick: () => onOther == null ? void 0 : onOther(onClose),
245
- ...otherButtonProps
246
- }
247
- ) : null,
248
- successButtonProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
249
- import_button.Button,
250
- {
251
- onClick: () => onSuccess == null ? void 0 : onSuccess(onClose),
252
- ...successButtonProps
253
- }
254
- ) : null
255
- ] }) }) : null
256
- ]
257
- }
258
- ) });
259
- }
260
- );
261
- var DialogOverlay = (0, import_motion.motionForwardRef)(
262
- ({ className, ...rest }, ref) => {
263
- const styles = useDialog();
264
- const css = { ...styles.overlay };
265
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
266
- ModalOverlay,
267
- {
268
- ref,
269
- className: (0, import_utils5.cx)("ui-dialog__overlay", className),
270
- __css: css,
271
- ...rest
272
- }
273
- );
274
- }
275
- );
276
- var DialogCloseButton = (0, import_core5.forwardRef)(
277
- ({ className, ...rest }, ref) => {
278
- const styles = useDialog();
279
- const css = { ...styles.closeButton };
280
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
281
- ModalCloseButton,
282
- {
283
- ref,
284
- className: (0, import_utils5.cx)("ui-dialog__close-button", className),
285
- __css: css,
286
- ...rest
287
- }
288
- );
289
- }
290
- );
291
- var DialogHeader = (0, import_core5.forwardRef)(
292
- ({ className, ...rest }, ref) => {
293
- const styles = useDialog();
294
- const css = { ...styles.header };
295
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
296
- ModalHeader,
297
- {
298
- ref,
299
- className: (0, import_utils5.cx)("ui-dialog__header", className),
300
- __css: css,
301
- ...rest
302
- }
303
- );
304
- }
305
- );
306
- var DialogBody = (0, import_core5.forwardRef)(
307
- ({ className, ...rest }, ref) => {
308
- const styles = useDialog();
309
- const css = { ...styles.body };
310
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
311
- ModalBody,
312
- {
313
- ref,
314
- className: (0, import_utils5.cx)("ui-dialog__body", className),
315
- __css: css,
316
- ...rest
317
- }
318
- );
319
- }
320
- );
321
- var DialogFooter = (0, import_core5.forwardRef)(
322
- ({ className, ...rest }, ref) => {
323
- const styles = useDialog();
324
- const css = { ...styles.footer };
325
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
326
- ModalFooter,
327
- {
328
- ref,
329
- className: (0, import_utils5.cx)("ui-dialog__footer", className),
330
- __css: css,
331
- ...rest
332
- }
333
- );
334
- }
335
- );
336
-
337
- // src/drawer.tsx
338
- var import_jsx_runtime6 = require("react/jsx-runtime");
339
- var [DrawerProvider, useDrawer] = (0, import_utils6.createContext)({
41
+ var [DrawerProvider, useDrawer] = (0, import_utils.createContext)({
340
42
  name: `DrawerContext`,
341
43
  errorMessage: `useDrawer returned is 'undefined'. Seems you forgot to wrap the components in "<Drawer />" `
342
44
  });
343
- var Drawer = (0, import_motion2.motionForwardRef)(
344
- ({ size, placement = "right", closeOnDrag = false, ...props }, ref) => {
345
- const [styles, mergedProps] = (0, import_core6.useMultiComponentStyle)("Drawer", {
346
- size,
347
- placement,
348
- closeOnDrag,
349
- ...props
350
- });
351
- const {
352
- children,
353
- isOpen,
354
- onClose,
355
- onOverlayClick,
356
- onEsc,
357
- onCloseComplete,
358
- withCloseButton = !closeOnDrag,
359
- withOverlay = true,
360
- withDragBar = true,
361
- allowPinchZoom,
362
- autoFocus,
363
- restoreFocus,
364
- initialFocusRef,
365
- finalFocusRef,
366
- blockScrollOnMount,
367
- closeOnOverlay,
368
- closeOnEsc,
369
- lockFocusAcrossFrames,
370
- duration = { enter: 0.4, exit: 0.3 },
371
- dragConstraints = 0,
372
- dragElastic = 0.1,
373
- dragOffset = 80,
374
- dragVelocity = 100,
375
- blankForDragProps,
376
- portalProps,
377
- containerProps,
378
- ...rest
379
- } = (0, import_core6.omitThemeProps)(mergedProps, ["isFullHeight"]);
380
- const validChildren = (0, import_utils6.getValidChildren)(children);
381
- const [customDrawerOverlay, ...cloneChildren] = (0, import_utils6.findChildren)(
382
- validChildren,
383
- DrawerOverlay
384
- );
385
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
386
- Modal,
387
- {
388
- ref,
389
- ...{
390
- isOpen,
391
- onClose,
392
- onOverlayClick,
393
- onEsc,
394
- onCloseComplete,
395
- withCloseButton: false,
396
- withOverlay: false,
397
- allowPinchZoom,
398
- autoFocus,
399
- restoreFocus,
400
- initialFocusRef,
401
- finalFocusRef,
402
- blockScrollOnMount,
403
- closeOnOverlay,
404
- closeOnEsc,
405
- lockFocusAcrossFrames,
406
- duration,
407
- portalProps,
408
- containerProps
409
- },
410
- children: [
411
- customDrawerOverlay != null ? customDrawerOverlay : withOverlay ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerOverlay, {}) : null,
412
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
413
- DrawerContent,
414
- {
415
- ...{
416
- dragConstraints,
417
- dragElastic,
418
- dragOffset,
419
- dragVelocity,
420
- withCloseButton,
421
- withDragBar,
422
- blankForDragProps,
423
- ...rest,
424
- placement,
425
- closeOnDrag
426
- },
427
- children: cloneChildren
428
- }
429
- )
430
- ]
431
- }
432
- ) });
433
- }
434
- );
435
- var DrawerContent = (0, import_motion2.motionForwardRef)(
436
- ({
437
- className,
438
- children,
439
- placement: _placement,
440
- withCloseButton,
441
- withDragBar,
442
- closeOnDrag,
443
- dragConstraints,
444
- dragElastic,
445
- dragOffset,
446
- dragVelocity,
447
- blankForDragProps,
448
- ...rest
449
- }, ref) => {
450
- const { isOpen, onClose, duration } = useModal();
451
- const styles = useDrawer();
452
- const placement = (0, import_use_value.useValue)(_placement);
453
- const validChildren = (0, import_utils6.getValidChildren)(children);
454
- const [customDrawerCloseButton, ...cloneChildren] = (0, import_utils6.findChildren)(
455
- validChildren,
456
- DrawerCloseButton
457
- );
458
- const blankForDragBg = (0, import_react.useMemo)(() => {
459
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
460
- const propBg = (_c = (_b = (_a = rest.backgroundColor) != null ? _a : rest.bgColor) != null ? _b : rest.background) != null ? _c : rest.bg;
461
- const styleBg = (_j = (_h = (_f = (_d = styles.container) == null ? void 0 : _d.backgroundColor) != null ? _f : (_e = styles.container) == null ? void 0 : _e.bgColor) != null ? _h : (_g = styles.container) == null ? void 0 : _g.background) != null ? _j : (_i = styles.container) == null ? void 0 : _i.bg;
462
- const computedBg = propBg != null ? propBg : styleBg;
463
- return (0, import_utils6.isArray)(computedBg) ? computedBg : [computedBg];
464
- }, [rest, styles]);
465
- const blankForDrag = (0, import_react.useMemo)(() => {
466
- let position = {};
467
- switch (placement) {
468
- case "top":
469
- position = { top: "calc(-100dvh + 1px)", left: 0, right: 0 };
470
- break;
471
- case "bottom":
472
- position = { bottom: "calc(-100dvh + 1px)", left: 0, right: 0 };
473
- break;
474
- case "left":
475
- position = { left: "calc(-100% + 1px)", top: 0, bottom: 0 };
476
- break;
477
- case "right":
478
- position = { right: "calc(-100% + 1px)", top: 0, bottom: 0 };
479
- break;
480
- }
481
- const [lightBg, darkBg] = blankForDragBg;
482
- return {
483
- _after: {
484
- content: '""',
485
- display: "block",
486
- w: "100%",
487
- h: "100dvh",
488
- bg: lightBg,
489
- position: "absolute",
490
- ...position,
491
- ...blankForDragProps
492
- },
493
- _dark: {
494
- _after: {
495
- bg: darkBg
496
- }
497
- }
498
- };
499
- }, [placement, blankForDragBg, blankForDragProps]);
500
- const css = (0, import_react.useMemo)(
501
- () => ({
502
- display: "flex",
503
- flexDirection: placement === "top" || placement === "bottom" ? "column" : "row",
504
- outline: 0,
505
- ...closeOnDrag ? blankForDrag : {},
506
- ...styles.container
507
- }),
508
- [blankForDrag, closeOnDrag, placement, styles]
509
- );
510
- const getDragDirectionRestriction = (0, import_react.useCallback)(
511
- (value) => {
512
- switch (placement) {
513
- case "top":
514
- return { bottom: value };
515
- case "bottom":
516
- return { top: value };
517
- case "left":
518
- return { right: value };
519
- case "right":
520
- return { left: value };
521
- }
522
- },
523
- [placement]
524
- );
525
- const getDragDirection = (0, import_react.useCallback)(() => {
526
- switch (placement) {
527
- case "top":
528
- case "bottom":
529
- return "y";
530
- case "left":
531
- case "right":
532
- return "x";
533
- }
534
- }, [placement]);
535
- const isCloseByDragInfo = (0, import_react.useCallback)(
536
- (info) => {
537
- switch (placement) {
538
- case "top":
539
- return info.velocity.y <= dragVelocity * -1 || info.offset.y <= dragOffset * -1;
540
- case "bottom":
541
- return info.velocity.y >= dragVelocity || info.offset.y >= dragOffset;
542
- case "left":
543
- return info.velocity.x <= dragVelocity * -1 || info.offset.x <= dragOffset * -1;
544
- case "right":
545
- return info.velocity.x >= dragVelocity || info.offset.x >= dragOffset;
546
- }
547
- },
548
- [placement, dragVelocity, dragOffset]
549
- );
550
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
551
- import_transitions.Slide,
552
- {
553
- ref,
554
- className: (0, import_utils6.cx)("ui-drawer", className),
555
- isOpen,
556
- placement,
557
- duration,
558
- drag: closeOnDrag ? getDragDirection() : false,
559
- dragConstraints: getDragDirectionRestriction(dragConstraints),
560
- dragElastic: getDragDirectionRestriction(dragElastic),
561
- dragSnapToOrigin: true,
562
- dragMomentum: false,
563
- onDragEnd: (_, info) => {
564
- if (isCloseByDragInfo(info)) onClose == null ? void 0 : onClose();
565
- },
566
- tabIndex: -1,
567
- __css: css,
568
- ...rest,
569
- children: [
570
- customDrawerCloseButton != null ? customDrawerCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerCloseButton, {}) : null,
571
- withDragBar && closeOnDrag && (placement === "bottom" || placement === "right") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerDragBar, {}) : null,
572
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
573
- import_core6.ui.div,
574
- {
575
- className: "ui-drawer__inner",
576
- __css: { display: "flex", flexDirection: "column", ...styles.inner },
577
- children: cloneChildren
578
- }
579
- ),
580
- withDragBar && closeOnDrag && (placement === "top" || placement === "left") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DrawerDragBar, {}) : null
581
- ]
582
- }
583
- );
584
- }
585
- );
586
- var DrawerOverlay = (0, import_motion2.motionForwardRef)(
587
- ({ className, ...rest }, ref) => {
588
- const styles = useDrawer();
589
- const css = { ...styles.overlay };
590
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
591
- ModalOverlay,
592
- {
593
- ref,
594
- className: (0, import_utils6.cx)("ui-drawer__overlay", className),
595
- __css: css,
596
- ...rest
597
- }
598
- );
599
- }
600
- );
601
- var DrawerDragBar = ({
602
- className,
603
- ...rest
604
- }) => {
605
- const styles = useDrawer();
606
- const css = { ...styles.dragBar };
607
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
608
- import_core6.ui.div,
609
- {
610
- className: (0, import_utils6.cx)("ui-drawer__drag-bar", className),
611
- __css: css,
612
- ...rest
613
- }
614
- );
615
- };
616
- var DrawerCloseButton = (0, import_core6.forwardRef)(
617
- ({ className, ...rest }, ref) => {
618
- const styles = useDrawer();
619
- const css = { ...styles.closeButton };
620
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
621
- ModalCloseButton,
622
- {
623
- ref,
624
- className: (0, import_utils6.cx)("ui-drawer__close-button", className),
625
- __css: css,
626
- ...rest
627
- }
628
- );
629
- }
630
- );
631
- var DrawerHeader = (0, import_core6.forwardRef)(
632
- ({ className, ...rest }, ref) => {
633
- const styles = useDrawer();
634
- const css = { ...styles.header };
635
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
636
- ModalHeader,
637
- {
638
- ref,
639
- className: (0, import_utils6.cx)("ui-drawer__header", className),
640
- __css: css,
641
- ...rest
642
- }
643
- );
644
- }
645
- );
646
- var DrawerBody = (0, import_core6.forwardRef)(
647
- ({ className, ...rest }, ref) => {
648
- const styles = useDrawer();
649
- const css = { ...styles.body };
650
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
651
- ModalBody,
652
- {
653
- ref,
654
- className: (0, import_utils6.cx)("ui-drawer__body", className),
655
- __css: css,
656
- ...rest
657
- }
658
- );
659
- }
660
- );
661
- var DrawerFooter = (0, import_core6.forwardRef)(
662
- ({ className, ...rest }, ref) => {
663
- const styles = useDrawer();
664
- const css = { ...styles.footer };
665
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
666
- ModalFooter,
667
- {
668
- ref,
669
- className: (0, import_utils6.cx)("ui-drawer__footer", className),
670
- __css: css,
671
- ...rest
672
- }
673
- );
674
- }
675
- );
676
-
677
- // src/modal.tsx
678
- var import_jsx_runtime7 = require("react/jsx-runtime");
679
- var [ModalProvider, useModal] = (0, import_utils7.createContext)({
680
- name: `ModalContext`,
681
- errorMessage: `useModal returned is 'undefined'. Seems you forgot to wrap the components in "<Modal />" `
682
- });
683
- var Modal = (0, import_motion3.motionForwardRef)(
684
- ({ size, ...props }, ref) => {
685
- const [styles, mergedProps] = (0, import_core7.useMultiComponentStyle)("Modal", {
686
- size,
687
- ...props
688
- });
689
- const {
690
- className,
691
- children,
692
- isOpen,
693
- onClose,
694
- onOverlayClick,
695
- onEsc,
696
- onCloseComplete,
697
- placement: _placement = "center",
698
- outside = "fallback(4, 1rem)",
699
- withCloseButton = true,
700
- withOverlay = true,
701
- allowPinchZoom = false,
702
- scrollBehavior = "inside",
703
- autoFocus,
704
- restoreFocus,
705
- initialFocusRef,
706
- finalFocusRef,
707
- blockScrollOnMount = true,
708
- closeOnOverlay = true,
709
- closeOnEsc = true,
710
- lockFocusAcrossFrames = true,
711
- animation = "scale",
712
- duration,
713
- portalProps,
714
- containerProps,
715
- ...rest
716
- } = (0, import_core7.omitThemeProps)(mergedProps);
717
- const onKeyDown = (0, import_react2.useCallback)(
718
- (ev) => {
719
- if (ev.key !== "Escape") return;
720
- ev.stopPropagation();
721
- if (closeOnEsc) onClose == null ? void 0 : onClose();
722
- onEsc == null ? void 0 : onEsc();
723
- },
724
- [closeOnEsc, onClose, onEsc]
725
- );
726
- const validChildren = (0, import_utils7.getValidChildren)(children);
727
- const [customModalOverlay, ...cloneChildren] = (0, import_utils7.findChildren)(
728
- validChildren,
729
- ModalOverlay,
730
- DialogOverlay,
731
- DrawerOverlay
732
- );
733
- let [drawerContent] = (0, import_utils7.findChildren)(validChildren, DrawerContent);
734
- if (drawerContent)
735
- drawerContent = (0, import_react2.cloneElement)(drawerContent, { onKeyDown });
736
- const placement = (0, import_use_value2.useValue)(_placement);
737
- const css = {
738
- position: "fixed",
739
- top: 0,
740
- left: 0,
741
- zIndex: "fallback(jeice, 110)",
742
- w: "100vw",
743
- h: "100dvh",
744
- p: size !== "full" ? outside : void 0,
745
- display: "flex",
746
- justifyContent: placement.includes("left") ? "flex-start" : placement.includes("right") ? "flex-end" : "center",
747
- alignItems: placement.includes("top") ? "flex-start" : placement.includes("bottom") ? "flex-end" : "center"
748
- };
749
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
750
- ModalProvider,
751
- {
752
- value: {
753
- isOpen,
754
- onClose,
755
- onOverlayClick,
756
- withCloseButton,
757
- scrollBehavior,
758
- closeOnOverlay,
759
- animation,
760
- duration,
761
- styles
762
- },
763
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_motion3.AnimatePresence, { onExitComplete: onCloseComplete, children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_portal.Portal, { ...portalProps, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
764
- import_focus_lock.FocusLock,
765
- {
766
- autoFocus,
767
- initialFocusRef,
768
- finalFocusRef,
769
- restoreFocus,
770
- lockFocusAcrossFrames,
771
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
772
- import_react_remove_scroll.RemoveScroll,
773
- {
774
- allowPinchZoom,
775
- enabled: blockScrollOnMount,
776
- forwardProps: true,
777
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { __css: css, ...containerProps, children: [
778
- customModalOverlay != null ? customModalOverlay : withOverlay && size !== "full" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalOverlay, {}) : null,
779
- drawerContent != null ? drawerContent : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
780
- ModalContent,
781
- {
782
- ref,
783
- className,
784
- onKeyDown,
785
- ...rest,
786
- children: cloneChildren
787
- }
788
- )
789
- ] })
790
- }
791
- )
792
- }
793
- ) }) : null })
794
- }
795
- );
796
- }
797
- );
798
- var getModalContentProps = (animation = "scale", duration) => {
799
- switch (animation) {
800
- case "scale":
801
- return {
802
- ...import_transitions2.scaleFadeProps,
803
- custom: { scale: 0.95, reverse: true, duration }
804
- };
805
- case "top":
806
- return {
807
- ...import_transitions2.slideFadeProps,
808
- custom: { offsetY: -16, reverse: true, duration }
809
- };
810
- case "right":
811
- return {
812
- ...import_transitions2.slideFadeProps,
813
- custom: { offsetX: 16, reverse: true, duration }
814
- };
815
- case "left":
816
- return {
817
- ...import_transitions2.slideFadeProps,
818
- custom: { offsetX: -16, reverse: true, duration }
819
- };
820
- case "bottom":
821
- return {
822
- ...import_transitions2.slideFadeProps,
823
- custom: { offsetY: 16, reverse: true, duration }
824
- };
825
- }
826
- };
827
- var ModalContent = (0, import_motion3.motionForwardRef)(
828
- ({ className, children, __css, ...rest }, ref) => {
829
- const {
830
- styles,
831
- scrollBehavior,
832
- withCloseButton,
833
- onClose,
834
- animation,
835
- duration
836
- } = useModal();
837
- const validChildren = (0, import_utils7.getValidChildren)(children);
838
- const [customModalCloseButton, ...cloneChildren] = (0, import_utils7.findChildren)(
839
- validChildren,
840
- ModalCloseButton,
841
- DialogCloseButton
842
- );
843
- const props = animation !== "none" ? getModalContentProps(animation, duration) : {};
844
- const css = {
845
- position: "relative",
846
- maxH: "100%",
847
- display: "flex",
848
- flexDirection: "column",
849
- overflow: scrollBehavior === "inside" ? "hidden" : "auto",
850
- outline: 0,
851
- ...__css ? __css : styles.container
852
- };
853
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
854
- import_motion3.motion.section,
855
- {
856
- role: "dialog",
857
- "aria-modal": "true",
858
- ref,
859
- className: (0, import_utils7.cx)("ui-modal", className),
860
- tabIndex: -1,
861
- __css: css,
862
- ...props,
863
- ...rest,
864
- children: [
865
- customModalCloseButton != null ? customModalCloseButton : withCloseButton && onClose ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ModalCloseButton, {}) : null,
866
- cloneChildren
867
- ]
868
- }
869
- );
870
- }
871
- );
872
45
 
873
46
  // src/modal-overlay.tsx
874
- var import_jsx_runtime8 = require("react/jsx-runtime");
875
- var ModalOverlay = (0, import_motion4.motionForwardRef)(
47
+ var import_jsx_runtime = require("react/jsx-runtime");
48
+ var ModalOverlay = (0, import_motion.motionForwardRef)(
876
49
  ({ className, __css, onClick, ...rest }, ref) => {
877
50
  const {
878
51
  styles,
@@ -890,15 +63,15 @@ var ModalOverlay = (0, import_motion4.motionForwardRef)(
890
63
  h: "100vh",
891
64
  ...__css ? __css : styles.overlay
892
65
  };
893
- const props = animation !== "none" ? import_transitions3.fadeProps : {};
894
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
895
- import_motion4.motion.div,
66
+ const props = animation !== "none" ? import_transitions.fadeProps : {};
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
+ import_motion.motion.div,
896
69
  {
897
70
  ref,
898
- className: (0, import_utils8.cx)("ui-modal__overlay", className),
71
+ className: (0, import_utils2.cx)("ui-modal__overlay", className),
899
72
  custom: { duration },
900
73
  __css: css,
901
- onClick: (0, import_utils8.handlerAll)(onClick, onOverlayClick, (ev) => {
74
+ onClick: (0, import_utils2.handlerAll)(onClick, onOverlayClick, (ev) => {
902
75
  ev.stopPropagation();
903
76
  if (closeOnOverlay) onClose == null ? void 0 : onClose();
904
77
  }),