@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,66 @@
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/table/Column.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 { CollectionContext, PartialNode } from "../collections/types.js";
18
+ import { Element } from "solid-js";
19
+ import { Key, Node } from "@solid2-aria/types-shared";
20
+ /** Widths that result in a constant pixel value for the same Table width. */
21
+ export type ColumnStaticSize = number | `${number}` | `${number}%`;
22
+ /**
23
+ * Widths that change size in relation to the remaining space and in ratio to other dynamic columns.
24
+ * All numbers must be integers and greater than 0.
25
+ * FR units take up remaining, if any, space in the table.
26
+ */
27
+ export type ColumnDynamicSize = `${number}fr`;
28
+ /** All possible sizes a column can be assigned. */
29
+ export type ColumnSize = ColumnStaticSize | ColumnDynamicSize;
30
+ export type ColumnElement<_T> = Element;
31
+ export type ColumnRenderer<T> = (item: T) => ColumnElement<T>;
32
+ export interface ColumnProps<T> {
33
+ key?: Key;
34
+ "aria-label"?: string;
35
+ /** Rendered contents of the column if `children` contains child columns. */
36
+ title?: Element;
37
+ /** Static child columns or content to render as the column header. */
38
+ children: Element | ColumnElement<T>[];
39
+ /** A list of child columns used when dynamically rendering nested child columns. */
40
+ childColumns?: T[];
41
+ /** The width of the column. */
42
+ width?: ColumnSize | null;
43
+ /** The minimum width of the column. */
44
+ minWidth?: ColumnStaticSize | null;
45
+ /** The maximum width of the column. */
46
+ maxWidth?: ColumnStaticSize | null;
47
+ /** The default width of the column. */
48
+ defaultWidth?: ColumnSize | null;
49
+ /** Whether the column allows resizing. */
50
+ allowsResizing?: boolean;
51
+ /** Whether the column allows sorting. */
52
+ allowsSorting?: boolean;
53
+ /**
54
+ * Whether a column is a [row header](https://www.w3.org/TR/wai-aria-1.1/#rowheader) and should be
55
+ * announced by assistive technology during row navigation.
56
+ */
57
+ isRowHeader?: boolean;
58
+ /** A string representation of the column's contents, used for accessibility announcements. */
59
+ textValue?: string;
60
+ }
61
+ declare function Column<T>(props: ColumnProps<T>): Element;
62
+ declare namespace Column {
63
+ var getCollectionNode: <T>(props: ColumnProps<T>, context: CollectionContext) => Generator<PartialNode<T>, void, Node<T>[]>;
64
+ }
65
+ export { Column };
66
+ //# sourceMappingURL=column.d.ts.map
@@ -0,0 +1,71 @@
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/table/Column.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 { hasContent } from "../utils/has-content.js";
18
+ import { collectionChildren } from "../collections/types.js";
19
+ import { isTableCollectionContext } from "./collection-context.js";
20
+ // src/table/column.ts
21
+ function Column(props) {
22
+ return Object.assign([], {
23
+ getCollectionNode: (context) => Column.getCollectionNode(props, context),
24
+ get key() {
25
+ return props.key;
26
+ },
27
+ props,
28
+ type: Column
29
+ });
30
+ }
31
+ Column.getCollectionNode = function* getCollectionNode(props, context) {
32
+ if (!isTableCollectionContext(context)) throw new Error("Table collection context is required.");
33
+ const { title, children, childColumns } = props;
34
+ const rendered = title ?? children;
35
+ let textValue = props["aria-label"] ?? "";
36
+ if (typeof rendered === "string" && rendered !== "") textValue = rendered;
37
+ if (props.textValue !== void 0 && props.textValue !== "") ({textValue} = props);
38
+ const fullNodes = yield {
39
+ *childNodes() {
40
+ if (childColumns) for (const child of childColumns) yield {
41
+ type: "column",
42
+ value: child
43
+ };
44
+ else if (hasContent(title)) {
45
+ const localChildColumns = [];
46
+ for (const child of collectionChildren(children)) localChildColumns.push({
47
+ element: child,
48
+ type: "column"
49
+ });
50
+ yield* localChildColumns;
51
+ }
52
+ },
53
+ hasChildNodes: !!childColumns || Boolean(title) && collectionChildren(children).length > 0,
54
+ props,
55
+ rendered,
56
+ shouldInvalidate(newContext) {
57
+ if (!isTableCollectionContext(newContext)) return true;
58
+ updateContext(newContext);
59
+ return false;
60
+ },
61
+ textValue,
62
+ type: "column"
63
+ };
64
+ function updateContext(localContext) {
65
+ for (const node of fullNodes) if (!node.hasChildNodes) localContext.columns.push(node);
66
+ }
67
+ updateContext(context);
68
+ };
69
+ export { Column };
70
+
71
+ //# sourceMappingURL=column.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column.js","names":[],"sources":["../../src/table/column.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/table/Column.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 { Key, Node } from \"@solid2-aria/types-shared\";\nimport type { Element as SolidElement } from \"solid-js\";\n\nimport type { PartialNode, CollectionContext } from \"../collections/types\";\nimport { collectionChildren } from \"../collections/types\";\nimport { hasContent } from \"../utils/has-content\";\nimport { isTableCollectionContext } from \"./collection-context\";\nimport type { CollectionBuilderContext } from \"./create-table-state\";\n\n/** Widths that result in a constant pixel value for the same Table width. */\n// match regex: /^(\\d+)(?=%$)/\nexport type ColumnStaticSize = number | `${number}` | `${number}%`;\n\n/**\n * Widths that change size in relation to the remaining space and in ratio to other dynamic columns.\n * All numbers must be integers and greater than 0.\n * FR units take up remaining, if any, space in the table.\n */\n// match regex: /^(\\d+)(?=fr$)/\nexport type ColumnDynamicSize = `${number}fr`;\n\n/** All possible sizes a column can be assigned. */\nexport type ColumnSize = ColumnStaticSize | ColumnDynamicSize;\n\nexport type ColumnElement<_T> = SolidElement;\n\nexport type ColumnRenderer<T> = (item: T) => ColumnElement<T>;\n\nexport interface ColumnProps<T> {\n key?: Key;\n \"aria-label\"?: string;\n /** Rendered contents of the column if `children` contains child columns. */\n title?: SolidElement;\n /** Static child columns or content to render as the column header. */\n children: SolidElement | ColumnElement<T>[];\n /** A list of child columns used when dynamically rendering nested child columns. */\n childColumns?: T[];\n /** The width of the column. */\n width?: ColumnSize | null;\n /** The minimum width of the column. */\n minWidth?: ColumnStaticSize | null;\n /** The maximum width of the column. */\n maxWidth?: ColumnStaticSize | null;\n /** The default width of the column. */\n defaultWidth?: ColumnSize | null;\n /** Whether the column allows resizing. */\n allowsResizing?: boolean;\n /** Whether the column allows sorting. */\n allowsSorting?: boolean;\n /**\n * Whether a column is a [row header](https://www.w3.org/TR/wai-aria-1.1/#rowheader) and should be\n * announced by assistive technology during row navigation.\n */\n isRowHeader?: boolean;\n /** A string representation of the column's contents, used for accessibility announcements. */\n textValue?: string;\n}\n\nfunction Column<T>(props: ColumnProps<T>): SolidElement {\n return Object.assign([], {\n getCollectionNode: (context: CollectionContext) =>\n Column.getCollectionNode(props, context),\n get key() {\n return props.key;\n },\n props,\n type: Column,\n });\n}\n\nColumn.getCollectionNode = function* getCollectionNode<T>(\n props: ColumnProps<T>,\n context: CollectionContext\n): Generator<PartialNode<T>, void, Node<T>[]> {\n if (!isTableCollectionContext<T>(context)) {\n throw new Error(\"Table collection context is required.\");\n }\n\n const { title, children, childColumns } = props;\n const rendered = title ?? children;\n\n let textValue = props[\"aria-label\"] ?? \"\";\n\n if (typeof rendered === \"string\" && rendered !== \"\") {\n textValue = rendered;\n }\n\n if (props.textValue !== undefined && props.textValue !== \"\") {\n ({ textValue } = props);\n }\n\n const fullNodes = yield {\n *childNodes() {\n if (childColumns) {\n for (const child of childColumns) {\n yield {\n type: \"column\",\n value: child,\n };\n }\n } else if (hasContent(title)) {\n const localChildColumns: PartialNode<T>[] = [];\n\n for (const child of collectionChildren(children)) {\n localChildColumns.push({\n element: child,\n type: \"column\",\n });\n }\n\n yield* localChildColumns;\n }\n },\n hasChildNodes:\n !!childColumns ||\n (Boolean(title) && collectionChildren(children).length > 0),\n props,\n rendered,\n shouldInvalidate(newContext: CollectionContext) {\n if (!isTableCollectionContext<T>(newContext)) {\n return true;\n }\n\n // This is a bit of a hack, but it works.\n // If this method is called, then there's a cached version of this node available.\n // But, we need to keep the list of columns in the new context up to date.\n updateContext(newContext);\n\n return false;\n },\n textValue,\n type: \"column\",\n };\n\n function updateContext(localContext: CollectionBuilderContext<T>) {\n // register leaf columns on the context so that <Row> can access them\n for (const node of fullNodes) {\n if (!node.hasChildNodes) {\n localContext.columns.push(node);\n }\n }\n }\n\n updateContext(context);\n};\n\n/**\n * A Column represents a field of each item within a Table. Columns may also contain nested\n * Column elements to represent column groups. Nested columns can be statically defined as\n * children, or dynamically generated using a function based on the `childColumns` prop.\n */\n// We don't want getCollectionNode to show up in the type definition\nexport { Column };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2EA,SAAS,OAAU,OAAqC;CACtD,OAAO,OAAO,OAAO,CAAC,GAAG;EACvB,oBAAoB,YAClB,OAAO,kBAAkB,OAAO,OAAO;EACzC,IAAI,MAAM;GACR,OAAO,MAAM;EACf;EACA;EACA,MAAM;CACR,CAAC;AACH;AAEA,OAAO,oBAAoB,UAAU,kBACnC,OACA,SAC4C;CAC5C,IAAI,CAAC,yBAA4B,OAAO,GACtC,MAAM,IAAI,MAAM,uCAAuC;CAGzD,MAAM,EAAE,OAAO,UAAU,iBAAiB;CAC1C,MAAM,WAAW,SAAS;CAE1B,IAAI,YAAY,MAAM,iBAAiB;CAEvC,IAAI,OAAO,aAAa,YAAY,aAAa,IAC/C,YAAY;CAGd,IAAI,MAAM,cAAc,KAAA,KAAa,MAAM,cAAc,IACvD,CAAC,CAAE,aAAc;CAGnB,MAAM,YAAY,MAAM;EACtB,CAAC,aAAa;GACZ,IAAI,cACF,KAAK,MAAM,SAAS,cAClB,MAAM;IACJ,MAAM;IACN,OAAO;GACT;QAEG,IAAI,WAAW,KAAK,GAAG;IAC5B,MAAM,oBAAsC,CAAC;IAE7C,KAAK,MAAM,SAAS,mBAAmB,QAAQ,GAC7C,kBAAkB,KAAK;KACrB,SAAS;KACT,MAAM;IACR,CAAC;IAGH,OAAO;GACT;EACF;EACA,eACE,CAAC,CAAC,gBACD,QAAQ,KAAK,KAAK,mBAAmB,QAAQ,CAAC,CAAC,SAAS;EAC3D;EACA;EACA,iBAAiB,YAA+B;GAC9C,IAAI,CAAC,yBAA4B,UAAU,GACzC,OAAO;GAMT,cAAc,UAAU;GAExB,OAAO;EACT;EACA;EACA,MAAM;CACR;CAEA,SAAS,cAAc,cAA2C;EAEhE,KAAK,MAAM,QAAQ,WACjB,IAAI,CAAC,KAAK,eACR,aAAa,QAAQ,KAAK,IAAI;CAGpC;CAEA,cAAc,OAAO;AACvB"}
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright 2022 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/table/useTableColumnResizeState.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 { GridNode } from "../grid/grid-collection.js";
18
+ import { ColumnSize } from "./column.js";
19
+ import { TableState } from "./create-table-state.js";
20
+ import { Key } from "@solid2-aria/types-shared";
21
+ export interface TableColumnResizeStateProps<T> {
22
+ /**
23
+ * Current width of the table or table viewport that the columns
24
+ * should be calculated against.
25
+ */
26
+ tableWidth: number;
27
+ /** A function that is called to find the default width for a given column. */
28
+ getDefaultWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;
29
+ /** A function that is called to find the default minWidth for a given column. */
30
+ getDefaultMinWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;
31
+ }
32
+ export interface TableColumnResizeState<T> {
33
+ /**
34
+ * Called to update the state that a resize event has occurred.
35
+ * Returns the new widths for all columns based on the resized column.
36
+ */
37
+ updateResizedColumns: (key: Key, width: number) => Map<Key, ColumnSize>;
38
+ /** Callback for when onColumnResize has started. */
39
+ startResize: (key: Key) => void;
40
+ /** Callback for when onColumnResize has ended. */
41
+ endResize: () => void;
42
+ /** Gets the current width for the specified column. */
43
+ getColumnWidth: (key: Key) => number;
44
+ /** Gets the current minWidth for the specified column. */
45
+ getColumnMinWidth: (key: Key) => number;
46
+ /** Gets the current maxWidth for the specified column. */
47
+ getColumnMaxWidth: (key: Key) => number;
48
+ /** Key of the currently resizing column. */
49
+ resizingColumn: Key | null;
50
+ /** A reference to the table state. */
51
+ tableState: TableState<T>;
52
+ /** A map of the current column widths. */
53
+ columnWidths: Map<Key, number>;
54
+ }
55
+ /**
56
+ * Provides column width state management for a table component with column resizing support.
57
+ * Handles building a map of column widths calculated from the table's width and any provided column
58
+ * width information from the collection. In addition, it tracks the currently resizing column and
59
+ * provides callbacks for updating the widths upon resize operations.
60
+ *
61
+ * @param props - Props for the table.
62
+ * @param state - State for the table, as returned by `createTableState`.
63
+ */
64
+ export declare function createTableColumnResizeState<T>(props: TableColumnResizeStateProps<T>, state: TableState<T>): TableColumnResizeState<T>;
65
+ //# sourceMappingURL=create-table-column-resize-state.d.ts.map
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright 2022 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/table/useTableColumnResizeState.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 { requireValue } from "../utils/require-value.js";
18
+ import { TableColumnLayout } from "./table-column-layout.js";
19
+ import { createMemo, createRenderEffect, createSignal, untrack } from "solid-js";
20
+ // src/table/create-table-column-resize-state.ts
21
+ /**
22
+ * Provides column width state management for a table component with column resizing support.
23
+ * Handles building a map of column widths calculated from the table's width and any provided column
24
+ * width information from the collection. In addition, it tracks the currently resizing column and
25
+ * provides callbacks for updating the widths upon resize operations.
26
+ *
27
+ * @param props - Props for the table.
28
+ * @param state - State for the table, as returned by `createTableState`.
29
+ */
30
+ function createTableColumnResizeState(props, state) {
31
+ const [resizingColumn, setResizingColumn] = createSignal(null, { ownedWrite: true });
32
+ const columnLayout = createMemo(() => new TableColumnLayout({
33
+ get getDefaultMinWidth() {
34
+ return props.getDefaultMinWidth;
35
+ },
36
+ get getDefaultWidth() {
37
+ return props.getDefaultWidth;
38
+ }
39
+ }));
40
+ const columnGroups = createMemo(() => columnLayout().splitColumnsIntoControlledAndUncontrolled(state.collection.columns));
41
+ const [uncontrolledWidths, setUncontrolledWidths] = createSignal(untrack(() => columnLayout().getInitialUncontrolledWidths(columnGroups()[1])), { ownedWrite: true });
42
+ let lastColumns = untrack(() => state.collection.columns);
43
+ createRenderEffect(() => {
44
+ const { columns } = state.collection;
45
+ return {
46
+ columns,
47
+ widths: columns.length !== lastColumns.length || columns.some((column, i) => column.key !== lastColumns[i]?.key) ? columnLayout().getInitialUncontrolledWidths(columnGroups()[1]) : void 0
48
+ };
49
+ }, ({ columns, widths }) => {
50
+ if (widths) setUncontrolledWidths(widths);
51
+ lastColumns = columns;
52
+ });
53
+ const colWidths = createMemo(() => columnLayout().recombineColumns(state.collection.columns, uncontrolledWidths(), columnGroups()[1], columnGroups()[0]));
54
+ const startResize = (key) => {
55
+ setResizingColumn(key);
56
+ };
57
+ const updateResizedColumns = (key, width) => {
58
+ const newSizes = columnLayout().resizeColumnWidth(state.collection, uncontrolledWidths(), key, width);
59
+ const map = new Map([...columnGroups()[1]].map(([localKey]) => [localKey, requireValue(newSizes.get(localKey), "Resizing must produce a width for each column.")]));
60
+ map.set(key, width);
61
+ setUncontrolledWidths(map);
62
+ return newSizes;
63
+ };
64
+ const endResize = () => {
65
+ setResizingColumn(null);
66
+ };
67
+ const columnWidths = createMemo(() => columnLayout().buildColumnWidths(props.tableWidth ?? 0, state.collection, colWidths()));
68
+ return {
69
+ get columnWidths() {
70
+ return columnWidths();
71
+ },
72
+ get endResize() {
73
+ return endResize;
74
+ },
75
+ get getColumnMaxWidth() {
76
+ return (key) => columnLayout().getColumnMaxWidth(key);
77
+ },
78
+ get getColumnMinWidth() {
79
+ return (key) => columnLayout().getColumnMinWidth(key);
80
+ },
81
+ get getColumnWidth() {
82
+ return (key) => columnLayout().getColumnWidth(key);
83
+ },
84
+ get resizingColumn() {
85
+ return resizingColumn();
86
+ },
87
+ get startResize() {
88
+ return startResize;
89
+ },
90
+ get tableState() {
91
+ return state;
92
+ },
93
+ get updateResizedColumns() {
94
+ return updateResizedColumns;
95
+ }
96
+ };
97
+ }
98
+ export { createTableColumnResizeState };
99
+
100
+ //# sourceMappingURL=create-table-column-resize-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-table-column-resize-state.js","names":[],"sources":["../../src/table/create-table-column-resize-state.ts"],"sourcesContent":["/*\n * Copyright 2022 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/table/useTableColumnResizeState.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 { Key } from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n createSignal,\n createRenderEffect,\n untrack,\n} from \"solid-js\";\n\nimport type { GridNode } from \"../grid/grid-collection\";\nimport { requireValue } from \"../utils/require-value\";\nimport type { ColumnSize } from \"./column\";\nimport type { TableState } from \"./create-table-state\";\nimport { TableColumnLayout } from \"./table-column-layout\";\n\nexport interface TableColumnResizeStateProps<T> {\n /**\n * Current width of the table or table viewport that the columns\n * should be calculated against.\n */\n tableWidth: number;\n /** A function that is called to find the default width for a given column. */\n getDefaultWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;\n /** A function that is called to find the default minWidth for a given column. */\n getDefaultMinWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;\n}\n\nexport interface TableColumnResizeState<T> {\n /**\n * Called to update the state that a resize event has occurred.\n * Returns the new widths for all columns based on the resized column.\n */\n updateResizedColumns: (key: Key, width: number) => Map<Key, ColumnSize>;\n /** Callback for when onColumnResize has started. */\n startResize: (key: Key) => void;\n /** Callback for when onColumnResize has ended. */\n endResize: () => void;\n /** Gets the current width for the specified column. */\n getColumnWidth: (key: Key) => number;\n /** Gets the current minWidth for the specified column. */\n getColumnMinWidth: (key: Key) => number;\n /** Gets the current maxWidth for the specified column. */\n getColumnMaxWidth: (key: Key) => number;\n /** Key of the currently resizing column. */\n resizingColumn: Key | null;\n /** A reference to the table state. */\n tableState: TableState<T>;\n /** A map of the current column widths. */\n columnWidths: Map<Key, number>;\n}\n\n/**\n * Provides column width state management for a table component with column resizing support.\n * Handles building a map of column widths calculated from the table's width and any provided column\n * width information from the collection. In addition, it tracks the currently resizing column and\n * provides callbacks for updating the widths upon resize operations.\n *\n * @param props - Props for the table.\n * @param state - State for the table, as returned by `createTableState`.\n */\nexport function createTableColumnResizeState<T>(\n props: TableColumnResizeStateProps<T>,\n state: TableState<T>\n): TableColumnResizeState<T> {\n const [resizingColumn, setResizingColumn] = createSignal<Key | null>(null, {\n ownedWrite: true,\n });\n\n const columnLayout = createMemo(\n () =>\n new TableColumnLayout({\n get getDefaultMinWidth() {\n return props.getDefaultMinWidth;\n },\n get getDefaultWidth() {\n return props.getDefaultWidth;\n },\n })\n );\n\n const columnGroups = createMemo(() =>\n columnLayout().splitColumnsIntoControlledAndUncontrolled(\n state.collection.columns\n )\n );\n\n // uncontrolled column widths\n const [uncontrolledWidths, setUncontrolledWidths] = createSignal(\n untrack(() =>\n columnLayout().getInitialUncontrolledWidths(columnGroups()[1])\n ),\n { ownedWrite: true }\n );\n\n // Update uncontrolled widths if the columns changed.\n let lastColumns = untrack(() => state.collection.columns);\n\n createRenderEffect(\n () => {\n const { columns } = state.collection;\n\n const changed =\n columns.length !== lastColumns.length ||\n columns.some((column, i) => column.key !== lastColumns[i]?.key);\n\n return {\n columns,\n widths: changed\n ? columnLayout().getInitialUncontrolledWidths(columnGroups()[1])\n : undefined,\n };\n },\n ({ columns, widths }) => {\n if (widths) {\n setUncontrolledWidths(widths);\n }\n\n lastColumns = columns;\n }\n );\n\n // combine columns back into one map that maintains same order as the columns\n const colWidths = createMemo(() =>\n columnLayout().recombineColumns(\n state.collection.columns,\n uncontrolledWidths(),\n columnGroups()[1],\n columnGroups()[0]\n )\n );\n\n const startResize = (key: Key) => {\n setResizingColumn(key);\n };\n\n const updateResizedColumns = (\n key: Key,\n width: number\n ): Map<Key, ColumnSize> => {\n const newSizes = columnLayout().resizeColumnWidth(\n state.collection,\n uncontrolledWidths(),\n key,\n width\n );\n\n const map = new Map(\n [...columnGroups()[1]].map(([localKey]) => [\n localKey,\n requireValue(\n newSizes.get(localKey),\n \"Resizing must produce a width for each column.\"\n ),\n ])\n );\n\n map.set(key, width);\n setUncontrolledWidths(map);\n\n return newSizes;\n };\n\n const endResize = () => {\n setResizingColumn(null);\n };\n\n const columnWidths = createMemo(() =>\n columnLayout().buildColumnWidths(\n props.tableWidth ?? 0,\n state.collection,\n colWidths()\n )\n );\n\n return {\n get columnWidths() {\n return columnWidths();\n },\n get endResize() {\n return endResize;\n },\n get getColumnMaxWidth() {\n return (key: Key) => columnLayout().getColumnMaxWidth(key);\n },\n get getColumnMinWidth() {\n return (key: Key) => columnLayout().getColumnMinWidth(key);\n },\n get getColumnWidth() {\n return (key: Key) => columnLayout().getColumnWidth(key);\n },\n get resizingColumn() {\n return resizingColumn();\n },\n get startResize() {\n return startResize;\n },\n get tableState() {\n return state;\n },\n get updateResizedColumns() {\n return updateResizedColumns;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,6BACd,OACA,OAC2B;CAC3B,MAAM,CAAC,gBAAgB,qBAAqB,aAAyB,MAAM,EACzE,YAAY,KACd,CAAC;CAED,MAAM,eAAe,iBAEjB,IAAI,kBAAkB;EACpB,IAAI,qBAAqB;GACvB,OAAO,MAAM;EACf;EACA,IAAI,kBAAkB;GACpB,OAAO,MAAM;EACf;CACF,CAAC,CACL;CAEA,MAAM,eAAe,iBACnB,aAAa,CAAC,CAAC,0CACb,MAAM,WAAW,OACnB,CACF;CAGA,MAAM,CAAC,oBAAoB,yBAAyB,aAClD,cACE,aAAa,CAAC,CAAC,6BAA6B,aAAa,CAAC,CAAC,EAAE,CAC/D,GACA,EAAE,YAAY,KAAK,CACrB;CAGA,IAAI,cAAc,cAAc,MAAM,WAAW,OAAO;CAExD,yBACQ;EACJ,MAAM,EAAE,YAAY,MAAM;EAM1B,OAAO;GACL;GACA,QALA,QAAQ,WAAW,YAAY,UAC/B,QAAQ,MAAM,QAAQ,MAAM,OAAO,QAAQ,YAAY,EAAE,EAAE,GAAG,IAK1D,aAAa,CAAC,CAAC,6BAA6B,aAAa,CAAC,CAAC,EAAE,IAC7D,KAAA;EACN;CACF,IACC,EAAE,SAAS,aAAa;EACvB,IAAI,QACF,sBAAsB,MAAM;EAG9B,cAAc;CAChB,CACF;CAGA,MAAM,YAAY,iBAChB,aAAa,CAAC,CAAC,iBACb,MAAM,WAAW,SACjB,mBAAmB,GACnB,aAAa,CAAC,CAAC,IACf,aAAa,CAAC,CAAC,EACjB,CACF;CAEA,MAAM,eAAe,QAAa;EAChC,kBAAkB,GAAG;CACvB;CAEA,MAAM,wBACJ,KACA,UACyB;EACzB,MAAM,WAAW,aAAa,CAAC,CAAC,kBAC9B,MAAM,YACN,mBAAmB,GACnB,KACA,KACF;EAEA,MAAM,MAAM,IAAI,IACd,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CACzC,UACA,aACE,SAAS,IAAI,QAAQ,GACrB,gDACF,CACF,CAAC,CACH;EAEA,IAAI,IAAI,KAAK,KAAK;EAClB,sBAAsB,GAAG;EAEzB,OAAO;CACT;CAEA,MAAM,kBAAkB;EACtB,kBAAkB,IAAI;CACxB;CAEA,MAAM,eAAe,iBACnB,aAAa,CAAC,CAAC,kBACb,MAAM,cAAc,GACpB,MAAM,YACN,UAAU,CACZ,CACF;CAEA,OAAO;EACL,IAAI,eAAe;GACjB,OAAO,aAAa;EACtB;EACA,IAAI,YAAY;GACd,OAAO;EACT;EACA,IAAI,oBAAoB;GACtB,QAAQ,QAAa,aAAa,CAAC,CAAC,kBAAkB,GAAG;EAC3D;EACA,IAAI,oBAAoB;GACtB,QAAQ,QAAa,aAAa,CAAC,CAAC,kBAAkB,GAAG;EAC3D;EACA,IAAI,iBAAiB;GACnB,QAAQ,QAAa,aAAa,CAAC,CAAC,eAAe,GAAG;EACxD;EACA,IAAI,iBAAiB;GACnB,OAAO,eAAe;EACxB;EACA,IAAI,cAAc;GAChB,OAAO;EACT;EACA,IAAI,aAAa;GACf,OAAO;EACT;EACA,IAAI,uBAAuB;GACzB,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,112 @@
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/table/useTableState.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 { MultipleSelectionState } from "../selection/types.js";
18
+ import { MultipleSelectionStateProps } from "../selection/create-multiple-selection-state.js";
19
+ import { GridState } from "../grid/create-grid-state.js";
20
+ import { ITableCollection } from "./table-collection.js";
21
+ import { Element } from "solid-js";
22
+ import { Expandable, Key, MultipleSelection, Node, SelectionMode, SortDescriptor, Sortable } from "@solid2-aria/types-shared";
23
+ export interface TableProps<_T> extends MultipleSelection, Sortable, Expandable {
24
+ /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */
25
+ children: [Element, Element];
26
+ /** A list of row keys to disable. */
27
+ disabledKeys?: Iterable<Key>;
28
+ /**
29
+ * Whether pressing the escape key should clear selection in the table or not.
30
+ *
31
+ * Most experiences should not modify this option as it eliminates a keyboard user's ability to
32
+ * easily clear selection. Only use if the escape key is being handled externally or should not
33
+ * trigger selection clearing contextually.
34
+ *
35
+ * @default 'clearSelection'
36
+ */
37
+ escapeKeyBehavior?: "clearSelection" | "none";
38
+ /** Whether selection should occur on press up instead of press down. */
39
+ shouldSelectOnPressUp?: boolean;
40
+ /** The id of the column that displays hierarchical data. */
41
+ treeColumn?: Key;
42
+ /**
43
+ * Whether keyboard navigation to focusable elements within the cells is
44
+ * via the left/right arrow keys or the tab key.
45
+ *
46
+ * @default 'arrow'
47
+ */
48
+ keyboardNavigationBehavior?: "arrow" | "tab";
49
+ }
50
+ export interface TableState<T> extends GridState<T, ITableCollection<T>> {
51
+ /** A collection of rows and columns in the table. */
52
+ collection: ITableCollection<T>;
53
+ /** Whether the row selection checkboxes should be displayed. */
54
+ showSelectionCheckboxes: boolean;
55
+ /** The current sorted column and direction. */
56
+ sortDescriptor: SortDescriptor | null;
57
+ /** Calls the provided onSortChange handler with the provided column key and sort direction. */
58
+ sort: (columnKey: Key, direction?: "ascending" | "descending") => void;
59
+ /**
60
+ * Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a
61
+ * component within a cell.
62
+ */
63
+ isKeyboardNavigationDisabled: boolean;
64
+ /**
65
+ * Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a
66
+ * component within a cell.
67
+ */
68
+ setKeyboardNavigationDisabled: (val: boolean) => void;
69
+ /** A set of keys for items that are expanded. */
70
+ expandedKeys: Set<Key>;
71
+ /** Toggles the expanded state for a row by its key. */
72
+ toggleKey: (key: Key) => void;
73
+ /** The id of the column that displays hierarchical data. */
74
+ treeColumn: Key | null;
75
+ }
76
+ export interface CollectionBuilderContext<T> {
77
+ showSelectionCheckboxes: boolean;
78
+ showDragButtons: boolean;
79
+ selectionMode: SelectionMode;
80
+ columns: Node<T>[];
81
+ }
82
+ export interface TableStateProps<T> extends MultipleSelectionStateProps, Expandable, Sortable {
83
+ /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */
84
+ children?: [Element, Element];
85
+ /** A pre-constructed collection to use instead of building one from items and children. */
86
+ collection?: ITableCollection<T>;
87
+ /** Whether the row selection checkboxes should be displayed. */
88
+ showSelectionCheckboxes?: boolean;
89
+ /**
90
+ * Whether the row drag button should be displayed.
91
+ *
92
+ * @private
93
+ */
94
+ showDragButtons?: boolean;
95
+ /**
96
+ * Do not use unless you know what you're doing.
97
+ * @private
98
+ */
99
+ UNSAFE_selectionState?: MultipleSelectionState;
100
+ /** The id of the column that displays hierarchical data. */
101
+ treeColumn?: Key;
102
+ }
103
+ /**
104
+ * Provides state management for a table component. Handles building a collection of columns and
105
+ * rows from props. In addition, it tracks row selection and manages sort order changes.
106
+ */
107
+ export declare function createTableState<T extends object>(props: TableStateProps<T>): TableState<T>;
108
+ /**
109
+ * Filters a collection using the provided filter function and returns a new TableState.
110
+ */
111
+ export declare function UNSTABLE_createFilteredTableState<T extends object>(state: TableState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): TableState<T>;
112
+ //# sourceMappingURL=create-table-state.d.ts.map
@@ -0,0 +1,122 @@
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/table/useTableState.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 { createCollection } from "../collections/create-collection.js";
19
+ import { requireValue } from "../utils/require-value.js";
20
+ import { createGridState } from "../grid/create-grid-state.js";
21
+ import { TableCollection } from "./table-collection.js";
22
+ import { createMemo, createSignal, merge, untrack } from "solid-js";
23
+ // src/table/create-table-state.ts
24
+ const OPPOSITE_SORT_DIRECTION = {
25
+ get ascending() {
26
+ return "descending";
27
+ },
28
+ get descending() {
29
+ return "ascending";
30
+ }
31
+ };
32
+ /**
33
+ * Provides state management for a table component. Handles building a collection of columns and
34
+ * rows from props. In addition, it tracks row selection and manages sort order changes.
35
+ */
36
+ function createTableState(props) {
37
+ const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = createSignal(false, { ownedWrite: true });
38
+ const context = createMemo(() => {
39
+ props.children;
40
+ return {
41
+ columns: [],
42
+ selectionMode: props.selectionMode ?? "none",
43
+ showDragButtons: props.showDragButtons === true,
44
+ showSelectionCheckboxes: props.showSelectionCheckboxes === true && (props.selectionMode ?? "none") !== "none"
45
+ };
46
+ });
47
+ const collection = createCollection(props, (nodes) => new TableCollection(nodes, null, context()), context);
48
+ const gridState = createGridState(merge(props, {
49
+ get collection() {
50
+ return collection();
51
+ },
52
+ get disabledBehavior() {
53
+ return props.disabledBehavior ?? "selection";
54
+ }
55
+ }));
56
+ const [expandedKeys, setExpandedKeys] = createControlledSignal(() => props.expandedKeys ? new Set(props.expandedKeys) : void 0, untrack(() => props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : /* @__PURE__ */ new Set()), (keys) => {
57
+ props.onExpandedChange?.(keys);
58
+ });
59
+ return {
60
+ get collection() {
61
+ return collection();
62
+ },
63
+ get disabledKeys() {
64
+ return gridState.disabledKeys;
65
+ },
66
+ get expandedKeys() {
67
+ return expandedKeys();
68
+ },
69
+ get isKeyboardNavigationDisabled() {
70
+ return collection().size === 0 || isKeyboardNavigationDisabled();
71
+ },
72
+ get selectionManager() {
73
+ return gridState.selectionManager;
74
+ },
75
+ get setKeyboardNavigationDisabled() {
76
+ return setKeyboardNavigationDisabled;
77
+ },
78
+ get showSelectionCheckboxes() {
79
+ return props.showSelectionCheckboxes === true || false;
80
+ },
81
+ sort(columnKey, direction) {
82
+ const current = props.sortDescriptor;
83
+ const nextDirection = direction ?? (current?.column === columnKey ? OPPOSITE_SORT_DIRECTION[current.direction] : "ascending");
84
+ props.onSortChange?.({
85
+ column: columnKey,
86
+ direction: nextDirection
87
+ });
88
+ },
89
+ get sortDescriptor() {
90
+ return props.sortDescriptor ?? null;
91
+ },
92
+ toggleKey(key) {
93
+ setExpandedKeys((keys) => {
94
+ const newKeys = new Set(keys);
95
+ if (newKeys.has(key)) newKeys.delete(key);
96
+ else newKeys.add(key);
97
+ return newKeys;
98
+ });
99
+ },
100
+ get treeColumn() {
101
+ return props.treeColumn ?? null;
102
+ }
103
+ };
104
+ }
105
+ /**
106
+ * Filters a collection using the provided filter function and returns a new TableState.
107
+ */
108
+ function UNSTABLE_createFilteredTableState(state, filterFn) {
109
+ const collection = createMemo(() => filterFn ? requireValue(state.collection.filter, "Expected state.collection.filter to exist.")(filterFn) : state.collection);
110
+ const selectionManager = createMemo(() => state.selectionManager.withCollection(collection()));
111
+ return merge(state, {
112
+ get collection() {
113
+ return collection();
114
+ },
115
+ get selectionManager() {
116
+ return selectionManager();
117
+ }
118
+ });
119
+ }
120
+ export { UNSTABLE_createFilteredTableState, createTableState };
121
+
122
+ //# sourceMappingURL=create-table-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-table-state.js","names":[],"sources":["../../src/table/create-table-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/table/useTableState.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 Expandable,\n Key,\n MultipleSelection,\n Node,\n SelectionMode,\n Sortable,\n SortDescriptor,\n SortDirection,\n} from \"@solid2-aria/types-shared\";\nimport type { Element as SolidElement } from \"solid-js\";\nimport { createMemo, createSignal, merge, untrack } from \"solid-js\";\n\nimport { createCollection } from \"../collections/create-collection\";\nimport { createGridState } from \"../grid/create-grid-state\";\nimport type { GridState } from \"../grid/create-grid-state\";\nimport type { MultipleSelectionStateProps } from \"../selection/create-multiple-selection-state\";\nimport type { MultipleSelectionState } from \"../selection/types\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport { requireValue } from \"../utils/require-value\";\nimport { TableCollection } from \"./table-collection\";\nimport type { ITableCollection } from \"./table-collection\";\n\nexport interface TableProps<_T>\n extends MultipleSelection, Sortable, Expandable {\n /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */\n children: [SolidElement, SolidElement];\n /** A list of row keys to disable. */\n disabledKeys?: Iterable<Key>;\n /**\n * Whether pressing the escape key should clear selection in the table or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: \"clearSelection\" | \"none\";\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n /** The id of the column that displays hierarchical data. */\n treeColumn?: Key;\n /**\n * Whether keyboard navigation to focusable elements within the cells is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: \"arrow\" | \"tab\";\n}\n\nexport interface TableState<T> extends GridState<T, ITableCollection<T>> {\n /** A collection of rows and columns in the table. */\n collection: ITableCollection<T>;\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes: boolean;\n /** The current sorted column and direction. */\n sortDescriptor: SortDescriptor | null;\n /** Calls the provided onSortChange handler with the provided column key and sort direction. */\n sort: (columnKey: Key, direction?: \"ascending\" | \"descending\") => void;\n /**\n * Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a\n * component within a cell.\n */\n isKeyboardNavigationDisabled: boolean;\n /**\n * Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a\n * component within a cell.\n */\n setKeyboardNavigationDisabled: (val: boolean) => void;\n /** A set of keys for items that are expanded. */\n expandedKeys: Set<Key>;\n /** Toggles the expanded state for a row by its key. */\n toggleKey: (key: Key) => void;\n /** The id of the column that displays hierarchical data. */\n treeColumn: Key | null;\n}\n\nexport interface CollectionBuilderContext<T> {\n showSelectionCheckboxes: boolean;\n showDragButtons: boolean;\n selectionMode: SelectionMode;\n columns: Node<T>[];\n}\n\nexport interface TableStateProps<T>\n extends MultipleSelectionStateProps, Expandable, Sortable {\n /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */\n children?: [SolidElement, SolidElement];\n /** A pre-constructed collection to use instead of building one from items and children. */\n collection?: ITableCollection<T>;\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes?: boolean;\n /**\n * Whether the row drag button should be displayed.\n *\n * @private\n */\n showDragButtons?: boolean;\n /**\n * Do not use unless you know what you're doing.\n * @private\n */\n UNSAFE_selectionState?: MultipleSelectionState;\n /** The id of the column that displays hierarchical data. */\n treeColumn?: Key;\n}\n\nconst OPPOSITE_SORT_DIRECTION: Record<SortDirection, SortDirection> = {\n get ascending(): SortDirection {\n return \"descending\";\n },\n get descending(): SortDirection {\n return \"ascending\";\n },\n};\n\n/**\n * Provides state management for a table component. Handles building a collection of columns and\n * rows from props. In addition, it tracks row selection and manages sort order changes.\n */\nexport function createTableState<T extends object>(\n props: TableStateProps<T>\n): TableState<T> {\n const [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] =\n createSignal(false, { ownedWrite: true });\n\n const context = createMemo<CollectionBuilderContext<T>>(() => {\n const _children = props.children;\n\n return {\n columns: [],\n selectionMode: props.selectionMode ?? \"none\",\n showDragButtons: props.showDragButtons === true,\n showSelectionCheckboxes:\n props.showSelectionCheckboxes === true &&\n (props.selectionMode ?? \"none\") !== \"none\",\n };\n });\n\n const collection = createCollection<T, ITableCollection<T>>(\n props,\n (nodes) => new TableCollection(nodes, null, context()),\n context\n );\n\n const gridState = createGridState(\n merge(props, {\n get collection() {\n return collection();\n },\n get disabledBehavior() {\n return props.disabledBehavior ?? \"selection\";\n },\n })\n );\n\n const [expandedKeys, setExpandedKeys] = createControlledSignal(\n () => (props.expandedKeys ? new Set(props.expandedKeys) : undefined),\n untrack(() =>\n props.defaultExpandedKeys\n ? new Set(props.defaultExpandedKeys)\n : new Set<Key>()\n ),\n (keys) => {\n props.onExpandedChange?.(keys);\n }\n );\n\n return {\n get collection() {\n return collection();\n },\n get disabledKeys() {\n return gridState.disabledKeys;\n },\n get expandedKeys() {\n return expandedKeys();\n },\n get isKeyboardNavigationDisabled() {\n return collection().size === 0 || isKeyboardNavigationDisabled();\n },\n get selectionManager() {\n return gridState.selectionManager;\n },\n get setKeyboardNavigationDisabled() {\n return setKeyboardNavigationDisabled;\n },\n get showSelectionCheckboxes() {\n return props.showSelectionCheckboxes === true || false;\n },\n sort(columnKey: Key, direction?: \"ascending\" | \"descending\") {\n const current = props.sortDescriptor;\n\n const nextDirection =\n direction ??\n (current?.column === columnKey\n ? OPPOSITE_SORT_DIRECTION[current.direction]\n : \"ascending\");\n\n props.onSortChange?.({ column: columnKey, direction: nextDirection });\n },\n get sortDescriptor() {\n return props.sortDescriptor ?? null;\n },\n toggleKey(key) {\n setExpandedKeys((keys) => {\n const newKeys = new Set(keys);\n\n if (newKeys.has(key)) {\n newKeys.delete(key);\n } else {\n newKeys.add(key);\n }\n\n return newKeys;\n });\n },\n get treeColumn() {\n return props.treeColumn ?? null;\n },\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new TableState.\n */\nexport function UNSTABLE_createFilteredTableState<T extends object>(\n state: TableState<T>,\n filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined\n): TableState<T> {\n const collection = createMemo(() =>\n filterFn\n ? requireValue(\n state.collection.filter,\n \"Expected state.collection.filter to exist.\"\n )(filterFn)\n : state.collection\n );\n\n const selectionManager = createMemo(() =>\n state.selectionManager.withCollection(collection())\n );\n\n // handle focus key reset? That logic is in createGridState\n return merge(state, {\n get collection() {\n return collection();\n },\n get selectionManager() {\n return selectionManager();\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8HA,MAAM,0BAAgE;CACpE,IAAI,YAA2B;EAC7B,OAAO;CACT;CACA,IAAI,aAA4B;EAC9B,OAAO;CACT;AACF;;;;;AAMA,SAAgB,iBACd,OACe;CACf,MAAM,CAAC,8BAA8B,iCACnC,aAAa,OAAO,EAAE,YAAY,KAAK,CAAC;CAE1C,MAAM,UAAU,iBAA8C;EAC1C,MAAM;EAExB,OAAO;GACL,SAAS,CAAC;GACV,eAAe,MAAM,iBAAiB;GACtC,iBAAiB,MAAM,oBAAoB;GAC3C,yBACE,MAAM,4BAA4B,SACjC,MAAM,iBAAiB,YAAY;EACxC;CACF,CAAC;CAED,MAAM,aAAa,iBACjB,QACC,UAAU,IAAI,gBAAgB,OAAO,MAAM,QAAQ,CAAC,GACrD,OACF;CAEA,MAAM,YAAY,gBAChB,MAAM,OAAO;EACX,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA,IAAI,mBAAmB;GACrB,OAAO,MAAM,oBAAoB;EACnC;CACF,CAAC,CACH;CAEA,MAAM,CAAC,cAAc,mBAAmB,6BAC/B,MAAM,eAAe,IAAI,IAAI,MAAM,YAAY,IAAI,KAAA,GAC1D,cACE,MAAM,sBACF,IAAI,IAAI,MAAM,mBAAmB,oBACjC,IAAI,IAAS,CACnB,IACC,SAAS;EACR,MAAM,mBAAmB,IAAI;CAC/B,CACF;CAEA,OAAO;EACL,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA,IAAI,eAAe;GACjB,OAAO,UAAU;EACnB;EACA,IAAI,eAAe;GACjB,OAAO,aAAa;EACtB;EACA,IAAI,+BAA+B;GACjC,OAAO,WAAW,CAAC,CAAC,SAAS,KAAK,6BAA6B;EACjE;EACA,IAAI,mBAAmB;GACrB,OAAO,UAAU;EACnB;EACA,IAAI,gCAAgC;GAClC,OAAO;EACT;EACA,IAAI,0BAA0B;GAC5B,OAAO,MAAM,4BAA4B,QAAQ;EACnD;EACA,KAAK,WAAgB,WAAwC;GAC3D,MAAM,UAAU,MAAM;GAEtB,MAAM,gBACJ,cACC,SAAS,WAAW,YACjB,wBAAwB,QAAQ,aAChC;GAEN,MAAM,eAAe;IAAE,QAAQ;IAAW,WAAW;GAAc,CAAC;EACtE;EACA,IAAI,iBAAiB;GACnB,OAAO,MAAM,kBAAkB;EACjC;EACA,UAAU,KAAK;GACb,iBAAiB,SAAS;IACxB,MAAM,UAAU,IAAI,IAAI,IAAI;IAE5B,IAAI,QAAQ,IAAI,GAAG,GACjB,QAAQ,OAAO,GAAG;SAElB,QAAQ,IAAI,GAAG;IAGjB,OAAO;GACT,CAAC;EACH;EACA,IAAI,aAAa;GACf,OAAO,MAAM,cAAc;EAC7B;CACF;AACF;;;;AAKA,SAAgB,kCACd,OACA,UACe;CACf,MAAM,aAAa,iBACjB,WACI,aACE,MAAM,WAAW,QACjB,4CACF,CAAC,CAAC,QAAQ,IACV,MAAM,UACZ;CAEA,MAAM,mBAAmB,iBACvB,MAAM,iBAAiB,eAAe,WAAW,CAAC,CACpD;CAGA,OAAO,MAAM,OAAO;EAClB,IAAI,aAAa;GACf,OAAO,WAAW;EACpB;EACA,IAAI,mBAAmB;GACrB,OAAO,iBAAiB;EAC1B;CACF,CAAC;AACH"}
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2023 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/table/useTreeGridState.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 { GridNode } from "../grid/grid-collection.js";
18
+ import { TableState, TableStateProps } from "./create-table-state.js";
19
+ import { Key } from "@solid2-aria/types-shared";
20
+ export interface TreeGridState<T> extends Omit<TableState<T>, "expandedKeys"> {
21
+ /** A set of keys for items that are expanded. */
22
+ expandedKeys: "all" | Set<Key>;
23
+ /** Toggles the expanded state for a row by its key. */
24
+ toggleKey: (key: Key) => void;
25
+ /** The key map containing nodes representing the collection's tree grid structure. */
26
+ keyMap: Map<Key, GridNode<T>>;
27
+ /** The number of leaf columns provided by the user. */
28
+ userColumnCount: number;
29
+ }
30
+ export interface TreeGridStateProps<T> extends Omit<TableStateProps<T>, "collection"> {
31
+ /** The currently expanded keys in the collection (controlled). */
32
+ UNSTABLE_expandedKeys?: "all" | Iterable<Key>;
33
+ /** The initial expanded keys in the collection (uncontrolled). */
34
+ UNSTABLE_defaultExpandedKeys?: "all" | Iterable<Key>;
35
+ /** Handler that is called when items are expanded or collapsed. */
36
+ UNSTABLE_onExpandedChange?: (keys: Set<Key>) => void;
37
+ }
38
+ /**
39
+ * Provides state management for a tree grid component. Handles building a collection of columns and
40
+ * rows from props. In addition, it tracks and manages expanded rows, row selection, and sort order
41
+ * changes.
42
+ */
43
+ export declare function UNSTABLE_createTreeGridState<T extends object>(props: TreeGridStateProps<T>): TreeGridState<T>;
44
+ //# sourceMappingURL=create-tree-grid-state.d.ts.map