@tribepad/themis 1.0.1 → 1.0.2

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 (301) hide show
  1. package/dist/elements/Accordion/index.js +1 -335
  2. package/dist/elements/Accordion/index.js.map +1 -1
  3. package/dist/elements/Accordion/index.mjs +1 -317
  4. package/dist/elements/Accordion/index.mjs.map +1 -1
  5. package/dist/elements/AlertDialog/AlertDialog.d.ts +43 -0
  6. package/dist/elements/AlertDialog/AlertDialog.d.ts.map +1 -0
  7. package/dist/elements/AlertDialog/AlertDialog.styles.d.ts +15 -0
  8. package/dist/elements/AlertDialog/AlertDialog.styles.d.ts.map +1 -0
  9. package/dist/elements/AlertDialog/AlertDialog.types.d.ts +72 -0
  10. package/dist/elements/AlertDialog/AlertDialog.types.d.ts.map +1 -0
  11. package/dist/elements/AlertDialog/index.d.ts +25 -0
  12. package/dist/elements/AlertDialog/index.d.ts.map +1 -0
  13. package/dist/elements/AlertDialog/index.js +3 -0
  14. package/dist/elements/AlertDialog/index.js.map +1 -0
  15. package/dist/elements/AlertDialog/index.mjs +3 -0
  16. package/dist/elements/AlertDialog/index.mjs.map +1 -0
  17. package/dist/elements/Avatar/index.js +1 -468
  18. package/dist/elements/Avatar/index.js.map +1 -1
  19. package/dist/elements/Avatar/index.mjs +1 -456
  20. package/dist/elements/Avatar/index.mjs.map +1 -1
  21. package/dist/elements/Badge/index.js +1 -243
  22. package/dist/elements/Badge/index.js.map +1 -1
  23. package/dist/elements/Badge/index.mjs +1 -234
  24. package/dist/elements/Badge/index.mjs.map +1 -1
  25. package/dist/elements/Breadcrumbs/index.js +1 -821
  26. package/dist/elements/Breadcrumbs/index.js.map +1 -1
  27. package/dist/elements/Breadcrumbs/index.mjs +1 -810
  28. package/dist/elements/Breadcrumbs/index.mjs.map +1 -1
  29. package/dist/elements/Button/Button.d.ts +26 -81
  30. package/dist/elements/Button/Button.d.ts.map +1 -1
  31. package/dist/elements/Button/Button.styles.d.ts +35 -0
  32. package/dist/elements/Button/Button.styles.d.ts.map +1 -0
  33. package/dist/elements/Button/Button.types.d.ts +20 -8
  34. package/dist/elements/Button/Button.types.d.ts.map +1 -1
  35. package/dist/elements/Button/index.js +1 -288
  36. package/dist/elements/Button/index.js.map +1 -1
  37. package/dist/elements/Button/index.mjs +1 -283
  38. package/dist/elements/Button/index.mjs.map +1 -1
  39. package/dist/elements/ButtonGroup/index.js +1 -237
  40. package/dist/elements/ButtonGroup/index.js.map +1 -1
  41. package/dist/elements/ButtonGroup/index.mjs +1 -222
  42. package/dist/elements/ButtonGroup/index.mjs.map +1 -1
  43. package/dist/elements/Card/index.js +1 -579
  44. package/dist/elements/Card/index.js.map +1 -1
  45. package/dist/elements/Card/index.mjs +1 -560
  46. package/dist/elements/Card/index.mjs.map +1 -1
  47. package/dist/elements/Carousel/Carousel.d.ts +1 -11
  48. package/dist/elements/Carousel/Carousel.d.ts.map +1 -1
  49. package/dist/elements/Carousel/LazyCarousel.d.ts +1 -1
  50. package/dist/elements/Carousel/LazyCarousel.d.ts.map +1 -1
  51. package/dist/elements/Carousel/index.js +1 -789
  52. package/dist/elements/Carousel/index.js.map +1 -1
  53. package/dist/elements/Carousel/index.mjs +1 -786
  54. package/dist/elements/Carousel/index.mjs.map +1 -1
  55. package/dist/elements/Chart/ChartContext.d.ts.map +1 -1
  56. package/dist/elements/Chart/index.js +1 -1842
  57. package/dist/elements/Chart/index.js.map +1 -1
  58. package/dist/elements/Chart/index.mjs +1 -1832
  59. package/dist/elements/Chart/index.mjs.map +1 -1
  60. package/dist/elements/Checkbox/index.js +1 -316
  61. package/dist/elements/Checkbox/index.js.map +1 -1
  62. package/dist/elements/Checkbox/index.mjs +1 -306
  63. package/dist/elements/Checkbox/index.mjs.map +1 -1
  64. package/dist/elements/CheckboxGroup/index.js +1 -455
  65. package/dist/elements/CheckboxGroup/index.js.map +1 -1
  66. package/dist/elements/CheckboxGroup/index.mjs +1 -439
  67. package/dist/elements/CheckboxGroup/index.mjs.map +1 -1
  68. package/dist/elements/Combobox/Combobox.d.ts +56 -0
  69. package/dist/elements/Combobox/Combobox.d.ts.map +1 -0
  70. package/dist/elements/Combobox/Combobox.styles.d.ts +29 -0
  71. package/dist/elements/Combobox/Combobox.styles.d.ts.map +1 -0
  72. package/dist/elements/Combobox/Combobox.types.d.ts +67 -0
  73. package/dist/elements/Combobox/Combobox.types.d.ts.map +1 -0
  74. package/dist/elements/Combobox/index.d.ts +20 -0
  75. package/dist/elements/Combobox/index.d.ts.map +1 -0
  76. package/dist/elements/Combobox/index.js +3 -0
  77. package/dist/elements/Combobox/index.js.map +1 -0
  78. package/dist/elements/Combobox/index.mjs +3 -0
  79. package/dist/elements/Combobox/index.mjs.map +1 -0
  80. package/dist/elements/DatePicker/DatePicker.d.ts +1 -1
  81. package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
  82. package/dist/elements/DatePicker/index.js +1 -903
  83. package/dist/elements/DatePicker/index.js.map +1 -1
  84. package/dist/elements/DatePicker/index.mjs +1 -853
  85. package/dist/elements/DatePicker/index.mjs.map +1 -1
  86. package/dist/elements/Dropdown/Dropdown.d.ts +7 -15
  87. package/dist/elements/Dropdown/Dropdown.d.ts.map +1 -1
  88. package/dist/elements/Dropdown/Dropdown.styles.d.ts +22 -0
  89. package/dist/elements/Dropdown/Dropdown.styles.d.ts.map +1 -0
  90. package/dist/elements/Dropdown/index.d.ts +1 -0
  91. package/dist/elements/Dropdown/index.d.ts.map +1 -1
  92. package/dist/elements/Dropdown/index.js +1 -193
  93. package/dist/elements/Dropdown/index.js.map +1 -1
  94. package/dist/elements/Dropdown/index.mjs +1 -184
  95. package/dist/elements/Dropdown/index.mjs.map +1 -1
  96. package/dist/elements/FileField/index.js +1 -1539
  97. package/dist/elements/FileField/index.js.map +1 -1
  98. package/dist/elements/FileField/index.mjs +1 -1507
  99. package/dist/elements/FileField/index.mjs.map +1 -1
  100. package/dist/elements/FormLayout/index.js +1 -170
  101. package/dist/elements/FormLayout/index.js.map +1 -1
  102. package/dist/elements/FormLayout/index.mjs +1 -167
  103. package/dist/elements/FormLayout/index.mjs.map +1 -1
  104. package/dist/elements/Modal/Modal.d.ts +9 -14
  105. package/dist/elements/Modal/Modal.d.ts.map +1 -1
  106. package/dist/elements/Modal/Modal.styles.d.ts +29 -0
  107. package/dist/elements/Modal/Modal.styles.d.ts.map +1 -0
  108. package/dist/elements/Modal/index.d.ts +1 -0
  109. package/dist/elements/Modal/index.d.ts.map +1 -1
  110. package/dist/elements/Modal/index.js +1 -232
  111. package/dist/elements/Modal/index.js.map +1 -1
  112. package/dist/elements/Modal/index.mjs +1 -220
  113. package/dist/elements/Modal/index.mjs.map +1 -1
  114. package/dist/elements/NumberField/index.js +1 -666
  115. package/dist/elements/NumberField/index.js.map +1 -1
  116. package/dist/elements/NumberField/index.mjs +1 -654
  117. package/dist/elements/NumberField/index.mjs.map +1 -1
  118. package/dist/elements/OTPInput/OTPInput.d.ts.map +1 -1
  119. package/dist/elements/OTPInput/index.js +1 -734
  120. package/dist/elements/OTPInput/index.js.map +1 -1
  121. package/dist/elements/OTPInput/index.mjs +1 -732
  122. package/dist/elements/OTPInput/index.mjs.map +1 -1
  123. package/dist/elements/Pagination/Pagination.d.ts +45 -0
  124. package/dist/elements/Pagination/Pagination.d.ts.map +1 -0
  125. package/dist/elements/Pagination/Pagination.styles.d.ts +10 -0
  126. package/dist/elements/Pagination/Pagination.styles.d.ts.map +1 -0
  127. package/dist/elements/Pagination/Pagination.types.d.ts +55 -0
  128. package/dist/elements/Pagination/Pagination.types.d.ts.map +1 -0
  129. package/dist/elements/Pagination/index.d.ts +21 -0
  130. package/dist/elements/Pagination/index.d.ts.map +1 -0
  131. package/dist/elements/Pagination/index.js +3 -0
  132. package/dist/elements/Pagination/index.js.map +1 -0
  133. package/dist/elements/Pagination/index.mjs +3 -0
  134. package/dist/elements/Pagination/index.mjs.map +1 -0
  135. package/dist/elements/Panel/index.js +1 -330
  136. package/dist/elements/Panel/index.js.map +1 -1
  137. package/dist/elements/Panel/index.mjs +1 -323
  138. package/dist/elements/Panel/index.mjs.map +1 -1
  139. package/dist/elements/PasswordField/PasswordField.d.ts +27 -0
  140. package/dist/elements/PasswordField/PasswordField.d.ts.map +1 -0
  141. package/dist/elements/PasswordField/PasswordField.styles.d.ts +32 -0
  142. package/dist/elements/PasswordField/PasswordField.styles.d.ts.map +1 -0
  143. package/dist/elements/PasswordField/PasswordField.types.d.ts +100 -0
  144. package/dist/elements/PasswordField/PasswordField.types.d.ts.map +1 -0
  145. package/dist/elements/PasswordField/index.css +2 -0
  146. package/dist/elements/PasswordField/index.css.map +1 -0
  147. package/dist/elements/PasswordField/index.d.ts +20 -0
  148. package/dist/elements/PasswordField/index.d.ts.map +1 -0
  149. package/dist/elements/PasswordField/index.js +3 -0
  150. package/dist/elements/PasswordField/index.js.map +1 -0
  151. package/dist/elements/PasswordField/index.mjs +3 -0
  152. package/dist/elements/PasswordField/index.mjs.map +1 -0
  153. package/dist/elements/Progress/index.js +1 -187
  154. package/dist/elements/Progress/index.js.map +1 -1
  155. package/dist/elements/Progress/index.mjs +1 -181
  156. package/dist/elements/Progress/index.mjs.map +1 -1
  157. package/dist/elements/RadioGroup/index.js +1 -369
  158. package/dist/elements/RadioGroup/index.js.map +1 -1
  159. package/dist/elements/RadioGroup/index.mjs +1 -359
  160. package/dist/elements/RadioGroup/index.mjs.map +1 -1
  161. package/dist/elements/Resizable/index.js +1 -1580
  162. package/dist/elements/Resizable/index.js.map +1 -1
  163. package/dist/elements/Resizable/index.mjs +1 -1566
  164. package/dist/elements/Resizable/index.mjs.map +1 -1
  165. package/dist/elements/SearchField/SearchField.d.ts +27 -0
  166. package/dist/elements/SearchField/SearchField.d.ts.map +1 -0
  167. package/dist/elements/SearchField/SearchField.styles.d.ts +32 -0
  168. package/dist/elements/SearchField/SearchField.styles.d.ts.map +1 -0
  169. package/dist/elements/SearchField/SearchField.types.d.ts +45 -0
  170. package/dist/elements/SearchField/SearchField.types.d.ts.map +1 -0
  171. package/dist/elements/SearchField/index.css +2 -0
  172. package/dist/elements/SearchField/index.css.map +1 -0
  173. package/dist/elements/SearchField/index.d.ts +21 -0
  174. package/dist/elements/SearchField/index.d.ts.map +1 -0
  175. package/dist/elements/SearchField/index.js +3 -0
  176. package/dist/elements/SearchField/index.js.map +1 -0
  177. package/dist/elements/SearchField/index.mjs +3 -0
  178. package/dist/elements/SearchField/index.mjs.map +1 -0
  179. package/dist/elements/Select/Select.d.ts +19 -48
  180. package/dist/elements/Select/Select.d.ts.map +1 -1
  181. package/dist/elements/Select/Select.styles.d.ts +55 -0
  182. package/dist/elements/Select/Select.styles.d.ts.map +1 -0
  183. package/dist/elements/Select/index.js +1 -589
  184. package/dist/elements/Select/index.js.map +1 -1
  185. package/dist/elements/Select/index.mjs +1 -582
  186. package/dist/elements/Select/index.mjs.map +1 -1
  187. package/dist/elements/Skeleton/index.js +1 -82
  188. package/dist/elements/Skeleton/index.js.map +1 -1
  189. package/dist/elements/Skeleton/index.mjs +1 -78
  190. package/dist/elements/Skeleton/index.mjs.map +1 -1
  191. package/dist/elements/Switch/index.js +1 -179
  192. package/dist/elements/Switch/index.js.map +1 -1
  193. package/dist/elements/Switch/index.mjs +1 -173
  194. package/dist/elements/Switch/index.mjs.map +1 -1
  195. package/dist/elements/Table/Table.d.ts +3 -24
  196. package/dist/elements/Table/Table.d.ts.map +1 -1
  197. package/dist/elements/Table/Table.styles.d.ts +24 -0
  198. package/dist/elements/Table/Table.styles.d.ts.map +1 -0
  199. package/dist/elements/Table/index.js +1 -595
  200. package/dist/elements/Table/index.js.map +1 -1
  201. package/dist/elements/Table/index.mjs +1 -578
  202. package/dist/elements/Table/index.mjs.map +1 -1
  203. package/dist/elements/Tabs/index.js +1 -337
  204. package/dist/elements/Tabs/index.js.map +1 -1
  205. package/dist/elements/Tabs/index.mjs +1 -320
  206. package/dist/elements/Tabs/index.mjs.map +1 -1
  207. package/dist/elements/TextField/TextField.d.ts +6 -42
  208. package/dist/elements/TextField/TextField.d.ts.map +1 -1
  209. package/dist/elements/TextField/TextField.hooks.d.ts +63 -0
  210. package/dist/elements/TextField/TextField.hooks.d.ts.map +1 -0
  211. package/dist/elements/TextField/TextField.icons.d.ts +19 -0
  212. package/dist/elements/TextField/TextField.icons.d.ts.map +1 -0
  213. package/dist/elements/TextField/TextField.styles.d.ts +37 -0
  214. package/dist/elements/TextField/TextField.styles.d.ts.map +1 -0
  215. package/dist/elements/TextField/TextField.types.d.ts +3 -0
  216. package/dist/elements/TextField/TextField.types.d.ts.map +1 -1
  217. package/dist/elements/TextField/index.css +1 -22
  218. package/dist/elements/TextField/index.css.map +1 -1
  219. package/dist/elements/TextField/index.js +1 -902
  220. package/dist/elements/TextField/index.js.map +1 -1
  221. package/dist/elements/TextField/index.mjs +1 -882
  222. package/dist/elements/TextField/index.mjs.map +1 -1
  223. package/dist/elements/TimeField/index.js +1 -254
  224. package/dist/elements/TimeField/index.js.map +1 -1
  225. package/dist/elements/TimeField/index.mjs +1 -238
  226. package/dist/elements/TimeField/index.mjs.map +1 -1
  227. package/dist/elements/Toast/Toast.d.ts +0 -22
  228. package/dist/elements/Toast/Toast.d.ts.map +1 -1
  229. package/dist/elements/Toast/index.js +1 -737
  230. package/dist/elements/Toast/index.js.map +1 -1
  231. package/dist/elements/Toast/index.mjs +1 -724
  232. package/dist/elements/Toast/index.mjs.map +1 -1
  233. package/dist/elements/Tooltip/index.js +1 -323
  234. package/dist/elements/Tooltip/index.js.map +1 -1
  235. package/dist/elements/Tooltip/index.mjs +1 -310
  236. package/dist/elements/Tooltip/index.mjs.map +1 -1
  237. package/dist/elements/index.css +1 -22
  238. package/dist/elements/index.css.map +1 -1
  239. package/dist/elements/index.d.ts +13 -1
  240. package/dist/elements/index.d.ts.map +1 -1
  241. package/dist/elements/index.js +1 -12455
  242. package/dist/elements/index.js.map +1 -1
  243. package/dist/elements/index.mjs +1 -12233
  244. package/dist/elements/index.mjs.map +1 -1
  245. package/dist/index.css +1 -22
  246. package/dist/index.css.map +1 -1
  247. package/dist/index.js +2 -12490
  248. package/dist/index.js.map +1 -1
  249. package/dist/index.mjs +2 -12262
  250. package/dist/index.mjs.map +1 -1
  251. package/dist/schemas/index.js +2 -54
  252. package/dist/schemas/index.js.map +1 -1
  253. package/dist/schemas/index.mjs +2 -48
  254. package/dist/schemas/index.mjs.map +1 -1
  255. package/dist/styles/defaults.css +151 -0
  256. package/dist/styles/index.js +1 -166
  257. package/dist/styles/index.js.map +1 -1
  258. package/dist/styles/index.mjs +1 -129
  259. package/dist/styles/index.mjs.map +1 -1
  260. package/dist/utils/index.js +1 -12
  261. package/dist/utils/index.js.map +1 -1
  262. package/dist/utils/index.mjs +1 -10
  263. package/dist/utils/index.mjs.map +1 -1
  264. package/package.json +9 -7
  265. package/src/elements/Accordion/Accordion.stories.tsx +1 -1
  266. package/src/elements/AlertDialog/AlertDialog.stories.tsx +124 -0
  267. package/src/elements/Avatar/Avatar.stories.tsx +1 -1
  268. package/src/elements/Badge/Badge.stories.tsx +1 -1
  269. package/src/elements/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
  270. package/src/elements/Button/Button.stories.tsx +1 -1
  271. package/src/elements/ButtonGroup/ButtonGroup.stories.tsx +1 -1
  272. package/src/elements/Card/Card.stories.tsx +1 -1
  273. package/src/elements/Carousel/Carousel.stories.tsx +1 -1
  274. package/src/elements/Chart/Chart.stories.tsx +1 -1
  275. package/src/elements/Checkbox/Checkbox.stories.tsx +1 -1
  276. package/src/elements/CheckboxGroup/CheckboxGroup.stories.tsx +1 -1
  277. package/src/elements/Combobox/Combobox.stories.tsx +133 -0
  278. package/src/elements/DatePicker/DatePicker.stories.tsx +1 -1
  279. package/src/elements/Dropdown/Dropdown.stories.tsx +1 -1
  280. package/src/elements/FileField/FileField.stories.tsx +1 -1
  281. package/src/elements/FileField/FileProgress.stories.tsx +1 -1
  282. package/src/elements/FormLayout/FormLayout.stories.tsx +1 -1
  283. package/src/elements/Modal/Modal.stories.tsx +1 -1
  284. package/src/elements/NumberField/NumberField.stories.tsx +1 -1
  285. package/src/elements/OTPInput/OTPInput.stories.tsx +1 -1
  286. package/src/elements/Pagination/Pagination.stories.tsx +203 -0
  287. package/src/elements/Panel/Panel.stories.tsx +1 -1
  288. package/src/elements/PasswordField/PasswordField.stories.tsx +167 -0
  289. package/src/elements/Progress/Progress.stories.tsx +1 -1
  290. package/src/elements/RadioGroup/RadioGroup.stories.tsx +1 -1
  291. package/src/elements/Resizable/Resizable.stories.tsx +1 -1
  292. package/src/elements/SearchField/SearchField.stories.tsx +146 -0
  293. package/src/elements/Select/Select.stories.tsx +1 -1
  294. package/src/elements/Skeleton/Skeleton.stories.tsx +1 -1
  295. package/src/elements/Switch/Switch.stories.tsx +1 -1
  296. package/src/elements/Table/Table.stories.tsx +1 -1
  297. package/src/elements/Tabs/Tabs.stories.tsx +1 -1
  298. package/src/elements/TextField/TextField.stories.tsx +1 -1
  299. package/src/elements/TimeField/TimeField.stories.tsx +1 -1
  300. package/src/elements/Toast/Toast.stories.tsx +1 -1
  301. package/src/elements/Tooltip/Tooltip.stories.tsx +1 -1
@@ -1,1568 +1,3 @@
1
1
  "use client";
2
- import { createContext, forwardRef, useImperativeHandle, useRef, useState, useEffect, memo, useId, useCallback, useContext } from 'react';
3
- import { clsx } from 'clsx';
4
- import { twMerge } from 'tailwind-merge';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { z } from 'zod';
7
- import { cva } from 'class-variance-authority';
8
- import { Loader2, Zap, Minus, Plus, X, GripVertical, GripHorizontal } from 'lucide-react';
9
- import { Button as Button$1, NumberField as NumberField$1, Label, Group, Input, Text, FieldError, DialogTrigger, Popover, Dialog } from 'react-aria-components';
10
-
11
- // src/elements/Resizable/components/ResizablePanelGroup.tsx
12
- function cn(...inputs) {
13
- return twMerge(clsx(inputs));
14
- }
15
- var ResizableContext = createContext(
16
- null
17
- );
18
- ResizableContext.displayName = "ResizableContext";
19
- function useResizableContext() {
20
- const context = useContext(ResizableContext);
21
- if (!context) {
22
- throw new Error(
23
- "useResizableContext must be used within a ResizablePanelGroup. Make sure ResizablePanel and ResizableHandle are children of ResizablePanelGroup."
24
- );
25
- }
26
- return context;
27
- }
28
- function useResizableProvider({
29
- direction,
30
- groupLabel,
31
- sizes: controlledSizes,
32
- onSizesChange
33
- }) {
34
- const [internalSizes, setInternalSizes] = useState([]);
35
- const [panels, setPanels] = useState([]);
36
- const containerRef = useRef(null);
37
- const liveRegionRef = useRef(null);
38
- const announceTimeoutRef = useRef(null);
39
- const sizesInitializedRef = useRef(false);
40
- const isControlled = controlledSizes !== void 0;
41
- const sizes = isControlled ? controlledSizes : internalSizes;
42
- const setSizes = useCallback(
43
- (newSizes) => {
44
- if (isControlled) {
45
- onSizesChange?.(newSizes);
46
- } else {
47
- setInternalSizes(newSizes);
48
- }
49
- },
50
- [isControlled, onSizesChange]
51
- );
52
- const registerPanel = useCallback((index, info) => {
53
- setPanels((prev) => {
54
- const newPanels = [...prev];
55
- newPanels[index] = info;
56
- return newPanels;
57
- });
58
- }, []);
59
- const unregisterPanel = useCallback((index) => {
60
- setPanels((prev) => {
61
- const newPanels = [...prev];
62
- delete newPanels[index];
63
- return newPanels.filter(Boolean);
64
- });
65
- }, []);
66
- useEffect(() => {
67
- if (isControlled || sizesInitializedRef.current) return;
68
- const registeredPanels = panels.filter(Boolean);
69
- const panelCount = registeredPanels.length;
70
- if (panelCount < 2) return;
71
- const needsInit = sizes.length < panelCount || sizes.some((s) => s === void 0);
72
- if (needsInit) {
73
- const newSizes = [];
74
- const equalSize = 100 / panelCount;
75
- for (let i = 0; i < panelCount; i++) {
76
- newSizes[i] = equalSize;
77
- }
78
- sizesInitializedRef.current = true;
79
- setInternalSizes(newSizes);
80
- }
81
- }, [panels, sizes, isControlled]);
82
- useEffect(() => {
83
- return () => {
84
- if (announceTimeoutRef.current) {
85
- clearTimeout(announceTimeoutRef.current);
86
- }
87
- if (liveRegionRef.current) {
88
- document.body.removeChild(liveRegionRef.current);
89
- liveRegionRef.current = null;
90
- }
91
- };
92
- }, []);
93
- const announce = useCallback((message) => {
94
- if (!liveRegionRef.current) {
95
- const liveRegion = document.createElement("div");
96
- liveRegion.setAttribute("aria-live", "polite");
97
- liveRegion.setAttribute("aria-atomic", "true");
98
- liveRegion.className = "sr-only";
99
- liveRegion.style.cssText = "position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;";
100
- document.body.appendChild(liveRegion);
101
- liveRegionRef.current = liveRegion;
102
- }
103
- liveRegionRef.current.textContent = message;
104
- if (announceTimeoutRef.current) {
105
- clearTimeout(announceTimeoutRef.current);
106
- }
107
- announceTimeoutRef.current = setTimeout(() => {
108
- if (liveRegionRef.current) {
109
- liveRegionRef.current.textContent = "";
110
- }
111
- }, 1e3);
112
- }, []);
113
- return {
114
- direction,
115
- groupLabel,
116
- sizes,
117
- setSizes,
118
- panels,
119
- registerPanel,
120
- unregisterPanel,
121
- announce,
122
- containerRef
123
- };
124
- }
125
- var ResizablePanelGroup = forwardRef(function ResizablePanelGroup2({ direction, groupLabel, sizes, onSizesChange, className, children }, ref) {
126
- const contextValue = useResizableProvider({
127
- direction,
128
- groupLabel,
129
- sizes,
130
- onSizesChange
131
- });
132
- useImperativeHandle(
133
- ref,
134
- () => contextValue.containerRef.current,
135
- [contextValue.containerRef]
136
- );
137
- return /* @__PURE__ */ jsx(ResizableContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
138
- "div",
139
- {
140
- ref: contextValue.containerRef,
141
- role: "group",
142
- "aria-label": `${groupLabel}, ${direction}`,
143
- "data-direction": direction,
144
- className: cn(
145
- "flex h-full w-full",
146
- direction === "horizontal" ? "flex-row" : "flex-col",
147
- className
148
- ),
149
- children
150
- }
151
- ) });
152
- });
153
- ResizablePanelGroup.displayName = "ResizablePanelGroup";
154
- var DEFAULT_MIN_SIZE = 10;
155
- var DEFAULT_MAX_SIZE = 90;
156
- var LONG_PRESS_THRESHOLD = 300;
157
- var ResizePresetSchema = z.object({
158
- label: z.string().min(1),
159
- sizes: z.array(z.number().min(0).max(100))
160
- });
161
- var ResizablePanelGroupPropsSchema = z.object({
162
- /** Layout direction */
163
- direction: z.enum(["horizontal", "vertical"]),
164
- /** REQUIRED: Label for screen reader identification of this group */
165
- groupLabel: z.string().min(1),
166
- /** Controlled mode: current sizes as percentages */
167
- sizes: z.array(z.number().min(0).max(100)).optional(),
168
- /** Callback when sizes change */
169
- onSizesChange: z.function().optional(),
170
- /** Additional CSS classes */
171
- className: z.string().optional(),
172
- /** Panel children */
173
- children: z.custom()
174
- });
175
- var ResizablePanelPropsSchema = z.object({
176
- /** REQUIRED: Name for screen reader identification */
177
- name: z.string().min(1),
178
- /** Default size as percentage (auto-distributes equally if omitted) */
179
- defaultSize: z.number().min(0).max(100).optional(),
180
- /** Minimum size as percentage */
181
- minSize: z.number().min(0).max(100).optional().default(DEFAULT_MIN_SIZE),
182
- /** Maximum size as percentage */
183
- maxSize: z.number().min(0).max(100).optional().default(DEFAULT_MAX_SIZE),
184
- /** Whether panel can collapse to 0% */
185
- collapsible: z.boolean().optional().default(false),
186
- /** Callback when panel collapses */
187
- onCollapse: z.function().optional(),
188
- /** Callback when panel expands from collapsed */
189
- onExpand: z.function().optional(),
190
- /** Callback when panel resizes */
191
- onResize: z.function().optional(),
192
- /** Additional CSS classes */
193
- className: z.string().optional(),
194
- /** Panel content */
195
- children: z.custom()
196
- });
197
- var ResizableHandlePropsSchema = z.object({
198
- /** Whether to show the visual grip indicator */
199
- withHandle: z.boolean().optional().default(true),
200
- /** Size presets for quick adjustment */
201
- presets: z.array(ResizePresetSchema).optional(),
202
- /** Whether the handle is disabled */
203
- disabled: z.boolean().optional().default(false),
204
- /** Additional CSS classes */
205
- className: z.string().optional()
206
- });
207
- var resizableHandleVariants = cva(
208
- [
209
- // Base styles - 44px touch target
210
- "relative flex items-center justify-center",
211
- "shrink-0",
212
- "bg-transparent",
213
- "transition-colors duration-150",
214
- // Focus styles
215
- "focus-visible:outline-none focus-visible:ring-2",
216
- "focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2",
217
- // Touch target padding for accessibility
218
- "touch-none select-none"
219
- ],
220
- {
221
- variants: {
222
- direction: {
223
- horizontal: [
224
- "w-3 min-w-[12px]",
225
- "cursor-col-resize",
226
- "hover:bg-[var(--accent)]/50",
227
- // Ensure 44px touch target via padding
228
- "before:absolute before:inset-y-0 before:-inset-x-4",
229
- "before:min-w-[44px]"
230
- ],
231
- vertical: [
232
- "h-3 min-h-[12px]",
233
- "cursor-row-resize",
234
- "hover:bg-[var(--accent)]/50",
235
- // Ensure 44px touch target via padding
236
- "before:absolute before:inset-x-0 before:-inset-y-4",
237
- "before:min-h-[44px]"
238
- ]
239
- },
240
- disabled: {
241
- true: "cursor-not-allowed opacity-50 pointer-events-none",
242
- false: ""
243
- },
244
- isDragging: {
245
- true: "bg-[var(--accent)]",
246
- false: ""
247
- }
248
- },
249
- defaultVariants: {
250
- direction: "horizontal",
251
- disabled: false,
252
- isDragging: false
253
- }
254
- }
255
- );
256
- var resizableGripVariants = cva(
257
- [
258
- "flex items-center justify-center",
259
- "rounded-full",
260
- "bg-[var(--border)]",
261
- "text-[var(--menu-muted)]"
262
- ],
263
- {
264
- variants: {
265
- direction: {
266
- horizontal: "h-8 w-1",
267
- vertical: "h-1 w-8"
268
- }
269
- },
270
- defaultVariants: {
271
- direction: "horizontal"
272
- }
273
- }
274
- );
275
- var ResizablePanel = forwardRef(
276
- function ResizablePanel2({
277
- name,
278
- defaultSize: _defaultSize,
279
- minSize = DEFAULT_MIN_SIZE,
280
- maxSize = DEFAULT_MAX_SIZE,
281
- collapsible = false,
282
- onCollapse,
283
- onExpand,
284
- onResize,
285
- className,
286
- children
287
- }, ref) {
288
- const { sizes, registerPanel, unregisterPanel, containerRef } = useResizableContext();
289
- const internalRef = useRef(null);
290
- const [panelIndex, setPanelIndex] = useState(-1);
291
- const prevSizeRef = useRef(null);
292
- const isRegisteredRef = useRef(false);
293
- const registeredIndexRef = useRef(-1);
294
- useEffect(() => {
295
- const panel = internalRef.current;
296
- const container = containerRef.current;
297
- if (!panel || !container) return;
298
- const allPanels = container.querySelectorAll("[data-resizable-panel]");
299
- let foundIndex = -1;
300
- for (let i = 0; i < allPanels.length; i++) {
301
- if (allPanels[i] === panel) {
302
- foundIndex = i;
303
- break;
304
- }
305
- }
306
- if (foundIndex === -1) return;
307
- if (panelIndex !== foundIndex) {
308
- setPanelIndex(foundIndex);
309
- }
310
- if (!isRegisteredRef.current) {
311
- isRegisteredRef.current = true;
312
- registeredIndexRef.current = foundIndex;
313
- registerPanel(foundIndex, {
314
- name,
315
- minSize,
316
- maxSize,
317
- collapsible
318
- });
319
- }
320
- return () => {
321
- if (isRegisteredRef.current) {
322
- unregisterPanel(registeredIndexRef.current);
323
- isRegisteredRef.current = false;
324
- }
325
- };
326
- }, [containerRef, registerPanel, unregisterPanel, name, minSize, maxSize, collapsible, panelIndex]);
327
- const currentSize = panelIndex >= 0 ? sizes[panelIndex] ?? 50 : 50;
328
- useEffect(() => {
329
- if (prevSizeRef.current === null) {
330
- prevSizeRef.current = currentSize;
331
- return;
332
- }
333
- const wasCollapsed = prevSizeRef.current === 0;
334
- const isCollapsed = currentSize === 0;
335
- if (!wasCollapsed && isCollapsed && onCollapse) {
336
- onCollapse();
337
- } else if (wasCollapsed && !isCollapsed && onExpand) {
338
- onExpand();
339
- }
340
- if (onResize && prevSizeRef.current !== currentSize) {
341
- onResize(currentSize);
342
- }
343
- prevSizeRef.current = currentSize;
344
- }, [currentSize, onCollapse, onExpand, onResize]);
345
- return /* @__PURE__ */ jsx(
346
- "div",
347
- {
348
- ref: (node) => {
349
- internalRef.current = node;
350
- if (typeof ref === "function") {
351
- ref(node);
352
- } else if (ref) {
353
- ref.current = node;
354
- }
355
- },
356
- role: "region",
357
- "aria-label": name,
358
- "data-resizable-panel": "",
359
- "data-panel-name": name,
360
- "data-panel-index": panelIndex,
361
- "data-collapsed": currentSize === 0,
362
- style: {
363
- flexBasis: `${currentSize}%`,
364
- flexGrow: 0,
365
- flexShrink: 0,
366
- overflow: "hidden"
367
- },
368
- className: cn("relative", className),
369
- children
370
- }
371
- );
372
- }
373
- );
374
- ResizablePanel.displayName = "ResizablePanel";
375
- function clampSize(size, min, max) {
376
- return Math.max(min, Math.min(max, size));
377
- }
378
- function calculateNewSizes(sizes, panels, leftIndex, rightIndex, delta) {
379
- const newSizes = [...sizes];
380
- const leftPanel = panels[leftIndex];
381
- const rightPanel = panels[rightIndex];
382
- if (!leftPanel || !rightPanel) return sizes;
383
- const leftSize = sizes[leftIndex] ?? 50;
384
- const rightSize = sizes[rightIndex] ?? 50;
385
- let newLeftSize = leftSize + delta;
386
- let newRightSize = rightSize - delta;
387
- const leftMin = leftPanel.collapsible ? 0 : leftPanel.minSize;
388
- const leftMax = leftPanel.maxSize;
389
- const rightMin = rightPanel.collapsible ? 0 : rightPanel.minSize;
390
- const rightMax = rightPanel.maxSize;
391
- newLeftSize = clampSize(newLeftSize, leftMin, leftMax);
392
- newRightSize = leftSize + rightSize - newLeftSize;
393
- newRightSize = clampSize(newRightSize, rightMin, rightMax);
394
- newLeftSize = leftSize + rightSize - newRightSize;
395
- newSizes[leftIndex] = newLeftSize;
396
- newSizes[rightIndex] = newRightSize;
397
- return newSizes;
398
- }
399
- function useResizable({
400
- direction,
401
- sizes,
402
- setSizes,
403
- panels,
404
- containerRef,
405
- leftPanelIndex,
406
- rightPanelIndex,
407
- disabled = false,
408
- announce,
409
- groupLabel,
410
- onOpenPopover
411
- }) {
412
- const [isDragging, setIsDragging] = useState(false);
413
- const dragStartRef = useRef(null);
414
- const longPressTimerRef = useRef(null);
415
- const pointerDownTimeRef = useRef(0);
416
- const wasLongPressRef = useRef(false);
417
- const panelsRef = useRef(panels);
418
- const sizesRef = useRef(sizes);
419
- const setSizesRef = useRef(setSizes);
420
- const handlePointerMoveRef = useRef(() => {
421
- });
422
- const handlePointerUpRef = useRef(() => {
423
- });
424
- useEffect(() => {
425
- panelsRef.current = panels;
426
- sizesRef.current = sizes;
427
- setSizesRef.current = setSizes;
428
- }, [panels, sizes, setSizes]);
429
- const getContainerSize = useCallback(() => {
430
- const container = containerRef.current;
431
- if (!container) return 0;
432
- return direction === "horizontal" ? container.offsetWidth : container.offsetHeight;
433
- }, [containerRef, direction]);
434
- const pixelsToPercent = useCallback(
435
- (pixels) => {
436
- const containerSize = getContainerSize();
437
- if (containerSize === 0) return 0;
438
- return pixels / containerSize * 100;
439
- },
440
- [getContainerSize]
441
- );
442
- const onPointerMove = useCallback((e) => {
443
- handlePointerMoveRef.current(e);
444
- }, []);
445
- const onPointerUp = useCallback(() => {
446
- handlePointerUpRef.current();
447
- }, []);
448
- const handlePointerMove = useCallback(
449
- (event) => {
450
- if (!dragStartRef.current || disabled) return;
451
- const position = direction === "horizontal" ? event.clientX : event.clientY;
452
- const delta = position - dragStartRef.current.position;
453
- const percentDelta = pixelsToPercent(delta);
454
- const newSizes = calculateNewSizes(
455
- dragStartRef.current.sizes,
456
- panelsRef.current,
457
- leftPanelIndex,
458
- rightPanelIndex,
459
- percentDelta
460
- );
461
- setSizesRef.current(newSizes);
462
- },
463
- [
464
- direction,
465
- disabled,
466
- leftPanelIndex,
467
- pixelsToPercent,
468
- rightPanelIndex
469
- ]
470
- );
471
- const handlePointerUp = useCallback(() => {
472
- if (longPressTimerRef.current) {
473
- clearTimeout(longPressTimerRef.current);
474
- longPressTimerRef.current = null;
475
- }
476
- const duration = Date.now() - pointerDownTimeRef.current;
477
- const wasTap = duration < LONG_PRESS_THRESHOLD && !wasLongPressRef.current;
478
- if (wasTap && onOpenPopover && !disabled) {
479
- onOpenPopover();
480
- }
481
- if (isDragging) {
482
- setIsDragging(false);
483
- const leftPanel = panelsRef.current[leftPanelIndex];
484
- const newSize = Math.round(sizesRef.current[leftPanelIndex] ?? 50);
485
- if (announce && leftPanel && groupLabel) {
486
- announce(
487
- `${leftPanel.name} in ${groupLabel} resized to ${newSize} percent`
488
- );
489
- }
490
- }
491
- dragStartRef.current = null;
492
- wasLongPressRef.current = false;
493
- document.removeEventListener("pointermove", onPointerMove);
494
- document.removeEventListener("pointerup", onPointerUp);
495
- document.removeEventListener("pointercancel", onPointerUp);
496
- document.body.style.cursor = "";
497
- document.body.style.userSelect = "";
498
- }, [
499
- announce,
500
- disabled,
501
- groupLabel,
502
- isDragging,
503
- leftPanelIndex,
504
- onOpenPopover,
505
- onPointerMove,
506
- onPointerUp
507
- ]);
508
- useEffect(() => {
509
- handlePointerMoveRef.current = handlePointerMove;
510
- handlePointerUpRef.current = handlePointerUp;
511
- });
512
- const handlePointerDown = useCallback(
513
- (event) => {
514
- if (disabled) return;
515
- event.preventDefault();
516
- const position = direction === "horizontal" ? event.clientX : event.clientY;
517
- pointerDownTimeRef.current = Date.now();
518
- wasLongPressRef.current = false;
519
- dragStartRef.current = {
520
- position,
521
- sizes: [...sizes],
522
- containerSize: getContainerSize()
523
- };
524
- longPressTimerRef.current = setTimeout(() => {
525
- wasLongPressRef.current = true;
526
- setIsDragging(true);
527
- document.body.style.cursor = direction === "horizontal" ? "col-resize" : "row-resize";
528
- document.body.style.userSelect = "none";
529
- }, LONG_PRESS_THRESHOLD);
530
- document.addEventListener("pointermove", onPointerMove);
531
- document.addEventListener("pointerup", onPointerUp);
532
- document.addEventListener("pointercancel", onPointerUp);
533
- if (event.pointerType === "mouse") {
534
- if (longPressTimerRef.current) {
535
- clearTimeout(longPressTimerRef.current);
536
- longPressTimerRef.current = null;
537
- }
538
- wasLongPressRef.current = true;
539
- setIsDragging(true);
540
- document.body.style.cursor = direction === "horizontal" ? "col-resize" : "row-resize";
541
- document.body.style.userSelect = "none";
542
- }
543
- },
544
- [
545
- direction,
546
- disabled,
547
- getContainerSize,
548
- onPointerMove,
549
- onPointerUp,
550
- sizes
551
- ]
552
- );
553
- const handleKeyDown = useCallback(
554
- (event) => {
555
- if (disabled) return;
556
- const step = event.shiftKey ? 10 : 1;
557
- let delta = 0;
558
- switch (event.key) {
559
- case "ArrowLeft":
560
- case "ArrowUp":
561
- delta = -step;
562
- break;
563
- case "ArrowRight":
564
- case "ArrowDown":
565
- delta = step;
566
- break;
567
- case "Home": {
568
- const leftPanel = panels[leftPanelIndex];
569
- if (leftPanel) {
570
- const minSize = leftPanel.collapsible ? 0 : leftPanel.minSize;
571
- delta = minSize - (sizes[leftPanelIndex] ?? 50);
572
- }
573
- break;
574
- }
575
- case "End": {
576
- const leftPanel = panels[leftPanelIndex];
577
- if (leftPanel) {
578
- delta = leftPanel.maxSize - (sizes[leftPanelIndex] ?? 50);
579
- }
580
- break;
581
- }
582
- case "Enter":
583
- case " ":
584
- event.preventDefault();
585
- onOpenPopover?.();
586
- return;
587
- default:
588
- return;
589
- }
590
- if (delta !== 0) {
591
- event.preventDefault();
592
- const newSizes = calculateNewSizes(
593
- sizes,
594
- panels,
595
- leftPanelIndex,
596
- rightPanelIndex,
597
- delta
598
- );
599
- setSizes(newSizes);
600
- const leftPanel = panels[leftPanelIndex];
601
- const newSize = Math.round(newSizes[leftPanelIndex] ?? 50);
602
- if (announce && leftPanel && groupLabel) {
603
- announce(
604
- `${leftPanel.name} in ${groupLabel} resized to ${newSize} percent`
605
- );
606
- }
607
- }
608
- },
609
- [
610
- announce,
611
- disabled,
612
- groupLabel,
613
- leftPanelIndex,
614
- onOpenPopover,
615
- panels,
616
- rightPanelIndex,
617
- setSizes,
618
- sizes
619
- ]
620
- );
621
- useEffect(() => {
622
- const moveHandler = onPointerMove;
623
- const upHandler = onPointerUp;
624
- return () => {
625
- if (longPressTimerRef.current) {
626
- clearTimeout(longPressTimerRef.current);
627
- }
628
- document.removeEventListener("pointermove", moveHandler);
629
- document.removeEventListener("pointerup", upHandler);
630
- document.removeEventListener("pointercancel", upHandler);
631
- };
632
- }, [onPointerMove, onPointerUp]);
633
- return {
634
- isDragging,
635
- handlePointerDown,
636
- handleKeyDown
637
- };
638
- }
639
- var PRESSED_STYLES = "data-[pressed]:scale-[0.97]";
640
- var HOVER_STYLES = "data-[hovered]:shadow-md";
641
- var HIGH_CONTRAST_HOVER = "hc:data-[hovered]:outline hc:data-[hovered]:outline-2 hc:data-[hovered]:outline-foreground";
642
- var HIGH_CONTRAST_PRESSED = "hc:data-[pressed]:outline hc:data-[pressed]:outline-2 hc:data-[pressed]:outline-offset-1 hc:data-[pressed]:outline-foreground";
643
- var ButtonGroupContext = createContext(null);
644
- ButtonGroupContext.displayName = "ButtonGroupContext";
645
- function useButtonGroupContext() {
646
- return useContext(ButtonGroupContext);
647
- }
648
- var ButtonGroupItemContext = createContext(null);
649
- ButtonGroupItemContext.displayName = "ButtonGroupItemContext";
650
- function useButtonGroupItemContext() {
651
- return useContext(ButtonGroupItemContext);
652
- }
653
- cva("inline-flex items-center gap-0", {
654
- variants: {
655
- orientation: {
656
- horizontal: "flex-row",
657
- vertical: "flex-col w-full"
658
- }
659
- },
660
- defaultVariants: {
661
- orientation: "horizontal"
662
- }
663
- });
664
- var buttonGroupItemVariants = cva("", {
665
- variants: {
666
- orientation: {
667
- // min-w-[44px] ensures visual layer fills touch target width (for icon buttons)
668
- horizontal: "min-w-[44px]",
669
- // flex (overrides inline-flex) + min-h-[44px] makes visual layer fill touch target,
670
- // eliminating gaps between stacked buttons in vertical orientation
671
- vertical: "flex min-h-[44px]"
672
- },
673
- position: {
674
- first: "",
675
- middle: "",
676
- last: "",
677
- only: ""
678
- // Single button - no modifications needed
679
- }
680
- },
681
- compoundVariants: [
682
- // ==========================================================================
683
- // Horizontal Orientation
684
- // ==========================================================================
685
- {
686
- orientation: "horizontal",
687
- position: "first",
688
- className: "rounded-r-none border-r-0"
689
- },
690
- {
691
- orientation: "horizontal",
692
- position: "middle",
693
- className: "rounded-none border-r-0"
694
- },
695
- {
696
- orientation: "horizontal",
697
- position: "last",
698
- className: "rounded-l-none"
699
- },
700
- // ==========================================================================
701
- // Vertical Orientation
702
- // Note: w-full is handled by Button's effectiveFullWidth for both layers
703
- // ==========================================================================
704
- {
705
- orientation: "vertical",
706
- position: "first",
707
- className: "rounded-b-none border-b-0"
708
- },
709
- {
710
- orientation: "vertical",
711
- position: "middle",
712
- className: "rounded-none border-b-0"
713
- },
714
- {
715
- orientation: "vertical",
716
- position: "last",
717
- className: "rounded-t-none"
718
- }
719
- ],
720
- defaultVariants: {
721
- orientation: "horizontal",
722
- position: "only"
723
- }
724
- });
725
- cva("bg-[var(--border)]", {
726
- variants: {
727
- orientation: {
728
- horizontal: "w-px h-6 mx-1",
729
- vertical: "h-px w-full my-1"
730
- }
731
- },
732
- defaultVariants: {
733
- orientation: "horizontal"
734
- }
735
- });
736
- var buttonOuterVariants = cva(
737
- "inline-flex justify-center min-h-[44px] min-w-[44px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",
738
- {
739
- variants: {
740
- fullWidth: {
741
- true: "w-full",
742
- false: ""
743
- },
744
- inVerticalGroup: {
745
- true: "items-stretch",
746
- false: "items-center"
747
- }
748
- },
749
- defaultVariants: {
750
- fullWidth: false,
751
- inVerticalGroup: false
752
- }
753
- }
754
- );
755
- var buttonVisualVariants = cva(
756
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 relative cursor-pointer",
757
- {
758
- variants: {
759
- variant: {
760
- default: "bg-[var(--primary-action)] text-[var(--primary-action-foreground)] shadow-md hover:bg-[var(--primary-action-hover)] data-[pressed]:bg-[var(--primary-action)]/80",
761
- destructive: "bg-[var(--destructive-background)] text-[var(--destructive-foreground)] shadow-md hover:bg-[var(--destructive-background)]/90 data-[pressed]:bg-[var(--destructive-background)]/80",
762
- outline: "border border-[var(--input-border)] bg-[var(--page-background)] hover:bg-[var(--input-border)] data-[pressed]:bg-[var(--input-border)]",
763
- secondary: "bg-[var(--secondary)] text-[var(--secondary-foreground)] shadow-md hover:bg-[var(--secondary)]/80 data-[pressed]:bg-[var(--secondary)]/70",
764
- ghost: "hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)] data-[pressed]:bg-[var(--accent)]",
765
- link: "text-[var(--text-link)] underline-offset-4 hover:underline data-[pressed]:text-[var(--text-link-hover)]"
766
- },
767
- fullWidth: {
768
- true: "w-full",
769
- false: ""
770
- },
771
- visualSize: {
772
- default: "h-10 px-4 py-2",
773
- sm: "h-9 rounded-md px-3 text-xs",
774
- lg: "h-11 rounded-md px-8",
775
- icon: "h-10 w-10",
776
- dot: "h-5 w-5 rounded-full p-0 min-h-0 min-w-0"
777
- },
778
- paywall: {
779
- true: "!bg-[var(--paywall)] !text-[var(--paywall-foreground)] !shadow-md hover:!bg-[var(--paywall)]/90 !cursor-not-allowed !border-transparent",
780
- false: ""
781
- }
782
- },
783
- defaultVariants: {
784
- variant: "default",
785
- visualSize: "default",
786
- paywall: false
787
- }
788
- }
789
- );
790
- var Button = memo(forwardRef(
791
- ({
792
- className,
793
- buttonVisualClassName,
794
- variant,
795
- size,
796
- visualSize,
797
- fullWidth,
798
- loading = false,
799
- loadingText = "Loading...",
800
- shortcut,
801
- children,
802
- isDisabled,
803
- paywall = false,
804
- paywallRedirect,
805
- paywallDescription,
806
- onPress,
807
- ...props
808
- }, ref) => {
809
- const paywallDescriptionId = useId();
810
- const groupContext = useButtonGroupContext();
811
- const itemContext = useButtonGroupItemContext();
812
- const effectiveVariant = variant ?? groupContext?.variant ?? "default";
813
- const effectiveSize = size ?? groupContext?.size;
814
- const effectiveIsDisabled = isDisabled ?? groupContext?.isDisabled ?? false;
815
- const isInVerticalGroup = groupContext?.orientation === "vertical";
816
- const effectiveFullWidth = fullWidth || isInVerticalGroup;
817
- const positionClassName = itemContext ? buttonGroupItemVariants({
818
- orientation: groupContext?.orientation ?? "horizontal",
819
- position: itemContext.position
820
- }) : "";
821
- const effectiveVisualSize = visualSize ?? effectiveSize ?? "default";
822
- if (process.env.NODE_ENV !== "production") {
823
- if ((effectiveVisualSize === "dot" || effectiveVisualSize === "icon") && !props["aria-label"] && !children) {
824
- console.warn(
825
- '[Button] visualSize="dot" or "icon" requires aria-label when no visible text is provided (WCAG 1.1.1)'
826
- );
827
- }
828
- }
829
- const handlePress = (e) => {
830
- if (paywall) {
831
- if (paywallRedirect) {
832
- window.open(paywallRedirect, "_blank", "noopener,noreferrer");
833
- }
834
- return;
835
- }
836
- onPress?.(e);
837
- };
838
- const computedIsDisabled = effectiveIsDisabled || loading || void 0;
839
- return /* @__PURE__ */ jsx(
840
- Button$1,
841
- {
842
- ref,
843
- isDisabled: computedIsDisabled,
844
- "aria-disabled": paywall ? true : void 0,
845
- "aria-describedby": paywall ? paywallDescriptionId : void 0,
846
- onPress: handlePress,
847
- className: cn(buttonOuterVariants({ fullWidth: effectiveFullWidth, inVerticalGroup: isInVerticalGroup }), className),
848
- ...props,
849
- children: (renderProps) => (
850
- /* Layer 2: Visual Button */
851
- /* @__PURE__ */ jsxs(
852
- "span",
853
- {
854
- className: cn(
855
- buttonVisualVariants({
856
- variant: effectiveVariant,
857
- visualSize: effectiveVisualSize,
858
- paywall,
859
- fullWidth: effectiveFullWidth
860
- }),
861
- // Position styling from ButtonGroup context (border-radius adjustments)
862
- positionClassName,
863
- buttonVisualClassName,
864
- // Layer 2 interaction styles (no focus - focus ring is on Layer 1)
865
- PRESSED_STYLES,
866
- HOVER_STYLES,
867
- HIGH_CONTRAST_HOVER,
868
- HIGH_CONTRAST_PRESSED
869
- ),
870
- "data-pressed": renderProps.isPressed || void 0,
871
- children: [
872
- loading && /* @__PURE__ */ jsxs(Fragment, { children: [
873
- /* @__PURE__ */ jsx(Loader2, { className: "motion-safe:animate-spin", "aria-hidden": "true" }),
874
- /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: loadingText })
875
- ] }),
876
- !loading && children,
877
- paywall && /* @__PURE__ */ jsx(
878
- Zap,
879
- {
880
- "data-testid": "zap-icon",
881
- "aria-hidden": "true",
882
- className: "ml-1"
883
- }
884
- ),
885
- paywall && /* @__PURE__ */ jsxs("span", { id: paywallDescriptionId, className: "sr-only", children: [
886
- "Premium feature: ",
887
- paywallDescription || "Upgrade required to access this feature"
888
- ] }),
889
- renderProps.isFocusVisible && shortcut && /* @__PURE__ */ jsx("kbd", { className: "ml-auto hidden text-xs opacity-60 lg:inline", children: shortcut }),
890
- renderProps.isPressed && /* @__PURE__ */ jsx(
891
- "span",
892
- {
893
- className: "absolute inset-0 rounded-[inherit] bg-current opacity-10 motion-safe:animate-in motion-safe:zoom-in-95",
894
- "aria-hidden": "true"
895
- }
896
- )
897
- ]
898
- }
899
- )
900
- )
901
- }
902
- );
903
- }
904
- ));
905
- Button.displayName = "Button";
906
- var DEFAULT_MAX_VALUE = 4294967295;
907
- var DEFAULT_MIN_VALUE = 0;
908
- var NEGATIVE_MIN_VALUE = -2147483647;
909
- z.object({
910
- // Value props
911
- /** Current value (controlled mode) */
912
- value: z.number().nullable().optional(),
913
- /** Default value (uncontrolled mode) */
914
- defaultValue: z.number().optional(),
915
- // Constraint props
916
- /** Minimum allowed value (default: 0) */
917
- minValue: z.number().optional(),
918
- /** Maximum allowed value (default: 4294967295 / UINT32_MAX) */
919
- maxValue: z.number().optional(),
920
- /** Allow negative numbers (sets minValue to -2147483647 if not explicitly set) */
921
- allowNegative: z.boolean().optional(),
922
- /** Step increment for stepper buttons and arrow keys (default: 1) */
923
- step: z.number().positive().optional(),
924
- // Formatting props
925
- /** Intl.NumberFormat options for locale-aware formatting */
926
- formatOptions: z.custom().optional(),
927
- // State props
928
- /** Whether the field is disabled */
929
- isDisabled: z.boolean().optional(),
930
- /** Whether the field is read-only */
931
- isReadOnly: z.boolean().optional(),
932
- /** Whether the field is required */
933
- isRequired: z.boolean().optional(),
934
- /** Whether the field is in an invalid state */
935
- isInvalid: z.boolean().optional(),
936
- /** Whether scroll wheel adjustment is disabled */
937
- isWheelDisabled: z.boolean().optional(),
938
- // Validation props
939
- /** Custom validation function that returns an error message or null */
940
- validate: z.function().optional(),
941
- /** Validation behavior: 'native' for HTML5 validation, 'aria' for ARIA-only */
942
- validationBehavior: z.enum(["native", "aria"]).default("native"),
943
- // Display props
944
- /** Field label (required for accessibility) */
945
- label: z.string(),
946
- /** Description text below the field */
947
- description: z.string().optional(),
948
- /** Error message string or render function */
949
- errorMessage: z.union([z.string(), z.function()]).optional(),
950
- // Stepper props
951
- /** Layout for stepper buttons */
952
- stepperLayout: z.enum(["sides", "stacked", "hidden"]).default("sides"),
953
- /** Custom aria-label for increment button */
954
- incrementAriaLabel: z.string().optional(),
955
- /** Custom aria-label for decrement button */
956
- decrementAriaLabel: z.string().optional(),
957
- // Form props
958
- /** Name attribute for form submission */
959
- name: z.string().optional(),
960
- // Variant props
961
- /** Size variant */
962
- size: z.enum(["sm", "default", "lg"]).default("default"),
963
- // Event props
964
- /** Called when the numeric value changes */
965
- onChange: z.function().optional(),
966
- /** Called when the field gains focus */
967
- onFocus: z.function().optional(),
968
- /** Called when the field loses focus */
969
- onBlur: z.function().optional(),
970
- /** Called when focus state changes */
971
- onFocusChange: z.function().optional(),
972
- // Standard props
973
- /** Additional CSS classes */
974
- className: z.string().optional(),
975
- /** Whether to auto-focus on mount */
976
- autoFocus: z.boolean().optional()
977
- });
978
- var numberFieldVariants = cva(
979
- [
980
- // Base styles
981
- "inline-flex items-center rounded-md border",
982
- "bg-[var(--content-background)] text-[var(--content-foreground)]",
983
- "transition-colors duration-200",
984
- // Focus within
985
- "focus-within:ring-2 focus-within:ring-[var(--ring)] focus-within:ring-offset-2",
986
- // Disabled
987
- "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50"
988
- ],
989
- {
990
- variants: {
991
- size: {
992
- sm: "h-9 text-sm",
993
- default: "h-10 text-base",
994
- lg: "h-12 text-lg"
995
- },
996
- isInvalid: {
997
- true: "border-[var(--destructive)] focus-within:ring-[var(--destructive)]",
998
- false: "border-[var(--input)] hover:border-[var(--input)]/80"
999
- }
1000
- },
1001
- defaultVariants: {
1002
- size: "default",
1003
- isInvalid: false
1004
- }
1005
- }
1006
- );
1007
- var numberFieldInputVariants = cva(
1008
- [
1009
- // Base styles
1010
- "flex-1 bg-transparent text-center tabular-nums",
1011
- "min-w-0",
1012
- // Allow shrinking
1013
- // Focus
1014
- "focus:outline-none",
1015
- // Hide native spinners
1016
- "[appearance:textfield]",
1017
- "[&::-webkit-outer-spin-button]:appearance-none",
1018
- "[&::-webkit-inner-spin-button]:appearance-none"
1019
- ],
1020
- {
1021
- variants: {
1022
- size: {
1023
- sm: "px-2 text-sm",
1024
- default: "px-3 text-base",
1025
- lg: "px-4 text-lg"
1026
- }
1027
- },
1028
- defaultVariants: {
1029
- size: "default"
1030
- }
1031
- }
1032
- );
1033
- var numberFieldStepperVariants = cva(
1034
- [
1035
- // Base styles
1036
- "flex items-center justify-center",
1037
- "transition-colors duration-150",
1038
- "select-none",
1039
- // Hover
1040
- "hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]",
1041
- // Focus
1042
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]",
1043
- "focus-visible:ring-inset",
1044
- // Active (pressed)
1045
- "active:bg-[var(--accent)]/80",
1046
- // Disabled
1047
- "disabled:pointer-events-none disabled:opacity-50"
1048
- ],
1049
- {
1050
- variants: {
1051
- size: {
1052
- sm: "min-w-8 min-h-8 text-sm",
1053
- default: "min-w-10 min-h-10 text-base",
1054
- lg: "min-w-12 min-h-12 text-lg"
1055
- },
1056
- position: {
1057
- left: "rounded-l-md border-r border-[var(--input)]",
1058
- right: "rounded-r-md border-l border-[var(--input)]",
1059
- top: "rounded-tr-md border-b border-l border-[var(--input)] h-1/2",
1060
- bottom: "rounded-br-md border-l border-[var(--input)] h-1/2"
1061
- }
1062
- },
1063
- defaultVariants: {
1064
- size: "default"
1065
- }
1066
- }
1067
- );
1068
- var numberFieldLabelVariants = cva(
1069
- [
1070
- "block font-medium text-[var(--content-foreground)]",
1071
- "mb-1.5",
1072
- // Required indicator
1073
- 'data-[required]:after:content-["*"] data-[required]:after:ml-0.5',
1074
- "data-[required]:after:text-[var(--destructive)]"
1075
- ],
1076
- {
1077
- variants: {
1078
- size: {
1079
- sm: "text-sm",
1080
- default: "text-sm",
1081
- lg: "text-base"
1082
- }
1083
- },
1084
- defaultVariants: {
1085
- size: "default"
1086
- }
1087
- }
1088
- );
1089
- var numberFieldDescriptionVariants = cva(
1090
- [
1091
- "text-[var(--menu-muted)]",
1092
- "mt-1"
1093
- ],
1094
- {
1095
- variants: {
1096
- size: {
1097
- sm: "text-xs",
1098
- default: "text-sm",
1099
- lg: "text-base"
1100
- }
1101
- },
1102
- defaultVariants: {
1103
- size: "default"
1104
- }
1105
- }
1106
- );
1107
- var numberFieldErrorVariants = cva(
1108
- [
1109
- "flex items-center gap-1",
1110
- "text-[var(--destructive)]",
1111
- "mt-1"
1112
- ],
1113
- {
1114
- variants: {
1115
- size: {
1116
- sm: "text-xs",
1117
- default: "text-sm",
1118
- lg: "text-base"
1119
- }
1120
- },
1121
- defaultVariants: {
1122
- size: "default"
1123
- }
1124
- }
1125
- );
1126
- var NumberField = forwardRef(
1127
- ({
1128
- // Display props
1129
- label,
1130
- description,
1131
- errorMessage,
1132
- // Variant props
1133
- size = "default",
1134
- stepperLayout = "sides",
1135
- // Custom props
1136
- allowNegative = false,
1137
- incrementAriaLabel,
1138
- decrementAriaLabel,
1139
- // Constraint props (apply defaults)
1140
- minValue,
1141
- maxValue,
1142
- // Standard props
1143
- className,
1144
- isInvalid,
1145
- isRequired,
1146
- isDisabled,
1147
- isReadOnly,
1148
- // All other props go to AriaNumberField
1149
- ...props
1150
- }, ref) => {
1151
- const effectiveMinValue = minValue ?? (allowNegative ? NEGATIVE_MIN_VALUE : DEFAULT_MIN_VALUE);
1152
- const effectiveMaxValue = maxValue ?? DEFAULT_MAX_VALUE;
1153
- const showSteppers = stepperLayout !== "hidden" && !isReadOnly;
1154
- const isStackedLayout = stepperLayout === "stacked";
1155
- return /* @__PURE__ */ jsxs(
1156
- NumberField$1,
1157
- {
1158
- ref,
1159
- className: cn("group flex flex-col", className),
1160
- minValue: effectiveMinValue,
1161
- maxValue: effectiveMaxValue,
1162
- isInvalid,
1163
- isRequired,
1164
- isDisabled,
1165
- isReadOnly,
1166
- ...props,
1167
- children: [
1168
- /* @__PURE__ */ jsx(
1169
- Label,
1170
- {
1171
- className: cn(numberFieldLabelVariants({ size })),
1172
- "data-required": isRequired || void 0,
1173
- children: label
1174
- }
1175
- ),
1176
- /* @__PURE__ */ jsxs(
1177
- Group,
1178
- {
1179
- className: cn(
1180
- numberFieldVariants({
1181
- size,
1182
- isInvalid: isInvalid ?? false
1183
- }),
1184
- isStackedLayout && "pr-0"
1185
- ),
1186
- children: [
1187
- showSteppers && !isStackedLayout && /* @__PURE__ */ jsx(
1188
- Button,
1189
- {
1190
- slot: "decrement",
1191
- variant: "ghost",
1192
- className: "!min-h-0 !min-w-0",
1193
- buttonVisualClassName: cn(
1194
- numberFieldStepperVariants({
1195
- size,
1196
- position: "left"
1197
- })
1198
- ),
1199
- "aria-label": decrementAriaLabel ?? "Decrease value",
1200
- children: /* @__PURE__ */ jsx(Minus, { className: "h-4 w-4", "aria-hidden": "true" })
1201
- }
1202
- ),
1203
- /* @__PURE__ */ jsx(
1204
- Input,
1205
- {
1206
- className: cn(numberFieldInputVariants({ size }))
1207
- }
1208
- ),
1209
- showSteppers && isStackedLayout && /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
1210
- /* @__PURE__ */ jsx(
1211
- Button,
1212
- {
1213
- slot: "increment",
1214
- variant: "ghost",
1215
- className: "!min-h-0 !min-w-0",
1216
- buttonVisualClassName: cn(
1217
- numberFieldStepperVariants({
1218
- size,
1219
- position: "top"
1220
- })
1221
- ),
1222
- "aria-label": incrementAriaLabel ?? "Increase value",
1223
- children: /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3", "aria-hidden": "true" })
1224
- }
1225
- ),
1226
- /* @__PURE__ */ jsx(
1227
- Button,
1228
- {
1229
- slot: "decrement",
1230
- variant: "ghost",
1231
- className: "!min-h-0 !min-w-0",
1232
- buttonVisualClassName: cn(
1233
- numberFieldStepperVariants({
1234
- size,
1235
- position: "bottom"
1236
- })
1237
- ),
1238
- "aria-label": decrementAriaLabel ?? "Decrease value",
1239
- children: /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3", "aria-hidden": "true" })
1240
- }
1241
- )
1242
- ] }),
1243
- showSteppers && !isStackedLayout && /* @__PURE__ */ jsx(
1244
- Button,
1245
- {
1246
- slot: "increment",
1247
- variant: "ghost",
1248
- className: "!min-h-0 !min-w-0",
1249
- buttonVisualClassName: cn(
1250
- numberFieldStepperVariants({
1251
- size,
1252
- position: "right"
1253
- })
1254
- ),
1255
- "aria-label": incrementAriaLabel ?? "Increase value",
1256
- children: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4", "aria-hidden": "true" })
1257
- }
1258
- )
1259
- ]
1260
- }
1261
- ),
1262
- description && /* @__PURE__ */ jsx(
1263
- Text,
1264
- {
1265
- slot: "description",
1266
- className: cn(numberFieldDescriptionVariants({ size })),
1267
- children: description
1268
- }
1269
- ),
1270
- /* @__PURE__ */ jsx(FieldError, { className: cn(numberFieldErrorVariants({ size })), children: errorMessage })
1271
- ]
1272
- }
1273
- );
1274
- }
1275
- );
1276
- NumberField.displayName = "NumberField";
1277
- var ResizablePopover = forwardRef(
1278
- function ResizablePopover2({
1279
- isOpen,
1280
- onOpenChange,
1281
- groupLabel,
1282
- leftPanel,
1283
- rightPanel,
1284
- leftSize,
1285
- rightSize,
1286
- onSizesChange,
1287
- presets,
1288
- triggerRef,
1289
- direction
1290
- }, _ref) {
1291
- const [originalSizes, setOriginalSizes] = useState({ left: leftSize, right: rightSize });
1292
- const wasOpenRef = useRef(false);
1293
- useEffect(() => {
1294
- if (isOpen && !wasOpenRef.current) {
1295
- setOriginalSizes({ left: leftSize, right: rightSize });
1296
- }
1297
- wasOpenRef.current = isOpen;
1298
- }, [isOpen, leftSize, rightSize]);
1299
- const handleLeftChange = useCallback(
1300
- (value) => {
1301
- if (value === null) return;
1302
- const newLeft = Math.max(
1303
- leftPanel.collapsible ? 0 : leftPanel.minSize,
1304
- Math.min(leftPanel.maxSize, value)
1305
- );
1306
- const newRight = 100 - newLeft;
1307
- const rightMin = rightPanel.collapsible ? 0 : rightPanel.minSize;
1308
- const rightMax = rightPanel.maxSize;
1309
- if (newRight < rightMin || newRight > rightMax) {
1310
- return;
1311
- }
1312
- onSizesChange(newLeft, newRight);
1313
- },
1314
- [leftPanel, rightPanel, onSizesChange]
1315
- );
1316
- const handleRightChange = useCallback(
1317
- (value) => {
1318
- if (value === null) return;
1319
- const newRight = Math.max(
1320
- rightPanel.collapsible ? 0 : rightPanel.minSize,
1321
- Math.min(rightPanel.maxSize, value)
1322
- );
1323
- const newLeft = 100 - newRight;
1324
- const leftMin = leftPanel.collapsible ? 0 : leftPanel.minSize;
1325
- const leftMax = leftPanel.maxSize;
1326
- if (newLeft < leftMin || newLeft > leftMax) {
1327
- return;
1328
- }
1329
- onSizesChange(newLeft, newRight);
1330
- },
1331
- [leftPanel, rightPanel, onSizesChange]
1332
- );
1333
- const handlePreset = useCallback(
1334
- (preset) => {
1335
- const leftSize2 = preset.sizes[0];
1336
- const rightSize2 = preset.sizes[1];
1337
- if (leftSize2 !== void 0 && rightSize2 !== void 0) {
1338
- onSizesChange(leftSize2, rightSize2);
1339
- }
1340
- },
1341
- [onSizesChange]
1342
- );
1343
- const handleCancel = useCallback(() => {
1344
- onSizesChange(originalSizes.left, originalSizes.right);
1345
- onOpenChange(false);
1346
- }, [onSizesChange, onOpenChange, originalSizes]);
1347
- const handleClose = useCallback(() => {
1348
- onOpenChange(false);
1349
- }, [onOpenChange]);
1350
- if (!isOpen) return null;
1351
- const placement = direction === "horizontal" ? "bottom" : "right";
1352
- return /* @__PURE__ */ jsxs(DialogTrigger, { isOpen, onOpenChange, children: [
1353
- /* @__PURE__ */ jsx(Button$1, { className: "sr-only", children: "Open resize controls" }),
1354
- /* @__PURE__ */ jsx(
1355
- Popover,
1356
- {
1357
- triggerRef,
1358
- placement,
1359
- offset: 8,
1360
- className: cn(
1361
- "w-72",
1362
- "rounded-lg border border-[var(--border)]",
1363
- "bg-[var(--popover)] text-[var(--popover-foreground)]",
1364
- "shadow-lg",
1365
- "outline-none",
1366
- "animate-in fade-in-0 zoom-in-95",
1367
- "data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:zoom-out-95"
1368
- ),
1369
- children: /* @__PURE__ */ jsxs(Dialog, { className: "outline-none", children: [
1370
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-[var(--border)] px-4 py-3", children: [
1371
- /* @__PURE__ */ jsxs("h3", { className: "text-sm font-medium", children: [
1372
- "Resize: ",
1373
- groupLabel
1374
- ] }),
1375
- /* @__PURE__ */ jsx(
1376
- Button$1,
1377
- {
1378
- onPress: handleClose,
1379
- className: cn(
1380
- "inline-flex items-center justify-center rounded-md",
1381
- "min-h-[44px] min-w-[44px]",
1382
- "text-[var(--menu-muted)]",
1383
- "hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]",
1384
- "focus-visible:outline-none focus-visible:ring-2",
1385
- "focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2"
1386
- ),
1387
- "aria-label": "Close",
1388
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
1389
- }
1390
- )
1391
- ] }),
1392
- /* @__PURE__ */ jsxs("div", { className: "space-y-4 px-4 py-4", children: [
1393
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1394
- NumberField,
1395
- {
1396
- label: `${leftPanel.name} (%)`,
1397
- value: Math.round(leftSize),
1398
- onChange: handleLeftChange,
1399
- minValue: leftPanel.collapsible ? 0 : leftPanel.minSize,
1400
- maxValue: leftPanel.maxSize,
1401
- step: 1,
1402
- stepperLayout: "sides"
1403
- }
1404
- ) }),
1405
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1406
- NumberField,
1407
- {
1408
- label: `${rightPanel.name} (%)`,
1409
- value: Math.round(rightSize),
1410
- onChange: handleRightChange,
1411
- minValue: rightPanel.collapsible ? 0 : rightPanel.minSize,
1412
- maxValue: rightPanel.maxSize,
1413
- step: 1,
1414
- stepperLayout: "sides"
1415
- }
1416
- ) }),
1417
- presets && presets.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-[var(--border)] pt-4", children: [
1418
- /* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium text-[var(--menu-muted)]", children: "Presets" }),
1419
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: presets.map((preset, index) => /* @__PURE__ */ jsx(
1420
- Button,
1421
- {
1422
- variant: "outline",
1423
- size: "sm",
1424
- onPress: () => handlePreset(preset),
1425
- children: preset.label
1426
- },
1427
- index
1428
- )) })
1429
- ] })
1430
- ] }),
1431
- /* @__PURE__ */ jsx("div", { className: "flex justify-end border-t border-[var(--border)] px-4 py-3", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: handleCancel, children: "Cancel" }) })
1432
- ] })
1433
- }
1434
- )
1435
- ] });
1436
- }
1437
- );
1438
- ResizablePopover.displayName = "ResizablePopover";
1439
- var ResizableHandle = forwardRef(
1440
- function ResizableHandle2({ withHandle = true, presets, disabled = false, className }, ref) {
1441
- const {
1442
- direction,
1443
- groupLabel,
1444
- sizes,
1445
- setSizes,
1446
- panels,
1447
- announce,
1448
- containerRef
1449
- } = useResizableContext();
1450
- const internalRef = useRef(null);
1451
- const handleRef = ref || internalRef;
1452
- const [handleIndex, setHandleIndex] = useState(0);
1453
- useEffect(() => {
1454
- const handle = handleRef.current;
1455
- const container = containerRef.current;
1456
- if (!handle || !container) return;
1457
- const handles = container.querySelectorAll('[role="slider"]');
1458
- let index = 0;
1459
- handles.forEach((h, i) => {
1460
- if (h === handle) {
1461
- index = i;
1462
- }
1463
- });
1464
- setHandleIndex(index);
1465
- }, [containerRef, handleRef]);
1466
- const leftPanelIndex = handleIndex;
1467
- const rightPanelIndex = handleIndex + 1;
1468
- const leftPanel = panels[leftPanelIndex];
1469
- const rightPanel = panels[rightPanelIndex];
1470
- const leftSize = sizes[leftPanelIndex] ?? 50;
1471
- const rightSize = sizes[rightPanelIndex] ?? 50;
1472
- const [isPopoverOpen, setIsPopoverOpen] = useState(false);
1473
- const handlePopoverSizesChange = useCallback(
1474
- (newLeftSize, newRightSize) => {
1475
- const newSizes = [...sizes];
1476
- newSizes[leftPanelIndex] = newLeftSize;
1477
- newSizes[rightPanelIndex] = newRightSize;
1478
- setSizes(newSizes);
1479
- },
1480
- [sizes, setSizes, leftPanelIndex, rightPanelIndex]
1481
- );
1482
- const { isDragging, handlePointerDown, handleKeyDown } = useResizable({
1483
- direction,
1484
- sizes,
1485
- setSizes,
1486
- panels,
1487
- containerRef,
1488
- leftPanelIndex,
1489
- rightPanelIndex,
1490
- disabled,
1491
- announce,
1492
- groupLabel,
1493
- onOpenPopover: () => setIsPopoverOpen(true)
1494
- });
1495
- const ariaLabel = leftPanel && rightPanel ? `Resize handle between ${leftPanel.name} and ${rightPanel.name} in ${groupLabel}` : `Resize handle in ${groupLabel}`;
1496
- const GripIcon = direction === "horizontal" ? GripVertical : GripHorizontal;
1497
- const leftPanelInfo = leftPanel ?? {
1498
- name: "Panel 1",
1499
- minSize: DEFAULT_MIN_SIZE,
1500
- maxSize: DEFAULT_MAX_SIZE,
1501
- collapsible: false
1502
- };
1503
- const rightPanelInfo = rightPanel ?? {
1504
- name: "Panel 2",
1505
- minSize: DEFAULT_MIN_SIZE,
1506
- maxSize: DEFAULT_MAX_SIZE,
1507
- collapsible: false
1508
- };
1509
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1510
- /* @__PURE__ */ jsx(
1511
- "div",
1512
- {
1513
- ref: handleRef,
1514
- role: "slider",
1515
- tabIndex: disabled ? -1 : 0,
1516
- "aria-label": ariaLabel,
1517
- "aria-valuenow": Math.round(leftSize),
1518
- "aria-valuemin": leftPanel?.collapsible ? 0 : leftPanel?.minSize ?? 0,
1519
- "aria-valuemax": leftPanel?.maxSize ?? 100,
1520
- "aria-orientation": direction,
1521
- "aria-disabled": disabled,
1522
- "data-direction": direction,
1523
- "data-dragging": isDragging,
1524
- "data-disabled": disabled,
1525
- onPointerDown: handlePointerDown,
1526
- onKeyDown: handleKeyDown,
1527
- className: cn(
1528
- resizableHandleVariants({
1529
- direction,
1530
- disabled,
1531
- isDragging
1532
- }),
1533
- className
1534
- ),
1535
- children: withHandle && /* @__PURE__ */ jsx(
1536
- "div",
1537
- {
1538
- className: cn(resizableGripVariants({ direction })),
1539
- "aria-hidden": "true",
1540
- children: /* @__PURE__ */ jsx(GripIcon, { className: "h-4 w-4" })
1541
- }
1542
- )
1543
- }
1544
- ),
1545
- /* @__PURE__ */ jsx(
1546
- ResizablePopover,
1547
- {
1548
- isOpen: isPopoverOpen,
1549
- onOpenChange: setIsPopoverOpen,
1550
- groupLabel,
1551
- leftPanel: leftPanelInfo,
1552
- rightPanel: rightPanelInfo,
1553
- leftSize,
1554
- rightSize,
1555
- onSizesChange: handlePopoverSizesChange,
1556
- presets,
1557
- triggerRef: handleRef,
1558
- direction
1559
- }
1560
- )
1561
- ] });
1562
- }
1563
- );
1564
- ResizableHandle.displayName = "ResizableHandle";
1565
-
1566
- export { DEFAULT_MAX_SIZE, DEFAULT_MIN_SIZE, LONG_PRESS_THRESHOLD, ResizableHandle, ResizableHandlePropsSchema, ResizablePanel, ResizablePanelGroup, ResizablePanelGroupPropsSchema, ResizablePanelPropsSchema, ResizePresetSchema, resizableGripVariants, resizableHandleVariants, useResizableContext };
1567
- //# sourceMappingURL=index.mjs.map
2
+ import {createContext,forwardRef,useImperativeHandle,useRef,useState,useEffect,memo,useId,useCallback,useContext}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {z}from'zod';import {cva}from'class-variance-authority';import {Loader2,Zap,Minus,Plus,X as X$1,GripVertical,GripHorizontal}from'lucide-react';import {Button,NumberField,Label,Group,Input,Text,FieldError,DialogTrigger,Popover,Dialog}from'react-aria-components';function N(...p){return twMerge(clsx(p))}var ee=createContext(null);ee.displayName="ResizableContext";function W(){let p=useContext(ee);if(!p)throw new Error("useResizableContext must be used within a ResizablePanelGroup. Make sure ResizablePanel and ResizableHandle are children of ResizablePanelGroup.");return p}function Se({direction:p,groupLabel:o,sizes:f,onSizesChange:n}){let[l,e]=useState([]),[a,i]=useState([]),t=useRef(null),s=useRef(null),v=useRef(null),c=useRef(false),P=f!==void 0,R=P?f:l,h=useCallback(b=>{P?n?.(b):e(b);},[P,n]),E=useCallback((b,r)=>{i(g=>{let w=[...g];return w[b]=r,w});},[]),L=useCallback(b=>{i(r=>{let g=[...r];return delete g[b],g.filter(Boolean)});},[]);useEffect(()=>{if(P||c.current)return;let r=a.filter(Boolean).length;if(r<2)return;if(R.length<r||R.some(w=>w===void 0)){let w=[],d=100/r;for(let u=0;u<r;u++)w[u]=d;c.current=true,e(w);}},[a,R,P]),useEffect(()=>()=>{v.current&&clearTimeout(v.current),s.current&&(document.body.removeChild(s.current),s.current=null);},[]);let y=useCallback(b=>{if(!s.current){let r=document.createElement("div");r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true"),r.className="sr-only",r.style.cssText="position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;",document.body.appendChild(r),s.current=r;}s.current.textContent=b,v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{s.current&&(s.current.textContent="");},1e3);},[]);return {direction:p,groupLabel:o,sizes:R,setSizes:h,panels:a,registerPanel:E,unregisterPanel:L,announce:y,containerRef:t}}var ye=forwardRef(function({direction:o,groupLabel:f,sizes:n,onSizesChange:l,className:e,children:a},i){let t=Se({direction:o,groupLabel:f,sizes:n,onSizesChange:l});return useImperativeHandle(i,()=>t.containerRef.current,[t.containerRef]),jsx(ee.Provider,{value:t,children:jsx("div",{ref:t.containerRef,role:"group","aria-label":`${f}, ${o}`,"data-direction":o,className:N("flex h-full w-full",o==="horizontal"?"flex-row":"flex-col",e),children:a})})});ye.displayName="ResizablePanelGroup";var U=10,$=90,te=300,Ee=z.object({label:z.string().min(1),sizes:z.array(z.number().min(0).max(100))}),lt=z.object({direction:z.enum(["horizontal","vertical"]),groupLabel:z.string().min(1),sizes:z.array(z.number().min(0).max(100)).optional(),onSizesChange:z.function().optional(),className:z.string().optional(),children:z.custom()}),ut=z.object({name:z.string().min(1),defaultSize:z.number().min(0).max(100).optional(),minSize:z.number().min(0).max(100).optional().default(U),maxSize:z.number().min(0).max(100).optional().default($),collapsible:z.boolean().optional().default(false),onCollapse:z.function().optional(),onExpand:z.function().optional(),onResize:z.function().optional(),className:z.string().optional(),children:z.custom()}),ct=z.object({withHandle:z.boolean().optional().default(true),presets:z.array(Ee).optional(),disabled:z.boolean().optional().default(false),className:z.string().optional()}),se=cva(["relative flex items-center justify-center","shrink-0","bg-transparent","transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2","focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2","touch-none select-none"],{variants:{direction:{horizontal:["w-3 min-w-[12px]","cursor-col-resize","hover:bg-[var(--accent)]/50","before:absolute before:inset-y-0 before:-inset-x-4","before:min-w-[44px]"],vertical:["h-3 min-h-[12px]","cursor-row-resize","hover:bg-[var(--accent)]/50","before:absolute before:inset-x-0 before:-inset-y-4","before:min-h-[44px]"]},disabled:{true:"cursor-not-allowed opacity-50 pointer-events-none",false:""},isDragging:{true:"bg-[var(--accent)]",false:""}},defaultVariants:{direction:"horizontal",disabled:false,isDragging:false}}),le=cva(["flex items-center justify-center","rounded-full","bg-[var(--border)]","text-[var(--menu-muted)]"],{variants:{direction:{horizontal:"h-8 w-1",vertical:"h-1 w-8"}},defaultVariants:{direction:"horizontal"}});var Ve=forwardRef(function({name:o,defaultSize:f,minSize:n=U,maxSize:l=$,collapsible:e=false,onCollapse:a,onExpand:i,onResize:t,className:s,children:v},c){let{sizes:P,registerPanel:R,unregisterPanel:h,containerRef:E}=W(),L=useRef(null),[y,b]=useState(-1),r=useRef(null),g=useRef(false),w=useRef(-1);useEffect(()=>{let u=L.current,x=E.current;if(!u||!x)return;let V=x.querySelectorAll("[data-resizable-panel]"),T=-1;for(let F=0;F<V.length;F++)if(V[F]===u){T=F;break}if(T!==-1)return y!==T&&b(T),g.current||(g.current=true,w.current=T,R(T,{name:o,minSize:n,maxSize:l,collapsible:e})),()=>{g.current&&(h(w.current),g.current=false);}},[E,R,h,o,n,l,e,y]);let d=y>=0?P[y]??50:50;return useEffect(()=>{if(r.current===null){r.current=d;return}let u=r.current===0,x=d===0;!u&&x&&a?a():u&&!x&&i&&i(),t&&r.current!==d&&t(d),r.current=d;},[d,a,i,t]),jsx("div",{ref:u=>{L.current=u,typeof c=="function"?c(u):c&&(c.current=u);},role:"region","aria-label":o,"data-resizable-panel":"","data-panel-name":o,"data-panel-index":y,"data-collapsed":d===0,style:{flexBasis:`${d}%`,flexGrow:0,flexShrink:0,overflow:"hidden"},className:N("relative",s),children:v})});Ve.displayName="ResizablePanel";function Te(p,o,f){return Math.max(o,Math.min(f,p))}function Le(p,o,f,n,l){let e=[...p],a=o[f],i=o[n];if(!a||!i)return p;let t=p[f]??50,s=p[n]??50,v=t+l,c=s-l,P=a.collapsible?0:a.minSize,R=a.maxSize,h=i.collapsible?0:i.minSize,E=i.maxSize;return v=Te(v,P,R),c=t+s-v,c=Te(c,h,E),v=t+s-c,e[f]=v,e[n]=c,e}function De({direction:p,sizes:o,setSizes:f,panels:n,containerRef:l,leftPanelIndex:e,rightPanelIndex:a,disabled:i=false,announce:t,groupLabel:s,onOpenPopover:v}){let[c,P]=useState(false),R=useRef(null),h=useRef(null),E=useRef(0),L=useRef(false),y=useRef(n),b=useRef(o),r=useRef(f),g=useRef(()=>{}),w=useRef(()=>{});useEffect(()=>{y.current=n,b.current=o,r.current=f;},[n,o,f]);let d=useCallback(()=>{let S=l.current;return S?p==="horizontal"?S.offsetWidth:S.offsetHeight:0},[l,p]),u=useCallback(S=>{let C=d();return C===0?0:S/C*100},[d]),x=useCallback(S=>{g.current(S);},[]),V=useCallback(()=>{w.current();},[]),T=useCallback(S=>{if(!R.current||i)return;let I=(p==="horizontal"?S.clientX:S.clientY)-R.current.position,D=u(I),_=Le(R.current.sizes,y.current,e,a,D);r.current(_);},[p,i,e,u,a]),F=useCallback(()=>{if(h.current&&(clearTimeout(h.current),h.current=null),Date.now()-E.current<te&&!L.current&&v&&!i&&v(),c){P(false);let I=y.current[e],D=Math.round(b.current[e]??50);t&&I&&s&&t(`${I.name} in ${s} resized to ${D} percent`);}R.current=null,L.current=false,document.removeEventListener("pointermove",x),document.removeEventListener("pointerup",V),document.removeEventListener("pointercancel",V),document.body.style.cursor="",document.body.style.userSelect="";},[t,i,s,c,e,v,x,V]);useEffect(()=>{g.current=T,w.current=F;});let K=useCallback(S=>{if(i)return;S.preventDefault();let C=p==="horizontal"?S.clientX:S.clientY;E.current=Date.now(),L.current=false,R.current={position:C,sizes:[...o],containerSize:d()},h.current=setTimeout(()=>{L.current=true,P(true),document.body.style.cursor=p==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none";},te),document.addEventListener("pointermove",x),document.addEventListener("pointerup",V),document.addEventListener("pointercancel",V),S.pointerType==="mouse"&&(h.current&&(clearTimeout(h.current),h.current=null),L.current=true,P(true),document.body.style.cursor=p==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none");},[p,i,d,x,V,o]),G=useCallback(S=>{if(i)return;let C=S.shiftKey?10:1,I=0;switch(S.key){case "ArrowLeft":case "ArrowUp":I=-C;break;case "ArrowRight":case "ArrowDown":I=C;break;case "Home":{let D=n[e];D&&(I=(D.collapsible?0:D.minSize)-(o[e]??50));break}case "End":{let D=n[e];D&&(I=D.maxSize-(o[e]??50));break}case "Enter":case " ":S.preventDefault(),v?.();return;default:return}if(I!==0){S.preventDefault();let D=Le(o,n,e,a,I);f(D);let _=n[e],k=Math.round(D[e]??50);t&&_&&s&&t(`${_.name} in ${s} resized to ${k} percent`);}},[t,i,s,e,v,n,a,f,o]);return useEffect(()=>{let S=x,C=V;return ()=>{h.current&&clearTimeout(h.current),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C);}},[x,V]),{isDragging:c,handlePointerDown:K,handleKeyDown:G}}var ce=cva("inline-flex justify-center min-h-[44px] min-w-[44px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{fullWidth:{true:"w-full",false:""},inVerticalGroup:{true:"items-stretch",false:"items-center"}},defaultVariants:{fullWidth:false,inVerticalGroup:false}}),de=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 relative cursor-pointer",{variants:{variant:{default:"bg-[var(--primary-action)] text-[var(--primary-action-foreground)] shadow-md hover:bg-[var(--primary-action-hover)] data-[pressed]:bg-[var(--primary-action)]/80",destructive:"bg-[var(--destructive-background)] text-[var(--destructive-foreground)] shadow-md hover:bg-[var(--destructive-background)]/90 data-[pressed]:bg-[var(--destructive-background)]/80",outline:"border border-[var(--input-border)] bg-[var(--page-background)] hover:bg-[var(--input-border)] data-[pressed]:bg-[var(--input-border)]",secondary:"bg-[var(--secondary)] text-[var(--secondary-foreground)] shadow-md hover:bg-[var(--secondary)]/80 data-[pressed]:bg-[var(--secondary)]/70",ghost:"hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)] data-[pressed]:bg-[var(--accent)]",link:"text-[var(--text-link)] underline-offset-4 hover:underline data-[pressed]:text-[var(--text-link-hover)]"},fullWidth:{true:"w-full",false:""},visualSize:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-xs",lg:"h-11 rounded-md px-8",icon:"h-10 w-10",dot:"h-5 w-5 rounded-full p-0 min-h-0 min-w-0"},paywall:{true:"!bg-[var(--paywall)] !text-[var(--paywall-foreground)] !shadow-md hover:!bg-[var(--paywall)]/90 !cursor-not-allowed !border-transparent",false:""}},defaultVariants:{variant:"default",visualSize:"default",paywall:false}});var me="data-[pressed]:scale-[0.97]";var pe="data-[hovered]:shadow-md";var re="hc:data-[hovered]:outline hc:data-[hovered]:outline-2 hc:data-[hovered]:outline-foreground",oe="hc:data-[pressed]:outline hc:data-[pressed]:outline-2 hc:data-[pressed]:outline-offset-1 hc:data-[pressed]:outline-foreground";var _e=createContext(null);_e.displayName="ButtonGroupContext";function Me(){return useContext(_e)}var Fe=createContext(null);Fe.displayName="ButtonGroupItemContext";function Ge(){return useContext(Fe)}cva("inline-flex items-center gap-0",{variants:{orientation:{horizontal:"flex-row",vertical:"flex-col w-full"}},defaultVariants:{orientation:"horizontal"}});var Be=cva("",{variants:{orientation:{horizontal:"min-w-[44px]",vertical:"flex min-h-[44px]"},position:{first:"",middle:"",last:"",only:""}},compoundVariants:[{orientation:"horizontal",position:"first",className:"rounded-r-none border-r-0"},{orientation:"horizontal",position:"middle",className:"rounded-none border-r-0"},{orientation:"horizontal",position:"last",className:"rounded-l-none"},{orientation:"vertical",position:"first",className:"rounded-b-none border-b-0"},{orientation:"vertical",position:"middle",className:"rounded-none border-b-0"},{orientation:"vertical",position:"last",className:"rounded-t-none"}],defaultVariants:{orientation:"horizontal",position:"only"}});cva("bg-[var(--border)]",{variants:{orientation:{horizontal:"w-px h-6 mx-1",vertical:"h-px w-full my-1"}},defaultVariants:{orientation:"horizontal"}});var M=memo(forwardRef(({className:p,buttonVisualClassName:o,variant:f,size:n,visualSize:l,fullWidth:e,loading:a=false,loadingText:i="Loading...",shortcut:t,children:s,isDisabled:v,paywall:c=false,paywallRedirect:P,paywallDescription:R,onPress:h,...E},L)=>{let y=useId(),b=Me(),r=Ge(),g=f??b?.variant??"default",w=n??b?.size,d=v??b?.isDisabled??false,u=b?.orientation==="vertical",x=e||u,V=r?Be({orientation:b?.orientation??"horizontal",position:r.position}):"",T=l??w??"default";return process.env.NODE_ENV!=="production"&&(T==="dot"||T==="icon")&&!E["aria-label"]&&!s&&console.warn('[Button] visualSize="dot" or "icon" requires aria-label when no visible text is provided (WCAG 1.1.1)'),jsx(Button,{ref:L,isDisabled:d||a||void 0,"aria-disabled":c?true:void 0,"aria-describedby":c?y:void 0,onPress:G=>{if(c){P&&window.open(P,"_blank","noopener,noreferrer");return}h?.(G);},className:N(ce({fullWidth:x,inVerticalGroup:u}),p),...E,children:G=>jsxs("span",{className:N(de({variant:g,visualSize:T,paywall:c,fullWidth:x}),V,o,me,pe,re,oe),"data-pressed":G.isPressed||void 0,children:[a&&jsxs(Fragment,{children:[jsx(Loader2,{className:"motion-safe:animate-spin","aria-hidden":"true"}),jsx("span",{className:"sr-only","aria-live":"polite",children:i})]}),!a&&s,c&&jsx(Zap,{"data-testid":"zap-icon","aria-hidden":"true",className:"ml-1"}),c&&jsxs("span",{id:y,className:"sr-only",children:["Premium feature: ",R||"Upgrade required to access this feature"]}),G.isFocusVisible&&t&&jsx("kbd",{className:"ml-auto hidden text-xs opacity-60 lg:inline",children:t}),G.isPressed&&jsx("span",{className:"absolute inset-0 rounded-[inherit] bg-current opacity-10 motion-safe:animate-in motion-safe:zoom-in-95","aria-hidden":"true"})]})})}));M.displayName="Button";var Oe=4294967295,ke=0,Ue=-2147483647;z.object({value:z.number().nullable().optional(),defaultValue:z.number().optional(),minValue:z.number().optional(),maxValue:z.number().optional(),allowNegative:z.boolean().optional(),step:z.number().positive().optional(),formatOptions:z.custom().optional(),isDisabled:z.boolean().optional(),isReadOnly:z.boolean().optional(),isRequired:z.boolean().optional(),isInvalid:z.boolean().optional(),isWheelDisabled:z.boolean().optional(),validate:z.function().optional(),validationBehavior:z.enum(["native","aria"]).default("native"),label:z.string(),description:z.string().optional(),errorMessage:z.union([z.string(),z.function()]).optional(),stepperLayout:z.enum(["sides","stacked","hidden"]).default("sides"),incrementAriaLabel:z.string().optional(),decrementAriaLabel:z.string().optional(),name:z.string().optional(),size:z.enum(["sm","default","lg"]).default("default"),onChange:z.function().optional(),onFocus:z.function().optional(),onBlur:z.function().optional(),onFocusChange:z.function().optional(),className:z.string().optional(),autoFocus:z.boolean().optional()});var $e=cva(["inline-flex items-center rounded-md border","bg-[var(--content-background)] text-[var(--content-foreground)]","transition-colors duration-200","focus-within:ring-2 focus-within:ring-[var(--ring)] focus-within:ring-offset-2","data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50"],{variants:{size:{sm:"h-9 text-sm",default:"h-10 text-base",lg:"h-12 text-lg"},isInvalid:{true:"border-[var(--destructive)] focus-within:ring-[var(--destructive)]",false:"border-[var(--input)] hover:border-[var(--input)]/80"}},defaultVariants:{size:"default",isInvalid:false}}),je=cva(["flex-1 bg-transparent text-center tabular-nums","min-w-0","focus:outline-none","[appearance:textfield]","[&::-webkit-outer-spin-button]:appearance-none","[&::-webkit-inner-spin-button]:appearance-none"],{variants:{size:{sm:"px-2 text-sm",default:"px-3 text-base",lg:"px-4 text-lg"}},defaultVariants:{size:"default"}}),X=cva(["flex items-center justify-center","transition-colors duration-150","select-none","hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]","focus-visible:ring-inset","active:bg-[var(--accent)]/80","disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{sm:"min-w-8 min-h-8 text-sm",default:"min-w-10 min-h-10 text-base",lg:"min-w-12 min-h-12 text-lg"},position:{left:"rounded-l-md border-r border-[var(--input)]",right:"rounded-r-md border-l border-[var(--input)]",top:"rounded-tr-md border-b border-l border-[var(--input)] h-1/2",bottom:"rounded-br-md border-l border-[var(--input)] h-1/2"}},defaultVariants:{size:"default"}}),qe=cva(["block font-medium text-[var(--content-foreground)]","mb-1.5",'data-[required]:after:content-["*"] data-[required]:after:ml-0.5',"data-[required]:after:text-[var(--destructive)]"],{variants:{size:{sm:"text-sm",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),Ye=cva(["text-[var(--menu-muted)]","mt-1"],{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),We=cva(["flex items-center gap-1","text-[var(--destructive)]","mt-1"],{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}});var ae=forwardRef(({label:p,description:o,errorMessage:f,size:n="default",stepperLayout:l="sides",allowNegative:e=false,incrementAriaLabel:a,decrementAriaLabel:i,minValue:t,maxValue:s,className:v,isInvalid:c,isRequired:P,isDisabled:R,isReadOnly:h,...E},L)=>{let y=t??(e?Ue:ke),b=s??Oe,r=l!=="hidden"&&!h,g=l==="stacked";return jsxs(NumberField,{ref:L,className:N("group flex flex-col",v),minValue:y,maxValue:b,isInvalid:c,isRequired:P,isDisabled:R,isReadOnly:h,...E,children:[jsx(Label,{className:N(qe({size:n})),"data-required":P||void 0,children:p}),jsxs(Group,{className:N($e({size:n,isInvalid:c??false}),g&&"pr-0"),children:[r&&!g&&jsx(M,{slot:"decrement",variant:"ghost",className:"!min-h-0 !min-w-0",buttonVisualClassName:N(X({size:n,position:"left"})),"aria-label":i??"Decrease value",children:jsx(Minus,{className:"h-4 w-4","aria-hidden":"true"})}),jsx(Input,{className:N(je({size:n}))}),r&&g&&jsxs("div",{className:"flex flex-col h-full",children:[jsx(M,{slot:"increment",variant:"ghost",className:"!min-h-0 !min-w-0",buttonVisualClassName:N(X({size:n,position:"top"})),"aria-label":a??"Increase value",children:jsx(Plus,{className:"h-3 w-3","aria-hidden":"true"})}),jsx(M,{slot:"decrement",variant:"ghost",className:"!min-h-0 !min-w-0",buttonVisualClassName:N(X({size:n,position:"bottom"})),"aria-label":i??"Decrease value",children:jsx(Minus,{className:"h-3 w-3","aria-hidden":"true"})})]}),r&&!g&&jsx(M,{slot:"increment",variant:"ghost",className:"!min-h-0 !min-w-0",buttonVisualClassName:N(X({size:n,position:"right"})),"aria-label":a??"Increase value",children:jsx(Plus,{className:"h-4 w-4","aria-hidden":"true"})})]}),o&&jsx(Text,{slot:"description",className:N(Ye({size:n})),children:o}),jsx(FieldError,{className:N(We({size:n})),children:f})]})});ae.displayName="NumberField";var he=forwardRef(function({isOpen:o,onOpenChange:f,groupLabel:n,leftPanel:l,rightPanel:e,leftSize:a,rightSize:i,onSizesChange:t,presets:s,triggerRef:v,direction:c},P){let[R,h]=useState({left:a,right:i}),E=useRef(false);useEffect(()=>{o&&!E.current&&h({left:a,right:i}),E.current=o;},[o,a,i]);let L=useCallback(d=>{if(d===null)return;let u=Math.max(l.collapsible?0:l.minSize,Math.min(l.maxSize,d)),x=100-u,V=e.collapsible?0:e.minSize,T=e.maxSize;x<V||x>T||t(u,x);},[l,e,t]),y=useCallback(d=>{if(d===null)return;let u=Math.max(e.collapsible?0:e.minSize,Math.min(e.maxSize,d)),x=100-u,V=l.collapsible?0:l.minSize,T=l.maxSize;x<V||x>T||t(x,u);},[l,e,t]),b=useCallback(d=>{let u=d.sizes[0],x=d.sizes[1];u!==void 0&&x!==void 0&&t(u,x);},[t]),r=useCallback(()=>{t(R.left,R.right),f(false);},[t,f,R]),g=useCallback(()=>{f(false);},[f]);return o?jsxs(DialogTrigger,{isOpen:o,onOpenChange:f,children:[jsx(Button,{className:"sr-only",children:"Open resize controls"}),jsx(Popover,{triggerRef:v,placement:c==="horizontal"?"bottom":"right",offset:8,className:N("w-72","rounded-lg border border-[var(--border)]","bg-[var(--popover)] text-[var(--popover-foreground)]","shadow-lg","outline-none","animate-in fade-in-0 zoom-in-95","data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:zoom-out-95"),children:jsxs(Dialog,{className:"outline-none",children:[jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-4 py-3",children:[jsxs("h3",{className:"text-sm font-medium",children:["Resize: ",n]}),jsx(Button,{onPress:g,className:N("inline-flex items-center justify-center rounded-md","min-h-[44px] min-w-[44px]","text-[var(--menu-muted)]","hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]","focus-visible:outline-none focus-visible:ring-2","focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2"),"aria-label":"Close",children:jsx(X$1,{className:"h-4 w-4"})})]}),jsxs("div",{className:"space-y-4 px-4 py-4",children:[jsx("div",{children:jsx(ae,{label:`${l.name} (%)`,value:Math.round(a),onChange:L,minValue:l.collapsible?0:l.minSize,maxValue:l.maxSize,step:1,stepperLayout:"sides"})}),jsx("div",{children:jsx(ae,{label:`${e.name} (%)`,value:Math.round(i),onChange:y,minValue:e.collapsible?0:e.minSize,maxValue:e.maxSize,step:1,stepperLayout:"sides"})}),s&&s.length>0&&jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[jsx("div",{className:"mb-2 text-xs font-medium text-[var(--menu-muted)]",children:"Presets"}),jsx("div",{className:"flex flex-wrap gap-2",children:s.map((d,u)=>jsx(M,{variant:"outline",size:"sm",onPress:()=>b(d),children:d.label},u))})]})]}),jsx("div",{className:"flex justify-end border-t border-[var(--border)] px-4 py-3",children:jsx(M,{variant:"ghost",size:"sm",onPress:r,children:"Cancel"})})]})})]}):null});he.displayName="ResizablePopover";var Qe=forwardRef(function({withHandle:o=true,presets:f,disabled:n=false,className:l},e){let{direction:a,groupLabel:i,sizes:t,setSizes:s,panels:v,announce:c,containerRef:P}=W(),R=useRef(null),h=e||R,[E,L]=useState(0);useEffect(()=>{let D=h.current,_=P.current;if(!D||!_)return;let k=_.querySelectorAll('[role="slider"]'),ze=0;k.forEach((et,tt)=>{et===D&&(ze=tt);}),L(ze);},[P,h]);let y=E,b=E+1,r=v[y],g=v[b],w=t[y]??50,d=t[b]??50,[u,x]=useState(false),V=useCallback((D,_)=>{let k=[...t];k[y]=D,k[b]=_,s(k);},[t,s,y,b]),{isDragging:T,handlePointerDown:F,handleKeyDown:K}=De({direction:a,sizes:t,setSizes:s,panels:v,containerRef:P,leftPanelIndex:y,rightPanelIndex:b,disabled:n,announce:c,groupLabel:i,onOpenPopover:()=>x(true)}),G=r&&g?`Resize handle between ${r.name} and ${g.name} in ${i}`:`Resize handle in ${i}`,S=a==="horizontal"?GripVertical:GripHorizontal,C=r??{name:"Panel 1",minSize:U,maxSize:$,collapsible:false},I=g??{name:"Panel 2",minSize:U,maxSize:$,collapsible:false};return jsxs(Fragment,{children:[jsx("div",{ref:h,role:"slider",tabIndex:n?-1:0,"aria-label":G,"aria-valuenow":Math.round(w),"aria-valuemin":r?.collapsible?0:r?.minSize??0,"aria-valuemax":r?.maxSize??100,"aria-orientation":a,"aria-disabled":n,"data-direction":a,"data-dragging":T,"data-disabled":n,onPointerDown:F,onKeyDown:K,className:N(se({direction:a,disabled:n,isDragging:T}),l),children:o&&jsx("div",{className:N(le({direction:a})),"aria-hidden":"true",children:jsx(S,{className:"h-4 w-4"})})}),jsx(he,{isOpen:u,onOpenChange:x,groupLabel:i,leftPanel:C,rightPanel:I,leftSize:w,rightSize:d,onSizesChange:V,presets:f,triggerRef:h,direction:a})]})});Qe.displayName="ResizableHandle";export{$ as DEFAULT_MAX_SIZE,U as DEFAULT_MIN_SIZE,te as LONG_PRESS_THRESHOLD,Qe as ResizableHandle,ct as ResizableHandlePropsSchema,Ve as ResizablePanel,ye as ResizablePanelGroup,lt as ResizablePanelGroupPropsSchema,ut as ResizablePanelPropsSchema,Ee as ResizePresetSchema,le as resizableGripVariants,se as resizableHandleVariants,W as useResizableContext};//# sourceMappingURL=index.mjs.map
1568
3
  //# sourceMappingURL=index.mjs.map