@szum-tech/design-system 3.17.0 → 3.18.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 (299) hide show
  1. package/dist/chunk-D5PAWOAZ.cjs +1 -0
  2. package/dist/chunk-JUNHRB4B.js +1 -0
  3. package/dist/chunk-P7BFOJLM.cjs +3 -0
  4. package/dist/chunk-ZYG2KYKK.js +3 -0
  5. package/dist/components/index.cjs +1 -924
  6. package/dist/components/index.d.cts +1650 -56
  7. package/dist/components/index.d.ts +1650 -56
  8. package/dist/components/index.js +1 -43
  9. package/dist/hooks/index.cjs +1 -35
  10. package/dist/hooks/index.js +1 -2
  11. package/dist/icons/index.cjs +2 -93
  12. package/dist/icons/index.js +2 -88
  13. package/dist/utils/index.cjs +1 -10
  14. package/dist/utils/index.js +1 -1
  15. package/package.json +30 -38
  16. package/dist/chunk-2WQJ36RD.cjs +0 -78
  17. package/dist/chunk-2Y2ZCPNV.cjs +0 -61
  18. package/dist/chunk-35H6T7OQ.cjs +0 -2912
  19. package/dist/chunk-375QAB65.cjs +0 -145
  20. package/dist/chunk-3DP3VMPN.js +0 -173
  21. package/dist/chunk-3GNVQFCK.cjs +0 -50
  22. package/dist/chunk-3RK5PCIC.js +0 -86
  23. package/dist/chunk-3WSQRFUY.cjs +0 -11
  24. package/dist/chunk-4LNGZHF2.cjs +0 -33
  25. package/dist/chunk-4TRADSTP.js +0 -34
  26. package/dist/chunk-5B37TQYT.cjs +0 -18
  27. package/dist/chunk-5F2Y65JH.js +0 -32
  28. package/dist/chunk-5MJPZUTO.js +0 -38
  29. package/dist/chunk-5MV54MWS.js +0 -46
  30. package/dist/chunk-6BSR3O2J.js +0 -53
  31. package/dist/chunk-6HX7ETL3.cjs +0 -183
  32. package/dist/chunk-7OD2NBSV.cjs +0 -50
  33. package/dist/chunk-A72LE53B.js +0 -21
  34. package/dist/chunk-A7SBXO2Y.cjs +0 -40
  35. package/dist/chunk-AAPMLWYK.js +0 -2831
  36. package/dist/chunk-B4M7Q5KX.cjs +0 -25
  37. package/dist/chunk-B7RHEMZH.js +0 -48
  38. package/dist/chunk-BTSHACKG.js +0 -123
  39. package/dist/chunk-BUJO4FB6.js +0 -252
  40. package/dist/chunk-CL2C6STG.cjs +0 -278
  41. package/dist/chunk-CXHDWIGF.cjs +0 -89
  42. package/dist/chunk-DGWBE2Y3.cjs +0 -205
  43. package/dist/chunk-DUAM4RTP.cjs +0 -23
  44. package/dist/chunk-EOTQVIA5.js +0 -993
  45. package/dist/chunk-EUH466AL.cjs +0 -179
  46. package/dist/chunk-F7NFSDOD.cjs +0 -91
  47. package/dist/chunk-G24PWQKG.js +0 -20
  48. package/dist/chunk-GEDBA3JU.cjs +0 -49
  49. package/dist/chunk-GYXQUTWZ.cjs +0 -59
  50. package/dist/chunk-H2BWO3SI.cjs +0 -11
  51. package/dist/chunk-H5NHGMSQ.js +0 -136
  52. package/dist/chunk-HCHVDUI6.cjs +0 -34
  53. package/dist/chunk-HNRVLRMN.js +0 -82
  54. package/dist/chunk-HPICKLBZ.cjs +0 -204
  55. package/dist/chunk-I3E75OQX.js +0 -16
  56. package/dist/chunk-I3RSTJP6.js +0 -20
  57. package/dist/chunk-IWF52DDE.js +0 -55
  58. package/dist/chunk-IZU3KULT.js +0 -41
  59. package/dist/chunk-K5AURCK5.js +0 -183
  60. package/dist/chunk-KTAIBRTH.cjs +0 -10
  61. package/dist/chunk-L2TRMQNN.js +0 -130
  62. package/dist/chunk-M7NIRB3U.js +0 -43
  63. package/dist/chunk-MNDQXDV4.cjs +0 -607
  64. package/dist/chunk-N4TYSZSU.cjs +0 -44
  65. package/dist/chunk-NU5UQPBX.cjs +0 -25
  66. package/dist/chunk-NXEZE7LG.js +0 -15
  67. package/dist/chunk-OCOCENE6.js +0 -42
  68. package/dist/chunk-OQCNPNPS.js +0 -23
  69. package/dist/chunk-OXZQGDTR.js +0 -208
  70. package/dist/chunk-OZSNSRLV.cjs +0 -1027
  71. package/dist/chunk-P4IL77YC.js +0 -66
  72. package/dist/chunk-P4JIMFSL.js +0 -51
  73. package/dist/chunk-P5IUC7HJ.js +0 -9
  74. package/dist/chunk-PBEZZMAB.js +0 -25
  75. package/dist/chunk-RKFU4DS3.cjs +0 -1064
  76. package/dist/chunk-S3ANEJJ7.cjs +0 -22
  77. package/dist/chunk-S3ZUFD6U.js +0 -23
  78. package/dist/chunk-SHPJGB2L.cjs +0 -19
  79. package/dist/chunk-TH44JYXB.cjs +0 -27
  80. package/dist/chunk-TMXVL5CV.cjs +0 -48
  81. package/dist/chunk-U3QKV7I4.js +0 -54
  82. package/dist/chunk-U7XZJQ4O.js +0 -36
  83. package/dist/chunk-UJX74PFK.cjs +0 -46
  84. package/dist/chunk-ULEEQ723.cjs +0 -108
  85. package/dist/chunk-UNOMGKAZ.cjs +0 -141
  86. package/dist/chunk-USIW3VT5.cjs +0 -73
  87. package/dist/chunk-VK2FJ65F.js +0 -575
  88. package/dist/chunk-VK5EX3OG.cjs +0 -132
  89. package/dist/chunk-WCQ5WKCQ.js +0 -1042
  90. package/dist/chunk-WMGJCB7O.js +0 -157
  91. package/dist/chunk-X3ZT3KGX.cjs +0 -53
  92. package/dist/chunk-X5O7GP4S.js +0 -48
  93. package/dist/chunk-X7WREEFD.js +0 -8
  94. package/dist/chunk-XENOUBSI.cjs +0 -37
  95. package/dist/chunk-XKCLVPUC.js +0 -176
  96. package/dist/chunk-XTKD76O5.js +0 -29
  97. package/dist/chunk-YBFG2IRJ.cjs +0 -225
  98. package/dist/chunk-YEFLGE3L.cjs +0 -47
  99. package/dist/chunk-YUMKV5TH.js +0 -56
  100. package/dist/chunk-ZD2QRAOX.js +0 -9
  101. package/dist/chunk-ZVF7J4EI.cjs +0 -58
  102. package/dist/color-picker.types-GI7dq2Ig.d.cts +0 -42
  103. package/dist/color-picker.types-GI7dq2Ig.d.ts +0 -42
  104. package/dist/components/accordion/index.cjs +0 -23
  105. package/dist/components/accordion/index.d.cts +0 -17
  106. package/dist/components/accordion/index.d.ts +0 -17
  107. package/dist/components/accordion/index.js +0 -2
  108. package/dist/components/alert/index.cjs +0 -19
  109. package/dist/components/alert/index.d.cts +0 -24
  110. package/dist/components/alert/index.d.ts +0 -24
  111. package/dist/components/alert/index.js +0 -2
  112. package/dist/components/alert-dialog/index.cjs +0 -43
  113. package/dist/components/alert-dialog/index.d.cts +0 -32
  114. package/dist/components/alert-dialog/index.d.ts +0 -32
  115. package/dist/components/alert-dialog/index.js +0 -2
  116. package/dist/components/avatar/index.cjs +0 -19
  117. package/dist/components/avatar/index.d.cts +0 -14
  118. package/dist/components/avatar/index.d.ts +0 -14
  119. package/dist/components/avatar/index.js +0 -2
  120. package/dist/components/badge/index.cjs +0 -19
  121. package/dist/components/badge/index.d.cts +0 -28
  122. package/dist/components/badge/index.d.ts +0 -28
  123. package/dist/components/badge/index.js +0 -2
  124. package/dist/components/badge-overflow/index.cjs +0 -183
  125. package/dist/components/badge-overflow/index.d.cts +0 -21
  126. package/dist/components/badge-overflow/index.d.ts +0 -21
  127. package/dist/components/badge-overflow/index.js +0 -161
  128. package/dist/components/breadcrump/index.cjs +0 -80
  129. package/dist/components/breadcrump/index.d.cts +0 -21
  130. package/dist/components/breadcrump/index.d.ts +0 -21
  131. package/dist/components/breadcrump/index.js +0 -72
  132. package/dist/components/button/index.cjs +0 -52
  133. package/dist/components/button/index.d.cts +0 -58
  134. package/dist/components/button/index.d.ts +0 -58
  135. package/dist/components/button/index.js +0 -43
  136. package/dist/components/card/index.cjs +0 -35
  137. package/dist/components/card/index.d.cts +0 -25
  138. package/dist/components/card/index.d.ts +0 -25
  139. package/dist/components/card/index.js +0 -2
  140. package/dist/components/carousel/index.cjs +0 -269
  141. package/dist/components/carousel/index.d.cts +0 -48
  142. package/dist/components/carousel/index.d.ts +0 -48
  143. package/dist/components/carousel/index.js +0 -238
  144. package/dist/components/checkbox/index.cjs +0 -11
  145. package/dist/components/checkbox/index.d.cts +0 -8
  146. package/dist/components/checkbox/index.d.ts +0 -8
  147. package/dist/components/checkbox/index.js +0 -2
  148. package/dist/components/collapsible/index.cjs +0 -18
  149. package/dist/components/collapsible/index.d.cts +0 -12
  150. package/dist/components/collapsible/index.d.ts +0 -12
  151. package/dist/components/collapsible/index.js +0 -1
  152. package/dist/components/color-picker/index.cjs +0 -92
  153. package/dist/components/color-picker/index.d.cts +0 -71
  154. package/dist/components/color-picker/index.d.ts +0 -71
  155. package/dist/components/color-picker/index.js +0 -43
  156. package/dist/components/color-swatch/index.cjs +0 -11
  157. package/dist/components/color-swatch/index.d.cts +0 -22
  158. package/dist/components/color-swatch/index.d.ts +0 -22
  159. package/dist/components/color-swatch/index.js +0 -2
  160. package/dist/components/counting-number/index.cjs +0 -11
  161. package/dist/components/counting-number/index.d.cts +0 -57
  162. package/dist/components/counting-number/index.d.ts +0 -57
  163. package/dist/components/counting-number/index.js +0 -2
  164. package/dist/components/dialog/index.cjs +0 -39
  165. package/dist/components/dialog/index.d.cts +0 -42
  166. package/dist/components/dialog/index.d.ts +0 -42
  167. package/dist/components/dialog/index.js +0 -2
  168. package/dist/components/dropdown-menu/index.cjs +0 -71
  169. package/dist/components/dropdown-menu/index.d.cts +0 -67
  170. package/dist/components/dropdown-menu/index.d.ts +0 -67
  171. package/dist/components/dropdown-menu/index.js +0 -2
  172. package/dist/components/empty/index.cjs +0 -31
  173. package/dist/components/empty/index.d.cts +0 -29
  174. package/dist/components/empty/index.d.ts +0 -29
  175. package/dist/components/empty/index.js +0 -2
  176. package/dist/components/field/index.cjs +0 -49
  177. package/dist/components/field/index.d.cts +0 -50
  178. package/dist/components/field/index.d.ts +0 -50
  179. package/dist/components/field/index.js +0 -4
  180. package/dist/components/file-upload/index.cjs +0 -60
  181. package/dist/components/file-upload/index.d.cts +0 -131
  182. package/dist/components/file-upload/index.d.ts +0 -131
  183. package/dist/components/file-upload/index.js +0 -3
  184. package/dist/components/header/index.cjs +0 -11
  185. package/dist/components/header/index.d.cts +0 -18
  186. package/dist/components/header/index.d.ts +0 -18
  187. package/dist/components/header/index.js +0 -2
  188. package/dist/components/input/index.cjs +0 -11
  189. package/dist/components/input/index.d.cts +0 -9
  190. package/dist/components/input/index.d.ts +0 -9
  191. package/dist/components/input/index.js +0 -2
  192. package/dist/components/item/index.cjs +0 -48
  193. package/dist/components/item/index.d.cts +0 -61
  194. package/dist/components/item/index.d.ts +0 -61
  195. package/dist/components/item/index.js +0 -3
  196. package/dist/components/label/index.cjs +0 -11
  197. package/dist/components/label/index.d.cts +0 -8
  198. package/dist/components/label/index.d.ts +0 -8
  199. package/dist/components/label/index.js +0 -2
  200. package/dist/components/marquee/index.cjs +0 -11
  201. package/dist/components/marquee/index.d.cts +0 -48
  202. package/dist/components/marquee/index.d.ts +0 -48
  203. package/dist/components/marquee/index.js +0 -2
  204. package/dist/components/masonry/index.cjs +0 -16
  205. package/dist/components/masonry/index.d.cts +0 -181
  206. package/dist/components/masonry/index.d.ts +0 -181
  207. package/dist/components/masonry/index.js +0 -3
  208. package/dist/components/popover/index.cjs +0 -35
  209. package/dist/components/popover/index.d.cts +0 -18
  210. package/dist/components/popover/index.d.ts +0 -18
  211. package/dist/components/popover/index.js +0 -2
  212. package/dist/components/progress/index.cjs +0 -11
  213. package/dist/components/progress/index.d.cts +0 -8
  214. package/dist/components/progress/index.d.ts +0 -8
  215. package/dist/components/progress/index.js +0 -2
  216. package/dist/components/radio-group/index.cjs +0 -15
  217. package/dist/components/radio-group/index.d.cts +0 -22
  218. package/dist/components/radio-group/index.d.ts +0 -22
  219. package/dist/components/radio-group/index.js +0 -2
  220. package/dist/components/scroll-area/index.cjs +0 -15
  221. package/dist/components/scroll-area/index.d.cts +0 -11
  222. package/dist/components/scroll-area/index.d.ts +0 -11
  223. package/dist/components/scroll-area/index.js +0 -2
  224. package/dist/components/select/index.cjs +0 -31
  225. package/dist/components/select/index.d.cts +0 -22
  226. package/dist/components/select/index.d.ts +0 -22
  227. package/dist/components/select/index.js +0 -2
  228. package/dist/components/separator/index.cjs +0 -11
  229. package/dist/components/separator/index.d.cts +0 -8
  230. package/dist/components/separator/index.d.ts +0 -8
  231. package/dist/components/separator/index.js +0 -2
  232. package/dist/components/sheet/index.cjs +0 -39
  233. package/dist/components/sheet/index.d.cts +0 -42
  234. package/dist/components/sheet/index.d.ts +0 -42
  235. package/dist/components/sheet/index.js +0 -2
  236. package/dist/components/sidebar/index.cjs +0 -148
  237. package/dist/components/sidebar/index.d.cts +0 -135
  238. package/dist/components/sidebar/index.d.ts +0 -135
  239. package/dist/components/sidebar/index.js +0 -43
  240. package/dist/components/skeleton/index.cjs +0 -11
  241. package/dist/components/skeleton/index.d.cts +0 -7
  242. package/dist/components/skeleton/index.d.ts +0 -7
  243. package/dist/components/skeleton/index.js +0 -2
  244. package/dist/components/sortable/index.cjs +0 -27
  245. package/dist/components/sortable/index.d.cts +0 -50
  246. package/dist/components/sortable/index.d.ts +0 -50
  247. package/dist/components/sortable/index.js +0 -2
  248. package/dist/components/spinner/index.cjs +0 -11
  249. package/dist/components/spinner/index.d.cts +0 -7
  250. package/dist/components/spinner/index.d.ts +0 -7
  251. package/dist/components/spinner/index.js +0 -2
  252. package/dist/components/status/index.cjs +0 -19
  253. package/dist/components/status/index.d.cts +0 -25
  254. package/dist/components/status/index.d.ts +0 -25
  255. package/dist/components/status/index.js +0 -2
  256. package/dist/components/stepper/index.cjs +0 -124
  257. package/dist/components/stepper/index.d.cts +0 -164
  258. package/dist/components/stepper/index.d.ts +0 -164
  259. package/dist/components/stepper/index.js +0 -43
  260. package/dist/components/switch/index.cjs +0 -11
  261. package/dist/components/switch/index.d.cts +0 -19
  262. package/dist/components/switch/index.d.ts +0 -19
  263. package/dist/components/switch/index.js +0 -2
  264. package/dist/components/tabs/index.cjs +0 -23
  265. package/dist/components/tabs/index.d.cts +0 -17
  266. package/dist/components/tabs/index.d.ts +0 -17
  267. package/dist/components/tabs/index.js +0 -2
  268. package/dist/components/textarea/index.cjs +0 -11
  269. package/dist/components/textarea/index.d.cts +0 -9
  270. package/dist/components/textarea/index.d.ts +0 -9
  271. package/dist/components/textarea/index.js +0 -2
  272. package/dist/components/timeline/index.cjs +0 -45
  273. package/dist/components/timeline/index.d.cts +0 -63
  274. package/dist/components/timeline/index.d.ts +0 -63
  275. package/dist/components/timeline/index.js +0 -4
  276. package/dist/components/toaster/index.cjs +0 -56
  277. package/dist/components/toaster/index.d.cts +0 -8
  278. package/dist/components/toaster/index.d.ts +0 -8
  279. package/dist/components/toaster/index.js +0 -43
  280. package/dist/components/tooltip/index.cjs +0 -19
  281. package/dist/components/tooltip/index.d.cts +0 -12
  282. package/dist/components/tooltip/index.d.ts +0 -12
  283. package/dist/components/tooltip/index.js +0 -2
  284. package/dist/components/typing-text/index.cjs +0 -11
  285. package/dist/components/typing-text/index.d.cts +0 -41
  286. package/dist/components/typing-text/index.d.ts +0 -41
  287. package/dist/components/typing-text/index.js +0 -2
  288. package/dist/components/word-rotate/index.cjs +0 -11
  289. package/dist/components/word-rotate/index.d.cts +0 -30
  290. package/dist/components/word-rotate/index.d.ts +0 -30
  291. package/dist/components/word-rotate/index.js +0 -2
  292. package/dist/direction-CUOPDLCj.d.cts +0 -7
  293. package/dist/direction-CUOPDLCj.d.ts +0 -7
  294. package/dist/popover-trigger-Cf4PPj0z.d.cts +0 -14
  295. package/dist/popover-trigger-Cf4PPj0z.d.ts +0 -14
  296. package/dist/select-Bf6XQtt-.d.cts +0 -12
  297. package/dist/select-Bf6XQtt-.d.ts +0 -12
  298. package/dist/tooltip-content-DqtogPBq.d.cts +0 -8
  299. package/dist/tooltip-content-DqtogPBq.d.ts +0 -8
@@ -1,2831 +0,0 @@
1
- import { Tooltip, TooltipTrigger, TooltipContent } from './chunk-U7XZJQ4O.js';
2
- import { Spinner } from './chunk-P5IUC7HJ.js';
3
- import { useDirection, useComposedRefs as useComposedRefs$1 } from './chunk-VK2FJ65F.js';
4
- import { Select, SelectContent, SelectItem } from './chunk-XKCLVPUC.js';
5
- import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription } from './chunk-H5NHGMSQ.js';
6
- import { Skeleton } from './chunk-X7WREEFD.js';
7
- import { Input } from './chunk-S3ZUFD6U.js';
8
- import { Popover, PopoverTrigger, PopoverContent } from './chunk-IZU3KULT.js';
9
- import { Separator } from './chunk-A72LE53B.js';
10
- import { useComposedRefs, useIsMobile } from './chunk-P4IL77YC.js';
11
- import { useLazyRef, useAsRef, useIsomorphicLayoutEffect } from './chunk-G24PWQKG.js';
12
- import { cn } from './chunk-ZD2QRAOX.js';
13
- import * as React16 from 'react';
14
- import { Slot as Slot$1 } from '@radix-ui/react-slot';
15
- import { Direction, Slot, Slider } from 'radix-ui';
16
- import { jsx, jsxs } from 'react/jsx-runtime';
17
- import { PipetteIcon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon, PanelLeftIcon } from 'lucide-react';
18
- import { cva } from 'class-variance-authority';
19
- import { Toaster as Toaster$1 } from 'sonner';
20
- export { toast } from 'sonner';
21
-
22
- function VisuallyHiddenInput(props) {
23
- const { control, value, checked, bubbles = true, type = "hidden", style, ...inputProps } = props;
24
- const isCheckInput = React16.useMemo(() => type === "checkbox" || type === "radio" || type === "switch", [type]);
25
- const inputRef = React16.useRef(null);
26
- const prevValueRef = React16.useRef({
27
- value: isCheckInput ? checked : value,
28
- previous: isCheckInput ? checked : value
29
- });
30
- const prevValue = React16.useMemo(() => {
31
- const currentValue = isCheckInput ? checked : value;
32
- if (prevValueRef.current.value !== currentValue) {
33
- prevValueRef.current.previous = prevValueRef.current.value;
34
- prevValueRef.current.value = currentValue;
35
- }
36
- return prevValueRef.current.previous;
37
- }, [isCheckInput, value, checked]);
38
- const [controlSize, setControlSize] = React16.useState({});
39
- React16.useLayoutEffect(() => {
40
- if (!control) {
41
- setControlSize({});
42
- return;
43
- }
44
- setControlSize({
45
- width: control.offsetWidth,
46
- height: control.offsetHeight
47
- });
48
- if (typeof window === "undefined") return;
49
- const resizeObserver = new ResizeObserver((entries) => {
50
- if (!Array.isArray(entries) || !entries.length) return;
51
- const entry = entries[0];
52
- if (!entry) return;
53
- let width;
54
- let height;
55
- if ("borderBoxSize" in entry) {
56
- const borderSizeEntry = entry.borderBoxSize;
57
- const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
58
- width = borderSize.inlineSize;
59
- height = borderSize.blockSize;
60
- } else {
61
- width = control.offsetWidth;
62
- height = control.offsetHeight;
63
- }
64
- setControlSize({ width, height });
65
- });
66
- resizeObserver.observe(control, { box: "border-box" });
67
- return () => {
68
- resizeObserver.disconnect();
69
- };
70
- }, [control]);
71
- React16.useEffect(() => {
72
- const input = inputRef.current;
73
- if (!input) return;
74
- const inputProto = window.HTMLInputElement.prototype;
75
- const propertyKey = isCheckInput ? "checked" : "value";
76
- const eventType = isCheckInput ? "click" : "input";
77
- const currentValue = isCheckInput ? checked : value;
78
- const serializedCurrentValue = isCheckInput ? checked : typeof value === "object" && value !== null ? JSON.stringify(value) : value;
79
- const descriptor = Object.getOwnPropertyDescriptor(inputProto, propertyKey);
80
- const setter = descriptor?.set;
81
- if (prevValue !== currentValue && setter) {
82
- const event = new Event(eventType, { bubbles });
83
- setter.call(input, serializedCurrentValue);
84
- input.dispatchEvent(event);
85
- }
86
- }, [prevValue, value, checked, bubbles, isCheckInput]);
87
- const composedStyle = React16.useMemo(() => {
88
- return {
89
- ...style,
90
- ...controlSize.width !== void 0 && controlSize.height !== void 0 ? controlSize : {},
91
- border: 0,
92
- clip: "rect(0 0 0 0)",
93
- clipPath: "inset(50%)",
94
- height: "1px",
95
- margin: "-1px",
96
- overflow: "hidden",
97
- padding: 0,
98
- position: "absolute",
99
- whiteSpace: "nowrap",
100
- width: "1px"
101
- };
102
- }, [style, controlSize]);
103
- return /* @__PURE__ */ jsx(
104
- "input",
105
- {
106
- type,
107
- ...inputProps,
108
- ref: inputRef,
109
- "aria-hidden": isCheckInput,
110
- tabIndex: -1,
111
- defaultChecked: isCheckInput ? checked : void 0,
112
- style: composedStyle
113
- }
114
- );
115
- }
116
-
117
- // src/components/color-picker/color-picker.constants.ts
118
- var COLOR_PICKER_ROOT_NAME = "ColorPicker";
119
- var COLOR_PICKER_IMPL_NAME = "ColorPickerImpl";
120
- var COLOR_PICKER_TRIGGER_NAME = "ColorPickerTrigger";
121
- var COLOR_PICKER_CONTENT_NAME = "ColorPickerContent";
122
- var COLOR_PICKER_AREA_NAME = "ColorPickerArea";
123
- var COLOR_PICKER_HUE_SLIDER_NAME = "ColorPickerHueSlider";
124
- var COLOR_PICKER_ALPHA_SLIDER_NAME = "ColorPickerAlphaSlider";
125
- var COLOR_PICKER_SWATCH_NAME = "ColorPickerSwatch";
126
- var COLOR_PICKER_EYE_DROPPER_NAME = "ColorPickerEyeDropper";
127
- var COLOR_PICKER_FORMAT_SELECT_NAME = "ColorPickerFormatSelect";
128
- var COLOR_PICKER_INPUT_NAME = "ColorPickerInput";
129
- var COLOR_FORMATS = ["hex", "rgb", "hsl", "hsb"];
130
- var ColorPickerContext = React16.createContext(null);
131
- function useColorPickerContext(consumerName) {
132
- const context = React16.useContext(ColorPickerContext);
133
- if (!context) {
134
- throw new Error(`\`${consumerName}\` must be used within \`${COLOR_PICKER_ROOT_NAME}\``);
135
- }
136
- return context;
137
- }
138
-
139
- // src/components/color-picker/color-picker.utils.ts
140
- function hexToRgb(hex, alpha) {
141
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
142
- return result ? {
143
- r: Number.parseInt(result[1] ?? "0", 16),
144
- g: Number.parseInt(result[2] ?? "0", 16),
145
- b: Number.parseInt(result[3] ?? "0", 16),
146
- a: alpha ?? 1
147
- } : { r: 0, g: 0, b: 0, a: alpha ?? 1 };
148
- }
149
- function rgbToHex(color) {
150
- const toHex = (n) => {
151
- const hex = Math.round(n).toString(16);
152
- return hex.length === 1 ? `0${hex}` : hex;
153
- };
154
- return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`;
155
- }
156
- function rgbToHsv(color) {
157
- const r = color.r / 255;
158
- const g = color.g / 255;
159
- const b = color.b / 255;
160
- const max = Math.max(r, g, b);
161
- const min = Math.min(r, g, b);
162
- const diff = max - min;
163
- let h = 0;
164
- if (diff !== 0) {
165
- switch (max) {
166
- case r:
167
- h = (g - b) / diff % 6;
168
- break;
169
- case g:
170
- h = (b - r) / diff + 2;
171
- break;
172
- case b:
173
- h = (r - g) / diff + 4;
174
- break;
175
- }
176
- }
177
- h = Math.round(h * 60);
178
- if (h < 0) h += 360;
179
- const s = max === 0 ? 0 : diff / max;
180
- return {
181
- h,
182
- s: Math.round(s * 100),
183
- v: Math.round(max * 100),
184
- a: color.a
185
- };
186
- }
187
- function hsvToRgb(hsv) {
188
- const h = hsv.h / 360;
189
- const s = hsv.s / 100;
190
- const v = hsv.v / 100;
191
- const i = Math.floor(h * 6);
192
- const f = h * 6 - i;
193
- const p = v * (1 - s);
194
- const q = v * (1 - f * s);
195
- const t = v * (1 - (1 - f) * s);
196
- let r;
197
- let g;
198
- let b;
199
- switch (i % 6) {
200
- case 0: {
201
- r = v;
202
- g = t;
203
- b = p;
204
- break;
205
- }
206
- case 1: {
207
- r = q;
208
- g = v;
209
- b = p;
210
- break;
211
- }
212
- case 2: {
213
- r = p;
214
- g = v;
215
- b = t;
216
- break;
217
- }
218
- case 3: {
219
- r = p;
220
- g = q;
221
- b = v;
222
- break;
223
- }
224
- case 4: {
225
- r = t;
226
- g = p;
227
- b = v;
228
- break;
229
- }
230
- case 5: {
231
- r = v;
232
- g = p;
233
- b = q;
234
- break;
235
- }
236
- default: {
237
- r = 0;
238
- g = 0;
239
- b = 0;
240
- }
241
- }
242
- return {
243
- r: Math.round(r * 255),
244
- g: Math.round(g * 255),
245
- b: Math.round(b * 255),
246
- a: hsv.a
247
- };
248
- }
249
- function rgbToHsl(color) {
250
- const r = color.r / 255;
251
- const g = color.g / 255;
252
- const b = color.b / 255;
253
- const max = Math.max(r, g, b);
254
- const min = Math.min(r, g, b);
255
- const diff = max - min;
256
- const sum = max + min;
257
- const l = sum / 2;
258
- let h = 0;
259
- let s = 0;
260
- if (diff !== 0) {
261
- s = l > 0.5 ? diff / (2 - sum) : diff / sum;
262
- if (max === r) {
263
- h = (g - b) / diff + (g < b ? 6 : 0);
264
- } else if (max === g) {
265
- h = (b - r) / diff + 2;
266
- } else if (max === b) {
267
- h = (r - g) / diff + 4;
268
- }
269
- h /= 6;
270
- }
271
- return {
272
- h: Math.round(h * 360),
273
- s: Math.round(s * 100),
274
- l: Math.round(l * 100)
275
- };
276
- }
277
- function hslToRgb(hsl, alpha = 1) {
278
- const h = hsl.h / 360;
279
- const s = hsl.s / 100;
280
- const l = hsl.l / 100;
281
- const c = (1 - Math.abs(2 * l - 1)) * s;
282
- const x = c * (1 - Math.abs(h * 6 % 2 - 1));
283
- const m = l - c / 2;
284
- let r = 0;
285
- let g = 0;
286
- let b = 0;
287
- if (h >= 0 && h < 1 / 6) {
288
- r = c;
289
- g = x;
290
- b = 0;
291
- } else if (h >= 1 / 6 && h < 2 / 6) {
292
- r = x;
293
- g = c;
294
- b = 0;
295
- } else if (h >= 2 / 6 && h < 3 / 6) {
296
- r = 0;
297
- g = c;
298
- b = x;
299
- } else if (h >= 3 / 6 && h < 4 / 6) {
300
- r = 0;
301
- g = x;
302
- b = c;
303
- } else if (h >= 4 / 6 && h < 5 / 6) {
304
- r = x;
305
- g = 0;
306
- b = c;
307
- } else if (h >= 5 / 6 && h < 1) {
308
- r = c;
309
- g = 0;
310
- b = x;
311
- }
312
- return {
313
- r: Math.round((r + m) * 255),
314
- g: Math.round((g + m) * 255),
315
- b: Math.round((b + m) * 255),
316
- a: alpha
317
- };
318
- }
319
- function colorToString(color, format = "hex") {
320
- switch (format) {
321
- case "hex":
322
- return rgbToHex(color);
323
- case "rgb":
324
- return color.a < 1 ? `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a})` : `rgb(${color.r}, ${color.g}, ${color.b})`;
325
- case "hsl": {
326
- const hsl = rgbToHsl(color);
327
- return color.a < 1 ? `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${color.a})` : `hsl(${hsl.h}, ${hsl.s}%, ${hsl.l}%)`;
328
- }
329
- case "hsb": {
330
- const hsv = rgbToHsv(color);
331
- return color.a < 1 ? `hsba(${hsv.h}, ${hsv.s}%, ${hsv.v}%, ${color.a})` : `hsb(${hsv.h}, ${hsv.s}%, ${hsv.v}%)`;
332
- }
333
- default:
334
- return rgbToHex(color);
335
- }
336
- }
337
- function parseColorString(value) {
338
- const trimmed = value.trim();
339
- if (trimmed.startsWith("#")) {
340
- const hexMatch = trimmed.match(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/);
341
- if (hexMatch) return hexToRgb(trimmed);
342
- }
343
- const rgbMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);
344
- if (rgbMatch) {
345
- return {
346
- r: Number.parseInt(rgbMatch[1] ?? "0", 10),
347
- g: Number.parseInt(rgbMatch[2] ?? "0", 10),
348
- b: Number.parseInt(rgbMatch[3] ?? "0", 10),
349
- a: rgbMatch[4] ? Number.parseFloat(rgbMatch[4]) : 1
350
- };
351
- }
352
- const hslMatch = trimmed.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+))?\s*\)$/);
353
- if (hslMatch) {
354
- const h = Number.parseInt(hslMatch[1] ?? "0", 10);
355
- const s = Number.parseInt(hslMatch[2] ?? "0", 10) / 100;
356
- const l = Number.parseInt(hslMatch[3] ?? "0", 10) / 100;
357
- const a = hslMatch[4] ? Number.parseFloat(hslMatch[4]) : 1;
358
- const c = (1 - Math.abs(2 * l - 1)) * s;
359
- const x = c * (1 - Math.abs(h / 60 % 2 - 1));
360
- const m = l - c / 2;
361
- let r = 0;
362
- let g = 0;
363
- let b = 0;
364
- if (h >= 0 && h < 60) {
365
- r = c;
366
- g = x;
367
- } else if (h >= 60 && h < 120) {
368
- r = x;
369
- g = c;
370
- } else if (h >= 120 && h < 180) {
371
- g = c;
372
- b = x;
373
- } else if (h >= 180 && h < 240) {
374
- g = x;
375
- b = c;
376
- } else if (h >= 240 && h < 300) {
377
- r = x;
378
- b = c;
379
- } else if (h >= 300 && h < 360) {
380
- r = c;
381
- b = x;
382
- }
383
- return {
384
- r: Math.round((r + m) * 255),
385
- g: Math.round((g + m) * 255),
386
- b: Math.round((b + m) * 255),
387
- a
388
- };
389
- }
390
- const hsbMatch = trimmed.match(/^hsba?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+))?\s*\)$/);
391
- if (hsbMatch) {
392
- const h = Number.parseInt(hsbMatch[1] ?? "0", 10);
393
- const s = Number.parseInt(hsbMatch[2] ?? "0", 10);
394
- const v = Number.parseInt(hsbMatch[3] ?? "0", 10);
395
- const a = hsbMatch[4] ? Number.parseFloat(hsbMatch[4]) : 1;
396
- return hsvToRgb({ h, s, v, a });
397
- }
398
- return null;
399
- }
400
-
401
- // src/components/color-picker/color-picker.store.tsx
402
- var ColorPickerStoreContext = React16.createContext(null);
403
- function useColorPickerStoreContext(consumerName) {
404
- const context = React16.useContext(ColorPickerStoreContext);
405
- if (!context) {
406
- throw new Error(`\`${consumerName}\` must be used within \`ColorPicker\``);
407
- }
408
- return context;
409
- }
410
- function useColorPickerStore(selector) {
411
- const store = useColorPickerStoreContext("useColorPickerStore");
412
- const getSnapshot = React16.useCallback(() => selector(store.getState()), [store, selector]);
413
- return React16.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
414
- }
415
- function createColorPickerStore(listenersRef, stateRef, propsRef) {
416
- const store = {
417
- subscribe: (cb) => {
418
- listenersRef.current.add(cb);
419
- return () => listenersRef.current.delete(cb);
420
- },
421
- getState: () => stateRef.current,
422
- setColor: (value) => {
423
- if (Object.is(stateRef.current.color, value)) return;
424
- const prevState = { ...stateRef.current };
425
- stateRef.current.color = value;
426
- if (propsRef.current.onValueChange) {
427
- propsRef.current.onValueChange(colorToString(value, prevState.format));
428
- }
429
- store.notify();
430
- },
431
- setHsv: (value) => {
432
- if (Object.is(stateRef.current.hsv, value)) return;
433
- const prevState = { ...stateRef.current };
434
- stateRef.current.hsv = value;
435
- if (propsRef.current.onValueChange) {
436
- propsRef.current.onValueChange(colorToString(hsvToRgb(value), prevState.format));
437
- }
438
- store.notify();
439
- },
440
- setOpen: (value) => {
441
- if (Object.is(stateRef.current.open, value)) return;
442
- stateRef.current.open = value;
443
- propsRef.current.onOpenChange?.(value);
444
- store.notify();
445
- },
446
- setFormat: (value) => {
447
- if (Object.is(stateRef.current.format, value)) return;
448
- stateRef.current.format = value;
449
- propsRef.current.onFormatChange?.(value);
450
- store.notify();
451
- },
452
- notify: () => {
453
- for (const cb of listenersRef.current) cb();
454
- }
455
- };
456
- return store;
457
- }
458
- function ColorPicker(props) {
459
- const {
460
- value: valueProp,
461
- defaultValue = "#000000",
462
- onValueChange,
463
- format: formatProp,
464
- defaultFormat = "hex",
465
- onFormatChange,
466
- defaultOpen,
467
- open: openProp,
468
- onOpenChange,
469
- modal,
470
- name,
471
- disabled,
472
- inline,
473
- readOnly,
474
- required,
475
- ...rootProps
476
- } = props;
477
- const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
478
- const stateRef = useLazyRef(() => {
479
- const colorString = valueProp ?? defaultValue;
480
- const color = hexToRgb(colorString);
481
- return {
482
- color,
483
- hsv: rgbToHsv(color),
484
- open: openProp ?? defaultOpen ?? false,
485
- format: formatProp ?? defaultFormat
486
- };
487
- });
488
- const propsRef = useAsRef({ onValueChange, onOpenChange, onFormatChange });
489
- const store = React16.useMemo(
490
- () => createColorPickerStore(listenersRef, stateRef, propsRef),
491
- [listenersRef, stateRef, propsRef]
492
- );
493
- return /* @__PURE__ */ jsx(ColorPickerStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx(
494
- ColorPickerImpl,
495
- {
496
- ...rootProps,
497
- value: valueProp,
498
- defaultOpen,
499
- open: openProp,
500
- modal,
501
- name,
502
- disabled,
503
- inline,
504
- readOnly,
505
- required
506
- }
507
- ) });
508
- }
509
- function ColorPickerImpl(props) {
510
- const {
511
- value: valueProp,
512
- dir: dirProp,
513
- defaultOpen,
514
- open: openProp,
515
- modal,
516
- name,
517
- ref,
518
- asChild,
519
- disabled,
520
- inline,
521
- readOnly,
522
- required,
523
- ...rootProps
524
- } = props;
525
- const store = useColorPickerStoreContext(COLOR_PICKER_IMPL_NAME);
526
- const dir = Direction.useDirection(dirProp);
527
- const [formTrigger, setFormTrigger] = React16.useState(null);
528
- const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
529
- const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
530
- useIsomorphicLayoutEffect(() => {
531
- if (valueProp !== void 0) {
532
- const currentState = store.getState();
533
- const color = hexToRgb(valueProp, currentState.color.a);
534
- store.setColor(color);
535
- store.setHsv(rgbToHsv(color));
536
- }
537
- }, [valueProp]);
538
- useIsomorphicLayoutEffect(() => {
539
- if (openProp !== void 0) {
540
- store.setOpen(openProp);
541
- }
542
- }, [openProp]);
543
- const contextValue = React16.useMemo(
544
- () => ({ dir, disabled, inline, readOnly, required }),
545
- [dir, disabled, inline, readOnly, required]
546
- );
547
- const value = useColorPickerStore((state) => rgbToHex(state.color));
548
- const open = useColorPickerStore((state) => state.open);
549
- const RootPrimitive = asChild ? Slot.Slot : "div";
550
- if (inline) {
551
- return /* @__PURE__ */ jsxs(ColorPickerContext.Provider, { value: contextValue, children: [
552
- /* @__PURE__ */ jsx(RootPrimitive, { "data-slot": "color-picker", ...rootProps, ref: composedRef }),
553
- isFormControl && /* @__PURE__ */ jsx(
554
- VisuallyHiddenInput,
555
- {
556
- type: "hidden",
557
- control: formTrigger,
558
- name,
559
- value,
560
- disabled,
561
- readOnly,
562
- required
563
- }
564
- )
565
- ] });
566
- }
567
- return /* @__PURE__ */ jsx(ColorPickerContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(Popover, { defaultOpen, open, onOpenChange: store.setOpen, modal, children: [
568
- /* @__PURE__ */ jsx(RootPrimitive, { "data-slot": "color-picker", ...rootProps, ref: composedRef }),
569
- isFormControl && /* @__PURE__ */ jsx(
570
- VisuallyHiddenInput,
571
- {
572
- type: "hidden",
573
- control: formTrigger,
574
- name,
575
- value,
576
- disabled,
577
- readOnly,
578
- required
579
- }
580
- )
581
- ] }) });
582
- }
583
- function ColorPickerTrigger(props) {
584
- const { asChild, disabled, ...triggerProps } = props;
585
- const context = useColorPickerContext(COLOR_PICKER_TRIGGER_NAME);
586
- const isDisabled = disabled || context.disabled;
587
- const TriggerPrimitive = asChild ? Slot.Slot : Button;
588
- return /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, disabled: isDisabled, children: /* @__PURE__ */ jsx(TriggerPrimitive, { "data-slot": "color-picker-trigger", ...triggerProps }) });
589
- }
590
- function ColorPickerContent(props) {
591
- const { asChild, className, children, ...popoverContentProps } = props;
592
- const context = useColorPickerContext(COLOR_PICKER_CONTENT_NAME);
593
- if (context.inline) {
594
- const ContentPrimitive = asChild ? Slot.Slot : "div";
595
- return /* @__PURE__ */ jsx(
596
- ContentPrimitive,
597
- {
598
- "data-slot": "color-picker-content",
599
- ...popoverContentProps,
600
- className: cn("flex w-[340px] flex-col gap-4 p-4", className),
601
- children
602
- }
603
- );
604
- }
605
- return /* @__PURE__ */ jsx(
606
- PopoverContent,
607
- {
608
- "data-slot": "color-picker-content",
609
- asChild,
610
- ...popoverContentProps,
611
- className: cn("flex w-[340px] flex-col gap-4 p-4", className),
612
- children
613
- }
614
- );
615
- }
616
- function ColorPickerArea(props) {
617
- const {
618
- asChild,
619
- onPointerDown: onPointerDownProp,
620
- onPointerMove: onPointerMoveProp,
621
- onPointerUp: onPointerUpProp,
622
- className,
623
- ref,
624
- ...areaProps
625
- } = props;
626
- const propsRef = useAsRef({
627
- onPointerDown: onPointerDownProp,
628
- onPointerMove: onPointerMoveProp,
629
- onPointerUp: onPointerUpProp
630
- });
631
- const context = useColorPickerContext(COLOR_PICKER_AREA_NAME);
632
- const store = useColorPickerStoreContext(COLOR_PICKER_AREA_NAME);
633
- const hsv = useColorPickerStore((state) => state.hsv);
634
- const isDraggingRef = React16.useRef(false);
635
- const areaRef = React16.useRef(null);
636
- const composedRef = useComposedRefs(ref, areaRef);
637
- const updateColorFromPosition = React16.useCallback(
638
- (clientX, clientY) => {
639
- if (!areaRef.current) return;
640
- const rect = areaRef.current.getBoundingClientRect();
641
- const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
642
- const y = Math.max(0, Math.min(1, 1 - (clientY - rect.top) / rect.height));
643
- const newHsv = {
644
- h: hsv?.h ?? 0,
645
- s: Math.round(x * 100),
646
- v: Math.round(y * 100),
647
- a: hsv?.a ?? 1
648
- };
649
- store.setHsv(newHsv);
650
- store.setColor(hsvToRgb(newHsv));
651
- },
652
- [hsv, store]
653
- );
654
- const onPointerDown = React16.useCallback(
655
- (event) => {
656
- if (context.disabled) return;
657
- propsRef.current.onPointerDown?.(event);
658
- if (event.defaultPrevented) return;
659
- isDraggingRef.current = true;
660
- areaRef.current?.setPointerCapture(event.pointerId);
661
- updateColorFromPosition(event.clientX, event.clientY);
662
- },
663
- [context.disabled, updateColorFromPosition, propsRef]
664
- );
665
- const onPointerMove = React16.useCallback(
666
- (event) => {
667
- propsRef.current.onPointerMove?.(event);
668
- if (event.defaultPrevented) return;
669
- if (isDraggingRef.current) updateColorFromPosition(event.clientX, event.clientY);
670
- },
671
- [updateColorFromPosition, propsRef]
672
- );
673
- const onPointerUp = React16.useCallback(
674
- (event) => {
675
- propsRef.current.onPointerUp?.(event);
676
- if (event.defaultPrevented) return;
677
- isDraggingRef.current = false;
678
- areaRef.current?.releasePointerCapture(event.pointerId);
679
- },
680
- [propsRef]
681
- );
682
- const hue = hsv?.h ?? 0;
683
- const backgroundHue = hsvToRgb({ h: hue, s: 100, v: 100, a: 1 });
684
- const AreaPrimitive = asChild ? Slot.Slot : "div";
685
- return /* @__PURE__ */ jsxs(
686
- AreaPrimitive,
687
- {
688
- "data-slot": "color-picker-area",
689
- ...areaProps,
690
- className: cn(
691
- "relative h-40 w-full cursor-crosshair touch-none rounded-sm border",
692
- context.disabled && "pointer-events-none opacity-50",
693
- className
694
- ),
695
- ref: composedRef,
696
- onPointerDown,
697
- onPointerMove,
698
- onPointerUp,
699
- children: [
700
- /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 overflow-hidden rounded-sm", children: [
701
- /* @__PURE__ */ jsx(
702
- "div",
703
- {
704
- className: "absolute inset-0",
705
- style: { backgroundColor: `rgb(${backgroundHue.r}, ${backgroundHue.g}, ${backgroundHue.b})` }
706
- }
707
- ),
708
- /* @__PURE__ */ jsx("div", { className: "absolute inset-0", style: { background: "linear-gradient(to right, #fff, transparent)" } }),
709
- /* @__PURE__ */ jsx("div", { className: "absolute inset-0", style: { background: "linear-gradient(to bottom, transparent, #000)" } })
710
- ] }),
711
- /* @__PURE__ */ jsx(
712
- "div",
713
- {
714
- className: "absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm",
715
- style: { left: `${hsv?.s ?? 0}%`, top: `${100 - (hsv?.v ?? 0)}%` }
716
- }
717
- )
718
- ]
719
- }
720
- );
721
- }
722
- function ColorPickerHueSlider(props) {
723
- const { className, ...sliderProps } = props;
724
- const context = useColorPickerContext(COLOR_PICKER_HUE_SLIDER_NAME);
725
- const store = useColorPickerStoreContext(COLOR_PICKER_HUE_SLIDER_NAME);
726
- const hsv = useColorPickerStore((state) => state.hsv);
727
- const onValueChange = React16.useCallback(
728
- (values) => {
729
- const newHsv = { h: values[0] ?? 0, s: hsv?.s ?? 0, v: hsv?.v ?? 0, a: hsv?.a ?? 1 };
730
- store.setHsv(newHsv);
731
- store.setColor(hsvToRgb(newHsv));
732
- },
733
- [hsv, store]
734
- );
735
- return /* @__PURE__ */ jsxs(
736
- Slider.Root,
737
- {
738
- "data-slot": "color-picker-hue-slider",
739
- ...sliderProps,
740
- max: 360,
741
- step: 1,
742
- className: cn("relative flex w-full touch-none items-center select-none", className),
743
- value: [hsv?.h ?? 0],
744
- onValueChange,
745
- disabled: context.disabled,
746
- children: [
747
- /* @__PURE__ */ jsx(Slider.Track, { className: "relative h-3 w-full grow overflow-hidden rounded-full bg-[linear-gradient(to_right,#ff0000_0%,#ffff00_16.66%,#00ff00_33.33%,#00ffff_50%,#0000ff_66.66%,#ff00ff_83.33%,#ff0000_100%)]", children: /* @__PURE__ */ jsx(Slider.Range, { className: "absolute h-full" }) }),
748
- /* @__PURE__ */ jsx(Slider.Thumb, { className: "border-primary/50 bg-background focus-visible:ring-ring block size-4 rounded-full border shadow transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50" })
749
- ]
750
- }
751
- );
752
- }
753
- function ColorPickerAlphaSlider(props) {
754
- const { className, ...sliderProps } = props;
755
- const context = useColorPickerContext(COLOR_PICKER_ALPHA_SLIDER_NAME);
756
- const store = useColorPickerStoreContext(COLOR_PICKER_ALPHA_SLIDER_NAME);
757
- const color = useColorPickerStore((state) => state.color);
758
- const hsv = useColorPickerStore((state) => state.hsv);
759
- const onValueChange = React16.useCallback(
760
- (values) => {
761
- const alpha = (values[0] ?? 0) / 100;
762
- store.setColor({ ...color, a: alpha });
763
- store.setHsv({ ...hsv, a: alpha });
764
- },
765
- [color, hsv, store]
766
- );
767
- const gradientColor = `rgb(${color?.r ?? 0}, ${color?.g ?? 0}, ${color?.b ?? 0})`;
768
- return /* @__PURE__ */ jsxs(
769
- Slider.Root,
770
- {
771
- "data-slot": "color-picker-alpha-slider",
772
- ...sliderProps,
773
- max: 100,
774
- step: 1,
775
- disabled: context.disabled,
776
- className: cn("relative flex w-full touch-none items-center select-none", className),
777
- value: [Math.round((color?.a ?? 1) * 100)],
778
- onValueChange,
779
- children: [
780
- /* @__PURE__ */ jsxs(
781
- Slider.Track,
782
- {
783
- className: "relative h-3 w-full grow overflow-hidden rounded-full",
784
- style: {
785
- background: "linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)",
786
- backgroundSize: "8px 8px",
787
- backgroundPosition: "0 0, 0 4px, 4px -4px, -4px 0px"
788
- },
789
- children: [
790
- /* @__PURE__ */ jsx(
791
- "div",
792
- {
793
- className: "absolute inset-0 rounded-full",
794
- style: { background: `linear-gradient(to right, transparent, ${gradientColor})` }
795
- }
796
- ),
797
- /* @__PURE__ */ jsx(Slider.Range, { className: "absolute h-full" })
798
- ]
799
- }
800
- ),
801
- /* @__PURE__ */ jsx(Slider.Thumb, { className: "border-primary/50 bg-background focus-visible:ring-ring block size-4 rounded-full border shadow transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50" })
802
- ]
803
- }
804
- );
805
- }
806
- function ColorPickerSwatch(props) {
807
- const { asChild, className, ...swatchProps } = props;
808
- const context = useColorPickerContext(COLOR_PICKER_SWATCH_NAME);
809
- const color = useColorPickerStore((state) => state.color);
810
- const format = useColorPickerStore((state) => state.format);
811
- const backgroundStyle = React16.useMemo(() => {
812
- if (!color) {
813
- return {
814
- background: "linear-gradient(to bottom right, transparent calc(50% - 1px), hsl(var(--destructive)) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) no-repeat"
815
- };
816
- }
817
- const colorString = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a})`;
818
- if (color.a < 1) {
819
- return {
820
- background: `linear-gradient(${colorString}, ${colorString}), repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0% 50% / 8px 8px`
821
- };
822
- }
823
- return { backgroundColor: colorString };
824
- }, [color]);
825
- const ariaLabel = !color ? "No color selected" : `Current color: ${colorToString(color, format)}`;
826
- const SwatchPrimitive = asChild ? Slot.Slot : "div";
827
- return /* @__PURE__ */ jsx(
828
- SwatchPrimitive,
829
- {
830
- role: "img",
831
- "aria-label": ariaLabel,
832
- "data-slot": "color-picker-swatch",
833
- ...swatchProps,
834
- className: cn("box-border size-8 rounded-sm border shadow-sm", context.disabled && "opacity-50", className),
835
- style: { ...backgroundStyle, forcedColorAdjust: "none" }
836
- }
837
- );
838
- }
839
- function ColorPickerEyeDropper(props) {
840
- const { size: sizeProp, children, disabled, ...buttonProps } = props;
841
- const context = useColorPickerContext(COLOR_PICKER_EYE_DROPPER_NAME);
842
- const store = useColorPickerStoreContext(COLOR_PICKER_EYE_DROPPER_NAME);
843
- const color = useColorPickerStore((state) => state.color);
844
- const isDisabled = disabled || context.disabled;
845
- const onEyeDropper = React16.useCallback(async () => {
846
- if (!window.EyeDropper) return;
847
- try {
848
- const eyeDropper = new window.EyeDropper();
849
- const result = await eyeDropper.open();
850
- if (result.sRGBHex) {
851
- const newColor = hexToRgb(result.sRGBHex, color?.a ?? 1);
852
- store.setColor(newColor);
853
- store.setHsv(rgbToHsv(newColor));
854
- }
855
- } catch (error) {
856
- console.warn("EyeDropper error:", error);
857
- }
858
- }, [color, store]);
859
- const hasEyeDropper = typeof window !== "undefined" && !!window.EyeDropper;
860
- if (!hasEyeDropper) return null;
861
- const size = sizeProp ?? (children ? "default" : "icon");
862
- return /* @__PURE__ */ jsx(
863
- Button,
864
- {
865
- "data-slot": "color-picker-eye-dropper",
866
- ...buttonProps,
867
- variant: "outline",
868
- size,
869
- onClick: onEyeDropper,
870
- disabled: isDisabled,
871
- children: children ?? /* @__PURE__ */ jsx(PipetteIcon, {})
872
- }
873
- );
874
- }
875
- function ColorPickerFormatSelect(props) {
876
- const { size, disabled, className, ...selectProps } = props;
877
- const context = useColorPickerContext(COLOR_PICKER_FORMAT_SELECT_NAME);
878
- const store = useColorPickerStoreContext(COLOR_PICKER_FORMAT_SELECT_NAME);
879
- const isDisabled = disabled || context.disabled;
880
- const format = useColorPickerStore((state) => state.format);
881
- const onFormatChange = React16.useCallback(
882
- (value) => {
883
- store.setFormat(value);
884
- },
885
- [store]
886
- );
887
- return /* @__PURE__ */ jsx(
888
- Select,
889
- {
890
- "data-slot": "color-picker-format-select",
891
- ...selectProps,
892
- value: format,
893
- onValueChange: onFormatChange,
894
- disabled: isDisabled,
895
- size: size ?? "sm",
896
- className: cn(className),
897
- children: /* @__PURE__ */ jsx(SelectContent, { children: COLOR_FORMATS.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f, children: f.toUpperCase() }, f)) })
898
- }
899
- );
900
- }
901
- var inputGroupItemVariants = cva(
902
- "h-8 [-moz-appearance:textfield] focus-visible:z-10 focus-visible:ring-1 [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none",
903
- {
904
- variants: {
905
- position: {
906
- first: "rounded-e-none",
907
- middle: "-ms-px rounded-none border-l-0",
908
- last: "-ms-px rounded-s-none border-l-0",
909
- isolated: ""
910
- }
911
- },
912
- defaultVariants: {
913
- position: "isolated"
914
- }
915
- }
916
- );
917
- function ColorPickerInput(props) {
918
- const store = useColorPickerStoreContext(COLOR_PICKER_INPUT_NAME);
919
- const context = useColorPickerContext(COLOR_PICKER_INPUT_NAME);
920
- const color = useColorPickerStore((state) => state.color);
921
- const format = useColorPickerStore((state) => state.format);
922
- const hsv = useColorPickerStore((state) => state.hsv);
923
- const onColorChange = React16.useCallback(
924
- (newColor) => {
925
- const newHsv = rgbToHsv(newColor);
926
- store.setColor(newColor);
927
- store.setHsv(newHsv);
928
- },
929
- [store]
930
- );
931
- if (format === "hex") {
932
- return /* @__PURE__ */ jsx(HexInput, { color, onColorChange, context, ...props });
933
- }
934
- if (format === "rgb") {
935
- return /* @__PURE__ */ jsx(RgbInput, { color, onColorChange, context, ...props });
936
- }
937
- if (format === "hsl") {
938
- return /* @__PURE__ */ jsx(HslInput, { color, onColorChange, context, ...props });
939
- }
940
- if (format === "hsb") {
941
- return /* @__PURE__ */ jsx(HsbInput, { hsv, onColorChange, context, ...props });
942
- }
943
- }
944
- function InputGroupItem({ className, position, ...props }) {
945
- return /* @__PURE__ */ jsx(Input, { "data-slot": "color-picker-input", className: cn(inputGroupItemVariants({ position, className })), ...props });
946
- }
947
- function HexInput(props) {
948
- const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
949
- const hexValue = rgbToHex(color);
950
- const alphaValue = Math.round((color?.a ?? 1) * 100);
951
- const onHexChange = React16.useCallback(
952
- (event) => {
953
- const value = event.target.value;
954
- const parsedColor = parseColorString(value);
955
- if (parsedColor) {
956
- onColorChange({ ...parsedColor, a: color?.a ?? 1 });
957
- }
958
- },
959
- [color, onColorChange]
960
- );
961
- const onAlphaChange = React16.useCallback(
962
- (event) => {
963
- const value = Number.parseInt(event.target.value, 10);
964
- if (!Number.isNaN(value) && value >= 0 && value <= 100) {
965
- onColorChange({ ...color, a: value / 100 });
966
- }
967
- },
968
- [color, onColorChange]
969
- );
970
- if (withoutAlpha) {
971
- return /* @__PURE__ */ jsx(
972
- InputGroupItem,
973
- {
974
- "aria-label": "Hex color value",
975
- position: "isolated",
976
- ...inputProps,
977
- placeholder: "#000000",
978
- className: cn("font-code", className),
979
- value: hexValue,
980
- onChange: onHexChange,
981
- disabled: context.disabled
982
- }
983
- );
984
- }
985
- return /* @__PURE__ */ jsxs("div", { "data-slot": "color-picker-input-wrapper", className: cn("flex flex-1 items-center", className), children: [
986
- /* @__PURE__ */ jsx(
987
- InputGroupItem,
988
- {
989
- "aria-label": "Hex color value",
990
- position: "first",
991
- ...inputProps,
992
- placeholder: "#000000",
993
- className: "font-code flex-1",
994
- value: hexValue,
995
- onChange: onHexChange,
996
- disabled: context.disabled
997
- }
998
- ),
999
- /* @__PURE__ */ jsx(
1000
- InputGroupItem,
1001
- {
1002
- "aria-label": "Alpha transparency percentage",
1003
- position: "last",
1004
- ...inputProps,
1005
- placeholder: "100",
1006
- inputMode: "numeric",
1007
- pattern: "[0-9]*",
1008
- min: "0",
1009
- max: "100",
1010
- className: "w-14",
1011
- value: alphaValue,
1012
- onChange: onAlphaChange,
1013
- disabled: context.disabled
1014
- }
1015
- )
1016
- ] });
1017
- }
1018
- function RgbInput(props) {
1019
- const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1020
- const rValue = Math.round(color?.r ?? 0);
1021
- const gValue = Math.round(color?.g ?? 0);
1022
- const bValue = Math.round(color?.b ?? 0);
1023
- const alphaValue = Math.round((color?.a ?? 1) * 100);
1024
- const onChannelChange = React16.useCallback(
1025
- (channel, max, isAlpha = false) => (event) => {
1026
- const value = Number.parseInt(event.target.value, 10);
1027
- if (!Number.isNaN(value) && value >= 0 && value <= max) {
1028
- const newValue = isAlpha ? value / 100 : value;
1029
- onColorChange({ ...color, [channel]: newValue });
1030
- }
1031
- },
1032
- [color, onColorChange]
1033
- );
1034
- return /* @__PURE__ */ jsxs("div", { "data-slot": "color-picker-input-wrapper", className: cn("flex flex-1 items-center", className), children: [
1035
- /* @__PURE__ */ jsx(
1036
- InputGroupItem,
1037
- {
1038
- "aria-label": "Red color component (0-255)",
1039
- position: "first",
1040
- ...inputProps,
1041
- placeholder: "0",
1042
- inputMode: "numeric",
1043
- pattern: "[0-9]*",
1044
- min: "0",
1045
- max: "255",
1046
- className: "w-14",
1047
- value: rValue,
1048
- onChange: onChannelChange("r", 255),
1049
- disabled: context.disabled
1050
- }
1051
- ),
1052
- /* @__PURE__ */ jsx(
1053
- InputGroupItem,
1054
- {
1055
- "aria-label": "Green color component (0-255)",
1056
- position: "middle",
1057
- ...inputProps,
1058
- placeholder: "0",
1059
- inputMode: "numeric",
1060
- pattern: "[0-9]*",
1061
- min: "0",
1062
- max: "255",
1063
- className: "w-14",
1064
- value: gValue,
1065
- onChange: onChannelChange("g", 255),
1066
- disabled: context.disabled
1067
- }
1068
- ),
1069
- /* @__PURE__ */ jsx(
1070
- InputGroupItem,
1071
- {
1072
- "aria-label": "Blue color component (0-255)",
1073
- position: withoutAlpha ? "last" : "middle",
1074
- ...inputProps,
1075
- placeholder: "0",
1076
- inputMode: "numeric",
1077
- pattern: "[0-9]*",
1078
- min: "0",
1079
- max: "255",
1080
- className: "w-14",
1081
- value: bValue,
1082
- onChange: onChannelChange("b", 255),
1083
- disabled: context.disabled
1084
- }
1085
- ),
1086
- !withoutAlpha && /* @__PURE__ */ jsx(
1087
- InputGroupItem,
1088
- {
1089
- "aria-label": "Alpha transparency percentage",
1090
- position: "last",
1091
- ...inputProps,
1092
- placeholder: "100",
1093
- inputMode: "numeric",
1094
- pattern: "[0-9]*",
1095
- min: "0",
1096
- max: "100",
1097
- className: "w-14",
1098
- value: alphaValue,
1099
- onChange: onChannelChange("a", 100, true),
1100
- disabled: context.disabled
1101
- }
1102
- )
1103
- ] });
1104
- }
1105
- function HslInput(props) {
1106
- const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1107
- const hsl = React16.useMemo(() => rgbToHsl(color), [color]);
1108
- const alphaValue = Math.round((color?.a ?? 1) * 100);
1109
- const onHslChannelChange = React16.useCallback(
1110
- (channel, max) => (event) => {
1111
- const value = Number.parseInt(event.target.value, 10);
1112
- if (!Number.isNaN(value) && value >= 0 && value <= max) {
1113
- const newHsl = { ...hsl, [channel]: value };
1114
- const newColor = hslToRgb(newHsl, color?.a ?? 1);
1115
- onColorChange(newColor);
1116
- }
1117
- },
1118
- [hsl, color, onColorChange]
1119
- );
1120
- const onAlphaChange = React16.useCallback(
1121
- (event) => {
1122
- const value = Number.parseInt(event.target.value, 10);
1123
- if (!Number.isNaN(value) && value >= 0 && value <= 100) {
1124
- onColorChange({ ...color, a: value / 100 });
1125
- }
1126
- },
1127
- [color, onColorChange]
1128
- );
1129
- return /* @__PURE__ */ jsxs("div", { "data-slot": "color-picker-input-wrapper", className: cn("flex items-center", className), children: [
1130
- /* @__PURE__ */ jsx(
1131
- InputGroupItem,
1132
- {
1133
- "aria-label": "Hue degree (0-360)",
1134
- position: "first",
1135
- ...inputProps,
1136
- placeholder: "0",
1137
- inputMode: "numeric",
1138
- pattern: "[0-9]*",
1139
- min: "0",
1140
- max: "360",
1141
- className: "w-14",
1142
- value: hsl.h,
1143
- onChange: onHslChannelChange("h", 360),
1144
- disabled: context.disabled
1145
- }
1146
- ),
1147
- /* @__PURE__ */ jsx(
1148
- InputGroupItem,
1149
- {
1150
- "aria-label": "Saturation percentage (0-100)",
1151
- position: "middle",
1152
- ...inputProps,
1153
- placeholder: "0",
1154
- inputMode: "numeric",
1155
- pattern: "[0-9]*",
1156
- min: "0",
1157
- max: "100",
1158
- className: "w-14",
1159
- value: hsl.s,
1160
- onChange: onHslChannelChange("s", 100),
1161
- disabled: context.disabled
1162
- }
1163
- ),
1164
- /* @__PURE__ */ jsx(
1165
- InputGroupItem,
1166
- {
1167
- "aria-label": "Lightness percentage (0-100)",
1168
- position: withoutAlpha ? "last" : "middle",
1169
- ...inputProps,
1170
- placeholder: "0",
1171
- inputMode: "numeric",
1172
- pattern: "[0-9]*",
1173
- min: "0",
1174
- max: "100",
1175
- className: "w-14",
1176
- value: hsl.l,
1177
- onChange: onHslChannelChange("l", 100),
1178
- disabled: context.disabled
1179
- }
1180
- ),
1181
- !withoutAlpha && /* @__PURE__ */ jsx(
1182
- InputGroupItem,
1183
- {
1184
- "aria-label": "Alpha transparency percentage",
1185
- position: "last",
1186
- ...inputProps,
1187
- placeholder: "100",
1188
- inputMode: "numeric",
1189
- pattern: "[0-9]*",
1190
- min: "0",
1191
- max: "100",
1192
- className: "w-14",
1193
- value: alphaValue,
1194
- onChange: onAlphaChange,
1195
- disabled: context.disabled
1196
- }
1197
- )
1198
- ] });
1199
- }
1200
- function HsbInput(props) {
1201
- const { hsv, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1202
- const alphaValue = Math.round((hsv?.a ?? 1) * 100);
1203
- const onHsvChannelChange = React16.useCallback(
1204
- (channel, max) => (event) => {
1205
- const value = Number.parseInt(event.target.value, 10);
1206
- if (!Number.isNaN(value) && value >= 0 && value <= max) {
1207
- const newHsv = { ...hsv, [channel]: value };
1208
- const newColor = hsvToRgb(newHsv);
1209
- onColorChange(newColor);
1210
- }
1211
- },
1212
- [hsv, onColorChange]
1213
- );
1214
- const onAlphaChange = React16.useCallback(
1215
- (event) => {
1216
- const value = Number.parseInt(event.target.value, 10);
1217
- if (!Number.isNaN(value) && value >= 0 && value <= 100) {
1218
- const currentColor = hsvToRgb(hsv);
1219
- onColorChange({ ...currentColor, a: value / 100 });
1220
- }
1221
- },
1222
- [hsv, onColorChange]
1223
- );
1224
- return /* @__PURE__ */ jsxs("div", { "data-slot": "color-picker-input-wrapper", className: cn("flex items-center", className), children: [
1225
- /* @__PURE__ */ jsx(
1226
- InputGroupItem,
1227
- {
1228
- "aria-label": "Hue degree (0-360)",
1229
- position: "first",
1230
- ...inputProps,
1231
- placeholder: "0",
1232
- inputMode: "numeric",
1233
- pattern: "[0-9]*",
1234
- min: "0",
1235
- max: "360",
1236
- className: "w-14",
1237
- value: hsv?.h ?? 0,
1238
- onChange: onHsvChannelChange("h", 360),
1239
- disabled: context.disabled
1240
- }
1241
- ),
1242
- /* @__PURE__ */ jsx(
1243
- InputGroupItem,
1244
- {
1245
- "aria-label": "Saturation percentage (0-100)",
1246
- position: "middle",
1247
- ...inputProps,
1248
- placeholder: "0",
1249
- inputMode: "numeric",
1250
- pattern: "[0-9]*",
1251
- min: "0",
1252
- max: "100",
1253
- className: "w-14",
1254
- value: hsv?.s ?? 0,
1255
- onChange: onHsvChannelChange("s", 100),
1256
- disabled: context.disabled
1257
- }
1258
- ),
1259
- /* @__PURE__ */ jsx(
1260
- InputGroupItem,
1261
- {
1262
- "aria-label": "Brightness percentage (0-100)",
1263
- position: withoutAlpha ? "last" : "middle",
1264
- ...inputProps,
1265
- placeholder: "0",
1266
- inputMode: "numeric",
1267
- pattern: "[0-9]*",
1268
- min: "0",
1269
- max: "100",
1270
- className: "w-14",
1271
- value: hsv?.v ?? 0,
1272
- onChange: onHsvChannelChange("v", 100),
1273
- disabled: context.disabled
1274
- }
1275
- ),
1276
- !withoutAlpha && /* @__PURE__ */ jsx(
1277
- InputGroupItem,
1278
- {
1279
- "aria-label": "Alpha transparency percentage",
1280
- position: "last",
1281
- ...inputProps,
1282
- placeholder: "100",
1283
- inputMode: "numeric",
1284
- pattern: "[0-9]*",
1285
- min: "0",
1286
- max: "100",
1287
- className: "w-14",
1288
- value: alphaValue,
1289
- onChange: onAlphaChange,
1290
- disabled: context.disabled
1291
- }
1292
- )
1293
- ] });
1294
- }
1295
-
1296
- // src/components/stepper/stepper.constants.ts
1297
- var STEPPER_ROOT_NAME = "Stepper";
1298
- var STEPPER_NAV_NAME = "StepperNav";
1299
- var STEPPER_ITEM_NAME = "StepperItem";
1300
- var STEPPER_TRIGGER_NAME = "StepperTrigger";
1301
- var STEPPER_INDICATOR_NAME = "StepperIndicator";
1302
- var STEPPER_TITLE_NAME = "StepperTitle";
1303
- var STEPPER_DESCRIPTION_NAME = "StepperDescription";
1304
- var STEPPER_CONTENT_NAME = "StepperContent";
1305
- var STEPPER_PREV_TRIGGER_NAME = "StepperPrevTrigger";
1306
- var STEPPER_NEXT_TRIGGER_NAME = "StepperNextTrigger";
1307
- var STEPPER_ENTRY_FOCUS = "stepperFocusGroup.onEntryFocus";
1308
- var STEPPER_EVENT_OPTIONS = { bubbles: false, cancelable: true };
1309
- var STEPPER_ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
1310
- var STEPPER_MAP_KEY_TO_FOCUS_INTENT = {
1311
- ArrowLeft: "prev",
1312
- ArrowUp: "prev",
1313
- ArrowRight: "next",
1314
- ArrowDown: "next",
1315
- PageUp: "first",
1316
- Home: "first",
1317
- PageDown: "last",
1318
- End: "last"
1319
- };
1320
-
1321
- // src/components/stepper/stepper.context.tsx
1322
- var StepperContext = React16.createContext(null);
1323
- function useStepperContext(consumerName) {
1324
- const context = React16.useContext(StepperContext);
1325
- if (!context) {
1326
- throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ROOT_NAME}\``);
1327
- }
1328
- return context;
1329
- }
1330
- function createStepperStore(listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate) {
1331
- const store = {
1332
- subscribe: (cb) => {
1333
- if (listenersRef.current) {
1334
- listenersRef.current.add(cb);
1335
- return () => listenersRef.current?.delete(cb);
1336
- }
1337
- return () => {
1338
- };
1339
- },
1340
- getState: () => stateRef.current ?? {
1341
- steps: /* @__PURE__ */ new Map(),
1342
- value: void 0
1343
- },
1344
- setState: (key, value) => {
1345
- const state = stateRef.current;
1346
- if (!state || Object.is(state[key], value)) return;
1347
- if (key === "value" && typeof value === "string") {
1348
- state.value = value;
1349
- onValueChange?.(value);
1350
- } else {
1351
- state[key] = value;
1352
- }
1353
- store.notify();
1354
- },
1355
- setStateWithValidation: async (value, direction) => {
1356
- if (!onValidate) {
1357
- store.setState("value", value);
1358
- return true;
1359
- }
1360
- try {
1361
- const isValid = await onValidate(value, direction);
1362
- if (isValid) {
1363
- store.setState("value", value);
1364
- }
1365
- return isValid;
1366
- } catch {
1367
- return false;
1368
- }
1369
- },
1370
- hasValidation: () => !!onValidate,
1371
- addStep: (newStep) => {
1372
- const state = stateRef.current;
1373
- if (state) {
1374
- state.steps = new Map(state.steps);
1375
- state.steps.set(newStep.value, newStep);
1376
- onValueAdd?.(newStep.value);
1377
- store.notify();
1378
- }
1379
- },
1380
- removeStep: (value) => {
1381
- const state = stateRef.current;
1382
- if (state) {
1383
- state.steps = new Map(state.steps);
1384
- state.steps.delete(value);
1385
- onValueRemove?.(value);
1386
- store.notify();
1387
- }
1388
- },
1389
- setStep: ({ value, disabled, loading, completed }) => {
1390
- const state = stateRef.current;
1391
- if (state) {
1392
- const step = state.steps.get(value);
1393
- if (step) {
1394
- const updatedStep = { ...step, completed, disabled, loading };
1395
- state.steps = new Map(state.steps);
1396
- state.steps.set(value, updatedStep);
1397
- if (completed !== step.completed) {
1398
- onValueComplete?.(value, completed);
1399
- }
1400
- store.notify();
1401
- }
1402
- }
1403
- },
1404
- notify: () => {
1405
- if (listenersRef.current) {
1406
- for (const cb of listenersRef.current) {
1407
- cb();
1408
- }
1409
- }
1410
- }
1411
- };
1412
- return store;
1413
- }
1414
- var StepperStoreContext = React16.createContext(null);
1415
- function useStepperStoreContext(consumerName) {
1416
- const context = React16.useContext(StepperStoreContext);
1417
- if (!context) {
1418
- throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ROOT_NAME}\``);
1419
- }
1420
- return context;
1421
- }
1422
- function useStepperStore(selector) {
1423
- const store = useStepperStoreContext("useStore");
1424
- const getSnapshot = React16.useCallback(() => selector(store.getState()), [selector, store]);
1425
- return React16.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
1426
- }
1427
- function Stepper({
1428
- value,
1429
- defaultValue,
1430
- onValueChange,
1431
- onValueComplete,
1432
- onValueAdd,
1433
- onValueRemove,
1434
- onValidate,
1435
- id: idProp,
1436
- dir: dirProp,
1437
- orientation = "horizontal",
1438
- activationMode = "automatic",
1439
- asChild,
1440
- disabled = false,
1441
- nonInteractive = false,
1442
- loop = false,
1443
- className,
1444
- indicators = {},
1445
- ...rootProps
1446
- }) {
1447
- const id = React16.useId();
1448
- const rootId = idProp ?? id;
1449
- const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
1450
- const stateRef = useLazyRef(() => ({
1451
- steps: /* @__PURE__ */ new Map(),
1452
- value: value ?? defaultValue
1453
- }));
1454
- const store = React16.useMemo(
1455
- () => createStepperStore(listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate),
1456
- [listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate]
1457
- );
1458
- useIsomorphicLayoutEffect(() => {
1459
- if (value !== void 0) {
1460
- store.setState("value", value);
1461
- }
1462
- }, [value]);
1463
- const dir = useDirection(dirProp);
1464
- const contextValue = React16.useMemo(
1465
- () => ({
1466
- id: rootId,
1467
- dir,
1468
- orientation,
1469
- activationMode,
1470
- disabled,
1471
- nonInteractive,
1472
- loop,
1473
- indicators
1474
- }),
1475
- [rootId, dir, orientation, activationMode, disabled, nonInteractive, loop, indicators]
1476
- );
1477
- const RootPrimitive = asChild ? Slot$1 : "div";
1478
- return /* @__PURE__ */ jsx(StepperStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx(StepperContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
1479
- RootPrimitive,
1480
- {
1481
- id: rootId,
1482
- "data-disabled": disabled ? "" : void 0,
1483
- "data-orientation": orientation,
1484
- "data-slot": "stepper",
1485
- dir,
1486
- ...rootProps,
1487
- className: cn("flex w-full flex-col gap-4 data-[orientation=vertical]:flex-row", className)
1488
- }
1489
- ) }) });
1490
- }
1491
-
1492
- // src/components/stepper/stepper.types.ts
1493
- var StepperFocusIntent = {
1494
- FIRST: "first",
1495
- LAST: "last",
1496
- PREV: "prev",
1497
- NEXT: "next"
1498
- };
1499
- var StepperOrientation = {
1500
- HORIZONTAL: "horizontal",
1501
- VERTICAL: "vertical"
1502
- };
1503
- var StepperNavigationDirection = {
1504
- NEXT: "next",
1505
- PREV: "prev"
1506
- };
1507
- var StepperActivationMode = {
1508
- AUTOMATIC: "automatic",
1509
- MANUAL: "manual"
1510
- };
1511
- var StepperDataState = {
1512
- INACTIVE: "inactive",
1513
- ACTIVE: "active",
1514
- COMPLETED: "completed"
1515
- };
1516
- var StepperFocusContext = React16.createContext(null);
1517
- function useStepperFocusContext(consumerName) {
1518
- const context = React16.useContext(StepperFocusContext);
1519
- if (!context) {
1520
- throw new Error(`\`${consumerName}\` must be used within \`FocusProvider\``);
1521
- }
1522
- return context;
1523
- }
1524
-
1525
- // src/components/stepper/stepper.utils.tsx
1526
- function focusFirst(candidates, preventScroll = false) {
1527
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1528
- for (const candidateRef of candidates) {
1529
- const candidate = candidateRef.current;
1530
- if (!candidate) continue;
1531
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
1532
- candidate.focus({ preventScroll });
1533
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1534
- }
1535
- }
1536
- function getDataState(value, itemValue, stepState, steps, variant = "item") {
1537
- const stepKeys = Array.from(steps.keys());
1538
- const currentIndex = stepKeys.indexOf(itemValue);
1539
- if (stepState?.completed) {
1540
- return StepperDataState.COMPLETED;
1541
- }
1542
- if (value === itemValue) {
1543
- return variant === "separator" ? StepperDataState.INACTIVE : StepperDataState.ACTIVE;
1544
- }
1545
- if (value) {
1546
- const activeIndex = stepKeys.indexOf(value);
1547
- if (activeIndex > currentIndex) {
1548
- return StepperDataState.COMPLETED;
1549
- }
1550
- }
1551
- return StepperDataState.INACTIVE;
1552
- }
1553
- function getId(id, variant, value) {
1554
- return `${id}-${variant}-${value}`;
1555
- }
1556
- function wrapArray(array, startIndex) {
1557
- return array.map((_, index) => array[(startIndex + index) % array.length]);
1558
- }
1559
- function getDirectionAwareKey(key, dir) {
1560
- if (dir !== "rtl") return key;
1561
- return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
1562
- }
1563
- function getFocusIntent(event, dir, orientation) {
1564
- const key = getDirectionAwareKey(event.key, dir);
1565
- if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
1566
- if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
1567
- return STEPPER_MAP_KEY_TO_FOCUS_INTENT[key];
1568
- }
1569
- function StepperNav({ className, children, asChild, ref, ...listProps }) {
1570
- const context = useStepperContext(STEPPER_NAV_NAME);
1571
- const orientation = context.orientation;
1572
- const currentValue = useStepperStore((state) => state.value);
1573
- const [tabStopId, setTabStopId] = React16.useState(null);
1574
- const [isTabbingBackOut, setIsTabbingBackOut] = React16.useState(false);
1575
- const [focusableItemCount, setFocusableItemCount] = React16.useState(0);
1576
- const isClickFocusRef = React16.useRef(false);
1577
- const itemsRef = React16.useRef(/* @__PURE__ */ new Map());
1578
- const listRef = React16.useRef(null);
1579
- const composedRef = useComposedRefs$1(ref, listRef);
1580
- const onItemFocus = React16.useCallback((tabStopId2) => {
1581
- setTabStopId(tabStopId2);
1582
- }, []);
1583
- const onItemShiftTab = React16.useCallback(() => {
1584
- setIsTabbingBackOut(true);
1585
- }, []);
1586
- const onFocusableItemAdd = React16.useCallback(() => {
1587
- setFocusableItemCount((prevCount) => prevCount + 1);
1588
- }, []);
1589
- const onFocusableItemRemove = React16.useCallback(() => {
1590
- setFocusableItemCount((prevCount) => prevCount - 1);
1591
- }, []);
1592
- const onItemRegister = React16.useCallback((item) => {
1593
- itemsRef.current.set(item.id, item);
1594
- }, []);
1595
- const onItemUnregister = React16.useCallback((id) => {
1596
- itemsRef.current.delete(id);
1597
- }, []);
1598
- const getItems = React16.useCallback(() => {
1599
- return Array.from(itemsRef.current.values()).filter((item) => item.ref.current).sort((a, b) => {
1600
- const elementA = a.ref.current;
1601
- const elementB = b.ref.current;
1602
- if (!elementA || !elementB) return 0;
1603
- const position = elementA.compareDocumentPosition(elementB);
1604
- if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
1605
- return -1;
1606
- }
1607
- if (position & Node.DOCUMENT_POSITION_PRECEDING) {
1608
- return 1;
1609
- }
1610
- return 0;
1611
- });
1612
- }, []);
1613
- const onBlur = React16.useCallback(
1614
- (event) => {
1615
- listProps.onBlur?.(event);
1616
- if (event.defaultPrevented) return;
1617
- setIsTabbingBackOut(false);
1618
- },
1619
- // eslint-disable-next-line react-hooks/exhaustive-deps
1620
- [listProps.onBlur]
1621
- );
1622
- const onFocus = React16.useCallback(
1623
- (event) => {
1624
- listProps.onFocus?.(event);
1625
- if (event.defaultPrevented) return;
1626
- const isKeyboardFocus = !isClickFocusRef.current;
1627
- if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
1628
- const entryFocusEvent = new CustomEvent(STEPPER_ENTRY_FOCUS, STEPPER_EVENT_OPTIONS);
1629
- event.currentTarget.dispatchEvent(entryFocusEvent);
1630
- if (!entryFocusEvent.defaultPrevented) {
1631
- const items = Array.from(itemsRef.current.values()).filter((item) => !item.disabled);
1632
- const selectedItem = currentValue ? items.find((item) => item.value === currentValue) : void 0;
1633
- const activeItem = items.find((item) => item.active);
1634
- const currentItem = items.find((item) => item.id === tabStopId);
1635
- const candidateItems = [selectedItem, activeItem, currentItem, ...items].filter(
1636
- Boolean
1637
- );
1638
- const candidateRefs = candidateItems.map((item) => item.ref);
1639
- focusFirst(candidateRefs, false);
1640
- }
1641
- }
1642
- isClickFocusRef.current = false;
1643
- },
1644
- // eslint-disable-next-line react-hooks/exhaustive-deps
1645
- [listProps.onFocus, isTabbingBackOut, currentValue, tabStopId]
1646
- );
1647
- const onMouseDown = React16.useCallback(
1648
- (event) => {
1649
- listProps.onMouseDown?.(event);
1650
- if (event.defaultPrevented) return;
1651
- isClickFocusRef.current = true;
1652
- },
1653
- // eslint-disable-next-line react-hooks/exhaustive-deps
1654
- [listProps.onMouseDown]
1655
- );
1656
- const focusContextValue = React16.useMemo(
1657
- () => ({
1658
- tabStopId,
1659
- onItemFocus,
1660
- onItemShiftTab,
1661
- onFocusableItemAdd,
1662
- onFocusableItemRemove,
1663
- onItemRegister,
1664
- onItemUnregister,
1665
- getItems
1666
- }),
1667
- [
1668
- tabStopId,
1669
- onItemFocus,
1670
- onItemShiftTab,
1671
- onFocusableItemAdd,
1672
- onFocusableItemRemove,
1673
- onItemRegister,
1674
- onItemUnregister,
1675
- getItems
1676
- ]
1677
- );
1678
- const StepperNavPrimitive = asChild ? Slot$1 : "nav";
1679
- return /* @__PURE__ */ jsx(StepperFocusContext.Provider, { value: focusContextValue, children: /* @__PURE__ */ jsx(
1680
- StepperNavPrimitive,
1681
- {
1682
- role: "tablist",
1683
- "data-slot": "stepper-nav",
1684
- "aria-orientation": orientation,
1685
- "data-orientation": orientation,
1686
- dir: context.dir,
1687
- tabIndex: isTabbingBackOut || focusableItemCount === 0 ? -1 : 0,
1688
- ref: composedRef,
1689
- onBlur,
1690
- onFocus,
1691
- onMouseDown,
1692
- className: cn(
1693
- "group/stepper-nav inline-flex gap-4",
1694
- "data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col",
1695
- className
1696
- ),
1697
- ...listProps,
1698
- children
1699
- }
1700
- ) });
1701
- }
1702
- var StepperItemContext = React16.createContext(null);
1703
- function useStepperItemContext(consumerName) {
1704
- const context = React16.useContext(StepperItemContext);
1705
- if (!context) {
1706
- throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ITEM_NAME}\``);
1707
- }
1708
- return context;
1709
- }
1710
- function StepperItem({
1711
- value: itemValue,
1712
- completed = false,
1713
- disabled = false,
1714
- loading = false,
1715
- asChild,
1716
- className,
1717
- children,
1718
- ...props
1719
- }) {
1720
- const { orientation, dir } = useStepperContext(STEPPER_ITEM_NAME);
1721
- const store = useStepperStoreContext(STEPPER_ITEM_NAME);
1722
- const value = useStepperStore((state) => state.value);
1723
- useIsomorphicLayoutEffect(() => {
1724
- store.addStep({ value: itemValue, completed, disabled, loading });
1725
- return () => {
1726
- store.removeStep(itemValue);
1727
- };
1728
- }, [itemValue, completed, disabled, loading]);
1729
- useIsomorphicLayoutEffect(() => {
1730
- store.setStep({ value: itemValue, completed, disabled, loading });
1731
- }, [itemValue, completed, disabled, loading]);
1732
- const stepState = useStepperStore((state) => state.steps.get(itemValue));
1733
- const steps = useStepperStore((state) => state.steps);
1734
- const dataState = getDataState(value, itemValue, stepState, steps);
1735
- const itemContextValue = React16.useMemo(
1736
- () => ({
1737
- value: itemValue,
1738
- stepState
1739
- }),
1740
- [itemValue, stepState]
1741
- );
1742
- const StepperItemPrimitive = asChild ? Slot$1 : "div";
1743
- return /* @__PURE__ */ jsx(StepperItemContext.Provider, { value: itemContextValue, children: /* @__PURE__ */ jsxs(
1744
- StepperItemPrimitive,
1745
- {
1746
- "data-disabled": stepState?.disabled ? "" : void 0,
1747
- "data-orientation": orientation,
1748
- "data-state": dataState,
1749
- "data-slot": "stepper-item",
1750
- dir,
1751
- className: cn(
1752
- "group/step flex flex-1 flex-col justify-end data-[disabled]:opacity-50",
1753
- "",
1754
- // "group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col",
1755
- className
1756
- ),
1757
- ...props,
1758
- children: [
1759
- children,
1760
- /* @__PURE__ */ jsx(
1761
- "div",
1762
- {
1763
- "data-state": dataState,
1764
- className: cn(
1765
- "bg-border h-1 w-full transition-colors duration-500",
1766
- "data-[state=active]:bg-primary data-[state=completed]:bg-success"
1767
- )
1768
- }
1769
- )
1770
- ]
1771
- }
1772
- ) });
1773
- }
1774
- function StepperTrigger({ asChild, disabled, className, ref, ...triggerProps }) {
1775
- const context = useStepperContext(STEPPER_TRIGGER_NAME);
1776
- const itemContext = useStepperItemContext(STEPPER_TRIGGER_NAME);
1777
- const store = useStepperStoreContext(STEPPER_TRIGGER_NAME);
1778
- const focusContext = useStepperFocusContext(STEPPER_TRIGGER_NAME);
1779
- const value = useStepperStore((state) => state.value);
1780
- const itemValue = itemContext.value;
1781
- const stepState = useStepperStore((state) => state.steps.get(itemValue));
1782
- const activationMode = context.activationMode;
1783
- const orientation = context.orientation;
1784
- const loop = context.loop;
1785
- const steps = useStepperStore((state) => state.steps);
1786
- const stepIndex = Array.from(steps.keys()).indexOf(itemValue);
1787
- const stepPosition = stepIndex + 1;
1788
- const stepCount = steps.size;
1789
- const triggerId = getId(context.id, "trigger", itemValue);
1790
- const contentId = getId(context.id, "content", itemValue);
1791
- const titleId = getId(context.id, "title", itemValue);
1792
- const descriptionId = getId(context.id, "description", itemValue);
1793
- const isDisabled = context.disabled || stepState?.disabled || disabled;
1794
- const isActive = value === itemValue;
1795
- const isTabStop = focusContext.tabStopId === triggerId;
1796
- const dataState = getDataState(value, itemValue, stepState, steps);
1797
- const triggerRef = React16.useRef(null);
1798
- const composedRef = useComposedRefs$1(ref, triggerRef);
1799
- const isArrowKeyPressedRef = React16.useRef(false);
1800
- const isMouseClickRef = React16.useRef(false);
1801
- React16.useEffect(() => {
1802
- function onKeyDown2(event) {
1803
- if (STEPPER_ARROW_KEYS.includes(event.key)) {
1804
- isArrowKeyPressedRef.current = true;
1805
- }
1806
- }
1807
- function onKeyUp() {
1808
- isArrowKeyPressedRef.current = false;
1809
- }
1810
- document.addEventListener("keydown", onKeyDown2);
1811
- document.addEventListener("keyup", onKeyUp);
1812
- return () => {
1813
- document.removeEventListener("keydown", onKeyDown2);
1814
- document.removeEventListener("keyup", onKeyUp);
1815
- };
1816
- }, []);
1817
- useIsomorphicLayoutEffect(() => {
1818
- focusContext.onItemRegister({
1819
- id: triggerId,
1820
- ref: triggerRef,
1821
- value: itemValue,
1822
- active: isTabStop,
1823
- disabled: !!isDisabled
1824
- });
1825
- if (!isDisabled) {
1826
- focusContext.onFocusableItemAdd();
1827
- }
1828
- return () => {
1829
- focusContext.onItemUnregister(triggerId);
1830
- if (!isDisabled) {
1831
- focusContext.onFocusableItemRemove();
1832
- }
1833
- };
1834
- }, [focusContext, triggerId, itemValue, isTabStop, isDisabled]);
1835
- const onClick = React16.useCallback(
1836
- async (event) => {
1837
- triggerProps.onClick?.(event);
1838
- if (event.defaultPrevented) return;
1839
- if (!isDisabled && !context.nonInteractive) {
1840
- const currentStepIndex = Array.from(steps.keys()).indexOf(value ?? "");
1841
- const targetStepIndex = Array.from(steps.keys()).indexOf(itemValue);
1842
- const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1843
- await store.setStateWithValidation(itemValue, direction);
1844
- }
1845
- },
1846
- // eslint-disable-next-line react-hooks/exhaustive-deps
1847
- [isDisabled, context.nonInteractive, store, itemValue, value, steps, triggerProps.onClick]
1848
- );
1849
- const onFocus = React16.useCallback(
1850
- async (event) => {
1851
- triggerProps.onFocus?.(event);
1852
- if (event.defaultPrevented) return;
1853
- focusContext.onItemFocus(triggerId);
1854
- const isKeyboardFocus = !isMouseClickRef.current;
1855
- if (!isActive && !isDisabled && activationMode !== "manual" && !context.nonInteractive && isKeyboardFocus) {
1856
- const currentStepIndex = Array.from(steps.keys()).indexOf(value || "");
1857
- const targetStepIndex = Array.from(steps.keys()).indexOf(itemValue);
1858
- const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1859
- await store.setStateWithValidation(itemValue, direction);
1860
- }
1861
- isMouseClickRef.current = false;
1862
- },
1863
- [
1864
- triggerProps,
1865
- focusContext,
1866
- triggerId,
1867
- isActive,
1868
- isDisabled,
1869
- activationMode,
1870
- context.nonInteractive,
1871
- steps,
1872
- value,
1873
- itemValue,
1874
- store
1875
- ]
1876
- );
1877
- const onKeyDown = React16.useCallback(
1878
- async (event) => {
1879
- triggerProps.onKeyDown?.(event);
1880
- if (event.defaultPrevented) return;
1881
- if (event.key === "Enter" && context.nonInteractive) {
1882
- event.preventDefault();
1883
- return;
1884
- }
1885
- if ((event.key === "Enter" || event.key === " ") && activationMode === "manual" && !context.nonInteractive) {
1886
- event.preventDefault();
1887
- if (!isDisabled && triggerRef.current) {
1888
- triggerRef.current.click();
1889
- }
1890
- return;
1891
- }
1892
- if (event.key === "Tab" && event.shiftKey) {
1893
- focusContext.onItemShiftTab();
1894
- return;
1895
- }
1896
- if (event.target !== event.currentTarget) return;
1897
- const focusIntent = getFocusIntent(event, context.dir, orientation);
1898
- if (focusIntent !== void 0) {
1899
- if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
1900
- event.preventDefault();
1901
- const items = focusContext.getItems().filter((item) => !item.disabled);
1902
- let candidateRefs = items.map((item) => item.ref);
1903
- if (focusIntent === "last") {
1904
- candidateRefs.reverse();
1905
- } else if (focusIntent === "prev" || focusIntent === "next") {
1906
- if (focusIntent === "prev") candidateRefs.reverse();
1907
- const currentIndex = candidateRefs.findIndex((ref2) => ref2.current === event.currentTarget);
1908
- candidateRefs = loop ? wrapArray(candidateRefs, currentIndex + 1) : candidateRefs.slice(currentIndex + 1);
1909
- }
1910
- if (store.hasValidation() && candidateRefs.length > 0) {
1911
- const nextRef = candidateRefs[0];
1912
- const nextElement = nextRef?.current;
1913
- const nextItem = items.find((item) => item.ref.current === nextElement);
1914
- if (nextItem && nextItem.value !== itemValue) {
1915
- const currentStepIndex = Array.from(steps.keys()).indexOf(value || "");
1916
- const targetStepIndex = Array.from(steps.keys()).indexOf(nextItem.value);
1917
- const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1918
- if (direction === "next") {
1919
- const isValid = await store.setStateWithValidation(nextItem.value, direction);
1920
- if (!isValid) return;
1921
- } else {
1922
- store.setState("value", nextItem.value);
1923
- }
1924
- queueMicrotask(() => nextElement?.focus());
1925
- return;
1926
- }
1927
- }
1928
- queueMicrotask(() => focusFirst(candidateRefs));
1929
- }
1930
- },
1931
- // eslint-disable-next-line react-hooks/exhaustive-deps
1932
- [
1933
- focusContext,
1934
- context.nonInteractive,
1935
- context.dir,
1936
- activationMode,
1937
- orientation,
1938
- loop,
1939
- isDisabled,
1940
- triggerProps.onKeyDown,
1941
- store,
1942
- itemValue,
1943
- value,
1944
- steps
1945
- ]
1946
- );
1947
- const onMouseDown = React16.useCallback(
1948
- (event) => {
1949
- triggerProps.onMouseDown?.(event);
1950
- if (event.defaultPrevented) {
1951
- return;
1952
- }
1953
- isMouseClickRef.current = true;
1954
- if (isDisabled) {
1955
- event.preventDefault();
1956
- } else {
1957
- focusContext.onItemFocus(triggerId);
1958
- }
1959
- },
1960
- // eslint-disable-next-line react-hooks/exhaustive-deps
1961
- [focusContext, triggerId, isDisabled, triggerProps.onMouseDown]
1962
- );
1963
- const TriggerPrimitive = asChild ? Slot$1 : "button";
1964
- return /* @__PURE__ */ jsx(
1965
- TriggerPrimitive,
1966
- {
1967
- id: triggerId,
1968
- role: "tab",
1969
- type: "button",
1970
- disabled: isDisabled,
1971
- tabIndex: isTabStop ? 0 : -1,
1972
- ref: composedRef,
1973
- "data-slot": "stepper-trigger",
1974
- "data-disabled": isDisabled ? "" : void 0,
1975
- "data-state": dataState,
1976
- "aria-controls": contentId,
1977
- "aria-current": isActive ? "step" : void 0,
1978
- "aria-describedby": `${titleId} ${descriptionId}`,
1979
- "aria-posinset": stepPosition,
1980
- "aria-selected": isActive,
1981
- "aria-setsize": stepCount,
1982
- className: cn(
1983
- "inline-flex w-full cursor-pointer items-center gap-3 rounded text-left transition-colors duration-500 outline-none",
1984
- "disabled:pointer-events-none",
1985
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
1986
- className
1987
- ),
1988
- onClick,
1989
- onFocus,
1990
- onKeyDown,
1991
- onMouseDown,
1992
- ...triggerProps
1993
- }
1994
- );
1995
- }
1996
- function StepperIndicator({ className, children, asChild, ref, ...props }) {
1997
- const { indicators, dir } = useStepperContext(STEPPER_INDICATOR_NAME);
1998
- const itemContext = useStepperItemContext(STEPPER_INDICATOR_NAME);
1999
- const value = useStepperStore((state) => state.value);
2000
- const itemValue = itemContext.value;
2001
- const stepState = useStepperStore((state) => state.steps.get(itemValue));
2002
- const steps = useStepperStore((state) => state.steps);
2003
- const stepPosition = Array.from(steps.keys()).indexOf(itemValue) + 1;
2004
- const dataState = getDataState(value, itemValue, stepState, steps);
2005
- const StepperIndicatorPrimitive = asChild ? Slot$1 : "div";
2006
- return /* @__PURE__ */ jsx(
2007
- StepperIndicatorPrimitive,
2008
- {
2009
- "data-slot": "stepper-indicator",
2010
- "data-state": dataState,
2011
- dir,
2012
- ref,
2013
- className: cn(
2014
- "bg-muted border-border text-muted-foreground relative flex size-6 shrink-0 items-center justify-center self-end overflow-hidden rounded-t border-x border-t text-xs transition-colors duration-500",
2015
- "data-[state=completed]:bg-success/50 data-[state=completed]:border-success data-[state=completed]:text-success-foreground",
2016
- "data-[state=active]:bg-primary/50 data-[state=active]:border-primary data-[state=active]:text-primary-foreground",
2017
- className
2018
- ),
2019
- ...props,
2020
- children: /* @__PURE__ */ jsx("div", { className: "absolute", children: typeof children === "function" ? children(dataState) : indicators && (itemContext.stepState?.loading && indicators.loading || dataState === "completed" && indicators.completed || dataState === "active" && indicators.active || dataState === "inactive" && indicators.inactive) ? itemContext.stepState?.loading && indicators.loading || dataState === "completed" && indicators.completed || dataState === "active" && indicators.active || dataState === "inactive" && indicators.inactive : children ? children : stepPosition })
2021
- }
2022
- );
2023
- }
2024
- function StepperTitle({ className, asChild = false, ...props }) {
2025
- const context = useStepperContext(STEPPER_TITLE_NAME);
2026
- const itemContext = useStepperItemContext(STEPPER_TITLE_NAME);
2027
- const titleId = getId(context.id, "title", itemContext.value);
2028
- const TitlePrimitive = asChild ? Slot$1 : "h3";
2029
- return /* @__PURE__ */ jsx(
2030
- TitlePrimitive,
2031
- {
2032
- id: titleId,
2033
- "data-slot": "stepper-title",
2034
- dir: context.dir,
2035
- className: cn("text-sm leading-none font-medium", className),
2036
- ...props
2037
- }
2038
- );
2039
- }
2040
- function StepperDescription({ className, asChild, ...props }) {
2041
- const context = useStepperContext(STEPPER_DESCRIPTION_NAME);
2042
- const itemContext = useStepperItemContext(STEPPER_DESCRIPTION_NAME);
2043
- const descriptionId = getId(context.id, "description", itemContext.value);
2044
- const StepperDescriptionPrimitive = asChild ? Slot$1 : "span";
2045
- return /* @__PURE__ */ jsx(
2046
- StepperDescriptionPrimitive,
2047
- {
2048
- id: descriptionId,
2049
- "data-slot": "stepper-description",
2050
- dir: context.dir,
2051
- className: cn("text-muted-foreground text-sm", className),
2052
- ...props
2053
- }
2054
- );
2055
- }
2056
- function StepperPanel({ children, asChild = false, className, ...props }) {
2057
- const currentValue = useStepperStore((state) => state.value);
2058
- const StepperPanelPrimitive = asChild ? Slot$1 : "div";
2059
- return /* @__PURE__ */ jsx(
2060
- StepperPanelPrimitive,
2061
- {
2062
- "data-slot": "stepper-panel",
2063
- "data-state": currentValue,
2064
- className: cn("w-full", className),
2065
- ...props,
2066
- children
2067
- }
2068
- );
2069
- }
2070
- function StepperContent({
2071
- value: valueProp,
2072
- asChild = false,
2073
- forceMount = false,
2074
- className,
2075
- ...props
2076
- }) {
2077
- const context = useStepperContext(STEPPER_CONTENT_NAME);
2078
- const value = useStepperStore((state) => state.value);
2079
- const contentId = getId(context.id, "content", valueProp);
2080
- const triggerId = getId(context.id, "trigger", valueProp);
2081
- const isActive = value === valueProp;
2082
- if (!isActive && !forceMount) {
2083
- return null;
2084
- }
2085
- const ContentPrimitive = asChild ? Slot$1 : "div";
2086
- return /* @__PURE__ */ jsx(
2087
- ContentPrimitive,
2088
- {
2089
- id: contentId,
2090
- role: "tabpanel",
2091
- "data-state": value,
2092
- "aria-labelledby": triggerId,
2093
- "data-slot": "stepper-content",
2094
- dir: context.dir,
2095
- className: cn("w-full", className, !isActive && forceMount && "hidden"),
2096
- hidden: !isActive && forceMount,
2097
- ...props
2098
- }
2099
- );
2100
- }
2101
- function StepperNextTrigger({ asChild = false, onClick, disabled, ...props }) {
2102
- const store = useStepperStoreContext(STEPPER_NEXT_TRIGGER_NAME);
2103
- const value = useStepperStore((state) => state.value);
2104
- const steps = useStepperStore((state) => state.steps);
2105
- const stepKeys = Array.from(steps.keys());
2106
- const currentIndex = value ? stepKeys.indexOf(value) : -1;
2107
- const isDisabled = disabled || currentIndex >= stepKeys.length - 1;
2108
- const handleClick = React16.useCallback(
2109
- async (event) => {
2110
- onClick?.(event);
2111
- if (event.defaultPrevented || isDisabled) {
2112
- return;
2113
- }
2114
- const nextIndex = Math.min(currentIndex + 1, stepKeys.length - 1);
2115
- const nextStepValue = stepKeys[nextIndex];
2116
- if (nextStepValue) {
2117
- await store.setStateWithValidation(nextStepValue, "next");
2118
- }
2119
- },
2120
- [onClick, isDisabled, currentIndex, stepKeys, store]
2121
- );
2122
- const StepperNextTriggerPrimitive = asChild ? Slot$1 : "button";
2123
- return /* @__PURE__ */ jsx(
2124
- StepperNextTriggerPrimitive,
2125
- {
2126
- type: "button",
2127
- "data-slot": "stepper-next-trigger",
2128
- disabled: isDisabled,
2129
- onClick: handleClick,
2130
- ...props
2131
- }
2132
- );
2133
- }
2134
- function StepperPrevTrigger({ asChild = false, disabled, onClick, ...props }) {
2135
- const store = useStepperStoreContext(STEPPER_PREV_TRIGGER_NAME);
2136
- const value = useStepperStore((state) => state.value);
2137
- const steps = useStepperStore((state) => state.steps);
2138
- const stepKeys = Array.from(steps.keys());
2139
- const currentIndex = value ? stepKeys.indexOf(value) : -1;
2140
- const isDisabled = disabled || currentIndex <= 0;
2141
- const handleClick = React16.useCallback(
2142
- async (event) => {
2143
- onClick?.(event);
2144
- if (event.defaultPrevented || isDisabled) {
2145
- return;
2146
- }
2147
- const prevIndex = Math.max(currentIndex - 1, 0);
2148
- const prevStepValue = stepKeys[prevIndex];
2149
- if (prevStepValue) {
2150
- store.setState("value", prevStepValue);
2151
- }
2152
- },
2153
- [currentIndex, isDisabled, onClick, stepKeys, store]
2154
- );
2155
- const StepperPrevTriggerPrimitive = asChild ? Slot$1 : "button";
2156
- return /* @__PURE__ */ jsx(
2157
- StepperPrevTriggerPrimitive,
2158
- {
2159
- type: "button",
2160
- "data-slot": "stepper-prev-trigger",
2161
- disabled: isDisabled,
2162
- onClick: handleClick,
2163
- ...props
2164
- }
2165
- );
2166
- }
2167
- var Toaster = ({ theme = "system", ...props }) => {
2168
- return /* @__PURE__ */ jsx(
2169
- Toaster$1,
2170
- {
2171
- className: "group",
2172
- icons: {
2173
- success: /* @__PURE__ */ jsx(CircleCheckIcon, { className: "size-4" }),
2174
- info: /* @__PURE__ */ jsx(InfoIcon, { className: "size-4" }),
2175
- warning: /* @__PURE__ */ jsx(TriangleAlertIcon, { className: "size-4" }),
2176
- error: /* @__PURE__ */ jsx(OctagonXIcon, { className: "size-4" }),
2177
- loading: /* @__PURE__ */ jsx(Spinner, {})
2178
- },
2179
- toastOptions: {
2180
- classNames: {
2181
- toast: "!bg-popover !text-popover-foreground !border !border-border !rounded",
2182
- description: "!text-muted-foreground"
2183
- }
2184
- },
2185
- theme,
2186
- ...props
2187
- }
2188
- );
2189
- };
2190
-
2191
- // src/components/sidebar/sidebar.constants.ts
2192
- var SIDEBAR_COOKIE_NAME = "sidebar_state";
2193
- var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
2194
- var SIDEBAR_WIDTH = "16rem";
2195
- var SIDEBAR_WIDTH_MOBILE = "18rem";
2196
- var SIDEBAR_WIDTH_ICON = "3rem";
2197
- var SIDEBAR_ROOT_NAME = "SidebarProvider";
2198
- var SidebarContext = React16.createContext(null);
2199
- function useSidebarContext(consumerName) {
2200
- const context = React16.useContext(SidebarContext);
2201
- if (!context) {
2202
- throw new Error(`\`${consumerName}\` must be used within \`${SIDEBAR_ROOT_NAME}\``);
2203
- }
2204
- return context;
2205
- }
2206
- function useSidebar() {
2207
- return useSidebarContext("useSidebar");
2208
- }
2209
- function SidebarProvider({
2210
- defaultOpen = true,
2211
- open: openProp,
2212
- onOpenChange: setOpenProp,
2213
- className,
2214
- style,
2215
- children,
2216
- ...props
2217
- }) {
2218
- const isMobile = useIsMobile();
2219
- const [openMobile, setOpenMobile] = React16.useState(false);
2220
- const [_open, _setOpen] = React16.useState(defaultOpen);
2221
- const open = openProp ?? _open;
2222
- const setOpen = React16.useCallback(
2223
- (value) => {
2224
- const openState = typeof value === "function" ? value(open) : value;
2225
- if (setOpenProp) {
2226
- setOpenProp(openState);
2227
- } else {
2228
- _setOpen(openState);
2229
- }
2230
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
2231
- },
2232
- [setOpenProp, open]
2233
- );
2234
- const toggleSidebar = React16.useCallback(() => {
2235
- return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
2236
- }, [isMobile, setOpen, setOpenMobile]);
2237
- React16.useEffect(() => {
2238
- const handleKeyDown = (event) => {
2239
- if (event.key === "b" && (event.metaKey || event.ctrlKey)) {
2240
- event.preventDefault();
2241
- toggleSidebar();
2242
- }
2243
- };
2244
- window.addEventListener("keydown", handleKeyDown);
2245
- return () => window.removeEventListener("keydown", handleKeyDown);
2246
- }, [toggleSidebar]);
2247
- const state = open ? "expanded" : "collapsed";
2248
- const contextValue = React16.useMemo(
2249
- () => ({ state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar }),
2250
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
2251
- );
2252
- return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
2253
- "div",
2254
- {
2255
- "data-slot": "sidebar-wrapper",
2256
- style: {
2257
- "--sidebar-width": SIDEBAR_WIDTH,
2258
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
2259
- ...style
2260
- },
2261
- className: cn("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", className),
2262
- ...props,
2263
- children
2264
- }
2265
- ) });
2266
- }
2267
- function Sidebar({
2268
- side = "left",
2269
- variant = "sidebar",
2270
- collapsible = "offcanvas",
2271
- className,
2272
- children,
2273
- dir,
2274
- ...props
2275
- }) {
2276
- const { isMobile, state, openMobile, setOpenMobile } = useSidebarContext("Sidebar");
2277
- if (collapsible === "none") {
2278
- return /* @__PURE__ */ jsx(
2279
- "div",
2280
- {
2281
- "data-slot": "sidebar",
2282
- className: cn("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", className),
2283
- ...props,
2284
- children
2285
- }
2286
- );
2287
- }
2288
- if (isMobile) {
2289
- return /* @__PURE__ */ jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs(
2290
- SheetContent,
2291
- {
2292
- dir,
2293
- "data-sidebar": "sidebar",
2294
- "data-slot": "sidebar",
2295
- "data-mobile": "true",
2296
- className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0",
2297
- style: { "--sidebar-width": SIDEBAR_WIDTH_MOBILE },
2298
- side,
2299
- showCloseButton: false,
2300
- children: [
2301
- /* @__PURE__ */ jsxs(SheetHeader, { className: "sr-only", children: [
2302
- /* @__PURE__ */ jsx(SheetTitle, { children: "Sidebar" }),
2303
- /* @__PURE__ */ jsx(SheetDescription, { children: "Displays the mobile sidebar." })
2304
- ] }),
2305
- /* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col", children })
2306
- ]
2307
- }
2308
- ) });
2309
- }
2310
- return /* @__PURE__ */ jsxs(
2311
- "div",
2312
- {
2313
- className: "group peer text-sidebar-foreground hidden md:block",
2314
- "data-state": state,
2315
- "data-collapsible": state === "collapsed" ? collapsible : "",
2316
- "data-variant": variant,
2317
- "data-side": side,
2318
- "data-slot": "sidebar",
2319
- children: [
2320
- /* @__PURE__ */ jsx(
2321
- "div",
2322
- {
2323
- "data-slot": "sidebar-gap",
2324
- className: cn(
2325
- "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
2326
- "group-data-[collapsible=offcanvas]:w-0",
2327
- "group-data-[side=right]:rotate-180",
2328
- variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
2329
- )
2330
- }
2331
- ),
2332
- /* @__PURE__ */ jsx(
2333
- "div",
2334
- {
2335
- "data-slot": "sidebar-container",
2336
- "data-side": side,
2337
- className: cn(
2338
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
2339
- variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
2340
- className
2341
- ),
2342
- ...props,
2343
- children: /* @__PURE__ */ jsx(
2344
- "div",
2345
- {
2346
- "data-sidebar": "sidebar",
2347
- "data-slot": "sidebar-inner",
2348
- className: "bg-sidebar group-data-[variant=floating]:ring-sidebar-border flex size-full flex-col group-data-[variant=floating]:rounded group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1",
2349
- children
2350
- }
2351
- )
2352
- }
2353
- )
2354
- ]
2355
- }
2356
- );
2357
- }
2358
- function SidebarTrigger({ className, onClick, ...props }) {
2359
- const { toggleSidebar } = useSidebarContext("SidebarTrigger");
2360
- return /* @__PURE__ */ jsxs(
2361
- Button,
2362
- {
2363
- "data-sidebar": "trigger",
2364
- "data-slot": "sidebar-trigger",
2365
- variant: "ghost",
2366
- size: "icon-sm",
2367
- className: cn(className),
2368
- onClick: (event) => {
2369
- onClick?.(event);
2370
- toggleSidebar();
2371
- },
2372
- ...props,
2373
- children: [
2374
- /* @__PURE__ */ jsx(PanelLeftIcon, { className: "cn-rtl-flip" }),
2375
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
2376
- ]
2377
- }
2378
- );
2379
- }
2380
- function SidebarRail({ className, ...props }) {
2381
- const { toggleSidebar } = useSidebarContext("SidebarRail");
2382
- return /* @__PURE__ */ jsx(
2383
- "button",
2384
- {
2385
- "data-sidebar": "rail",
2386
- "data-slot": "sidebar-rail",
2387
- "aria-label": "Toggle Sidebar",
2388
- tabIndex: -1,
2389
- onClick: toggleSidebar,
2390
- title: "Toggle Sidebar",
2391
- className: cn(
2392
- "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
2393
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
2394
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
2395
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
2396
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
2397
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
2398
- className
2399
- ),
2400
- ...props
2401
- }
2402
- );
2403
- }
2404
- function SidebarInset({ className, ...props }) {
2405
- return /* @__PURE__ */ jsx(
2406
- "main",
2407
- {
2408
- "data-slot": "sidebar-inset",
2409
- className: cn(
2410
- "bg-background relative flex w-full flex-1 flex-col md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
2411
- className
2412
- ),
2413
- ...props
2414
- }
2415
- );
2416
- }
2417
- function SidebarInput({ className, ...props }) {
2418
- return /* @__PURE__ */ jsx(
2419
- Input,
2420
- {
2421
- "data-slot": "sidebar-input",
2422
- "data-sidebar": "input",
2423
- className: cn("bg-background h-8 w-full shadow-none", className),
2424
- ...props
2425
- }
2426
- );
2427
- }
2428
- function SidebarHeader({ className, ...props }) {
2429
- return /* @__PURE__ */ jsx(
2430
- "div",
2431
- {
2432
- "data-slot": "sidebar-header",
2433
- "data-sidebar": "header",
2434
- className: cn("flex flex-col gap-2 p-2", className),
2435
- ...props
2436
- }
2437
- );
2438
- }
2439
- function SidebarFooter({ className, ...props }) {
2440
- return /* @__PURE__ */ jsx(
2441
- "div",
2442
- {
2443
- "data-slot": "sidebar-footer",
2444
- "data-sidebar": "footer",
2445
- className: cn("flex flex-col gap-2 p-2", className),
2446
- ...props
2447
- }
2448
- );
2449
- }
2450
- function SidebarSeparator({ className, ...props }) {
2451
- return /* @__PURE__ */ jsx(
2452
- Separator,
2453
- {
2454
- "data-slot": "sidebar-separator",
2455
- "data-sidebar": "separator",
2456
- className: cn("bg-sidebar-border mx-2 w-auto", className),
2457
- ...props
2458
- }
2459
- );
2460
- }
2461
- function SidebarContent({ className, ...props }) {
2462
- return /* @__PURE__ */ jsx(
2463
- "div",
2464
- {
2465
- "data-slot": "sidebar-content",
2466
- "data-sidebar": "content",
2467
- className: cn(
2468
- "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
2469
- className
2470
- ),
2471
- ...props
2472
- }
2473
- );
2474
- }
2475
- function SidebarGroup({ className, ...props }) {
2476
- return /* @__PURE__ */ jsx(
2477
- "div",
2478
- {
2479
- "data-slot": "sidebar-group",
2480
- "data-sidebar": "group",
2481
- className: cn("relative flex w-full min-w-0 flex-col p-2", className),
2482
- ...props
2483
- }
2484
- );
2485
- }
2486
- function SidebarGroupLabel({ className, asChild = false, ...props }) {
2487
- const Comp = asChild ? Slot$1 : "div";
2488
- return /* @__PURE__ */ jsx(
2489
- Comp,
2490
- {
2491
- "data-slot": "sidebar-group-label",
2492
- "data-sidebar": "group-label",
2493
- className: cn(
2494
- "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
2495
- className
2496
- ),
2497
- ...props
2498
- }
2499
- );
2500
- }
2501
- function SidebarGroupAction({ className, asChild = false, ...props }) {
2502
- const Comp = asChild ? Slot$1 : "button";
2503
- return /* @__PURE__ */ jsx(
2504
- Comp,
2505
- {
2506
- "data-slot": "sidebar-group-action",
2507
- "data-sidebar": "group-action",
2508
- className: cn(
2509
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded p-0 outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
2510
- className
2511
- ),
2512
- ...props
2513
- }
2514
- );
2515
- }
2516
- function SidebarGroupContent({ className, ...props }) {
2517
- return /* @__PURE__ */ jsx(
2518
- "div",
2519
- {
2520
- "data-slot": "sidebar-group-content",
2521
- "data-sidebar": "group-content",
2522
- className: cn("w-full text-sm", className),
2523
- ...props
2524
- }
2525
- );
2526
- }
2527
- function SidebarMenu({ className, ...props }) {
2528
- return /* @__PURE__ */ jsx(
2529
- "ul",
2530
- {
2531
- "data-slot": "sidebar-menu",
2532
- "data-sidebar": "menu",
2533
- className: cn("flex w-full min-w-0 flex-col gap-0", className),
2534
- ...props
2535
- }
2536
- );
2537
- }
2538
- function SidebarMenuItem({ className, ...props }) {
2539
- return /* @__PURE__ */ jsx(
2540
- "li",
2541
- {
2542
- "data-slot": "sidebar-menu-item",
2543
- "data-sidebar": "menu-item",
2544
- className: cn("group/menu-item relative", className),
2545
- ...props
2546
- }
2547
- );
2548
- }
2549
- var sidebarMenuButtonVariants = cva(
2550
- [
2551
- "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>span:last-child]:truncate",
2552
- "disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50",
2553
- "active:bg-sidebar-accent active:text-sidebar-accent-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground",
2554
- "data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground",
2555
- "[&_svg]:size-4 [&_svg]:shrink-0"
2556
- ],
2557
- {
2558
- variants: {
2559
- variant: {
2560
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
2561
- outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
2562
- },
2563
- size: {
2564
- default: "h-8 text-sm",
2565
- sm: "h-7 text-xs",
2566
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
2567
- }
2568
- },
2569
- defaultVariants: {
2570
- variant: "default",
2571
- size: "default"
2572
- }
2573
- }
2574
- );
2575
- function SidebarMenuButton({
2576
- asChild = false,
2577
- isActive = false,
2578
- variant = "default",
2579
- size = "default",
2580
- tooltip,
2581
- className,
2582
- ...props
2583
- }) {
2584
- const Comp = asChild ? Slot$1 : "button";
2585
- const { isMobile, state } = useSidebarContext("SidebarMenuButton");
2586
- const button = /* @__PURE__ */ jsx(
2587
- Comp,
2588
- {
2589
- "data-slot": "sidebar-menu-button",
2590
- "data-sidebar": "menu-button",
2591
- "data-size": size,
2592
- "data-active": isActive,
2593
- className: cn(sidebarMenuButtonVariants({ variant, size }), className),
2594
- ...props
2595
- }
2596
- );
2597
- if (!tooltip) {
2598
- return button;
2599
- }
2600
- if (typeof tooltip === "string") {
2601
- tooltip = { children: tooltip };
2602
- }
2603
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
2604
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
2605
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", align: "center", hidden: state !== "collapsed" || isMobile, ...tooltip })
2606
- ] });
2607
- }
2608
- function SidebarMenuAction({
2609
- className,
2610
- asChild = false,
2611
- showOnHover = false,
2612
- ...props
2613
- }) {
2614
- const Comp = asChild ? Slot$1 : "button";
2615
- return /* @__PURE__ */ jsx(
2616
- Comp,
2617
- {
2618
- "data-slot": "sidebar-menu-action",
2619
- "data-sidebar": "menu-action",
2620
- className: cn(
2621
- "text-sidebar-foreground ring-sidebar-ring peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded p-0 outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
2622
- showOnHover && "peer-data-active/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 aria-expanded:opacity-100 md:opacity-0",
2623
- className
2624
- ),
2625
- ...props
2626
- }
2627
- );
2628
- }
2629
- function SidebarMenuBadge({ className, ...props }) {
2630
- return /* @__PURE__ */ jsx(
2631
- "div",
2632
- {
2633
- "data-slot": "sidebar-menu-badge",
2634
- "data-sidebar": "menu-badge",
2635
- className: cn(
2636
- "text-sidebar-foreground peer-hover/menu-button:text-sidebar-accent-foreground peer-data-active/menu-button:text-sidebar-accent-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none group-data-[collapsible=icon]:hidden peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1",
2637
- className
2638
- ),
2639
- ...props
2640
- }
2641
- );
2642
- }
2643
- function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
2644
- const [width] = React16.useState(() => {
2645
- return `${Math.floor(Math.random() * 40) + 50}%`;
2646
- });
2647
- return /* @__PURE__ */ jsxs(
2648
- "div",
2649
- {
2650
- "data-slot": "sidebar-menu-skeleton",
2651
- "data-sidebar": "menu-skeleton",
2652
- className: cn("flex h-8 items-center gap-2 rounded px-2", className),
2653
- ...props,
2654
- children: [
2655
- showIcon && /* @__PURE__ */ jsx(Skeleton, { className: "size-4 rounded", "data-sidebar": "menu-skeleton-icon" }),
2656
- /* @__PURE__ */ jsx(
2657
- Skeleton,
2658
- {
2659
- className: "h-4 max-w-(--skeleton-width) flex-1",
2660
- "data-sidebar": "menu-skeleton-text",
2661
- style: {
2662
- "--skeleton-width": width
2663
- }
2664
- }
2665
- )
2666
- ]
2667
- }
2668
- );
2669
- }
2670
- function SidebarMenuSub({ className, ...props }) {
2671
- return /* @__PURE__ */ jsx(
2672
- "ul",
2673
- {
2674
- "data-slot": "sidebar-menu-sub",
2675
- "data-sidebar": "menu-sub",
2676
- className: cn(
2677
- "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
2678
- className
2679
- ),
2680
- ...props
2681
- }
2682
- );
2683
- }
2684
- function SidebarMenuSubItem({ className, ...props }) {
2685
- return /* @__PURE__ */ jsx(
2686
- "li",
2687
- {
2688
- "data-slot": "sidebar-menu-sub-item",
2689
- "data-sidebar": "menu-sub-item",
2690
- className: cn("group/menu-sub-item relative", className),
2691
- ...props
2692
- }
2693
- );
2694
- }
2695
- function SidebarMenuSubButton({
2696
- asChild = false,
2697
- size = "md",
2698
- isActive = false,
2699
- className,
2700
- ...props
2701
- }) {
2702
- const Comp = asChild ? Slot$1 : "a";
2703
- return /* @__PURE__ */ jsx(
2704
- Comp,
2705
- {
2706
- "data-slot": "sidebar-menu-sub-button",
2707
- "data-sidebar": "menu-sub-button",
2708
- "data-size": size,
2709
- "data-active": isActive,
2710
- className: cn(
2711
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-[state=active]:bg-sidebar-accent data-[state=active]:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded px-2 outline-hidden group-data-[collapsible=icon]:hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
2712
- className
2713
- ),
2714
- ...props
2715
- }
2716
- );
2717
- }
2718
- var buttonVariants = cva(
2719
- [
2720
- "inline-flex shrink-0 items-center justify-center gap-2 rounded text-sm font-medium whitespace-nowrap transition-all outline-none",
2721
- "disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50",
2722
- "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2723
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring",
2724
- "aria-invalid:ring-error/20 dark:aria-invalid:ring-error/40 aria-invalid:border-error"
2725
- ],
2726
- {
2727
- variants: {
2728
- variant: {
2729
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
2730
- error: "bg-error hover:bg-error/90 focus-visible:ring-error/20 dark:focus-visible:ring-error/40 dark:bg-error/60 text-white",
2731
- outline: "bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs",
2732
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
2733
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
2734
- link: "text-primary underline-offset-4 hover:underline"
2735
- },
2736
- size: {
2737
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
2738
- sm: "h-8 gap-1.5 rounded px-3 has-[>svg]:px-2.5",
2739
- lg: "h-10 rounded px-6 has-[>svg]:px-4",
2740
- icon: "size-9",
2741
- "icon-sm": "size-8",
2742
- "icon-lg": "size-10"
2743
- },
2744
- fullWidth: {
2745
- true: "w-full"
2746
- }
2747
- },
2748
- defaultVariants: {
2749
- variant: "default",
2750
- size: "default",
2751
- fullWidth: false
2752
- }
2753
- }
2754
- );
2755
- function Button({
2756
- asChild = false,
2757
- variant = "default",
2758
- disabled = false,
2759
- fullWidth = false,
2760
- loadingPosition: loadingPositionProp = "start",
2761
- children,
2762
- type = "button",
2763
- loading = false,
2764
- size = "default",
2765
- endIcon,
2766
- startIcon,
2767
- className,
2768
- ...props
2769
- }) {
2770
- const Comp = asChild ? Slot$1 : "button";
2771
- const isDisabled = disabled || loading;
2772
- const loadingPosition = size?.startsWith("icon") ? "center" : loadingPositionProp;
2773
- return /* @__PURE__ */ jsx(
2774
- Comp,
2775
- {
2776
- "data-slot": "button",
2777
- "aria-disabled": isDisabled || void 0,
2778
- className: cn(buttonVariants({ fullWidth, size, variant }), className),
2779
- "data-state": loading ? "loading" : void 0,
2780
- disabled: isDisabled,
2781
- role: Comp !== "button" ? "button" : void 0,
2782
- tabIndex: isDisabled ? -1 : 0,
2783
- type: Comp === "button" ? type : void 0,
2784
- "data-size": size,
2785
- "data-variant": variant,
2786
- ...props,
2787
- children: /* @__PURE__ */ jsx(
2788
- ButtonContent,
2789
- {
2790
- loading,
2791
- size,
2792
- loadingPosition,
2793
- startIcon,
2794
- endIcon,
2795
- asChild,
2796
- children
2797
- }
2798
- )
2799
- }
2800
- );
2801
- }
2802
- function ButtonContent({
2803
- children,
2804
- loading = false,
2805
- loadingPosition = "start",
2806
- startIcon,
2807
- asChild,
2808
- endIcon,
2809
- ...props
2810
- }) {
2811
- const isStartLoading = loading && loadingPosition === "start";
2812
- const StartIcon = isStartLoading ? /* @__PURE__ */ jsx(Spinner, { "aria-label": "Loading" }) : startIcon || null;
2813
- const isEndLoading = loading && loadingPosition === "end";
2814
- const EndIcon = isEndLoading ? /* @__PURE__ */ jsx(Spinner, { "aria-label": "Loading" }) : endIcon || null;
2815
- const isCenterLoading = loading && loadingPosition === "center";
2816
- return asChild && React16.isValidElement(children) ? React16.cloneElement(
2817
- children,
2818
- props,
2819
- /* @__PURE__ */ jsxs(React16.Fragment, { children: [
2820
- StartIcon,
2821
- isCenterLoading ? /* @__PURE__ */ jsx(Spinner, { "aria-label": "Loading" }) : React16.isValidElement(children) ? children.props?.children : null,
2822
- EndIcon
2823
- ] })
2824
- ) : /* @__PURE__ */ jsxs(React16.Fragment, { children: [
2825
- StartIcon,
2826
- isCenterLoading ? /* @__PURE__ */ jsx(Spinner, { "aria-label": "Loading" }) : children,
2827
- EndIcon
2828
- ] });
2829
- }
2830
-
2831
- export { Button, ColorPicker, ColorPickerAlphaSlider, ColorPickerArea, ColorPickerContent, ColorPickerEyeDropper, ColorPickerFormatSelect, ColorPickerHueSlider, ColorPickerInput, ColorPickerSwatch, ColorPickerTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Stepper, StepperActivationMode, StepperContent, StepperDataState, StepperDescription, StepperFocusIntent, StepperIndicator, StepperItem, StepperNav, StepperNavigationDirection, StepperNextTrigger, StepperOrientation, StepperPanel, StepperPrevTrigger, StepperTitle, StepperTrigger, Toaster, useColorPickerStore, useSidebar, useSidebarContext, useStepperContext, useStepperFocusContext, useStepperItemContext };