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