@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,191 @@
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/datepicker/useDatePickerState.ts.
14
+ * Modified for Solid Aria: adapted reactive state, getters, imports, and 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 { getLegacyValidationState } from "../utils/legacy-props.js";
19
+ import { createFormValidationState } from "../form/create-form-validation-state.js";
20
+ import { createOverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
21
+ import { createDefaultProps, getFormatOptions, getPlaceholderTime, getValidationResult } from "./utils.js";
22
+ import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
23
+ import { DateFormatter, toCalendarDate, toCalendarDateTime } from "@internationalized/date";
24
+ // src/datepicker/create-date-picker-state.ts
25
+ /**
26
+ * Provides state management for a date picker component. A date picker combines a DateField and a
27
+ * Calendar popover to allow users to enter or select a date and time value.
28
+ */
29
+ function createDatePickerState(props) {
30
+ const overlayState = createOverlayTriggerState(props);
31
+ const [value, setValue] = createControlledSignal(() => props.value, untrack(() => props.defaultValue ?? null), (localValue) => props.onChange?.(localValue));
32
+ const initialValue = untrack(() => value());
33
+ const v = createMemo(() => {
34
+ return value() ?? props.placeholderValue ?? null;
35
+ });
36
+ const derived0 = createDefaultProps(v, () => props.granularity);
37
+ const granularity = createMemo(() => {
38
+ const [currentGranularity] = derived0();
39
+ const currentValue = v();
40
+ if (currentValue && !(currentGranularity in currentValue)) throw new Error(`Invalid granularity ${currentGranularity} for value ${currentValue.toString()}`);
41
+ return currentGranularity;
42
+ });
43
+ const defaultTimeZone = createMemo(() => {
44
+ return derived0()[1];
45
+ });
46
+ const dateValue = createMemo(() => {
47
+ const currentValue = value();
48
+ const currentDefaultTimeZone = defaultTimeZone();
49
+ return currentValue === null || currentValue === void 0 ? null : currentValue.toDate(currentDefaultTimeZone ?? "UTC");
50
+ });
51
+ const hasTime = createMemo(() => {
52
+ const currentGranularity = granularity();
53
+ return currentGranularity === "hour" || currentGranularity === "minute" || currentGranularity === "second";
54
+ });
55
+ const shouldCloseOnSelect = createMemo(() => props.shouldCloseOnSelect ?? true);
56
+ const [selectedDate, setSelectedDate] = createSignal(null, { ownedWrite: true });
57
+ const [selectedTime, setSelectedTime] = createSignal(null, { ownedWrite: true });
58
+ createRenderEffect(value, (currentValue) => {
59
+ if (currentValue) {
60
+ setSelectedDate(currentValue);
61
+ if ("hour" in currentValue) setSelectedTime(currentValue);
62
+ }
63
+ });
64
+ const showEra = createMemo(() => {
65
+ const currentValue = value();
66
+ return currentValue?.calendar.identifier === "gregory" && currentValue.era === "BC";
67
+ });
68
+ const formatOpts = createMemo(() => {
69
+ const currentGranularity = granularity();
70
+ const currentDefaultTimeZone = defaultTimeZone();
71
+ const currentShowEra = showEra();
72
+ return {
73
+ granularity: currentGranularity,
74
+ hideTimeZone: props.hideTimeZone,
75
+ hourCycle: props.hourCycle,
76
+ shouldForceLeadingZeros: props.shouldForceLeadingZeros,
77
+ showEra: currentShowEra,
78
+ timeZone: currentDefaultTimeZone
79
+ };
80
+ });
81
+ const minValue = createMemo(() => props.minValue);
82
+ const maxValue = createMemo(() => props.maxValue);
83
+ const isDateUnavailable = createMemo(() => props.isDateUnavailable);
84
+ const builtinValidation = createMemo(() => {
85
+ const currentValue = value();
86
+ const currentMinValue = minValue();
87
+ const currentMaxValue = maxValue();
88
+ const currentIsDateUnavailable = isDateUnavailable();
89
+ const currentFormatOpts = formatOpts();
90
+ return getValidationResult(currentValue, currentMinValue, currentMaxValue, currentIsDateUnavailable, currentFormatOpts);
91
+ });
92
+ const validation = createFormValidationState(merge(props, {
93
+ get builtinValidation() {
94
+ return builtinValidation();
95
+ },
96
+ validate: (localValue) => props.validate?.(localValue),
97
+ get value() {
98
+ return value();
99
+ }
100
+ }));
101
+ const isValueInvalid = createMemo(() => validation.displayValidation.isInvalid);
102
+ const validationState = createMemo(() => {
103
+ const currentIsValueInvalid = isValueInvalid();
104
+ return getLegacyValidationState(props) ?? (currentIsValueInvalid ? "invalid" : null);
105
+ });
106
+ const commitValue = (date, time) => {
107
+ setValue("timeZone" in time ? time.set(toCalendarDate(date)) : toCalendarDateTime(date, time));
108
+ setSelectedDate(null);
109
+ setSelectedTime(null);
110
+ validation.commitValidation();
111
+ };
112
+ const selectDate = (newValue) => {
113
+ const currentShouldCloseOnSelect = shouldCloseOnSelect();
114
+ const currentHasTime = hasTime();
115
+ const currentSelectedTime = selectedTime();
116
+ const shouldClose = typeof currentShouldCloseOnSelect === "function" ? currentShouldCloseOnSelect() : currentShouldCloseOnSelect;
117
+ if (currentHasTime) {
118
+ if (currentSelectedTime || shouldClose) commitValue(newValue, currentSelectedTime ?? getPlaceholderTime(props.defaultValue ?? props.placeholderValue));
119
+ else setSelectedDate(newValue);
120
+ } else {
121
+ setValue(newValue);
122
+ validation.commitValidation();
123
+ }
124
+ if (shouldClose) overlayState.setOpen(false);
125
+ };
126
+ const selectTime = (newValue) => {
127
+ const currentSelectedDate = selectedDate();
128
+ if (currentSelectedDate && Boolean(newValue)) commitValue(currentSelectedDate, newValue);
129
+ else setSelectedTime(newValue);
130
+ };
131
+ return merge(validation, {
132
+ get dateValue() {
133
+ return selectedDate();
134
+ },
135
+ get defaultValue() {
136
+ return props.defaultValue ?? initialValue;
137
+ },
138
+ get granularity() {
139
+ return granularity();
140
+ },
141
+ get hasTime() {
142
+ return hasTime();
143
+ },
144
+ get setDateValue() {
145
+ return selectDate;
146
+ },
147
+ get setTimeValue() {
148
+ return selectTime;
149
+ },
150
+ setValue,
151
+ get timeValue() {
152
+ return selectedTime();
153
+ },
154
+ get value() {
155
+ return value();
156
+ }
157
+ }, overlayState, {
158
+ formatValue(locale, fieldOptions) {
159
+ const currentDateValue = dateValue();
160
+ const currentFormatOpts = formatOpts();
161
+ if (!currentDateValue) return "";
162
+ const formatOptions = getFormatOptions(fieldOptions, currentFormatOpts);
163
+ return new DateFormatter(locale, formatOptions).format(currentDateValue);
164
+ },
165
+ getDateFormatter(locale, formatOptions) {
166
+ const newOptions = {
167
+ ...formatOpts(),
168
+ ...formatOptions
169
+ };
170
+ const newFormatOptions = getFormatOptions({}, newOptions);
171
+ return new DateFormatter(locale, newFormatOptions);
172
+ },
173
+ get isInvalid() {
174
+ return isValueInvalid();
175
+ },
176
+ setOpen(isOpen) {
177
+ const currentValue = value();
178
+ const currentSelectedDate = selectedDate();
179
+ const currentHasTime = hasTime();
180
+ const currentSelectedTime = selectedTime();
181
+ if (!isOpen && !currentValue && currentSelectedDate && currentHasTime) commitValue(currentSelectedDate, currentSelectedTime ?? getPlaceholderTime(props.defaultValue ?? props.placeholderValue));
182
+ overlayState.setOpen(isOpen);
183
+ },
184
+ get validationState() {
185
+ return validationState();
186
+ }
187
+ });
188
+ }
189
+ export { createDatePickerState };
190
+
191
+ //# sourceMappingURL=create-date-picker-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-date-picker-state.js","names":[],"sources":["../../src/datepicker/create-date-picker-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/datepicker/useDatePickerState.ts.\n * Modified for Solid Aria: adapted reactive state, getters, imports, and 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 {\n DateFormatter,\n toCalendarDate,\n toCalendarDateTime,\n} from \"@internationalized/date\";\nimport type { ValidationState } from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n createSignal,\n createRenderEffect,\n untrack,\n merge,\n} from \"solid-js\";\n\nimport { createFormValidationState } from \"../form/create-form-validation-state\";\nimport type { FormValidationState } from \"../form/create-form-validation-state\";\nimport { createOverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport type { OverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { getLegacyValidationState } from \"../utils/legacy-props\";\nimport type {\n DatePickerProps,\n DateValue,\n Granularity,\n MappedDateValue,\n TimeValue,\n} from \"./types\";\nimport {\n getFormatOptions,\n getPlaceholderTime,\n getValidationResult,\n createDefaultProps,\n} from \"./utils\";\nimport type { FieldOptions, FormatterOptions } from \"./utils\";\n\nexport interface DatePickerStateOptions<\n T extends DateValue,\n> extends DatePickerProps<T> {\n /**\n * Determines whether the date picker popover should close automatically when a date is selected.\n *\n * @default true\n */\n shouldCloseOnSelect?: boolean | (() => boolean);\n}\n\nexport interface DatePickerState\n extends OverlayTriggerState, FormValidationState {\n /** The currently selected date. */\n value: DateValue | null;\n /** The default date. */\n defaultValue: DateValue | null;\n /** Sets the selected date. */\n setValue: (value: DateValue | null) => void;\n /**\n * The date portion of the value. This may be set prior to `value` if the user has\n * selected a date but has not yet selected a time.\n */\n dateValue: DateValue | null;\n /** Sets the date portion of the value. */\n setDateValue: (value: DateValue) => void;\n /**\n * The time portion of the value. This may be set prior to `value` if the user has\n * selected a time but has not yet selected a date.\n */\n timeValue: TimeValue | null;\n /** Sets the time portion of the value. */\n setTimeValue: (value: TimeValue) => void;\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity;\n /**\n * Whether the date picker supports selecting a time, according to the `granularity` prop and\n * current value.\n */\n hasTime: boolean;\n /** Whether the calendar popover is currently open. */\n isOpen: boolean;\n /** Sets whether the calendar popover is open. */\n setOpen: (isOpen: boolean) => void;\n /**\n * The current validation state of the date picker, based on the `validationState`, `minValue`,\n * and `maxValue` props.\n *\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null;\n /** Whether the date picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue` props. */\n isInvalid: boolean;\n /** Formats the selected value using the given options. */\n formatValue: (locale: string, fieldOptions: FieldOptions) => string;\n /** Gets a formatter based on state's props. */\n getDateFormatter: (\n locale: string,\n formatOptions: FormatterOptions\n ) => DateFormatter;\n}\n\n/**\n * Provides state management for a date picker component. A date picker combines a DateField and a\n * Calendar popover to allow users to enter or select a date and time value.\n */\nexport function createDatePickerState<T extends DateValue = DateValue>(\n props: DatePickerStateOptions<T>\n): DatePickerState {\n const overlayState = createOverlayTriggerState(props);\n\n const [value, setValue] = createControlledSignal<DateValue | null>(\n () => props.value,\n untrack(() => props.defaultValue ?? null),\n // SAFETY: Date edits preserve the input date/time class; the mapped generic callback widens subclasses to that class.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n (localValue) => props.onChange?.(localValue as MappedDateValue<T> | null)\n );\n\n const initialValue = untrack(() => value());\n\n const v = createMemo(() => {\n const currentValue = value();\n\n return currentValue ?? props.placeholderValue ?? null;\n });\n\n const derived0 = createDefaultProps(v, () => props.granularity);\n\n const granularity = createMemo(() => {\n const [currentGranularity] = derived0();\n const currentValue = v();\n\n if (currentValue && !(currentGranularity in currentValue)) {\n throw new Error(\n `Invalid granularity ${currentGranularity} for value ${currentValue.toString()}`\n );\n }\n\n return currentGranularity;\n });\n\n const defaultTimeZone = createMemo(() => {\n const currentDerived0 = derived0();\n\n return currentDerived0[1];\n });\n\n const dateValue = createMemo(() => {\n const currentValue = value();\n const currentDefaultTimeZone = defaultTimeZone();\n\n return currentValue === null || currentValue === undefined\n ? null\n : currentValue.toDate(currentDefaultTimeZone ?? \"UTC\");\n });\n\n const hasTime = createMemo(() => {\n const currentGranularity = granularity();\n\n return (\n currentGranularity === \"hour\" ||\n currentGranularity === \"minute\" ||\n currentGranularity === \"second\"\n );\n });\n\n const shouldCloseOnSelect = createMemo(\n () => props.shouldCloseOnSelect ?? true\n );\n\n const [selectedDate, setSelectedDate] = createSignal<DateValue | null>(null, {\n ownedWrite: true,\n });\n\n const [selectedTime, setSelectedTime] = createSignal<TimeValue | null>(null, {\n ownedWrite: true,\n });\n\n createRenderEffect(value, (currentValue) => {\n if (currentValue) {\n setSelectedDate(currentValue);\n\n if (\"hour\" in currentValue) {\n setSelectedTime(currentValue);\n }\n }\n });\n\n const showEra = createMemo(() => {\n const currentValue = value();\n\n return (\n currentValue?.calendar.identifier === \"gregory\" &&\n currentValue.era === \"BC\"\n );\n });\n\n const formatOpts = createMemo(() => {\n const currentGranularity = granularity();\n const currentDefaultTimeZone = defaultTimeZone();\n const currentShowEra = showEra();\n\n return {\n granularity: currentGranularity,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n showEra: currentShowEra,\n timeZone: currentDefaultTimeZone,\n };\n });\n\n const minValue = createMemo(() => props.minValue);\n const maxValue = createMemo(() => props.maxValue);\n const isDateUnavailable = createMemo(() => props.isDateUnavailable);\n\n const builtinValidation = createMemo(() => {\n const currentValue = value();\n const currentMinValue = minValue();\n const currentMaxValue = maxValue();\n const currentIsDateUnavailable = isDateUnavailable();\n const currentFormatOpts = formatOpts();\n\n return getValidationResult(\n currentValue,\n currentMinValue,\n currentMaxValue,\n currentIsDateUnavailable,\n currentFormatOpts\n );\n });\n\n const validation = createFormValidationState<DateValue>(\n merge(props, {\n get builtinValidation() {\n return builtinValidation();\n },\n validate: (localValue: DateValue) =>\n // SAFETY: Date edits preserve the input date/time class; the mapped generic callback widens subclasses to that class.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n props.validate?.(localValue as MappedDateValue<T>),\n get value() {\n return value();\n },\n })\n );\n\n const isValueInvalid = createMemo(\n () => validation.displayValidation.isInvalid\n );\n\n const validationState = createMemo(() => {\n const currentIsValueInvalid = isValueInvalid();\n\n return (\n getLegacyValidationState(props) ??\n (currentIsValueInvalid ? \"invalid\" : null)\n );\n });\n\n const commitValue = (date: DateValue, time: TimeValue) => {\n setValue(\n \"timeZone\" in time\n ? time.set(toCalendarDate(date))\n : toCalendarDateTime(date, time)\n );\n setSelectedDate(null);\n setSelectedTime(null);\n validation.commitValidation();\n };\n\n // Intercept setValue to make sure the Time section is not changed by date selection in Calendar\n const selectDate = (newValue: DateValue) => {\n const currentShouldCloseOnSelect = shouldCloseOnSelect();\n const currentHasTime = hasTime();\n const currentSelectedTime = selectedTime();\n\n const shouldClose =\n typeof currentShouldCloseOnSelect === \"function\"\n ? currentShouldCloseOnSelect()\n : currentShouldCloseOnSelect;\n\n if (currentHasTime) {\n if (currentSelectedTime || shouldClose) {\n commitValue(\n newValue,\n currentSelectedTime ??\n getPlaceholderTime(props.defaultValue ?? props.placeholderValue)\n );\n } else {\n setSelectedDate(newValue);\n }\n } else {\n setValue(newValue);\n validation.commitValidation();\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n const selectTime = (newValue: TimeValue) => {\n const currentSelectedDate = selectedDate();\n\n if (currentSelectedDate && Boolean(newValue)) {\n commitValue(currentSelectedDate, newValue);\n } else {\n setSelectedTime(newValue);\n }\n };\n\n return merge(\n validation,\n {\n get dateValue() {\n return selectedDate();\n },\n get defaultValue() {\n return props.defaultValue ?? initialValue;\n },\n get granularity() {\n return granularity();\n },\n get hasTime() {\n return hasTime();\n },\n get setDateValue() {\n return selectDate;\n },\n get setTimeValue() {\n return selectTime;\n },\n setValue,\n get timeValue() {\n return selectedTime();\n },\n get value() {\n return value();\n },\n } satisfies Partial<DatePickerState>,\n overlayState,\n {\n formatValue(locale, fieldOptions) {\n const currentDateValue = dateValue();\n const currentFormatOpts = formatOpts();\n\n if (!currentDateValue) {\n return \"\";\n }\n\n const formatOptions = getFormatOptions(fieldOptions, currentFormatOpts);\n const formatter = new DateFormatter(locale, formatOptions);\n\n return formatter.format(currentDateValue);\n },\n getDateFormatter(locale, formatOptions: FormatterOptions) {\n const currentFormatOpts = formatOpts();\n const newOptions = { ...currentFormatOpts, ...formatOptions };\n const newFormatOptions = getFormatOptions({}, newOptions);\n\n return new DateFormatter(locale, newFormatOptions);\n },\n get isInvalid() {\n return isValueInvalid();\n },\n setOpen(isOpen) {\n const currentValue = value();\n const currentSelectedDate = selectedDate();\n const currentHasTime = hasTime();\n const currentSelectedTime = selectedTime();\n\n // Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time was set and not the date, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (!isOpen && !currentValue && currentSelectedDate && currentHasTime) {\n commitValue(\n currentSelectedDate,\n currentSelectedTime ??\n getPlaceholderTime(props.defaultValue ?? props.placeholderValue)\n );\n }\n\n overlayState.setOpen(isOpen);\n },\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get validationState() {\n return validationState();\n },\n } satisfies Partial<DatePickerState>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,97 @@
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/datepicker/useDateRangePickerState.ts.
14
+ * Modified for Solid Aria: adapted reactive state, getters, imports, and 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 { OverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
19
+ import { DateRange, DateRangePickerProps, DateValue, Granularity, TimeValue } from "./types.js";
20
+ import { FieldOptions, FormatterOptions } from "./utils.js";
21
+ import { DateFormatter } from "@internationalized/date";
22
+ import { RangeValue, ValidationState } from "@solid2-aria/types-shared";
23
+ export interface DateRangePickerStateOptions<T extends DateValue = DateValue> extends DateRangePickerProps<T> {
24
+ /**
25
+ * Determines whether the date picker popover should close automatically when a date is selected.
26
+ *
27
+ * @default true
28
+ */
29
+ shouldCloseOnSelect?: boolean | (() => boolean);
30
+ }
31
+ type TimeRange = RangeValue<TimeValue>;
32
+ export interface DateRangePickerState extends OverlayTriggerState, FormValidationState {
33
+ /** The currently selected date range. */
34
+ value: RangeValue<DateValue | null>;
35
+ /** The default selected date range. */
36
+ defaultValue: DateRange | null;
37
+ /** Sets the selected date range. */
38
+ setValue: (value: DateRange | null) => void;
39
+ /**
40
+ * The date portion of the selected range. This may be set prior to `value` if the user has
41
+ * selected a date range but has not yet selected a time range.
42
+ */
43
+ dateRange: RangeValue<DateValue | null> | null;
44
+ /** Sets the date portion of the selected range. */
45
+ setDateRange: (value: DateRange) => void;
46
+ /**
47
+ * The time portion of the selected range. This may be set prior to `value` if the user has
48
+ * selected a time range but has not yet selected a date range.
49
+ */
50
+ timeRange: RangeValue<TimeValue | null> | null;
51
+ /** Sets the time portion of the selected range. */
52
+ setTimeRange: (value: TimeRange) => void;
53
+ /** Sets the date portion of either the start or end of the selected range. */
54
+ setDate: (part: "start" | "end", value: DateValue | null) => void;
55
+ /** Sets the time portion of either the start or end of the selected range. */
56
+ setTime: (part: "start" | "end", value: TimeValue | null) => void;
57
+ /** Sets the date and time of either the start or end of the selected range. */
58
+ setDateTime: (part: "start" | "end", value: DateValue | null) => void;
59
+ /** The granularity for the field, based on the `granularity` prop and current value. */
60
+ granularity: Granularity;
61
+ /**
62
+ * Whether the date range picker supports selecting times, according to the `granularity` prop and
63
+ * current value.
64
+ */
65
+ hasTime: boolean;
66
+ /** Whether the calendar popover is currently open. */
67
+ isOpen: boolean;
68
+ /** Sets whether the calendar popover is open. */
69
+ setOpen: (isOpen: boolean) => void;
70
+ /**
71
+ * The current validation state of the date range picker, based on the `validationState`,
72
+ * `minValue`, and `maxValue` props.
73
+ *
74
+ * @deprecated Use `isInvalid` instead.
75
+ */
76
+ validationState: ValidationState | null;
77
+ /**
78
+ * Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue`
79
+ * props.
80
+ */
81
+ isInvalid: boolean;
82
+ /** Formats the selected range using the given options. */
83
+ formatValue: (locale: string, fieldOptions: FieldOptions) => {
84
+ start: string;
85
+ end: string;
86
+ } | null;
87
+ /** Gets a formatter based on state's props. */
88
+ getDateFormatter: (locale: string, formatOptions: FormatterOptions) => DateFormatter;
89
+ }
90
+ /**
91
+ * Provides state management for a date range picker component.
92
+ * A date range picker combines two DateFields and a RangeCalendar popover to allow
93
+ * users to enter or select a date and time range.
94
+ */
95
+ export declare function createDateRangePickerState<T extends DateValue = DateValue>(props: DateRangePickerStateOptions<T>): DateRangePickerState;
96
+ export {};
97
+ //# sourceMappingURL=create-date-range-picker-state.d.ts.map
@@ -0,0 +1,305 @@
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/datepicker/useDateRangePickerState.ts.
14
+ * Modified for Solid Aria: adapted reactive state, getters, imports, and 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 { getLegacyValidationState } from "../utils/legacy-props.js";
19
+ import { createFormValidationState } from "../form/create-form-validation-state.js";
20
+ import { createOverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
21
+ import { createDefaultProps, getFormatOptions, getPlaceholderTime, getRangeValidationResult } from "./utils.js";
22
+ import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
23
+ import { DateFormatter, toCalendarDate, toCalendarDateTime } from "@internationalized/date";
24
+ // src/datepicker/create-date-range-picker-state.ts
25
+ /**
26
+ * Provides state management for a date range picker component.
27
+ * A date range picker combines two DateFields and a RangeCalendar popover to allow
28
+ * users to enter or select a date and time range.
29
+ */
30
+ function createDateRangePickerState(props) {
31
+ const overlayState = createOverlayTriggerState(props);
32
+ const [controlledValue, setControlledValue] = createControlledSignal(() => props.value, untrack(() => props.defaultValue ?? null), (value) => props.onChange?.(value));
33
+ const initialValue = untrack(() => controlledValue());
34
+ const [placeholderValue, setPlaceholderValue] = createSignal(untrack(() => (() => {
35
+ return controlledValue() ?? {
36
+ end: null,
37
+ start: null
38
+ };
39
+ })()), { ownedWrite: true });
40
+ createRenderEffect(() => ({
41
+ controlled: controlledValue(),
42
+ placeholder: placeholderValue()
43
+ }), ({ controlled, placeholder }) => {
44
+ if (!controlled && placeholder.start && placeholder.end) setPlaceholderValue({
45
+ end: null,
46
+ start: null
47
+ });
48
+ });
49
+ const value = createMemo(() => {
50
+ const currentControlledValue = controlledValue();
51
+ const currentPlaceholderValue = placeholderValue();
52
+ return currentControlledValue ?? currentPlaceholderValue;
53
+ });
54
+ const setValue = (newValue) => {
55
+ const currentValue = newValue ?? {
56
+ end: null,
57
+ start: null
58
+ };
59
+ setPlaceholderValue(currentValue);
60
+ if (isCompleteRange(currentValue)) setControlledValue(currentValue);
61
+ else setControlledValue(null);
62
+ };
63
+ const v = createMemo(() => {
64
+ const currentValue = value();
65
+ return currentValue?.start ?? currentValue?.end ?? props.placeholderValue ?? null;
66
+ });
67
+ const derived0 = createDefaultProps(v, () => props.granularity);
68
+ const granularity = createMemo(() => {
69
+ return derived0()[0];
70
+ });
71
+ const defaultTimeZone = createMemo(() => {
72
+ return derived0()[1];
73
+ });
74
+ const hasTime = createMemo(() => {
75
+ const currentGranularity = granularity();
76
+ return currentGranularity === "hour" || currentGranularity === "minute" || currentGranularity === "second";
77
+ });
78
+ const shouldCloseOnSelect = createMemo(() => props.shouldCloseOnSelect ?? true);
79
+ const [dateRange, setSelectedDateRange] = createSignal(null, { ownedWrite: true });
80
+ const [timeRange, setSelectedTimeRange] = createSignal(null, { ownedWrite: true });
81
+ createRenderEffect(value, (currentValue) => {
82
+ if (isCompleteRange(currentValue)) {
83
+ setSelectedDateRange(currentValue);
84
+ if ("hour" in currentValue.start && "hour" in currentValue.end) setSelectedTimeRange({
85
+ end: currentValue.end,
86
+ start: currentValue.start
87
+ });
88
+ }
89
+ });
90
+ const showEra = createMemo(() => {
91
+ const currentValue = value();
92
+ return currentValue?.start?.calendar.identifier === "gregory" && currentValue.start.era === "BC" || currentValue?.end?.calendar.identifier === "gregory" && currentValue.end.era === "BC";
93
+ });
94
+ const formatOpts = createMemo(() => {
95
+ const currentGranularity = granularity();
96
+ const currentDefaultTimeZone = defaultTimeZone();
97
+ const currentShowEra = showEra();
98
+ return {
99
+ granularity: currentGranularity,
100
+ hideTimeZone: props.hideTimeZone,
101
+ hourCycle: props.hourCycle,
102
+ shouldForceLeadingZeros: props.shouldForceLeadingZeros,
103
+ showEra: currentShowEra,
104
+ timeZone: currentDefaultTimeZone
105
+ };
106
+ });
107
+ const minValue = createMemo(() => props.minValue);
108
+ const maxValue = createMemo(() => props.maxValue);
109
+ const isDateUnavailable = createMemo(() => props.isDateUnavailable);
110
+ const builtinValidation = createMemo(() => {
111
+ const currentValue = value();
112
+ const currentMinValue = minValue();
113
+ const currentMaxValue = maxValue();
114
+ const currentIsDateUnavailable = isDateUnavailable();
115
+ const currentFormatOpts = formatOpts();
116
+ return getRangeValidationResult(currentValue, currentMinValue, currentMaxValue, currentIsDateUnavailable ? (date) => currentIsDateUnavailable(date, null) : void 0, currentFormatOpts);
117
+ });
118
+ const derivedProperty0 = createMemo(() => [props.startName, props.endName].filter((n) => n !== null && n !== void 0));
119
+ const validation = createFormValidationState(merge(props, {
120
+ get builtinValidation() {
121
+ return builtinValidation();
122
+ },
123
+ get name() {
124
+ return derivedProperty0();
125
+ },
126
+ validate: (localValue) => props.validate?.(localValue),
127
+ get value() {
128
+ return controlledValue();
129
+ }
130
+ }));
131
+ const commitValue = (localDateRange, localTimeRange) => {
132
+ setValue({
133
+ end: "timeZone" in localTimeRange.end ? localTimeRange.end.set(toCalendarDate(localDateRange.end)) : toCalendarDateTime(localDateRange.end, localTimeRange.end),
134
+ start: "timeZone" in localTimeRange.start ? localTimeRange.start.set(toCalendarDate(localDateRange.start)) : toCalendarDateTime(localDateRange.start, localTimeRange.start)
135
+ });
136
+ setSelectedDateRange(null);
137
+ setSelectedTimeRange(null);
138
+ validation.commitValidation();
139
+ };
140
+ const setDateRange = (range) => {
141
+ const currentShouldCloseOnSelect = shouldCloseOnSelect();
142
+ const currentHasTime = hasTime();
143
+ const currentTimeRange = timeRange();
144
+ const shouldClose = typeof currentShouldCloseOnSelect === "function" ? currentShouldCloseOnSelect() : currentShouldCloseOnSelect;
145
+ if (currentHasTime) {
146
+ if (isCompleteRange(range) && (shouldClose || currentTimeRange?.start && currentTimeRange?.end)) commitValue(range, {
147
+ end: currentTimeRange?.end ?? getPlaceholderTime(props.placeholderValue),
148
+ start: currentTimeRange?.start ?? getPlaceholderTime(props.placeholderValue)
149
+ });
150
+ else setSelectedDateRange(range);
151
+ } else if (isCompleteRange(range)) {
152
+ setValue(range);
153
+ validation.commitValidation();
154
+ } else setSelectedDateRange(range);
155
+ if (shouldClose) overlayState.setOpen(false);
156
+ };
157
+ const setTimeRange = (range) => {
158
+ const currentDateRange = dateRange();
159
+ if (isCompleteRange(currentDateRange) && isCompleteRange(range)) commitValue(currentDateRange, range);
160
+ else setSelectedTimeRange(range);
161
+ };
162
+ const isValueInvalid = createMemo(() => validation.displayValidation.isInvalid);
163
+ const validationState = createMemo(() => {
164
+ const currentIsValueInvalid = isValueInvalid();
165
+ return getLegacyValidationState(props) ?? (currentIsValueInvalid ? "invalid" : null);
166
+ });
167
+ return merge(validation, {
168
+ get dateRange() {
169
+ return dateRange();
170
+ },
171
+ get defaultValue() {
172
+ return props.defaultValue ?? initialValue;
173
+ },
174
+ get granularity() {
175
+ return granularity();
176
+ },
177
+ get hasTime() {
178
+ return hasTime();
179
+ },
180
+ setDate(part, date) {
181
+ const currentDateRange = dateRange();
182
+ if (part === "start") setDateRange({
183
+ end: currentDateRange?.end ?? null,
184
+ start: date
185
+ });
186
+ else setDateRange({
187
+ end: date,
188
+ start: currentDateRange?.start ?? null
189
+ });
190
+ },
191
+ setDateRange,
192
+ setDateTime(part, dateTime) {
193
+ const currentValue = value();
194
+ if (part === "start") setValue({
195
+ end: currentValue?.end ?? null,
196
+ start: dateTime
197
+ });
198
+ else setValue({
199
+ end: dateTime,
200
+ start: currentValue?.start ?? null
201
+ });
202
+ },
203
+ setTime(part, time) {
204
+ const currentTimeRange = timeRange();
205
+ if (part === "start") setTimeRange({
206
+ end: currentTimeRange?.end ?? null,
207
+ start: time
208
+ });
209
+ else setTimeRange({
210
+ end: time,
211
+ start: currentTimeRange?.start ?? null
212
+ });
213
+ },
214
+ setTimeRange,
215
+ setValue,
216
+ get timeRange() {
217
+ return timeRange();
218
+ },
219
+ get value() {
220
+ return value();
221
+ }
222
+ }, overlayState, {
223
+ formatValue(locale, fieldOptions) {
224
+ const currentValue = value();
225
+ if (!currentValue.start || !currentValue.end) return null;
226
+ const startTimeZone = "timeZone" in currentValue.start ? currentValue.start.timeZone : void 0;
227
+ const startGranularity = props.granularity ?? (Boolean(currentValue.start) && "minute" in currentValue.start ? "minute" : "day");
228
+ const endTimeZone = "timeZone" in currentValue.end ? currentValue.end.timeZone : void 0;
229
+ const endGranularity = props.granularity ?? (Boolean(currentValue.end) && "minute" in currentValue.end ? "minute" : "day");
230
+ const startOptions = getFormatOptions(fieldOptions, {
231
+ granularity: startGranularity,
232
+ hideTimeZone: props.hideTimeZone,
233
+ hourCycle: props.hourCycle,
234
+ showEra: currentValue.start.calendar.identifier === "gregory" && currentValue.start.era === "BC" || currentValue.end.calendar.identifier === "gregory" && currentValue.end.era === "BC",
235
+ timeZone: startTimeZone
236
+ });
237
+ const startDate = currentValue.start.toDate(startTimeZone ?? "UTC");
238
+ const endDate = currentValue.end.toDate(endTimeZone ?? "UTC");
239
+ const startFormatter = new DateFormatter(locale, startOptions);
240
+ let endFormatter;
241
+ if (startTimeZone === endTimeZone && startGranularity === endGranularity && currentValue.start.compare(currentValue.end) !== 0) {
242
+ try {
243
+ return splitDateRangeParts(startFormatter.formatRangeToParts(startDate, endDate));
244
+ } catch {}
245
+ endFormatter = startFormatter;
246
+ } else {
247
+ const endOptions = getFormatOptions(fieldOptions, {
248
+ granularity: endGranularity,
249
+ hideTimeZone: props.hideTimeZone,
250
+ hourCycle: props.hourCycle,
251
+ timeZone: endTimeZone
252
+ });
253
+ endFormatter = new DateFormatter(locale, endOptions);
254
+ }
255
+ return {
256
+ end: endFormatter.format(endDate),
257
+ start: startFormatter.format(startDate)
258
+ };
259
+ },
260
+ getDateFormatter(locale, formatOptions) {
261
+ const newOptions = {
262
+ ...formatOpts(),
263
+ ...formatOptions
264
+ };
265
+ const newFormatOptions = getFormatOptions({}, newOptions);
266
+ return new DateFormatter(locale, newFormatOptions);
267
+ },
268
+ get isInvalid() {
269
+ return isValueInvalid();
270
+ },
271
+ setOpen(isOpen) {
272
+ const currentValue = value();
273
+ const currentDateRange = dateRange();
274
+ const currentHasTime = hasTime();
275
+ const currentTimeRange = timeRange();
276
+ if (!isOpen && (!currentValue?.start || !currentValue?.end) && isCompleteRange(currentDateRange) && currentHasTime) commitValue(currentDateRange, {
277
+ end: currentTimeRange?.end ?? getPlaceholderTime(props.placeholderValue),
278
+ start: currentTimeRange?.start ?? getPlaceholderTime(props.placeholderValue)
279
+ });
280
+ overlayState.setOpen(isOpen);
281
+ },
282
+ get validationState() {
283
+ return validationState();
284
+ }
285
+ });
286
+ }
287
+ function isCompleteRange(value) {
288
+ return value?.start !== null && value?.start !== void 0 && value.end !== null && value.end !== void 0;
289
+ }
290
+ function splitDateRangeParts(parts) {
291
+ let separatorIndex = -1;
292
+ for (const [index, part] of parts.entries()) if (part.source === "shared" && part.type === "literal") separatorIndex = index;
293
+ else if (part.source === "endRange") break;
294
+ let start = "";
295
+ let end = "";
296
+ for (const [index, part] of parts.entries()) if (index < separatorIndex) start += part.value;
297
+ else if (index > separatorIndex) end += part.value;
298
+ return {
299
+ end,
300
+ start
301
+ };
302
+ }
303
+ export { createDateRangePickerState };
304
+
305
+ //# sourceMappingURL=create-date-range-picker-state.js.map