premium-ds 0.1.0

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 (257) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/dist/alert.d.ts +31 -0
  4. package/dist/alert.js +6 -0
  5. package/dist/alert.js.map +1 -0
  6. package/dist/avatar-group.d.ts +13 -0
  7. package/dist/avatar-group.js +3 -0
  8. package/dist/avatar-group.js.map +1 -0
  9. package/dist/avatar.d.ts +25 -0
  10. package/dist/avatar.js +3 -0
  11. package/dist/avatar.js.map +1 -0
  12. package/dist/badge.d.ts +23 -0
  13. package/dist/badge.js +3 -0
  14. package/dist/badge.js.map +1 -0
  15. package/dist/button.d.ts +20 -0
  16. package/dist/button.js +3 -0
  17. package/dist/button.js.map +1 -0
  18. package/dist/checkbox.d.ts +25 -0
  19. package/dist/checkbox.js +3 -0
  20. package/dist/checkbox.js.map +1 -0
  21. package/dist/chunk-2OWHZ4JT.js +36 -0
  22. package/dist/chunk-2OWHZ4JT.js.map +1 -0
  23. package/dist/chunk-34SIXSYL.js +64 -0
  24. package/dist/chunk-34SIXSYL.js.map +1 -0
  25. package/dist/chunk-37O2ZXD6.js +55 -0
  26. package/dist/chunk-37O2ZXD6.js.map +1 -0
  27. package/dist/chunk-4AZL76UJ.js +89 -0
  28. package/dist/chunk-4AZL76UJ.js.map +1 -0
  29. package/dist/chunk-4HSCN5TZ.js +86 -0
  30. package/dist/chunk-4HSCN5TZ.js.map +1 -0
  31. package/dist/chunk-5DDOOT33.js +258 -0
  32. package/dist/chunk-5DDOOT33.js.map +1 -0
  33. package/dist/chunk-5FVHWIMY.js +117 -0
  34. package/dist/chunk-5FVHWIMY.js.map +1 -0
  35. package/dist/chunk-5K6KRJGX.js +147 -0
  36. package/dist/chunk-5K6KRJGX.js.map +1 -0
  37. package/dist/chunk-5PQMQBQC.js +74 -0
  38. package/dist/chunk-5PQMQBQC.js.map +1 -0
  39. package/dist/chunk-7OCTVQ7C.js +95 -0
  40. package/dist/chunk-7OCTVQ7C.js.map +1 -0
  41. package/dist/chunk-7OPMOET7.js +39 -0
  42. package/dist/chunk-7OPMOET7.js.map +1 -0
  43. package/dist/chunk-BXXS7YRC.js +270 -0
  44. package/dist/chunk-BXXS7YRC.js.map +1 -0
  45. package/dist/chunk-CV2Q4YXX.js +272 -0
  46. package/dist/chunk-CV2Q4YXX.js.map +1 -0
  47. package/dist/chunk-EIMMDWIW.js +282 -0
  48. package/dist/chunk-EIMMDWIW.js.map +1 -0
  49. package/dist/chunk-EZ2CWTBE.js +230 -0
  50. package/dist/chunk-EZ2CWTBE.js.map +1 -0
  51. package/dist/chunk-FGHDG3Y4.js +89 -0
  52. package/dist/chunk-FGHDG3Y4.js.map +1 -0
  53. package/dist/chunk-FPP2XLKX.js +127 -0
  54. package/dist/chunk-FPP2XLKX.js.map +1 -0
  55. package/dist/chunk-G6OY35DI.js +295 -0
  56. package/dist/chunk-G6OY35DI.js.map +1 -0
  57. package/dist/chunk-H6KWJNOE.js +65 -0
  58. package/dist/chunk-H6KWJNOE.js.map +1 -0
  59. package/dist/chunk-HGILYGY3.js +45 -0
  60. package/dist/chunk-HGILYGY3.js.map +1 -0
  61. package/dist/chunk-I3BCB4Z5.js +88 -0
  62. package/dist/chunk-I3BCB4Z5.js.map +1 -0
  63. package/dist/chunk-KBWNUUWM.js +582 -0
  64. package/dist/chunk-KBWNUUWM.js.map +1 -0
  65. package/dist/chunk-KN7JFAZ6.js +113 -0
  66. package/dist/chunk-KN7JFAZ6.js.map +1 -0
  67. package/dist/chunk-MEF7PI6U.js +16 -0
  68. package/dist/chunk-MEF7PI6U.js.map +1 -0
  69. package/dist/chunk-NKGMQL6I.js +310 -0
  70. package/dist/chunk-NKGMQL6I.js.map +1 -0
  71. package/dist/chunk-NMFQRGLL.js +127 -0
  72. package/dist/chunk-NMFQRGLL.js.map +1 -0
  73. package/dist/chunk-OUBWD6CX.js +433 -0
  74. package/dist/chunk-OUBWD6CX.js.map +1 -0
  75. package/dist/chunk-PFNXVBLU.js +96 -0
  76. package/dist/chunk-PFNXVBLU.js.map +1 -0
  77. package/dist/chunk-PUPZ4HME.js +165 -0
  78. package/dist/chunk-PUPZ4HME.js.map +1 -0
  79. package/dist/chunk-QFS52OK5.js +690 -0
  80. package/dist/chunk-QFS52OK5.js.map +1 -0
  81. package/dist/chunk-QNC6O3PG.js +45 -0
  82. package/dist/chunk-QNC6O3PG.js.map +1 -0
  83. package/dist/chunk-QUHOXWBK.js +82 -0
  84. package/dist/chunk-QUHOXWBK.js.map +1 -0
  85. package/dist/chunk-UIQGSTBJ.js +106 -0
  86. package/dist/chunk-UIQGSTBJ.js.map +1 -0
  87. package/dist/chunk-UJQKVP6V.js +193 -0
  88. package/dist/chunk-UJQKVP6V.js.map +1 -0
  89. package/dist/chunk-VVPGEAC6.js +11 -0
  90. package/dist/chunk-VVPGEAC6.js.map +1 -0
  91. package/dist/chunk-XA3T5KWA.js +58 -0
  92. package/dist/chunk-XA3T5KWA.js.map +1 -0
  93. package/dist/chunk-YSHJHSJM.js +19 -0
  94. package/dist/chunk-YSHJHSJM.js.map +1 -0
  95. package/dist/chunk-YVHOAVSM.js +182 -0
  96. package/dist/chunk-YVHOAVSM.js.map +1 -0
  97. package/dist/collapse.d.ts +16 -0
  98. package/dist/collapse.js +3 -0
  99. package/dist/collapse.js.map +1 -0
  100. package/dist/count-badge.d.ts +11 -0
  101. package/dist/count-badge.js +4 -0
  102. package/dist/count-badge.js.map +1 -0
  103. package/dist/date-field.d.ts +39 -0
  104. package/dist/date-field.js +8 -0
  105. package/dist/date-field.js.map +1 -0
  106. package/dist/date-range-field.d.ts +30 -0
  107. package/dist/date-range-field.js +8 -0
  108. package/dist/date-range-field.js.map +1 -0
  109. package/dist/datetime-field.d.ts +28 -0
  110. package/dist/datetime-field.js +10 -0
  111. package/dist/datetime-field.js.map +1 -0
  112. package/dist/dialog.d.ts +26 -0
  113. package/dist/dialog.js +7 -0
  114. package/dist/dialog.js.map +1 -0
  115. package/dist/index.d.ts +35 -0
  116. package/dist/index.js +40 -0
  117. package/dist/index.js.map +1 -0
  118. package/dist/motion-tokens.d.ts +29 -0
  119. package/dist/motion-tokens.js +3 -0
  120. package/dist/motion-tokens.js.map +1 -0
  121. package/dist/multi-select.d.ts +25 -0
  122. package/dist/multi-select.js +7 -0
  123. package/dist/multi-select.js.map +1 -0
  124. package/dist/number-field.d.ts +24 -0
  125. package/dist/number-field.js +4 -0
  126. package/dist/number-field.js.map +1 -0
  127. package/dist/otp-field.d.ts +20 -0
  128. package/dist/otp-field.js +3 -0
  129. package/dist/otp-field.js.map +1 -0
  130. package/dist/overlay.d.ts +31 -0
  131. package/dist/overlay.js +4 -0
  132. package/dist/overlay.js.map +1 -0
  133. package/dist/pagination.d.ts +24 -0
  134. package/dist/pagination.js +5 -0
  135. package/dist/pagination.js.map +1 -0
  136. package/dist/radio-group.d.ts +46 -0
  137. package/dist/radio-group.js +6 -0
  138. package/dist/radio-group.js.map +1 -0
  139. package/dist/select-core-SAyS-8w0.d.ts +16 -0
  140. package/dist/select.d.ts +27 -0
  141. package/dist/select.js +7 -0
  142. package/dist/select.js.map +1 -0
  143. package/dist/status-badge.d.ts +17 -0
  144. package/dist/status-badge.js +5 -0
  145. package/dist/status-badge.js.map +1 -0
  146. package/dist/table.d.ts +65 -0
  147. package/dist/table.js +5 -0
  148. package/dist/table.js.map +1 -0
  149. package/dist/tabs.d.ts +44 -0
  150. package/dist/tabs.js +5 -0
  151. package/dist/tabs.js.map +1 -0
  152. package/dist/tag.d.ts +28 -0
  153. package/dist/tag.js +5 -0
  154. package/dist/tag.js.map +1 -0
  155. package/dist/text-field.d.ts +30 -0
  156. package/dist/text-field.js +6 -0
  157. package/dist/text-field.js.map +1 -0
  158. package/dist/textarea.d.ts +33 -0
  159. package/dist/textarea.js +5 -0
  160. package/dist/textarea.js.map +1 -0
  161. package/dist/time-field.d.ts +27 -0
  162. package/dist/time-field.js +6 -0
  163. package/dist/time-field.js.map +1 -0
  164. package/dist/toast-store.d.ts +75 -0
  165. package/dist/toast-store.js +3 -0
  166. package/dist/toast-store.js.map +1 -0
  167. package/dist/toast.d.ts +3 -0
  168. package/dist/toast.js +6 -0
  169. package/dist/toast.js.map +1 -0
  170. package/dist/toggle-tag.d.ts +24 -0
  171. package/dist/toggle-tag.js +4 -0
  172. package/dist/toggle-tag.js.map +1 -0
  173. package/dist/toggle.d.ts +21 -0
  174. package/dist/toggle.js +3 -0
  175. package/dist/toggle.js.map +1 -0
  176. package/dist/tooltip.d.ts +27 -0
  177. package/dist/tooltip.js +4 -0
  178. package/dist/tooltip.js.map +1 -0
  179. package/llms.txt +165 -0
  180. package/package.json +205 -0
  181. package/src/components/alert/Alert.tsx +118 -0
  182. package/src/components/alert/alert.css +136 -0
  183. package/src/components/avatar/Avatar.tsx +128 -0
  184. package/src/components/avatar/AvatarGroup.tsx +50 -0
  185. package/src/components/avatar/avatar.css +200 -0
  186. package/src/components/badge/Badge.tsx +66 -0
  187. package/src/components/badge/CountBadge.tsx +46 -0
  188. package/src/components/badge/StatusBadge.tsx +132 -0
  189. package/src/components/badge/badge.css +243 -0
  190. package/src/components/button/Button.tsx +68 -0
  191. package/src/components/button/button.css +222 -0
  192. package/src/components/checkbox/Checkbox.tsx +90 -0
  193. package/src/components/checkbox/checkbox.css +179 -0
  194. package/src/components/date-picker/DateField.tsx +362 -0
  195. package/src/components/date-picker/DateRangeField.tsx +533 -0
  196. package/src/components/date-picker/DateTimeField.tsx +177 -0
  197. package/src/components/date-picker/TimeField.tsx +100 -0
  198. package/src/components/date-picker/date-picker.css +591 -0
  199. package/src/components/date-picker/date-utils.ts +55 -0
  200. package/src/components/date-picker/field-shell.tsx +78 -0
  201. package/src/components/date-picker/glide-pill.tsx +81 -0
  202. package/src/components/date-picker/time-core.tsx +305 -0
  203. package/src/components/dialog/Dialog.tsx +181 -0
  204. package/src/components/dialog/dialog.css +170 -0
  205. package/src/components/glass/glass.css +100 -0
  206. package/src/components/icon/Icon.tsx +76 -0
  207. package/src/components/icon/IconSlot.tsx +11 -0
  208. package/src/components/icon/icon.css +33 -0
  209. package/src/components/input/NumberField.tsx +117 -0
  210. package/src/components/input/OtpField.tsx +118 -0
  211. package/src/components/input/TextField.tsx +123 -0
  212. package/src/components/input/input.css +335 -0
  213. package/src/components/motion/Collapse.tsx +33 -0
  214. package/src/components/motion/collapse.css +41 -0
  215. package/src/components/overlay/Overlay.tsx +239 -0
  216. package/src/components/overlay/overlay-core.tsx +565 -0
  217. package/src/components/overlay/overlay.css +119 -0
  218. package/src/components/overlay/sheet-drag.tsx +146 -0
  219. package/src/components/pagination/Pagination.tsx +140 -0
  220. package/src/components/pagination/pagination.css +48 -0
  221. package/src/components/radio-group/RadioGroup.tsx +182 -0
  222. package/src/components/radio-group/radio-group.css +277 -0
  223. package/src/components/select/MultiSelect.tsx +251 -0
  224. package/src/components/select/Select.tsx +235 -0
  225. package/src/components/select/select-core.tsx +417 -0
  226. package/src/components/select/select.css +386 -0
  227. package/src/components/table/Table.tsx +433 -0
  228. package/src/components/table/table.css +348 -0
  229. package/src/components/tabs/Tabs.tsx +371 -0
  230. package/src/components/tabs/tabs.css +228 -0
  231. package/src/components/tag/Tag.tsx +145 -0
  232. package/src/components/tag/ToggleTag.tsx +125 -0
  233. package/src/components/tag/tag.css +248 -0
  234. package/src/components/textarea/Textarea.tsx +197 -0
  235. package/src/components/textarea/textarea.css +219 -0
  236. package/src/components/toast/Toast.tsx +349 -0
  237. package/src/components/toast/toast-store.ts +266 -0
  238. package/src/components/toast/toast.css +233 -0
  239. package/src/components/toggle/Toggle.tsx +94 -0
  240. package/src/components/toggle/toggle.css +152 -0
  241. package/src/components/tooltip/Tooltip.tsx +365 -0
  242. package/src/components/tooltip/tooltip.css +86 -0
  243. package/src/index.ts +42 -0
  244. package/src/styles.css +39 -0
  245. package/src/tokens/avatar.css +20 -0
  246. package/src/tokens/color.css +56 -0
  247. package/src/tokens/elevation.css +20 -0
  248. package/src/tokens/fonts.css +3 -0
  249. package/src/tokens/glass.css +21 -0
  250. package/src/tokens/icons.css +7 -0
  251. package/src/tokens/layers.css +6 -0
  252. package/src/tokens/motion-tokens.ts +72 -0
  253. package/src/tokens/motion.css +49 -0
  254. package/src/tokens/radius.css +11 -0
  255. package/src/tokens/semantic.css +75 -0
  256. package/src/tokens/spacing.css +26 -0
  257. package/src/tokens/typography.css +54 -0
@@ -0,0 +1,690 @@
1
+ 'use client';import { UIMotion } from './chunk-37O2ZXD6.js';
2
+ import * as React from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { AnimatePresence, motion, useMotionValue, useDragControls, useTransform, animate } from 'motion/react';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ var ovSM = UIMotion;
8
+ var {
9
+ useState: ovUseState,
10
+ useEffect: ovUseEffect,
11
+ useLayoutEffect: ovUseLayoutEffect,
12
+ useRef: ovUseRef
13
+ } = React;
14
+ function useControllable(controlled, initial, onChange) {
15
+ const [internal, setInternal] = ovUseState(initial);
16
+ const isControlled = controlled !== void 0;
17
+ const value = isControlled ? controlled : internal;
18
+ const setValue = (next) => {
19
+ if (!isControlled) setInternal(next);
20
+ if (onChange) onChange(next);
21
+ };
22
+ return [value, setValue];
23
+ }
24
+ function ovReadPx(token) {
25
+ const root = document.documentElement;
26
+ const v = getComputedStyle(root).getPropertyValue(token).trim();
27
+ const n = parseFloat(v);
28
+ if (Number.isNaN(n)) return 0;
29
+ return v.endsWith("rem") ? n * parseFloat(getComputedStyle(root).fontSize) : n;
30
+ }
31
+ function ovResolveChildren(children, close) {
32
+ return typeof children === "function" ? children({ close }) : children;
33
+ }
34
+ function ovCloneTrigger(trigger, {
35
+ open,
36
+ onPress,
37
+ panelId,
38
+ haspopup,
39
+ triggerRef
40
+ }) {
41
+ if (!trigger) return null;
42
+ const setRef = (node) => {
43
+ if (triggerRef) triggerRef.current = node;
44
+ const r = trigger.ref;
45
+ if (typeof r === "function") r(node);
46
+ else if (r) r.current = node;
47
+ };
48
+ return React.cloneElement(trigger, {
49
+ ref: setRef,
50
+ onClick: (e) => {
51
+ const oc = trigger.props.onClick;
52
+ if (oc) oc(e);
53
+ onPress();
54
+ },
55
+ "aria-haspopup": haspopup,
56
+ "aria-expanded": open,
57
+ "aria-controls": open ? panelId : void 0
58
+ });
59
+ }
60
+ var ovStack = [];
61
+ function ovOnDocKeyDown(e) {
62
+ if (e.key !== "Escape" || e.defaultPrevented || ovStack.length === 0) return;
63
+ const top = ovStack[ovStack.length - 1];
64
+ if (!top.isDismissible()) return;
65
+ e.preventDefault();
66
+ top.requestClose();
67
+ }
68
+ function ovIsTop(entry) {
69
+ return ovStack[ovStack.length - 1] === entry;
70
+ }
71
+ function ovInOverlayAbove(entry, target) {
72
+ const i = ovStack.indexOf(entry);
73
+ return i >= 0 && ovStack.slice(i + 1).some((e) => e.contains(target));
74
+ }
75
+ function useOverlayEntry({
76
+ nodeRef,
77
+ dismissible,
78
+ requestClose
79
+ }) {
80
+ const ref = ovUseRef(null);
81
+ if (!ref.current) {
82
+ ref.current = {
83
+ contains: (t) => Boolean(nodeRef.current && nodeRef.current.contains(t)),
84
+ isDismissible: () => ref.current._dismissible,
85
+ requestClose: () => ref.current._close()
86
+ };
87
+ }
88
+ ref.current._dismissible = dismissible;
89
+ ref.current._close = requestClose;
90
+ ovUseLayoutEffect(() => {
91
+ const entry = ref.current;
92
+ if (ovStack.length === 0) document.addEventListener("keydown", ovOnDocKeyDown);
93
+ ovStack.push(entry);
94
+ if (nodeRef.current)
95
+ nodeRef.current.style.zIndex = "calc(var(--layer-overlay) + " + (ovStack.length - 1) + ")";
96
+ return () => {
97
+ const i = ovStack.indexOf(entry);
98
+ if (i >= 0) ovStack.splice(i, 1);
99
+ if (ovStack.length === 0) document.removeEventListener("keydown", ovOnDocKeyDown);
100
+ };
101
+ }, []);
102
+ return ref.current;
103
+ }
104
+ function useOutsidePress({
105
+ entry,
106
+ refs,
107
+ enabled,
108
+ onPress
109
+ }) {
110
+ const latest = ovUseRef(null);
111
+ latest.current = { enabled, onPress };
112
+ ovUseEffect(() => {
113
+ const onDown = (e) => {
114
+ if (!latest.current.enabled) return;
115
+ const t = e.target;
116
+ if (refs.some((r) => r.current && r.current.contains(t))) return;
117
+ if (ovInOverlayAbove(entry, t)) return;
118
+ latest.current.onPress();
119
+ };
120
+ document.addEventListener("pointerdown", onDown, true);
121
+ return () => document.removeEventListener("pointerdown", onDown, true);
122
+ }, []);
123
+ }
124
+ function useReturnFocus(nodeRef) {
125
+ ovUseEffect(() => {
126
+ const prev = document.activeElement;
127
+ return () => {
128
+ const a = document.activeElement;
129
+ const orphaned = !a || a === document.body || nodeRef.current && nodeRef.current.contains(a);
130
+ if (orphaned && prev && prev.isConnected && typeof prev.focus === "function") {
131
+ queueMicrotask(() => {
132
+ if (prev.isConnected) prev.focus({ preventScroll: true });
133
+ });
134
+ }
135
+ };
136
+ }, []);
137
+ }
138
+ var OV_FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
139
+ function useFocusTrap({
140
+ panelRef,
141
+ entry
142
+ }) {
143
+ ovUseEffect(() => {
144
+ const panel = panelRef.current;
145
+ if (!panel) return void 0;
146
+ const focusables = () => Array.from(panel.querySelectorAll(OV_FOCUSABLE)).filter(
147
+ (el) => el.offsetParent !== null || el === document.activeElement
148
+ );
149
+ const seed = panel.querySelector("[autofocus], [data-autofocus]") || focusables()[0] || panel;
150
+ seed.focus({ preventScroll: true });
151
+ const onKeyDown = (e) => {
152
+ if (e.key !== "Tab") return;
153
+ const f = focusables();
154
+ if (f.length === 0) {
155
+ e.preventDefault();
156
+ return;
157
+ }
158
+ const cur = document.activeElement;
159
+ if (e.shiftKey) {
160
+ if (cur === f[0] || cur === panel) {
161
+ e.preventDefault();
162
+ f[f.length - 1].focus();
163
+ }
164
+ } else if (cur === f[f.length - 1]) {
165
+ e.preventDefault();
166
+ f[0].focus();
167
+ }
168
+ };
169
+ const onFocusIn = (e) => {
170
+ if (panel.contains(e.target)) return;
171
+ if (!ovIsTop(entry) || ovInOverlayAbove(entry, e.target)) return;
172
+ (focusables()[0] || panel).focus({ preventScroll: true });
173
+ };
174
+ panel.addEventListener("keydown", onKeyDown);
175
+ document.addEventListener("focusin", onFocusIn);
176
+ return () => {
177
+ panel.removeEventListener("keydown", onKeyDown);
178
+ document.removeEventListener("focusin", onFocusIn);
179
+ };
180
+ }, []);
181
+ }
182
+ var ovLocks = 0;
183
+ var ovSavedOverflow = "";
184
+ var ovSavedPad = "";
185
+ function useScrollLock() {
186
+ ovUseEffect(() => {
187
+ if (++ovLocks === 1) {
188
+ const body = document.body;
189
+ const gutter = window.innerWidth - document.documentElement.clientWidth;
190
+ ovSavedOverflow = body.style.overflow;
191
+ ovSavedPad = body.style.paddingRight;
192
+ body.style.overflow = "hidden";
193
+ if (gutter > 0)
194
+ body.style.paddingRight = (parseFloat(getComputedStyle(body).paddingRight) || 0) + gutter + "px";
195
+ }
196
+ return () => {
197
+ if (--ovLocks === 0) {
198
+ document.body.style.overflow = ovSavedOverflow;
199
+ document.body.style.paddingRight = ovSavedPad;
200
+ }
201
+ };
202
+ }, []);
203
+ }
204
+ var ovInertCount = 0;
205
+ var ovInerted = /* @__PURE__ */ new Set();
206
+ function useInertOutside() {
207
+ ovUseEffect(() => {
208
+ if (++ovInertCount === 1) {
209
+ for (const el of Array.from(document.body.children)) {
210
+ if (el.hasAttribute("data-overlay-root") || el.tagName === "SCRIPT" || el.tagName === "STYLE" || el.inert)
211
+ continue;
212
+ el.inert = true;
213
+ ovInerted.add(el);
214
+ }
215
+ }
216
+ return () => {
217
+ if (--ovInertCount === 0) {
218
+ ovInerted.forEach((el) => {
219
+ el.inert = false;
220
+ });
221
+ ovInerted.clear();
222
+ }
223
+ };
224
+ }, []);
225
+ }
226
+ function useAnchorPosition({
227
+ side,
228
+ align,
229
+ arrow,
230
+ triggerRef,
231
+ panelRef
232
+ }) {
233
+ ovUseLayoutEffect(() => {
234
+ const place = () => {
235
+ const t = triggerRef.current;
236
+ const p = panelRef.current;
237
+ if (!t || !p) return;
238
+ const r = t.getBoundingClientRect();
239
+ const pw = p.offsetWidth, ph = p.offsetHeight;
240
+ const edge = ovReadPx("--space-2");
241
+ const gap = edge + (arrow ? 3 : 0);
242
+ const vw = window.innerWidth, vh = window.innerHeight;
243
+ const room = {
244
+ top: r.top,
245
+ bottom: vh - r.bottom,
246
+ left: r.left,
247
+ right: vw - r.right
248
+ };
249
+ const opposite = {
250
+ top: "bottom",
251
+ bottom: "top",
252
+ left: "right",
253
+ right: "left"
254
+ };
255
+ const vertical = side === "top" || side === "bottom";
256
+ let s = side;
257
+ if (room[s] < (vertical ? ph : pw) + gap && room[opposite[s]] > room[s]) s = opposite[s];
258
+ let x, y;
259
+ if (vertical) {
260
+ y = s === "top" ? r.top - ph - gap : r.bottom + gap;
261
+ x = align === "start" ? r.left : align === "end" ? r.right - pw : r.left + (r.width - pw) / 2;
262
+ x = Math.min(Math.max(x, edge), vw - pw - edge);
263
+ y = Math.max(
264
+ Math.min(y, vh - ph - edge),
265
+ edge
266
+ );
267
+ } else {
268
+ x = s === "left" ? r.left - pw - gap : r.right + gap;
269
+ y = align === "start" ? r.top : align === "end" ? r.bottom - ph : r.top + (r.height - ph) / 2;
270
+ y = Math.min(Math.max(y, edge), vh - ph - edge);
271
+ x = Math.max(Math.min(x, vw - pw - edge), edge);
272
+ }
273
+ p.style.left = Math.round(x) + "px";
274
+ p.style.top = Math.round(y) + "px";
275
+ p.setAttribute("data-side", s);
276
+ p.setAttribute("data-align", align);
277
+ if (arrow) {
278
+ if (vertical)
279
+ p.style.setProperty(
280
+ "--overlay-arrow-x",
281
+ Math.round(Math.min(Math.max(r.left + r.width / 2 - x, 12), pw - 12)) + "px"
282
+ );
283
+ else
284
+ p.style.setProperty(
285
+ "--overlay-arrow-y",
286
+ Math.round(Math.min(Math.max(r.top + r.height / 2 - y, 12), ph - 12)) + "px"
287
+ );
288
+ }
289
+ };
290
+ place();
291
+ window.addEventListener("scroll", place, true);
292
+ window.addEventListener("resize", place);
293
+ const ro = new ResizeObserver(place);
294
+ ro.observe(panelRef.current);
295
+ return () => {
296
+ window.removeEventListener("scroll", place, true);
297
+ window.removeEventListener("resize", place);
298
+ ro.disconnect();
299
+ };
300
+ }, [side, align, arrow]);
301
+ }
302
+ function OverlayPortal({ children }) {
303
+ const hostRef = ovUseRef(null);
304
+ if (typeof document !== "undefined" && !hostRef.current) {
305
+ hostRef.current = document.createElement("div");
306
+ hostRef.current.setAttribute("data-overlay-root", "");
307
+ }
308
+ ovUseLayoutEffect(() => {
309
+ const el = hostRef.current;
310
+ if (!el) return;
311
+ document.body.appendChild(el);
312
+ return () => el.remove();
313
+ }, []);
314
+ if (!hostRef.current) return null;
315
+ return createPortal(children, hostRef.current);
316
+ }
317
+ var ovScrimVariants = {
318
+ closed: { opacity: 0, transition: { duration: ovSM.dur.base, ease: ovSM.ease.standard } },
319
+ open: { opacity: 1, transition: { duration: ovSM.dur.slow, ease: ovSM.ease.entrance } }
320
+ };
321
+ function OverlayScrim({
322
+ dismissible,
323
+ onPress,
324
+ opacity = null
325
+ }) {
326
+ const down = ovUseRef(false);
327
+ return /* @__PURE__ */ jsx(
328
+ motion.div,
329
+ {
330
+ className: "overlay-scrim",
331
+ "aria-hidden": "true",
332
+ ...opacity ? { style: { opacity } } : { variants: ovScrimVariants },
333
+ onPointerDown: (e) => {
334
+ down.current = e.target === e.currentTarget;
335
+ },
336
+ onClick: (e) => {
337
+ if (dismissible && down.current && e.target === e.currentTarget) onPress();
338
+ }
339
+ }
340
+ );
341
+ }
342
+ function ovPanelElement({
343
+ asChild,
344
+ children,
345
+ prepend = null,
346
+ nodeRef,
347
+ className,
348
+ motionProps
349
+ }) {
350
+ if (asChild) {
351
+ const child = React.Children.only(children);
352
+ if (typeof child.type === "string") {
353
+ const Tag = motion[child.type];
354
+ const composedRef = (node) => {
355
+ nodeRef.current = node;
356
+ const r = child.ref;
357
+ if (typeof r === "function") r(node);
358
+ else if (r) r.current = node;
359
+ };
360
+ return /* @__PURE__ */ jsxs(
361
+ Tag,
362
+ {
363
+ ...child.props,
364
+ ...motionProps,
365
+ ref: composedRef,
366
+ className: child.props.className ? className + " " + child.props.className : className,
367
+ style: { ...motionProps.style, ...child.props.style },
368
+ children: [
369
+ prepend,
370
+ child.props.children
371
+ ]
372
+ }
373
+ );
374
+ }
375
+ console.warn("[Overlay] asChild requires a DOM-element child - falling back to a wrapper");
376
+ }
377
+ return /* @__PURE__ */ jsxs(
378
+ motion.div,
379
+ {
380
+ ...motionProps,
381
+ ref: nodeRef,
382
+ className,
383
+ children: [
384
+ prepend,
385
+ children
386
+ ]
387
+ }
388
+ );
389
+ }
390
+ function ModalShell({
391
+ layerClass,
392
+ slotClass,
393
+ slotVariants,
394
+ panelId,
395
+ dismissible,
396
+ requestClose,
397
+ asChild = false,
398
+ slotRef: externalSlotRef = null,
399
+ slotProps = {},
400
+ scrimOpacity = null,
401
+ children
402
+ }) {
403
+ const layerRef = ovUseRef(null);
404
+ const internalSlotRef = ovUseRef(null);
405
+ const slotRef = externalSlotRef || internalSlotRef;
406
+ const entry = useOverlayEntry({ nodeRef: layerRef, dismissible, requestClose });
407
+ useScrollLock();
408
+ useInertOutside();
409
+ useReturnFocus(layerRef);
410
+ useFocusTrap({ panelRef: slotRef, entry });
411
+ return /* @__PURE__ */ jsxs(
412
+ motion.div,
413
+ {
414
+ ref: layerRef,
415
+ className: "overlay-layer " + layerClass,
416
+ initial: "closed",
417
+ animate: "open",
418
+ exit: "closed",
419
+ children: [
420
+ /* @__PURE__ */ jsx(OverlayScrim, { dismissible, onPress: requestClose, opacity: scrimOpacity }),
421
+ ovPanelElement({
422
+ asChild,
423
+ children,
424
+ nodeRef: slotRef,
425
+ className: "overlay-slot " + slotClass,
426
+ motionProps: { id: panelId, tabIndex: -1, variants: slotVariants, ...slotProps }
427
+ })
428
+ ]
429
+ }
430
+ );
431
+ }
432
+ var sdSM = UIMotion;
433
+ var { useEffect: sdUseEffect, useRef: sdUseRef } = React;
434
+ var DISMISS_RATIO = 0.4;
435
+ var DISMISS_VELOCITY = 500;
436
+ var INTENT_PX = 4;
437
+ var STRETCH_MAX = 0.06;
438
+ function findScrollable(node, stop) {
439
+ let el = node instanceof Element ? node : null;
440
+ while (el && el !== stop) {
441
+ const s = getComputedStyle(el);
442
+ if (/(auto|scroll)/.test(s.overflowY + s.overflowX) && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth))
443
+ return el;
444
+ el = el.parentElement;
445
+ }
446
+ return null;
447
+ }
448
+ function useSheetDrag({
449
+ side,
450
+ slotRef,
451
+ enabled,
452
+ requestClose
453
+ }) {
454
+ const axis = side === "bottom" ? "y" : "x";
455
+ const travel = useMotionValue("100%");
456
+ const stretch = useMotionValue(1);
457
+ const controls = useDragControls();
458
+ const savedUserSelect = sdUseRef(null);
459
+ function suspendSelection() {
460
+ const sel = window.getSelection();
461
+ if (sel) sel.removeAllRanges();
462
+ savedUserSelect.current = document.body.style.userSelect;
463
+ document.body.style.userSelect = "none";
464
+ }
465
+ function restoreSelection() {
466
+ if (savedUserSelect.current === null) return;
467
+ document.body.style.userSelect = savedUserSelect.current;
468
+ savedUserSelect.current = null;
469
+ }
470
+ sdUseEffect(() => restoreSelection, []);
471
+ const progress = useTransform(travel, (v) => {
472
+ if (typeof v === "string") return Math.min(Math.max(parseFloat(v) / 100 || 0, 0), 1);
473
+ const el = slotRef.current;
474
+ const size = el ? axis === "y" ? el.offsetHeight : el.offsetWidth : Infinity;
475
+ return Math.min(Math.max(v / size, 0), 1);
476
+ });
477
+ const scrimOpacity = useTransform(progress, (p) => 1 - p);
478
+ function onPointerDown(e) {
479
+ if (e.button !== 0) return;
480
+ const startX = e.clientX, startY = e.clientY;
481
+ const scrollable = findScrollable(e.target, slotRef.current);
482
+ const onMove = (ev) => {
483
+ const dx = ev.clientX - startX, dy = ev.clientY - startY;
484
+ if (Math.max(Math.abs(dx), Math.abs(dy)) < INTENT_PX) return;
485
+ cleanup();
486
+ const along = axis === "y" ? dy : dx;
487
+ const cross = axis === "y" ? dx : dy;
488
+ if (Math.abs(along) <= Math.abs(cross)) return;
489
+ if (scrollable) {
490
+ if (along < 0) return;
491
+ if (axis === "y" ? scrollable.scrollTop > 0 : scrollable.scrollLeft > 0) return;
492
+ }
493
+ suspendSelection();
494
+ window.addEventListener("pointerup", restoreSelection, { once: true });
495
+ window.addEventListener("pointercancel", restoreSelection, { once: true });
496
+ controls.start(ev);
497
+ };
498
+ const cleanup = () => {
499
+ window.removeEventListener("pointermove", onMove);
500
+ window.removeEventListener("pointerup", cleanup);
501
+ window.removeEventListener("pointercancel", cleanup);
502
+ };
503
+ window.addEventListener("pointermove", onMove);
504
+ window.addEventListener("pointerup", cleanup);
505
+ window.addEventListener("pointercancel", cleanup);
506
+ }
507
+ function onDrag(_ev, info) {
508
+ const el = slotRef.current;
509
+ if (!el) return;
510
+ const size = axis === "y" ? el.offsetHeight : el.offsetWidth;
511
+ const o = info.offset[axis];
512
+ stretch.set(o < 0 ? 1 + Math.min(-o / size, 1) * STRETCH_MAX : 1);
513
+ }
514
+ function onDragEnd(_ev, info) {
515
+ restoreSelection();
516
+ animate(stretch, 1, sdSM.t.settle);
517
+ const el = slotRef.current;
518
+ if (!el) return;
519
+ const size = axis === "y" ? el.offsetHeight : el.offsetWidth;
520
+ if (info.offset[axis] > size * DISMISS_RATIO || info.velocity[axis] > DISMISS_VELOCITY)
521
+ requestClose();
522
+ }
523
+ const stretchStyle = axis === "y" ? { scaleY: stretch, originY: 1 } : { scaleX: stretch, originX: 1 };
524
+ const slotProps = enabled ? {
525
+ drag: axis,
526
+ dragControls: controls,
527
+ dragListener: false,
528
+ dragMomentum: false,
529
+ dragConstraints: { top: 0, bottom: 0, left: 0, right: 0 },
530
+ /* away from the edge: hard clamp (stretch covers it); toward: free */
531
+ dragElastic: axis === "y" ? { top: 0, bottom: 1 } : { left: 0, right: 1 },
532
+ onPointerDown,
533
+ onDrag,
534
+ onDragEnd,
535
+ style: { [axis]: travel, ...stretchStyle }
536
+ } : { style: { [axis]: travel } };
537
+ return { slotProps, scrimOpacity };
538
+ }
539
+ var { useRef, useId } = React;
540
+ var popoverVariants = {
541
+ closed: { opacity: 0, scale: 0.96, transition: ovSM.t.exit },
542
+ open: { opacity: 1, scale: 1, transition: ovSM.t.enter }
543
+ };
544
+ var dialogVariants = {
545
+ closed: {
546
+ opacity: 0,
547
+ y: 6,
548
+ scale: 0.98,
549
+ transition: { duration: ovSM.dur.base, ease: ovSM.ease.standard }
550
+ },
551
+ open: {
552
+ opacity: 1,
553
+ y: 0,
554
+ scale: 1,
555
+ transition: { duration: ovSM.dur.slow, ease: ovSM.ease.entrance }
556
+ }
557
+ };
558
+ function sheetVariants(side) {
559
+ const axis = side === "bottom" ? "y" : "x";
560
+ return {
561
+ closed: { [axis]: "100%", transition: { duration: ovSM.dur.base, ease: ovSM.ease.exit } },
562
+ open: { [axis]: 0, transition: { duration: ovSM.dur.slow, ease: ovSM.ease.entrance } }
563
+ };
564
+ }
565
+ function PopoverPanel({
566
+ panelId,
567
+ side,
568
+ align,
569
+ arrow,
570
+ dismissible,
571
+ asChild,
572
+ requestClose,
573
+ triggerRef,
574
+ children
575
+ }) {
576
+ const panelRef = useRef(null);
577
+ const entry = useOverlayEntry({ nodeRef: panelRef, dismissible, requestClose });
578
+ useReturnFocus(panelRef);
579
+ useAnchorPosition({ side, align, arrow, triggerRef, panelRef });
580
+ useOutsidePress({
581
+ entry,
582
+ refs: [triggerRef, panelRef],
583
+ enabled: dismissible,
584
+ onPress: requestClose
585
+ });
586
+ return ovPanelElement({
587
+ asChild,
588
+ children,
589
+ prepend: arrow ? /* @__PURE__ */ jsx("span", { className: "overlay-popover__arrow", "aria-hidden": "true" }, "arrow") : null,
590
+ nodeRef: panelRef,
591
+ className: "overlay-popover",
592
+ motionProps: {
593
+ id: panelId,
594
+ variants: popoverVariants,
595
+ initial: "closed",
596
+ animate: "open",
597
+ exit: "closed"
598
+ }
599
+ });
600
+ }
601
+ function SheetShell({
602
+ side,
603
+ panelId,
604
+ dismissible,
605
+ asChild,
606
+ requestClose,
607
+ children
608
+ }) {
609
+ const slotRef = useRef(null);
610
+ const { slotProps, scrimOpacity } = useSheetDrag({
611
+ side,
612
+ slotRef,
613
+ enabled: dismissible,
614
+ requestClose
615
+ });
616
+ return /* @__PURE__ */ jsx(
617
+ ModalShell,
618
+ {
619
+ layerClass: "overlay-layer--sheet-" + side,
620
+ slotClass: "overlay-slot--sheet-" + side,
621
+ slotVariants: sheetVariants(side),
622
+ panelId,
623
+ dismissible,
624
+ requestClose,
625
+ asChild,
626
+ slotRef,
627
+ slotProps,
628
+ scrimOpacity,
629
+ children
630
+ }
631
+ );
632
+ }
633
+ function Overlay({
634
+ mode = "popover",
635
+ open: controlledOpen,
636
+ defaultOpen = false,
637
+ onOpenChange,
638
+ trigger = null,
639
+ side,
640
+ align = "start",
641
+ arrow = false,
642
+ dismissible = true,
643
+ asChild = false,
644
+ id,
645
+ children
646
+ }) {
647
+ const [open, setOpen] = useControllable(controlledOpen, defaultOpen, onOpenChange);
648
+ const triggerRef = useRef(null);
649
+ const panelId = id || "overlay-" + useId();
650
+ const close = () => setOpen(false);
651
+ const modal = mode !== "popover";
652
+ const s = side || (mode === "sheet" ? "right" : "bottom");
653
+ const content = ovResolveChildren(children, close);
654
+ const shared = { panelId, dismissible, asChild, requestClose: close };
655
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
656
+ ovCloneTrigger(trigger, {
657
+ open,
658
+ onPress: () => setOpen(modal ? true : !open),
659
+ panelId,
660
+ haspopup: modal ? "dialog" : "true",
661
+ triggerRef
662
+ }),
663
+ /* @__PURE__ */ jsx(OverlayPortal, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: open && (mode === "popover" ? /* @__PURE__ */ jsx(
664
+ PopoverPanel,
665
+ {
666
+ ...shared,
667
+ side: s,
668
+ align,
669
+ arrow,
670
+ triggerRef,
671
+ children: content
672
+ },
673
+ "panel"
674
+ ) : mode === "sheet" ? /* @__PURE__ */ jsx(SheetShell, { ...shared, side: s, children: content }, "shell") : /* @__PURE__ */ jsx(
675
+ ModalShell,
676
+ {
677
+ ...shared,
678
+ layerClass: "overlay-layer--dialog",
679
+ slotClass: "overlay-slot--dialog",
680
+ slotVariants: dialogVariants,
681
+ children: content
682
+ },
683
+ "shell"
684
+ )) }) })
685
+ ] });
686
+ }
687
+
688
+ export { Overlay };
689
+ //# sourceMappingURL=chunk-QFS52OK5.js.map
690
+ //# sourceMappingURL=chunk-QFS52OK5.js.map