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