@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,63 @@
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/calendar/useRangeCalendarState.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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 { CalendarPropsBase, DateValue, MappedDateValue, RangeCalendarState } from "./types.js";
18
+ import { Calendar, CalendarDate, CalendarIdentifier, DateDuration } from "@internationalized/date";
19
+ import { RangeValue, ValueBase } from "@solid2-aria/types-shared";
20
+ export type DateRange = RangeValue<DateValue> | null;
21
+ export interface RangeCalendarProps<T extends DateValue> extends CalendarPropsBase, ValueBase<RangeValue<T> | null, RangeValue<MappedDateValue<T>>> {
22
+ /**
23
+ * When combined with `isDateUnavailable`, determines whether non-contiguous ranges,
24
+ * i.e. ranges containing unavailable dates, may be selected.
25
+ */
26
+ allowsNonContiguousRanges?: boolean;
27
+ /**
28
+ * Callback that is called for each date of the calendar. If it returns true, then the date is
29
+ * unavailable. The second argument provides the current selection anchor date, if any. This can
30
+ * be used to adjust the available dates based on the user's first selected date.
31
+ */
32
+ isDateUnavailable?: (date: DateValue, anchorDate: CalendarDate | null) => boolean;
33
+ }
34
+ export interface RangeCalendarStateOptions<T extends DateValue = DateValue> extends RangeCalendarProps<T> {
35
+ /** The locale to display and edit the value according to. */
36
+ locale: string;
37
+ /**
38
+ * A function that creates a [Calendar](../internationalized/date/Calendar.html)
39
+ * object for a given calendar identifier. Such a function may be imported from the
40
+ * `@internationalized/date` package, or manually implemented to include support for
41
+ * only certain calendars.
42
+ */
43
+ createCalendar: (name: CalendarIdentifier) => Calendar;
44
+ /**
45
+ * The amount of days that will be displayed at once. This affects how pagination works.
46
+ *
47
+ * @default { months: 1 }
48
+ */
49
+ visibleDuration?: DateDuration;
50
+ /**
51
+ * Determines the alignment of the visible months on initial render based on the current selection
52
+ * or current date if there is no selection.
53
+ *
54
+ * @default 'center'
55
+ */
56
+ selectionAlignment?: "start" | "center" | "end";
57
+ }
58
+ /**
59
+ * Provides state management for a range calendar component. A range calendar displays one or more
60
+ * date grids and allows users to select a contiguous range of dates.
61
+ */
62
+ export declare function createRangeCalendarState<T extends DateValue = DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState<T>;
63
+ //# sourceMappingURL=create-range-calendar-state.d.ts.map
@@ -0,0 +1,204 @@
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/calendar/useRangeCalendarState.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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 { alignCenter, constrainValue, isInvalid, previousAvailableDate } from "./utils.js";
20
+ import { createCalendarState } from "./create-calendar-state.js";
21
+ import { createMemo, createSignal, merge, omit, untrack } from "solid-js";
22
+ import { GregorianCalendar, maxDate, minDate, toCalendar, toCalendarDate } from "@internationalized/date";
23
+ // src/calendar/create-range-calendar-state.ts
24
+ /**
25
+ * Provides state management for a range calendar component. A range calendar displays one or more
26
+ * date grids and allows users to select a contiguous range of dates.
27
+ */
28
+ function createRangeCalendarState(props) {
29
+ const locale = createMemo(() => props.locale);
30
+ const visibleDuration = createMemo(() => props.visibleDuration ?? { months: 1 });
31
+ const minValue = createMemo(() => props.minValue);
32
+ const maxValue = createMemo(() => props.maxValue);
33
+ const [value, setValue] = createControlledSignal(() => props.value, untrack(() => props.defaultValue) ?? null, (v) => props.onChange?.(v));
34
+ const [anchorDate, setAnchorDate] = createSignal(null);
35
+ const alignment = createMemo(() => {
36
+ const currentValue = value();
37
+ const currentVisibleDuration = visibleDuration();
38
+ let localAlignment = "center";
39
+ if (currentValue && Boolean(currentValue.start) && Boolean(currentValue.end)) {
40
+ const end = alignCenter(toCalendarDate(currentValue.start), currentVisibleDuration, locale(), minValue(), maxValue()).add(currentVisibleDuration).subtract({ days: 1 });
41
+ if (currentValue.end.compare(end) > 0) localAlignment = "start";
42
+ }
43
+ return localAlignment;
44
+ });
45
+ const isDateUnavailable = createMemo(() => {
46
+ const { isDateUnavailable: localIsDateUnavailable } = props;
47
+ return localIsDateUnavailable ? (date) => localIsDateUnavailable(date, anchorDate()) : void 0;
48
+ });
49
+ const getAvailableRange = (localAnchorDate) => {
50
+ const currentIsDateUnavailable = isDateUnavailable();
51
+ const currentVisibleDuration = visibleDuration();
52
+ if (localAnchorDate && currentIsDateUnavailable && !(props.allowsNonContiguousRanges === true)) {
53
+ const nextAvailableStartDate = nextUnavailableDate(localAnchorDate, currentIsDateUnavailable, currentVisibleDuration, -1);
54
+ return {
55
+ end: nextUnavailableDate(localAnchorDate, currentIsDateUnavailable, currentVisibleDuration, 1),
56
+ start: nextAvailableStartDate
57
+ };
58
+ }
59
+ return null;
60
+ };
61
+ const availableRange = createMemo(() => {
62
+ const currentAnchorDate = anchorDate();
63
+ return getAvailableRange(currentAnchorDate);
64
+ });
65
+ const min = createMemo(() => maxDate(minValue(), availableRange()?.start));
66
+ const max = createMemo(() => minDate(maxValue(), availableRange()?.end));
67
+ const calendar = createCalendarState(merge(omit(props, "value", "defaultValue", "onChange", "isDateUnavailable"), {
68
+ defaultValue: null,
69
+ get isDateUnavailable() {
70
+ return isDateUnavailable();
71
+ },
72
+ get maxValue() {
73
+ return max();
74
+ },
75
+ get minValue() {
76
+ return min();
77
+ },
78
+ onChange: void 0,
79
+ get selectionAlignment() {
80
+ return props.selectionAlignment ?? alignment();
81
+ },
82
+ get value() {
83
+ const currentValue = value();
84
+ return currentValue && currentValue.start;
85
+ }
86
+ }));
87
+ const highlightedRange = createMemo(() => {
88
+ const currentAnchorDate = anchorDate();
89
+ const currentValue = value();
90
+ return currentAnchorDate ? makeRange(currentAnchorDate, calendar.focusedDate) : currentValue && makeRange(currentValue.start, currentValue.end);
91
+ });
92
+ const selectDate = (date) => {
93
+ const currentIsDateUnavailable = isDateUnavailable();
94
+ const currentAnchorDate = anchorDate();
95
+ const currentValue = value();
96
+ if (props.isReadOnly === true || props.isDisabled === true) return;
97
+ const constrainedDate = constrainValue(date, min(), max());
98
+ const previousAvailableConstrainedDate = previousAvailableDate(constrainedDate, calendar.visibleRange.start, currentIsDateUnavailable);
99
+ if (!previousAvailableConstrainedDate) return;
100
+ if (currentAnchorDate) {
101
+ const range = makeRange(currentAnchorDate, previousAvailableConstrainedDate);
102
+ if (range) setValue({
103
+ end: convertValue(range.end, currentValue?.end),
104
+ start: convertValue(range.start, currentValue?.start)
105
+ });
106
+ setAnchorDate(null);
107
+ } else setAnchorDate(previousAvailableConstrainedDate);
108
+ };
109
+ const [isDragging, setDragging] = createSignal(false);
110
+ const isInvalidSelection = createMemo(() => {
111
+ const currentValue = value();
112
+ const currentAnchorDate = anchorDate();
113
+ const currentIsDateUnavailable = isDateUnavailable();
114
+ if (!currentValue || currentAnchorDate) return false;
115
+ if (currentIsDateUnavailable && (currentIsDateUnavailable(currentValue.start) || currentIsDateUnavailable(currentValue.end))) return true;
116
+ return isInvalid(currentValue.start, minValue(), maxValue()) || isInvalid(currentValue.end, minValue(), maxValue());
117
+ });
118
+ const isValueInvalid = createMemo(() => props.isInvalid === true || getLegacyValidationState(props) === "invalid" || isInvalidSelection());
119
+ const validationState = createMemo(() => isValueInvalid() ? "invalid" : null);
120
+ return merge(calendar, {
121
+ get anchorDate() {
122
+ return anchorDate();
123
+ },
124
+ clearSelection() {
125
+ setAnchorDate(null);
126
+ setValue(null);
127
+ },
128
+ commitSelection() {
129
+ selectDate(calendar.focusedDate);
130
+ },
131
+ focusNearestAvailableDate(localAnchorDate) {
132
+ const localAvailableRange = getAvailableRange(localAnchorDate);
133
+ const isDateInvalid = (date) => this.isInvalid(date) || isInvalid(date, localAvailableRange?.start, localAvailableRange?.end);
134
+ let nextDay = localAnchorDate.add({ days: 1 });
135
+ if (isDateInvalid(nextDay)) nextDay = localAnchorDate.subtract({ days: 1 });
136
+ if (!isDateInvalid(nextDay)) {
137
+ calendar.setFocusedDate(nextDay);
138
+ calendar.setFocused(true);
139
+ }
140
+ },
141
+ highlightDate(date) {
142
+ if (anchorDate()) calendar.setFocusedDate(date);
143
+ },
144
+ get highlightedRange() {
145
+ return highlightedRange();
146
+ },
147
+ get isDragging() {
148
+ return isDragging();
149
+ },
150
+ isInvalid(date) {
151
+ return calendar.isInvalid(date) || isInvalid(date, availableRange()?.start, availableRange()?.end);
152
+ },
153
+ isSelected(date) {
154
+ const currentHighlightedRange = highlightedRange();
155
+ return Boolean(currentHighlightedRange && date.compare(currentHighlightedRange.start) >= 0 && date.compare(currentHighlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date));
156
+ },
157
+ get isValueInvalid() {
158
+ return isValueInvalid();
159
+ },
160
+ selectDate,
161
+ selectFocusedDate() {
162
+ if (!calendar.isCellUnavailable(calendar.focusedDate)) selectDate(calendar.focusedDate);
163
+ },
164
+ setAnchorDate,
165
+ setDragging,
166
+ setValue,
167
+ get validationState() {
168
+ return validationState();
169
+ },
170
+ get value() {
171
+ return value();
172
+ }
173
+ });
174
+ }
175
+ function makeRange(initialStart, initialEnd) {
176
+ let start = initialStart;
177
+ let end = initialEnd;
178
+ if (end.compare(start) < 0) [start, end] = [end, start];
179
+ return {
180
+ end: toCalendarDate(end),
181
+ start: toCalendarDate(start)
182
+ };
183
+ }
184
+ function convertValue(initialNewValue, oldValue) {
185
+ let newValue = initialNewValue;
186
+ newValue = toCalendar(newValue, oldValue?.calendar ?? new GregorianCalendar());
187
+ if (oldValue && "hour" in oldValue) return oldValue.set(newValue);
188
+ return newValue;
189
+ }
190
+ function nextUnavailableDate(anchorDate, isDateUnavailable, visibleDuration, dir) {
191
+ let nextDate = anchorDate.add({ days: dir });
192
+ const localMinDate = anchorDate.subtract(visibleDuration);
193
+ const localMaxDate = anchorDate.add(visibleDuration);
194
+ while (!isDateUnavailable(nextDate)) {
195
+ if (dir < 0 ? nextDate.compare(localMinDate) < 0 : nextDate.compare(localMaxDate) > 0) break;
196
+ const following = nextDate.add({ days: dir });
197
+ if (following.compare(nextDate) === 0) return;
198
+ nextDate = following;
199
+ }
200
+ if (isDateUnavailable(nextDate)) return nextDate.add({ days: -dir });
201
+ }
202
+ export { createRangeCalendarState };
203
+
204
+ //# sourceMappingURL=create-range-calendar-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-range-calendar-state.js","names":[],"sources":["../../src/calendar/create-range-calendar-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/calendar/useRangeCalendarState.ts.\n * Modified for Solid Aria: adapted state, collection descriptors, 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 GregorianCalendar,\n maxDate,\n minDate,\n toCalendar,\n toCalendarDate,\n} from \"@internationalized/date\";\nimport type {\n CalendarDate,\n Calendar,\n CalendarIdentifier,\n DateDuration,\n} from \"@internationalized/date\";\nimport type { RangeValue, ValueBase } from \"@solid2-aria/types-shared\";\nimport { createMemo, createSignal, untrack, merge, omit } from \"solid-js\";\n\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { getLegacyValidationState } from \"../utils/legacy-props\";\nimport { createCalendarState } from \"./create-calendar-state\";\nimport type {\n CalendarPropsBase,\n DateValue,\n MappedDateValue,\n RangeCalendarState,\n} from \"./types\";\nimport {\n alignCenter,\n constrainValue,\n isInvalid,\n previousAvailableDate,\n} from \"./utils\";\n\nexport type DateRange = RangeValue<DateValue> | null;\n\nexport interface RangeCalendarProps<T extends DateValue>\n extends\n CalendarPropsBase,\n ValueBase<RangeValue<T> | null, RangeValue<MappedDateValue<T>>> {\n /**\n * When combined with `isDateUnavailable`, determines whether non-contiguous ranges,\n * i.e. ranges containing unavailable dates, may be selected.\n */\n allowsNonContiguousRanges?: boolean;\n /**\n * Callback that is called for each date of the calendar. If it returns true, then the date is\n * unavailable. The second argument provides the current selection anchor date, if any. This can\n * be used to adjust the available dates based on the user's first selected date.\n */\n isDateUnavailable?: (\n date: DateValue,\n anchorDate: CalendarDate | null\n ) => boolean;\n}\n\nexport interface RangeCalendarStateOptions<\n T extends DateValue = DateValue,\n> extends RangeCalendarProps<T> {\n /** The locale to display and edit the value according to. */\n locale: string;\n /**\n * A function that creates a [Calendar](../internationalized/date/Calendar.html)\n * object for a given calendar identifier. Such a function may be imported from the\n * `@internationalized/date` package, or manually implemented to include support for\n * only certain calendars.\n */\n createCalendar: (name: CalendarIdentifier) => Calendar;\n /**\n * The amount of days that will be displayed at once. This affects how pagination works.\n *\n * @default { months: 1 }\n */\n visibleDuration?: DateDuration;\n /**\n * Determines the alignment of the visible months on initial render based on the current selection\n * or current date if there is no selection.\n *\n * @default 'center'\n */\n selectionAlignment?: \"start\" | \"center\" | \"end\";\n}\n\n/**\n * Provides state management for a range calendar component. A range calendar displays one or more\n * date grids and allows users to select a contiguous range of dates.\n */\nexport function createRangeCalendarState<T extends DateValue = DateValue>(\n props: RangeCalendarStateOptions<T>\n): RangeCalendarState<T> {\n const locale = createMemo(() => props.locale);\n\n const visibleDuration = createMemo(\n () => props.visibleDuration ?? { months: 1 }\n );\n\n const minValue = createMemo(() => props.minValue);\n const maxValue = createMemo(() => props.maxValue);\n\n const [value, setValue] = createControlledSignal<RangeValue<T> | null>(\n () => props.value,\n untrack(() => props.defaultValue) ?? null,\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions, typescript/no-unsafe-type-assertion -- SAFETY: values retain the input date class and selection shape; preserve the upstream mapped callback contract when clearing.\n (v) => props.onChange?.(v as unknown as RangeValue<MappedDateValue<T>>)\n );\n\n const [anchorDate, setAnchorDate] = createSignal<CalendarDate | null>(null);\n\n const alignment = createMemo(() => {\n const currentValue = value();\n const currentVisibleDuration = visibleDuration();\n let localAlignment: \"center\" | \"start\" = \"center\";\n\n if (\n currentValue &&\n Boolean(currentValue.start) &&\n Boolean(currentValue.end)\n ) {\n const start = alignCenter(\n toCalendarDate(currentValue.start),\n currentVisibleDuration,\n locale(),\n minValue(),\n maxValue()\n );\n\n const end = start.add(currentVisibleDuration).subtract({ days: 1 });\n\n if (currentValue.end.compare(end) > 0) {\n localAlignment = \"start\";\n }\n }\n\n return localAlignment;\n });\n\n const isDateUnavailable = createMemo<\n ((date: DateValue) => boolean) | undefined\n >(() => {\n const { isDateUnavailable: localIsDateUnavailable } = props;\n\n return localIsDateUnavailable\n ? // oxlint-disable-next-line solid/reactivity -- The returned callback runs in its consumer's scope.\n (date: DateValue) => localIsDateUnavailable(date, anchorDate())\n : undefined;\n });\n\n const getAvailableRange = (localAnchorDate: CalendarDate | null) => {\n const currentIsDateUnavailable = isDateUnavailable();\n const currentVisibleDuration = visibleDuration();\n\n if (\n localAnchorDate &&\n currentIsDateUnavailable &&\n !(props.allowsNonContiguousRanges === true)\n ) {\n const nextAvailableStartDate = nextUnavailableDate(\n localAnchorDate,\n currentIsDateUnavailable,\n currentVisibleDuration,\n -1\n );\n\n const nextAvailableEndDate = nextUnavailableDate(\n localAnchorDate,\n currentIsDateUnavailable,\n currentVisibleDuration,\n 1\n );\n\n return {\n end: nextAvailableEndDate,\n start: nextAvailableStartDate,\n };\n }\n\n return null;\n };\n\n const availableRange = createMemo(() => {\n const currentAnchorDate = anchorDate();\n\n return getAvailableRange(currentAnchorDate);\n });\n\n const min = createMemo(() => maxDate(minValue(), availableRange()?.start));\n const max = createMemo(() => minDate(maxValue(), availableRange()?.end));\n\n const calendar = createCalendarState(\n merge(\n omit(props, \"value\", \"defaultValue\", \"onChange\", \"isDateUnavailable\"),\n {\n defaultValue: null,\n get isDateUnavailable() {\n const currentIsDateUnavailable = isDateUnavailable();\n\n return currentIsDateUnavailable;\n },\n get maxValue() {\n return max();\n },\n get minValue() {\n return min();\n },\n onChange: undefined,\n get selectionAlignment() {\n return props.selectionAlignment ?? alignment();\n },\n get value() {\n const currentValue = value();\n\n return currentValue && currentValue.start;\n },\n }\n )\n );\n\n const highlightedRange = createMemo(() => {\n const currentAnchorDate = anchorDate();\n const currentValue = value();\n\n return currentAnchorDate\n ? makeRange(currentAnchorDate, calendar.focusedDate)\n : currentValue && makeRange(currentValue.start, currentValue.end);\n });\n\n const selectDate = (date: CalendarDate) => {\n const currentIsDateUnavailable = isDateUnavailable();\n const currentAnchorDate = anchorDate();\n const currentValue = value();\n\n if (props.isReadOnly === true || props.isDisabled === true) {\n return;\n }\n\n const constrainedDate = constrainValue(date, min(), max());\n\n const previousAvailableConstrainedDate = previousAvailableDate(\n constrainedDate,\n calendar.visibleRange.start,\n currentIsDateUnavailable\n );\n\n if (!previousAvailableConstrainedDate) {\n return;\n }\n\n if (currentAnchorDate) {\n const range = makeRange(\n currentAnchorDate,\n previousAvailableConstrainedDate\n );\n\n if (range) {\n setValue({\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- SAFETY: conversion preserves the input calendar and date class, including time and time zone.\n end: convertValue(range.end, currentValue?.end) as T,\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- SAFETY: conversion preserves the input calendar and date class, including time and time zone.\n start: convertValue(range.start, currentValue?.start) as T,\n });\n }\n\n setAnchorDate(null);\n } else {\n setAnchorDate(previousAvailableConstrainedDate);\n }\n };\n\n const [isDragging, setDragging] = createSignal(false);\n\n const isInvalidSelection = createMemo(() => {\n const currentValue = value();\n const currentAnchorDate = anchorDate();\n const currentIsDateUnavailable = isDateUnavailable();\n\n if (!currentValue || currentAnchorDate) {\n return false;\n }\n\n if (\n currentIsDateUnavailable &&\n (currentIsDateUnavailable(currentValue.start) ||\n currentIsDateUnavailable(currentValue.end))\n ) {\n return true;\n }\n\n return (\n isInvalid(currentValue.start, minValue(), maxValue()) ||\n isInvalid(currentValue.end, minValue(), maxValue())\n );\n });\n\n const isValueInvalid = createMemo(\n () =>\n props.isInvalid === true ||\n getLegacyValidationState(props) === \"invalid\" ||\n isInvalidSelection()\n );\n\n const validationState = createMemo(() =>\n isValueInvalid() ? \"invalid\" : null\n );\n\n return merge(calendar, {\n get anchorDate() {\n const currentAnchorDate = anchorDate();\n\n return currentAnchorDate;\n },\n clearSelection() {\n setAnchorDate(null);\n setValue(null);\n },\n commitSelection() {\n selectDate(calendar.focusedDate);\n },\n focusNearestAvailableDate(localAnchorDate: CalendarDate) {\n const localAvailableRange = getAvailableRange(localAnchorDate);\n\n const isDateInvalid = (date: CalendarDate) =>\n this.isInvalid(date) ||\n isInvalid(date, localAvailableRange?.start, localAvailableRange?.end);\n\n let nextDay = localAnchorDate.add({ days: 1 });\n\n if (isDateInvalid(nextDay)) {\n nextDay = localAnchorDate.subtract({ days: 1 });\n }\n\n if (!isDateInvalid(nextDay)) {\n calendar.setFocusedDate(nextDay);\n calendar.setFocused(true);\n }\n },\n highlightDate(date: CalendarDate) {\n const currentAnchorDate = anchorDate();\n\n if (currentAnchorDate) {\n calendar.setFocusedDate(date);\n }\n },\n get highlightedRange() {\n const currentHighlightedRange = highlightedRange();\n\n return currentHighlightedRange;\n },\n get isDragging() {\n return isDragging();\n },\n isInvalid(date: CalendarDate) {\n return (\n calendar.isInvalid(date) ||\n isInvalid(date, availableRange()?.start, availableRange()?.end)\n );\n },\n isSelected(date: CalendarDate) {\n const currentHighlightedRange = highlightedRange();\n\n return Boolean(\n currentHighlightedRange &&\n date.compare(currentHighlightedRange.start) >= 0 &&\n date.compare(currentHighlightedRange.end) <= 0 &&\n !calendar.isCellDisabled(date) &&\n !calendar.isCellUnavailable(date)\n );\n },\n get isValueInvalid() {\n return isValueInvalid();\n },\n selectDate,\n selectFocusedDate() {\n if (!calendar.isCellUnavailable(calendar.focusedDate)) {\n selectDate(calendar.focusedDate);\n }\n },\n setAnchorDate,\n setDragging,\n setValue,\n get validationState() {\n return validationState();\n },\n get value() {\n const currentValue = value();\n\n return currentValue;\n },\n });\n}\n\nfunction makeRange(\n initialStart: DateValue,\n initialEnd: DateValue\n): RangeValue<CalendarDate> | null {\n let start = initialStart;\n let end = initialEnd;\n\n if (end.compare(start) < 0) {\n [start, end] = [end, start];\n }\n\n return { end: toCalendarDate(end), start: toCalendarDate(start) };\n}\n\nfunction convertValue(\n initialNewValue: CalendarDate,\n oldValue?: DateValue\n): DateValue {\n let newValue = initialNewValue;\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(\n newValue,\n oldValue?.calendar ?? new GregorianCalendar()\n );\n\n // Preserve time if the input value had one.\n if (oldValue && \"hour\" in oldValue) {\n return oldValue.set(newValue);\n }\n\n return newValue;\n}\n\nfunction nextUnavailableDate(\n anchorDate: CalendarDate,\n isDateUnavailable: (date: CalendarDate) => boolean,\n visibleDuration: DateDuration,\n dir: number\n): CalendarDate | undefined {\n let nextDate = anchorDate.add({ days: dir });\n const localMinDate = anchorDate.subtract(visibleDuration);\n const localMaxDate = anchorDate.add(visibleDuration);\n\n while (!isDateUnavailable(nextDate)) {\n if (\n dir < 0\n ? nextDate.compare(localMinDate) < 0\n : nextDate.compare(localMaxDate) > 0\n ) {\n break;\n }\n\n const following = nextDate.add({ days: dir });\n\n if (following.compare(nextDate) === 0) {\n return undefined;\n }\n\n nextDate = following;\n }\n\n if (isDateUnavailable(nextDate)) {\n return nextDate.add({ days: -dir });\n }\n\n return undefined;\n}\n"],"mappings":"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"}
@@ -0,0 +1,222 @@
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/calendar/types.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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 { Element } from "solid-js";
18
+ import { CalendarDate, CalendarDateTime, DateDuration, ZonedDateTime } from "@internationalized/date";
19
+ import { RangeValue, ValidationState } from "@solid2-aria/types-shared";
20
+ export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
21
+ export type MappedDateValue<T> = T extends ZonedDateTime ? ZonedDateTime : T extends CalendarDateTime ? CalendarDateTime : T extends CalendarDate ? CalendarDate : never;
22
+ export type PageBehavior = "single" | "visible";
23
+ export interface CalendarPropsBase {
24
+ /** The minimum allowed date that a user may select. */
25
+ minValue?: DateValue | null;
26
+ /** The maximum allowed date that a user may select. */
27
+ maxValue?: DateValue | null;
28
+ /**
29
+ * Whether the calendar is disabled.
30
+ *
31
+ * @default false
32
+ */
33
+ isDisabled?: boolean;
34
+ /**
35
+ * Whether the calendar value is immutable.
36
+ *
37
+ * @default false
38
+ */
39
+ isReadOnly?: boolean;
40
+ /**
41
+ * Whether to automatically focus the calendar when it mounts.
42
+ *
43
+ * @default false
44
+ */
45
+ autoFocus?: boolean;
46
+ /** Controls the currently focused date within the calendar. */
47
+ focusedValue?: DateValue | null;
48
+ /** The date that is focused when the calendar first mounts (uncontrolled). */
49
+ defaultFocusedValue?: DateValue | null;
50
+ /** Handler that is called when the focused date changes. */
51
+ onFocusChange?: (date: CalendarDate) => void;
52
+ /**
53
+ * Whether the current selection is valid or invalid according to application logic.
54
+ *
55
+ * @deprecated Use `isInvalid` instead.
56
+ */
57
+ validationState?: ValidationState;
58
+ /** Whether the current selection is invalid according to application logic. */
59
+ isInvalid?: boolean;
60
+ /** An error message to display when the selected value is invalid. */
61
+ errorMessage?: Element;
62
+ /**
63
+ * Controls the behavior of paging. Pagination either works by advancing the visible page by
64
+ * visibleDuration (default) or one unit of visibleDuration.
65
+ *
66
+ * @default visible
67
+ */
68
+ pageBehavior?: PageBehavior;
69
+ /**
70
+ * The day that starts the week.
71
+ */
72
+ firstDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
73
+ /**
74
+ * Determines the alignment of the visible months on initial render based on the current selection
75
+ * or current date if there is no selection.
76
+ *
77
+ * @default 'center'
78
+ */
79
+ selectionAlignment?: "start" | "center" | "end";
80
+ /**
81
+ * The number of weeks in a month. This overrides the default set by the locale.
82
+ */
83
+ weeksInMonth?: number;
84
+ }
85
+ interface CalendarStateBase {
86
+ /** Whether the calendar is disabled. */
87
+ readonly isDisabled: boolean;
88
+ /** Whether the calendar is in a read only state. */
89
+ readonly isReadOnly: boolean;
90
+ /** The visible duration in the calendar. */
91
+ readonly visibleDuration: DateDuration;
92
+ /** The date range that is currently visible in the calendar. */
93
+ readonly visibleRange: RangeValue<CalendarDate>;
94
+ /** The minimum allowed date that a user may select. */
95
+ readonly minValue?: DateValue | null;
96
+ /** The maximum allowed date that a user may select. */
97
+ readonly maxValue?: DateValue | null;
98
+ /** The time zone of the dates currently being displayed. */
99
+ readonly timeZone: string;
100
+ /**
101
+ * The current validation state of the selected value.
102
+ *
103
+ * @deprecated Use `isValueInvalid` instead.
104
+ */
105
+ readonly validationState: ValidationState | null;
106
+ /** Whether the calendar is invalid. */
107
+ readonly isValueInvalid: boolean;
108
+ /** The currently focused date. */
109
+ readonly focusedDate: CalendarDate;
110
+ /** Sets the focused date. */
111
+ setFocusedDate: (value: CalendarDate) => void;
112
+ /** Moves focus to the next calendar date. */
113
+ focusNextDay: () => void;
114
+ /** Moves focus to the previous calendar date. */
115
+ focusPreviousDay: () => void;
116
+ /** Moves focus to the next row of dates, e.g. the next week. */
117
+ focusNextRow: () => void;
118
+ /** Moves focus to the previous row of dates, e.g. the previous work. */
119
+ focusPreviousRow: () => void;
120
+ /** Moves focus to the next page of dates, e.g. the next month if one month is visible. */
121
+ focusNextPage: () => void;
122
+ /** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */
123
+ focusPreviousPage: () => void;
124
+ /** Moves focus to the start of the current section of dates, e.g. the start of the current month. */
125
+ focusSectionStart: () => void;
126
+ /**
127
+ * Moves focus to the end of the current section of dates, e.g. the end of the current month
128
+ * month.
129
+ */
130
+ focusSectionEnd: () => void;
131
+ /**
132
+ * Moves focus to the next section of dates based on what is currently displayed.
133
+ * By default, focus is moved by one of the currently displayed unit. For example, if
134
+ * one or more months are displayed, then focus is moved forward by one month.
135
+ * If the `larger` option is `true`, the focus is moved by the next larger unit than
136
+ * the one displayed. For example, if months are displayed, then focus moves to the next year.
137
+ */
138
+ focusNextSection: (larger?: boolean) => void;
139
+ /**
140
+ * Moves focus to the previous section of dates based on what is currently displayed.
141
+ * By default, focus is moved by one of the currently displayed unit. For example, if
142
+ * one or more months are displayed, then focus is moved backward by one month.
143
+ * If the `larger` option is `true`, the focus is moved by the next larger unit than
144
+ * the one displayed. For example, if months are displayed, then focus moves to the previous year.
145
+ */
146
+ focusPreviousSection: (larger?: boolean) => void;
147
+ /** Selects the currently focused date. */
148
+ selectFocusedDate: () => void;
149
+ /** Selects the given date. */
150
+ selectDate: (date: CalendarDate) => void;
151
+ /** Whether focus is currently within the calendar. */
152
+ readonly isFocused: boolean;
153
+ /** Sets whether focus is currently within the calendar. */
154
+ setFocused: (value: boolean) => void;
155
+ /** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */
156
+ isInvalid: (date: CalendarDate) => boolean;
157
+ /** Returns whether the given date is currently selected. */
158
+ isSelected: (date: CalendarDate) => boolean;
159
+ /** Returns whether the given date is currently focused. */
160
+ isCellFocused: (date: CalendarDate) => boolean;
161
+ /**
162
+ * Returns whether the given date is disabled according to the `minValue, `maxValue`, and
163
+ * `isDisabled` props.
164
+ */
165
+ isCellDisabled: (date: CalendarDate) => boolean;
166
+ /** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */
167
+ isCellUnavailable: (date: CalendarDate) => boolean;
168
+ /**
169
+ * Returns whether the previous visible date range is allowed to be selected according to the
170
+ * `minValue` prop.
171
+ */
172
+ isPreviousVisibleRangeInvalid: () => boolean;
173
+ /**
174
+ * Returns whether the next visible date range is allowed to be selected according to the
175
+ * `maxValue` prop.
176
+ */
177
+ isNextVisibleRangeInvalid: () => boolean;
178
+ /**
179
+ * Returns an array of dates in the week index counted from the provided start date, or the first
180
+ * visible date if not given. The returned array always has 7 elements, but may include null if
181
+ * the date does not exist according to the calendar system.
182
+ */
183
+ getDatesInWeek: (weekIndex: number, startDate?: CalendarDate) => (CalendarDate | null)[];
184
+ /** Returns the number of weeks in a month. */
185
+ getWeeksInMonth: (startDate?: CalendarDate) => number;
186
+ }
187
+ export type CalendarSelectionMode = "single" | "multiple";
188
+ export type CalendarValueType<T, M extends CalendarSelectionMode> = M extends "single" ? T : readonly T[];
189
+ export interface CalendarState<M extends CalendarSelectionMode = "single"> extends CalendarStateBase {
190
+ /** Whether single or multiple selection is enabled. */
191
+ readonly selectionMode: M;
192
+ /** The currently selected date. */
193
+ readonly value: CalendarValueType<CalendarDate | null, M>;
194
+ /** Sets the currently selected date. */
195
+ setValue: (value: CalendarValueType<CalendarDate | null, M>) => void;
196
+ }
197
+ export interface RangeCalendarState<T extends DateValue = DateValue> extends CalendarStateBase {
198
+ /** The currently selected date range. */
199
+ readonly value: RangeValue<T> | null;
200
+ /** Sets the currently selected date range. */
201
+ setValue: (value: RangeValue<T> | null) => void;
202
+ /** Highlights the given date during selection, e.g. by hovering or dragging. */
203
+ highlightDate: (date: CalendarDate) => void;
204
+ /** The current anchor date that the user clicked on to begin range selection. */
205
+ readonly anchorDate: CalendarDate | null;
206
+ /** Sets the anchor date that the user clicked on to begin range selection. */
207
+ setAnchorDate: (date: CalendarDate | null) => void;
208
+ /** The currently highlighted date range. */
209
+ readonly highlightedRange: RangeValue<CalendarDate> | null;
210
+ /** Whether the user is currently dragging over the calendar. */
211
+ readonly isDragging: boolean;
212
+ /** Sets whether the user is dragging over the calendar. */
213
+ setDragging: (isDragging: boolean) => void;
214
+ /** Clears the current selection. */
215
+ clearSelection: () => void;
216
+ /** Commits the current selection. */
217
+ commitSelection: () => void;
218
+ /** Focuses the next available day before or after the anchor date. */
219
+ focusNearestAvailableDate: (anchorDate: CalendarDate) => void;
220
+ }
221
+ export {};
222
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,16 @@
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/calendar/types.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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
+ */
@@ -0,0 +1,27 @@
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/calendar/utils.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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 } from "./types.js";
18
+ import { CalendarDate, DateDuration } from "@internationalized/date";
19
+ export declare function isInvalid(date: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
20
+ export declare function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate;
21
+ export declare function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate;
22
+ export declare function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate;
23
+ export declare function constrainStart(date: CalendarDate, initialAligned: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate;
24
+ export declare function constrainValue(initialDate: CalendarDate, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate;
25
+ export declare function previousAvailableDate(initialDate: CalendarDate, minValue: DateValue, isDateUnavailable?: (date: CalendarDate) => boolean): CalendarDate | null;
26
+ export declare function isEqualDuration(a: DateDuration, b: DateDuration): boolean;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,81 @@
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/calendar/utils.ts.
14
+ * Modified for Solid Aria: adapted state, collection descriptors, 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 { maxDate, minDate, startOfMonth, startOfWeek, startOfYear, toCalendarDate } from "@internationalized/date";
18
+ // src/calendar/utils.ts
19
+ function isInvalid(date, minValue, maxValue) {
20
+ return minValue !== null && minValue !== void 0 && date.compare(minValue) < 0 || maxValue !== null && maxValue !== void 0 && date.compare(maxValue) > 0;
21
+ }
22
+ function alignCenter(date, duration, locale, minValue, maxValue) {
23
+ const halfDuration = {};
24
+ for (const key of [
25
+ "years",
26
+ "months",
27
+ "weeks",
28
+ "days"
29
+ ]) {
30
+ halfDuration[key] = Math.floor((duration[key] ?? 0) / 2);
31
+ if (halfDuration[key] > 0 && (duration[key] ?? 0) % 2 === 0) halfDuration[key] -= 1;
32
+ }
33
+ return constrainStart(date, alignStart(date, duration, locale).subtract(halfDuration), duration, locale, minValue, maxValue);
34
+ }
35
+ function alignStart(date, duration, locale, minValue, maxValue) {
36
+ let aligned = date;
37
+ if (duration.years !== void 0 && duration.years !== 0 && !Number.isNaN(duration.years)) aligned = startOfYear(date);
38
+ else if (duration.months !== void 0 && duration.months !== 0 && !Number.isNaN(duration.months)) aligned = startOfMonth(date);
39
+ else if (duration.weeks !== void 0 && duration.weeks !== 0 && !Number.isNaN(duration.weeks) || duration.days !== void 0 && duration.days !== 0 && !Number.isNaN(duration.days) && duration.days > 7) aligned = startOfWeek(date, locale);
40
+ return constrainStart(date, aligned, duration, locale, minValue, maxValue);
41
+ }
42
+ function alignEnd(date, duration, locale, minValue, maxValue) {
43
+ const d = { ...duration };
44
+ if (d.days !== void 0 && d.days !== 0 && !Number.isNaN(d.days)) d.days -= 1;
45
+ else if (d.weeks !== void 0 && d.weeks !== 0 && !Number.isNaN(d.weeks)) d.weeks -= 1;
46
+ else if (d.months !== void 0 && d.months !== 0 && !Number.isNaN(d.months)) d.months -= 1;
47
+ else if (d.years !== void 0 && d.years !== 0 && !Number.isNaN(d.years)) d.years -= 1;
48
+ return constrainStart(date, alignStart(date, duration, locale).subtract(d), duration, locale, minValue, maxValue);
49
+ }
50
+ function constrainStart(date, initialAligned, duration, locale, minValue, maxValue) {
51
+ let aligned = initialAligned;
52
+ if (minValue && date.compare(minValue) >= 0) {
53
+ const newDate = maxDate(aligned, alignStart(toCalendarDate(minValue), duration, locale));
54
+ if (newDate) aligned = newDate;
55
+ }
56
+ if (maxValue && date.compare(maxValue) <= 0) aligned = minDate(aligned, alignEnd(toCalendarDate(maxValue), duration, locale));
57
+ return aligned;
58
+ }
59
+ function constrainValue(initialDate, minValue, maxValue) {
60
+ let date = initialDate;
61
+ if (minValue) {
62
+ const newDate = maxDate(date, toCalendarDate(minValue));
63
+ if (newDate) date = newDate;
64
+ }
65
+ if (maxValue) date = minDate(date, toCalendarDate(maxValue));
66
+ return date;
67
+ }
68
+ function previousAvailableDate(initialDate, minValue, isDateUnavailable) {
69
+ let date = initialDate;
70
+ if (!isDateUnavailable) return date;
71
+ while (date.compare(minValue) >= 0 && isDateUnavailable(date)) date = date.subtract({ days: 1 });
72
+ if (date.compare(minValue) >= 0) return date;
73
+ return null;
74
+ }
75
+ function isEqualDuration(a, b) {
76
+ if (a === b) return true;
77
+ return a.days === b.days && a.weeks === b.weeks && a.months === b.months && a.years === b.years;
78
+ }
79
+ export { alignCenter, alignEnd, alignStart, constrainStart, constrainValue, isEqualDuration, isInvalid, previousAvailableDate };
80
+
81
+ //# sourceMappingURL=utils.js.map