@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,450 @@
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/combobox/useComboBoxState.ts.
14
+ * Modified for Solid Aria: adapted reactive state, getters, imports, and APIs for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ import { createControlledSignal } from "../utils/create-controlled-signal.js";
18
+ import { getLegacyDefaultSelectedKey, getLegacySelectedKey, notifyLegacySelectionChange } from "../utils/legacy-props.js";
19
+ import { createFormValidationState } from "../form/create-form-validation-state.js";
20
+ import { getChildNodes } from "../collections/get-child-nodes.js";
21
+ import { ListCollection } from "../list/list-collection.js";
22
+ import { createListState } from "../list/create-list-state.js";
23
+ import { createOverlayTriggerState } from "../overlays/create-overlay-trigger-state.js";
24
+ import { createMemo, createRenderEffect, createSignal, merge, untrack } from "solid-js";
25
+ // src/combobox/create-combo-box-state.ts
26
+ /**
27
+ * Provides state management for a combo box component. Handles building a collection of items from
28
+ * props and manages the option selection state of the combo box. In addition, it tracks the input
29
+ * value, focus state, and other properties of the combo box.
30
+ */
31
+ function createComboBoxState(props) {
32
+ const defaultFilter = createMemo(() => props.defaultFilter);
33
+ const menuTrigger = createMemo(() => props.menuTrigger ?? "input");
34
+ const allowsEmptyCollection = createMemo(() => props.allowsEmptyCollection ?? false);
35
+ const allowsCustomValue = createMemo(() => props.allowsCustomValue);
36
+ const shouldCloseOnBlur = createMemo(() => props.shouldCloseOnBlur ?? true);
37
+ const selectionMode = createMemo(() => props.selectionMode ?? "single");
38
+ const [showAllItems, setShowAllItems] = createSignal(false, { ownedWrite: true });
39
+ const [isFocused, setFocusedState] = createSignal(false, { ownedWrite: true });
40
+ const [focusStrategy, setFocusStrategy] = createSignal(null, { ownedWrite: true });
41
+ let closedDueToEmpty = false;
42
+ const defaultValue = createMemo(() => {
43
+ const currentSelectionMode = selectionMode();
44
+ return props.defaultValue ?? (currentSelectionMode === "single" ? getLegacyDefaultSelectedKey(props) ?? null : []);
45
+ });
46
+ const value = createMemo(() => {
47
+ const currentSelectionMode = selectionMode();
48
+ return props.value ?? (currentSelectionMode === "single" ? getLegacySelectedKey(props) : void 0);
49
+ });
50
+ const [controlledValue, setControlledValue] = createControlledSignal(() => value(), untrack(() => defaultValue()), (localValue) => {
51
+ const change = isKeyArray(localValue) ? [...localValue] : localValue;
52
+ props.onChange?.(change);
53
+ });
54
+ const displayValue = createMemo(() => {
55
+ const currentSelectionMode = selectionMode();
56
+ const currentControlledValue = controlledValue();
57
+ return currentSelectionMode === "single" && isKeyArray(currentControlledValue) ? currentControlledValue[0] ?? null : currentControlledValue;
58
+ });
59
+ const setValue = (localValue) => {
60
+ const currentSelectionMode = selectionMode();
61
+ const currentDisplayValue = displayValue();
62
+ if (currentSelectionMode === "single") {
63
+ const key = isKeyArray(localValue) ? localValue[0] ?? null : localValue;
64
+ setControlledValue(key);
65
+ if (key !== currentDisplayValue) notifyLegacySelectionChange(props, key);
66
+ } else {
67
+ let keys = [];
68
+ if (isKeyArray(localValue)) keys = [...localValue];
69
+ else if (localValue !== null && localValue !== void 0) keys = [localValue];
70
+ setControlledValue(keys);
71
+ }
72
+ };
73
+ const derivedProperty0 = createMemo(() => {
74
+ return convertValue(displayValue());
75
+ });
76
+ const listState = createListState(merge(props, {
77
+ get allowDuplicateSelectionEvents() {
78
+ return true;
79
+ },
80
+ get disallowEmptySelection() {
81
+ return selectionMode() === "single";
82
+ },
83
+ get items() {
84
+ return props.items ?? props.defaultItems;
85
+ },
86
+ get onSelectionChange() {
87
+ return (keys) => {
88
+ const currentSelectionMode = selectionMode();
89
+ const currentDisplayValue = displayValue();
90
+ if (keys === "all") return;
91
+ if (currentSelectionMode === "single") {
92
+ const key = keys.values().next().value ?? null;
93
+ if (key === currentDisplayValue) {
94
+ notifyLegacySelectionChange(props, key);
95
+ resetInputValue();
96
+ closeMenu();
97
+ } else setValue(key);
98
+ } else setValue([...keys]);
99
+ };
100
+ },
101
+ get selectedKeys() {
102
+ return derivedProperty0();
103
+ },
104
+ get selectionMode() {
105
+ return selectionMode();
106
+ }
107
+ }));
108
+ const collection = createMemo(() => listState.collection);
109
+ const selectionManager = createMemo(() => listState.selectionManager);
110
+ const disabledKeys = createMemo(() => listState.disabledKeys);
111
+ const selectedKey = createMemo(() => {
112
+ const currentSelectionMode = selectionMode();
113
+ const currentSelectionManager = selectionManager();
114
+ return currentSelectionMode === "single" ? currentSelectionManager.firstSelectedKey : null;
115
+ });
116
+ const selectedItems = createMemo(() => {
117
+ return [...selectionManager().selectedKeys].flatMap((key) => {
118
+ const item = collection().getItem(key);
119
+ return item === null || item === void 0 ? [] : [item];
120
+ });
121
+ });
122
+ const [inputValue, setInputValue] = createControlledSignal(() => props.inputValue, untrack(() => {
123
+ const currentSelectedKey = selectedKey();
124
+ const currentCollection = collection();
125
+ return getDefaultInputValue(props.defaultInputValue, currentSelectedKey, currentCollection) ?? "";
126
+ }), (localValue) => {
127
+ props.onInputChange?.(localValue);
128
+ });
129
+ const initialValue = untrack(() => displayValue());
130
+ const initialInputValue = untrack(() => inputValue());
131
+ const originalCollection = createMemo(() => collection());
132
+ const filteredCollection = createMemo(() => {
133
+ const currentDefaultFilter = defaultFilter();
134
+ const currentCollection = collection();
135
+ const currentInputValue = inputValue();
136
+ return props.items !== null && props.items !== void 0 || !currentDefaultFilter ? currentCollection : filterCollection(currentCollection, currentInputValue, currentDefaultFilter);
137
+ });
138
+ const [lastCollection, setLastCollection] = createSignal(untrack(() => filteredCollection()), { ownedWrite: true });
139
+ let menuOpenTrigger = "focus";
140
+ const onOpenChange = (open) => {
141
+ const currentSelectionManager = selectionManager();
142
+ if (props.onOpenChange) props.onOpenChange(open, open ? menuOpenTrigger : void 0);
143
+ currentSelectionManager.setFocused(open);
144
+ if (!open) currentSelectionManager.setFocusedKey(null);
145
+ };
146
+ const triggerState = createOverlayTriggerState(merge(props, {
147
+ defaultOpen: void 0,
148
+ isOpen: void 0,
149
+ onOpenChange
150
+ }));
151
+ const open = (localFocusStrategy = null, trigger) => {
152
+ const currentMenuTrigger = menuTrigger();
153
+ const currentAllowsEmptyCollection = allowsEmptyCollection();
154
+ const currentFilteredCollection = filteredCollection();
155
+ const currentOriginalCollection = originalCollection();
156
+ const displayAllItems = trigger === "manual" || trigger === "focus" && currentMenuTrigger === "focus";
157
+ if (currentAllowsEmptyCollection || currentFilteredCollection.size > 0 || displayAllItems && currentOriginalCollection.size > 0 || props.items) {
158
+ if (displayAllItems && !triggerState.isOpen && props.items === void 0) setShowAllItems(true);
159
+ menuOpenTrigger = trigger;
160
+ setFocusStrategy(localFocusStrategy);
161
+ triggerState.open();
162
+ }
163
+ };
164
+ const toggle = (localFocusStrategy = null, trigger) => {
165
+ const currentMenuTrigger = menuTrigger();
166
+ const currentAllowsEmptyCollection = allowsEmptyCollection();
167
+ const currentFilteredCollection = filteredCollection();
168
+ const currentOriginalCollection = originalCollection();
169
+ const displayAllItems = trigger === "manual" || trigger === "focus" && currentMenuTrigger === "focus";
170
+ if (!currentAllowsEmptyCollection && !(currentFilteredCollection.size > 0) && (!displayAllItems || !(currentOriginalCollection.size > 0)) && !props.items && !triggerState.isOpen) return;
171
+ if (displayAllItems && !triggerState.isOpen && props.items === void 0) setShowAllItems(true);
172
+ if (!triggerState.isOpen) menuOpenTrigger = trigger;
173
+ toggleMenu(localFocusStrategy);
174
+ };
175
+ const updateLastCollection = () => {
176
+ const currentShowAllItems = showAllItems();
177
+ const currentOriginalCollection = originalCollection();
178
+ const currentFilteredCollection = filteredCollection();
179
+ setLastCollection(currentShowAllItems ? currentOriginalCollection : currentFilteredCollection);
180
+ };
181
+ function toggleMenu(localFocusStrategy = null) {
182
+ if (triggerState.isOpen) updateLastCollection();
183
+ setFocusStrategy(localFocusStrategy);
184
+ triggerState.toggle();
185
+ }
186
+ function closeMenu() {
187
+ if (triggerState.isOpen) {
188
+ updateLastCollection();
189
+ triggerState.close();
190
+ }
191
+ }
192
+ const [lastValue, setLastValue] = createSignal(untrack(() => inputValue()), { ownedWrite: true });
193
+ function resetInputValue() {
194
+ const currentSelectedKey = selectedKey();
195
+ const currentCollection = collection();
196
+ const itemText = currentSelectedKey === null || currentSelectedKey === void 0 ? "" : currentCollection.getItem(currentSelectedKey)?.textValue ?? "";
197
+ setLastValue(itemText);
198
+ setInputValue(itemText);
199
+ }
200
+ let previousValue = untrack(() => displayValue());
201
+ let lastSelectedKeyText = untrack(() => {
202
+ const currentSelectedKey = selectedKey();
203
+ const currentCollection = collection();
204
+ return currentSelectedKey === null || currentSelectedKey === void 0 ? "" : currentCollection.getItem(currentSelectedKey)?.textValue ?? "";
205
+ });
206
+ createRenderEffect(() => {
207
+ const currentSelectedKey = selectedKey();
208
+ const currentCollection = collection();
209
+ return {
210
+ currentAllowsEmptyCollection: allowsEmptyCollection(),
211
+ currentDisplayValue: displayValue(),
212
+ currentFilteredCollection: filteredCollection(),
213
+ currentInputValue: inputValue(),
214
+ currentIsFocused: isFocused(),
215
+ currentIsOpen: triggerState.isOpen,
216
+ currentLastValue: lastValue(),
217
+ currentMenuTrigger: menuTrigger(),
218
+ currentSelectedKey,
219
+ currentSelectedText: currentSelectedKey === null ? "" : currentCollection.getItem(currentSelectedKey)?.textValue ?? "",
220
+ currentSelectionManager: selectionManager(),
221
+ currentSelectionMode: selectionMode(),
222
+ currentShowAllItems: showAllItems(),
223
+ currentValue: value(),
224
+ inputIsControlled: props.inputValue !== void 0
225
+ };
226
+ }, ({ currentIsFocused, currentFilteredCollection, currentAllowsEmptyCollection, currentInputValue, currentLastValue, currentMenuTrigger, currentShowAllItems, currentDisplayValue, currentSelectionMode, currentSelectionManager, currentValue, currentSelectedKey, currentSelectedText, currentIsOpen, inputIsControlled }) => {
227
+ function synchronizeMenu() {
228
+ if (currentIsFocused && (currentFilteredCollection.size > 0 || currentAllowsEmptyCollection) && !currentIsOpen && currentInputValue !== currentLastValue && currentMenuTrigger !== "manual") open(null, "input");
229
+ if (!currentShowAllItems && !currentAllowsEmptyCollection && currentIsOpen && currentFilteredCollection.size === 0) {
230
+ closedDueToEmpty = true;
231
+ closeMenu();
232
+ }
233
+ if (currentIsFocused && closedDueToEmpty && currentFilteredCollection.size > 0 && !currentIsOpen && currentMenuTrigger !== "manual") {
234
+ closedDueToEmpty = false;
235
+ open(null, "input");
236
+ }
237
+ }
238
+ function synchronizeSelection() {
239
+ if (currentDisplayValue !== null && currentDisplayValue !== void 0 && currentDisplayValue !== previousValue && currentSelectionMode === "single") closeMenu();
240
+ if (currentInputValue !== currentLastValue) {
241
+ currentSelectionManager.setFocusedKey(null);
242
+ setShowAllItems(false);
243
+ if (currentSelectionMode === "single" && currentInputValue === "" && (!inputIsControlled || currentValue === void 0)) setValue(null);
244
+ }
245
+ if (currentDisplayValue !== previousValue && (!inputIsControlled || currentValue === void 0)) resetInputValue();
246
+ else if (currentLastValue !== currentInputValue) setLastValue(currentInputValue);
247
+ }
248
+ function synchronizeSelectedText() {
249
+ const selectedItemText = currentSelectedText;
250
+ if (!currentIsFocused && currentSelectedKey !== null && currentSelectedKey !== void 0 && !inputIsControlled && currentSelectedKey === previousValue && lastSelectedKeyText !== selectedItemText) {
251
+ setLastValue(selectedItemText);
252
+ setInputValue(selectedItemText);
253
+ }
254
+ return selectedItemText;
255
+ }
256
+ untrack(() => {
257
+ synchronizeMenu();
258
+ synchronizeSelection();
259
+ const selectedItemText = synchronizeSelectedText();
260
+ previousValue = currentDisplayValue;
261
+ lastSelectedKeyText = selectedItemText;
262
+ });
263
+ });
264
+ const derivedProperty1 = createMemo(() => {
265
+ const currentDisplayValue = displayValue();
266
+ const currentInputValue = inputValue();
267
+ const currentSelectedKey = selectedKey();
268
+ return isKeyArray(currentDisplayValue) && currentDisplayValue.length === 0 ? null : {
269
+ inputValue: currentInputValue,
270
+ selectedKey: currentSelectedKey,
271
+ value: isKeyArray(currentDisplayValue) ? [...currentDisplayValue] : currentDisplayValue
272
+ };
273
+ });
274
+ const validation = createFormValidationState(merge(props, { get value() {
275
+ return derivedProperty1();
276
+ } }));
277
+ const revert = () => {
278
+ const currentAllowsCustomValue = allowsCustomValue();
279
+ const currentSelectedKey = selectedKey();
280
+ closedDueToEmpty = false;
281
+ if (currentAllowsCustomValue === true && (currentSelectedKey === null || currentSelectedKey === void 0)) commitCustomValue();
282
+ else commitSelection();
283
+ };
284
+ function commitCustomValue() {
285
+ const currentSelectionMode = selectionMode();
286
+ const currentInputValue = inputValue();
287
+ if (currentSelectionMode === "multiple") {
288
+ setLastValue(currentInputValue);
289
+ closeMenu();
290
+ return;
291
+ }
292
+ const localValue = null;
293
+ previousValue = localValue;
294
+ setValue(localValue);
295
+ closeMenu();
296
+ }
297
+ function commitSelection(shouldForceSelectionChange = false) {
298
+ const currentValue = value();
299
+ const currentSelectedKey = selectedKey();
300
+ const currentCollection = collection();
301
+ const currentSelectionMode = selectionMode();
302
+ const currentInputValue = inputValue();
303
+ const currentDisplayValue = displayValue();
304
+ if (currentValue !== void 0 && props.inputValue !== void 0) {
305
+ const itemText = currentSelectedKey === null || currentSelectedKey === void 0 ? "" : currentCollection.getItem(currentSelectedKey)?.textValue ?? "";
306
+ if (shouldForceSelectionChange || currentSelectionMode === "multiple" || currentInputValue !== itemText) {
307
+ notifyLegacySelectionChange(props, currentSelectedKey);
308
+ const change = isKeyArray(currentDisplayValue) ? [...currentDisplayValue] : currentDisplayValue;
309
+ props.onChange?.(change);
310
+ }
311
+ setLastValue(itemText);
312
+ } else resetInputValue();
313
+ closeMenu();
314
+ }
315
+ const commitValue = () => {
316
+ const currentAllowsCustomValue = allowsCustomValue();
317
+ const currentSelectedKey = selectedKey();
318
+ const currentCollection = collection();
319
+ const currentInputValue = inputValue();
320
+ closedDueToEmpty = false;
321
+ if (currentAllowsCustomValue === true) {
322
+ if (currentInputValue === (currentSelectedKey === null || currentSelectedKey === void 0 ? "" : currentCollection.getItem(currentSelectedKey)?.textValue ?? "")) commitSelection();
323
+ else commitCustomValue();
324
+ } else commitSelection();
325
+ };
326
+ const commit = () => {
327
+ const currentSelectionManager = selectionManager();
328
+ const currentSelectionMode = selectionMode();
329
+ if (triggerState.isOpen && currentSelectionManager.focusedKey !== null && currentSelectionManager.focusedKey !== void 0) {
330
+ if (currentSelectionManager.isSelected(currentSelectionManager.focusedKey) && currentSelectionMode === "single") commitSelection(true);
331
+ else currentSelectionManager.select(currentSelectionManager.focusedKey);
332
+ } else commitValue();
333
+ };
334
+ let valueOnFocus = untrack(() => {
335
+ return [inputValue(), displayValue()];
336
+ });
337
+ const setFocused = (localIsFocused) => {
338
+ const currentInputValue = inputValue();
339
+ const currentDisplayValue = displayValue();
340
+ const currentMenuTrigger = menuTrigger();
341
+ const currentShouldCloseOnBlur = shouldCloseOnBlur();
342
+ if (localIsFocused) {
343
+ valueOnFocus = [currentInputValue, currentDisplayValue];
344
+ if (currentMenuTrigger === "focus" && !(props.isReadOnly === true)) open(null, "focus");
345
+ } else {
346
+ if (currentShouldCloseOnBlur) commitValue();
347
+ if (currentInputValue !== valueOnFocus[0] || currentDisplayValue !== valueOnFocus[1]) validation.commitValidation();
348
+ }
349
+ setFocusedState(localIsFocused);
350
+ };
351
+ const displayedCollection = createMemo(() => {
352
+ const currentShowAllItems = showAllItems();
353
+ const currentOriginalCollection = originalCollection();
354
+ const currentFilteredCollection = filteredCollection();
355
+ const currentLastCollection = lastCollection();
356
+ if (triggerState.isOpen) {
357
+ if (currentShowAllItems) return currentOriginalCollection;
358
+ return currentFilteredCollection;
359
+ }
360
+ return currentLastCollection;
361
+ });
362
+ const defaultSelectedKey = createMemo(() => {
363
+ const currentSelectionMode = selectionMode();
364
+ const currentInitialValue = initialValue;
365
+ return getLegacyDefaultSelectedKey(props) ?? (currentSelectionMode === "single" && (typeof currentInitialValue === "string" || typeof currentInitialValue === "number") ? currentInitialValue : null);
366
+ });
367
+ return merge(validation, triggerState, {
368
+ get close() {
369
+ return commitValue;
370
+ },
371
+ get collection() {
372
+ return displayedCollection();
373
+ },
374
+ commit,
375
+ get defaultInputValue() {
376
+ return getDefaultInputValue(props.defaultInputValue, defaultSelectedKey(), collection()) ?? initialInputValue;
377
+ },
378
+ get defaultSelectedKey() {
379
+ return defaultSelectedKey();
380
+ },
381
+ get defaultValue() {
382
+ return defaultValue() ?? initialValue;
383
+ },
384
+ get disabledKeys() {
385
+ return disabledKeys();
386
+ },
387
+ get focusStrategy() {
388
+ return focusStrategy();
389
+ },
390
+ get inputValue() {
391
+ return inputValue();
392
+ },
393
+ get isFocused() {
394
+ return isFocused();
395
+ },
396
+ open,
397
+ revert,
398
+ get selectedItem() {
399
+ return selectedItems()[0] ?? null;
400
+ },
401
+ get selectedItems() {
402
+ return selectedItems();
403
+ },
404
+ get selectedKey() {
405
+ return selectedKey();
406
+ },
407
+ get selectionManager() {
408
+ return selectionManager();
409
+ },
410
+ setFocused,
411
+ setInputValue,
412
+ get setSelectedKey() {
413
+ return setValue;
414
+ },
415
+ setValue,
416
+ toggle,
417
+ get value() {
418
+ return displayValue();
419
+ }
420
+ });
421
+ }
422
+ function filterCollection(collection, inputValue, filter) {
423
+ return new ListCollection(filterNodes(collection, collection, inputValue, filter));
424
+ }
425
+ function filterNodes(collection, nodes, inputValue, filter) {
426
+ const filteredNode = [];
427
+ for (const node of nodes) if (node.type === "section" && node.hasChildNodes) {
428
+ const filtered = filterNodes(collection, getChildNodes(node, collection), inputValue, filter);
429
+ if ([...filtered].some((localNode) => localNode.type === "item")) filteredNode.push({
430
+ ...node,
431
+ childNodes: filtered
432
+ });
433
+ } else if (node.type !== "item" || filter(node.textValue, inputValue)) filteredNode.push({ ...node });
434
+ return filteredNode;
435
+ }
436
+ function getDefaultInputValue(defaultInputValue, selectedKey, collection) {
437
+ if ((defaultInputValue === null || defaultInputValue === void 0) && selectedKey !== null && selectedKey !== void 0) return collection.getItem(selectedKey)?.textValue ?? "";
438
+ return defaultInputValue;
439
+ }
440
+ function convertValue(value) {
441
+ if (value === void 0) return value;
442
+ if (value === null) return [];
443
+ return isKeyArray(value) ? value : [value];
444
+ }
445
+ function isKeyArray(value) {
446
+ return Array.isArray(value);
447
+ }
448
+ export { createComboBoxState };
449
+
450
+ //# sourceMappingURL=create-combo-box-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-combo-box-state.js","names":[],"sources":["../../src/combobox/create-combo-box-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/combobox/useComboBoxState.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 CollectionBase,\n CollectionStateBase,\n FocusableProps,\n FocusStrategy,\n HelpTextProps,\n InputBase,\n Key,\n LabelableProps,\n Node,\n Selection,\n TextInputBase,\n Validation,\n ValueBase,\n} from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n createSignal,\n createRenderEffect,\n untrack,\n merge,\n} from \"solid-js\";\n\nimport { getChildNodes } from \"../collections/get-child-nodes\";\nimport { createFormValidationState } from \"../form/create-form-validation-state\";\nimport type { FormValidationState } from \"../form/create-form-validation-state\";\nimport { createListState } from \"../list/create-list-state\";\nimport type { ListState } from \"../list/create-list-state\";\nimport { ListCollection } from \"../list/list-collection\";\nimport { createOverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport type { OverlayTriggerState } from \"../overlays/create-overlay-trigger-state\";\nimport { createControlledSignal } from \"../utils/create-controlled-signal\";\nimport {\n getLegacyDefaultSelectedKey,\n getLegacySelectedKey,\n notifyLegacySelectionChange,\n} from \"../utils/legacy-props\";\n\nexport type MenuTriggerAction = \"focus\" | \"input\" | \"manual\";\n\nexport type SelectionMode = \"single\" | \"multiple\";\n\nexport type ValueType<M extends SelectionMode> = M extends \"single\"\n ? Key | null\n : readonly Key[];\n\nexport type ChangeValueType<M extends SelectionMode> = M extends \"single\"\n ? Key | null\n : Key[];\n\ntype ValidationType<M extends SelectionMode> = M extends \"single\"\n ? Key | null\n : Key[];\n\nexport interface ComboBoxValidationValue<M extends SelectionMode = \"single\"> {\n /**\n * The selected key in the ComboBox.\n *\n * @deprecated\n */\n selectedKey: Key | null;\n /** The keys of the currently selected items. */\n value: ValidationType<M>;\n /** The value of the ComboBox input. */\n inputValue: string;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = \"single\">\n extends\n CollectionBase<T>,\n InputBase,\n ValueBase<ValueType<M>, ChangeValueType<M>>,\n TextInputBase,\n Validation<ComboBoxValidationValue<M>>,\n FocusableProps<HTMLInputElement>,\n LabelableProps,\n HelpTextProps {\n /** The list of ComboBox items (uncontrolled). */\n defaultItems?: Iterable<T>;\n /** The list of ComboBox items (controlled). */\n items?: Iterable<T>;\n /**\n * Method that is called when the open state of the menu changes. Returns the new open state and\n * the action that caused the opening of the menu.\n */\n onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void;\n /**\n * Whether single or multiple selection is enabled.\n *\n * @default 'single'\n */\n selectionMode?: M;\n /**\n * The currently selected key in the collection (controlled).\n *\n * @deprecated\n */\n selectedKey?: Key | null;\n /**\n * The initial selected key in the collection (uncontrolled).\n *\n * @deprecated\n */\n defaultSelectedKey?: Key | null;\n /**\n * Handler that is called when the selection changes.\n *\n * @deprecated\n */\n onSelectionChange?: (key: Key | null) => void;\n /** The value of the ComboBox input (controlled). */\n inputValue?: string;\n /** The default value of the ComboBox input (uncontrolled). */\n defaultInputValue?: string;\n /** Handler that is called when the ComboBox input value changes. */\n onInputChange?: (value: string) => void;\n /** Whether the ComboBox allows a non-item matching input value to be set. */\n allowsCustomValue?: boolean;\n // /**\n // * Whether the Combobox should only suggest matching options or autocomplete the field with the nearest matching option.\n // * @default 'suggest'\n // */\n // completionMode?: 'suggest' | 'complete',\n /**\n * The interaction required to display the ComboBox menu.\n *\n * @default 'input'\n */\n menuTrigger?: MenuTriggerAction;\n}\n\nexport interface ComboBoxState<T, M extends SelectionMode = \"single\">\n extends ListState<T>, OverlayTriggerState, FormValidationState {\n /**\n * The key for the first selected item.\n *\n * @deprecated\n */\n readonly selectedKey: Key | null;\n /**\n * The default selected key.\n *\n * @deprecated\n */\n readonly defaultSelectedKey: Key | null;\n /**\n * Sets the selected key.\n *\n * @deprecated\n */\n setSelectedKey: (key: Key | null) => void;\n /** The current combobox value. */\n readonly value: ValueType<M>;\n /** The default combobox value. */\n readonly defaultValue: ValueType<M>;\n /** Sets the combobox value. */\n setValue: (value: Key | readonly Key[] | null) => void;\n /**\n * The value of the first selected item.\n *\n * @deprecated\n */\n readonly selectedItem: Node<T> | null;\n /** The value of the selected items. */\n readonly selectedItems: Node<T>[];\n /** The current value of the combo box input. */\n inputValue: string;\n /** The default value of the combo box input. */\n defaultInputValue: string;\n /** Sets the value of the combo box input. */\n setInputValue: (value: string) => void;\n /** Selects the currently focused item and updates the input value. */\n commit: () => void;\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy | null;\n /** Whether the select is currently focused. */\n readonly isFocused: boolean;\n /** Sets whether the select is focused. */\n setFocused: (isFocused: boolean) => void;\n /** Opens the menu. */\n open: (\n focusStrategy?: FocusStrategy | null,\n trigger?: MenuTriggerAction\n ) => void;\n /** Toggles the menu. */\n toggle: (\n focusStrategy?: FocusStrategy | null,\n trigger?: MenuTriggerAction\n ) => void;\n /** Resets the input value to the previously selected item's text if any and closes the menu. */\n revert: () => void;\n}\n\ntype FilterFn = (textValue: string, inputValue: string) => boolean;\n\nexport interface ComboBoxStateOptions<T, M extends SelectionMode = \"single\">\n extends Omit<ComboBoxProps<T, M>, \"children\">, CollectionStateBase<T> {\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: FilterFn;\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n /** Whether the combo box menu should close on blur. */\n shouldCloseOnBlur?: boolean;\n}\n\n/**\n * Provides state management for a combo box component. Handles building a collection of items from\n * props and manages the option selection state of the combo box. In addition, it tracks the input\n * value, focus state, and other properties of the combo box.\n */\nexport function createComboBoxState<\n T extends object,\n M extends SelectionMode = \"single\",\n>(props: ComboBoxStateOptions<T, M>): ComboBoxState<T, M> {\n const defaultFilter = createMemo(() => props.defaultFilter);\n const menuTrigger = createMemo(() => props.menuTrigger ?? \"input\");\n\n const allowsEmptyCollection = createMemo(\n () => props.allowsEmptyCollection ?? false\n );\n\n const allowsCustomValue = createMemo(() => props.allowsCustomValue);\n const shouldCloseOnBlur = createMemo(() => props.shouldCloseOnBlur ?? true);\n\n const selectionMode = createMemo(() => props.selectionMode ?? \"single\");\n\n const [showAllItems, setShowAllItems] = createSignal(false, {\n ownedWrite: true,\n });\n\n const [isFocused, setFocusedState] = createSignal(false, {\n ownedWrite: true,\n });\n\n const [focusStrategy, setFocusStrategy] = createSignal<FocusStrategy | null>(\n null,\n { ownedWrite: true }\n );\n\n let closedDueToEmpty = false;\n\n const defaultValue = createMemo(() => {\n const currentSelectionMode = selectionMode();\n\n return (\n props.defaultValue ??\n (currentSelectionMode === \"single\"\n ? (getLegacyDefaultSelectedKey(props) ?? null)\n : [])\n );\n });\n\n const value = createMemo(() => {\n const currentSelectionMode = selectionMode();\n\n return (\n props.value ??\n (currentSelectionMode === \"single\"\n ? getLegacySelectedKey(props)\n : undefined)\n );\n });\n\n const [controlledValue, setControlledValue] = createControlledSignal<\n Key | readonly Key[] | null\n >(\n () => value(),\n untrack(() => defaultValue()),\n (localValue) => {\n const change = isKeyArray(localValue) ? [...localValue] : localValue;\n // SAFETY: setValue normalizes changes to the active selection mode.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n props.onChange?.(change as ChangeValueType<M>);\n }\n );\n\n // Only display the first selected item if in single selection mode but the value is an array.\n const displayValue = createMemo(() => {\n const currentSelectionMode = selectionMode();\n const currentControlledValue = controlledValue();\n\n return currentSelectionMode === \"single\" &&\n isKeyArray(currentControlledValue)\n ? (currentControlledValue[0] ?? null)\n : currentControlledValue;\n });\n\n const setValue = (localValue: Key | readonly Key[] | null) => {\n const currentSelectionMode = selectionMode();\n const currentDisplayValue = displayValue();\n\n if (currentSelectionMode === \"single\") {\n const key = isKeyArray(localValue) ? (localValue[0] ?? null) : localValue;\n setControlledValue(key);\n\n if (key !== currentDisplayValue) {\n notifyLegacySelectionChange(props, key);\n }\n } else {\n let keys: Key[] = [];\n\n if (isKeyArray(localValue)) {\n keys = [...localValue];\n } else if (localValue !== null && localValue !== undefined) {\n keys = [localValue];\n }\n\n setControlledValue(keys);\n }\n };\n\n const derivedProperty0 = createMemo(() => {\n const currentDisplayValue = displayValue();\n\n return convertValue(currentDisplayValue);\n });\n\n const listState = createListState(\n merge(props, {\n get allowDuplicateSelectionEvents() {\n return true;\n },\n get disallowEmptySelection() {\n return selectionMode() === \"single\";\n },\n get items() {\n return props.items ?? props.defaultItems;\n },\n get onSelectionChange() {\n return (keys: Selection) => {\n const currentSelectionMode = selectionMode();\n const currentDisplayValue = displayValue();\n\n // impossible, but TS doesn't know that\n if (keys === \"all\") {\n return;\n }\n\n if (currentSelectionMode === \"single\") {\n const key = keys.values().next().value ?? null;\n\n if (key === currentDisplayValue) {\n notifyLegacySelectionChange(props, key);\n // If key is the same, reset the inputValue and close the menu\n // (scenario: user clicks on already selected option)\n resetInputValue();\n closeMenu();\n } else {\n setValue(key);\n }\n } else {\n setValue([...keys]);\n }\n };\n },\n get selectedKeys() {\n return derivedProperty0();\n },\n get selectionMode() {\n return selectionMode();\n },\n })\n );\n\n const collection = createMemo(() => listState.collection);\n const selectionManager = createMemo(() => listState.selectionManager);\n const disabledKeys = createMemo(() => listState.disabledKeys);\n\n const selectedKey = createMemo(() => {\n const currentSelectionMode = selectionMode();\n const currentSelectionManager = selectionManager();\n\n return currentSelectionMode === \"single\"\n ? currentSelectionManager.firstSelectedKey\n : null;\n });\n\n const selectedItems = createMemo(() => {\n const currentSelectionManager = selectionManager();\n\n return [...currentSelectionManager.selectedKeys].flatMap((key) => {\n const item = collection().getItem(key);\n\n return item === null || item === undefined ? [] : [item];\n });\n });\n\n const [inputValue, setInputValue] = createControlledSignal(\n () => props.inputValue,\n untrack(() => {\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n\n return (\n getDefaultInputValue(\n props.defaultInputValue,\n currentSelectedKey,\n currentCollection\n ) ?? \"\"\n );\n }),\n (localValue) => {\n props.onInputChange?.(localValue);\n }\n );\n\n const initialValue = untrack(() => displayValue());\n const initialInputValue = untrack(() => inputValue());\n // Preserve original collection so we can show all items on demand\n const originalCollection = createMemo(() => collection());\n\n const filteredCollection = createMemo(() => {\n const currentDefaultFilter = defaultFilter();\n const currentCollection = collection();\n const currentInputValue = inputValue();\n\n return (\n // No default filter if items are controlled.\n (props.items !== null && props.items !== undefined) ||\n !currentDefaultFilter\n ? currentCollection\n : filterCollection(\n currentCollection,\n currentInputValue,\n currentDefaultFilter\n )\n );\n });\n\n const [lastCollection, setLastCollection] = createSignal(\n untrack(() => filteredCollection()),\n { ownedWrite: true }\n );\n // Track what action is attempting to open the menu\n\n let menuOpenTrigger: MenuTriggerAction | undefined = \"focus\";\n\n const onOpenChange = (open: boolean) => {\n const currentSelectionManager = selectionManager();\n\n if (props.onOpenChange) {\n props.onOpenChange(open, open ? menuOpenTrigger : undefined);\n }\n\n currentSelectionManager.setFocused(open);\n\n if (!open) {\n currentSelectionManager.setFocusedKey(null);\n }\n };\n\n const triggerState = createOverlayTriggerState(\n merge(props, {\n defaultOpen: undefined,\n isOpen: undefined,\n onOpenChange,\n })\n );\n\n const open = (\n localFocusStrategy: FocusStrategy | null = null,\n trigger?: MenuTriggerAction\n ) => {\n const currentMenuTrigger = menuTrigger();\n const currentAllowsEmptyCollection = allowsEmptyCollection();\n const currentFilteredCollection = filteredCollection();\n const currentOriginalCollection = originalCollection();\n\n const displayAllItems =\n trigger === \"manual\" ||\n (trigger === \"focus\" && currentMenuTrigger === \"focus\");\n\n // Prevent open operations from triggering if there is nothing to display\n // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true.\n // This is to prevent comboboxes with empty defaultItems from opening but allow controlled items comboboxes to open even if the inital list is empty (assumption is user will provide swap the empty list with a base list via onOpenChange returning `menuTrigger` manual)\n if (\n currentAllowsEmptyCollection ||\n currentFilteredCollection.size > 0 ||\n (displayAllItems && currentOriginalCollection.size > 0) ||\n props.items\n ) {\n if (\n displayAllItems &&\n !triggerState.isOpen &&\n props.items === undefined\n ) {\n // Show all items if menu is manually opened. Only care about this if items are undefined\n setShowAllItems(true);\n }\n\n menuOpenTrigger = trigger;\n setFocusStrategy(localFocusStrategy);\n triggerState.open();\n }\n };\n\n const toggle = (\n localFocusStrategy: FocusStrategy | null = null,\n trigger?: MenuTriggerAction\n ) => {\n const currentMenuTrigger = menuTrigger();\n const currentAllowsEmptyCollection = allowsEmptyCollection();\n const currentFilteredCollection = filteredCollection();\n const currentOriginalCollection = originalCollection();\n\n const displayAllItems =\n trigger === \"manual\" ||\n (trigger === \"focus\" && currentMenuTrigger === \"focus\");\n\n // If the menu is closed and there is nothing to display, early return so toggle isn't called to prevent extraneous onOpenChange\n if (\n !currentAllowsEmptyCollection &&\n !(currentFilteredCollection.size > 0) &&\n (!displayAllItems || !(currentOriginalCollection.size > 0)) &&\n !props.items &&\n !triggerState.isOpen\n ) {\n return;\n }\n\n if (displayAllItems && !triggerState.isOpen && props.items === undefined) {\n // Show all items if menu is toggled open. Only care about this if items are undefined\n setShowAllItems(true);\n }\n\n // Only update the menuOpenTrigger if menu is currently closed\n if (!triggerState.isOpen) {\n menuOpenTrigger = trigger;\n }\n\n toggleMenu(localFocusStrategy);\n };\n\n const updateLastCollection = () => {\n const currentShowAllItems = showAllItems();\n const currentOriginalCollection = originalCollection();\n const currentFilteredCollection = filteredCollection();\n setLastCollection(\n currentShowAllItems\n ? currentOriginalCollection\n : currentFilteredCollection\n );\n };\n\n // If menu is going to close, save the current collection so we can freeze the displayed collection when the\n // user clicks outside the popover to close the menu. Prevents the menu contents from updating as the menu closes.\n function toggleMenu(localFocusStrategy: FocusStrategy | null = null) {\n if (triggerState.isOpen) {\n updateLastCollection();\n }\n\n setFocusStrategy(localFocusStrategy);\n triggerState.toggle();\n }\n\n function closeMenu() {\n if (triggerState.isOpen) {\n updateLastCollection();\n triggerState.close();\n }\n }\n\n const [lastValue, setLastValue] = createSignal(\n untrack(() => inputValue()),\n { ownedWrite: true }\n );\n\n function resetInputValue() {\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n\n const itemText =\n currentSelectedKey === null || currentSelectedKey === undefined\n ? \"\"\n : (currentCollection.getItem(currentSelectedKey)?.textValue ?? \"\");\n\n setLastValue(itemText);\n setInputValue(itemText);\n }\n\n let previousValue: Key | readonly Key[] | null | undefined = untrack(() =>\n displayValue()\n );\n\n let lastSelectedKeyText = untrack(() => {\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n\n return currentSelectedKey === null || currentSelectedKey === undefined\n ? \"\"\n : (currentCollection.getItem(currentSelectedKey)?.textValue ?? \"\");\n });\n\n createRenderEffect(\n () => {\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n\n return {\n currentAllowsEmptyCollection: allowsEmptyCollection(),\n currentDisplayValue: displayValue(),\n currentFilteredCollection: filteredCollection(),\n currentInputValue: inputValue(),\n currentIsFocused: isFocused(),\n currentIsOpen: triggerState.isOpen,\n currentLastValue: lastValue(),\n currentMenuTrigger: menuTrigger(),\n currentSelectedKey,\n currentSelectedText:\n currentSelectedKey === null\n ? \"\"\n : (currentCollection.getItem(currentSelectedKey)?.textValue ?? \"\"),\n currentSelectionManager: selectionManager(),\n currentSelectionMode: selectionMode(),\n currentShowAllItems: showAllItems(),\n currentValue: value(),\n inputIsControlled: props.inputValue !== undefined,\n };\n },\n ({\n currentIsFocused,\n currentFilteredCollection,\n currentAllowsEmptyCollection,\n currentInputValue,\n currentLastValue,\n currentMenuTrigger,\n currentShowAllItems,\n currentDisplayValue,\n currentSelectionMode,\n currentSelectionManager,\n currentValue,\n currentSelectedKey,\n currentSelectedText,\n currentIsOpen,\n inputIsControlled,\n }) => {\n function synchronizeMenu() {\n // Open and close menu automatically when the input value changes if the input is focused,\n // and there are items in the collection or allowEmptyCollection is true.\n if (\n currentIsFocused &&\n (currentFilteredCollection.size > 0 ||\n currentAllowsEmptyCollection) &&\n !currentIsOpen &&\n currentInputValue !== currentLastValue &&\n currentMenuTrigger !== \"manual\"\n ) {\n open(null, \"input\");\n }\n\n // Close the menu if the collection is empty. Don't close menu if filtered collection size is 0\n // but we are currently showing all items via button press\n if (\n !currentShowAllItems &&\n !currentAllowsEmptyCollection &&\n currentIsOpen &&\n currentFilteredCollection.size === 0\n ) {\n closedDueToEmpty = true;\n closeMenu();\n }\n\n // Re-open the menu when items become non-empty after being auto-closed due to\n // an empty collection (e.g. async load completed with results after a previous empty response).\n // This works for both controlled items on ComboBox and Collection patterns\n // (where items are provided on the ListBox rather than the ComboBox).\n if (\n currentIsFocused &&\n closedDueToEmpty &&\n currentFilteredCollection.size > 0 &&\n !currentIsOpen &&\n currentMenuTrigger !== \"manual\"\n ) {\n closedDueToEmpty = false;\n open(null, \"input\");\n }\n }\n\n function synchronizeSelection() {\n // Close when an item is selected.\n if (\n currentDisplayValue !== null &&\n currentDisplayValue !== undefined &&\n currentDisplayValue !== previousValue &&\n currentSelectionMode === \"single\"\n ) {\n closeMenu();\n }\n\n // Clear focused key when input value changes and display filtered collection again.\n if (currentInputValue !== currentLastValue) {\n currentSelectionManager.setFocusedKey(null);\n setShowAllItems(false);\n\n // Set value to null when the user clears the input.\n // If controlled, this is the application developer's responsibility.\n if (\n currentSelectionMode === \"single\" &&\n currentInputValue === \"\" &&\n (!inputIsControlled || currentValue === undefined)\n ) {\n setValue(null);\n }\n }\n\n // If the value changed, update the input value.\n // Do nothing if both inputValue and value are controlled.\n // In this case, it's the user's responsibility to update inputValue in onSelectionChange.\n if (\n currentDisplayValue !== previousValue &&\n (!inputIsControlled || currentValue === undefined)\n ) {\n resetInputValue();\n } else if (currentLastValue !== currentInputValue) {\n setLastValue(currentInputValue);\n }\n }\n\n function synchronizeSelectedText() {\n // Update the inputValue if the selected item's text changes from its last tracked value.\n // This is to handle cases where a selectedKey is specified but the items aren't available (async loading) or the selected item's text value updates.\n // Only reset if the user isn't currently within the field so we don't erroneously modify user input.\n // If inputValue is controlled, it is the user's responsibility to update the inputValue when items change.\n const selectedItemText = currentSelectedText;\n\n if (\n !currentIsFocused &&\n currentSelectedKey !== null &&\n currentSelectedKey !== undefined &&\n !inputIsControlled &&\n currentSelectedKey === previousValue &&\n lastSelectedKeyText !== selectedItemText\n ) {\n setLastValue(selectedItemText);\n setInputValue(selectedItemText);\n }\n\n return selectedItemText;\n }\n\n untrack(() => {\n synchronizeMenu();\n synchronizeSelection();\n const selectedItemText = synchronizeSelectedText();\n previousValue = currentDisplayValue;\n lastSelectedKeyText = selectedItemText;\n });\n }\n );\n\n const derivedProperty1 = createMemo(() => {\n const currentDisplayValue = displayValue();\n const currentInputValue = inputValue();\n const currentSelectedKey = selectedKey();\n\n return isKeyArray(currentDisplayValue) && currentDisplayValue.length === 0\n ? null\n : {\n inputValue: currentInputValue,\n selectedKey: currentSelectedKey,\n // SAFETY: The active selection mode determines the value shape; readonly input arrays are copied for mutable callback values.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n value: (isKeyArray(currentDisplayValue)\n ? [...currentDisplayValue]\n : currentDisplayValue) as ComboBoxValidationValue<M>[\"value\"],\n };\n });\n\n const validation = createFormValidationState(\n merge(props, {\n get value() {\n return derivedProperty1();\n },\n })\n );\n\n // Revert input value and close menu\n const revert = () => {\n const currentAllowsCustomValue = allowsCustomValue();\n const currentSelectedKey = selectedKey();\n closedDueToEmpty = false;\n\n if (\n currentAllowsCustomValue === true &&\n (currentSelectedKey === null || currentSelectedKey === undefined)\n ) {\n commitCustomValue();\n } else {\n commitSelection();\n }\n };\n\n function commitCustomValue() {\n const currentSelectionMode = selectionMode();\n const currentInputValue = inputValue();\n\n if (currentSelectionMode === \"multiple\") {\n // In multi-select mode, the input's custom text is independent from the selected items.\n // Closing or committing the field should not clear the existing selection.\n setLastValue(currentInputValue);\n closeMenu();\n\n return;\n }\n\n const localValue = null;\n previousValue = localValue;\n setValue(localValue);\n closeMenu();\n }\n\n function commitSelection(shouldForceSelectionChange = false) {\n const currentValue = value();\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n const currentSelectionMode = selectionMode();\n const currentInputValue = inputValue();\n const currentDisplayValue = displayValue();\n\n // If multiple things are controlled, call onSelectionChange only when selecting the focused item,\n // or when inputValue needs to be synced back to the selected item on commit/blur.\n if (currentValue !== undefined && props.inputValue !== undefined) {\n const itemText =\n currentSelectedKey === null || currentSelectedKey === undefined\n ? \"\"\n : (currentCollection.getItem(currentSelectedKey)?.textValue ?? \"\");\n\n if (\n shouldForceSelectionChange ||\n currentSelectionMode === \"multiple\" ||\n currentInputValue !== itemText\n ) {\n notifyLegacySelectionChange(props, currentSelectedKey);\n\n const change = isKeyArray(currentDisplayValue)\n ? [...currentDisplayValue]\n : currentDisplayValue;\n\n // SAFETY: the committed value has the active mode's shape and arrays are copied for callbacks.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n props.onChange?.(change as ChangeValueType<M>);\n }\n\n // Keep the committed input value from reopening the menu.\n setLastValue(itemText);\n } else {\n // If only a single aspect of combobox is controlled, reset input value and close menu for the user\n resetInputValue();\n }\n\n closeMenu();\n }\n\n const commitValue = () => {\n const currentAllowsCustomValue = allowsCustomValue();\n const currentSelectedKey = selectedKey();\n const currentCollection = collection();\n const currentInputValue = inputValue();\n closedDueToEmpty = false;\n\n if (currentAllowsCustomValue === true) {\n const itemText =\n currentSelectedKey === null || currentSelectedKey === undefined\n ? \"\"\n : (currentCollection.getItem(currentSelectedKey)?.textValue ?? \"\");\n\n if (currentInputValue === itemText) {\n commitSelection();\n } else {\n commitCustomValue();\n }\n } else {\n // Reset inputValue and close menu\n commitSelection();\n }\n };\n\n const commit = () => {\n const currentSelectionManager = selectionManager();\n const currentSelectionMode = selectionMode();\n\n if (\n triggerState.isOpen &&\n currentSelectionManager.focusedKey !== null &&\n currentSelectionManager.focusedKey !== undefined\n ) {\n // Reset inputValue and close menu here if the selected key is already the focused key. Otherwise\n // fire onSelectionChange to allow the application to control the closing.\n if (\n currentSelectionManager.isSelected(\n currentSelectionManager.focusedKey\n ) &&\n currentSelectionMode === \"single\"\n ) {\n commitSelection(true);\n } else {\n currentSelectionManager.select(currentSelectionManager.focusedKey);\n }\n } else {\n commitValue();\n }\n };\n\n let valueOnFocus = untrack(() => {\n const currentInputValue = inputValue();\n const currentDisplayValue = displayValue();\n\n return [currentInputValue, currentDisplayValue];\n });\n\n const setFocused = (localIsFocused: boolean) => {\n const currentInputValue = inputValue();\n const currentDisplayValue = displayValue();\n const currentMenuTrigger = menuTrigger();\n const currentShouldCloseOnBlur = shouldCloseOnBlur();\n\n if (localIsFocused) {\n valueOnFocus = [currentInputValue, currentDisplayValue];\n\n if (currentMenuTrigger === \"focus\" && !(props.isReadOnly === true)) {\n open(null, \"focus\");\n }\n } else {\n if (currentShouldCloseOnBlur) {\n commitValue();\n }\n\n // Commit validation if the input value or selected items changed.\n if (\n currentInputValue !== valueOnFocus[0] ||\n currentDisplayValue !== valueOnFocus[1]\n ) {\n validation.commitValidation();\n }\n }\n\n setFocusedState(localIsFocused);\n };\n\n const displayedCollection = createMemo(() => {\n const currentShowAllItems = showAllItems();\n const currentOriginalCollection = originalCollection();\n const currentFilteredCollection = filteredCollection();\n const currentLastCollection = lastCollection();\n\n if (triggerState.isOpen) {\n if (currentShowAllItems) {\n return currentOriginalCollection;\n }\n\n return currentFilteredCollection;\n }\n\n return currentLastCollection;\n });\n\n const defaultSelectedKey = createMemo(() => {\n const currentSelectionMode = selectionMode();\n const currentInitialValue = initialValue;\n\n return (\n getLegacyDefaultSelectedKey(props) ??\n (currentSelectionMode === \"single\" &&\n (typeof currentInitialValue === \"string\" ||\n typeof currentInitialValue === \"number\")\n ? currentInitialValue\n : null)\n );\n });\n\n return merge(validation, triggerState, {\n get close() {\n return commitValue;\n },\n get collection() {\n return displayedCollection();\n },\n commit,\n get defaultInputValue() {\n return (\n getDefaultInputValue(\n props.defaultInputValue,\n defaultSelectedKey(),\n collection()\n ) ?? initialInputValue\n );\n },\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get defaultSelectedKey() {\n return defaultSelectedKey();\n },\n get defaultValue() {\n // SAFETY: the default is constructed with the same selection mode as this state.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return (defaultValue() ?? initialValue) as ValueType<M>;\n },\n get disabledKeys() {\n return disabledKeys();\n },\n get focusStrategy() {\n return focusStrategy();\n },\n get inputValue() {\n return inputValue();\n },\n get isFocused() {\n return isFocused();\n },\n open,\n revert,\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get selectedItem() {\n return selectedItems()[0] ?? null;\n },\n get selectedItems() {\n return selectedItems();\n },\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get selectedKey() {\n return selectedKey();\n },\n get selectionManager() {\n return selectionManager();\n },\n setFocused,\n setInputValue,\n // oxlint-disable-next-line typescript/no-deprecated -- Expose the legacy output alias for existing consumers; internal state uses its modern replacement.\n get setSelectedKey() {\n return setValue;\n },\n setValue,\n toggle,\n get value() {\n // SAFETY: displayValue normalizes single mode to a key and multiple mode to an array.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return displayValue() as ValueType<M>;\n },\n } satisfies Partial<ComboBoxState<T, M>>);\n}\n\nfunction filterCollection<T>(\n collection: Collection<Node<T>>,\n inputValue: string,\n filter: FilterFn\n): Collection<Node<T>> {\n return new ListCollection(\n filterNodes(collection, collection, inputValue, filter)\n );\n}\n\nfunction filterNodes<T>(\n collection: Collection<Node<T>>,\n nodes: Iterable<Node<T>>,\n inputValue: string,\n filter: FilterFn\n): Iterable<Node<T>> {\n const filteredNode: Node<T>[] = [];\n\n for (const node of nodes) {\n if (node.type === \"section\" && node.hasChildNodes) {\n const filtered = filterNodes(\n collection,\n getChildNodes(node, collection),\n inputValue,\n filter\n );\n\n if ([...filtered].some((localNode) => localNode.type === \"item\")) {\n // oxlint-disable-next-line typescript/no-deprecated -- Node-backed collection construction must populate the upstream childNodes output contract.\n filteredNode.push({ ...node, childNodes: filtered });\n }\n } else if (node.type !== \"item\" || filter(node.textValue, inputValue)) {\n filteredNode.push({ ...node });\n }\n }\n\n return filteredNode;\n}\n\nfunction getDefaultInputValue(\n defaultInputValue: string | null | undefined,\n selectedKey: Key | null,\n collection: Collection<Node<unknown>>\n) {\n if (\n (defaultInputValue === null || defaultInputValue === undefined) &&\n selectedKey !== null &&\n selectedKey !== undefined\n ) {\n return collection.getItem(selectedKey)?.textValue ?? \"\";\n }\n\n return defaultInputValue;\n}\n\nfunction convertValue(value: Key | readonly Key[] | null | undefined) {\n if (value === undefined) {\n return value;\n }\n\n if (value === null) {\n return [];\n }\n\n return isKeyArray(value) ? value : [value];\n}\n\nfunction isKeyArray(\n value: Key | readonly Key[] | null | undefined\n): value is readonly Key[] {\n return Array.isArray(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoOA,SAAgB,oBAGd,OAAwD;CACxD,MAAM,gBAAgB,iBAAiB,MAAM,aAAa;CAC1D,MAAM,cAAc,iBAAiB,MAAM,eAAe,OAAO;CAEjE,MAAM,wBAAwB,iBACtB,MAAM,yBAAyB,KACvC;CAEA,MAAM,oBAAoB,iBAAiB,MAAM,iBAAiB;CAClE,MAAM,oBAAoB,iBAAiB,MAAM,qBAAqB,IAAI;CAE1E,MAAM,gBAAg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AAQ,sBAAsB,KAAA,MACrD,gBAAgB,QAChB,gBAAgB,KAAA,GAEhB,OAAO,WAAW,QAAQ,WAAW,CAAC,EAAE,aAAa;CAGvD,OAAO;AACT;AAEA,SAAS,aAAa,OAAgD;CACpE,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,IAAI,UAAU,MACZ,OAAO,CAAC;CAGV,OAAO,WAAW,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC3C;AAEA,SAAS,WACP,OACyB;CACzB,OAAO,MAAM,QAAQ,KAAK;AAC5B"}
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-stately/src/data/useAsyncList.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 { ListData } from "./create-list-data.js";
18
+ import { Key, LoadingState, Selection, SortDescriptor } from "@solid2-aria/types-shared";
19
+ export interface AsyncListOptions<T, C> {
20
+ /** The keys for the initially selected items. */
21
+ initialSelectedKeys?: Iterable<Key>;
22
+ /** The initial sort descriptor. */
23
+ initialSortDescriptor?: SortDescriptor;
24
+ /** The initial filter text. */
25
+ initialFilterText?: string;
26
+ /** A function that returns a unique key for an item object. */
27
+ getKey?: (item: T) => Key;
28
+ /** A function that loads the data for the items in the list. */
29
+ load: AsyncListLoadFunction<T, C>;
30
+ /**
31
+ * An optional function that performs sorting. If not provided,
32
+ * then `sortDescriptor` is passed to the `load` function.
33
+ */
34
+ sort?: AsyncListLoadFunction<T, C, AsyncListLoadOptions<T, C> & {
35
+ sortDescriptor: SortDescriptor;
36
+ }>;
37
+ }
38
+ export type AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
39
+ export interface AsyncListLoadOptions<T, C> {
40
+ /** The items currently in the list. */
41
+ items: T[];
42
+ /** The keys of the currently selected items in the list. */
43
+ selectedKeys: Selection;
44
+ /** The current sort descriptor for the list. */
45
+ sortDescriptor?: SortDescriptor;
46
+ /** An abort signal used to notify the load function that the request has been aborted. */
47
+ signal: AbortSignal;
48
+ /** The pagination cursor returned from the last page load. */
49
+ cursor?: C;
50
+ /** The current filter text used to perform server side filtering. */
51
+ filterText?: string;
52
+ /** The current loading state of the list. */
53
+ loadingState?: LoadingState;
54
+ }
55
+ export interface AsyncListStateUpdate<T, C> {
56
+ /** The new items to append to the list. */
57
+ items: Iterable<T>;
58
+ /** The keys to add to the selection. */
59
+ selectedKeys?: Iterable<Key>;
60
+ /** The sort descriptor to set. */
61
+ sortDescriptor?: SortDescriptor;
62
+ /** The pagination cursor to be used for the next page load. */
63
+ cursor?: C;
64
+ /** The updated filter text for the list. */
65
+ filterText?: string;
66
+ }
67
+ export interface AsyncListData<T> extends ListData<T> {
68
+ /** Whether data is currently being loaded. */
69
+ isLoading: boolean;
70
+ /** If loading data failed, then this contains the error that occurred. */
71
+ error?: Error;
72
+ /** The current sort descriptor for the list. */
73
+ sortDescriptor?: SortDescriptor;
74
+ /** Reloads the data in the list. */
75
+ reload: () => void;
76
+ /** Loads the next page of data in the list. */
77
+ loadMore: () => void;
78
+ /** Triggers sorting for the list. */
79
+ sort: (descriptor: SortDescriptor) => void;
80
+ /** The current loading state for the list. */
81
+ loadingState: LoadingState;
82
+ }
83
+ /**
84
+ * Manages state for an immutable async loaded list data structure, and provides convenience methods
85
+ * to update the data over time. Manages loading and error states, pagination, and sorting.
86
+ */
87
+ export declare function createAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T>;
88
+ //# sourceMappingURL=create-async-list.d.ts.map