@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,250 @@
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/data/useListData.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 { getItemKey } from "../utils/get-item-key.js";
18
+ import { createMemo, createSignal, merge, untrack } from "solid-js";
19
+ // src/data/create-list-data.ts
20
+ /**
21
+ * Manages state for an immutable list data structure, and provides convenience methods to
22
+ * update the data over time.
23
+ */
24
+ function createListData(options) {
25
+ const initialItems = createMemo(() => options.initialItems ?? []);
26
+ const initialSelectedKeys = createMemo(() => options.initialSelectedKeys);
27
+ const getKey = createMemo(() => options.getKey ?? getItemKey);
28
+ const filter = createMemo(() => options.filter);
29
+ const initialFilterText = createMemo(() => options.initialFilterText ?? "");
30
+ const [state, setState] = createSignal(untrack(() => {
31
+ const currentInitialItems = initialItems();
32
+ const currentInitialSelectedKeys = initialSelectedKeys();
33
+ return {
34
+ filterText: initialFilterText(),
35
+ items: currentInitialItems,
36
+ selectedKeys: currentInitialSelectedKeys === "all" ? "all" : new Set(currentInitialSelectedKeys)
37
+ };
38
+ }), { ownedWrite: true });
39
+ const filteredItems = createMemo(() => {
40
+ const currentFilter = filter();
41
+ const currentState = state();
42
+ return currentFilter ? currentState.items.filter((item) => currentFilter(item, currentState.filterText)) : currentState.items;
43
+ });
44
+ return merge({
45
+ get filterText() {
46
+ return state().filterText;
47
+ },
48
+ get selectedKeys() {
49
+ return state().selectedKeys;
50
+ }
51
+ }, { get items() {
52
+ return filteredItems();
53
+ } }, createListActions({ get getKey() {
54
+ return getKey();
55
+ } }, (update) => {
56
+ setState(update);
57
+ }), { getItem(key) {
58
+ return state().items.find((item) => {
59
+ return getKey()(item) === key;
60
+ });
61
+ } });
62
+ }
63
+ function createListActions(opts, dispatch) {
64
+ const getKey = (item) => (opts.getKey ?? getItemKey)(item);
65
+ return {
66
+ addKeysToSelection(selectedKeys) {
67
+ dispatch((state) => {
68
+ if (state.selectedKeys === "all") return state;
69
+ if (selectedKeys === "all") return {
70
+ ...state,
71
+ selectedKeys: "all"
72
+ };
73
+ return {
74
+ ...state,
75
+ selectedKeys: /* @__PURE__ */ new Set([...state.selectedKeys, ...selectedKeys])
76
+ };
77
+ });
78
+ },
79
+ append(...values) {
80
+ dispatch((state) => insert(state, state.items.length, ...values));
81
+ },
82
+ insert(index, ...values) {
83
+ dispatch((state) => insert(state, index, ...values));
84
+ },
85
+ insertAfter(key, ...values) {
86
+ dispatch((state) => {
87
+ let index = state.items.findIndex((item) => getKey?.(item) === key);
88
+ if (index === -1) {
89
+ if (state.items.length === 0) index = 0;
90
+ else return state;
91
+ }
92
+ return insert(state, index + 1, ...values);
93
+ });
94
+ },
95
+ insertBefore(key, ...values) {
96
+ dispatch((state) => {
97
+ let index = state.items.findIndex((item) => getKey?.(item) === key);
98
+ if (index === -1) {
99
+ if (state.items.length === 0) index = 0;
100
+ else return state;
101
+ }
102
+ return insert(state, index, ...values);
103
+ });
104
+ },
105
+ move(key, toIndex) {
106
+ dispatch((state) => {
107
+ const index = state.items.findIndex((item) => getKey(item) === key);
108
+ if (index === -1) return state;
109
+ const copy = [...state.items];
110
+ const removed = copy.splice(index, 1);
111
+ copy.splice(toIndex, 0, ...removed);
112
+ return {
113
+ ...state,
114
+ items: copy
115
+ };
116
+ });
117
+ },
118
+ moveAfter(key, keys) {
119
+ dispatch((state) => {
120
+ const toIndex = state.items.findIndex((item) => getKey(item) === key);
121
+ if (toIndex === -1) return state;
122
+ return move(state, [...keys].map((localKey) => state.items.findIndex((item) => getKey(item) === localKey)).toSorted((a, b) => a - b), toIndex + 1);
123
+ });
124
+ },
125
+ moveBefore(key, keys) {
126
+ dispatch((state) => {
127
+ const toIndex = state.items.findIndex((item) => getKey(item) === key);
128
+ if (toIndex === -1) return state;
129
+ return move(state, [...keys].map((localKey) => state.items.findIndex((item) => getKey(item) === localKey)).toSorted((a, b) => a - b), toIndex);
130
+ });
131
+ },
132
+ prepend(...values) {
133
+ dispatch((state) => insert(state, 0, ...values));
134
+ },
135
+ remove(...keys) {
136
+ dispatch((state) => {
137
+ const keySet = new Set(keys);
138
+ const items = state.items.filter((item) => !keySet.has(getKey(item)));
139
+ let selection = "all";
140
+ if (state.selectedKeys !== "all") {
141
+ selection = new Set(state.selectedKeys);
142
+ for (const key of keys) selection.delete(key);
143
+ }
144
+ if ((opts.cursor === null || opts.cursor === void 0) && items.length === 0) selection = /* @__PURE__ */ new Set();
145
+ return {
146
+ ...state,
147
+ items,
148
+ selectedKeys: selection
149
+ };
150
+ });
151
+ },
152
+ removeKeysFromSelection(selectedKeys) {
153
+ dispatch((state) => {
154
+ if (selectedKeys === "all") return {
155
+ ...state,
156
+ selectedKeys: /* @__PURE__ */ new Set()
157
+ };
158
+ const selection = state.selectedKeys === "all" ? new Set(state.items.map(getKey)) : new Set(state.selectedKeys);
159
+ for (const key of selectedKeys) selection.delete(key);
160
+ return {
161
+ ...state,
162
+ selectedKeys: selection
163
+ };
164
+ });
165
+ },
166
+ removeSelectedItems() {
167
+ dispatch((state) => {
168
+ if (state.selectedKeys === "all") return {
169
+ ...state,
170
+ items: [],
171
+ selectedKeys: /* @__PURE__ */ new Set()
172
+ };
173
+ const { selectedKeys } = state;
174
+ const items = state.items.filter((item) => !selectedKeys.has(getKey(item)));
175
+ return {
176
+ ...state,
177
+ items,
178
+ selectedKeys: /* @__PURE__ */ new Set()
179
+ };
180
+ });
181
+ },
182
+ setFilterText(filterText) {
183
+ dispatch((state) => ({
184
+ ...state,
185
+ filterText
186
+ }));
187
+ },
188
+ setSelectedKeys(selectedKeys) {
189
+ dispatch((state) => ({
190
+ ...state,
191
+ selectedKeys
192
+ }));
193
+ },
194
+ update(key, newValue) {
195
+ dispatch((state) => {
196
+ const index = state.items.findIndex((item) => getKey(item) === key);
197
+ if (index === -1) return state;
198
+ const items = state.items.map((item, itemIndex) => {
199
+ if (itemIndex !== index) return item;
200
+ if (typeof newValue === "function") return newValue(item);
201
+ return newValue;
202
+ });
203
+ return {
204
+ ...state,
205
+ items
206
+ };
207
+ });
208
+ }
209
+ };
210
+ }
211
+ function insert(state, index, ...values) {
212
+ return {
213
+ ...state,
214
+ items: [
215
+ ...state.items.slice(0, index),
216
+ ...values,
217
+ ...state.items.slice(index)
218
+ ]
219
+ };
220
+ }
221
+ function move(state, indices, initialToIndex) {
222
+ let toIndex = initialToIndex;
223
+ toIndex -= indices.filter((index) => index < toIndex).length;
224
+ const moves = indices.map((from) => {
225
+ const localMove = {
226
+ from,
227
+ to: toIndex
228
+ };
229
+ toIndex += 1;
230
+ return localMove;
231
+ });
232
+ for (const [i, currentMove] of moves.entries()) {
233
+ const a = currentMove.from;
234
+ for (const laterMove of moves.slice(i)) if (laterMove.from > a) laterMove.from -= 1;
235
+ }
236
+ for (const [i, a] of moves.entries()) for (const b of moves.slice(i + 1).toReversed()) if (b.from < a.to) a.to += 1;
237
+ else b.from += 1;
238
+ const copy = [...state.items];
239
+ for (const localMove of moves) {
240
+ const removed = copy.splice(localMove.from, 1);
241
+ copy.splice(localMove.to, 0, ...removed);
242
+ }
243
+ return {
244
+ ...state,
245
+ items: copy
246
+ };
247
+ }
248
+ export { createListActions, createListData };
249
+
250
+ //# sourceMappingURL=create-list-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-list-data.js","names":[],"sources":["../../src/data/create-list-data.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/data/useListData.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 type { Key, Selection } from \"@solid2-aria/types-shared\";\nimport { createMemo, createSignal, untrack, merge } from \"solid-js\";\n\nimport { getItemKey } from \"../utils/get-item-key\";\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[];\n /** The keys for the initially selected items. */\n initialSelectedKeys?: \"all\" | Iterable<Key>;\n /** The initial text to filter the list by. */\n initialFilterText?: string;\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key;\n /** A function that returns whether a item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean;\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n items: T[];\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection;\n /** Sets the selected keys. */\n setSelectedKeys: (keys: Selection) => void;\n /** Adds the given keys to the current selected keys. */\n addKeysToSelection: (keys: Selection) => void;\n /** Removes the given keys from the current selected keys. */\n removeKeysFromSelection: (keys: Selection) => void;\n /** The current filter text. */\n filterText: string;\n /** Sets the filter text. */\n setFilterText: (filterText: string) => void;\n /**\n * Gets an item from the list by key.\n *\n * @param key - The key of the item to retrieve.\n */\n getItem: (key: Key) => T | undefined;\n /**\n * Inserts items into the list at the given index.\n *\n * @param index - The index to insert into.\n * @param values - The values to insert.\n */\n insert: (index: number, ...values: T[]) => void;\n /**\n * Inserts items into the list before the item at the given key.\n *\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore: (key: Key, ...values: T[]) => void;\n /**\n * Inserts items into the list after the item at the given key.\n *\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter: (key: Key, ...values: T[]) => void;\n /**\n * Appends items to the list.\n *\n * @param values - The values to insert.\n */\n append: (...values: T[]) => void;\n /**\n * Prepends items to the list.\n *\n * @param value - The value to insert.\n */\n prepend: (...values: T[]) => void;\n /**\n * Removes items from the list by their keys.\n *\n * @param keys - The keys of the item to remove.\n */\n remove: (...keys: Key[]) => void;\n /**\n * Removes all items from the list that are currently\n * in the set of selected items.\n */\n removeSelectedItems: () => void;\n /**\n * Moves an item within the list.\n *\n * @param key - The key of the item to move.\n * @param toIndex - The index to move the item to.\n */\n move: (key: Key, toIndex: number) => void;\n /**\n * Moves one or more items before a given key.\n *\n * @param key - The key of the item to move the items before.\n * @param keys - The keys of the items to move.\n */\n moveBefore: (key: Key, keys: Iterable<Key>) => void;\n /**\n * Moves one or more items after a given key.\n *\n * @param key - The key of the item to move the items after.\n * @param keys - The keys of the items to move.\n */\n moveAfter: (key: Key, keys: Iterable<Key>) => void;\n /**\n * Updates an item in the list.\n *\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item, or a function that returns the new value based on\n * the previous value.\n */\n update: (key: Key, newValue: T | ((prev: T) => T)) => void;\n}\n\nexport interface ListState<T> {\n items: T[];\n selectedKeys: Selection;\n filterText: string;\n}\n\ninterface CreateListOptions<T, C> extends ListOptions<T> {\n cursor?: C;\n}\n\n/**\n * Manages state for an immutable list data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function createListData<T>(options: ListOptions<T>): ListData<T> {\n const initialItems = createMemo(() => options.initialItems ?? []);\n const initialSelectedKeys = createMemo(() => options.initialSelectedKeys);\n const getKey = createMemo(() => options.getKey ?? getItemKey);\n const filter = createMemo(() => options.filter);\n const initialFilterText = createMemo(() => options.initialFilterText ?? \"\");\n\n // Store both items and filteredItems in state so we can go back to the unfiltered list\n const [state, setState] = createSignal<ListState<T>>(\n untrack(() => {\n const currentInitialItems = initialItems();\n const currentInitialSelectedKeys = initialSelectedKeys();\n const currentInitialFilterText = initialFilterText();\n\n return {\n filterText: currentInitialFilterText,\n items: currentInitialItems,\n selectedKeys:\n currentInitialSelectedKeys === \"all\"\n ? \"all\"\n : new Set(currentInitialSelectedKeys),\n };\n }),\n { ownedWrite: true }\n );\n\n const filteredItems = createMemo(() => {\n const currentFilter = filter();\n const currentState = state();\n\n return currentFilter\n ? currentState.items.filter((item) =>\n currentFilter(item, currentState.filterText)\n )\n : currentState.items;\n });\n\n return merge(\n {\n get filterText() {\n return state().filterText;\n },\n get selectedKeys() {\n return state().selectedKeys;\n },\n },\n {\n get items() {\n return filteredItems();\n },\n } satisfies Partial<ListData<T>>,\n createListActions(\n {\n get getKey() {\n return getKey();\n },\n },\n (update) => {\n setState(update);\n }\n ),\n {\n getItem(key: Key) {\n const currentState = state();\n\n return currentState.items.find((item) => {\n const currentGetKey = getKey();\n\n return currentGetKey(item) === key;\n });\n },\n } satisfies Partial<ListData<T>>\n );\n}\n\nexport function createListActions<T, C>(\n opts: CreateListOptions<T, C>,\n dispatch: (updater: (state: ListState<T>) => ListState<T>) => void\n): Omit<ListData<T>, \"items\" | \"selectedKeys\" | \"getItem\" | \"filterText\"> {\n const getKey = (item: T) => (opts.getKey ?? getItemKey)(item);\n\n return {\n addKeysToSelection(selectedKeys: Selection) {\n dispatch((state) => {\n if (state.selectedKeys === \"all\") {\n return state;\n }\n\n if (selectedKeys === \"all\") {\n return {\n ...state,\n selectedKeys: \"all\",\n };\n }\n\n return {\n ...state,\n selectedKeys: new Set([...state.selectedKeys, ...selectedKeys]),\n };\n });\n },\n append(...values: T[]) {\n dispatch((state) => insert(state, state.items.length, ...values));\n },\n insert(index: number, ...values: T[]) {\n dispatch((state) => insert(state, index, ...values));\n },\n insertAfter(key: Key, ...values: T[]) {\n dispatch((state) => {\n let index = state.items.findIndex((item) => getKey?.(item) === key);\n\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index + 1, ...values);\n });\n },\n insertBefore(key: Key, ...values: T[]) {\n dispatch((state) => {\n let index = state.items.findIndex((item) => getKey?.(item) === key);\n\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index, ...values);\n });\n },\n move(key: Key, toIndex: number) {\n dispatch((state) => {\n const index = state.items.findIndex((item) => getKey(item) === key);\n\n if (index === -1) {\n return state;\n }\n\n const copy = [...state.items];\n const removed = copy.splice(index, 1);\n copy.splice(toIndex, 0, ...removed);\n\n return {\n ...state,\n items: copy,\n };\n });\n },\n moveAfter(key: Key, keys: Iterable<Key>) {\n dispatch((state) => {\n const toIndex = state.items.findIndex((item) => getKey(item) === key);\n\n if (toIndex === -1) {\n return state;\n }\n\n const keyArray = [...keys];\n\n const indices = keyArray\n .map((localKey) =>\n state.items.findIndex((item) => getKey(item) === localKey)\n )\n .toSorted((a, b) => a - b);\n\n return move(state, indices, toIndex + 1);\n });\n },\n moveBefore(key: Key, keys: Iterable<Key>) {\n dispatch((state) => {\n const toIndex = state.items.findIndex((item) => getKey(item) === key);\n\n if (toIndex === -1) {\n return state;\n }\n\n // Find indices of keys to move. Sort them so that the order in the list is retained.\n const keyArray = [...keys];\n\n const indices = keyArray\n .map((localKey) =>\n state.items.findIndex((item) => getKey(item) === localKey)\n )\n .toSorted((a, b) => a - b);\n\n return move(state, indices, toIndex);\n });\n },\n prepend(...values: T[]) {\n dispatch((state) => insert(state, 0, ...values));\n },\n remove(...keys: Key[]) {\n dispatch((state) => {\n const keySet = new Set(keys);\n const items = state.items.filter((item) => !keySet.has(getKey(item)));\n let selection: Selection = \"all\";\n\n if (state.selectedKeys !== \"all\") {\n selection = new Set(state.selectedKeys);\n\n for (const key of keys) {\n selection.delete(key);\n }\n }\n\n if (\n (opts.cursor === null || opts.cursor === undefined) &&\n items.length === 0\n ) {\n selection = new Set();\n }\n\n return {\n ...state,\n items,\n selectedKeys: selection,\n };\n });\n },\n removeKeysFromSelection(selectedKeys: Selection) {\n dispatch((state) => {\n if (selectedKeys === \"all\") {\n return {\n ...state,\n selectedKeys: new Set(),\n };\n }\n\n const selection: Selection =\n state.selectedKeys === \"all\"\n ? new Set(state.items.map(getKey))\n : new Set(state.selectedKeys);\n\n for (const key of selectedKeys) {\n selection.delete(key);\n }\n\n return {\n ...state,\n selectedKeys: selection,\n };\n });\n },\n removeSelectedItems() {\n dispatch((state) => {\n if (state.selectedKeys === \"all\") {\n return {\n ...state,\n items: [],\n selectedKeys: new Set(),\n };\n }\n\n const { selectedKeys } = state;\n\n const items = state.items.filter(\n (item) => !selectedKeys.has(getKey(item))\n );\n\n return {\n ...state,\n items,\n selectedKeys: new Set(),\n };\n });\n },\n setFilterText(filterText: string) {\n dispatch((state) => ({\n ...state,\n filterText,\n }));\n },\n setSelectedKeys(selectedKeys: Selection) {\n dispatch((state) => ({\n ...state,\n selectedKeys,\n }));\n },\n update(key: Key, newValue: T | ((prev: T) => T)) {\n dispatch((state) => {\n const index = state.items.findIndex((item) => getKey(item) === key);\n\n if (index === -1) {\n return state;\n }\n\n const items = state.items.map((item, itemIndex) => {\n if (itemIndex !== index) {\n return item;\n }\n\n if (typeof newValue === \"function\") {\n // SAFETY: the public update contract treats functions as updaters, including when T is callable.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return (newValue as (prev: T) => T)(item);\n }\n\n return newValue;\n });\n\n return {\n ...state,\n items,\n };\n });\n },\n };\n}\n\nfunction insert<T>(\n state: ListState<T>,\n index: number,\n ...values: T[]\n): ListState<T> {\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n ...values,\n ...state.items.slice(index),\n ],\n };\n}\n\nfunction move<T>(\n state: ListState<T>,\n indices: number[],\n initialToIndex: number\n): ListState<T> {\n let toIndex = initialToIndex;\n\n // Shift the target down by the number of items being moved from before the target\n toIndex -= indices.filter((index) => index < toIndex).length;\n\n const moves = indices.map((from) => {\n const localMove = { from, to: toIndex };\n toIndex += 1;\n\n return localMove;\n });\n\n // Shift later from indices down if they have a larger index\n for (const [i, currentMove] of moves.entries()) {\n const a = currentMove.from;\n\n for (const laterMove of moves.slice(i)) {\n if (laterMove.from > a) {\n laterMove.from -= 1;\n }\n }\n }\n\n // Interleave the moves so they can be applied one by one rather than all at once\n for (const [i, a] of moves.entries()) {\n for (const b of moves.slice(i + 1).toReversed()) {\n if (b.from < a.to) {\n a.to += 1;\n } else {\n b.from += 1;\n }\n }\n }\n\n const copy = [...state.items];\n\n for (const localMove of moves) {\n const removed = copy.splice(localMove.from, 1);\n copy.splice(localMove.to, 0, ...removed);\n }\n\n return {\n ...state,\n items: copy,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiJA,SAAgB,eAAkB,SAAsC;CACtE,MAAM,eAAe,iBAAiB,QAAQ,gBAAgB,CAAC,CAAC;CAChE,MAAM,sBAAsB,iBAAiB,QAAQ,mBAAmB;CACxE,MAAM,SAAS,iBAAiB,QAAQ,UAAU,UAAU;CAC5D,MAAM,SAAS,iBAAiB,QAAQ,MAAM;CAC9C,MAAM,oBAAoB,iBAAiB,QAAQ,qBAAqB,EAAE;CAG1E,MAAM,CAAC,OAAO,YAAY,aACxB,cAAc;EACZ,MAAM,sBAAsB,aAAa;EACzC,MAAM,6BAA6B,oBAAoB;EAGvD,OAAO;GACL,YAH+B,kBAGI;GACnC,OAAO;GACP,cACE,+BAA+B,QAC3B,QACA,IAAI,IAAI,0BAA0B;EAC1C;CACF,CAAC,GACD,EAAE,YAAY,KAAK,CACrB;CAEA,MAAM,gBAAgB,iBAAiB;EACrC,MAAM,gBAAgB,OAAO;EAC7B,MAAM,eAAe,MAAM;EAE3B,OAAO,gBACH,aAAa,MAAM,QAAQ,SACzB,cAAc,MAAM,aAAa,UAAU,CAC7C,IACA,aAAa;CACnB,CAAC;CAED,OAAO,MACL;EACE,IAAI,aAAa;GACf,OAAO,MAAM,CAAC,CAAC;EACjB;EACA,IAAI,eAAe;GACjB,OAAO,MAAM,CAAC,CAAC;EACjB;CACF,GACA,EACE,IAAI,QAAQ;EACV,OAAO,cAAc;CACvB,EACF,GACA,kBACE,EACE,IAAI,SAAS;EACX,OAAO,OAAO;CAChB,EACF,IACC,WAAW;EACV,SAAS,MAAM;CACjB,CACF,GACA,EACE,QAAQ,KAAU;EAGhB,OAFqB,MAEH,CAAC,CAAC,MAAM,MAAM,SAAS;GAGvC,OAFsB,OAE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4B,IAAI;KAG1C,OAAO;IACT,CAAC;IAED,OAAO;KACL,GAAG;KACH;IACF;GACF,CAAC;EACH;CACF;AACF;AAEA,SAAS,OACP,OACA,OACA,GAAG,QACW;CACd,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAG,MAAM,MAAM,MAAM,GAAG,KAAK;GAC7B,GAAG;GACH,GAAG,MAAM,MAAM,MAAM,KAAK;EAC5B;CACF;AACF;AAEA,SAAS,KACP,OACA,SACA,gBACc;CACd,IAAI,UAAU;CAGd,WAAW,QAAQ,QAAQ,UAAU,QAAQ,OAAO,CAAC,CAAC;CAEtD,MAAM,QAAQ,QAAQ,KAAK,SAAS;EAClC,MAAM,YAAY;GAAE;GAAM,IAAI;EAAQ;EACtC,WAAW;EAEX,OAAO;CACT,CAAC;CAGD,KAAK,MAAM,CAAC,GAAG,gBAAgB,MAAM,QAAQ,GAAG;EAC9C,MAAM,IAAI,YAAY;EAEtB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,GACnC,IAAI,UAAU,OAAO,GACnB,UAAU,QAAQ;CAGxB;CAGA,KAAK,MAAM,CAAC,GAAG,MAAM,MAAM,QAAQ,GACjC,KAAK,MAAM,KAAK,MAAM,MAAM,IAAI,CAAC,CAAC,CAAC,WAAW,GAC5C,IAAI,EAAE,OAAO,EAAE,IACb,EAAE,MAAM;MAER,EAAE,QAAQ;CAKhB,MAAM,OAAO,CAAC,GAAG,MAAM,KAAK;CAE5B,KAAK,MAAM,aAAa,OAAO;EAC7B,MAAM,UAAU,KAAK,OAAO,UAAU,MAAM,CAAC;EAC7C,KAAK,OAAO,UAAU,IAAI,GAAG,GAAG,OAAO;CACzC;CAEA,OAAO;EACL,GAAG;EACH,OAAO;CACT;AACF"}
@@ -0,0 +1,134 @@
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/data/useTreeData.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 { Key } from "@solid2-aria/types-shared";
18
+ export interface TreeOptions<T extends object> {
19
+ /** Initial root items in the tree. */
20
+ initialItems?: T[];
21
+ /** The keys for the initially selected items. */
22
+ initialSelectedKeys?: Iterable<Key>;
23
+ /** A function that returns a unique key for an item object. */
24
+ getKey?: (item: T) => Key;
25
+ /** A function that returns the children for an item object. */
26
+ getChildren?: (item: T) => T[];
27
+ }
28
+ interface TreeNode<T extends object> {
29
+ /** A unique key for the tree node. */
30
+ key: Key;
31
+ /** The key of the parent node. */
32
+ parentKey?: Key | null;
33
+ /** The value object for the tree node. */
34
+ value: T;
35
+ /** Children of the tree node. */
36
+ children: TreeNode<T>[] | null;
37
+ }
38
+ export interface TreeData<T extends object> {
39
+ /** The root nodes in the tree. */
40
+ items: TreeNode<T>[];
41
+ /** The keys of the currently selected items in the tree. */
42
+ selectedKeys: Set<Key>;
43
+ /** Sets the selected keys. */
44
+ setSelectedKeys: (keys: Set<Key>) => void;
45
+ /**
46
+ * Gets a node from the tree by key.
47
+ *
48
+ * @param key - The key of the item to retrieve.
49
+ */
50
+ getItem: (key: Key) => TreeNode<T> | undefined;
51
+ /**
52
+ * Inserts an item into a parent node as a child.
53
+ *
54
+ * @param parentKey - The key of the parent item to insert into. `null` for the root.
55
+ * @param index - The index within the parent to insert into.
56
+ * @param value - The value to insert.
57
+ */
58
+ insert: (parentKey: Key | null, index: number, ...values: T[]) => void;
59
+ /**
60
+ * Inserts items into the list before the item at the given key.
61
+ *
62
+ * @param key - The key of the item to insert before.
63
+ * @param values - The values to insert.
64
+ */
65
+ insertBefore: (key: Key, ...values: T[]) => void;
66
+ /**
67
+ * Inserts items into the list after the item at the given key.
68
+ *
69
+ * @param key - The key of the item to insert after.
70
+ * @param values - The values to insert.
71
+ */
72
+ insertAfter: (key: Key, ...values: T[]) => void;
73
+ /**
74
+ * Appends an item into a parent node as a child.
75
+ *
76
+ * @param parentKey - The key of the parent item to insert into. `null` for the root.
77
+ * @param value - The value to insert.
78
+ */
79
+ append: (parentKey: Key | null, ...values: T[]) => void;
80
+ /**
81
+ * Prepends an item into a parent node as a child.
82
+ *
83
+ * @param parentKey - The key of the parent item to insert into. `null` for the root.
84
+ * @param value - The value to insert.
85
+ */
86
+ prepend: (parentKey: Key | null, ...value: T[]) => void;
87
+ /**
88
+ * Removes an item from the tree by its key.
89
+ *
90
+ * @param key - The key of the item to remove.
91
+ */
92
+ remove: (...keys: Key[]) => void;
93
+ /**
94
+ * Removes all items from the tree that are currently
95
+ * in the set of selected items.
96
+ */
97
+ removeSelectedItems: () => void;
98
+ /**
99
+ * Moves an item within the tree.
100
+ *
101
+ * @param key - The key of the item to move.
102
+ * @param toParentKey - The key of the new parent to insert into. `null` for the root.
103
+ * @param index - The index within the new parent to insert at.
104
+ */
105
+ move: (key: Key, toParentKey: Key | null, index: number) => void;
106
+ /**
107
+ * Moves one or more items before a given key.
108
+ *
109
+ * @param key - The key of the item to move the items before.
110
+ * @param keys - The keys of the items to move.
111
+ */
112
+ moveBefore: (key: Key, keys: Iterable<Key>) => void;
113
+ /**
114
+ * Moves one or more items after a given key.
115
+ *
116
+ * @param key - The key of the item to move the items after.
117
+ * @param keys - The keys of the items to move.
118
+ */
119
+ moveAfter: (key: Key, keys: Iterable<Key>) => void;
120
+ /**
121
+ * Updates an item in the tree.
122
+ *
123
+ * @param key - The key of the item to update.
124
+ * @param newValue - The new value for the item.
125
+ */
126
+ update: (key: Key, newValue: T) => void;
127
+ }
128
+ /**
129
+ * Manages state for an immutable tree data structure, and provides convenience methods to
130
+ * update the data over time.
131
+ */
132
+ export declare function createTreeData<T extends object>(options: TreeOptions<T>): TreeData<T>;
133
+ export {};
134
+ //# sourceMappingURL=create-tree-data.d.ts.map