@proyecto-viviana/solidaria-components 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/dist/ActionBar.js +184 -0
  2. package/dist/ActionBar.js.map +1 -0
  3. package/dist/ActionBar.jsx +128 -0
  4. package/dist/ActionBar.jsx.map +1 -0
  5. package/dist/ActionGroup.js +179 -0
  6. package/dist/ActionGroup.js.map +1 -0
  7. package/dist/ActionGroup.jsx +129 -0
  8. package/dist/ActionGroup.jsx.map +1 -0
  9. package/dist/Alert.js +111 -0
  10. package/dist/Alert.js.map +1 -0
  11. package/dist/Alert.jsx +82 -0
  12. package/dist/Alert.jsx.map +1 -0
  13. package/dist/Autocomplete.js +130 -0
  14. package/dist/Autocomplete.js.map +1 -0
  15. package/dist/Autocomplete.jsx +116 -0
  16. package/dist/Autocomplete.jsx.map +1 -0
  17. package/dist/Breadcrumbs.d.ts.map +1 -1
  18. package/dist/Breadcrumbs.js +334 -0
  19. package/dist/Breadcrumbs.js.map +1 -0
  20. package/dist/Breadcrumbs.jsx +266 -0
  21. package/dist/Breadcrumbs.jsx.map +1 -0
  22. package/dist/Button.d.ts.map +1 -1
  23. package/dist/Button.js +348 -0
  24. package/dist/Button.js.map +1 -0
  25. package/dist/Button.jsx +314 -0
  26. package/dist/Button.jsx.map +1 -0
  27. package/dist/Calendar.d.ts +4 -4
  28. package/dist/Calendar.d.ts.map +1 -1
  29. package/dist/Calendar.js +538 -0
  30. package/dist/Calendar.js.map +1 -0
  31. package/dist/Calendar.jsx +333 -0
  32. package/dist/Calendar.jsx.map +1 -0
  33. package/dist/CalendarPicker.d.ts +33 -0
  34. package/dist/CalendarPicker.d.ts.map +1 -0
  35. package/dist/CalendarPicker.js +44 -0
  36. package/dist/CalendarPicker.js.map +1 -0
  37. package/dist/CalendarPicker.jsx +44 -0
  38. package/dist/CalendarPicker.jsx.map +1 -0
  39. package/dist/Checkbox.d.ts +83 -4
  40. package/dist/Checkbox.d.ts.map +1 -1
  41. package/dist/Checkbox.js +923 -0
  42. package/dist/Checkbox.js.map +1 -0
  43. package/dist/Checkbox.jsx +707 -0
  44. package/dist/Checkbox.jsx.map +1 -0
  45. package/dist/Collection.d.ts.map +1 -1
  46. package/dist/Collection.js +202 -0
  47. package/dist/Collection.js.map +1 -0
  48. package/dist/Collection.jsx +152 -0
  49. package/dist/Collection.jsx.map +1 -0
  50. package/dist/Color.d.ts.map +1 -1
  51. package/dist/Color.js +1720 -0
  52. package/dist/Color.js.map +1 -0
  53. package/dist/Color.jsx +1344 -0
  54. package/dist/Color.jsx.map +1 -0
  55. package/dist/ColorEditor.js +208 -0
  56. package/dist/ColorEditor.js.map +1 -0
  57. package/dist/ColorEditor.jsx +120 -0
  58. package/dist/ColorEditor.jsx.map +1 -0
  59. package/dist/ComboBox.d.ts +4 -4
  60. package/dist/ComboBox.d.ts.map +1 -1
  61. package/dist/ComboBox.js +992 -0
  62. package/dist/ComboBox.js.map +1 -0
  63. package/dist/ComboBox.jsx +714 -0
  64. package/dist/ComboBox.jsx.map +1 -0
  65. package/dist/ContextualHelpTrigger.js +146 -0
  66. package/dist/ContextualHelpTrigger.js.map +1 -0
  67. package/dist/ContextualHelpTrigger.jsx +109 -0
  68. package/dist/ContextualHelpTrigger.jsx.map +1 -0
  69. package/dist/DateField.d.ts +3 -3
  70. package/dist/DateField.d.ts.map +1 -1
  71. package/dist/DateField.js +4 -0
  72. package/dist/DateField.jsx +4 -0
  73. package/dist/DateField2.js +499 -0
  74. package/dist/DateField2.js.map +1 -0
  75. package/dist/DateField2.jsx +317 -0
  76. package/dist/DateField2.jsx.map +1 -0
  77. package/dist/DatePicker.d.ts +4 -4
  78. package/dist/DatePicker.d.ts.map +1 -1
  79. package/dist/DatePicker.js +991 -0
  80. package/dist/DatePicker.js.map +1 -0
  81. package/dist/DatePicker.jsx +682 -0
  82. package/dist/DatePicker.jsx.map +1 -0
  83. package/dist/Dialog.d.ts.map +1 -1
  84. package/dist/Dialog.js +337 -0
  85. package/dist/Dialog.js.map +1 -0
  86. package/dist/Dialog.jsx +192 -0
  87. package/dist/Dialog.jsx.map +1 -0
  88. package/dist/Disclosure.d.ts.map +1 -1
  89. package/dist/Disclosure.js +328 -0
  90. package/dist/Disclosure.js.map +1 -0
  91. package/dist/Disclosure.jsx +230 -0
  92. package/dist/Disclosure.jsx.map +1 -0
  93. package/dist/DragAndDrop.d.ts.map +1 -1
  94. package/dist/DragAndDrop.js +176 -0
  95. package/dist/DragAndDrop.js.map +1 -0
  96. package/dist/DragAndDrop.jsx +160 -0
  97. package/dist/DragAndDrop.jsx.map +1 -0
  98. package/dist/DropZone.d.ts.map +1 -1
  99. package/dist/DropZone.js +189 -0
  100. package/dist/DropZone.js.map +1 -0
  101. package/dist/DropZone.jsx +144 -0
  102. package/dist/DropZone.jsx.map +1 -0
  103. package/dist/FieldError.js +66 -0
  104. package/dist/FieldError.js.map +1 -0
  105. package/dist/FieldError.jsx +47 -0
  106. package/dist/FieldError.jsx.map +1 -0
  107. package/dist/FileTrigger.js +79 -0
  108. package/dist/FileTrigger.js.map +1 -0
  109. package/dist/FileTrigger.jsx +49 -0
  110. package/dist/FileTrigger.jsx.map +1 -0
  111. package/dist/Focusable.js +70 -0
  112. package/dist/Focusable.js.map +1 -0
  113. package/dist/Focusable.jsx +69 -0
  114. package/dist/Focusable.jsx.map +1 -0
  115. package/dist/Form.js +99 -0
  116. package/dist/Form.js.map +1 -0
  117. package/dist/Form.jsx +73 -0
  118. package/dist/Form.jsx.map +1 -0
  119. package/dist/GridList.d.ts +34 -2
  120. package/dist/GridList.d.ts.map +1 -1
  121. package/dist/GridList.js +723 -0
  122. package/dist/GridList.js.map +1 -0
  123. package/dist/GridList.jsx +552 -0
  124. package/dist/GridList.jsx.map +1 -0
  125. package/dist/HiddenTimeInput.js +104 -0
  126. package/dist/HiddenTimeInput.js.map +1 -0
  127. package/dist/HiddenTimeInput.jsx +69 -0
  128. package/dist/HiddenTimeInput.jsx.map +1 -0
  129. package/dist/Icon.d.ts.map +1 -1
  130. package/dist/Icon.js +127 -0
  131. package/dist/Icon.js.map +1 -0
  132. package/dist/Icon.jsx +72 -0
  133. package/dist/Icon.jsx.map +1 -0
  134. package/dist/Keyboard.js +30 -0
  135. package/dist/Keyboard.js.map +1 -0
  136. package/dist/Keyboard.jsx +24 -0
  137. package/dist/Keyboard.jsx.map +1 -0
  138. package/dist/Landmark.js +134 -0
  139. package/dist/Landmark.js.map +1 -0
  140. package/dist/Landmark.jsx +118 -0
  141. package/dist/Landmark.jsx.map +1 -0
  142. package/dist/Link.d.ts.map +1 -1
  143. package/dist/Link.js +219 -0
  144. package/dist/Link.js.map +1 -0
  145. package/dist/Link.jsx +189 -0
  146. package/dist/Link.jsx.map +1 -0
  147. package/dist/ListBox.d.ts.map +1 -1
  148. package/dist/ListBox.js +670 -0
  149. package/dist/ListBox.js.map +1 -0
  150. package/dist/ListBox.jsx +508 -0
  151. package/dist/ListBox.jsx.map +1 -0
  152. package/dist/Menu.d.ts +27 -9
  153. package/dist/Menu.d.ts.map +1 -1
  154. package/dist/Menu.js +1254 -0
  155. package/dist/Menu.js.map +1 -0
  156. package/dist/Menu.jsx +1042 -0
  157. package/dist/Menu.jsx.map +1 -0
  158. package/dist/Meter.d.ts.map +1 -1
  159. package/dist/Meter.js +123 -0
  160. package/dist/Meter.js.map +1 -0
  161. package/dist/Meter.jsx +107 -0
  162. package/dist/Meter.jsx.map +1 -0
  163. package/dist/Modal.d.ts.map +1 -1
  164. package/dist/Modal.js +380 -0
  165. package/dist/Modal.js.map +1 -0
  166. package/dist/Modal.jsx +314 -0
  167. package/dist/Modal.jsx.map +1 -0
  168. package/dist/NumberField.d.ts +3 -3
  169. package/dist/NumberField.d.ts.map +1 -1
  170. package/dist/NumberField.js +573 -0
  171. package/dist/NumberField.js.map +1 -0
  172. package/dist/NumberField.jsx +443 -0
  173. package/dist/NumberField.jsx.map +1 -0
  174. package/dist/Popover.d.ts +10 -2
  175. package/dist/Popover.d.ts.map +1 -1
  176. package/dist/Popover.js +464 -0
  177. package/dist/Popover.js.map +1 -0
  178. package/dist/Popover.jsx +333 -0
  179. package/dist/Popover.jsx.map +1 -0
  180. package/dist/Pressable.js +69 -0
  181. package/dist/Pressable.js.map +1 -0
  182. package/dist/Pressable.jsx +68 -0
  183. package/dist/Pressable.jsx.map +1 -0
  184. package/dist/ProgressBar.d.ts.map +1 -1
  185. package/dist/ProgressBar.js +130 -0
  186. package/dist/ProgressBar.js.map +1 -0
  187. package/dist/ProgressBar.jsx +114 -0
  188. package/dist/ProgressBar.jsx.map +1 -0
  189. package/dist/RadioGroup.d.ts +82 -4
  190. package/dist/RadioGroup.d.ts.map +1 -1
  191. package/dist/RadioGroup.js +931 -0
  192. package/dist/RadioGroup.js.map +1 -0
  193. package/dist/RadioGroup.jsx +681 -0
  194. package/dist/RadioGroup.jsx.map +1 -0
  195. package/dist/RangeCalendar.d.ts.map +1 -1
  196. package/dist/RangeCalendar.js +410 -0
  197. package/dist/RangeCalendar.js.map +1 -0
  198. package/dist/RangeCalendar.jsx +253 -0
  199. package/dist/RangeCalendar.jsx.map +1 -0
  200. package/dist/RouterProvider.js +118 -0
  201. package/dist/RouterProvider.js.map +1 -0
  202. package/dist/RouterProvider.jsx +112 -0
  203. package/dist/RouterProvider.jsx.map +1 -0
  204. package/dist/SearchField.d.ts +2 -2
  205. package/dist/SearchField.d.ts.map +1 -1
  206. package/dist/SearchField.js +643 -0
  207. package/dist/SearchField.js.map +1 -0
  208. package/dist/SearchField.jsx +526 -0
  209. package/dist/SearchField.jsx.map +1 -0
  210. package/dist/Select.d.ts.map +1 -1
  211. package/dist/Select.js +1031 -0
  212. package/dist/Select.js.map +1 -0
  213. package/dist/Select.jsx +744 -0
  214. package/dist/Select.jsx.map +1 -0
  215. package/dist/SelectionIndicator.d.ts.map +1 -1
  216. package/dist/SelectionIndicator.js +86 -0
  217. package/dist/SelectionIndicator.js.map +1 -0
  218. package/dist/SelectionIndicator.jsx +50 -0
  219. package/dist/SelectionIndicator.jsx.map +1 -0
  220. package/dist/Separator.js +97 -0
  221. package/dist/Separator.js.map +1 -0
  222. package/dist/Separator.jsx +85 -0
  223. package/dist/Separator.jsx.map +1 -0
  224. package/dist/SharedElementTransition.d.ts.map +1 -1
  225. package/dist/SharedElementTransition.js +165 -0
  226. package/dist/SharedElementTransition.js.map +1 -0
  227. package/dist/SharedElementTransition.jsx +138 -0
  228. package/dist/SharedElementTransition.jsx.map +1 -0
  229. package/dist/Slider.d.ts +33 -1
  230. package/dist/Slider.d.ts.map +1 -1
  231. package/dist/Slider.js +515 -0
  232. package/dist/Slider.js.map +1 -0
  233. package/dist/Slider.jsx +403 -0
  234. package/dist/Slider.jsx.map +1 -0
  235. package/dist/StepList.js +198 -0
  236. package/dist/StepList.js.map +1 -0
  237. package/dist/StepList.jsx +141 -0
  238. package/dist/StepList.jsx.map +1 -0
  239. package/dist/Switch.d.ts +65 -2
  240. package/dist/Switch.d.ts.map +1 -1
  241. package/dist/Switch.js +534 -0
  242. package/dist/Switch.js.map +1 -0
  243. package/dist/Switch.jsx +393 -0
  244. package/dist/Switch.jsx.map +1 -0
  245. package/dist/Table.d.ts +48 -0
  246. package/dist/Table.d.ts.map +1 -1
  247. package/dist/Table.js +1759 -0
  248. package/dist/Table.js.map +1 -0
  249. package/dist/Table.jsx +1348 -0
  250. package/dist/Table.jsx.map +1 -0
  251. package/dist/Tabs.d.ts +0 -4
  252. package/dist/Tabs.d.ts.map +1 -1
  253. package/dist/Tabs.js +595 -0
  254. package/dist/Tabs.js.map +1 -0
  255. package/dist/Tabs.jsx +367 -0
  256. package/dist/Tabs.jsx.map +1 -0
  257. package/dist/TagGroup.d.ts.map +1 -1
  258. package/dist/TagGroup.js +378 -0
  259. package/dist/TagGroup.js.map +1 -0
  260. package/dist/TagGroup.jsx +270 -0
  261. package/dist/TagGroup.jsx.map +1 -0
  262. package/dist/Text.d.ts +18 -6
  263. package/dist/Text.d.ts.map +1 -1
  264. package/dist/Text.js +42 -0
  265. package/dist/Text.js.map +1 -0
  266. package/dist/Text.jsx +35 -0
  267. package/dist/Text.jsx.map +1 -0
  268. package/dist/TextField.d.ts +6 -6
  269. package/dist/TextField.d.ts.map +1 -1
  270. package/dist/TextField.js +436 -0
  271. package/dist/TextField.js.map +1 -0
  272. package/dist/TextField.jsx +403 -0
  273. package/dist/TextField.jsx.map +1 -0
  274. package/dist/TimeField.d.ts +3 -3
  275. package/dist/TimeField.d.ts.map +1 -1
  276. package/dist/TimeField.js +372 -0
  277. package/dist/TimeField.js.map +1 -0
  278. package/dist/TimeField.jsx +224 -0
  279. package/dist/TimeField.jsx.map +1 -0
  280. package/dist/Toast.d.ts +14 -0
  281. package/dist/Toast.d.ts.map +1 -1
  282. package/dist/Toast.js +551 -0
  283. package/dist/Toast.js.map +1 -0
  284. package/dist/Toast.jsx +361 -0
  285. package/dist/Toast.jsx.map +1 -0
  286. package/dist/ToggleButton.d.ts.map +1 -1
  287. package/dist/ToggleButton.js +123 -0
  288. package/dist/ToggleButton.js.map +1 -0
  289. package/dist/ToggleButton.jsx +88 -0
  290. package/dist/ToggleButton.jsx.map +1 -0
  291. package/dist/ToggleButtonGroup.d.ts.map +1 -1
  292. package/dist/ToggleButtonGroup.js +114 -0
  293. package/dist/ToggleButtonGroup.js.map +1 -0
  294. package/dist/ToggleButtonGroup.jsx +85 -0
  295. package/dist/ToggleButtonGroup.jsx.map +1 -0
  296. package/dist/Toolbar.js +112 -0
  297. package/dist/Toolbar.js.map +1 -0
  298. package/dist/Toolbar.jsx +92 -0
  299. package/dist/Toolbar.jsx.map +1 -0
  300. package/dist/Tooltip.d.ts.map +1 -1
  301. package/dist/Tooltip.js +539 -0
  302. package/dist/Tooltip.js.map +1 -0
  303. package/dist/Tooltip.jsx +465 -0
  304. package/dist/Tooltip.jsx.map +1 -0
  305. package/dist/Tree.d.ts +14 -2
  306. package/dist/Tree.d.ts.map +1 -1
  307. package/dist/Tree.js +1424 -0
  308. package/dist/Tree.js.map +1 -0
  309. package/dist/Tree.jsx +1172 -0
  310. package/dist/Tree.jsx.map +1 -0
  311. package/dist/Virtualizer.d.ts +16 -2
  312. package/dist/Virtualizer.d.ts.map +1 -1
  313. package/dist/Virtualizer.js +2 -0
  314. package/dist/Virtualizer.jsx +2 -0
  315. package/dist/Virtualizer2.js +751 -0
  316. package/dist/Virtualizer2.js.map +1 -0
  317. package/dist/Virtualizer2.jsx +730 -0
  318. package/dist/Virtualizer2.jsx.map +1 -0
  319. package/dist/VirtualizerLayouts.d.ts +18 -0
  320. package/dist/VirtualizerLayouts.d.ts.map +1 -1
  321. package/dist/VisuallyHidden.js +42 -0
  322. package/dist/VisuallyHidden.js.map +1 -0
  323. package/dist/VisuallyHidden.jsx +35 -0
  324. package/dist/VisuallyHidden.jsx.map +1 -0
  325. package/dist/contexts.js +33 -0
  326. package/dist/contexts.js.map +1 -0
  327. package/dist/contexts.jsx +33 -0
  328. package/dist/contexts.jsx.map +1 -0
  329. package/dist/index.d.ts +7 -6
  330. package/dist/index.d.ts.map +1 -1
  331. package/dist/index.js +70 -23932
  332. package/dist/index.jsx +70 -18337
  333. package/dist/useDragAndDrop.js +2 -0
  334. package/dist/useDragAndDrop.jsx +2 -0
  335. package/dist/useDragAndDrop2.js +395 -0
  336. package/dist/useDragAndDrop2.js.map +1 -0
  337. package/dist/useDragAndDrop2.jsx +395 -0
  338. package/dist/useDragAndDrop2.jsx.map +1 -0
  339. package/dist/utils.d.ts +83 -11
  340. package/dist/utils.d.ts.map +1 -1
  341. package/dist/utils.js +285 -0
  342. package/dist/utils.js.map +1 -0
  343. package/dist/utils.jsx +277 -0
  344. package/dist/utils.jsx.map +1 -0
  345. package/dist/virtualizer/Layout.js +144 -0
  346. package/dist/virtualizer/Layout.js.map +1 -0
  347. package/dist/virtualizer/Layout.jsx +144 -0
  348. package/dist/virtualizer/Layout.jsx.map +1 -0
  349. package/package.json +401 -4
  350. package/src/Breadcrumbs.tsx +3 -1
  351. package/src/Button.tsx +22 -2
  352. package/src/Calendar.tsx +27 -10
  353. package/src/CalendarPicker.tsx +73 -0
  354. package/src/Checkbox.tsx +539 -3
  355. package/src/Collection.tsx +9 -3
  356. package/src/Color.tsx +42 -14
  357. package/src/ComboBox.tsx +50 -6
  358. package/src/DateField.tsx +20 -2
  359. package/src/DatePicker.tsx +57 -5
  360. package/src/Dialog.tsx +13 -5
  361. package/src/Disclosure.tsx +3 -1
  362. package/src/DragAndDrop.tsx +3 -1
  363. package/src/DropZone.tsx +3 -1
  364. package/src/GridList.tsx +125 -24
  365. package/src/Icon.tsx +3 -1
  366. package/src/Link.tsx +3 -1
  367. package/src/ListBox.tsx +31 -4
  368. package/src/Menu.tsx +252 -128
  369. package/src/Meter.tsx +3 -1
  370. package/src/Modal.tsx +100 -52
  371. package/src/NumberField.tsx +51 -8
  372. package/src/Popover.tsx +40 -10
  373. package/src/ProgressBar.tsx +3 -1
  374. package/src/RadioGroup.tsx +468 -4
  375. package/src/RangeCalendar.tsx +3 -1
  376. package/src/SearchField.tsx +27 -3
  377. package/src/Select.tsx +22 -7
  378. package/src/SelectionIndicator.tsx +3 -1
  379. package/src/SharedElementTransition.tsx +3 -1
  380. package/src/Slider.tsx +159 -13
  381. package/src/Switch.tsx +395 -2
  382. package/src/Table.tsx +409 -95
  383. package/src/Tabs.tsx +16 -45
  384. package/src/TagGroup.tsx +3 -1
  385. package/src/Text.tsx +31 -10
  386. package/src/TextField.tsx +43 -5
  387. package/src/TimeField.tsx +20 -2
  388. package/src/Toast.tsx +79 -14
  389. package/src/ToggleButton.tsx +3 -1
  390. package/src/ToggleButtonGroup.tsx +3 -1
  391. package/src/Tooltip.tsx +3 -1
  392. package/src/Tree.tsx +77 -9
  393. package/src/Virtualizer.tsx +180 -31
  394. package/src/VirtualizerLayouts.ts +45 -10
  395. package/src/index.ts +50 -0
  396. package/src/utils.tsx +243 -27
  397. package/dist/index.js.map +0 -1
  398. package/dist/index.jsx.map +0 -1
package/dist/Color.jsx ADDED
@@ -0,0 +1,1344 @@
1
+ import { filterDOMProps, useRenderProps } from "./utils.jsx";
2
+ import { Show, createContext, createEffect, createMemo, createSignal, onCleanup, splitProps, untrack, useContext } from "solid-js";
3
+ import { createColorArea, createColorField, createColorSlider, createColorSwatch, createColorWheel, createFocusRing, createHover, createListBox, createOption, mergeProps as mergeProps$1 } from "@proyecto-viviana/solidaria";
4
+ import { createColorAreaState, createColorFieldState, createColorSliderState, createColorWheelState, createListState, normalizeColor } from "@proyecto-viviana/solid-stately";
5
+ //#region src/Color.tsx
6
+ /**
7
+ * Color components for solidaria-components
8
+ *
9
+ * Pre-wired headless color picker components that combine state + aria hooks.
10
+ * Port of react-aria-components color components.
11
+ */
12
+ const ColorPickerContextInternal = createContext(null);
13
+ const ColorPickerStateContextInternal = createContext(null);
14
+ const ColorSwatchContextInternal = createContext(null);
15
+ const ColorSwatchPickerContextInternal = createContext(null);
16
+ const ColorSliderContext = createContext(null);
17
+ /**
18
+ * A color slider allows users to adjust a single color channel.
19
+ */
20
+ function ColorSlider(props) {
21
+ const pickerContext = useContext(ColorPickerContextInternal);
22
+ const [local, stateProps, ariaProps, rest] = splitProps(props, [
23
+ "children",
24
+ "class",
25
+ "style",
26
+ "slot",
27
+ "label"
28
+ ], [
29
+ "value",
30
+ "defaultValue",
31
+ "onChange",
32
+ "onChangeEnd",
33
+ "channel",
34
+ "colorSpace"
35
+ ], [
36
+ "id",
37
+ "aria-label",
38
+ "aria-labelledby",
39
+ "aria-describedby",
40
+ "aria-details",
41
+ "isDisabled",
42
+ "name",
43
+ "form",
44
+ "orientation",
45
+ "channelName"
46
+ ]);
47
+ const state = createColorSliderState(() => ({
48
+ value: stateProps.value ?? pickerContext?.value,
49
+ defaultValue: stateProps.defaultValue,
50
+ onChange: stateProps.onChange ?? pickerContext?.onChange,
51
+ onChangeEnd: stateProps.onChangeEnd,
52
+ channel: stateProps.channel,
53
+ colorSpace: stateProps.colorSpace,
54
+ orientation: ariaProps.orientation,
55
+ isDisabled: ariaProps.isDisabled
56
+ }));
57
+ let trackRef;
58
+ const setTrackRef = (el) => {
59
+ trackRef = el;
60
+ };
61
+ let inputRef;
62
+ const setInputRef = (el) => {
63
+ inputRef = el;
64
+ };
65
+ const colorSliderAria = createColorSlider(() => ({
66
+ id: ariaProps.id,
67
+ channel: stateProps.channel,
68
+ label: local.label,
69
+ "aria-label": ariaProps["aria-label"],
70
+ "aria-labelledby": ariaProps["aria-labelledby"],
71
+ "aria-describedby": ariaProps["aria-describedby"],
72
+ "aria-details": ariaProps["aria-details"],
73
+ isDisabled: ariaProps.isDisabled,
74
+ name: ariaProps.name,
75
+ form: ariaProps.form,
76
+ orientation: ariaProps.orientation,
77
+ channelName: ariaProps.channelName
78
+ }), () => state, () => trackRef ?? null, () => inputRef ?? null);
79
+ const renderValues = createMemo(() => ({
80
+ isDisabled: state.isDisabled,
81
+ isDragging: state.isDragging,
82
+ channel: state.channel,
83
+ orientation: state.orientation,
84
+ value: state.getThumbValue(),
85
+ valueLabel: state.getThumbValueLabel(),
86
+ color: state.value,
87
+ defaultStyle: colorSliderAria.trackProps.style ?? {}
88
+ }));
89
+ const renderProps = useRenderProps({
90
+ get children() {
91
+ return props.children;
92
+ },
93
+ class: local.class,
94
+ style: local.style,
95
+ defaultClassName: "solidaria-ColorSlider"
96
+ }, renderValues);
97
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
98
+ return <ColorSliderContext.Provider value={{
99
+ state,
100
+ get trackProps() {
101
+ return colorSliderAria.trackProps;
102
+ },
103
+ get thumbProps() {
104
+ return colorSliderAria.thumbProps;
105
+ },
106
+ get inputProps() {
107
+ return colorSliderAria.inputProps;
108
+ },
109
+ get outputProps() {
110
+ return colorSliderAria.outputProps;
111
+ },
112
+ get labelProps() {
113
+ return colorSliderAria.labelProps;
114
+ },
115
+ get trackRef() {
116
+ return trackRef;
117
+ },
118
+ setTrackRef,
119
+ setInputRef
120
+ }}>
121
+ <div {...domProps()} class={renderProps.class()} style={renderProps.style()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0} data-orientation={state.orientation} slot={local.slot || void 0}>
122
+ {renderProps.renderChildren()}
123
+ </div>
124
+ </ColorSliderContext.Provider>;
125
+ }
126
+ /**
127
+ * The label element of a color slider.
128
+ */
129
+ function ColorSliderLabel(props) {
130
+ const [local, domProps] = splitProps(props, [
131
+ "class",
132
+ "slot",
133
+ "children"
134
+ ]);
135
+ const context = useContext(ColorSliderContext);
136
+ if (!context) throw new Error("ColorSliderLabel must be used within a ColorSlider");
137
+ const labelProps = () => {
138
+ const { ref: _ref, ...rest } = context.labelProps;
139
+ return rest;
140
+ };
141
+ return <label {...domProps} {...labelProps()} class={local.class}>
142
+ {local.children}
143
+ </label>;
144
+ }
145
+ /**
146
+ * The output element of a color slider.
147
+ */
148
+ function ColorSliderOutput(props) {
149
+ const [local, domProps] = splitProps(props, [
150
+ "class",
151
+ "slot",
152
+ "children"
153
+ ]);
154
+ const context = useContext(ColorSliderContext);
155
+ if (!context) throw new Error("ColorSliderOutput must be used within a ColorSlider");
156
+ const state = context.state;
157
+ const renderValues = createMemo(() => ({
158
+ isDisabled: state.isDisabled,
159
+ isDragging: state.isDragging,
160
+ channel: state.channel,
161
+ orientation: state.orientation,
162
+ value: state.getThumbValue(),
163
+ valueLabel: state.getThumbValueLabel(),
164
+ color: state.value,
165
+ defaultStyle: context.trackProps.style ?? {}
166
+ }));
167
+ const children = () => typeof local.children === "function" ? local.children(renderValues()) : local.children ?? renderValues().valueLabel;
168
+ return <output {...domProps} {...context.outputProps} class={local.class}>
169
+ {children()}
170
+ </output>;
171
+ }
172
+ /**
173
+ * The track element of a color slider.
174
+ */
175
+ function ColorSliderTrack(props) {
176
+ const [local, domProps] = splitProps(props, [
177
+ "class",
178
+ "style",
179
+ "slot",
180
+ "children"
181
+ ]);
182
+ const context = useContext(ColorSliderContext);
183
+ if (!context) throw new Error("ColorSliderTrack must be used within a ColorSlider");
184
+ const state = context.state;
185
+ const renderValues = createMemo(() => ({
186
+ isDisabled: state.isDisabled,
187
+ isDragging: state.isDragging,
188
+ orientation: state.orientation,
189
+ defaultStyle: context.trackProps.style ?? {}
190
+ }));
191
+ const renderProps = useRenderProps({
192
+ get children() {
193
+ return props.children;
194
+ },
195
+ class: local.class,
196
+ style: local.style,
197
+ defaultClassName: "solidaria-ColorSlider-track"
198
+ }, renderValues);
199
+ const cleanTrackProps = () => {
200
+ const { ref: _ref, style: _trackStyle, ...rest } = context.trackProps;
201
+ return rest;
202
+ };
203
+ const mergedStyle = () => {
204
+ const trackStyle = context.trackProps.style || {};
205
+ const renderStyle = renderProps.style() || {};
206
+ return {
207
+ ...trackStyle,
208
+ ...renderStyle
209
+ };
210
+ };
211
+ return <div {...domProps} ref={context.setTrackRef} {...cleanTrackProps()} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0} data-orientation={state.orientation}>
212
+ {renderProps.renderChildren()}
213
+ </div>;
214
+ }
215
+ /**
216
+ * The thumb element of a color slider.
217
+ */
218
+ function ColorSliderThumb(props) {
219
+ const [local, domProps] = splitProps(props, [
220
+ "class",
221
+ "style",
222
+ "slot",
223
+ "children",
224
+ "ref"
225
+ ]);
226
+ const context = useContext(ColorSliderContext);
227
+ if (!context) throw new Error("ColorSliderThumb must be used within a ColorSlider");
228
+ const state = context.state;
229
+ const { isFocused, isFocusVisible, focusProps } = createFocusRing();
230
+ const { isHovered, hoverProps } = createHover({ get isDisabled() {
231
+ return state.isDisabled;
232
+ } });
233
+ const renderValues = createMemo(() => ({
234
+ isDisabled: state.isDisabled,
235
+ isDragging: state.isDragging,
236
+ isFocused: isFocused(),
237
+ isFocusVisible: isFocusVisible(),
238
+ isHovered: isHovered(),
239
+ color: state.getDisplayColor(),
240
+ defaultStyle: context.thumbProps.style ?? {}
241
+ }));
242
+ const renderProps = useRenderProps({
243
+ get children() {
244
+ return props.children;
245
+ },
246
+ class: local.class,
247
+ style: local.style,
248
+ defaultClassName: "solidaria-ColorSlider-thumb"
249
+ }, renderValues);
250
+ const cleanThumbProps = () => {
251
+ const { ref: _ref, style: _thumbStyle, ...rest } = context.thumbProps;
252
+ return rest;
253
+ };
254
+ const cleanFocusProps = () => {
255
+ const { ref: _ref, ...rest } = focusProps;
256
+ return rest;
257
+ };
258
+ const cleanHoverProps = () => {
259
+ const { ref: _ref, ...rest } = hoverProps;
260
+ return rest;
261
+ };
262
+ const mergedInputProps = () => {
263
+ return mergeProps$1(context.inputProps, cleanFocusProps());
264
+ };
265
+ const mergedStyle = () => {
266
+ const thumbStyle = context.thumbProps.style || {};
267
+ const renderStyle = renderProps.style() || {};
268
+ return {
269
+ ...thumbStyle,
270
+ ...renderStyle
271
+ };
272
+ };
273
+ return <div {...domProps} {...cleanThumbProps()} {...cleanHoverProps()} ref={local.ref} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0} data-focused={isFocused() || void 0} data-focus-visible={isFocusVisible() || void 0} data-hovered={isHovered() || void 0}>
274
+ <input ref={context.setInputRef} {...mergedInputProps()} />
275
+ {renderProps.renderChildren()}
276
+ </div>;
277
+ }
278
+ ColorSlider.Track = ColorSliderTrack;
279
+ ColorSlider.Thumb = ColorSliderThumb;
280
+ ColorSlider.Label = ColorSliderLabel;
281
+ ColorSlider.Output = ColorSliderOutput;
282
+ const ColorAreaContext = createContext(null);
283
+ /**
284
+ * A color area allows users to select a color using a 2D gradient.
285
+ */
286
+ function ColorArea(props) {
287
+ const pickerContext = useContext(ColorPickerContextInternal);
288
+ const [local, stateProps, ariaProps, rest] = splitProps(props, [
289
+ "children",
290
+ "class",
291
+ "style",
292
+ "slot"
293
+ ], [
294
+ "value",
295
+ "defaultValue",
296
+ "onChange",
297
+ "onChangeEnd",
298
+ "xChannel",
299
+ "yChannel",
300
+ "colorSpace"
301
+ ], [
302
+ "id",
303
+ "aria-label",
304
+ "aria-labelledby",
305
+ "aria-describedby",
306
+ "aria-details",
307
+ "isDisabled",
308
+ "xName",
309
+ "yName",
310
+ "form"
311
+ ]);
312
+ const state = createColorAreaState(() => ({
313
+ value: stateProps.value ?? pickerContext?.value,
314
+ defaultValue: stateProps.defaultValue,
315
+ onChange: stateProps.onChange ?? pickerContext?.onChange,
316
+ onChangeEnd: stateProps.onChangeEnd,
317
+ xChannel: stateProps.xChannel,
318
+ yChannel: stateProps.yChannel,
319
+ colorSpace: stateProps.colorSpace,
320
+ isDisabled: ariaProps.isDisabled
321
+ }));
322
+ let areaRef;
323
+ const setAreaRef = (el) => {
324
+ areaRef = el;
325
+ };
326
+ const colorAreaAria = createColorArea(() => ({
327
+ id: ariaProps.id,
328
+ "aria-label": ariaProps["aria-label"],
329
+ "aria-labelledby": ariaProps["aria-labelledby"],
330
+ "aria-describedby": ariaProps["aria-describedby"],
331
+ "aria-details": ariaProps["aria-details"],
332
+ isDisabled: ariaProps.isDisabled,
333
+ xName: ariaProps.xName,
334
+ yName: ariaProps.yName,
335
+ form: ariaProps.form
336
+ }), () => state, () => areaRef ?? null);
337
+ const renderValues = createMemo(() => ({
338
+ isDisabled: state.isDisabled,
339
+ isDragging: state.isDragging,
340
+ xChannel: state.xChannel,
341
+ yChannel: state.yChannel,
342
+ color: state.value,
343
+ defaultStyle: colorAreaAria.colorAreaProps.style ?? {}
344
+ }));
345
+ const childRenderValues = {
346
+ get isDisabled() {
347
+ return state.isDisabled;
348
+ },
349
+ get isDragging() {
350
+ return state.isDragging;
351
+ },
352
+ get xChannel() {
353
+ return state.xChannel;
354
+ },
355
+ get yChannel() {
356
+ return state.yChannel;
357
+ },
358
+ get color() {
359
+ return state.value;
360
+ },
361
+ get defaultStyle() {
362
+ return colorAreaAria.colorAreaProps.style ?? {};
363
+ }
364
+ };
365
+ const colorAreaChildren = () => {
366
+ const children = props.children;
367
+ return typeof children === "function" ? children(childRenderValues) : children;
368
+ };
369
+ const renderProps = useRenderProps({
370
+ get children() {
371
+ return props.children;
372
+ },
373
+ class: local.class,
374
+ style: local.style,
375
+ defaultClassName: "solidaria-ColorArea"
376
+ }, renderValues);
377
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
378
+ const cleanColorAreaProps = () => {
379
+ const { ref: _ref, style: _areaStyle, ...rest } = colorAreaAria.colorAreaProps;
380
+ return rest;
381
+ };
382
+ const mergedStyle = () => {
383
+ const areaStyle = colorAreaAria.colorAreaProps.style || {};
384
+ const renderStyle = renderProps.style() || {};
385
+ return {
386
+ ...areaStyle,
387
+ ...renderStyle
388
+ };
389
+ };
390
+ return <ColorAreaContext.Provider value={{
391
+ state,
392
+ get colorAreaProps() {
393
+ return colorAreaAria.colorAreaProps;
394
+ },
395
+ get gradientProps() {
396
+ return colorAreaAria.gradientProps;
397
+ },
398
+ get thumbProps() {
399
+ return colorAreaAria.thumbProps;
400
+ },
401
+ get xInputProps() {
402
+ return colorAreaAria.xInputProps;
403
+ },
404
+ get yInputProps() {
405
+ return colorAreaAria.yInputProps;
406
+ },
407
+ areaRef,
408
+ setAreaRef
409
+ }}>
410
+ <div ref={setAreaRef} {...domProps()} {...cleanColorAreaProps()} class={renderProps.class()} style={mergedStyle()} slot={local.slot ?? void 0} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0}>
411
+ {colorAreaChildren()}
412
+ </div>
413
+ </ColorAreaContext.Provider>;
414
+ }
415
+ /**
416
+ * The gradient background of a color area.
417
+ */
418
+ function ColorAreaGradient(props) {
419
+ const [local, domProps] = splitProps(props, [
420
+ "class",
421
+ "style",
422
+ "slot",
423
+ "children"
424
+ ]);
425
+ const context = useContext(ColorAreaContext);
426
+ if (!context) throw new Error("ColorAreaGradient must be used within a ColorArea");
427
+ const { state } = context;
428
+ const renderValues = createMemo(() => ({ isDisabled: state.isDisabled }));
429
+ const renderProps = useRenderProps({
430
+ get children() {
431
+ return props.children;
432
+ },
433
+ class: local.class,
434
+ style: local.style,
435
+ defaultClassName: "solidaria-ColorArea-gradient"
436
+ }, renderValues);
437
+ const cleanGradientProps = () => {
438
+ const { ref: _ref, style: _gradStyle, ...rest } = context.gradientProps;
439
+ return rest;
440
+ };
441
+ const mergedStyle = () => {
442
+ const gradStyle = context.gradientProps.style || {};
443
+ const renderStyle = renderProps.style() || {};
444
+ return {
445
+ ...gradStyle,
446
+ ...renderStyle
447
+ };
448
+ };
449
+ return <div {...domProps} {...cleanGradientProps()} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0}>
450
+ {renderProps.renderChildren()}
451
+ </div>;
452
+ }
453
+ /**
454
+ * The thumb element of a color area.
455
+ */
456
+ function ColorAreaThumb(props) {
457
+ const [local, domProps] = splitProps(props, [
458
+ "class",
459
+ "style",
460
+ "slot",
461
+ "children",
462
+ "ref"
463
+ ]);
464
+ const context = useContext(ColorAreaContext);
465
+ if (!context) throw new Error("ColorAreaThumb must be used within a ColorArea");
466
+ const { state } = context;
467
+ const { isFocused, isFocusVisible, focusProps } = createFocusRing();
468
+ let xInputRef;
469
+ let yInputRef;
470
+ const { isHovered, hoverProps } = createHover({ get isDisabled() {
471
+ return state.isDisabled;
472
+ } });
473
+ const renderValues = createMemo(() => ({
474
+ isDisabled: state.isDisabled,
475
+ isDragging: state.isDragging,
476
+ color: state.getDisplayColor(),
477
+ isFocused: isFocused(),
478
+ isFocusVisible: isFocusVisible(),
479
+ isHovered: isHovered()
480
+ }));
481
+ const renderProps = useRenderProps({
482
+ get children() {
483
+ return props.children;
484
+ },
485
+ class: local.class,
486
+ style: local.style,
487
+ defaultClassName: "solidaria-ColorArea-thumb"
488
+ }, renderValues);
489
+ const cleanThumbProps = () => {
490
+ const { ref: _ref, style: _thumbStyle, ...rest } = context.thumbProps;
491
+ return rest;
492
+ };
493
+ const cleanFocusProps = () => {
494
+ const { ref: _ref, ...rest } = focusProps;
495
+ return rest;
496
+ };
497
+ const cleanHoverProps = () => {
498
+ const { ref: _ref, ...rest } = hoverProps;
499
+ return rest;
500
+ };
501
+ const mergedXInputProps = () => {
502
+ const { value: _value, ...inputProps } = context.xInputProps;
503
+ return mergeProps$1(inputProps, cleanFocusProps());
504
+ };
505
+ const mergedYInputProps = () => {
506
+ const { value: _value, ...inputProps } = context.yInputProps;
507
+ return mergeProps$1(inputProps, cleanFocusProps());
508
+ };
509
+ const mergedStyle = () => {
510
+ const thumbStyle = context.thumbProps.style || {};
511
+ const renderStyle = renderProps.style() || {};
512
+ return {
513
+ ...thumbStyle,
514
+ ...renderStyle
515
+ };
516
+ };
517
+ const syncInputValue = (input, value) => {
518
+ const nextValue = String(value);
519
+ const update = () => {
520
+ if (input && input.value !== nextValue) input.value = nextValue;
521
+ };
522
+ update();
523
+ queueMicrotask(update);
524
+ };
525
+ createEffect(() => {
526
+ syncInputValue(xInputRef, state.getXValue());
527
+ });
528
+ createEffect(() => {
529
+ syncInputValue(yInputRef, state.getYValue());
530
+ });
531
+ return <div {...domProps} ref={local.ref} {...cleanThumbProps()} {...cleanHoverProps()} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0} data-focused={isFocused() || void 0} data-focus-visible={isFocusVisible() || void 0} data-hovered={isHovered() || void 0}>
532
+ <input {...mergedXInputProps()} ref={(el) => {
533
+ xInputRef = el;
534
+ syncInputValue(el, state.getXValue());
535
+ }} />
536
+ <input {...mergedYInputProps()} ref={(el) => {
537
+ yInputRef = el;
538
+ syncInputValue(el, state.getYValue());
539
+ }} />
540
+ {renderProps.renderChildren()}
541
+ </div>;
542
+ }
543
+ ColorArea.Gradient = ColorAreaGradient;
544
+ ColorArea.Thumb = ColorAreaThumb;
545
+ const ColorWheelContext = createContext(null);
546
+ /**
547
+ * A color wheel allows users to select a hue using a circular control.
548
+ */
549
+ function ColorWheel(props) {
550
+ const pickerContext = useContext(ColorPickerContextInternal);
551
+ const [local, stateProps, ariaProps, rest] = splitProps(props, [
552
+ "children",
553
+ "class",
554
+ "style",
555
+ "slot"
556
+ ], [
557
+ "value",
558
+ "defaultValue",
559
+ "onChange",
560
+ "onChangeEnd"
561
+ ], [
562
+ "id",
563
+ "aria-label",
564
+ "aria-labelledby",
565
+ "aria-describedby",
566
+ "aria-details",
567
+ "aria-errormessage",
568
+ "isDisabled",
569
+ "name",
570
+ "form",
571
+ "outerRadius",
572
+ "innerRadius"
573
+ ]);
574
+ const state = createColorWheelState(() => ({
575
+ value: stateProps.value ?? pickerContext?.value,
576
+ defaultValue: stateProps.defaultValue,
577
+ onChange: stateProps.onChange ?? pickerContext?.onChange,
578
+ onChangeEnd: stateProps.onChangeEnd,
579
+ isDisabled: ariaProps.isDisabled
580
+ }));
581
+ let wheelRef;
582
+ const setWheelRef = (el) => {
583
+ wheelRef = el;
584
+ };
585
+ const colorWheelAria = createColorWheel(() => ({
586
+ id: ariaProps.id,
587
+ "aria-label": ariaProps["aria-label"],
588
+ "aria-labelledby": ariaProps["aria-labelledby"],
589
+ "aria-describedby": ariaProps["aria-describedby"],
590
+ "aria-details": ariaProps["aria-details"],
591
+ "aria-errormessage": ariaProps["aria-errormessage"],
592
+ isDisabled: ariaProps.isDisabled,
593
+ name: ariaProps.name,
594
+ form: ariaProps.form,
595
+ outerRadius: ariaProps.outerRadius,
596
+ innerRadius: ariaProps.innerRadius
597
+ }), () => state, () => wheelRef ?? null);
598
+ const renderValues = createMemo(() => ({
599
+ isDisabled: state.isDisabled,
600
+ isDragging: state.isDragging,
601
+ hue: state.getHue(),
602
+ color: state.value,
603
+ defaultStyle: { position: "relative" }
604
+ }));
605
+ const renderProps = useRenderProps({
606
+ get children() {
607
+ return props.children;
608
+ },
609
+ class: local.class,
610
+ style: local.style,
611
+ defaultClassName: "solidaria-ColorWheel"
612
+ }, renderValues);
613
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
614
+ return <ColorWheelContext.Provider value={{
615
+ state,
616
+ get trackProps() {
617
+ return colorWheelAria.trackProps;
618
+ },
619
+ get thumbProps() {
620
+ return colorWheelAria.thumbProps;
621
+ },
622
+ get inputProps() {
623
+ return colorWheelAria.inputProps;
624
+ },
625
+ get wheelRef() {
626
+ return wheelRef;
627
+ },
628
+ setWheelRef
629
+ }}>
630
+ <div ref={setWheelRef} {...domProps()} class={renderProps.class()} style={renderProps.style()} slot={local.slot || void 0} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0}>
631
+ {renderProps.renderChildren()}
632
+ </div>
633
+ </ColorWheelContext.Provider>;
634
+ }
635
+ /**
636
+ * The track element of a color wheel.
637
+ */
638
+ function ColorWheelTrack(props) {
639
+ const [local, domProps] = splitProps(props, [
640
+ "class",
641
+ "style",
642
+ "slot",
643
+ "children"
644
+ ]);
645
+ const context = useContext(ColorWheelContext);
646
+ if (!context) throw new Error("ColorWheelTrack must be used within a ColorWheel");
647
+ const state = context.state;
648
+ const renderValues = createMemo(() => ({
649
+ isDisabled: state.isDisabled,
650
+ isDragging: state.isDragging,
651
+ defaultStyle: context.trackProps.style ?? {}
652
+ }));
653
+ const renderProps = useRenderProps({
654
+ get children() {
655
+ return props.children;
656
+ },
657
+ class: local.class,
658
+ style: local.style,
659
+ defaultClassName: "solidaria-ColorWheel-track"
660
+ }, renderValues);
661
+ const cleanTrackProps = () => {
662
+ const { ref: _ref, style: _trackStyle, ...rest } = context.trackProps;
663
+ return rest;
664
+ };
665
+ const mergedStyle = () => {
666
+ const trackStyle = context.trackProps.style || {};
667
+ const renderStyle = renderProps.style() || {};
668
+ return {
669
+ ...trackStyle,
670
+ ...renderStyle
671
+ };
672
+ };
673
+ return <div {...domProps} {...cleanTrackProps()} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0}>
674
+ {renderProps.renderChildren()}
675
+ </div>;
676
+ }
677
+ /**
678
+ * The thumb element of a color wheel.
679
+ */
680
+ function ColorWheelThumb(props) {
681
+ const [local, domProps] = splitProps(props, [
682
+ "class",
683
+ "style",
684
+ "slot",
685
+ "children",
686
+ "ref"
687
+ ]);
688
+ const context = useContext(ColorWheelContext);
689
+ if (!context) throw new Error("ColorWheelThumb must be used within a ColorWheel");
690
+ const state = context.state;
691
+ const { isFocused, isFocusVisible, focusProps } = createFocusRing();
692
+ const { isHovered, hoverProps } = createHover({ get isDisabled() {
693
+ return state.isDisabled;
694
+ } });
695
+ const renderValues = createMemo(() => ({
696
+ isDisabled: state.isDisabled,
697
+ isDragging: state.isDragging,
698
+ color: state.getDisplayColor(),
699
+ isFocused: isFocused(),
700
+ isFocusVisible: isFocusVisible(),
701
+ isHovered: isHovered(),
702
+ defaultStyle: context.thumbProps.style ?? {}
703
+ }));
704
+ const renderProps = useRenderProps({
705
+ get children() {
706
+ return props.children;
707
+ },
708
+ class: local.class,
709
+ style: local.style,
710
+ defaultClassName: "solidaria-ColorWheel-thumb"
711
+ }, renderValues);
712
+ const cleanThumbProps = () => {
713
+ const { ref: _ref, style: _thumbStyle, ...rest } = context.thumbProps;
714
+ return rest;
715
+ };
716
+ const cleanFocusProps = () => {
717
+ const { ref: _ref, ...rest } = focusProps;
718
+ return rest;
719
+ };
720
+ const cleanHoverProps = () => {
721
+ const { ref: _ref, ...rest } = hoverProps;
722
+ return rest;
723
+ };
724
+ const mergedInputProps = () => {
725
+ return mergeProps$1(context.inputProps, cleanFocusProps());
726
+ };
727
+ const mergedStyle = () => {
728
+ const thumbStyle = context.thumbProps.style || {};
729
+ const renderStyle = renderProps.style() || {};
730
+ return {
731
+ ...thumbStyle,
732
+ ...renderStyle
733
+ };
734
+ };
735
+ return <div {...domProps} ref={local.ref} {...cleanThumbProps()} {...cleanHoverProps()} class={renderProps.class()} style={mergedStyle()} data-disabled={state.isDisabled || void 0} data-dragging={state.isDragging || void 0} data-focused={isFocused() || void 0} data-focus-visible={isFocusVisible() || void 0} data-hovered={isHovered() || void 0}>
736
+ <input {...mergedInputProps()} />
737
+ {renderProps.renderChildren()}
738
+ </div>;
739
+ }
740
+ ColorWheel.Track = ColorWheelTrack;
741
+ ColorWheel.Thumb = ColorWheelThumb;
742
+ const ColorFieldContext = createContext(null);
743
+ /**
744
+ * A color field allows users to enter a color value as text.
745
+ */
746
+ function ColorField(props) {
747
+ const pickerContext = useContext(ColorPickerContextInternal);
748
+ const [local, stateProps, ariaProps, rest] = splitProps(props, [
749
+ "children",
750
+ "class",
751
+ "style",
752
+ "slot",
753
+ "label",
754
+ "description",
755
+ "errorMessage"
756
+ ], [
757
+ "value",
758
+ "defaultValue",
759
+ "onChange",
760
+ "channel",
761
+ "colorSpace",
762
+ "colorFormat"
763
+ ], [
764
+ "id",
765
+ "aria-label",
766
+ "aria-labelledby",
767
+ "aria-describedby",
768
+ "aria-details",
769
+ "aria-errormessage",
770
+ "name",
771
+ "form",
772
+ "isWheelDisabled",
773
+ "isDisabled",
774
+ "isReadOnly",
775
+ "isRequired",
776
+ "isInvalid",
777
+ "validationBehavior",
778
+ "autoFocus",
779
+ "excludeFromTabOrder",
780
+ "placeholder"
781
+ ]);
782
+ const [hasRegisteredLabelElement, setHasRegisteredLabelElement] = createSignal(false);
783
+ const state = createColorFieldState(() => ({
784
+ value: stateProps.value ?? pickerContext?.value,
785
+ defaultValue: stateProps.defaultValue,
786
+ onChange: stateProps.onChange ?? ((color) => {
787
+ if (color) pickerContext?.onChange?.(color);
788
+ }),
789
+ channel: stateProps.channel,
790
+ colorSpace: stateProps.colorSpace,
791
+ colorFormat: stateProps.colorFormat,
792
+ isDisabled: ariaProps.isDisabled,
793
+ isReadOnly: ariaProps.isReadOnly,
794
+ isInvalid: ariaProps.isInvalid,
795
+ isRequired: ariaProps.isRequired
796
+ }));
797
+ let inputRef;
798
+ const setInputRef = (el) => {
799
+ inputRef = el;
800
+ };
801
+ const colorFieldAria = createColorField(() => ({
802
+ id: ariaProps.id,
803
+ "aria-label": ariaProps["aria-label"],
804
+ "aria-labelledby": ariaProps["aria-labelledby"],
805
+ "aria-describedby": ariaProps["aria-describedby"],
806
+ "aria-details": ariaProps["aria-details"],
807
+ "aria-errormessage": ariaProps["aria-errormessage"],
808
+ name: ariaProps.name,
809
+ form: ariaProps.form,
810
+ isWheelDisabled: ariaProps.isWheelDisabled,
811
+ isDisabled: ariaProps.isDisabled,
812
+ isReadOnly: ariaProps.isReadOnly,
813
+ isRequired: ariaProps.isRequired,
814
+ isInvalid: ariaProps.isInvalid,
815
+ validationBehavior: ariaProps.validationBehavior,
816
+ autoFocus: ariaProps.autoFocus,
817
+ excludeFromTabOrder: ariaProps.excludeFromTabOrder,
818
+ placeholder: ariaProps.placeholder,
819
+ channel: stateProps.channel,
820
+ colorSpace: stateProps.colorSpace
821
+ }), () => state, () => inputRef ?? null);
822
+ const describedBy = () => {
823
+ const invalid = ariaProps.isInvalid || state.isInvalid;
824
+ return [
825
+ ariaProps["aria-describedby"],
826
+ local.description && !invalid ? colorFieldAria.descriptionProps.id : void 0,
827
+ invalid && local.errorMessage ? colorFieldAria.errorMessageProps.id : void 0
828
+ ].filter(Boolean).join(" ") || void 0;
829
+ };
830
+ const fieldInputProps = () => {
831
+ const labelledBy = ariaProps["aria-labelledby"] ?? (!ariaProps["aria-label"] && (local.label || hasRegisteredLabelElement()) ? colorFieldAria.labelProps.id : void 0);
832
+ return {
833
+ ...colorFieldAria.inputProps,
834
+ "aria-label": labelledBy ? void 0 : colorFieldAria.inputProps["aria-label"],
835
+ "aria-labelledby": labelledBy,
836
+ "aria-describedby": describedBy(),
837
+ "aria-errormessage": (ariaProps.isInvalid || state.isInvalid) && local.errorMessage ? colorFieldAria.errorMessageProps.id : colorFieldAria.inputProps["aria-errormessage"]
838
+ };
839
+ };
840
+ const hiddenInputValue = createMemo(() => Number.isNaN(state.numberValue) ? "" : String(state.numberValue));
841
+ const renderValues = createMemo(() => ({
842
+ isDisabled: state.isDisabled,
843
+ isReadOnly: state.isReadOnly,
844
+ isRequired: state.isRequired,
845
+ isInvalid: state.isInvalid,
846
+ color: state.value,
847
+ channel: state.channel ?? "hex"
848
+ }));
849
+ const renderProps = useRenderProps({
850
+ get children() {
851
+ return props.children;
852
+ },
853
+ class: local.class,
854
+ style: local.style,
855
+ defaultClassName: "solidaria-ColorField"
856
+ }, renderValues);
857
+ const childRenderValues = {
858
+ get isDisabled() {
859
+ return state.isDisabled;
860
+ },
861
+ get isReadOnly() {
862
+ return state.isReadOnly;
863
+ },
864
+ get isRequired() {
865
+ return state.isRequired;
866
+ },
867
+ get isInvalid() {
868
+ return state.isInvalid;
869
+ },
870
+ get color() {
871
+ return state.value;
872
+ },
873
+ get channel() {
874
+ return state.channel ?? "hex";
875
+ }
876
+ };
877
+ let hasRenderedChildren = false;
878
+ let renderedChildren;
879
+ const renderChildren = () => {
880
+ if (!hasRenderedChildren) {
881
+ const children = local.children;
882
+ renderedChildren = typeof children === "function" ? untrack(() => children(childRenderValues)) : children;
883
+ hasRenderedChildren = true;
884
+ }
885
+ return renderedChildren;
886
+ };
887
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
888
+ return <ColorFieldContext.Provider value={{
889
+ state,
890
+ get inputProps() {
891
+ return fieldInputProps();
892
+ },
893
+ get labelProps() {
894
+ return colorFieldAria.labelProps;
895
+ },
896
+ get descriptionProps() {
897
+ return colorFieldAria.descriptionProps;
898
+ },
899
+ get errorMessageProps() {
900
+ return colorFieldAria.errorMessageProps;
901
+ },
902
+ setInputRef,
903
+ setLabelElement: setHasRegisteredLabelElement
904
+ }}>
905
+ <>
906
+ <div {...domProps()} class={renderProps.class()} style={renderProps.style()} slot={local.slot ?? void 0} data-disabled={state.isDisabled || void 0} data-readonly={state.isReadOnly || void 0} data-invalid={state.isInvalid || void 0} data-required={state.isRequired || void 0} data-channel={state.channel ?? "hex"}>
907
+ <Show when={local.label}>
908
+ <label {...colorFieldAria.labelProps}>{local.label}</label>
909
+ </Show>
910
+
911
+ {renderChildren()}
912
+ </div>
913
+ <Show when={state.channel && ariaProps.name}>
914
+ <input type="hidden" name={ariaProps.name} form={ariaProps.form} value={hiddenInputValue()} />
915
+ </Show>
916
+ </>
917
+ </ColorFieldContext.Provider>;
918
+ }
919
+ /**
920
+ * The input element of a color field.
921
+ */
922
+ function ColorFieldInput(props) {
923
+ const [local, domProps] = splitProps(props, [
924
+ "class",
925
+ "style",
926
+ "slot",
927
+ "children",
928
+ "ref"
929
+ ]);
930
+ const context = useContext(ColorFieldContext);
931
+ if (!context) throw new Error("ColorFieldInput must be used within a ColorField");
932
+ const state = context.state;
933
+ const inputValue = createMemo(() => state.inputValue);
934
+ const { isFocused, isFocusVisible, focusProps } = createFocusRing();
935
+ const { isHovered, hoverProps } = createHover({ get isDisabled() {
936
+ return state.isDisabled;
937
+ } });
938
+ const renderValues = createMemo(() => ({
939
+ isDisabled: state.isDisabled,
940
+ isReadOnly: state.isReadOnly,
941
+ isInvalid: state.isInvalid,
942
+ isFocused: isFocused(),
943
+ isFocusVisible: isFocusVisible(),
944
+ isHovered: isHovered()
945
+ }));
946
+ const renderProps = useRenderProps({
947
+ get children() {
948
+ return props.children;
949
+ },
950
+ class: local.class,
951
+ style: local.style,
952
+ defaultClassName: "solidaria-ColorField-input"
953
+ }, renderValues);
954
+ const cleanInputProps = () => {
955
+ const { ref: _ref, style: _inputStyle, value: _value, ...rest } = context.inputProps;
956
+ return rest;
957
+ };
958
+ const cleanFocusProps = () => {
959
+ const { ref: _ref, ...rest } = focusProps;
960
+ return rest;
961
+ };
962
+ const cleanHoverProps = () => {
963
+ const { ref: _ref, ...rest } = hoverProps;
964
+ return rest;
965
+ };
966
+ return <input {...domProps} {...cleanInputProps()} {...cleanFocusProps()} {...cleanHoverProps()} ref={(el) => {
967
+ context.setInputRef(el);
968
+ local.ref?.(el);
969
+ }} class={renderProps.class()} style={renderProps.style()} value={inputValue()} data-disabled={state.isDisabled || void 0} data-readonly={state.isReadOnly || void 0} data-invalid={state.isInvalid || void 0} data-focused={isFocused() || void 0} data-focus-visible={isFocusVisible() || void 0} data-hovered={isHovered() || void 0} />;
970
+ }
971
+ ColorField.Input = ColorFieldInput;
972
+ /**
973
+ * A color swatch displays a preview of a color.
974
+ */
975
+ function ColorSwatch(props) {
976
+ const swatchContext = useContext(ColorSwatchContextInternal);
977
+ const pickerContext = useContext(ColorPickerContextInternal);
978
+ const [local, ariaProps, rest] = splitProps(props, [
979
+ "children",
980
+ "class",
981
+ "style",
982
+ "slot",
983
+ "color",
984
+ "colorName"
985
+ ], [
986
+ "aria-label",
987
+ "aria-labelledby",
988
+ "aria-describedby",
989
+ "aria-details"
990
+ ]);
991
+ const resolvedColor = createMemo(() => {
992
+ return local.color ?? swatchContext?.color ?? pickerContext?.value ?? "#fff0";
993
+ });
994
+ const swatchAria = createColorSwatch(() => ({
995
+ id: rest.id,
996
+ slot: local.slot,
997
+ color: resolvedColor(),
998
+ colorName: local.colorName,
999
+ "aria-label": ariaProps["aria-label"],
1000
+ "aria-labelledby": ariaProps["aria-labelledby"],
1001
+ "aria-describedby": ariaProps["aria-describedby"],
1002
+ "aria-details": ariaProps["aria-details"]
1003
+ }));
1004
+ const renderValues = createMemo(() => ({
1005
+ color: swatchAria.color,
1006
+ colorValue: swatchAria.color.toString("css")
1007
+ }));
1008
+ const renderProps = useRenderProps({
1009
+ get children() {
1010
+ return props.children;
1011
+ },
1012
+ class: local.class,
1013
+ style: local.style,
1014
+ defaultClassName: "solidaria-ColorSwatch"
1015
+ }, renderValues);
1016
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
1017
+ const cleanSwatchProps = () => {
1018
+ const { ref: _ref, style: _swatchStyle, ...rest } = swatchAria.swatchProps;
1019
+ return rest;
1020
+ };
1021
+ const mergedStyle = () => {
1022
+ const swatchStyle = swatchAria.swatchProps.style || {};
1023
+ const renderStyle = renderProps.style() || {};
1024
+ return {
1025
+ ...swatchStyle,
1026
+ ...renderStyle
1027
+ };
1028
+ };
1029
+ return <div {...domProps()} {...cleanSwatchProps()} class={renderProps.class()} style={mergedStyle()}>
1030
+ {renderProps.renderChildren()}
1031
+ </div>;
1032
+ }
1033
+ const ColorSliderStateContext = ColorSliderContext;
1034
+ const ColorAreaStateContext = ColorAreaContext;
1035
+ const ColorWheelStateContext = ColorWheelContext;
1036
+ const ColorWheelTrackContext = ColorWheelContext;
1037
+ const ColorFieldStateContext = ColorFieldContext;
1038
+ const ColorSwatchContext = ColorSwatchContextInternal;
1039
+ const ColorPickerContext = ColorPickerContextInternal;
1040
+ const ColorPickerStateContext = ColorPickerStateContextInternal;
1041
+ const ColorSwatchPickerContext = ColorSwatchPickerContextInternal;
1042
+ const ColorThumb = ColorSliderThumb;
1043
+ function ColorPicker(props) {
1044
+ const [local] = splitProps(props, [
1045
+ "value",
1046
+ "defaultValue",
1047
+ "onChange",
1048
+ "children",
1049
+ "class",
1050
+ "style",
1051
+ "slot"
1052
+ ]);
1053
+ const [internalColor, setInternalColor] = createSignal(normalizeColor(local.defaultValue ?? "#ff0000"));
1054
+ const color = createMemo(() => {
1055
+ if (local.value !== void 0) return normalizeColor(local.value);
1056
+ return internalColor();
1057
+ });
1058
+ const setColor = (nextColor) => {
1059
+ if (local.value === void 0) setInternalColor(nextColor);
1060
+ local.onChange?.(nextColor);
1061
+ };
1062
+ const renderValues = createMemo(() => ({ color: color() }));
1063
+ const renderProps = useRenderProps({
1064
+ get children() {
1065
+ return local.children;
1066
+ },
1067
+ class: local.class,
1068
+ style: local.style,
1069
+ defaultClassName: "solidaria-ColorPicker"
1070
+ }, renderValues);
1071
+ return <ColorPickerStateContextInternal.Provider value={{
1072
+ color: () => color(),
1073
+ setColor
1074
+ }}>
1075
+ <ColorPickerContextInternal.Provider value={{
1076
+ get value() {
1077
+ return color();
1078
+ },
1079
+ onChange: setColor
1080
+ }}>
1081
+ <div class={renderProps.class()} style={renderProps.style()}>
1082
+ {renderProps.renderChildren()}
1083
+ </div>
1084
+ </ColorPickerContextInternal.Provider>
1085
+ </ColorPickerStateContextInternal.Provider>;
1086
+ }
1087
+ function ColorSwatchPicker(props) {
1088
+ const pickerContext = useContext(ColorPickerContextInternal);
1089
+ const [local, rest] = splitProps(props, [
1090
+ "value",
1091
+ "defaultValue",
1092
+ "onChange",
1093
+ "id",
1094
+ "aria-label",
1095
+ "aria-labelledby",
1096
+ "aria-describedby",
1097
+ "aria-details",
1098
+ "layout",
1099
+ "children",
1100
+ "class",
1101
+ "style",
1102
+ "slot"
1103
+ ]);
1104
+ const [itemMap, setItemMap] = createSignal(/* @__PURE__ */ new Map());
1105
+ const [itemOrder, setItemOrder] = createSignal([]);
1106
+ const [internalColor, setInternalColor] = createSignal(normalizeColor(local.defaultValue ?? pickerContext?.value ?? "#ff0000"));
1107
+ const selectedColor = createMemo(() => {
1108
+ if (local.value !== void 0) return normalizeColor(local.value);
1109
+ if (pickerContext?.value !== void 0) return normalizeColor(pickerContext.value);
1110
+ return internalColor();
1111
+ });
1112
+ const selectedKey = createMemo(() => selectedColor().toString("hexa"));
1113
+ const isControlled = createMemo(() => local.value !== void 0 || pickerContext?.value !== void 0);
1114
+ const registerItem = (item) => {
1115
+ setItemMap((prev) => {
1116
+ const next = new Map(prev);
1117
+ next.set(item.key, item);
1118
+ return next;
1119
+ });
1120
+ setItemOrder((prev) => prev.includes(item.key) ? prev : [...prev, item.key]);
1121
+ };
1122
+ const unregisterItem = (key) => {
1123
+ setItemMap((prev) => {
1124
+ if (!prev.has(key)) return prev;
1125
+ const next = new Map(prev);
1126
+ next.delete(key);
1127
+ return next;
1128
+ });
1129
+ setItemOrder((prev) => prev.filter((itemKey) => itemKey !== key));
1130
+ };
1131
+ const items = createMemo(() => {
1132
+ const map = itemMap();
1133
+ return itemOrder().map((key) => map.get(key)).filter((item) => item != null);
1134
+ });
1135
+ const state = createListState({
1136
+ get items() {
1137
+ return items();
1138
+ },
1139
+ get getKey() {
1140
+ return (item) => item.key;
1141
+ },
1142
+ get getTextValue() {
1143
+ return (item) => item.textValue;
1144
+ },
1145
+ get getDisabled() {
1146
+ return (item) => !!item.isDisabled;
1147
+ },
1148
+ selectionMode: "single",
1149
+ disallowEmptySelection: true,
1150
+ get selectedKeys() {
1151
+ return [selectedKey()];
1152
+ },
1153
+ onSelectionChange(keys) {
1154
+ if (keys === "all") return;
1155
+ const key = keys.values().next().value;
1156
+ if (!key) return;
1157
+ const item = itemMap().get(key);
1158
+ if (!item) return;
1159
+ if (!isControlled()) setInternalColor(item.color);
1160
+ (local.onChange ?? pickerContext?.onChange)?.(item.color);
1161
+ }
1162
+ });
1163
+ const listBoxAria = createListBox(() => ({
1164
+ id: local.id,
1165
+ "aria-label": local["aria-label"] ?? (!local["aria-labelledby"] ? "Color swatch picker" : void 0),
1166
+ "aria-labelledby": local["aria-labelledby"],
1167
+ "aria-describedby": local["aria-describedby"],
1168
+ "aria-details": local["aria-details"],
1169
+ shouldFocusWrap: true
1170
+ }), state);
1171
+ const resolveDirection = () => {
1172
+ if (typeof document === "undefined") return "ltr";
1173
+ return document.dir === "rtl" ? "rtl" : "ltr";
1174
+ };
1175
+ const findNextEnabledKey = (from, direction) => {
1176
+ const collection = state.collection();
1177
+ const getAdjacent = direction === "next" ? (key) => collection.getKeyAfter(key) : (key) => collection.getKeyBefore(key);
1178
+ let key = from != null ? getAdjacent(from) : (direction === "next" ? () => collection.getFirstKey() : () => collection.getLastKey())();
1179
+ while (key != null && state.isDisabled(key)) key = getAdjacent(key);
1180
+ return key;
1181
+ };
1182
+ const getBoundaryEnabledKey = (direction) => {
1183
+ const collection = state.collection();
1184
+ const getAdjacent = direction === "next" ? (key) => collection.getKeyAfter(key) : (key) => collection.getKeyBefore(key);
1185
+ let key = (direction === "next" ? () => collection.getFirstKey() : () => collection.getLastKey())();
1186
+ while (key != null && state.isDisabled(key)) key = getAdjacent(key);
1187
+ return key;
1188
+ };
1189
+ const getOptionElementForKey = (listbox, key) => {
1190
+ if (!listbox || key == null) return null;
1191
+ const keyString = String(key);
1192
+ for (const optionElement of listbox.querySelectorAll("[role=\"option\"]")) if (optionElement.id === keyString) return optionElement;
1193
+ return null;
1194
+ };
1195
+ const findGridKey = (listbox, key, nextKey, shouldSkip) => {
1196
+ let candidate = key;
1197
+ const previousRect = getOptionElementForKey(listbox, candidate)?.getBoundingClientRect();
1198
+ if (!previousRect) return null;
1199
+ while (candidate != null) {
1200
+ candidate = nextKey(candidate);
1201
+ if (candidate == null) return null;
1202
+ const itemRect = getOptionElementForKey(listbox, candidate)?.getBoundingClientRect();
1203
+ if (!itemRect) return null;
1204
+ if (!shouldSkip(previousRect, itemRect)) return candidate;
1205
+ }
1206
+ return null;
1207
+ };
1208
+ const isSameRow = (prevRect, itemRect) => prevRect.y === itemRect.y || prevRect.x !== itemRect.x;
1209
+ const getGridKeyBelow = (listbox, key) => findGridKey(listbox, key, (current) => findNextEnabledKey(current, "next"), isSameRow);
1210
+ const getGridKeyAbove = (listbox, key) => findGridKey(listbox, key, (current) => findNextEnabledKey(current, "prev"), isSameRow);
1211
+ const getGridKeyRightOf = (key) => resolveDirection() === "rtl" ? findNextEnabledKey(key, "prev") : findNextEnabledKey(key, "next");
1212
+ const getGridKeyLeftOf = (key) => resolveDirection() === "rtl" ? findNextEnabledKey(key, "next") : findNextEnabledKey(key, "prev");
1213
+ const handleGridKeyDown = (e) => {
1214
+ if ((local.layout ?? "grid") !== "grid") return false;
1215
+ if (e.key !== "ArrowRight" && e.key !== "ArrowLeft" && e.key !== "ArrowDown" && e.key !== "ArrowUp") return false;
1216
+ const listbox = e.currentTarget;
1217
+ const initialKey = state.focusedKey() ?? (e.key === "ArrowUp" || e.key === "ArrowLeft" ? getBoundaryEnabledKey("prev") : getBoundaryEnabledKey("next"));
1218
+ if (initialKey == null) return false;
1219
+ let nextKey = null;
1220
+ switch (e.key) {
1221
+ case "ArrowDown":
1222
+ nextKey = getGridKeyBelow(listbox, initialKey) ?? getBoundaryEnabledKey("next");
1223
+ break;
1224
+ case "ArrowUp":
1225
+ nextKey = getGridKeyAbove(listbox, initialKey) ?? getBoundaryEnabledKey("prev");
1226
+ break;
1227
+ case "ArrowRight":
1228
+ nextKey = getGridKeyRightOf(initialKey) ?? (resolveDirection() === "rtl" ? getBoundaryEnabledKey("prev") : getBoundaryEnabledKey("next"));
1229
+ break;
1230
+ case "ArrowLeft":
1231
+ nextKey = getGridKeyLeftOf(initialKey) ?? (resolveDirection() === "rtl" ? getBoundaryEnabledKey("next") : getBoundaryEnabledKey("prev"));
1232
+ break;
1233
+ }
1234
+ if (nextKey == null) return false;
1235
+ state.setFocusedKey(nextKey);
1236
+ if (state.selectionMode() === "single") state.replaceSelection(nextKey);
1237
+ e.preventDefault();
1238
+ e.stopPropagation();
1239
+ return true;
1240
+ };
1241
+ const getListBoxKeyDown = () => {
1242
+ return listBoxAria.listBoxProps.onKeyDown;
1243
+ };
1244
+ const onColorSwatchPickerKeyDown = (e) => {
1245
+ if (handleGridKeyDown(e)) return;
1246
+ getListBoxKeyDown()?.(e);
1247
+ };
1248
+ createEffect(() => {
1249
+ const key = selectedKey();
1250
+ if (key) state.setFocusedKey(key);
1251
+ });
1252
+ const { isFocused, isFocusVisible, focusProps } = createFocusRing({ within: true });
1253
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
1254
+ const renderValues = createMemo(() => ({
1255
+ isFocused: state.isFocused() || isFocused(),
1256
+ isFocusVisible: isFocusVisible(),
1257
+ selectedColor: selectedColor(),
1258
+ layout: local.layout ?? "grid"
1259
+ }));
1260
+ const renderProps = useRenderProps({
1261
+ class: local.class,
1262
+ style: local.style,
1263
+ defaultClassName: "solidaria-ColorSwatchPicker"
1264
+ }, renderValues);
1265
+ const cleanListBoxProps = () => {
1266
+ const { ref: _ref, onKeyDown: _onKeyDown, ...restListBoxProps } = listBoxAria.listBoxProps;
1267
+ return restListBoxProps;
1268
+ };
1269
+ const cleanFocusProps = () => {
1270
+ const { ref: _ref, ...restFocusProps } = focusProps;
1271
+ return restFocusProps;
1272
+ };
1273
+ return <ColorSwatchPickerContextInternal.Provider value={{
1274
+ state,
1275
+ registerItem,
1276
+ unregisterItem
1277
+ }}>
1278
+ <div {...mergeProps$1(domProps(), cleanListBoxProps(), cleanFocusProps(), { onKeyDown: onColorSwatchPickerKeyDown })} class={renderProps.class()} style={renderProps.style()} slot={local.slot ?? void 0} data-focused={state.isFocused() || void 0} data-focus-visible={isFocusVisible() || void 0} data-layout={local.layout ?? "grid"}>
1279
+ {local.children}
1280
+ </div>
1281
+ </ColorSwatchPickerContextInternal.Provider>;
1282
+ }
1283
+ function ColorSwatchPickerItem(props) {
1284
+ const context = useContext(ColorSwatchPickerContextInternal);
1285
+ if (!context) throw new Error("ColorSwatchPickerItem must be used within a ColorSwatchPicker");
1286
+ const [local, ariaProps, rest] = splitProps(props, [
1287
+ "children",
1288
+ "class",
1289
+ "style",
1290
+ "slot",
1291
+ "color"
1292
+ ], ["isDisabled", "aria-label"]);
1293
+ const color = createMemo(() => normalizeColor(local.color));
1294
+ const key = createMemo(() => color().toString("hexa"));
1295
+ const textValue = createMemo(() => {
1296
+ const locale = globalThis.navigator?.language ?? "en-US";
1297
+ return color().getColorName(locale);
1298
+ });
1299
+ createEffect(() => {
1300
+ const itemKey = key();
1301
+ context.registerItem({
1302
+ key: itemKey,
1303
+ color: color(),
1304
+ textValue: textValue(),
1305
+ isDisabled: ariaProps.isDisabled
1306
+ });
1307
+ onCleanup(() => context.unregisterItem(itemKey));
1308
+ });
1309
+ const optionAria = createOption(() => ({
1310
+ key: key(),
1311
+ isDisabled: ariaProps.isDisabled,
1312
+ "aria-label": ariaProps["aria-label"] ?? textValue()
1313
+ }), context.state);
1314
+ const renderValues = createMemo(() => ({
1315
+ isSelected: optionAria.isSelected(),
1316
+ isFocused: optionAria.isFocused(),
1317
+ isFocusVisible: optionAria.isFocusVisible(),
1318
+ isPressed: optionAria.isPressed(),
1319
+ isDisabled: optionAria.isDisabled(),
1320
+ color: color()
1321
+ }));
1322
+ const renderProps = useRenderProps({
1323
+ get children() {
1324
+ return local.children;
1325
+ },
1326
+ class: local.class,
1327
+ style: local.style,
1328
+ defaultClassName: "solidaria-ColorSwatchPickerItem"
1329
+ }, renderValues);
1330
+ const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
1331
+ const cleanOptionProps = () => {
1332
+ const { ref: _ref, ...restOptionProps } = optionAria.optionProps;
1333
+ return restOptionProps;
1334
+ };
1335
+ return <div {...mergeProps$1(domProps(), cleanOptionProps())} class={renderProps.class()} style={renderProps.style()}>
1336
+ <ColorSwatchContextInternal.Provider value={{ color: color() }}>
1337
+ {renderProps.children ? renderProps.renderChildren() : <ColorSwatch />}
1338
+ </ColorSwatchContextInternal.Provider>
1339
+ </div>;
1340
+ }
1341
+ //#endregion
1342
+ export { ColorArea, ColorAreaContext, ColorAreaGradient, ColorAreaStateContext, ColorAreaThumb, ColorField, ColorFieldContext, ColorFieldInput, ColorFieldStateContext, ColorPicker, ColorPickerContext, ColorPickerStateContext, ColorSlider, ColorSliderContext, ColorSliderLabel, ColorSliderOutput, ColorSliderStateContext, ColorSliderThumb, ColorSliderTrack, ColorSwatch, ColorSwatchContext, ColorSwatchPicker, ColorSwatchPickerContext, ColorSwatchPickerItem, ColorThumb, ColorWheel, ColorWheelContext, ColorWheelStateContext, ColorWheelThumb, ColorWheelTrack, ColorWheelTrackContext };
1343
+
1344
+ //# sourceMappingURL=Color.jsx.map