@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,85 @@
1
+ /*
2
+ * Copyright 2024 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/layout/WaterfallLayout.ts.
14
+ * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state 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 { Size } from "../virtualizer/size.js";
18
+ import { Rect } from "../virtualizer/rect.js";
19
+ import { LayoutInfo } from "../virtualizer/layout-info.js";
20
+ import { InvalidationContext } from "../virtualizer/types.js";
21
+ import { Layout } from "../virtualizer/layout.js";
22
+ import { DropTarget, DropTargetDelegate, Key, LayoutDelegate, Node } from "@solid2-aria/types-shared";
23
+ export interface WaterfallLayoutOptions {
24
+ /**
25
+ * The minimum item size.
26
+ *
27
+ * @default 200 x 200
28
+ */
29
+ minItemSize?: Size;
30
+ /**
31
+ * The maximum item size.
32
+ *
33
+ * @default Infinity
34
+ */
35
+ maxItemSize?: Size;
36
+ /**
37
+ * The minimum space required between items.
38
+ *
39
+ * @default 18 x 18
40
+ */
41
+ minSpace?: Size;
42
+ /**
43
+ * The maximum allowed horizontal space between items.
44
+ *
45
+ * @default Infinity
46
+ */
47
+ maxHorizontalSpace?: number;
48
+ /**
49
+ * The maximum number of columns.
50
+ *
51
+ * @default Infinity
52
+ */
53
+ maxColumns?: number;
54
+ /**
55
+ * The thickness of the drop indicator.
56
+ *
57
+ * @default 2
58
+ */
59
+ dropIndicatorThickness?: number;
60
+ /**
61
+ * The fixed height of a loader element in px. This loader is specifically for "load more"
62
+ * elements rendered when loading more rows at the root level or inside nested row/sections.
63
+ *
64
+ * @default 48
65
+ */
66
+ loaderHeight?: number;
67
+ }
68
+ export declare class WaterfallLayout<T extends object, O extends WaterfallLayoutOptions = WaterfallLayoutOptions> extends Layout<Node<T>, O> implements LayoutDelegate, DropTargetDelegate {
69
+ private contentSize;
70
+ private layoutInfos;
71
+ protected numColumns: number;
72
+ protected dropIndicatorThickness: number;
73
+ private margin;
74
+ shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean;
75
+ update(invalidationContext: InvalidationContext<O>): void;
76
+ getLayoutInfo(key: Key): LayoutInfo | null;
77
+ getContentSize(): Size;
78
+ getVisibleLayoutInfos(rect: Rect): LayoutInfo[];
79
+ updateItemSize(key: Key, size: Size): boolean;
80
+ getKeyRightOf(key: Key): Key | null;
81
+ getKeyLeftOf(key: Key): Key | null;
82
+ getKeyRange(from: Key, to: Key): Key[];
83
+ getDropTargetFromPoint(initialX: number, initialY: number): DropTarget;
84
+ }
85
+ //# sourceMappingURL=waterfall-layout.d.ts.map
@@ -0,0 +1,225 @@
1
+ /*
2
+ * Copyright 2024 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/layout/WaterfallLayout.ts.
14
+ * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state 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 { getNodeProps } from "../utils/get-node-props.js";
18
+ import { requireValue } from "../utils/require-value.js";
19
+ import { Layout } from "../virtualizer/layout.js";
20
+ import { LayoutInfo } from "../virtualizer/layout-info.js";
21
+ import { Point } from "../virtualizer/point.js";
22
+ import { Rect } from "../virtualizer/rect.js";
23
+ import { Size } from "../virtualizer/size.js";
24
+ // src/layout/waterfall-layout.ts
25
+ var WaterfallLayoutInfo = class WaterfallLayoutInfo extends LayoutInfo {
26
+ column = 0;
27
+ index = 0;
28
+ copy() {
29
+ const res = Object.assign(new WaterfallLayoutInfo(this.type, this.key, this.rect.copy()), super.copy());
30
+ res.column = this.column;
31
+ res.index = this.index;
32
+ return res;
33
+ }
34
+ };
35
+ const DEFAULT_OPTIONS = {
36
+ dropIndicatorThickness: 2,
37
+ loaderHeight: 48,
38
+ maxColumns: Infinity,
39
+ maxItemSize: new Size(Infinity, Infinity),
40
+ maxSpace: Infinity,
41
+ minItemSize: new Size(200, 200),
42
+ minSpace: new Size(18, 18)
43
+ };
44
+ var WaterfallLayout = class extends Layout {
45
+ contentSize = new Size();
46
+ layoutInfos = /* @__PURE__ */ new Map();
47
+ numColumns = 0;
48
+ dropIndicatorThickness = 2;
49
+ margin = 0;
50
+ shouldInvalidateLayoutOptions(newOptions, oldOptions) {
51
+ return newOptions.maxColumns !== oldOptions.maxColumns || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness || !(newOptions.minItemSize ?? DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize ?? DEFAULT_OPTIONS.minItemSize) || !(newOptions.maxItemSize ?? DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize ?? DEFAULT_OPTIONS.maxItemSize) || !(newOptions.minSpace ?? DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace ?? DEFAULT_OPTIONS.minSpace) || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace || newOptions.loaderHeight !== oldOptions.loaderHeight;
52
+ }
53
+ update(invalidationContext) {
54
+ const measureGrid = () => {
55
+ const { minItemSize = DEFAULT_OPTIONS.minItemSize, maxItemSize = DEFAULT_OPTIONS.maxItemSize, minSpace = DEFAULT_OPTIONS.minSpace, maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace, maxColumns = DEFAULT_OPTIONS.maxColumns, dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness } = invalidationContext.layoutOptions ?? {};
56
+ const loaderHeight = invalidationContext.layoutOptions?.loaderHeight ?? DEFAULT_OPTIONS.loaderHeight;
57
+ this.dropIndicatorThickness = dropIndicatorThickness;
58
+ const virtualizerWidth = this.attachedVirtualizer.size.width;
59
+ const maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);
60
+ const maxItemHeight = Number.isFinite(maxItemSize.height) ? maxItemSize.height : Math.floor(minItemSize.height / minItemSize.width * maxItemWidth);
61
+ const columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));
62
+ const numColumns = Math.max(1, Math.min(maxColumns, columns));
63
+ const width = virtualizerWidth - minSpace.width * Math.max(0, numColumns);
64
+ let itemWidth = Math.floor(width / numColumns);
65
+ itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));
66
+ const t = (itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width);
67
+ let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);
68
+ itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));
69
+ const horizontalSpacing = Math.min(Math.max(maxHorizontalSpace, minSpace.width), Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1)));
70
+ this.margin = Math.floor((virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2);
71
+ return {
72
+ horizontalSpacing,
73
+ itemHeight,
74
+ itemWidth,
75
+ loaderHeight,
76
+ minSpace,
77
+ numColumns,
78
+ virtualizerWidth
79
+ };
80
+ };
81
+ const { virtualizerWidth, numColumns, itemWidth, itemHeight, horizontalSpacing, minSpace, loaderHeight: initialLoaderHeight } = measureGrid();
82
+ let loaderHeight = initialLoaderHeight;
83
+ const columnHeights = Array.from({ length: numColumns }, () => minSpace.height);
84
+ const newLayoutInfos = /* @__PURE__ */ new Map();
85
+ let index = 0;
86
+ const addNode = (key, node) => {
87
+ const oldLayoutInfo = this.layoutInfos.get(key);
88
+ let height = itemHeight;
89
+ let estimatedSize = true;
90
+ if (oldLayoutInfo) {
91
+ height = oldLayoutInfo.rect.height / oldLayoutInfo.rect.width * itemWidth;
92
+ estimatedSize = invalidationContext.sizeChanged === true || oldLayoutInfo.estimatedSize || oldLayoutInfo.content !== node;
93
+ }
94
+ let column = numColumns === this.numColumns && oldLayoutInfo && oldLayoutInfo.index === index && oldLayoutInfo.rect.y < this.attachedVirtualizer.visibleRect.maxY ? oldLayoutInfo.column : void 0;
95
+ if (column === void 0) {
96
+ column = 0;
97
+ let minimumHeight = Infinity;
98
+ for (const [candidate, columnHeight] of columnHeights.entries()) if (columnHeight < minimumHeight) {
99
+ column = candidate;
100
+ minimumHeight = columnHeight;
101
+ }
102
+ }
103
+ const x = horizontalSpacing + column * (itemWidth + horizontalSpacing) + this.margin;
104
+ const y = requireValue(columnHeights[column], "The selected waterfall column must exist.");
105
+ const rect = new Rect(x, y, itemWidth, height);
106
+ const layoutInfo = new WaterfallLayoutInfo(node.type, key, rect);
107
+ layoutInfo.estimatedSize = estimatedSize;
108
+ layoutInfo.allowOverflow = true;
109
+ layoutInfo.content = node;
110
+ layoutInfo.column = column;
111
+ layoutInfo.index = index;
112
+ index += 1;
113
+ newLayoutInfos.set(key, layoutInfo);
114
+ columnHeights[column] = y + layoutInfo.rect.height + minSpace.height;
115
+ };
116
+ const { collection } = this.attachedVirtualizer;
117
+ let skeletonCount = 0;
118
+ for (const node of collection) if (node.type === "skeleton") {
119
+ const startingHeights = [...columnHeights];
120
+ while (!columnHeights.every((h, i) => h !== startingHeights[i]) || Math.min(...columnHeights) < this.attachedVirtualizer.size.height) {
121
+ const key = `${node.key}-${skeletonCount}`;
122
+ skeletonCount += 1;
123
+ addNode(key, this.layoutInfos.get(key)?.content ?? { ...node });
124
+ }
125
+ break;
126
+ } else if (node.type !== "loader") addNode(node.key, node);
127
+ let maxHeight = collection.size === 0 ? 0 : Math.max(...columnHeights);
128
+ const lastKey = collection.getLastKey();
129
+ const lastNode = lastKey === null ? null : collection.getItem(lastKey);
130
+ if (lastNode?.type === "loader") {
131
+ if (skeletonCount > 0 || !getNodeProps(lastNode).isLoading) loaderHeight = 0;
132
+ const loaderWidth = virtualizerWidth - horizontalSpacing * 2;
133
+ const rect = new Rect(horizontalSpacing, maxHeight, loaderWidth, loaderHeight);
134
+ const layoutInfo = new WaterfallLayoutInfo("loader", lastNode.key, rect);
135
+ newLayoutInfos.set(lastNode.key, layoutInfo);
136
+ maxHeight = layoutInfo.rect.maxY;
137
+ }
138
+ this.contentSize = new Size(this.attachedVirtualizer.size.width, maxHeight);
139
+ this.layoutInfos = newLayoutInfos;
140
+ this.numColumns = numColumns;
141
+ }
142
+ getLayoutInfo(key) {
143
+ return this.layoutInfos.get(key) ?? null;
144
+ }
145
+ getContentSize() {
146
+ return this.contentSize;
147
+ }
148
+ getVisibleLayoutInfos(rect) {
149
+ const layoutInfos = [];
150
+ for (const layoutInfo of this.layoutInfos.values()) if (layoutInfo.rect.intersects(rect) || this.attachedVirtualizer.isPersistedKey(layoutInfo.key) || layoutInfo.type === "loader") layoutInfos.push(layoutInfo);
151
+ return layoutInfos;
152
+ }
153
+ updateItemSize(key, size) {
154
+ const layoutInfo = this.layoutInfos.get(key);
155
+ if (!layoutInfo) return false;
156
+ if (size.height !== layoutInfo.rect.height) {
157
+ const newLayoutInfo = layoutInfo.copy();
158
+ newLayoutInfo.rect.height = size.height;
159
+ newLayoutInfo.estimatedSize = false;
160
+ this.layoutInfos.set(key, newLayoutInfo);
161
+ return true;
162
+ }
163
+ return false;
164
+ }
165
+ getKeyRightOf(key) {
166
+ const layoutInfo = this.getLayoutInfo(key);
167
+ if (!layoutInfo) return null;
168
+ const rect = new Rect(layoutInfo.rect.maxX, layoutInfo.rect.y, this.attachedVirtualizer.visibleRect.maxX - layoutInfo.rect.maxX, layoutInfo.rect.height);
169
+ const layoutInfos = this.getVisibleLayoutInfos(rect);
170
+ let bestKey = null;
171
+ let bestDistance = Infinity;
172
+ for (const candidate of layoutInfos) {
173
+ if (candidate.key === key) continue;
174
+ const distance = candidate.rect.x - rect.x - (Math.min(candidate.rect.maxY, rect.maxY) - Math.max(candidate.rect.y, rect.y));
175
+ if (distance < bestDistance) {
176
+ bestDistance = distance;
177
+ bestKey = candidate.key;
178
+ }
179
+ }
180
+ return bestKey;
181
+ }
182
+ getKeyLeftOf(key) {
183
+ const layoutInfo = this.getLayoutInfo(key);
184
+ if (!layoutInfo) return null;
185
+ const rect = new Rect(0, layoutInfo.rect.y, layoutInfo.rect.x, layoutInfo.rect.height);
186
+ const layoutInfos = this.getVisibleLayoutInfos(rect);
187
+ let bestKey = null;
188
+ let bestDistance = Infinity;
189
+ for (const candidate of layoutInfos) {
190
+ if (candidate.key === key) continue;
191
+ const distance = rect.maxX - candidate.rect.maxX - (Math.min(candidate.rect.maxY, rect.maxY) - Math.max(candidate.rect.y, rect.y));
192
+ if (distance < bestDistance) {
193
+ bestDistance = distance;
194
+ bestKey = candidate.key;
195
+ }
196
+ }
197
+ return bestKey;
198
+ }
199
+ getKeyRange(from, to) {
200
+ const fromLayoutInfo = this.getLayoutInfo(from);
201
+ const toLayoutInfo = this.getLayoutInfo(to);
202
+ if (!fromLayoutInfo || !toLayoutInfo) return [];
203
+ const rect = fromLayoutInfo.rect.union(toLayoutInfo.rect);
204
+ const keys = [];
205
+ for (const layoutInfo of this.layoutInfos.values()) if (rect.intersection(layoutInfo.rect).area > layoutInfo.rect.area / 2) keys.push(layoutInfo.key);
206
+ return keys;
207
+ }
208
+ getDropTargetFromPoint(initialX, initialY) {
209
+ let x = initialX;
210
+ let y = initialY;
211
+ if (this.layoutInfos.size === 0) return { type: "root" };
212
+ x += this.attachedVirtualizer.visibleRect.x;
213
+ y += this.attachedVirtualizer.visibleRect.y;
214
+ const key = this.attachedVirtualizer.keyAtPoint(new Point(x, y));
215
+ if (key === null || key === void 0) return { type: "root" };
216
+ return {
217
+ dropPosition: "on",
218
+ key,
219
+ type: "item"
220
+ };
221
+ }
222
+ };
223
+ export { WaterfallLayout };
224
+
225
+ //# sourceMappingURL=waterfall-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waterfall-layout.js","names":[],"sources":["../../src/layout/waterfall-layout.ts"],"sourcesContent":["/*\n * Copyright 2024 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/layout/WaterfallLayout.ts.\n * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state APIs for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type {\n DropTarget,\n DropTargetDelegate,\n Key,\n LayoutDelegate,\n Node,\n} from \"@solid2-aria/types-shared\";\n\nimport { getNodeProps } from \"../utils/get-node-props\";\nimport { requireValue } from \"../utils/require-value\";\nimport { Layout } from \"../virtualizer/layout\";\nimport { LayoutInfo } from \"../virtualizer/layout-info\";\nimport { Point } from \"../virtualizer/point\";\nimport { Rect } from \"../virtualizer/rect\";\nimport { Size } from \"../virtualizer/size\";\nimport type { InvalidationContext } from \"../virtualizer/types\";\n\nexport interface WaterfallLayoutOptions {\n /**\n * The minimum item size.\n *\n * @default 200 x 200\n */\n minItemSize?: Size;\n /**\n * The maximum item size.\n *\n * @default Infinity\n */\n maxItemSize?: Size;\n /**\n * The minimum space required between items.\n *\n * @default 18 x 18\n */\n minSpace?: Size;\n /**\n * The maximum allowed horizontal space between items.\n *\n * @default Infinity\n */\n maxHorizontalSpace?: number;\n /**\n * The maximum number of columns.\n *\n * @default Infinity\n */\n maxColumns?: number;\n /**\n * The thickness of the drop indicator.\n *\n * @default 2\n */\n dropIndicatorThickness?: number;\n /**\n * The fixed height of a loader element in px. This loader is specifically for \"load more\"\n * elements rendered when loading more rows at the root level or inside nested row/sections.\n *\n * @default 48\n */\n loaderHeight?: number;\n}\n\nclass WaterfallLayoutInfo<T> extends LayoutInfo<Node<T>> {\n column = 0;\n index = 0;\n override copy(): WaterfallLayoutInfo<T> {\n const res = Object.assign(\n new WaterfallLayoutInfo<T>(this.type, this.key, this.rect.copy()),\n super.copy()\n );\n\n res.column = this.column;\n res.index = this.index;\n\n return res;\n }\n}\n\nconst DEFAULT_OPTIONS = {\n dropIndicatorThickness: 2,\n loaderHeight: 48,\n maxColumns: Infinity,\n maxItemSize: new Size(Infinity, Infinity),\n maxSpace: Infinity,\n minItemSize: new Size(200, 200),\n minSpace: new Size(18, 18),\n};\n\nexport class WaterfallLayout<\n T extends object,\n O extends WaterfallLayoutOptions = WaterfallLayoutOptions,\n>\n extends Layout<Node<T>, O>\n implements LayoutDelegate, DropTargetDelegate\n{\n private contentSize: Size = new Size();\n private layoutInfos = new Map<Key, WaterfallLayoutInfo<T>>();\n protected numColumns = 0;\n protected dropIndicatorThickness = 2;\n private margin = 0;\n override shouldInvalidateLayoutOptions(\n newOptions: O,\n oldOptions: O\n ): boolean {\n return (\n newOptions.maxColumns !== oldOptions.maxColumns ||\n newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness ||\n !(newOptions.minItemSize ?? DEFAULT_OPTIONS.minItemSize).equals(\n oldOptions.minItemSize ?? DEFAULT_OPTIONS.minItemSize\n ) ||\n !(newOptions.maxItemSize ?? DEFAULT_OPTIONS.maxItemSize).equals(\n oldOptions.maxItemSize ?? DEFAULT_OPTIONS.maxItemSize\n ) ||\n !(newOptions.minSpace ?? DEFAULT_OPTIONS.minSpace).equals(\n oldOptions.minSpace ?? DEFAULT_OPTIONS.minSpace\n ) ||\n newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace ||\n newOptions.loaderHeight !== oldOptions.loaderHeight\n );\n }\n override update(invalidationContext: InvalidationContext<O>): void {\n const measureGrid = () => {\n const {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n } = invalidationContext.layoutOptions ?? {};\n\n const loaderHeight =\n invalidationContext.layoutOptions?.loaderHeight ??\n DEFAULT_OPTIONS.loaderHeight;\n\n this.dropIndicatorThickness = dropIndicatorThickness;\n const virtualizerWidth = this.attachedVirtualizer.size.width;\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n const maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n\n const maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n const columns = Math.floor(\n virtualizerWidth / (minItemSize.width + minSpace.width)\n );\n\n const numColumns = Math.max(1, Math.min(maxColumns, columns));\n // Compute the available width (minus the space between items)\n const width = virtualizerWidth - minSpace.width * Math.max(0, numColumns);\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(\n minItemSize.width,\n Math.min(maxItemWidth, itemWidth)\n );\n\n // Compute the item height, which is proportional to the item width\n const t =\n (itemWidth - minItemSize.width) /\n Math.max(1, maxItemWidth - minItemSize.width);\n\n let itemHeight =\n minItemSize.height +\n Math.floor((maxItemHeight - minItemSize.height) * t);\n\n itemHeight = Math.max(\n minItemSize.height,\n Math.min(maxItemHeight, itemHeight)\n );\n\n // Compute the horizontal spacing, content height and horizontal margin\n const horizontalSpacing = Math.min(\n Math.max(maxHorizontalSpace, minSpace.width),\n Math.floor(\n (virtualizerWidth - numColumns * itemWidth) / (numColumns + 1)\n )\n );\n\n this.margin = Math.floor(\n (virtualizerWidth -\n numColumns * itemWidth -\n horizontalSpacing * (numColumns + 1)) /\n 2\n );\n\n return {\n horizontalSpacing,\n itemHeight,\n itemWidth,\n loaderHeight,\n minSpace,\n numColumns,\n virtualizerWidth,\n };\n };\n\n const {\n virtualizerWidth,\n numColumns,\n itemWidth,\n itemHeight,\n horizontalSpacing,\n minSpace,\n loaderHeight: initialLoaderHeight,\n } = measureGrid();\n\n let loaderHeight = initialLoaderHeight;\n\n // Setup an array of column heights\n const columnHeights = Array.from(\n { length: numColumns },\n () => minSpace.height\n );\n\n const newLayoutInfos = new Map<Key, WaterfallLayoutInfo<T>>();\n let index = 0;\n\n const addNode = (key: Key, node: Node<T>) => {\n const oldLayoutInfo = this.layoutInfos.get(key);\n let height = itemHeight;\n let estimatedSize = true;\n\n if (oldLayoutInfo) {\n height =\n (oldLayoutInfo.rect.height / oldLayoutInfo.rect.width) * itemWidth;\n estimatedSize =\n invalidationContext.sizeChanged === true ||\n oldLayoutInfo.estimatedSize ||\n oldLayoutInfo.content !== node;\n }\n\n // Figure out which column to place the item in, and compute its position.\n // Preserve the previous column index so items don't jump around during resizing unless the number of columns changed.\n const prevColumn =\n numColumns === this.numColumns &&\n oldLayoutInfo &&\n oldLayoutInfo.index === index &&\n oldLayoutInfo.rect.y < this.attachedVirtualizer.visibleRect.maxY\n ? oldLayoutInfo.column\n : undefined;\n\n let column = prevColumn;\n\n if (column === undefined) {\n column = 0;\n let minimumHeight = Infinity;\n\n for (const [candidate, columnHeight] of columnHeights.entries()) {\n if (columnHeight < minimumHeight) {\n column = candidate;\n minimumHeight = columnHeight;\n }\n }\n }\n\n const x =\n horizontalSpacing +\n column * (itemWidth + horizontalSpacing) +\n this.margin;\n\n const y = requireValue(\n columnHeights[column],\n \"The selected waterfall column must exist.\"\n );\n\n const rect = new Rect(x, y, itemWidth, height);\n const layoutInfo = new WaterfallLayoutInfo<T>(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = node;\n layoutInfo.column = column;\n layoutInfo.index = index;\n index += 1;\n newLayoutInfos.set(key, layoutInfo);\n columnHeights[column] = y + layoutInfo.rect.height + minSpace.height;\n };\n\n const { collection } = this.attachedVirtualizer;\n let skeletonCount = 0;\n\n for (const node of collection) {\n if (node.type === \"skeleton\") {\n // Add skeleton cards until every column has at least one, and we fill the viewport.\n const startingHeights = [...columnHeights];\n\n while (\n !columnHeights.every((h, i) => h !== startingHeights[i]) ||\n Math.min(...columnHeights) < this.attachedVirtualizer.size.height\n ) {\n const key = `${node.key}-${skeletonCount}`;\n skeletonCount += 1;\n const content = this.layoutInfos.get(key)?.content ?? { ...node };\n addNode(key, content);\n }\n\n break;\n } else if (node.type !== \"loader\") {\n addNode(node.key, node);\n }\n }\n\n // Reset all columns to the maximum for the next section. If loading, set to 0 so virtualizer doesn't render its body since there aren't items to render,\n // except if we are performing skeleton loading\n const isEmptyOrLoading = collection.size === 0;\n\n let maxHeight = isEmptyOrLoading ? 0 : Math.max(...columnHeights);\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n // Add it under the first column for simplicity\n const lastKey = collection.getLastKey();\n const lastNode = lastKey === null ? null : collection.getItem(lastKey);\n\n if (lastNode?.type === \"loader\") {\n if (skeletonCount > 0 || !getNodeProps(lastNode).isLoading) {\n loaderHeight = 0;\n }\n\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n const rect = new Rect(\n horizontalSpacing,\n maxHeight,\n loaderWidth,\n loaderHeight\n );\n\n const layoutInfo = new WaterfallLayoutInfo<T>(\n \"loader\",\n lastNode.key,\n rect\n );\n\n newLayoutInfos.set(lastNode.key, layoutInfo);\n maxHeight = layoutInfo.rect.maxY;\n }\n\n this.contentSize = new Size(this.attachedVirtualizer.size.width, maxHeight);\n this.layoutInfos = newLayoutInfos;\n this.numColumns = numColumns;\n }\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) ?? null;\n }\n getContentSize(): Size {\n return this.contentSize;\n }\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n const layoutInfos: LayoutInfo[] = [];\n\n for (const layoutInfo of this.layoutInfos.values()) {\n if (\n layoutInfo.rect.intersects(rect) ||\n this.attachedVirtualizer.isPersistedKey(layoutInfo.key) ||\n layoutInfo.type === \"loader\"\n ) {\n layoutInfos.push(layoutInfo);\n }\n }\n\n return layoutInfos;\n }\n override updateItemSize(key: Key, size: Size): boolean {\n const layoutInfo = this.layoutInfos.get(key);\n\n if (!layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n const newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n\n return true;\n }\n\n return false;\n }\n // Override keyboard navigation to work spatially.\n getKeyRightOf(key: Key): Key | null {\n const layoutInfo = this.getLayoutInfo(key);\n\n if (!layoutInfo) {\n return null;\n }\n\n const rect = new Rect(\n layoutInfo.rect.maxX,\n layoutInfo.rect.y,\n this.attachedVirtualizer.visibleRect.maxX - layoutInfo.rect.maxX,\n layoutInfo.rect.height\n );\n\n const layoutInfos = this.getVisibleLayoutInfos(rect);\n let bestKey: Key | null = null;\n let bestDistance = Infinity;\n\n for (const candidate of layoutInfos) {\n if (candidate.key === key) {\n continue;\n }\n\n // Find the closest item in the x direction with the most overlap in the y direction.\n const deltaX = candidate.rect.x - rect.x;\n\n const overlapY =\n Math.min(candidate.rect.maxY, rect.maxY) -\n Math.max(candidate.rect.y, rect.y);\n\n const distance = deltaX - overlapY;\n\n if (distance < bestDistance) {\n bestDistance = distance;\n bestKey = candidate.key;\n }\n }\n\n return bestKey;\n }\n getKeyLeftOf(key: Key): Key | null {\n const layoutInfo = this.getLayoutInfo(key);\n\n if (!layoutInfo) {\n return null;\n }\n\n const rect = new Rect(\n 0,\n layoutInfo.rect.y,\n layoutInfo.rect.x,\n layoutInfo.rect.height\n );\n\n const layoutInfos = this.getVisibleLayoutInfos(rect);\n let bestKey: Key | null = null;\n let bestDistance = Infinity;\n\n for (const candidate of layoutInfos) {\n if (candidate.key === key) {\n continue;\n }\n\n // Find the closest item in the x direction with the most overlap in the y direction.\n const deltaX = rect.maxX - candidate.rect.maxX;\n\n const overlapY =\n Math.min(candidate.rect.maxY, rect.maxY) -\n Math.max(candidate.rect.y, rect.y);\n\n const distance = deltaX - overlapY;\n\n if (distance < bestDistance) {\n bestDistance = distance;\n bestKey = candidate.key;\n }\n }\n\n return bestKey;\n }\n // This overrides the default behavior of shift selection to work spatially\n // rather than following the order of the items in the collection (which may appear unpredictable).\n getKeyRange(from: Key, to: Key): Key[] {\n const fromLayoutInfo = this.getLayoutInfo(from);\n const toLayoutInfo = this.getLayoutInfo(to);\n\n if (!fromLayoutInfo || !toLayoutInfo) {\n return [];\n }\n\n // Find items where half of the area intersects the rectangle\n // formed from the first item to the last item in the range.\n const rect = fromLayoutInfo.rect.union(toLayoutInfo.rect);\n const keys: Key[] = [];\n\n for (const layoutInfo of this.layoutInfos.values()) {\n if (rect.intersection(layoutInfo.rect).area > layoutInfo.rect.area / 2) {\n keys.push(layoutInfo.key);\n }\n }\n\n return keys;\n }\n getDropTargetFromPoint(initialX: number, initialY: number): DropTarget {\n let x = initialX;\n\n let y = initialY;\n\n if (this.layoutInfos.size === 0) {\n return { type: \"root\" };\n }\n\n x += this.attachedVirtualizer.visibleRect.x;\n y += this.attachedVirtualizer.visibleRect.y;\n const key = this.attachedVirtualizer.keyAtPoint(new Point(x, y));\n\n if (key === null || key === undefined) {\n return { type: \"root\" };\n }\n\n // Only support \"on\" drop position in waterfall layout.\n // Reordering doesn't make sense because the items don't have a deterministic order.\n return {\n dropPosition: \"on\",\n key,\n type: \"item\",\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgFA,IAAM,sBAAN,MAAM,4BAA+B,WAAoB;CACvD,SAAS;CACT,QAAQ;CACR,OAAwC;EACtC,MAAM,MAAM,OAAO,OACjB,IAAI,oBAAuB,KAAK,MAA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O,CAAC;EAKV,MAAM,OAAO,eAAe,KAAK,MAAM,aAAa,IAAI;EACxD,MAAM,OAAc,CAAC;EAErB,KAAK,MAAM,cAAc,KAAK,YAAY,OAAO,GAC/C,IAAI,KAAK,aAAa,WAAW,IAAI,CAAC,CAAC,OAAO,WAAW,KAAK,OAAO,GACnE,KAAK,KAAK,WAAW,GAAG;EAI5B,OAAO;CACT;CACA,uBAAuB,UAAkB,UAA8B;EACrE,IAAI,IAAI;EAER,IAAI,IAAI;EAER,IAAI,KAAK,YAAY,SAAS,GAC5B,OAAO,EAAE,MAAM,OAAO;EAGxB,KAAK,KAAK,oBAAoB,YAAY;EAC1C,KAAK,KAAK,oBAAoB,YAAY;EAC1C,MAAM,MAAM,KAAK,oBAAoB,WAAW,IAAI,MAAM,GAAG,CAAC,CAAC;EAE/D,IAAI,QAAQ,QAAQ,QAAQ,KAAA,GAC1B,OAAO,EAAE,MAAM,OAAO;EAKxB,OAAO;GACL,cAAc;GACd;GACA,MAAM;EACR;CACF;AACF"}
@@ -0,0 +1,48 @@
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/list/useListState.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 { MultipleSelectionStateProps } from "../selection/create-multiple-selection-state.js";
18
+ import { SelectionManager } from "../selection/selection-manager.js";
19
+ import { Collection, CollectionStateBase, Key, LayoutDelegate, Node } from "@solid2-aria/types-shared";
20
+ export interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps {
21
+ /** Filter function to generate a filtered list of nodes. */
22
+ filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>;
23
+ /** @private */
24
+ suppressTextValueWarning?: boolean;
25
+ /**
26
+ * A delegate object that provides layout information for items in the collection.
27
+ * This can be used to override the behavior of shift selection.
28
+ */
29
+ layoutDelegate?: LayoutDelegate;
30
+ }
31
+ export interface ListState<T> {
32
+ /** A collection of items in the list. */
33
+ collection: Collection<Node<T>>;
34
+ /** A set of items that are disabled. */
35
+ disabledKeys: Set<Key>;
36
+ /** A selection manager to read and update multiple selection state. */
37
+ selectionManager: SelectionManager;
38
+ }
39
+ /**
40
+ * Provides state management for list-like components. Handles building a collection
41
+ * of items from props, and manages multiple selection state.
42
+ */
43
+ export declare function createListState<T extends object>(props: ListProps<T>): ListState<T>;
44
+ /**
45
+ * Filters a collection using the provided filter function and returns a new ListState.
46
+ */
47
+ export declare function UNSTABLE_createFilteredListState<T>(state: ListState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): ListState<T>;
48
+ //# sourceMappingURL=create-list-state.d.ts.map
@@ -0,0 +1,123 @@
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/list/useListState.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 { createCollection } from "../collections/create-collection.js";
18
+ import { createMultipleSelectionState } from "../selection/create-multiple-selection-state.js";
19
+ import { SelectionManager } from "../selection/selection-manager.js";
20
+ import { ListCollection } from "./list-collection.js";
21
+ import { createMemo, createRenderEffect, untrack } from "solid-js";
22
+ // src/list/create-list-state.ts
23
+ /**
24
+ * Provides state management for list-like components. Handles building a collection
25
+ * of items from props, and manages multiple selection state.
26
+ */
27
+ function createListState(props) {
28
+ const filter = createMemo(() => props.filter);
29
+ const layoutDelegate = createMemo(() => props.layoutDelegate);
30
+ const selectionState = createMultipleSelectionState(props);
31
+ const disabledKeys = createMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set());
32
+ const factory = (nodes) => {
33
+ const currentFilter = filter();
34
+ return currentFilter ? new ListCollection(currentFilter(nodes)) : new ListCollection(nodes);
35
+ };
36
+ const collection = createCollection(props, factory, { get suppressTextValueWarning() {
37
+ return props.suppressTextValueWarning;
38
+ } });
39
+ const selectionManager = createMemo(() => {
40
+ const currentCollection = collection();
41
+ const currentLayoutDelegate = layoutDelegate();
42
+ return new SelectionManager(currentCollection, selectionState, { layoutDelegate: currentLayoutDelegate });
43
+ });
44
+ createFocusedKeyReset(collection, selectionManager);
45
+ return {
46
+ get collection() {
47
+ return collection();
48
+ },
49
+ get disabledKeys() {
50
+ return disabledKeys();
51
+ },
52
+ get selectionManager() {
53
+ return selectionManager();
54
+ }
55
+ };
56
+ }
57
+ /**
58
+ * Filters a collection using the provided filter function and returns a new ListState.
59
+ */
60
+ function UNSTABLE_createFilteredListState(state, filterFn) {
61
+ const collection = createMemo(() => {
62
+ const current = state.collection;
63
+ if (!filterFn) return current;
64
+ if (!current.filter) throw new Error("The collection does not support filtering.");
65
+ return current.filter(filterFn);
66
+ });
67
+ const selectionManager = createMemo(() => state.selectionManager.withCollection(collection()));
68
+ createFocusedKeyReset(collection, selectionManager);
69
+ return {
70
+ get collection() {
71
+ return collection();
72
+ },
73
+ get disabledKeys() {
74
+ return state.disabledKeys;
75
+ },
76
+ get selectionManager() {
77
+ return selectionManager();
78
+ }
79
+ };
80
+ }
81
+ function createFocusedKeyReset(getCollection, getSelectionManager) {
82
+ let cachedCollection = null;
83
+ createRenderEffect(() => {
84
+ const collection = getCollection();
85
+ const selectionManager = getSelectionManager();
86
+ const { focusedKey } = selectionManager;
87
+ let nextFocusedKey;
88
+ if (focusedKey !== null && !collection.getItem(focusedKey) && cachedCollection) {
89
+ let key = cachedCollection.getKeyAfter(focusedKey);
90
+ nextFocusedKey = null;
91
+ while (key !== null && key !== void 0) {
92
+ if (collection.getItem(key)?.type === "item" && !selectionManager.isDisabled(key)) {
93
+ nextFocusedKey = key;
94
+ break;
95
+ }
96
+ key = cachedCollection.getKeyAfter(key);
97
+ }
98
+ if (nextFocusedKey === null) {
99
+ key = cachedCollection.getKeyBefore(focusedKey);
100
+ while (key !== null && key !== void 0) {
101
+ if (collection.getItem(key)?.type === "item" && !selectionManager.isDisabled(key)) {
102
+ nextFocusedKey = key;
103
+ break;
104
+ }
105
+ key = cachedCollection.getKeyBefore(key);
106
+ }
107
+ }
108
+ }
109
+ return {
110
+ collection,
111
+ nextFocusedKey,
112
+ selectionManager
113
+ };
114
+ }, ({ collection, nextFocusedKey, selectionManager }) => {
115
+ cachedCollection = collection;
116
+ if (nextFocusedKey !== void 0) untrack(() => {
117
+ selectionManager.setFocusedKey(nextFocusedKey);
118
+ });
119
+ });
120
+ }
121
+ export { UNSTABLE_createFilteredListState, createListState };
122
+
123
+ //# sourceMappingURL=create-list-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-list-state.js","names":[],"sources":["../../src/list/create-list-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/list/useListState.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 {\n Collection,\n CollectionStateBase,\n Key,\n LayoutDelegate,\n Node,\n} from \"@solid2-aria/types-shared\";\nimport { createMemo, createRenderEffect, untrack } from \"solid-js\";\n\nimport { createCollection } from \"../collections/create-collection\";\nimport { createMultipleSelectionState } from \"../selection/create-multiple-selection-state\";\nimport type { MultipleSelectionStateProps } from \"../selection/create-multiple-selection-state\";\nimport { SelectionManager } from \"../selection/selection-manager\";\nimport { ListCollection } from \"./list-collection\";\n\nexport interface ListProps<T>\n extends CollectionStateBase<T>, MultipleSelectionStateProps {\n /** Filter function to generate a filtered list of nodes. */\n filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>;\n /** @private */\n suppressTextValueWarning?: boolean;\n /**\n * A delegate object that provides layout information for items in the collection.\n * This can be used to override the behavior of shift selection.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ListState<T> {\n /** A collection of items in the list. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\n/**\n * Provides state management for list-like components. Handles building a collection\n * of items from props, and manages multiple selection state.\n */\nexport function createListState<T extends object>(\n props: ListProps<T>\n): ListState<T> {\n const filter = createMemo(() => props.filter);\n const layoutDelegate = createMemo(() => props.layoutDelegate);\n const selectionState = createMultipleSelectionState(props);\n\n const disabledKeys = createMemo(() =>\n props.disabledKeys ? new Set(props.disabledKeys) : new Set<Key>()\n );\n\n const factory = (nodes: Iterable<Node<T>>) => {\n const currentFilter = filter();\n\n return currentFilter\n ? new ListCollection(currentFilter(nodes))\n : new ListCollection(nodes);\n };\n\n const context = {\n get suppressTextValueWarning() {\n return props.suppressTextValueWarning;\n },\n };\n\n const collection = createCollection(props, factory, context);\n\n const selectionManager = createMemo(() => {\n const currentCollection = collection();\n const currentLayoutDelegate = layoutDelegate();\n\n return new SelectionManager(currentCollection, selectionState, {\n layoutDelegate: currentLayoutDelegate,\n });\n });\n\n createFocusedKeyReset(collection, selectionManager);\n\n return {\n get collection() {\n return collection();\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get selectionManager() {\n return selectionManager();\n },\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new ListState.\n */\nexport function UNSTABLE_createFilteredListState<T>(\n state: ListState<T>,\n filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined\n): ListState<T> {\n const collection = createMemo(() => {\n const current = state.collection;\n\n if (!filterFn) {\n return current;\n }\n\n if (!current.filter) {\n throw new Error(\"The collection does not support filtering.\");\n }\n\n return current.filter(filterFn);\n });\n\n const selectionManager = createMemo(() =>\n state.selectionManager.withCollection(collection())\n );\n\n createFocusedKeyReset(collection, selectionManager);\n\n return {\n get collection() {\n return collection();\n },\n get disabledKeys() {\n return state.disabledKeys;\n },\n get selectionManager() {\n return selectionManager();\n },\n };\n}\n\nfunction createFocusedKeyReset<T>(\n getCollection: () => Collection<Node<T>>,\n getSelectionManager: () => SelectionManager\n) {\n // Reset focused key if that item is deleted from the collection.\n let cachedCollection: Collection<Node<T>> | null = null;\n createRenderEffect(\n () => {\n const collection = getCollection();\n const selectionManager = getSelectionManager();\n const { focusedKey } = selectionManager;\n let nextFocusedKey: Key | null | undefined;\n\n if (\n focusedKey !== null &&\n !collection.getItem(focusedKey) &&\n cachedCollection\n ) {\n let key = cachedCollection.getKeyAfter(focusedKey);\n nextFocusedKey = null;\n\n while (key !== null && key !== undefined) {\n const node = collection.getItem(key);\n\n if (node?.type === \"item\" && !selectionManager.isDisabled(key)) {\n nextFocusedKey = key;\n break;\n }\n\n key = cachedCollection.getKeyAfter(key);\n }\n\n if (nextFocusedKey === null) {\n key = cachedCollection.getKeyBefore(focusedKey);\n\n while (key !== null && key !== undefined) {\n const node = collection.getItem(key);\n\n if (node?.type === \"item\" && !selectionManager.isDisabled(key)) {\n nextFocusedKey = key;\n break;\n }\n\n key = cachedCollection.getKeyBefore(key);\n }\n }\n }\n\n return { collection, nextFocusedKey, selectionManager };\n },\n ({ collection, nextFocusedKey, selectionManager }) => {\n cachedCollection = collection;\n\n if (nextFocusedKey !== undefined) {\n untrack(() => {\n selectionManager.setFocusedKey(nextFocusedKey);\n });\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,gBACd,OACc;CACd,MAAM,SAAS,iBAAiB,MAAM,MAAM;CAC5C,MAAM,iBAAiB,iBAAiB,MAAM,cAAc;CAC5D,MAAM,iBAAiB,6BAA6B,KAAK;CAEzD,MAAM,eAAe,iBACnB,MAAM,eAAe,IAAI,IAAI,MAAM,YAAY,oBAAI,IAAI,IAAS,CAClE;CAEA,MAAM,WAAW,UAA6B;EAC5C,MAAM,gBAAgB,OAAO;EAE7B,OAAO,gBACH,IAAI,eAAe,cAAc,KAAK,CAAC,IACvC,IAAI,eAAe,KAAK;CAC9B;CAQA,MAAM,aAAa,iBAAiB,OAAO,SAAS,EALlD,IAAI,2BAA2B;EAC7B,OAAO,MAAM;CACf,EAGwD,CAAC;CAE3D,MAAM,mBAAmB,iBAAiB;EACxC,MAAM,oBAAoB,WAAW;EACrC,MAAM,wBAAwB,eAAe;EAE7C,OAAO,IAAI,iBAAiB,mBAAmB,gBAAgB,EAC7D,gBAAgB,sBAClB,CAAC;CACH,CAAC;CAED,sBAAsB,YAAY,gBAAgB;CAElD,OAAO;EACL,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA,IAAI,eAAe;GACjB,OAA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BAAiB,aAAa,GAAG;IACzC;GACF;EACF;EAEA,OAAO;GAAE;GAAY;GAAgB;EAAiB;CACxD,IACC,EAAE,YAAY,gBAAgB,uBAAuB;EACpD,mBAAmB;EAEnB,IAAI,mBAAmB,KAAA,GACrB,cAAc;GACZ,iBAAiB,cAAc,cAAc;EAC/C,CAAC;CAEL,CACF;AACF"}
@@ -0,0 +1,38 @@
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/list/useSingleSelectListState.ts.
14
+ * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state 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 { ListState } from "./create-list-state.js";
18
+ import { CollectionStateBase, Key, Node, SingleSelection } from "@solid2-aria/types-shared";
19
+ export interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, "disallowEmptySelection"> {
20
+ /** Filter function to generate a filtered list of nodes. */
21
+ filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>;
22
+ /** @private */
23
+ suppressTextValueWarning?: boolean;
24
+ }
25
+ export interface SingleSelectListState<T> extends ListState<T> {
26
+ /** The key for the currently selected item. */
27
+ readonly selectedKey: Key | null;
28
+ /** Sets the selected key. */
29
+ setSelectedKey: (key: Key | null) => void;
30
+ /** The value of the currently selected item. */
31
+ readonly selectedItem: Node<T> | null;
32
+ }
33
+ /**
34
+ * Provides state management for list-like components with single selection.
35
+ * Handles building a collection of items from props, and manages selection state.
36
+ */
37
+ export declare function createSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T>;
38
+ //# sourceMappingURL=create-single-select-list-state.d.ts.map
@@ -0,0 +1,55 @@
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/list/useSingleSelectListState.ts.
14
+ * Modified for Solid Aria: adapted imports, collection descriptors, and reactive state 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 { createListState } from "./create-list-state.js";
19
+ import { merge, untrack } from "solid-js";
20
+ // src/list/create-single-select-list-state.ts
21
+ /**
22
+ * Provides state management for list-like components with single selection.
23
+ * Handles building a collection of items from props, and manages selection state.
24
+ */
25
+ function createSingleSelectListState(props) {
26
+ const [selectedKey, setSelectedKey] = createControlledSignal(() => props.selectedKey, untrack(() => props.defaultSelectedKey ?? null), (key) => props.onSelectionChange?.(key));
27
+ const state = createListState(merge(props, {
28
+ allowDuplicateSelectionEvents: true,
29
+ disallowEmptySelection: true,
30
+ onSelectionChange(keys) {
31
+ if (keys === "all") return;
32
+ const key = keys.values().next().value ?? null;
33
+ if (key === selectedKey()) props.onSelectionChange?.(key);
34
+ setSelectedKey(key);
35
+ },
36
+ get selectedKeys() {
37
+ const key = selectedKey();
38
+ return key === null || key === void 0 ? [] : [key];
39
+ },
40
+ selectionMode: "single"
41
+ }));
42
+ return merge(state, {
43
+ get selectedItem() {
44
+ const key = selectedKey();
45
+ return key === null || key === void 0 ? null : state.collection.getItem(key);
46
+ },
47
+ get selectedKey() {
48
+ return selectedKey();
49
+ },
50
+ setSelectedKey
51
+ });
52
+ }
53
+ export { createSingleSelectListState };
54
+
55
+ //# sourceMappingURL=create-single-select-list-state.js.map