@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 @@
1
+ {"version":3,"file":"create-date-range-picker-state.js","names":[],"sources":["../../src/datepicker/create-date-range-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/useDateRangePickerState.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 { RangeValue, 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 DateRange,\n DateRangePickerProps,\n DateValue,\n Granularity,\n MappedDateValue,\n TimeValue,\n} from \"./types\";\nimport {\n getFormatOptions,\n getPlaceholderTime,\n getRangeValidationResult,\n createDefaultProps,\n} from \"./utils\";\nimport type { FieldOptions, FormatterOptions } from \"./utils\";\n\nexport interface DateRangePickerStateOptions<\n T extends DateValue = DateValue,\n> extends DateRangePickerProps<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\ntype TimeRange = RangeValue<TimeValue>;\n\nexport interface DateRangePickerState\n extends OverlayTriggerState, FormValidationState {\n /** The currently selected date range. */\n value: RangeValue<DateValue | null>;\n /** The default selected date range. */\n defaultValue: DateRange | null;\n /** Sets the selected date range. */\n setValue: (value: DateRange | null) => void;\n /**\n * The date portion of the selected range. This may be set prior to `value` if the user has\n * selected a date range but has not yet selected a time range.\n */\n dateRange: RangeValue<DateValue | null> | null;\n /** Sets the date portion of the selected range. */\n setDateRange: (value: DateRange) => void;\n /**\n * The time portion of the selected range. This may be set prior to `value` if the user has\n * selected a time range but has not yet selected a date range.\n */\n timeRange: RangeValue<TimeValue | null> | null;\n /** Sets the time portion of the selected range. */\n setTimeRange: (value: TimeRange) => void;\n /** Sets the date portion of either the start or end of the selected range. */\n setDate: (part: \"start\" | \"end\", value: DateValue | null) => void;\n /** Sets the time portion of either the start or end of the selected range. */\n setTime: (part: \"start\" | \"end\", value: TimeValue | null) => void;\n /** Sets the date and time of either the start or end of the selected range. */\n setDateTime: (part: \"start\" | \"end\", value: DateValue | null) => void;\n /** The granularity for the field, based on the `granularity` prop and current value. */\n granularity: Granularity;\n /**\n * Whether the date range picker supports selecting times, 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 range picker, based on the `validationState`,\n * `minValue`, and `maxValue` props.\n *\n * @deprecated Use `isInvalid` instead.\n */\n validationState: ValidationState | null;\n /**\n * Whether the date range picker is invalid, based on the `isInvalid`, `minValue`, and `maxValue`\n * props.\n */\n isInvalid: boolean;\n /** Formats the selected range using the given options. */\n formatValue: (\n locale: string,\n fieldOptions: FieldOptions\n ) => {\n start: string;\n end: string;\n } | null;\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 range picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function createDateRangePickerState<T extends DateValue = DateValue>(\n props: DateRangePickerStateOptions<T>\n): DateRangePickerState {\n const overlayState = createOverlayTriggerState(props);\n\n const [controlledValue, setControlledValue] =\n createControlledSignal<DateRange | null>(\n () => props.value,\n untrack(() => props.defaultValue ?? null),\n (value) =>\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.onChange?.(value as RangeValue<MappedDateValue<T>> | null)\n );\n\n const initialValue = untrack(() => controlledValue());\n\n const [placeholderValue, setPlaceholderValue] = createSignal<\n RangeValue<DateValue | null>\n >(\n untrack(() =>\n (() => {\n const currentControlledValue = controlledValue();\n\n return currentControlledValue ?? { end: null, start: null };\n })()\n ),\n { ownedWrite: true }\n );\n\n createRenderEffect(\n () => ({\n controlled: controlledValue(),\n placeholder: placeholderValue(),\n }),\n ({ controlled, placeholder }) => {\n if (!controlled && placeholder.start && placeholder.end) {\n setPlaceholderValue({ end: null, start: null });\n }\n }\n );\n\n const value = createMemo(() => {\n const currentControlledValue = controlledValue();\n const currentPlaceholderValue = placeholderValue();\n\n return currentControlledValue ?? currentPlaceholderValue;\n });\n\n const setValue = (newValue: RangeValue<DateValue | null> | null) => {\n const currentValue = newValue ?? { end: null, start: null };\n setPlaceholderValue(currentValue);\n\n if (isCompleteRange(currentValue)) {\n setControlledValue(currentValue);\n } else {\n setControlledValue(null);\n }\n };\n\n const v = createMemo(() => {\n const currentValue = value();\n\n return (\n currentValue?.start ?? currentValue?.end ?? props.placeholderValue ?? null\n );\n });\n\n const derived0 = createDefaultProps(v, () => props.granularity);\n\n const granularity = createMemo(() => {\n const currentDerived0 = derived0();\n\n return currentDerived0[0];\n });\n\n const defaultTimeZone = createMemo(() => {\n const currentDerived0 = derived0();\n\n return currentDerived0[1];\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 [dateRange, setSelectedDateRange] =\n createSignal<RangeValue<DateValue | null> | null>(null, {\n ownedWrite: true,\n });\n\n const [timeRange, setSelectedTimeRange] =\n createSignal<RangeValue<TimeValue | null> | null>(null, {\n ownedWrite: true,\n });\n\n createRenderEffect(value, (currentValue) => {\n if (isCompleteRange(currentValue)) {\n setSelectedDateRange(currentValue);\n\n if (\"hour\" in currentValue.start && \"hour\" in currentValue.end) {\n setSelectedTimeRange({\n end: currentValue.end,\n start: currentValue.start,\n });\n }\n }\n });\n\n const showEra = createMemo(() => {\n const currentValue = value();\n\n return (\n (currentValue?.start?.calendar.identifier === \"gregory\" &&\n currentValue.start.era === \"BC\") ||\n (currentValue?.end?.calendar.identifier === \"gregory\" &&\n currentValue.end.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 getRangeValidationResult(\n currentValue,\n currentMinValue,\n currentMaxValue,\n currentIsDateUnavailable\n ? (date) => currentIsDateUnavailable(date, null)\n : undefined,\n currentFormatOpts\n );\n });\n\n const derivedProperty0 = createMemo(() =>\n [props.startName, props.endName].filter(\n (n) => n !== null && n !== undefined\n )\n );\n\n const validation = createFormValidationState<DateRange>(\n merge(props, {\n get builtinValidation() {\n return builtinValidation();\n },\n get name() {\n return derivedProperty0();\n },\n validate: (localValue: DateRange) =>\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 RangeValue<MappedDateValue<T>>),\n get value() {\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 return controlledValue() as RangeValue<MappedDateValue<T>> | null;\n },\n })\n );\n\n const commitValue = (\n localDateRange: DateRange,\n localTimeRange: TimeRange\n ) => {\n setValue({\n end:\n \"timeZone\" in localTimeRange.end\n ? localTimeRange.end.set(toCalendarDate(localDateRange.end))\n : toCalendarDateTime(localDateRange.end, localTimeRange.end),\n start:\n \"timeZone\" in localTimeRange.start\n ? localTimeRange.start.set(toCalendarDate(localDateRange.start))\n : toCalendarDateTime(localDateRange.start, localTimeRange.start),\n });\n setSelectedDateRange(null);\n setSelectedTimeRange(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 setDateRange = (range: RangeValue<DateValue | null>) => {\n const currentShouldCloseOnSelect = shouldCloseOnSelect();\n const currentHasTime = hasTime();\n const currentTimeRange = timeRange();\n\n const shouldClose =\n typeof currentShouldCloseOnSelect === \"function\"\n ? currentShouldCloseOnSelect()\n : currentShouldCloseOnSelect;\n\n if (currentHasTime) {\n // Set a placeholder time if the popover is closing so we don't leave the field in an incomplete state.\n if (\n isCompleteRange(range) &&\n (shouldClose || (currentTimeRange?.start && currentTimeRange?.end))\n ) {\n commitValue(range, {\n end:\n currentTimeRange?.end ?? getPlaceholderTime(props.placeholderValue),\n start:\n currentTimeRange?.start ??\n getPlaceholderTime(props.placeholderValue),\n });\n } else {\n setSelectedDateRange(range);\n }\n } else if (isCompleteRange(range)) {\n setValue(range);\n validation.commitValidation();\n } else {\n setSelectedDateRange(range);\n }\n\n if (shouldClose) {\n overlayState.setOpen(false);\n }\n };\n\n const setTimeRange = (range: RangeValue<TimeValue | null>) => {\n const currentDateRange = dateRange();\n\n if (isCompleteRange(currentDateRange) && isCompleteRange(range)) {\n commitValue(currentDateRange, range);\n } else {\n setSelectedTimeRange(range);\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 return merge(\n validation,\n {\n get dateRange() {\n return dateRange();\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 setDate(part, date) {\n const currentDateRange = dateRange();\n\n if (part === \"start\") {\n setDateRange({ end: currentDateRange?.end ?? null, start: date });\n } else {\n setDateRange({ end: date, start: currentDateRange?.start ?? null });\n }\n },\n setDateRange,\n setDateTime(part, dateTime) {\n const currentValue = value();\n\n if (part === \"start\") {\n setValue({ end: currentValue?.end ?? null, start: dateTime });\n } else {\n setValue({ end: dateTime, start: currentValue?.start ?? null });\n }\n },\n setTime(part, time) {\n const currentTimeRange = timeRange();\n\n if (part === \"start\") {\n setTimeRange({ end: currentTimeRange?.end ?? null, start: time });\n } else {\n setTimeRange({ end: time, start: currentTimeRange?.start ?? null });\n }\n },\n setTimeRange,\n setValue,\n get timeRange() {\n return timeRange();\n },\n get value() {\n return value();\n },\n } satisfies Partial<DateRangePickerState>,\n overlayState,\n {\n formatValue(locale, fieldOptions) {\n const currentValue = value();\n\n if (!currentValue.start || !currentValue.end) {\n return null;\n }\n\n const startTimeZone =\n \"timeZone\" in currentValue.start\n ? currentValue.start.timeZone\n : undefined;\n\n const startGranularity =\n props.granularity ??\n (Boolean(currentValue.start) && \"minute\" in currentValue.start\n ? \"minute\"\n : \"day\");\n\n const endTimeZone =\n \"timeZone\" in currentValue.end\n ? currentValue.end.timeZone\n : undefined;\n\n const endGranularity =\n props.granularity ??\n (Boolean(currentValue.end) && \"minute\" in currentValue.end\n ? \"minute\"\n : \"day\");\n\n const startOptions = getFormatOptions(fieldOptions, {\n granularity: startGranularity,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n showEra:\n (currentValue.start.calendar.identifier === \"gregory\" &&\n currentValue.start.era === \"BC\") ||\n (currentValue.end.calendar.identifier === \"gregory\" &&\n currentValue.end.era === \"BC\"),\n timeZone: startTimeZone,\n });\n\n const startDate = currentValue.start.toDate(startTimeZone ?? \"UTC\");\n const endDate = currentValue.end.toDate(endTimeZone ?? \"UTC\");\n const startFormatter = new DateFormatter(locale, startOptions);\n let endFormatter: Intl.DateTimeFormat;\n\n if (\n startTimeZone === endTimeZone &&\n startGranularity === endGranularity &&\n currentValue.start.compare(currentValue.end) !== 0\n ) {\n // Use formatRange, as it results in shorter output when some of the fields\n // are shared between the start and end dates (e.g. the same month).\n // Formatting will fail if the end date is before the start date. Fall back below when that happens.\n try {\n return splitDateRangeParts(\n startFormatter.formatRangeToParts(startDate, endDate)\n );\n } catch {\n // ignore\n }\n\n endFormatter = startFormatter;\n } else {\n const endOptions = getFormatOptions(fieldOptions, {\n granularity: endGranularity,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n timeZone: endTimeZone,\n });\n\n endFormatter = new DateFormatter(locale, endOptions);\n }\n\n return {\n end: endFormatter.format(endDate),\n start: startFormatter.format(startDate),\n };\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 currentDateRange = dateRange();\n const currentHasTime = hasTime();\n const currentTimeRange = timeRange();\n\n // Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.\n // If only the time range was set and not the date range, don't commit. The state will be preserved until\n // the user opens the popover again.\n if (\n !isOpen &&\n (!currentValue?.start || !currentValue?.end) &&\n isCompleteRange(currentDateRange) &&\n currentHasTime\n ) {\n commitValue(currentDateRange, {\n end:\n currentTimeRange?.end ??\n getPlaceholderTime(props.placeholderValue),\n start:\n currentTimeRange?.start ??\n getPlaceholderTime(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<DateRangePickerState>\n );\n}\n\nfunction isCompleteRange<T>(\n value: RangeValue<T | null> | null\n): value is RangeValue<T> {\n return (\n value?.start !== null &&\n value?.start !== undefined &&\n value.end !== null &&\n value.end !== undefined\n );\n}\n\nfunction splitDateRangeParts(\n parts: ReturnType<Intl.DateTimeFormat[\"formatRangeToParts\"]>\n) {\n let separatorIndex = -1;\n\n for (const [index, part] of parts.entries()) {\n if (part.source === \"shared\" && part.type === \"literal\") {\n separatorIndex = index;\n } else if (part.source === \"endRange\") {\n break;\n }\n }\n\n let start = \"\";\n let end = \"\";\n\n for (const [index, part] of parts.entries()) {\n if (index < separatorIndex) {\n start += part.value;\n } else if (index > separatorIndex) {\n end += part.value;\n }\n }\n\n return { end, start };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyIA,SAAgB,2BACd,OACsB;CACtB,MAAM,eAAe,0BAA0B,KAAK;CAEpD,MAAM,CAAC,iBAAiB,sBACtB,6BACQ,MAAM,OACZ,cAAc,MAAM,gBAAgB,IAAI,IACvC,UAGC,MAAM,WAAW,KAA8C,CACnE;CAEF,MAAM,eAAe,cAAc,gBAAgB,CAAC;CAEpD,MAAM,CAAC,kBAAkB,uBAAuB,aAG9C,qBACS;EAGL,OAF+B,gBAEH,KAAK;GAAE,KAAK;GAAM,OAAO;EAAK;CAC5D,EAAA,CAAG,CACL,GACA,EAAE,YAAY,KAAK,CACrB;CAEA,0BACS;EACL,YAAY,gBAAgB;EAC5B,aAAa,iBAAiB;CAChC,KACC,EAAE,YAAY,kBAAkB;EAC/B,IAAI,CAAC,cAAc,YAAY,SAAS,YAAY,KAClD,oBAAoB;GAAE,KAAK;GAAM,OAAO;EAAK,CAAC;CAElD,CACF;CAEA,MAAM,QAAQ,iBAAiB;EAC7B,MAAM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S,gBACP,OACwB;CACxB,OACE,OAAO,UAAU,QACjB,OAAO,UAAU,KAAA,KACjB,MAAM,QAAQ,QACd,MAAM,QAAQ,KAAA;AAElB;AAEA,SAAS,oBACP,OACA;CACA,IAAI,iBAAiB;CAErB,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,IAAI,KAAK,WAAW,YAAY,KAAK,SAAS,WAC5C,iBAAiB;MACZ,IAAI,KAAK,WAAW,YACzB;CAIJ,IAAI,QAAQ;CACZ,IAAI,MAAM;CAEV,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,IAAI,QAAQ,gBACV,SAAS,KAAK;MACT,IAAI,QAAQ,gBACjB,OAAO,KAAK;CAIhB,OAAO;EAAE;EAAK;CAAM;AACtB"}
@@ -0,0 +1,34 @@
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/useTimeFieldState.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 { TimePickerProps, TimeValue } from "./types.js";
18
+ import { DateFieldState } from "./create-date-field-state.js";
19
+ import { Time } from "@internationalized/date";
20
+ export interface TimeFieldStateOptions<T extends TimeValue = TimeValue> extends TimePickerProps<T> {
21
+ /** The locale to display and edit the value according to. */
22
+ locale: string;
23
+ }
24
+ export interface TimeFieldState extends DateFieldState {
25
+ /** The current time value. */
26
+ timeValue: Time;
27
+ }
28
+ /**
29
+ * Provides state management for a time field component.
30
+ * A time field allows users to enter and edit time values using a keyboard.
31
+ * Each part of a time value is displayed in an individually editable segment.
32
+ */
33
+ export declare function createTimeFieldState<T extends TimeValue = TimeValue>(props: TimeFieldStateOptions<T>): TimeFieldState;
34
+ //# sourceMappingURL=create-time-field-state.d.ts.map
@@ -0,0 +1,128 @@
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/useTimeFieldState.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 { requireValue } from "../utils/require-value.js";
19
+ import { createDateFieldState } from "./create-date-field-state.js";
20
+ import { createMemo, merge, omit, untrack } from "solid-js";
21
+ import { GregorianCalendar, Time, getLocalTimeZone, toCalendarDateTime, toTime, toZoned, today } from "@internationalized/date";
22
+ // src/datepicker/create-time-field-state.ts
23
+ /**
24
+ * Provides state management for a time field component.
25
+ * A time field allows users to enter and edit time values using a keyboard.
26
+ * Each part of a time value is displayed in an individually editable segment.
27
+ */
28
+ function createTimeFieldState(props) {
29
+ const placeholderValue = createMemo(() => props.placeholderValue ?? new Time());
30
+ const minValue = createMemo(() => props.minValue);
31
+ const maxValue = createMemo(() => props.maxValue);
32
+ const defaultValue = createMemo(() => props.defaultValue);
33
+ const granularity = createMemo(() => props.granularity);
34
+ const validate = createMemo(() => props.validate);
35
+ const [value, setValue] = createControlledSignal(() => props.value, untrack(() => {
36
+ return defaultValue() ?? null;
37
+ }), (localValue) => props.onChange?.(localValue));
38
+ const v = createMemo(() => {
39
+ const currentValue = value();
40
+ const currentPlaceholderValue = placeholderValue();
41
+ return currentValue ?? currentPlaceholderValue;
42
+ });
43
+ const day = createMemo(() => {
44
+ const currentV = v();
45
+ return Boolean(currentV) && "day" in currentV ? currentV : void 0;
46
+ });
47
+ const defaultValueTimeZone = createMemo(() => {
48
+ const currentDefaultValue = defaultValue();
49
+ return currentDefaultValue && "timeZone" in currentDefaultValue ? currentDefaultValue.timeZone : void 0;
50
+ });
51
+ const placeholderDate = createMemo(() => {
52
+ const currentV = v();
53
+ const currentDefaultValueTimeZone = defaultValueTimeZone();
54
+ const currentPlaceholderValue = placeholderValue();
55
+ const valueTimeZone = Boolean(currentV) && "timeZone" in currentV ? currentV.timeZone : void 0;
56
+ return (valueTimeZone !== void 0 && valueTimeZone !== "" || currentDefaultValueTimeZone !== void 0 && currentDefaultValueTimeZone !== "") && Boolean(currentPlaceholderValue) ? toZoned(requireValue(convertValue(currentPlaceholderValue), "Expected convertValue(currentPlaceholderValue) to exist."), requireValue(valueTimeZone ?? currentDefaultValueTimeZone, "Zoned placeholders require a time zone.")) : convertValue(currentPlaceholderValue);
57
+ });
58
+ const minDate = createMemo(() => {
59
+ return convertValue(minValue(), day());
60
+ });
61
+ const maxDate = createMemo(() => {
62
+ return convertValue(maxValue(), day());
63
+ });
64
+ const timeValue = createMemo(() => {
65
+ const currentValue = value();
66
+ return currentValue && "day" in currentValue ? toTime(currentValue) : currentValue;
67
+ });
68
+ const dateTime = createMemo(() => {
69
+ const currentValue = value();
70
+ return currentValue === null || currentValue === void 0 ? null : convertValue(currentValue);
71
+ });
72
+ const defaultDateTime = createMemo(() => {
73
+ const currentDefaultValue = defaultValue();
74
+ return currentDefaultValue === null || currentDefaultValue === void 0 ? null : convertValue(currentDefaultValue);
75
+ });
76
+ const onChange = (newValue) => {
77
+ const currentDay = day();
78
+ const currentDefaultValueTimeZone = defaultValueTimeZone();
79
+ if (newValue === null || newValue === void 0) setValue(null);
80
+ else if ("hour" in newValue) setValue(currentDay || currentDefaultValueTimeZone !== void 0 && currentDefaultValueTimeZone !== "" ? newValue : toTime(newValue));
81
+ };
82
+ const state = createDateFieldState(merge(omit(props, "value", "defaultValue", "minValue", "maxValue", "placeholderValue", "onChange", "validate"), {
83
+ get createCalendar() {
84
+ return () => new GregorianCalendar();
85
+ },
86
+ get defaultValue() {
87
+ return defaultDateTime();
88
+ },
89
+ get granularity() {
90
+ return granularity() ?? "minute";
91
+ },
92
+ get maxGranularity() {
93
+ return "hour";
94
+ },
95
+ get maxValue() {
96
+ return maxDate();
97
+ },
98
+ get minValue() {
99
+ return minDate();
100
+ },
101
+ onChange,
102
+ get placeholderValue() {
103
+ const date = placeholderDate();
104
+ return date && "day" in date ? date : void 0;
105
+ },
106
+ get validate() {
107
+ return () => {
108
+ const currentValidate = validate();
109
+ const currentValue = value();
110
+ return currentValidate?.(currentValue);
111
+ };
112
+ },
113
+ get value() {
114
+ return dateTime();
115
+ }
116
+ }));
117
+ return merge(state, { get timeValue() {
118
+ return requireValue(timeValue(), "Time fields require a placeholder time.");
119
+ } });
120
+ }
121
+ function convertValue(value, date = today(getLocalTimeZone())) {
122
+ if (!value) return null;
123
+ if ("day" in value) return value;
124
+ return toCalendarDateTime(date, value);
125
+ }
126
+ export { createTimeFieldState };
127
+
128
+ //# sourceMappingURL=create-time-field-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-time-field-state.js","names":[],"sources":["../../src/datepicker/create-time-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/datepicker/useTimeFieldState.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 getLocalTimeZone,\n GregorianCalendar,\n Time,\n toCalendarDateTime,\n today,\n toTime,\n toZoned,\n} from \"@internationalized/date\";\nimport { createMemo, untrack, merge, omit } from \"solid-js\";\n\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { requireValue } from \"../utils/require-value\";\nimport { createDateFieldState } from \"./create-date-field-state\";\nimport type { DateFieldState } from \"./create-date-field-state\";\nimport type {\n DateValue,\n MappedTimeValue,\n TimePickerProps,\n TimeValue,\n} from \"./types\";\n\nexport interface TimeFieldStateOptions<\n T extends TimeValue = TimeValue,\n> extends TimePickerProps<T> {\n /** The locale to display and edit the value according to. */\n locale: string;\n}\n\nexport interface TimeFieldState extends DateFieldState {\n /** The current time value. */\n timeValue: Time;\n}\n\n/**\n * Provides state management for a time field component.\n * A time field allows users to enter and edit time values using a keyboard.\n * Each part of a time value is displayed in an individually editable segment.\n */\nexport function createTimeFieldState<T extends TimeValue = TimeValue>(\n props: TimeFieldStateOptions<T>\n): TimeFieldState {\n const placeholderValue = createMemo(\n () => props.placeholderValue ?? new Time()\n );\n\n const minValue = createMemo(() => props.minValue);\n const maxValue = createMemo(() => props.maxValue);\n const defaultValue = createMemo(() => props.defaultValue);\n const granularity = createMemo(() => props.granularity);\n const validate = createMemo(() => props.validate);\n\n const [value, setValue] = createControlledSignal<TimeValue | null>(\n () => props.value,\n untrack(() => {\n const currentDefaultValue = defaultValue();\n\n return currentDefaultValue ?? null;\n }),\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 MappedTimeValue<T> | null)\n );\n\n const v = createMemo(() => {\n const currentValue = value();\n const currentPlaceholderValue = placeholderValue();\n\n return currentValue ?? currentPlaceholderValue;\n });\n\n const day = createMemo(() => {\n const currentV = v();\n\n return Boolean(currentV) && \"day\" in currentV ? currentV : undefined;\n });\n\n const defaultValueTimeZone = createMemo(() => {\n const currentDefaultValue = defaultValue();\n\n return currentDefaultValue && \"timeZone\" in currentDefaultValue\n ? currentDefaultValue.timeZone\n : undefined;\n });\n\n const placeholderDate = createMemo(() => {\n const currentV = v();\n const currentDefaultValueTimeZone = defaultValueTimeZone();\n const currentPlaceholderValue = placeholderValue();\n\n const valueTimeZone =\n Boolean(currentV) && \"timeZone\" in currentV\n ? currentV.timeZone\n : undefined;\n\n return ((valueTimeZone !== undefined && valueTimeZone !== \"\") ||\n (currentDefaultValueTimeZone !== undefined &&\n currentDefaultValueTimeZone !== \"\")) &&\n Boolean(currentPlaceholderValue)\n ? toZoned(\n requireValue(\n convertValue(currentPlaceholderValue),\n \"Expected convertValue(currentPlaceholderValue) to exist.\"\n ),\n requireValue(\n valueTimeZone ?? currentDefaultValueTimeZone,\n \"Zoned placeholders require a time zone.\"\n )\n )\n : convertValue(currentPlaceholderValue);\n });\n\n const minDate = createMemo(() => {\n const currentMinValue = minValue();\n const currentDay = day();\n\n return convertValue(currentMinValue, currentDay);\n });\n\n const maxDate = createMemo(() => {\n const currentMaxValue = maxValue();\n const currentDay = day();\n\n return convertValue(currentMaxValue, currentDay);\n });\n\n const timeValue = createMemo(() => {\n const currentValue = value();\n\n return currentValue && \"day\" in currentValue\n ? toTime(currentValue)\n : currentValue;\n });\n\n const dateTime = createMemo(() => {\n const currentValue = value();\n\n return currentValue === null || currentValue === undefined\n ? null\n : convertValue(currentValue);\n });\n\n const defaultDateTime = createMemo(() => {\n const currentDefaultValue = defaultValue();\n\n return currentDefaultValue === null || currentDefaultValue === undefined\n ? null\n : convertValue(currentDefaultValue);\n });\n\n const onChange = (newValue: DateValue | null) => {\n const currentDay = day();\n const currentDefaultValueTimeZone = defaultValueTimeZone();\n\n if (newValue === null || newValue === undefined) {\n setValue(null);\n } else if (\"hour\" in newValue) {\n setValue(\n currentDay ||\n (currentDefaultValueTimeZone !== undefined &&\n currentDefaultValueTimeZone !== \"\")\n ? newValue\n : toTime(newValue)\n );\n }\n };\n\n const state = createDateFieldState(\n merge(\n omit(\n props,\n \"value\",\n \"defaultValue\",\n \"minValue\",\n \"maxValue\",\n \"placeholderValue\",\n \"onChange\",\n \"validate\"\n ),\n {\n // Calendar should not matter for time fields.\n get createCalendar() {\n return () => new GregorianCalendar();\n },\n get defaultValue() {\n return defaultDateTime();\n },\n get granularity(): \"hour\" | \"minute\" | \"second\" {\n return granularity() ?? \"minute\";\n },\n get maxGranularity() {\n return \"hour\" as const;\n },\n get maxValue() {\n return maxDate();\n },\n get minValue() {\n return minDate();\n },\n onChange,\n get placeholderValue(): DateValue | undefined {\n const date = placeholderDate();\n\n return date && \"day\" in date ? date : undefined;\n },\n get validate() {\n return () => {\n const currentValidate = validate();\n const currentValue = value();\n\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 return currentValidate?.(currentValue as MappedTimeValue<T>);\n };\n },\n get value() {\n return dateTime();\n },\n }\n )\n );\n\n return merge(state, {\n get timeValue() {\n return requireValue(\n timeValue(),\n \"Time fields require a placeholder time.\"\n );\n },\n } satisfies Partial<TimeFieldState>);\n}\n\nfunction convertValue(\n value: TimeValue | null | undefined,\n date: DateValue = today(getLocalTimeZone())\n) {\n if (!value) {\n return null;\n }\n\n if (\"day\" in value) {\n return value;\n }\n\n return toCalendarDateTime(date, value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB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,OAAO,kBAAkB,YAAkC;GAC7D;EACF;EACA,IAAI,QAAQ;GACV,OAAO,SAAS;EAClB;CACF,CACF,CACF;CAEA,OAAO,MAAM,OAAO,EAClB,IAAI,YAAY;EACd,OAAO,aACL,UAAU,GACV,yCACF;CACF,EACF,CAAmC;AACrC;AAEA,SAAS,aACP,OACA,OAAkB,MAAM,iBAAiB,CAAC,GAC1C;CACA,IAAI,CAAC,OACH,OAAO;CAGT,IAAI,SAAS,OACX,OAAO;CAGT,OAAO,mBAAmB,MAAM,KAAK;AACvC"}
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright 2026 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/IncompleteDate.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 { DateValue, MappedDateValue } from "./types.js";
18
+ import { DateSegmentType } from "./create-date-field-state.js";
19
+ import { AnyDateTime, Calendar } from "@internationalized/date";
20
+ type HourCycle = "h12" | "h11" | "h23" | "h24";
21
+ /**
22
+ * This class represents a date that is incomplete or otherwise invalid as a result of user editing.
23
+ * For example, it can represent temporary dates such as February 31st if the user edits the day
24
+ * before the month. Times are represented according to an hour cycle rather than always in 24 hour
25
+ * time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.
26
+ */
27
+ export declare class IncompleteDate {
28
+ calendar: Calendar;
29
+ era: string | null;
30
+ year: number | null;
31
+ month: number | null;
32
+ day: number | null;
33
+ hour: number | null;
34
+ hourCycle: HourCycle;
35
+ dayPeriod: number | null;
36
+ minute: number | null;
37
+ second: number | null;
38
+ millisecond: number | null;
39
+ offset: number | null;
40
+ constructor(calendar: Calendar, hourCycle: HourCycle, dateValue?: Partial<Omit<AnyDateTime, "copy">> | null);
41
+ copy(): IncompleteDate;
42
+ /** Checks whether all the specified segments have a value. */
43
+ isComplete(segments: DateSegmentType[]): boolean;
44
+ /** Checks whether the given date value matches this value for the specified segments. */
45
+ validate(dt: DateValue, segments: DateSegmentType[]): boolean;
46
+ /** Checks if the date is empty (i.e. all specified segments are null). */
47
+ isCleared(segments: DateSegmentType[]): boolean;
48
+ /** Sets the given field. */
49
+ set(field: DateSegmentType, value: number | string, placeholder: DateValue): IncompleteDate;
50
+ /** Sets the given field to null. */
51
+ clear(field: DateSegmentType): IncompleteDate;
52
+ /**
53
+ * Increments or decrements the given field. If it is null, then it is set to the placeholder
54
+ * value.
55
+ */
56
+ cycle(field: DateSegmentType, amount: number, placeholder: DateValue, displaySegments: DateSegmentType[]): IncompleteDate;
57
+ private initializeSegment;
58
+ private cycleHour;
59
+ /**
60
+ * Converts the incomplete date to a full date value, using the provided value for any unset
61
+ * fields.
62
+ */
63
+ toValue<T extends DateValue>(value: T): MappedDateValue<T>;
64
+ getSegmentLimits(type: string): {
65
+ value: number | null;
66
+ minValue: number;
67
+ maxValue: number;
68
+ } | undefined;
69
+ }
70
+ export {};
71
+ //# sourceMappingURL=incomplete-date.d.ts.map
@@ -0,0 +1,324 @@
1
+ /*
2
+ * Copyright 2026 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/IncompleteDate.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 { requireValue } from "../utils/require-value.js";
18
+ import { CalendarDate } from "@internationalized/date";
19
+ // src/datepicker/incomplete-date.ts
20
+ /**
21
+ * This class represents a date that is incomplete or otherwise invalid as a result of user editing.
22
+ * For example, it can represent temporary dates such as February 31st if the user edits the day
23
+ * before the month. Times are represented according to an hour cycle rather than always in 24 hour
24
+ * time. This enables the user to adjust the day period (e.g. am/pm) independently from the hour.
25
+ */
26
+ var IncompleteDate = class IncompleteDate {
27
+ calendar;
28
+ era;
29
+ year;
30
+ month;
31
+ day;
32
+ hour;
33
+ hourCycle;
34
+ dayPeriod;
35
+ minute;
36
+ second;
37
+ millisecond;
38
+ offset;
39
+ constructor(calendar, hourCycle, dateValue) {
40
+ this.era = dateValue?.era ?? null;
41
+ this.calendar = calendar;
42
+ this.year = dateValue?.year ?? null;
43
+ this.month = dateValue?.month ?? null;
44
+ this.day = dateValue?.day ?? null;
45
+ this.hour = dateValue?.hour ?? null;
46
+ this.hourCycle = hourCycle;
47
+ this.dayPeriod = null;
48
+ this.minute = dateValue?.minute ?? null;
49
+ this.second = dateValue?.second ?? null;
50
+ this.millisecond = dateValue?.millisecond ?? null;
51
+ this.offset = getDateOffset(dateValue);
52
+ if (this.hour !== null && this.hour !== void 0) {
53
+ const [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);
54
+ this.dayPeriod = dayPeriod;
55
+ this.hour = hour;
56
+ }
57
+ }
58
+ copy() {
59
+ const res = new IncompleteDate(this.calendar, this.hourCycle);
60
+ res.era = this.era;
61
+ res.year = this.year;
62
+ res.month = this.month;
63
+ res.day = this.day;
64
+ res.hour = this.hour;
65
+ res.dayPeriod = this.dayPeriod;
66
+ res.minute = this.minute;
67
+ res.second = this.second;
68
+ res.millisecond = this.millisecond;
69
+ res.offset = this.offset;
70
+ return res;
71
+ }
72
+ /** Checks whether all the specified segments have a value. */
73
+ isComplete(segments) {
74
+ return segments.every((segment) => isEditableSegment(segment) && this[segment] !== null && this[segment] !== void 0);
75
+ }
76
+ /** Checks whether the given date value matches this value for the specified segments. */
77
+ validate(dt, segments) {
78
+ const fields = dt;
79
+ return segments.every((segment) => {
80
+ if ((segment === "hour" || segment === "dayPeriod") && "hour" in dt) {
81
+ const [dayPeriod, hour] = toHourCycle(dt.hour, this.hourCycle);
82
+ return this.dayPeriod === dayPeriod && this.hour === hour;
83
+ }
84
+ return isEditableSegment(segment) && segment in dt && this[segment] === fields[segment];
85
+ });
86
+ }
87
+ /** Checks if the date is empty (i.e. all specified segments are null). */
88
+ isCleared(segments) {
89
+ return segments.every((segment) => isEditableSegment(segment) && this[segment] === null);
90
+ }
91
+ /** Sets the given field. */
92
+ set(field, value, placeholder) {
93
+ const result = this.copy();
94
+ if (field === "era" && typeof value === "string") result.era = value;
95
+ else if (isEditableSegment(field) && field !== "era" && typeof value === "number") result[field] = value;
96
+ if (field === "hour" && (result.dayPeriod === null || result.dayPeriod === void 0) && "hour" in placeholder) [result.dayPeriod] = toHourCycle(placeholder.hour, this.hourCycle);
97
+ if (field === "year" && (result.era === null || result.era === void 0)) result.era = placeholder.era;
98
+ if (field !== "second" && field !== "literal" && field !== "timeZoneName") result.offset = null;
99
+ return result;
100
+ }
101
+ /** Sets the given field to null. */
102
+ clear(field) {
103
+ const result = this.copy();
104
+ if (isEditableSegment(field)) result[field] = null;
105
+ if (field === "year") result.era = null;
106
+ result.offset = null;
107
+ return result;
108
+ }
109
+ /**
110
+ * Increments or decrements the given field. If it is null, then it is set to the placeholder
111
+ * value.
112
+ */
113
+ cycle(field, amount, placeholder, displaySegments) {
114
+ const res = this.copy();
115
+ if (!isEditableSegment(field)) return res;
116
+ if ((res[field] === null || res[field] === void 0) && field !== "dayPeriod" && field !== "era") {
117
+ this.initializeSegment(res, field, placeholder);
118
+ return res;
119
+ }
120
+ switch (field) {
121
+ case "era": {
122
+ const eras = this.calendar.getEras();
123
+ let index = eras.indexOf(requireValue(res.era, "Expected res.era to exist."));
124
+ index = cycleValue(index, amount, 0, eras.length - 1);
125
+ res.era = eras[index] ?? null;
126
+ break;
127
+ }
128
+ case "year": {
129
+ let date = new CalendarDate(this.calendar, this.era ?? placeholder.era, this.year ?? placeholder.year, this.month ?? 1, this.day ?? 1);
130
+ date = date.cycle(field, amount, { round: field === "year" });
131
+ res.era = date.era;
132
+ res.year = date.year;
133
+ break;
134
+ }
135
+ case "month":
136
+ res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());
137
+ break;
138
+ case "day":
139
+ res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());
140
+ break;
141
+ case "hour":
142
+ this.cycleHour(res, amount, placeholder, displaySegments);
143
+ break;
144
+ case "dayPeriod":
145
+ res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);
146
+ break;
147
+ case "minute":
148
+ res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);
149
+ break;
150
+ case "second": res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
151
+ }
152
+ return res;
153
+ }
154
+ initializeSegment(res, field, placeholder) {
155
+ if (field === "hour" && "hour" in placeholder) {
156
+ const [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);
157
+ res.dayPeriod = dayPeriod;
158
+ res.hour = hour;
159
+ } else if (field in placeholder) res[field] = placeholder[field] ?? null;
160
+ if (field === "year" && (res.era === null || res.era === void 0)) res.era = placeholder.era;
161
+ }
162
+ cycleHour(res, amount, placeholder, displaySegments) {
163
+ const hasDateSegements = displaySegments.some((s) => [
164
+ "year",
165
+ "month",
166
+ "day"
167
+ ].includes(s));
168
+ if ("timeZone" in placeholder && (!hasDateSegements || res.year !== null && res.year !== void 0 && res.month !== null && res.month !== void 0 && res.day !== null && res.day !== void 0)) {
169
+ let date = this.toValue(placeholder);
170
+ date = date.cycle("hour", amount, {
171
+ hourCycle: this.hourCycle === "h12" ? 12 : 24,
172
+ round: false
173
+ });
174
+ const [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);
175
+ res.hour = adjustedHour;
176
+ res.dayPeriod = dayPeriod;
177
+ res.offset = date.offset;
178
+ } else {
179
+ const hours = res.hour ?? 0;
180
+ const limits = requireValue(this.getSegmentLimits("hour"), "Hour segments must have limits.");
181
+ res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);
182
+ if ((res.dayPeriod === null || res.dayPeriod === void 0) && "hour" in placeholder) [res.dayPeriod] = toHourCycle(placeholder.hour, this.hourCycle);
183
+ }
184
+ }
185
+ toValue(value) {
186
+ const fields = {
187
+ day: this.day ?? value.day,
188
+ era: this.era ?? value.era,
189
+ month: this.month ?? value.month,
190
+ year: this.year ?? value.year
191
+ };
192
+ if ("hour" in value) {
193
+ let { hour } = this;
194
+ if (hour !== null && hour !== void 0) hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);
195
+ else if (this.hourCycle === "h12" || this.hourCycle === "h11") hour = this.dayPeriod === 1 ? 12 : 0;
196
+ let res = value.set({
197
+ ...fields,
198
+ hour: hour ?? value.hour,
199
+ millisecond: this.millisecond ?? value.millisecond,
200
+ minute: this.minute ?? value.minute,
201
+ second: this.second ?? value.second
202
+ });
203
+ if ("offset" in res && this.offset !== null && this.offset !== void 0 && res.offset !== this.offset) res = res.add({ milliseconds: res.offset - this.offset });
204
+ return res;
205
+ }
206
+ return value.set(fields);
207
+ }
208
+ getSegmentLimits(type) {
209
+ switch (type) {
210
+ case "era": {
211
+ const eras = this.calendar.getEras();
212
+ return {
213
+ maxValue: eras.length - 1,
214
+ minValue: 0,
215
+ value: this.era === null || this.era === void 0 ? eras.length - 1 : eras.indexOf(this.era)
216
+ };
217
+ }
218
+ case "year": return {
219
+ maxValue: 9999,
220
+ minValue: 1,
221
+ value: this.year
222
+ };
223
+ case "month": return {
224
+ maxValue: this.calendar.getMaximumMonthsInYear(),
225
+ minValue: 1,
226
+ value: this.month
227
+ };
228
+ case "day": return {
229
+ maxValue: this.calendar.getMaximumDaysInMonth(),
230
+ minValue: 1,
231
+ value: this.day
232
+ };
233
+ case "dayPeriod": return {
234
+ maxValue: 1,
235
+ minValue: 0,
236
+ value: this.dayPeriod
237
+ };
238
+ case "hour": {
239
+ let minValue = 0;
240
+ let maxValue = 23;
241
+ if (this.hourCycle === "h12") {
242
+ minValue = 1;
243
+ maxValue = 12;
244
+ } else if (this.hourCycle === "h11") {
245
+ minValue = 0;
246
+ maxValue = 11;
247
+ }
248
+ return {
249
+ maxValue,
250
+ minValue,
251
+ value: this.hour
252
+ };
253
+ }
254
+ case "minute": return {
255
+ maxValue: 59,
256
+ minValue: 0,
257
+ value: this.minute
258
+ };
259
+ case "second": return {
260
+ maxValue: 59,
261
+ minValue: 0,
262
+ value: this.second
263
+ };
264
+ }
265
+ }
266
+ };
267
+ function cycleValue(initialValue, amount, min, max, round = false) {
268
+ let value = initialValue;
269
+ if (round) {
270
+ value += Math.sign(amount);
271
+ if (value < min) value = max;
272
+ const div = Math.abs(amount);
273
+ value = amount > 0 ? Math.ceil(value / div) * div : Math.floor(value / div) * div;
274
+ if (value > max) value = min;
275
+ } else {
276
+ value += amount;
277
+ if (value < min) value = max - (min - value - 1);
278
+ else if (value > max) value = min + (value - max - 1);
279
+ }
280
+ return value;
281
+ }
282
+ function toHourCycle(initialHour, hourCycle) {
283
+ let hour = initialHour;
284
+ let dayPeriod = hour >= 12 ? 1 : 0;
285
+ switch (hourCycle) {
286
+ case "h11":
287
+ if (hour >= 12) hour -= 12;
288
+ break;
289
+ case "h12":
290
+ if (hour === 0) hour = 12;
291
+ else if (hour > 12) hour -= 12;
292
+ break;
293
+ case "h23":
294
+ dayPeriod = null;
295
+ break;
296
+ case "h24":
297
+ hour += 1;
298
+ dayPeriod = null;
299
+ }
300
+ return [dayPeriod, hour];
301
+ }
302
+ function fromHourCycle(initialHour, dayPeriod, hourCycle) {
303
+ let hour = initialHour;
304
+ switch (hourCycle) {
305
+ case "h11":
306
+ if (dayPeriod === 1) hour += 12;
307
+ break;
308
+ case "h12":
309
+ if (hour === 12) hour = 0;
310
+ if (dayPeriod === 1) hour += 12;
311
+ break;
312
+ case "h24": hour -= 1;
313
+ }
314
+ return hour;
315
+ }
316
+ function isEditableSegment(value) {
317
+ return value !== "literal" && value !== "timeZoneName";
318
+ }
319
+ function getDateOffset(dateValue) {
320
+ return dateValue && "offset" in dateValue && typeof dateValue.offset === "number" ? dateValue.offset : null;
321
+ }
322
+ export { IncompleteDate };
323
+
324
+ //# sourceMappingURL=incomplete-date.js.map