@solid2-aria/stately 0.0.0-stage → 0.0.1

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 (477) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/dist/LICENSES/Apache-2.0.txt +201 -0
  4. package/dist/LICENSES/react-spectrum-NOTICE.txt +242 -0
  5. package/dist/NOTICE.txt +636 -0
  6. package/dist/autocomplete/create-autocomplete-state.d.ts +46 -0
  7. package/dist/autocomplete/create-autocomplete-state.js +41 -0
  8. package/dist/autocomplete/create-autocomplete-state.js.map +1 -0
  9. package/dist/calendar/create-calendar-state.d.ts +62 -0
  10. package/dist/calendar/create-calendar-state.js +357 -0
  11. package/dist/calendar/create-calendar-state.js.map +1 -0
  12. package/dist/calendar/create-range-calendar-state.d.ts +63 -0
  13. package/dist/calendar/create-range-calendar-state.js +204 -0
  14. package/dist/calendar/create-range-calendar-state.js.map +1 -0
  15. package/dist/calendar/types.d.ts +222 -0
  16. package/dist/calendar/types.js +16 -0
  17. package/dist/calendar/utils.d.ts +27 -0
  18. package/dist/calendar/utils.js +81 -0
  19. package/dist/calendar/utils.js.map +1 -0
  20. package/dist/checkbox/create-checkbox-group-state.d.ts +60 -0
  21. package/dist/checkbox/create-checkbox-group-state.js +88 -0
  22. package/dist/checkbox/create-checkbox-group-state.js.map +1 -0
  23. package/dist/collections/collection-builder.d.ts +28 -0
  24. package/dist/collections/collection-builder.js +164 -0
  25. package/dist/collections/collection-builder.js.map +1 -0
  26. package/dist/collections/create-collection.d.ts +24 -0
  27. package/dist/collections/create-collection.js +35 -0
  28. package/dist/collections/create-collection.js.map +1 -0
  29. package/dist/collections/get-child-nodes.d.ts +25 -0
  30. package/dist/collections/get-child-nodes.js +67 -0
  31. package/dist/collections/get-child-nodes.js.map +1 -0
  32. package/dist/collections/get-item-count.d.ts +19 -0
  33. package/dist/collections/get-item-count.js +34 -0
  34. package/dist/collections/get-item-count.js.map +1 -0
  35. package/dist/collections/item.d.ts +29 -0
  36. package/dist/collections/item.js +68 -0
  37. package/dist/collections/item.js.map +1 -0
  38. package/dist/collections/section.d.ts +29 -0
  39. package/dist/collections/section.js +60 -0
  40. package/dist/collections/section.js.map +1 -0
  41. package/dist/collections/types.d.ts +46 -0
  42. package/dist/collections/types.js +29 -0
  43. package/dist/collections/types.js.map +1 -0
  44. package/dist/color/color/base-color.d.ts +40 -0
  45. package/dist/color/color/base-color.js +122 -0
  46. package/dist/color/color/base-color.js.map +1 -0
  47. package/dist/color/color/color-classes.d.ts +27 -0
  48. package/dist/color/color/color-classes.js +29 -0
  49. package/dist/color/color/color-classes.js.map +1 -0
  50. package/dist/color/color/color-constructors.d.ts +23 -0
  51. package/dist/color/color/color-constructors.js +16 -0
  52. package/dist/color/color/color.d.ts +3 -0
  53. package/dist/color/color/color.js +2 -0
  54. package/dist/color/color/hsb-color.d.ts +24 -0
  55. package/dist/color/color/hsb-color.js +183 -0
  56. package/dist/color/color/hsb-color.js.map +1 -0
  57. package/dist/color/color/hsl-color.d.ts +24 -0
  58. package/dist/color/color/hsl-color.js +184 -0
  59. package/dist/color/color/hsl-color.js.map +1 -0
  60. package/dist/color/color/normalize-hue.d.ts +18 -0
  61. package/dist/color/color/normalize-hue.js +24 -0
  62. package/dist/color/color/normalize-hue.js.map +1 -0
  63. package/dist/color/color/oklch.d.ts +19 -0
  64. package/dist/color/color/oklch.js +97 -0
  65. package/dist/color/color/oklch.js.map +1 -0
  66. package/dist/color/color/rgb-color.d.ts +24 -0
  67. package/dist/color/color/rgb-color.js +230 -0
  68. package/dist/color/color/rgb-color.js.map +1 -0
  69. package/dist/color/color.d.ts +25 -0
  70. package/dist/color/color.js +41 -0
  71. package/dist/color/color.js.map +1 -0
  72. package/dist/color/create-color-area-state.d.ts +105 -0
  73. package/dist/color/create-color-area-state.js +138 -0
  74. package/dist/color/create-color-area-state.js.map +1 -0
  75. package/dist/color/create-color-channel-field-state.d.ts +29 -0
  76. package/dist/color/create-color-channel-field-state.js +69 -0
  77. package/dist/color/create-color-channel-field-state.js.map +1 -0
  78. package/dist/color/create-color-field-state.d.ts +61 -0
  79. package/dist/color/create-color-field-state.js +113 -0
  80. package/dist/color/create-color-field-state.js.map +1 -0
  81. package/dist/color/create-color-picker-state.d.ts +16 -0
  82. package/dist/color/create-color-picker-state.js +26 -0
  83. package/dist/color/create-color-picker-state.js.map +1 -0
  84. package/dist/color/create-color-slider-state.d.ts +50 -0
  85. package/dist/color/create-color-slider-state.js +93 -0
  86. package/dist/color/create-color-slider-state.js.map +1 -0
  87. package/dist/color/create-color-wheel-state.d.ts +76 -0
  88. package/dist/color/create-color-wheel-state.js +130 -0
  89. package/dist/color/create-color-wheel-state.js.map +1 -0
  90. package/dist/color/create-color.d.ts +20 -0
  91. package/dist/color/create-color.js +33 -0
  92. package/dist/color/create-color.js.map +1 -0
  93. package/dist/color/types.d.ts +87 -0
  94. package/dist/color/types.js +5 -0
  95. package/dist/combobox/create-combo-box-state.d.ts +157 -0
  96. package/dist/combobox/create-combo-box-state.js +450 -0
  97. package/dist/combobox/create-combo-box-state.js.map +1 -0
  98. package/dist/data/create-async-list.d.ts +88 -0
  99. package/dist/data/create-async-list.js +276 -0
  100. package/dist/data/create-async-list.js.map +1 -0
  101. package/dist/data/create-list-data.d.ts +140 -0
  102. package/dist/data/create-list-data.js +250 -0
  103. package/dist/data/create-list-data.js.map +1 -0
  104. package/dist/data/create-tree-data.d.ts +134 -0
  105. package/dist/data/create-tree-data.js +364 -0
  106. package/dist/data/create-tree-data.js.map +1 -0
  107. package/dist/datepicker/create-date-field-state.d.ts +138 -0
  108. package/dist/datepicker/create-date-field-state.js +449 -0
  109. package/dist/datepicker/create-date-field-state.js.map +1 -0
  110. package/dist/datepicker/create-date-picker-state.d.ts +82 -0
  111. package/dist/datepicker/create-date-picker-state.js +191 -0
  112. package/dist/datepicker/create-date-picker-state.js.map +1 -0
  113. package/dist/datepicker/create-date-range-picker-state.d.ts +97 -0
  114. package/dist/datepicker/create-date-range-picker-state.js +305 -0
  115. package/dist/datepicker/create-date-range-picker-state.js.map +1 -0
  116. package/dist/datepicker/create-time-field-state.d.ts +34 -0
  117. package/dist/datepicker/create-time-field-state.js +128 -0
  118. package/dist/datepicker/create-time-field-state.js.map +1 -0
  119. package/dist/datepicker/incomplete-date.d.ts +71 -0
  120. package/dist/datepicker/incomplete-date.js +324 -0
  121. package/dist/datepicker/incomplete-date.js.map +1 -0
  122. package/dist/datepicker/placeholders.d.ts +18 -0
  123. package/dist/datepicker/placeholders.js +418 -0
  124. package/dist/datepicker/placeholders.js.map +1 -0
  125. package/dist/datepicker/types.d.ts +131 -0
  126. package/dist/datepicker/types.js +16 -0
  127. package/dist/datepicker/utils.d.ts +37 -0
  128. package/dist/datepicker/utils.js +168 -0
  129. package/dist/datepicker/utils.js.map +1 -0
  130. package/dist/disclosure/create-disclosure-group-state.d.ts +47 -0
  131. package/dist/disclosure/create-disclosure-group-state.js +62 -0
  132. package/dist/disclosure/create-disclosure-group-state.js.map +1 -0
  133. package/dist/disclosure/create-disclosure-state.d.ts +42 -0
  134. package/dist/disclosure/create-disclosure-state.js +49 -0
  135. package/dist/disclosure/create-disclosure-state.js.map +1 -0
  136. package/dist/dnd/create-draggable-collection-state.d.ts +63 -0
  137. package/dist/dnd/create-draggable-collection-state.js +136 -0
  138. package/dist/dnd/create-draggable-collection-state.js.map +1 -0
  139. package/dist/dnd/create-droppable-collection-state.d.ts +55 -0
  140. package/dist/dnd/create-droppable-collection-state.js +155 -0
  141. package/dist/dnd/create-droppable-collection-state.js.map +1 -0
  142. package/dist/flags/flags.d.ts +21 -0
  143. package/dist/flags/flags.js +34 -0
  144. package/dist/flags/flags.js.map +1 -0
  145. package/dist/form/create-form-validation-state.d.ts +37 -0
  146. package/dist/form/create-form-validation-state.js +152 -0
  147. package/dist/form/create-form-validation-state.js.map +1 -0
  148. package/dist/grid/create-grid-state.d.ts +38 -0
  149. package/dist/grid/create-grid-state.js +85 -0
  150. package/dist/grid/create-grid-state.js.map +1 -0
  151. package/dist/grid/grid-collection.d.ts +68 -0
  152. package/dist/grid/grid-collection.js +133 -0
  153. package/dist/grid/grid-collection.js.map +1 -0
  154. package/dist/index.d.ts +91 -0
  155. package/dist/index.js +86 -0
  156. package/dist/intl/color/ar-AE.js +44 -0
  157. package/dist/intl/color/ar-AE.js.map +1 -0
  158. package/dist/intl/color/bg-BG.js +44 -0
  159. package/dist/intl/color/bg-BG.js.map +1 -0
  160. package/dist/intl/color/cs-CZ.js +44 -0
  161. package/dist/intl/color/cs-CZ.js.map +1 -0
  162. package/dist/intl/color/da-DK.js +44 -0
  163. package/dist/intl/color/da-DK.js.map +1 -0
  164. package/dist/intl/color/de-DE.js +44 -0
  165. package/dist/intl/color/de-DE.js.map +1 -0
  166. package/dist/intl/color/el-GR.js +44 -0
  167. package/dist/intl/color/el-GR.js.map +1 -0
  168. package/dist/intl/color/en-US.js +44 -0
  169. package/dist/intl/color/en-US.js.map +1 -0
  170. package/dist/intl/color/es-ES.js +44 -0
  171. package/dist/intl/color/es-ES.js.map +1 -0
  172. package/dist/intl/color/et-EE.js +44 -0
  173. package/dist/intl/color/et-EE.js.map +1 -0
  174. package/dist/intl/color/fi-FI.js +44 -0
  175. package/dist/intl/color/fi-FI.js.map +1 -0
  176. package/dist/intl/color/fr-FR.js +44 -0
  177. package/dist/intl/color/fr-FR.js.map +1 -0
  178. package/dist/intl/color/he-IL.js +44 -0
  179. package/dist/intl/color/he-IL.js.map +1 -0
  180. package/dist/intl/color/hr-HR.js +44 -0
  181. package/dist/intl/color/hr-HR.js.map +1 -0
  182. package/dist/intl/color/hu-HU.js +44 -0
  183. package/dist/intl/color/hu-HU.js.map +1 -0
  184. package/dist/intl/color/index.js +75 -0
  185. package/dist/intl/color/index.js.map +1 -0
  186. package/dist/intl/color/it-IT.js +44 -0
  187. package/dist/intl/color/it-IT.js.map +1 -0
  188. package/dist/intl/color/ja-JP.js +44 -0
  189. package/dist/intl/color/ja-JP.js.map +1 -0
  190. package/dist/intl/color/ko-KR.js +44 -0
  191. package/dist/intl/color/ko-KR.js.map +1 -0
  192. package/dist/intl/color/lt-LT.js +44 -0
  193. package/dist/intl/color/lt-LT.js.map +1 -0
  194. package/dist/intl/color/lv-LV.js +44 -0
  195. package/dist/intl/color/lv-LV.js.map +1 -0
  196. package/dist/intl/color/nb-NO.js +44 -0
  197. package/dist/intl/color/nb-NO.js.map +1 -0
  198. package/dist/intl/color/nl-NL.js +44 -0
  199. package/dist/intl/color/nl-NL.js.map +1 -0
  200. package/dist/intl/color/pl-PL.js +44 -0
  201. package/dist/intl/color/pl-PL.js.map +1 -0
  202. package/dist/intl/color/pt-BR.js +44 -0
  203. package/dist/intl/color/pt-BR.js.map +1 -0
  204. package/dist/intl/color/pt-PT.js +44 -0
  205. package/dist/intl/color/pt-PT.js.map +1 -0
  206. package/dist/intl/color/ro-RO.js +44 -0
  207. package/dist/intl/color/ro-RO.js.map +1 -0
  208. package/dist/intl/color/ru-RU.js +44 -0
  209. package/dist/intl/color/ru-RU.js.map +1 -0
  210. package/dist/intl/color/sk-SK.js +44 -0
  211. package/dist/intl/color/sk-SK.js.map +1 -0
  212. package/dist/intl/color/sl-SI.js +44 -0
  213. package/dist/intl/color/sl-SI.js.map +1 -0
  214. package/dist/intl/color/sr-SP.js +44 -0
  215. package/dist/intl/color/sr-SP.js.map +1 -0
  216. package/dist/intl/color/sv-SE.js +44 -0
  217. package/dist/intl/color/sv-SE.js.map +1 -0
  218. package/dist/intl/color/tr-TR.js +44 -0
  219. package/dist/intl/color/tr-TR.js.map +1 -0
  220. package/dist/intl/color/uk-UA.js +44 -0
  221. package/dist/intl/color/uk-UA.js.map +1 -0
  222. package/dist/intl/color/zh-CN.js +44 -0
  223. package/dist/intl/color/zh-CN.js.map +1 -0
  224. package/dist/intl/color/zh-TW.js +44 -0
  225. package/dist/intl/color/zh-TW.js.map +1 -0
  226. package/dist/intl/datepicker/ar-AE.js +11 -0
  227. package/dist/intl/datepicker/ar-AE.js.map +1 -0
  228. package/dist/intl/datepicker/bg-BG.js +11 -0
  229. package/dist/intl/datepicker/bg-BG.js.map +1 -0
  230. package/dist/intl/datepicker/cs-CZ.js +11 -0
  231. package/dist/intl/datepicker/cs-CZ.js.map +1 -0
  232. package/dist/intl/datepicker/da-DK.js +11 -0
  233. package/dist/intl/datepicker/da-DK.js.map +1 -0
  234. package/dist/intl/datepicker/de-DE.js +11 -0
  235. package/dist/intl/datepicker/de-DE.js.map +1 -0
  236. package/dist/intl/datepicker/el-GR.js +11 -0
  237. package/dist/intl/datepicker/el-GR.js.map +1 -0
  238. package/dist/intl/datepicker/en-US.js +11 -0
  239. package/dist/intl/datepicker/en-US.js.map +1 -0
  240. package/dist/intl/datepicker/es-ES.js +11 -0
  241. package/dist/intl/datepicker/es-ES.js.map +1 -0
  242. package/dist/intl/datepicker/et-EE.js +11 -0
  243. package/dist/intl/datepicker/et-EE.js.map +1 -0
  244. package/dist/intl/datepicker/fi-FI.js +11 -0
  245. package/dist/intl/datepicker/fi-FI.js.map +1 -0
  246. package/dist/intl/datepicker/fr-FR.js +11 -0
  247. package/dist/intl/datepicker/fr-FR.js.map +1 -0
  248. package/dist/intl/datepicker/he-IL.js +11 -0
  249. package/dist/intl/datepicker/he-IL.js.map +1 -0
  250. package/dist/intl/datepicker/hr-HR.js +11 -0
  251. package/dist/intl/datepicker/hr-HR.js.map +1 -0
  252. package/dist/intl/datepicker/hu-HU.js +11 -0
  253. package/dist/intl/datepicker/hu-HU.js.map +1 -0
  254. package/dist/intl/datepicker/index.js +75 -0
  255. package/dist/intl/datepicker/index.js.map +1 -0
  256. package/dist/intl/datepicker/it-IT.js +11 -0
  257. package/dist/intl/datepicker/it-IT.js.map +1 -0
  258. package/dist/intl/datepicker/ja-JP.js +11 -0
  259. package/dist/intl/datepicker/ja-JP.js.map +1 -0
  260. package/dist/intl/datepicker/ko-KR.js +11 -0
  261. package/dist/intl/datepicker/ko-KR.js.map +1 -0
  262. package/dist/intl/datepicker/lt-LT.js +11 -0
  263. package/dist/intl/datepicker/lt-LT.js.map +1 -0
  264. package/dist/intl/datepicker/lv-LV.js +11 -0
  265. package/dist/intl/datepicker/lv-LV.js.map +1 -0
  266. package/dist/intl/datepicker/nb-NO.js +11 -0
  267. package/dist/intl/datepicker/nb-NO.js.map +1 -0
  268. package/dist/intl/datepicker/nl-NL.js +11 -0
  269. package/dist/intl/datepicker/nl-NL.js.map +1 -0
  270. package/dist/intl/datepicker/pl-PL.js +11 -0
  271. package/dist/intl/datepicker/pl-PL.js.map +1 -0
  272. package/dist/intl/datepicker/pt-BR.js +11 -0
  273. package/dist/intl/datepicker/pt-BR.js.map +1 -0
  274. package/dist/intl/datepicker/pt-PT.js +11 -0
  275. package/dist/intl/datepicker/pt-PT.js.map +1 -0
  276. package/dist/intl/datepicker/ro-RO.js +11 -0
  277. package/dist/intl/datepicker/ro-RO.js.map +1 -0
  278. package/dist/intl/datepicker/ru-RU.js +11 -0
  279. package/dist/intl/datepicker/ru-RU.js.map +1 -0
  280. package/dist/intl/datepicker/sk-SK.js +11 -0
  281. package/dist/intl/datepicker/sk-SK.js.map +1 -0
  282. package/dist/intl/datepicker/sl-SI.js +11 -0
  283. package/dist/intl/datepicker/sl-SI.js.map +1 -0
  284. package/dist/intl/datepicker/sr-SP.js +11 -0
  285. package/dist/intl/datepicker/sr-SP.js.map +1 -0
  286. package/dist/intl/datepicker/sv-SE.js +11 -0
  287. package/dist/intl/datepicker/sv-SE.js.map +1 -0
  288. package/dist/intl/datepicker/tr-TR.js +11 -0
  289. package/dist/intl/datepicker/tr-TR.js.map +1 -0
  290. package/dist/intl/datepicker/uk-UA.js +11 -0
  291. package/dist/intl/datepicker/uk-UA.js.map +1 -0
  292. package/dist/intl/datepicker/zh-CN.js +11 -0
  293. package/dist/intl/datepicker/zh-CN.js.map +1 -0
  294. package/dist/intl/datepicker/zh-TW.js +11 -0
  295. package/dist/intl/datepicker/zh-TW.js.map +1 -0
  296. package/dist/layout/grid-layout.d.ts +107 -0
  297. package/dist/layout/grid-layout.js +253 -0
  298. package/dist/layout/grid-layout.js.map +1 -0
  299. package/dist/layout/list-layout.d.ts +187 -0
  300. package/dist/layout/list-layout.js +488 -0
  301. package/dist/layout/list-layout.js.map +1 -0
  302. package/dist/layout/table-layout.d.ts +98 -0
  303. package/dist/layout/table-layout.js +476 -0
  304. package/dist/layout/table-layout.js.map +1 -0
  305. package/dist/layout/waterfall-layout.d.ts +85 -0
  306. package/dist/layout/waterfall-layout.js +225 -0
  307. package/dist/layout/waterfall-layout.js.map +1 -0
  308. package/dist/list/create-list-state.d.ts +48 -0
  309. package/dist/list/create-list-state.js +123 -0
  310. package/dist/list/create-list-state.js.map +1 -0
  311. package/dist/list/create-single-select-list-state.d.ts +38 -0
  312. package/dist/list/create-single-select-list-state.js +55 -0
  313. package/dist/list/create-single-select-list-state.js.map +1 -0
  314. package/dist/list/list-collection.d.ts +36 -0
  315. package/dist/list/list-collection.js +91 -0
  316. package/dist/list/list-collection.js.map +1 -0
  317. package/dist/menu/create-menu-trigger-state.d.ts +55 -0
  318. package/dist/menu/create-menu-trigger-state.js +58 -0
  319. package/dist/menu/create-menu-trigger-state.js.map +1 -0
  320. package/dist/menu/create-submenu-trigger-state.d.ts +47 -0
  321. package/dist/menu/create-submenu-trigger-state.js +59 -0
  322. package/dist/menu/create-submenu-trigger-state.js.map +1 -0
  323. package/dist/numberfield/create-number-field-state.d.ts +93 -0
  324. package/dist/numberfield/create-number-field-state.js +139 -0
  325. package/dist/numberfield/create-number-field-state.js.map +1 -0
  326. package/dist/overlays/create-overlay-trigger-state.d.ts +51 -0
  327. package/dist/overlays/create-overlay-trigger-state.js +56 -0
  328. package/dist/overlays/create-overlay-trigger-state.js.map +1 -0
  329. package/dist/radio/create-radio-group-state.d.ts +61 -0
  330. package/dist/radio/create-radio-group-state.js +71 -0
  331. package/dist/radio/create-radio-group-state.js.map +1 -0
  332. package/dist/searchfield/create-search-field-state.d.ts +35 -0
  333. package/dist/searchfield/create-search-field-state.js +34 -0
  334. package/dist/searchfield/create-search-field-state.js.map +1 -0
  335. package/dist/select/create-select-state.d.ts +116 -0
  336. package/dist/select/create-select-state.js +151 -0
  337. package/dist/select/create-select-state.js.map +1 -0
  338. package/dist/selection/create-multiple-selection-state.d.ts +39 -0
  339. package/dist/selection/create-multiple-selection-state.js +114 -0
  340. package/dist/selection/create-multiple-selection-state.js.map +1 -0
  341. package/dist/selection/selection-manager.d.ts +139 -0
  342. package/dist/selection/selection-manager.js +334 -0
  343. package/dist/selection/selection-manager.js.map +1 -0
  344. package/dist/selection/selection.d.ts +27 -0
  345. package/dist/selection/selection.js +38 -0
  346. package/dist/selection/selection.js.map +1 -0
  347. package/dist/selection/types.d.ts +116 -0
  348. package/dist/selection/types.js +16 -0
  349. package/dist/slider/create-slider-state.d.ts +182 -0
  350. package/dist/slider/create-slider-state.js +131 -0
  351. package/dist/slider/create-slider-state.js.map +1 -0
  352. package/dist/steplist/create-step-list-state.d.ts +40 -0
  353. package/dist/steplist/create-step-list-state.js +132 -0
  354. package/dist/steplist/create-step-list-state.js.map +1 -0
  355. package/dist/table/cell.d.ts +37 -0
  356. package/dist/table/cell.js +47 -0
  357. package/dist/table/cell.js.map +1 -0
  358. package/dist/table/collection-context.d.ts +4 -0
  359. package/dist/table/collection-context.js +8 -0
  360. package/dist/table/collection-context.js.map +1 -0
  361. package/dist/table/column.d.ts +66 -0
  362. package/dist/table/column.js +71 -0
  363. package/dist/table/column.js.map +1 -0
  364. package/dist/table/create-table-column-resize-state.d.ts +65 -0
  365. package/dist/table/create-table-column-resize-state.js +100 -0
  366. package/dist/table/create-table-column-resize-state.js.map +1 -0
  367. package/dist/table/create-table-state.d.ts +112 -0
  368. package/dist/table/create-table-state.js +122 -0
  369. package/dist/table/create-table-state.js.map +1 -0
  370. package/dist/table/create-tree-grid-state.d.ts +44 -0
  371. package/dist/table/create-tree-grid-state.js +145 -0
  372. package/dist/table/create-tree-grid-state.js.map +1 -0
  373. package/dist/table/row.d.ts +44 -0
  374. package/dist/table/row.js +91 -0
  375. package/dist/table/row.js.map +1 -0
  376. package/dist/table/table-body.d.ts +36 -0
  377. package/dist/table/table-body.js +57 -0
  378. package/dist/table/table-body.js.map +1 -0
  379. package/dist/table/table-collection.d.ts +62 -0
  380. package/dist/table/table-collection.js +274 -0
  381. package/dist/table/table-collection.js.map +1 -0
  382. package/dist/table/table-column-layout.d.ts +47 -0
  383. package/dist/table/table-column-layout.js +94 -0
  384. package/dist/table/table-column-layout.js.map +1 -0
  385. package/dist/table/table-header.d.ts +37 -0
  386. package/dist/table/table-header.js +52 -0
  387. package/dist/table/table-header.js.map +1 -0
  388. package/dist/table/table-utils.d.ts +60 -0
  389. package/dist/table/table-utils.js +203 -0
  390. package/dist/table/table-utils.js.map +1 -0
  391. package/dist/tabs/create-tab-list-state.d.ts +42 -0
  392. package/dist/tabs/create-tab-list-state.js +78 -0
  393. package/dist/tabs/create-tab-list-state.js.map +1 -0
  394. package/dist/toast/create-toast-state.d.ts +97 -0
  395. package/dist/toast/create-toast-state.js +166 -0
  396. package/dist/toast/create-toast-state.js.map +1 -0
  397. package/dist/toggle/create-toggle-group-state.d.ts +55 -0
  398. package/dist/toggle/create-toggle-group-state.js +62 -0
  399. package/dist/toggle/create-toggle-group-state.js.map +1 -0
  400. package/dist/toggle/create-toggle-state.d.ts +58 -0
  401. package/dist/toggle/create-toggle-state.js +43 -0
  402. package/dist/toggle/create-toggle-state.js.map +1 -0
  403. package/dist/tokenfield/create-token-field-state.d.ts +39 -0
  404. package/dist/tokenfield/create-token-field-state.js +44 -0
  405. package/dist/tokenfield/create-token-field-state.js.map +1 -0
  406. package/dist/tokenfield/token-field-value.d.ts +111 -0
  407. package/dist/tokenfield/token-field-value.js +327 -0
  408. package/dist/tokenfield/token-field-value.js.map +1 -0
  409. package/dist/tooltip/create-tooltip-trigger-state.d.ts +73 -0
  410. package/dist/tooltip/create-tooltip-trigger-state.js +136 -0
  411. package/dist/tooltip/create-tooltip-trigger-state.js.map +1 -0
  412. package/dist/tree/create-tree-state.d.ts +42 -0
  413. package/dist/tree/create-tree-state.js +75 -0
  414. package/dist/tree/create-tree-state.js.map +1 -0
  415. package/dist/tree/tree-collection.d.ts +36 -0
  416. package/dist/tree/tree-collection.js +84 -0
  417. package/dist/tree/tree-collection.js.map +1 -0
  418. package/dist/utils/create-controlled-signal.d.ts +23 -0
  419. package/dist/utils/create-controlled-signal.js +54 -0
  420. package/dist/utils/create-controlled-signal.js.map +1 -0
  421. package/dist/utils/get-item-key.d.ts +5 -0
  422. package/dist/utils/get-item-key.js +12 -0
  423. package/dist/utils/get-item-key.js.map +1 -0
  424. package/dist/utils/get-node-props.d.ts +23 -0
  425. package/dist/utils/get-node-props.js +38 -0
  426. package/dist/utils/get-node-props.js.map +1 -0
  427. package/dist/utils/has-content.d.ts +5 -0
  428. package/dist/utils/has-content.js +7 -0
  429. package/dist/utils/has-content.js.map +1 -0
  430. package/dist/utils/legacy-props.d.ts +10 -0
  431. package/dist/utils/legacy-props.js +17 -0
  432. package/dist/utils/legacy-props.js.map +1 -0
  433. package/dist/utils/number.d.ts +25 -0
  434. package/dist/utils/number.js +59 -0
  435. package/dist/utils/number.js.map +1 -0
  436. package/dist/utils/parse-calendar-identifier.d.ts +5 -0
  437. package/dist/utils/parse-calendar-identifier.js +31 -0
  438. package/dist/utils/parse-calendar-identifier.js.map +1 -0
  439. package/dist/utils/require-value.d.ts +4 -0
  440. package/dist/utils/require-value.js +10 -0
  441. package/dist/utils/require-value.js.map +1 -0
  442. package/dist/virtualizer/create-virtualizer-state.d.ts +44 -0
  443. package/dist/virtualizer/create-virtualizer-state.js +92 -0
  444. package/dist/virtualizer/create-virtualizer-state.js.map +1 -0
  445. package/dist/virtualizer/layout-info.d.ts +94 -0
  446. package/dist/virtualizer/layout-info.js +118 -0
  447. package/dist/virtualizer/layout-info.js.map +1 -0
  448. package/dist/virtualizer/layout.d.ts +91 -0
  449. package/dist/virtualizer/layout.js +71 -0
  450. package/dist/virtualizer/layout.js.map +1 -0
  451. package/dist/virtualizer/overscan-manager.d.ts +25 -0
  452. package/dist/virtualizer/overscan-manager.js +46 -0
  453. package/dist/virtualizer/overscan-manager.js.map +1 -0
  454. package/dist/virtualizer/point.d.ts +36 -0
  455. package/dist/virtualizer/point.js +48 -0
  456. package/dist/virtualizer/point.js.map +1 -0
  457. package/dist/virtualizer/rect.d.ts +103 -0
  458. package/dist/virtualizer/rect.js +156 -0
  459. package/dist/virtualizer/rect.js.map +1 -0
  460. package/dist/virtualizer/reusable-view.d.ts +51 -0
  461. package/dist/virtualizer/reusable-view.js +81 -0
  462. package/dist/virtualizer/reusable-view.js.map +1 -0
  463. package/dist/virtualizer/scroll-anchor.d.ts +98 -0
  464. package/dist/virtualizer/scroll-anchor.js +150 -0
  465. package/dist/virtualizer/scroll-anchor.js.map +1 -0
  466. package/dist/virtualizer/size.d.ts +34 -0
  467. package/dist/virtualizer/size.js +46 -0
  468. package/dist/virtualizer/size.js.map +1 -0
  469. package/dist/virtualizer/types.d.ts +47 -0
  470. package/dist/virtualizer/types.js +16 -0
  471. package/dist/virtualizer/utils.d.ts +19 -0
  472. package/dist/virtualizer/utils.js +27 -0
  473. package/dist/virtualizer/utils.js.map +1 -0
  474. package/dist/virtualizer/virtualizer.d.ts +99 -0
  475. package/dist/virtualizer/virtualizer.js +314 -0
  476. package/dist/virtualizer/virtualizer.js.map +1 -0
  477. package/package.json +174 -4
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorChannelFieldState.ts.
3
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
4
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
+ */
6
+ import { Color, ColorChannel, ColorSpace } from "./types.js";
7
+ import { NumberFieldState } from "../numberfield/create-number-field-state.js";
8
+ import { ColorFieldProps } from "./create-color-field-state.js";
9
+ export interface ColorChannelFieldProps extends ColorFieldProps {
10
+ colorSpace?: ColorSpace;
11
+ channel: ColorChannel;
12
+ }
13
+ export interface ColorChannelFieldStateOptions extends ColorChannelFieldProps {
14
+ locale: string;
15
+ }
16
+ export interface ColorChannelFieldState extends NumberFieldState {
17
+ /** The current value of the field. */
18
+ colorValue: Color;
19
+ /** The default value of the field. */
20
+ defaultColorValue: Color | null;
21
+ /** Sets the color value of the field. */
22
+ setColorValue: (value: Color | null) => void;
23
+ }
24
+ /**
25
+ * Provides state management for a color channel field, allowing users to edit the
26
+ * value of an individual color channel.
27
+ */
28
+ export declare function createColorChannelFieldState(props: ColorChannelFieldStateOptions): ColorChannelFieldState;
29
+ //# sourceMappingURL=create-color-channel-field-state.d.ts.map
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorChannelFieldState.ts.
3
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
4
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
+ */
6
+ import { createControlledSignal } from "../utils/create-controlled-signal.js";
7
+ import { parseColor } from "./color.js";
8
+ import { createColor } from "./create-color.js";
9
+ import { createNumberFieldState } from "../numberfield/create-number-field-state.js";
10
+ import { createMemo, merge, untrack } from "solid-js";
11
+ // src/color/create-color-channel-field-state.ts
12
+ /**
13
+ * Provides state management for a color channel field, allowing users to edit the
14
+ * value of an individual color channel.
15
+ */
16
+ function createColorChannelFieldState(props) {
17
+ const initialValue = createColor(() => props.value);
18
+ const initialDefault = createColor(() => props.defaultValue);
19
+ const [colorValue, setColor] = createControlledSignal(initialValue, untrack(initialDefault) ?? null, (v) => props.onChange?.(v));
20
+ const initial = untrack(colorValue);
21
+ const black = parseColor("#000");
22
+ const convert = (v) => props.colorSpace ? (v ?? black).toFormat(props.colorSpace) : v ?? black;
23
+ const color = createMemo(() => convert(colorValue()));
24
+ const defaultValue = () => initialDefault() ?? initial;
25
+ const defaultColor = createMemo(() => convert(defaultValue()));
26
+ const range = () => color().getChannelRange(props.channel);
27
+ const options = createMemo(() => color().getChannelFormatOptions(props.channel));
28
+ const multiplier = () => options().style === "percent" && range().maxValue === 100 ? 100 : 1;
29
+ const numberState = createNumberFieldState({
30
+ get defaultValue() {
31
+ return defaultValue() === null ? NaN : defaultColor().getChannelValue(props.channel) / multiplier();
32
+ },
33
+ get formatOptions() {
34
+ return options();
35
+ },
36
+ get locale() {
37
+ return props.locale;
38
+ },
39
+ get maxValue() {
40
+ return range().maxValue / multiplier();
41
+ },
42
+ get minValue() {
43
+ return range().minValue / multiplier();
44
+ },
45
+ onChange(v) {
46
+ setColor(Number.isNaN(v) ? null : color().withChannelValue(props.channel, v * multiplier()));
47
+ },
48
+ get step() {
49
+ return range().step / multiplier();
50
+ },
51
+ get value() {
52
+ return colorValue() === null ? NaN : color().getChannelValue(props.channel) / multiplier();
53
+ }
54
+ });
55
+ return merge(numberState, {
56
+ get colorValue() {
57
+ return color();
58
+ },
59
+ get defaultColorValue() {
60
+ return defaultValue();
61
+ },
62
+ setColorValue(v) {
63
+ setColor(v);
64
+ }
65
+ });
66
+ }
67
+ export { createColorChannelFieldState };
68
+
69
+ //# sourceMappingURL=create-color-channel-field-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-color-channel-field-state.js","names":[],"sources":["../../src/color/create-color-channel-field-state.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorChannelFieldState.ts.\n * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { createMemo, merge, untrack } from \"solid-js\";\n\nimport { createNumberFieldState } from \"../numberfield/create-number-field-state\";\nimport type { NumberFieldState } from \"../numberfield/create-number-field-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { parseColor } from \"./color\";\nimport { createColor } from \"./create-color\";\nimport type { ColorFieldProps } from \"./create-color-field-state\";\nimport type { Color, ColorChannel, ColorSpace } from \"./types\";\n\nexport interface ColorChannelFieldProps extends ColorFieldProps {\n colorSpace?: ColorSpace;\n channel: ColorChannel;\n}\n\nexport interface ColorChannelFieldStateOptions extends ColorChannelFieldProps {\n locale: string;\n}\n\nexport interface ColorChannelFieldState extends NumberFieldState {\n /** The current value of the field. */\n colorValue: Color;\n /** The default value of the field. */\n defaultColorValue: Color | null;\n /** Sets the color value of the field. */\n setColorValue: (value: Color | null) => void;\n}\n\n/**\n * Provides state management for a color channel field, allowing users to edit the\n * value of an individual color channel.\n */\n\nexport function createColorChannelFieldState(\n props: ColorChannelFieldStateOptions\n): ColorChannelFieldState {\n const initialValue = createColor(() => props.value);\n const initialDefault = createColor(() => props.defaultValue);\n\n const [colorValue, setColor] = createControlledSignal(\n initialValue,\n untrack(initialDefault) ?? null,\n (v) => props.onChange?.(v)\n );\n\n const initial = untrack(colorValue);\n const black = parseColor(\"#000\");\n\n const convert = (v: Color | null | undefined) =>\n props.colorSpace ? (v ?? black).toFormat(props.colorSpace) : (v ?? black);\n\n const color = createMemo(() => convert(colorValue()));\n const defaultValue = () => initialDefault() ?? initial;\n const defaultColor = createMemo(() => convert(defaultValue()));\n const range = () => color().getChannelRange(props.channel);\n\n const options = createMemo(() =>\n color().getChannelFormatOptions(props.channel)\n );\n\n const multiplier = () =>\n options().style === \"percent\" && range().maxValue === 100 ? 100 : 1;\n\n const numberState = createNumberFieldState({\n get defaultValue() {\n return defaultValue() === null\n ? Number.NaN\n : defaultColor().getChannelValue(props.channel) / multiplier();\n },\n get formatOptions() {\n return options();\n },\n get locale() {\n return props.locale;\n },\n get maxValue() {\n return range().maxValue / multiplier();\n },\n get minValue() {\n return range().minValue / multiplier();\n },\n onChange(v) {\n setColor(\n Number.isNaN(v)\n ? null\n : color().withChannelValue(props.channel, v * multiplier())\n );\n },\n get step() {\n return range().step / multiplier();\n },\n get value() {\n return colorValue() === null\n ? Number.NaN\n : color().getChannelValue(props.channel) / multiplier();\n },\n });\n\n return merge(numberState, {\n get colorValue() {\n return color();\n },\n get defaultColorValue() {\n return defaultValue();\n },\n setColorValue(v: Color | null) {\n setColor(v);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAgB,6BACd,OACwB;CACxB,MAAM,eAAe,kBAAkB,MAAM,KAAK;CAClD,MAAM,iBAAiB,kBAAkB,MAAM,YAAY;CAE3D,MAAM,CAAC,YAAY,YAAY,uBAC7B,cACA,QAAQ,cAAc,KAAK,OAC1B,MAAM,MAAM,WAAW,CAAC,CAC3B;CAEA,MAAM,UAAU,QAAQ,UAAU;CAClC,MAAM,QAAQ,WAAW,MAAM;CAE/B,MAAM,WAAW,MACf,MAAM,cAAc,KAAK,MAAA,CAAO,SAAS,MAAM,UAAU,IAAK,KAAK;CAErE,MAAM,QAAQ,iBAAiB,QAAQ,WAAW,CAAC,CAAC;CACpD,MAAM,qBAAqB,eAAe,KAAK;CAC/C,MAAM,eAAe,iBAAiB,QAAQ,aAAa,CAAC,CAAC;CAC7D,MAAM,cAAc,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO;CAEzD,MAAM,UAAU,iBACd,MAAM,CAAC,CAAC,wBAAwB,MAAM,OAAO,CAC/C;CAEA,MAAM,mBACJ,QAAQ,CAAC,CAAC,UAAU,aAAa,MAAM,CAAC,CAAC,aAAa,MAAM,MAAM;CAEpE,MAAM,cAAc,uBAAuB;EACzC,IAAI,eAAe;GACjB,OAAO,aAAa,MAAM,OACtB,MACA,aAAa,CAAC,CAAC,gBAAgB,MAAM,OAAO,IAAI,WAAW;EACjE;EACA,IAAI,gBAAgB;GAClB,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS;GACX,OAAO,MAAM;EACf;EACA,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC,WAAW,WAAW;EACvC;EACA,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC,WAAW,WAAW;EACvC;EACA,SAAS,GAAG;GACV,SACE,OAAO,MAAM,CAAC,IACV,OACA,MAAM,CAAC,CAAC,iBAAiB,MAAM,SAAS,IAAI,WAAW,CAAC,CAC9D;EACF;EACA,IAAI,OAAO;GACT,OAAO,MAAM,CAAC,CAAC,OAAO,WAAW;EACnC;EACA,IAAI,QAAQ;GACV,OAAO,WAAW,MAAM,OACpB,MACA,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,IAAI,WAAW;EAC1D;CACF,CAAC;CAED,OAAO,MAAM,aAAa;EACxB,IAAI,aAAa;GACf,OAAO,MAAM;EACf;EACA,IAAI,oBAAoB;GACtB,OAAO,aAAa;EACtB;EACA,cAAc,GAAiB;GAC7B,SAAS,CAAC;EACZ;CACF,CAAC;AACH"}
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorFieldState.ts.
14
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { FormValidationState } from "../form/create-form-validation-state.js";
18
+ import { Color } from "./types.js";
19
+ import { FocusableProps, HelpTextProps, InputBase, LabelableProps, TextInputBase, Validation, ValueBase } from "@solid2-aria/types-shared";
20
+ export interface ColorFieldProps extends Omit<ValueBase<string | Color | null>, "onChange">, InputBase, Validation<Color | null>, FocusableProps, TextInputBase, LabelableProps, HelpTextProps {
21
+ /** Handler that is called when the value changes. */
22
+ onChange?: (color: Color | null) => void;
23
+ }
24
+ export interface ColorFieldState extends FormValidationState {
25
+ /**
26
+ * The current text value of the input. Updated as the user types,
27
+ * and formatted according to `formatOptions` on blur.
28
+ */
29
+ readonly inputValue: string;
30
+ /**
31
+ * The currently parsed color value, or null if the field is empty.
32
+ * Updated based on the `inputValue` as the user types.
33
+ */
34
+ readonly colorValue: Color | null;
35
+ /** The default value of the color field. */
36
+ readonly defaultColorValue: Color | null;
37
+ /** Sets the color value of the field. */
38
+ setColorValue: (value: Color | null) => void;
39
+ /** Sets the current text value of the input. */
40
+ setInputValue: (value: string) => void;
41
+ /**
42
+ * Updates the input value based on the currently parsed color value.
43
+ * Typically this is called when the field is blurred.
44
+ */
45
+ commit: () => void;
46
+ /** Increments the current input value to the next step boundary, and fires `onChange`. */
47
+ increment: () => void;
48
+ /** Decrements the current input value to the next step boundary, and fires `onChange`. */
49
+ decrement: () => void;
50
+ /** Sets the current value to the maximum color value, and fires `onChange`. */
51
+ incrementToMax: () => void;
52
+ /** Sets the current value to the minimum color value, and fires `onChange`. */
53
+ decrementToMin: () => void;
54
+ /**
55
+ * Validates a user input string. Values can be partially entered, and may be valid even if they
56
+ * cannot currently be parsed to a color. Can be used to implement validation as a user types.
57
+ */
58
+ validate: (value: string) => boolean;
59
+ }
60
+ export declare function createColorFieldState(props: ColorFieldProps): ColorFieldState;
61
+ //# sourceMappingURL=create-color-field-state.d.ts.map
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorFieldState.ts.
14
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { createControlledSignal } from "../utils/create-controlled-signal.js";
18
+ import { createFormValidationState } from "../form/create-form-validation-state.js";
19
+ import { parseColor } from "./color.js";
20
+ import { createColor } from "./create-color.js";
21
+ import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
22
+ // src/color/create-color-field-state.ts
23
+ const MIN_COLOR = parseColor("#000000");
24
+ const MAX_COLOR = parseColor("#FFFFFF");
25
+ const MIN_COLOR_INT = MIN_COLOR.toHexInt();
26
+ const MAX_COLOR_INT = MAX_COLOR.toHexInt();
27
+ /**
28
+ * Provides state management for a color field component. Color fields allow
29
+ * users to enter and adjust a hex color value.
30
+ */
31
+ const format = (v) => v ? v.toString("hex") : "";
32
+ function createColorFieldState(props) {
33
+ const value = createColor(() => props.value);
34
+ const defaultValue = createColor(() => props.defaultValue);
35
+ const [colorValue, setColorValue] = createControlledSignal(() => value() ?? (props.value === null ? null : void 0), untrack(defaultValue) ?? null, (v) => props.onChange?.(v));
36
+ const initialValue = untrack(colorValue);
37
+ const [inputValue, setInputValue] = createSignal(untrack(() => format(colorValue())), { ownedWrite: true });
38
+ let previous = initialValue;
39
+ createRenderEffect(colorValue, (v) => {
40
+ if (previous !== v) {
41
+ previous = v;
42
+ setInputValue(format(v));
43
+ }
44
+ });
45
+ const validation = createFormValidationState(merge(props, { get value() {
46
+ return colorValue();
47
+ } }));
48
+ const parsed = createMemo(() => {
49
+ try {
50
+ const v = inputValue();
51
+ return parseColor(v.startsWith("#") ? v : `#${v}`);
52
+ } catch {
53
+ return null;
54
+ }
55
+ });
56
+ const safelySet = (v) => {
57
+ if (!v || !colorValue() || v.toHexInt() !== colorValue()?.toHexInt()) setColorValue(v);
58
+ };
59
+ const add = (step) => {
60
+ const base = parsed() ?? MIN_COLOR;
61
+ const n = Math.min(Math.max(base.toHexInt() + step, MIN_COLOR_INT), MAX_COLOR_INT);
62
+ const next = n === base.toHexInt() ? base : parseColor(`#${n.toString(16).padStart(6, "0")}`);
63
+ if (next === colorValue()) setInputValue(format(next));
64
+ safelySet(next);
65
+ validation.commitValidation();
66
+ };
67
+ return merge(validation, {
68
+ get colorValue() {
69
+ return colorValue();
70
+ },
71
+ commit() {
72
+ if (!inputValue().length) {
73
+ safelySet(null);
74
+ setInputValue(props.value === void 0 || colorValue() === null ? "" : format(colorValue()));
75
+ return;
76
+ }
77
+ const next = parsed();
78
+ if (next === null) {
79
+ setInputValue(format(colorValue()));
80
+ return;
81
+ }
82
+ safelySet(next);
83
+ setInputValue(format(props.value === void 0 ? next : colorValue()));
84
+ validation.commitValidation();
85
+ },
86
+ decrement() {
87
+ add(-1);
88
+ },
89
+ decrementToMin() {
90
+ safelySet(MIN_COLOR);
91
+ },
92
+ get defaultColorValue() {
93
+ return defaultValue() ?? initialValue;
94
+ },
95
+ increment() {
96
+ add(1);
97
+ },
98
+ incrementToMax() {
99
+ safelySet(MAX_COLOR);
100
+ },
101
+ get inputValue() {
102
+ return inputValue();
103
+ },
104
+ setColorValue,
105
+ setInputValue,
106
+ validate(v) {
107
+ return /^#?[0-9a-f]{0,6}$/iu.test(v);
108
+ }
109
+ });
110
+ }
111
+ export { createColorFieldState };
112
+
113
+ //# sourceMappingURL=create-color-field-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-color-field-state.js","names":[],"sources":["../../src/color/create-color-field-state.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorFieldState.ts.\n * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type {\n FocusableProps,\n HelpTextProps,\n InputBase,\n LabelableProps,\n TextInputBase,\n Validation,\n ValueBase,\n} from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n createSignal,\n createRenderEffect,\n merge,\n untrack,\n} from \"solid-js\";\n\nimport { createFormValidationState } from \"../form/create-form-validation-state\";\nimport type { FormValidationState } from \"../form/create-form-validation-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { parseColor } from \"./color\";\nimport { createColor } from \"./create-color\";\nimport type { Color } from \"./types\";\n\nexport interface ColorFieldProps\n extends\n Omit<ValueBase<string | Color | null>, \"onChange\">,\n InputBase,\n Validation<Color | null>,\n FocusableProps,\n TextInputBase,\n LabelableProps,\n HelpTextProps {\n /** Handler that is called when the value changes. */\n onChange?: (color: Color | null) => void;\n}\n\nexport interface ColorFieldState extends FormValidationState {\n /**\n * The current text value of the input. Updated as the user types,\n * and formatted according to `formatOptions` on blur.\n */\n readonly inputValue: string;\n /**\n * The currently parsed color value, or null if the field is empty.\n * Updated based on the `inputValue` as the user types.\n */\n readonly colorValue: Color | null;\n /** The default value of the color field. */\n readonly defaultColorValue: Color | null;\n /** Sets the color value of the field. */\n setColorValue: (value: Color | null) => void;\n /** Sets the current text value of the input. */\n setInputValue: (value: string) => void;\n /**\n * Updates the input value based on the currently parsed color value.\n * Typically this is called when the field is blurred.\n */\n commit: () => void;\n /** Increments the current input value to the next step boundary, and fires `onChange`. */\n increment: () => void;\n /** Decrements the current input value to the next step boundary, and fires `onChange`. */\n decrement: () => void;\n /** Sets the current value to the maximum color value, and fires `onChange`. */\n incrementToMax: () => void;\n /** Sets the current value to the minimum color value, and fires `onChange`. */\n decrementToMin: () => void;\n /**\n * Validates a user input string. Values can be partially entered, and may be valid even if they\n * cannot currently be parsed to a color. Can be used to implement validation as a user types.\n */\n validate: (value: string) => boolean;\n}\n\nconst MIN_COLOR = parseColor(\"#000000\");\nconst MAX_COLOR = parseColor(\"#FFFFFF\");\nconst MIN_COLOR_INT = MIN_COLOR.toHexInt();\nconst MAX_COLOR_INT = MAX_COLOR.toHexInt();\n\n/**\n * Provides state management for a color field component. Color fields allow\n * users to enter and adjust a hex color value.\n */\n\nconst format = (v: Color | null) => (v ? v.toString(\"hex\") : \"\");\n\nexport function createColorFieldState(props: ColorFieldProps): ColorFieldState {\n const value = createColor(() => props.value);\n const defaultValue = createColor(() => props.defaultValue);\n\n const [colorValue, setColorValue] = createControlledSignal(\n () => value() ?? (props.value === null ? null : undefined),\n untrack(defaultValue) ?? null,\n (v) => props.onChange?.(v)\n );\n\n const initialValue = untrack(colorValue);\n\n const [inputValue, setInputValue] = createSignal(\n untrack(() => format(colorValue())),\n { ownedWrite: true }\n );\n\n let previous = initialValue;\n createRenderEffect(colorValue, (v) => {\n if (previous !== v) {\n previous = v;\n setInputValue(format(v));\n }\n });\n\n const validation = createFormValidationState(\n merge(props, {\n get value() {\n return colorValue();\n },\n })\n );\n\n const parsed = createMemo(() => {\n try {\n const v = inputValue();\n\n return parseColor(v.startsWith(\"#\") ? v : `#${v}`);\n } catch {\n return null;\n }\n });\n\n const safelySet = (v: Color | null) => {\n if (!v || !colorValue() || v.toHexInt() !== colorValue()?.toHexInt()) {\n setColorValue(v);\n }\n };\n\n const add = (step: number) => {\n const base = parsed() ?? MIN_COLOR;\n\n const n = Math.min(\n Math.max(base.toHexInt() + step, MIN_COLOR_INT),\n MAX_COLOR_INT\n );\n\n const next =\n n === base.toHexInt()\n ? base\n : parseColor(`#${n.toString(16).padStart(6, \"0\")}`);\n\n if (next === colorValue()) {\n setInputValue(format(next));\n }\n\n safelySet(next);\n validation.commitValidation();\n };\n\n return merge(validation, {\n get colorValue() {\n return colorValue();\n },\n commit() {\n if (!inputValue().length) {\n safelySet(null);\n setInputValue(\n props.value === undefined || colorValue() === null\n ? \"\"\n : format(colorValue())\n );\n\n return;\n }\n\n const next = parsed();\n\n if (next === null) {\n setInputValue(format(colorValue()));\n\n return;\n }\n\n safelySet(next);\n setInputValue(format(props.value === undefined ? next : colorValue()));\n validation.commitValidation();\n },\n decrement() {\n add(-1);\n },\n decrementToMin() {\n safelySet(MIN_COLOR);\n },\n get defaultColorValue() {\n return defaultValue() ?? initialValue;\n },\n increment() {\n add(1);\n },\n incrementToMax() {\n safelySet(MAX_COLOR);\n },\n get inputValue() {\n return inputValue();\n },\n setColorValue,\n setInputValue,\n validate(v: string) {\n return /^#?[0-9a-f]{0,6}$/iu.test(v);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2FA,MAAM,YAAY,WAAW,SAAS;AACtC,MAAM,YAAY,WAAW,SAAS;AACtC,MAAM,gBAAgB,UAAU,SAAS;AACzC,MAAM,gBAAgB,UAAU,SAAS;;;;;AAOzC,MAAM,UAAU,MAAqB,IAAI,EAAE,SAAS,KAAK,IAAI;AAE7D,SAAgB,sBAAsB,OAAyC;CAC7E,MAAM,QAAQ,kBAAkB,MAAM,KAAK;CAC3C,MAAM,eAAe,kBAAkB,MAAM,YAAY;CAEzD,MAAM,CAAC,YAAY,iBAAiB,6BAC5B,MAAM,MAAM,MAAM,UAAU,OAAO,OAAO,KAAA,IAChD,QAAQ,YAAY,KAAK,OACxB,MAAM,MAAM,WAAW,CAAC,CAC3B;CAEA,MAAM,eAAe,QAAQ,UAAU;CAEvC,MAAM,CAAC,YAAY,iBAAiB,aAClC,cAAc,OAAO,WAAW,CAAC,CAAC,GAClC,EAAE,YAAY,KAAK,CACrB;CAEA,IAAI,WAAW;CACf,mBAAmB,aAAa,MAAM;EACpC,IAAI,aAAa,GAAG;GAClB,WAAW;GACX,cAAc,OAAO,CAAC,CAAC;EACzB;CACF,CAAC;CAED,MAAM,aAAa,0BACjB,MAAM,OAAO,EACX,IAAI,QAAQ;EACV,OAAO,WAAW;CACpB,EACF,CAAC,CACH;CAEA,MAAM,SAAS,iBAAiB;EAC9B,IAAI;GACF,MAAM,IAAI,WAAW;GAErB,OAAO,WAAW,EAAE,WAAW,GAAG,IAAI,IAAI,IAAI,GAAG;EACnD,QAAQ;GACN,OAAO;EACT;CACF,CAAC;CAED,MAAM,aAAa,MAAoB;EACrC,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,EAAE,SAAS,MAAM,WAAW,CAAC,EAAE,SAAS,GACjE,cAAc,CAAC;CAEnB;CAEA,MAAM,OAAO,SAAiB;EAC5B,MAAM,OAAO,OAAO,KAAK;EAEzB,MAAM,IAAI,KAAK,IACb,KAAK,IAAI,KAAK,SAAS,IAAI,MAAM,aAAa,GAC9C,aACF;EAEA,MAAM,OACJ,MAAM,KAAK,SAAS,IAChB,OACA,WAAW,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;EAEtD,IAAI,SAAS,WAAW,GACtB,cAAc,OAAO,IAAI,CAAC;EAG5B,UAAU,IAAI;EACd,WAAW,iBAAiB;CAC9B;CAEA,OAAO,MAAM,YAAY;EACvB,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA,SAAS;GACP,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ;IACxB,UAAU,IAAI;IACd,cACE,MAAM,UAAU,KAAA,KAAa,WAAW,MAAM,OAC1C,KACA,OAAO,WAAW,CAAC,CACzB;IAEA;GACF;GAEA,MAAM,OAAO,OAAO;GAEpB,IAAI,SAAS,MAAM;IACjB,cAAc,OAAO,WAAW,CAAC,CAAC;IAElC;GACF;GAEA,UAAU,IAAI;GACd,cAAc,OAAO,MAAM,UAAU,KAAA,IAAY,OAAO,WAAW,CAAC,CAAC;GACrE,WAAW,iBAAiB;EAC9B;EACA,YAAY;GACV,IAAI,EAAE;EACR;EACA,iBAAiB;GACf,UAAU,SAAS;EACrB;EACA,IAAI,oBAAoB;GACtB,OAAO,aAAa,KAAK;EAC3B;EACA,YAAY;GACV,IAAI,CAAC;EACP;EACA,iBAAiB;GACf,UAAU,SAAS;EACrB;EACA,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA;EACA;EACA,SAAS,GAAW;GAClB,OAAO,sBAAsB,KAAK,CAAC;EACrC;CACF,CAAC;AACH"}
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorPickerState.ts.
3
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
4
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
+ */
6
+ import { Color } from "./types.js";
7
+ import { ValueBase } from "@solid2-aria/types-shared";
8
+ export type ColorPickerProps = ValueBase<string | Color, Color>;
9
+ export interface ColorPickerState {
10
+ /** The current color value of the color picker. */
11
+ color: Color;
12
+ /** Sets the current color value of the color picker. */
13
+ setColor: (color: Color | null) => void;
14
+ }
15
+ export declare function createColorPickerState(props: ColorPickerProps): ColorPickerState;
16
+ //# sourceMappingURL=create-color-picker-state.d.ts.map
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorPickerState.ts.
3
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
4
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
+ */
6
+ import { createControlledSignal } from "../utils/create-controlled-signal.js";
7
+ import { parseColor } from "./color.js";
8
+ import { createColor } from "./create-color.js";
9
+ import { untrack } from "solid-js";
10
+ // src/color/create-color-picker-state.ts
11
+ function createColorPickerState(props) {
12
+ const value = createColor(() => props.value);
13
+ const defaultValue = createColor(() => props.defaultValue ?? "#000000");
14
+ const [color, setColor] = createControlledSignal(() => value() ?? void 0, untrack(defaultValue) ?? parseColor("#000000"), (v) => props.onChange?.(v));
15
+ return {
16
+ get color() {
17
+ return color();
18
+ },
19
+ setColor(v) {
20
+ if (v !== null) setColor(v);
21
+ }
22
+ };
23
+ }
24
+ export { createColorPickerState };
25
+
26
+ //# sourceMappingURL=create-color-picker-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-color-picker-state.js","names":[],"sources":["../../src/color/create-color-picker-state.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorPickerState.ts.\n * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { ValueBase } from \"@solid2-aria/types-shared\";\nimport { untrack } from \"solid-js\";\n\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { parseColor } from \"./color\";\nimport { createColor } from \"./create-color\";\nimport type { Color } from \"./types\";\n\nexport type ColorPickerProps = ValueBase<string | Color, Color>;\n\nexport interface ColorPickerState {\n /** The current color value of the color picker. */\n color: Color;\n /** Sets the current color value of the color picker. */\n setColor: (color: Color | null) => void;\n}\n\nexport function createColorPickerState(\n props: ColorPickerProps\n): ColorPickerState {\n const value = createColor(() => props.value);\n const defaultValue = createColor(() => props.defaultValue ?? \"#000000\");\n\n const [color, setColor] = createControlledSignal(\n () => value() ?? undefined,\n untrack(defaultValue) ?? parseColor(\"#000000\"),\n (v) => props.onChange?.(v)\n );\n\n return {\n get color() {\n return color();\n },\n setColor(v) {\n if (v !== null) {\n setColor(v);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,uBACd,OACkB;CAClB,MAAM,QAAQ,kBAAkB,MAAM,KAAK;CAC3C,MAAM,eAAe,kBAAkB,MAAM,gBAAgB,SAAS;CAEtE,MAAM,CAAC,OAAO,YAAY,6BAClB,MAAM,KAAK,KAAA,GACjB,QAAQ,YAAY,KAAK,WAAW,SAAS,IAC5C,MAAM,MAAM,WAAW,CAAC,CAC3B;CAEA,OAAO;EACL,IAAI,QAAQ;GACV,OAAO,MAAM;EACf;EACA,SAAS,GAAG;GACV,IAAI,MAAM,MACR,SAAS,CAAC;EAEd;CACF;AACF"}
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorSliderState.ts.
14
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { Color, ColorChannel, ColorSpace } from "./types.js";
18
+ import { SliderProps, SliderState } from "../slider/create-slider-state.js";
19
+ export interface ColorSliderProps extends Omit<SliderProps<string | Color>, "minValue" | "maxValue" | "step" | "pageSize" | "onChange" | "onChangeEnd"> {
20
+ /**
21
+ * The color space that the slider operates in. The `channel` must be in this color space.
22
+ * If not provided, this defaults to the color space of the `color` or `defaultColor` value.
23
+ */
24
+ colorSpace?: ColorSpace;
25
+ /** The color channel that the slider manipulates. */
26
+ channel: ColorChannel;
27
+ /** Handler that is called when the value changes, as the user drags. */
28
+ onChange?: (value: Color) => void;
29
+ /** Handler that is called when the user stops dragging. */
30
+ onChangeEnd?: (value: Color) => void;
31
+ }
32
+ export interface ColorSliderState extends SliderState {
33
+ /** The current color value represented by the color slider. */
34
+ readonly value: Color;
35
+ /** Sets the current color value. If a string is passed, it will be parsed to a Color. */
36
+ setValue: (value: string | Color) => void;
37
+ /**
38
+ * Returns the color that should be displayed in the slider instead of `value` or the optional
39
+ * parameter.
40
+ */
41
+ getDisplayColor: () => Color;
42
+ /** Whether the color slider is currently being dragged. */
43
+ readonly isDragging: boolean;
44
+ }
45
+ export interface ColorSliderStateOptions extends ColorSliderProps {
46
+ /** The locale to use for formatting the color channel value. */
47
+ locale: string;
48
+ }
49
+ export declare function createColorSliderState(props: ColorSliderStateOptions): ColorSliderState;
50
+ //# sourceMappingURL=create-color-slider-state.d.ts.map
@@ -0,0 +1,93 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorSliderState.ts.
14
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { createControlledSignal } from "../utils/create-controlled-signal.js";
18
+ import { normalizeColor, parseColor } from "./color.js";
19
+ import { createSliderState } from "../slider/create-slider-state.js";
20
+ import { createMemo, merge, untrack } from "solid-js";
21
+ // src/color/create-color-slider-state.ts
22
+ /**
23
+ * Provides state management for a color slider component.
24
+ * Color sliders allow users to adjust an individual channel of a color value.
25
+ */
26
+ const normalize = (v) => v !== void 0 && v !== "" ? normalizeColor(v) : void 0;
27
+ function createColorSliderState(props) {
28
+ const initial = untrack(() => normalize(props.defaultValue) ?? normalize(props.value));
29
+ if (!initial) throw new Error("createColorSliderState requires a value or defaultValue");
30
+ const controlledValue = createMemo(() => normalize(props.value));
31
+ const [colorValue, setColor] = createControlledSignal(controlledValue, initial, (v) => props.onChange?.(v));
32
+ const initialValue = untrack(colorValue);
33
+ const color = createMemo(() => props.colorSpace ? colorValue().toFormat(props.colorSpace) : colorValue());
34
+ const defaultColor = createMemo(() => {
35
+ const c = normalize(props.defaultValue) ?? initialValue;
36
+ return props.colorSpace ? c.toFormat(props.colorSpace) : c;
37
+ });
38
+ const numberFormatter = new Intl.NumberFormat();
39
+ const sliderState = createSliderState(merge(props, {
40
+ get defaultValue() {
41
+ return defaultColor().getChannelValue(props.channel);
42
+ },
43
+ get maxValue() {
44
+ return color().getChannelRange(props.channel).maxValue;
45
+ },
46
+ get minValue() {
47
+ return color().getChannelRange(props.channel).minValue;
48
+ },
49
+ numberFormatter,
50
+ onChange(v) {
51
+ if (typeof v === "number") setColor(color().withChannelValue(props.channel, v));
52
+ },
53
+ onChangeEnd(v) {
54
+ if (typeof v === "number") props.onChangeEnd?.(color().withChannelValue(props.channel, v));
55
+ },
56
+ get step() {
57
+ return color().getChannelRange(props.channel).step;
58
+ },
59
+ get value() {
60
+ return color().getChannelValue(props.channel);
61
+ }
62
+ }));
63
+ return merge(sliderState, {
64
+ getDisplayColor() {
65
+ if (props.channel === "hue") return parseColor(`hsl(${color().getChannelValue("hue")}, 100%, 50%)`);
66
+ return props.channel === "alpha" ? color() : color().withChannelValue("alpha", 1);
67
+ },
68
+ getFormattedValue() {
69
+ return color().formatChannelValue(props.channel, props.locale);
70
+ },
71
+ getThumbValueLabel() {
72
+ return color().formatChannelValue(props.channel, props.locale);
73
+ },
74
+ get isDragging() {
75
+ return sliderState.isThumbDragging(0);
76
+ },
77
+ get pageSize() {
78
+ return color().getChannelRange(props.channel).pageSize;
79
+ },
80
+ setValue(v) {
81
+ setColor(normalizeColor(v));
82
+ },
83
+ get step() {
84
+ return color().getChannelRange(props.channel).step;
85
+ },
86
+ get value() {
87
+ return color();
88
+ }
89
+ });
90
+ }
91
+ export { createColorSliderState };
92
+
93
+ //# sourceMappingURL=create-color-slider-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-color-slider-state.js","names":[],"sources":["../../src/color/create-color-slider-state.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorSliderState.ts.\n * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { createMemo, merge, untrack } from \"solid-js\";\n\nimport { createSliderState } from \"../slider/create-slider-state\";\nimport type { SliderProps, SliderState } from \"../slider/create-slider-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { normalizeColor, parseColor } from \"./color\";\nimport type { Color, ColorChannel, ColorSpace } from \"./types\";\n\nexport interface ColorSliderProps extends Omit<\n SliderProps<string | Color>,\n \"minValue\" | \"maxValue\" | \"step\" | \"pageSize\" | \"onChange\" | \"onChangeEnd\"\n> {\n /**\n * The color space that the slider operates in. The `channel` must be in this color space.\n * If not provided, this defaults to the color space of the `color` or `defaultColor` value.\n */\n colorSpace?: ColorSpace;\n /** The color channel that the slider manipulates. */\n channel: ColorChannel;\n /** Handler that is called when the value changes, as the user drags. */\n onChange?: (value: Color) => void;\n /** Handler that is called when the user stops dragging. */\n onChangeEnd?: (value: Color) => void;\n}\n\nexport interface ColorSliderState extends SliderState {\n /** The current color value represented by the color slider. */\n readonly value: Color;\n /** Sets the current color value. If a string is passed, it will be parsed to a Color. */\n setValue: (value: string | Color) => void;\n /**\n * Returns the color that should be displayed in the slider instead of `value` or the optional\n * parameter.\n */\n getDisplayColor: () => Color;\n /** Whether the color slider is currently being dragged. */\n readonly isDragging: boolean;\n}\n\nexport interface ColorSliderStateOptions extends ColorSliderProps {\n /** The locale to use for formatting the color channel value. */\n locale: string;\n}\n\n/**\n * Provides state management for a color slider component.\n * Color sliders allow users to adjust an individual channel of a color value.\n */\n\nconst normalize = (v: string | Color | undefined) =>\n v !== undefined && v !== \"\" ? normalizeColor(v) : undefined;\n\nexport function createColorSliderState(\n props: ColorSliderStateOptions\n): ColorSliderState {\n const initial = untrack(\n () => normalize(props.defaultValue) ?? normalize(props.value)\n );\n\n if (!initial) {\n throw new Error(\"createColorSliderState requires a value or defaultValue\");\n }\n\n const controlledValue = createMemo(() => normalize(props.value));\n\n const [colorValue, setColor] = createControlledSignal(\n controlledValue,\n initial,\n (v) => props.onChange?.(v)\n );\n\n const initialValue = untrack(colorValue);\n\n const color = createMemo(() =>\n props.colorSpace ? colorValue().toFormat(props.colorSpace) : colorValue()\n );\n\n const defaultColor = createMemo(() => {\n const c = normalize(props.defaultValue) ?? initialValue;\n\n return props.colorSpace ? c.toFormat(props.colorSpace) : c;\n });\n\n const numberFormatter = new Intl.NumberFormat();\n\n const sliderState = createSliderState(\n merge(props, {\n get defaultValue() {\n return defaultColor().getChannelValue(props.channel);\n },\n get maxValue() {\n return color().getChannelRange(props.channel).maxValue;\n },\n get minValue() {\n return color().getChannelRange(props.channel).minValue;\n },\n numberFormatter,\n onChange(v: number | number[]) {\n if (typeof v === \"number\") {\n setColor(color().withChannelValue(props.channel, v));\n }\n },\n onChangeEnd(v: number | number[]) {\n if (typeof v === \"number\") {\n props.onChangeEnd?.(color().withChannelValue(props.channel, v));\n }\n },\n get step() {\n return color().getChannelRange(props.channel).step;\n },\n get value() {\n return color().getChannelValue(props.channel);\n },\n })\n );\n\n return merge(sliderState, {\n getDisplayColor() {\n if (props.channel === \"hue\") {\n return parseColor(`hsl(${color().getChannelValue(\"hue\")}, 100%, 50%)`);\n }\n\n return props.channel === \"alpha\"\n ? color()\n : color().withChannelValue(\"alpha\", 1);\n },\n getFormattedValue() {\n return color().formatChannelValue(props.channel, props.locale);\n },\n getThumbValueLabel() {\n return color().formatChannelValue(props.channel, props.locale);\n },\n get isDragging() {\n return sliderState.isThumbDragging(0);\n },\n get pageSize() {\n return color().getChannelRange(props.channel).pageSize;\n },\n setValue(v: string | Color) {\n setColor(normalizeColor(v));\n },\n get step() {\n return color().getChannelRange(props.channel).step;\n },\n get value() {\n return color();\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAM,aAAa,MACjB,MAAM,KAAA,KAAa,MAAM,KAAK,eAAe,CAAC,IAAI,KAAA;AAEpD,SAAgB,uBACd,OACkB;CAClB,MAAM,UAAU,cACR,UAAU,MAAM,YAAY,KAAK,UAAU,MAAM,KAAK,CAC9D;CAEA,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,yDAAyD;CAG3E,MAAM,kBAAkB,iBAAiB,UAAU,MAAM,KAAK,CAAC;CAE/D,MAAM,CAAC,YAAY,YAAY,uBAC7B,iBACA,UACC,MAAM,MAAM,WAAW,CAAC,CAC3B;CAEA,MAAM,eAAe,QAAQ,UAAU;CAEvC,MAAM,QAAQ,iBACZ,MAAM,aAAa,WAAW,CAAC,CAAC,SAAS,MAAM,UAAU,IAAI,WAAW,CAC1E;CAEA,MAAM,eAAe,iBAAiB;EACpC,MAAM,IAAI,UAAU,MAAM,YAAY,KAAK;EAE3C,OAAO,MAAM,aAAa,EAAE,SAAS,MAAM,UAAU,IAAI;CAC3D,CAAC;CAED,MAAM,kBAAkB,IAAI,KAAK,aAAa;CAE9C,MAAM,cAAc,kBAClB,MAAM,OAAO;EACX,IAAI,eAAe;GACjB,OAAO,aAAa,CAAC,CAAC,gBAAgB,MAAM,OAAO;EACrD;EACA,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,CAAC,CAAC;EAChD;EACA,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,CAAC,CAAC;EAChD;EACA;EACA,SAAS,GAAsB;GAC7B,IAAI,OAAO,MAAM,UACf,SAAS,MAAM,CAAC,CAAC,iBAAiB,MAAM,SAAS,CAAC,CAAC;EAEvD;EACA,YAAY,GAAsB;GAChC,IAAI,OAAO,MAAM,UACf,MAAM,cAAc,MAAM,CAAC,CAAC,iBAAiB,MAAM,SAAS,CAAC,CAAC;EAElE;EACA,IAAI,OAAO;GACT,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,CAAC,CAAC;EAChD;EACA,IAAI,QAAQ;GACV,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO;EAC9C;CACF,CAAC,CACH;CAEA,OAAO,MAAM,aAAa;EACxB,kBAAkB;GAChB,IAAI,MAAM,YAAY,OACpB,OAAO,WAAW,OAAO,MAAM,CAAC,CAAC,gBAAgB,KAAK,EAAE,aAAa;GAGvE,OAAO,MAAM,YAAY,UACrB,MAAM,IACN,MAAM,CAAC,CAAC,iBAAiB,SAAS,CAAC;EACzC;EACA,oBAAoB;GAClB,OAAO,MAAM,CAAC,CAAC,mBAAmB,MAAM,SAAS,MAAM,MAAM;EAC/D;EACA,qBAAqB;GACnB,OAAO,MAAM,CAAC,CAAC,mBAAmB,MAAM,SAAS,MAAM,MAAM;EAC/D;EACA,IAAI,aAAa;GACf,OAAO,YAAY,gBAAgB,CAAC;EACtC;EACA,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,CAAC,CAAC;EAChD;EACA,SAAS,GAAmB;GAC1B,SAAS,eAAe,CAAC,CAAC;EAC5B;EACA,IAAI,OAAO;GACT,OAAO,MAAM,CAAC,CAAC,gBAAgB,MAAM,OAAO,CAAC,CAAC;EAChD;EACA,IAAI,QAAQ;GACV,OAAO,MAAM;EACf;CACF,CAAC;AACH"}
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/color/useColorWheelState.ts.
14
+ * Modified for Solid Aria: adapted reactive state and public APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { Color } from "./types.js";
18
+ import { ValueBase } from "@solid2-aria/types-shared";
19
+ export interface ColorWheelProps extends Omit<ValueBase<string | Color>, "onChange"> {
20
+ /** Whether the ColorWheel is disabled. */
21
+ isDisabled?: boolean;
22
+ /** Handler that is called when the value changes, as the user drags. */
23
+ onChange?: (value: Color) => void;
24
+ /** Handler that is called when the user stops dragging. */
25
+ onChangeEnd?: (value: Color) => void;
26
+ /**
27
+ * The default value (uncontrolled).
28
+ *
29
+ * @default 'hsl(0, 100%, 50%)'
30
+ */
31
+ defaultValue?: string | Color;
32
+ }
33
+ export interface ColorWheelState {
34
+ /** The current color value represented by the color wheel. */
35
+ readonly value: Color;
36
+ /** The default color value. */
37
+ readonly defaultValue: Color;
38
+ /** Sets the color value represented by the color wheel, and triggers `onChange`. */
39
+ setValue: (value: string | Color) => void;
40
+ /** The current value of the hue channel displayed by the color wheel. */
41
+ readonly hue: number;
42
+ /** Sets the hue channel of the current color value and triggers `onChange`. */
43
+ setHue: (value: number) => void;
44
+ /**
45
+ * Sets the hue channel of the current color value based on the given coordinates and radius of
46
+ * the color wheel, and triggers `onChange`.
47
+ */
48
+ setHueFromPoint: (x: number, y: number, radius: number) => void;
49
+ /** Returns the coordinates of the thumb relative to the center point of the color wheel. */
50
+ getThumbPosition: (radius: number) => {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ /** Increments the hue by the given amount (defaults to 1). */
55
+ increment: (stepSize?: number) => void;
56
+ /** Decrements the hue by the given amount (defaults to 1). */
57
+ decrement: (stepSize?: number) => void;
58
+ /** Whether the color wheel is currently being dragged. */
59
+ readonly isDragging: boolean;
60
+ /** Sets whether the color wheel is being dragged. */
61
+ setDragging: (value: boolean) => void;
62
+ /** Returns the color that should be displayed in the color wheel instead of `value`. */
63
+ getDisplayColor: () => Color;
64
+ /** The step value of the hue channel, used when incrementing and decrementing. */
65
+ step: number;
66
+ /** The page step value of the hue channel, used when incrementing and decrementing. */
67
+ pageStep: number;
68
+ /** Whether the color wheel is disabled. */
69
+ readonly isDisabled: boolean;
70
+ }
71
+ /**
72
+ * Provides state management for a color wheel component.
73
+ * Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.
74
+ */
75
+ export declare function createColorWheelState(props: ColorWheelProps): ColorWheelState;
76
+ //# sourceMappingURL=create-color-wheel-state.d.ts.map