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