@ember-joinery/primitives 0.0.0-stage → 1.1.0

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 (485) hide show
  1. package/CHANGELOG.md +480 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +11 -2
  5. package/addon-main.cjs +4 -0
  6. package/declarations/-private/combobox-list.d.ts +59 -0
  7. package/declarations/-private/combobox-list.d.ts.map +1 -0
  8. package/declarations/-private/command-score.d.ts +33 -0
  9. package/declarations/-private/command-score.d.ts.map +1 -0
  10. package/declarations/-private/delay-group.d.ts +47 -0
  11. package/declarations/-private/delay-group.d.ts.map +1 -0
  12. package/declarations/-private/dialog.d.ts +180 -0
  13. package/declarations/-private/dialog.d.ts.map +1 -0
  14. package/declarations/-private/form-control.d.ts +70 -0
  15. package/declarations/-private/form-control.d.ts.map +1 -0
  16. package/declarations/-private/form-data.d.ts +14 -0
  17. package/declarations/-private/form-data.d.ts.map +1 -0
  18. package/declarations/-private/hover-intent.d.ts +48 -0
  19. package/declarations/-private/hover-intent.d.ts.map +1 -0
  20. package/declarations/-private/image-loading.d.ts +77 -0
  21. package/declarations/-private/image-loading.d.ts.map +1 -0
  22. package/declarations/-private/indicator.d.ts +27 -0
  23. package/declarations/-private/indicator.d.ts.map +1 -0
  24. package/declarations/-private/instances.d.ts +11 -0
  25. package/declarations/-private/instances.d.ts.map +1 -0
  26. package/declarations/-private/layout-styles.d.ts +34 -0
  27. package/declarations/-private/layout-styles.d.ts.map +1 -0
  28. package/declarations/-private/menu.d.ts +616 -0
  29. package/declarations/-private/menu.d.ts.map +1 -0
  30. package/declarations/-private/observers.d.ts +35 -0
  31. package/declarations/-private/observers.d.ts.map +1 -0
  32. package/declarations/-private/popper.d.ts +149 -0
  33. package/declarations/-private/popper.d.ts.map +1 -0
  34. package/declarations/-private/presence-chart.d.ts +39 -0
  35. package/declarations/-private/presence-chart.d.ts.map +1 -0
  36. package/declarations/-private/promise-state.d.ts +41 -0
  37. package/declarations/-private/promise-state.d.ts.map +1 -0
  38. package/declarations/-private/scroll-end.d.ts +16 -0
  39. package/declarations/-private/scroll-end.d.ts.map +1 -0
  40. package/declarations/-private/scroll-visibility.d.ts +68 -0
  41. package/declarations/-private/scroll-visibility.d.ts.map +1 -0
  42. package/declarations/-private/toast.d.ts +119 -0
  43. package/declarations/-private/toast.d.ts.map +1 -0
  44. package/declarations/-private/typeahead-search.d.ts +29 -0
  45. package/declarations/-private/typeahead-search.d.ts.map +1 -0
  46. package/declarations/accordion.d.ts +284 -0
  47. package/declarations/accordion.d.ts.map +1 -0
  48. package/declarations/alert-dialog.d.ts +80 -0
  49. package/declarations/alert-dialog.d.ts.map +1 -0
  50. package/declarations/anchor/component.d.ts +63 -0
  51. package/declarations/anchor/component.d.ts.map +1 -0
  52. package/declarations/anchor/index.d.ts +7 -0
  53. package/declarations/anchor/index.d.ts.map +1 -0
  54. package/declarations/anchor/middleware.d.ts +46 -0
  55. package/declarations/anchor/middleware.d.ts.map +1 -0
  56. package/declarations/anchor/modifier.d.ts +34 -0
  57. package/declarations/anchor/modifier.d.ts.map +1 -0
  58. package/declarations/anchor/options.d.ts +112 -0
  59. package/declarations/anchor/options.d.ts.map +1 -0
  60. package/declarations/anchor/position.d.ts +36 -0
  61. package/declarations/anchor/position.d.ts.map +1 -0
  62. package/declarations/anchor.d.ts +2 -0
  63. package/declarations/as.d.ts +33 -0
  64. package/declarations/as.d.ts.map +1 -0
  65. package/declarations/aspect-ratio.d.ts +34 -0
  66. package/declarations/aspect-ratio.d.ts.map +1 -0
  67. package/declarations/avatar.d.ts +178 -0
  68. package/declarations/avatar.d.ts.map +1 -0
  69. package/declarations/body-class.d.ts +30 -0
  70. package/declarations/body-class.d.ts.map +1 -0
  71. package/declarations/breadcrumb.d.ts +64 -0
  72. package/declarations/breadcrumb.d.ts.map +1 -0
  73. package/declarations/calendar/dates.d.ts +142 -0
  74. package/declarations/calendar/dates.d.ts.map +1 -0
  75. package/declarations/calendar/index.d.ts +59 -0
  76. package/declarations/calendar/index.d.ts.map +1 -0
  77. package/declarations/calendar/state.d.ts +415 -0
  78. package/declarations/calendar/state.d.ts.map +1 -0
  79. package/declarations/calendar.d.ts +3 -0
  80. package/declarations/checkbox.d.ts +71 -0
  81. package/declarations/checkbox.d.ts.map +1 -0
  82. package/declarations/collapsible.d.ts +216 -0
  83. package/declarations/collapsible.d.ts.map +1 -0
  84. package/declarations/color-scheme.d.ts +115 -0
  85. package/declarations/color-scheme.d.ts.map +1 -0
  86. package/declarations/combobox.d.ts +569 -0
  87. package/declarations/combobox.d.ts.map +1 -0
  88. package/declarations/command.d.ts +410 -0
  89. package/declarations/command.d.ts.map +1 -0
  90. package/declarations/context-menu.d.ts +155 -0
  91. package/declarations/context-menu.d.ts.map +1 -0
  92. package/declarations/controllable-state.d.ts +85 -0
  93. package/declarations/controllable-state.d.ts.map +1 -0
  94. package/declarations/dialog.d.ts +80 -0
  95. package/declarations/dialog.d.ts.map +1 -0
  96. package/declarations/direction.d.ts +55 -0
  97. package/declarations/direction.d.ts.map +1 -0
  98. package/declarations/dismiss.d.ts +111 -0
  99. package/declarations/dismiss.d.ts.map +1 -0
  100. package/declarations/dom-context.d.ts +74 -0
  101. package/declarations/dom-context.d.ts.map +1 -0
  102. package/declarations/drawer/controller.d.ts +174 -0
  103. package/declarations/drawer/controller.d.ts.map +1 -0
  104. package/declarations/drawer/index.d.ts +105 -0
  105. package/declarations/drawer/index.d.ts.map +1 -0
  106. package/declarations/drawer/machine.d.ts +139 -0
  107. package/declarations/drawer/machine.d.ts.map +1 -0
  108. package/declarations/drawer/parts.d.ts +85 -0
  109. package/declarations/drawer/parts.d.ts.map +1 -0
  110. package/declarations/drawer.d.ts +2 -0
  111. package/declarations/dropdown-menu.d.ts +169 -0
  112. package/declarations/dropdown-menu.d.ts.map +1 -0
  113. package/declarations/external-link.d.ts +26 -0
  114. package/declarations/external-link.d.ts.map +1 -0
  115. package/declarations/file-drop.d.ts +119 -0
  116. package/declarations/file-drop.d.ts.map +1 -0
  117. package/declarations/focus-scope.d.ts +105 -0
  118. package/declarations/focus-scope.d.ts.map +1 -0
  119. package/declarations/focus.d.ts +114 -0
  120. package/declarations/focus.d.ts.map +1 -0
  121. package/declarations/head.d.ts +20 -0
  122. package/declarations/head.d.ts.map +1 -0
  123. package/declarations/heading.d.ts +59 -0
  124. package/declarations/heading.d.ts.map +1 -0
  125. package/declarations/hero.d.ts +32 -0
  126. package/declarations/hero.d.ts.map +1 -0
  127. package/declarations/hide-others.d.ts +35 -0
  128. package/declarations/hide-others.d.ts.map +1 -0
  129. package/declarations/hover-card.d.ts +148 -0
  130. package/declarations/hover-card.d.ts.map +1 -0
  131. package/declarations/i18n.d.ts +47 -0
  132. package/declarations/i18n.d.ts.map +1 -0
  133. package/declarations/id.d.ts +15 -0
  134. package/declarations/id.d.ts.map +1 -0
  135. package/declarations/iframe.d.ts +12 -0
  136. package/declarations/iframe.d.ts.map +1 -0
  137. package/declarations/incremental-each.d.ts +81 -0
  138. package/declarations/incremental-each.d.ts.map +1 -0
  139. package/declarations/index.d.ts +108 -0
  140. package/declarations/index.d.ts.map +1 -0
  141. package/declarations/input-otp.d.ts +201 -0
  142. package/declarations/input-otp.d.ts.map +1 -0
  143. package/declarations/keys.d.ts +50 -0
  144. package/declarations/keys.d.ts.map +1 -0
  145. package/declarations/label.d.ts +36 -0
  146. package/declarations/label.d.ts.map +1 -0
  147. package/declarations/layer.d.ts +56 -0
  148. package/declarations/layer.d.ts.map +1 -0
  149. package/declarations/link-helper.d.ts +73 -0
  150. package/declarations/link-helper.d.ts.map +1 -0
  151. package/declarations/link.d.ts +60 -0
  152. package/declarations/link.d.ts.map +1 -0
  153. package/declarations/load.d.ts +47 -0
  154. package/declarations/load.d.ts.map +1 -0
  155. package/declarations/menubar.d.ts +231 -0
  156. package/declarations/menubar.d.ts.map +1 -0
  157. package/declarations/message-scroller/components.d.ts +229 -0
  158. package/declarations/message-scroller/components.d.ts.map +1 -0
  159. package/declarations/message-scroller/geometry.d.ts +95 -0
  160. package/declarations/message-scroller/geometry.d.ts.map +1 -0
  161. package/declarations/message-scroller/index.d.ts +4 -0
  162. package/declarations/message-scroller/index.d.ts.map +1 -0
  163. package/declarations/message-scroller/state.d.ts +124 -0
  164. package/declarations/message-scroller/state.d.ts.map +1 -0
  165. package/declarations/message-scroller.d.ts +2 -0
  166. package/declarations/messages.d.ts +166 -0
  167. package/declarations/messages.d.ts.map +1 -0
  168. package/declarations/narrowing.d.ts +24 -0
  169. package/declarations/narrowing.d.ts.map +1 -0
  170. package/declarations/native-form.d.ts +56 -0
  171. package/declarations/native-form.d.ts.map +1 -0
  172. package/declarations/native-value.d.ts +47 -0
  173. package/declarations/native-value.d.ts.map +1 -0
  174. package/declarations/navigation-menu.d.ts +406 -0
  175. package/declarations/navigation-menu.d.ts.map +1 -0
  176. package/declarations/on-resize.d.ts +32 -0
  177. package/declarations/on-resize.d.ts.map +1 -0
  178. package/declarations/part.d.ts +99 -0
  179. package/declarations/part.d.ts.map +1 -0
  180. package/declarations/popover.d.ts +236 -0
  181. package/declarations/popover.d.ts.map +1 -0
  182. package/declarations/portal/index.d.ts +3 -0
  183. package/declarations/portal/index.d.ts.map +1 -0
  184. package/declarations/portal/portal.d.ts +46 -0
  185. package/declarations/portal/portal.d.ts.map +1 -0
  186. package/declarations/portal/targets.d.ts +40 -0
  187. package/declarations/portal/targets.d.ts.map +1 -0
  188. package/declarations/portal.d.ts +2 -0
  189. package/declarations/presence.d.ts +80 -0
  190. package/declarations/presence.d.ts.map +1 -0
  191. package/declarations/progress.d.ts +98 -0
  192. package/declarations/progress.d.ts.map +1 -0
  193. package/declarations/proper-links.d.ts +69 -0
  194. package/declarations/proper-links.d.ts.map +1 -0
  195. package/declarations/qp.d.ts +55 -0
  196. package/declarations/qp.d.ts.map +1 -0
  197. package/declarations/questionnaire/components.d.ts +348 -0
  198. package/declarations/questionnaire/components.d.ts.map +1 -0
  199. package/declarations/questionnaire/index.d.ts +4 -0
  200. package/declarations/questionnaire/index.d.ts.map +1 -0
  201. package/declarations/questionnaire/state.d.ts +400 -0
  202. package/declarations/questionnaire/state.d.ts.map +1 -0
  203. package/declarations/questionnaire/utils.d.ts +65 -0
  204. package/declarations/questionnaire/utils.d.ts.map +1 -0
  205. package/declarations/questionnaire.d.ts +2 -0
  206. package/declarations/radio-group.d.ts +115 -0
  207. package/declarations/radio-group.d.ts.map +1 -0
  208. package/declarations/rating.d.ts +214 -0
  209. package/declarations/rating.d.ts.map +1 -0
  210. package/declarations/resizable/components.d.ts +107 -0
  211. package/declarations/resizable/components.d.ts.map +1 -0
  212. package/declarations/resizable/index.d.ts +4 -0
  213. package/declarations/resizable/index.d.ts.map +1 -0
  214. package/declarations/resizable/layout.d.ts +93 -0
  215. package/declarations/resizable/layout.d.ts.map +1 -0
  216. package/declarations/resizable/state.d.ts +211 -0
  217. package/declarations/resizable/state.d.ts.map +1 -0
  218. package/declarations/resizable.d.ts +2 -0
  219. package/declarations/resize-observer.d.ts +40 -0
  220. package/declarations/resize-observer.d.ts.map +1 -0
  221. package/declarations/roving-focus.d.ts +204 -0
  222. package/declarations/roving-focus.d.ts.map +1 -0
  223. package/declarations/scroll-area/components.d.ts +125 -0
  224. package/declarations/scroll-area/components.d.ts.map +1 -0
  225. package/declarations/scroll-area/index.d.ts +3 -0
  226. package/declarations/scroll-area/index.d.ts.map +1 -0
  227. package/declarations/scroll-area/state.d.ts +147 -0
  228. package/declarations/scroll-area/state.d.ts.map +1 -0
  229. package/declarations/scroll-area.d.ts +2 -0
  230. package/declarations/scroll-lock.d.ts +69 -0
  231. package/declarations/scroll-lock.d.ts.map +1 -0
  232. package/declarations/scroller.d.ts +71 -0
  233. package/declarations/scroller.d.ts.map +1 -0
  234. package/declarations/select.d.ts +459 -0
  235. package/declarations/select.d.ts.map +1 -0
  236. package/declarations/separator.d.ts +71 -0
  237. package/declarations/separator.d.ts.map +1 -0
  238. package/declarations/service.d.ts +83 -0
  239. package/declarations/service.d.ts.map +1 -0
  240. package/declarations/shadowed.d.ts +63 -0
  241. package/declarations/shadowed.d.ts.map +1 -0
  242. package/declarations/slider.d.ts +283 -0
  243. package/declarations/slider.d.ts.map +1 -0
  244. package/declarations/sticky-footer.d.ts +43 -0
  245. package/declarations/sticky-footer.d.ts.map +1 -0
  246. package/declarations/store.d.ts +47 -0
  247. package/declarations/store.d.ts.map +1 -0
  248. package/declarations/switch.d.ts +76 -0
  249. package/declarations/switch.d.ts.map +1 -0
  250. package/declarations/tabs.d.ts +250 -0
  251. package/declarations/tabs.d.ts.map +1 -0
  252. package/declarations/toast/icons.d.ts +29 -0
  253. package/declarations/toast/icons.d.ts.map +1 -0
  254. package/declarations/toast/index.d.ts +4 -0
  255. package/declarations/toast/index.d.ts.map +1 -0
  256. package/declarations/toast/item.d.ts +162 -0
  257. package/declarations/toast/item.d.ts.map +1 -0
  258. package/declarations/toast/state.d.ts +276 -0
  259. package/declarations/toast/state.d.ts.map +1 -0
  260. package/declarations/toast/styles.d.ts +20 -0
  261. package/declarations/toast/styles.d.ts.map +1 -0
  262. package/declarations/toast/toaster.d.ts +173 -0
  263. package/declarations/toast/toaster.d.ts.map +1 -0
  264. package/declarations/toast.d.ts +2 -0
  265. package/declarations/toggle-group.d.ts +161 -0
  266. package/declarations/toggle-group.d.ts.map +1 -0
  267. package/declarations/toggle.d.ts +70 -0
  268. package/declarations/toggle.d.ts.map +1 -0
  269. package/declarations/tooltip.d.ts +227 -0
  270. package/declarations/tooltip.d.ts.map +1 -0
  271. package/declarations/typeahead.d.ts +97 -0
  272. package/declarations/typeahead.d.ts.map +1 -0
  273. package/declarations/viewport.d.ts +109 -0
  274. package/declarations/viewport.d.ts.map +1 -0
  275. package/declarations/visually-hidden.d.ts +42 -0
  276. package/declarations/visually-hidden.d.ts.map +1 -0
  277. package/declarations/zoetrope.d.ts +120 -0
  278. package/declarations/zoetrope.d.ts.map +1 -0
  279. package/dist/accordion.js +367 -0
  280. package/dist/accordion.js.map +1 -0
  281. package/dist/alert-dialog.js +122 -0
  282. package/dist/alert-dialog.js.map +1 -0
  283. package/dist/anchor.js +2 -0
  284. package/dist/anchor.js.map +1 -0
  285. package/dist/as.js +60 -0
  286. package/dist/as.js.map +1 -0
  287. package/dist/aspect-ratio.js +59 -0
  288. package/dist/aspect-ratio.js.map +1 -0
  289. package/dist/avatar.js +464 -0
  290. package/dist/avatar.js.map +1 -0
  291. package/dist/body-class.js +57 -0
  292. package/dist/body-class.js.map +1 -0
  293. package/dist/breadcrumb.js +59 -0
  294. package/dist/breadcrumb.js.map +1 -0
  295. package/dist/calendar.js +1494 -0
  296. package/dist/calendar.js.map +1 -0
  297. package/dist/checkbox.js +81 -0
  298. package/dist/checkbox.js.map +1 -0
  299. package/dist/collapsible.js +255 -0
  300. package/dist/collapsible.js.map +1 -0
  301. package/dist/color-scheme.js +306 -0
  302. package/dist/color-scheme.js.map +1 -0
  303. package/dist/combobox.js +1413 -0
  304. package/dist/combobox.js.map +1 -0
  305. package/dist/command.js +1054 -0
  306. package/dist/command.js.map +1 -0
  307. package/dist/component-DqLt83fo.js +886 -0
  308. package/dist/component-DqLt83fo.js.map +1 -0
  309. package/dist/components-CWfg0cFs.js +1745 -0
  310. package/dist/components-CWfg0cFs.js.map +1 -0
  311. package/dist/components-DBWszEI3.js +1285 -0
  312. package/dist/components-DBWszEI3.js.map +1 -0
  313. package/dist/components-DI8Azu05.js +1542 -0
  314. package/dist/components-DI8Azu05.js.map +1 -0
  315. package/dist/components-F0Ini448.js +875 -0
  316. package/dist/components-F0Ini448.js.map +1 -0
  317. package/dist/context-menu.js +207 -0
  318. package/dist/context-menu.js.map +1 -0
  319. package/dist/controllable-state.js +134 -0
  320. package/dist/controllable-state.js.map +1 -0
  321. package/dist/delay-group-B1K03gBL.js +75 -0
  322. package/dist/delay-group-B1K03gBL.js.map +1 -0
  323. package/dist/dialog-3gfz_8NA.js +349 -0
  324. package/dist/dialog-3gfz_8NA.js.map +1 -0
  325. package/dist/dialog.js +57 -0
  326. package/dist/dialog.js.map +1 -0
  327. package/dist/direction.js +75 -0
  328. package/dist/direction.js.map +1 -0
  329. package/dist/dismiss.js +329 -0
  330. package/dist/dismiss.js.map +1 -0
  331. package/dist/dom-context.js +104 -0
  332. package/dist/dom-context.js.map +1 -0
  333. package/dist/drawer.js +1456 -0
  334. package/dist/drawer.js.map +1 -0
  335. package/dist/dropdown-menu.js +201 -0
  336. package/dist/dropdown-menu.js.map +1 -0
  337. package/dist/external-link.js +21 -0
  338. package/dist/external-link.js.map +1 -0
  339. package/dist/file-drop.js +183 -0
  340. package/dist/file-drop.js.map +1 -0
  341. package/dist/focus-scope.js +292 -0
  342. package/dist/focus-scope.js.map +1 -0
  343. package/dist/focus.js +311 -0
  344. package/dist/focus.js.map +1 -0
  345. package/dist/form-control-Ca_KHSKK.js +177 -0
  346. package/dist/form-control-Ca_KHSKK.js.map +1 -0
  347. package/dist/head.js +25 -0
  348. package/dist/head.js.map +1 -0
  349. package/dist/heading.js +152 -0
  350. package/dist/heading.js.map +1 -0
  351. package/dist/hero.js +36 -0
  352. package/dist/hero.js.map +1 -0
  353. package/dist/hide-others.js +108 -0
  354. package/dist/hide-others.js.map +1 -0
  355. package/dist/hover-card.js +246 -0
  356. package/dist/hover-card.js.map +1 -0
  357. package/dist/hover-intent-Bxb83fgX.js +92 -0
  358. package/dist/hover-intent-Bxb83fgX.js.map +1 -0
  359. package/dist/i18n.js +72 -0
  360. package/dist/i18n.js.map +1 -0
  361. package/dist/id.js +24 -0
  362. package/dist/id.js.map +1 -0
  363. package/dist/iframe.js +19 -0
  364. package/dist/iframe.js.map +1 -0
  365. package/dist/incremental-each.js +181 -0
  366. package/dist/incremental-each.js.map +1 -0
  367. package/dist/index.js +87 -0
  368. package/dist/index.js.map +1 -0
  369. package/dist/indicator-sYuRuFJA.js +26 -0
  370. package/dist/indicator-sYuRuFJA.js.map +1 -0
  371. package/dist/input-otp.js +611 -0
  372. package/dist/input-otp.js.map +1 -0
  373. package/dist/keys.js +65 -0
  374. package/dist/keys.js.map +1 -0
  375. package/dist/label.js +41 -0
  376. package/dist/label.js.map +1 -0
  377. package/dist/layer.js +157 -0
  378. package/dist/layer.js.map +1 -0
  379. package/dist/layout-styles-DY86so8a.js +81 -0
  380. package/dist/layout-styles-DY86so8a.js.map +1 -0
  381. package/dist/link-helper.js +122 -0
  382. package/dist/link-helper.js.map +1 -0
  383. package/dist/link.js +39 -0
  384. package/dist/link.js.map +1 -0
  385. package/dist/load.js +54 -0
  386. package/dist/load.js.map +1 -0
  387. package/dist/menu-Da1LFCet.js +1109 -0
  388. package/dist/menu-Da1LFCet.js.map +1 -0
  389. package/dist/menubar.js +357 -0
  390. package/dist/menubar.js.map +1 -0
  391. package/dist/message-scroller.js +2 -0
  392. package/dist/message-scroller.js.map +1 -0
  393. package/dist/messages.js +168 -0
  394. package/dist/messages.js.map +1 -0
  395. package/dist/narrowing.js +29 -0
  396. package/dist/narrowing.js.map +1 -0
  397. package/dist/native-form.js +134 -0
  398. package/dist/native-form.js.map +1 -0
  399. package/dist/native-value.js +125 -0
  400. package/dist/native-value.js.map +1 -0
  401. package/dist/navigation-menu.js +872 -0
  402. package/dist/navigation-menu.js.map +1 -0
  403. package/dist/observers-aItWe029.js +113 -0
  404. package/dist/observers-aItWe029.js.map +1 -0
  405. package/dist/on-resize.js +47 -0
  406. package/dist/on-resize.js.map +1 -0
  407. package/dist/part.js +291 -0
  408. package/dist/part.js.map +1 -0
  409. package/dist/popover.js +419 -0
  410. package/dist/popover.js.map +1 -0
  411. package/dist/popper-BbTzV8dP.js +323 -0
  412. package/dist/popper-BbTzV8dP.js.map +1 -0
  413. package/dist/portal-U554WDI9.js +214 -0
  414. package/dist/portal-U554WDI9.js.map +1 -0
  415. package/dist/portal.js +2 -0
  416. package/dist/portal.js.map +1 -0
  417. package/dist/presence.js +243 -0
  418. package/dist/presence.js.map +1 -0
  419. package/dist/progress.js +106 -0
  420. package/dist/progress.js.map +1 -0
  421. package/dist/promise-state-BMi2zVoT.js +91 -0
  422. package/dist/promise-state-BMi2zVoT.js.map +1 -0
  423. package/dist/proper-links.js +136 -0
  424. package/dist/proper-links.js.map +1 -0
  425. package/dist/qp.js +77 -0
  426. package/dist/qp.js.map +1 -0
  427. package/dist/questionnaire.js +2 -0
  428. package/dist/questionnaire.js.map +1 -0
  429. package/dist/radio-group.js +149 -0
  430. package/dist/radio-group.js.map +1 -0
  431. package/dist/rating.js +261 -0
  432. package/dist/rating.js.map +1 -0
  433. package/dist/resizable.js +2 -0
  434. package/dist/resizable.js.map +1 -0
  435. package/dist/resize-observer.js +85 -0
  436. package/dist/resize-observer.js.map +1 -0
  437. package/dist/roving-focus.js +355 -0
  438. package/dist/roving-focus.js.map +1 -0
  439. package/dist/scroll-area.js +2 -0
  440. package/dist/scroll-area.js.map +1 -0
  441. package/dist/scroll-end-Cer8JSIB.js +87 -0
  442. package/dist/scroll-end-Cer8JSIB.js.map +1 -0
  443. package/dist/scroll-lock.js +267 -0
  444. package/dist/scroll-lock.js.map +1 -0
  445. package/dist/scroller.js +117 -0
  446. package/dist/scroller.js.map +1 -0
  447. package/dist/select.js +1223 -0
  448. package/dist/select.js.map +1 -0
  449. package/dist/separator.js +80 -0
  450. package/dist/separator.js.map +1 -0
  451. package/dist/service.js +160 -0
  452. package/dist/service.js.map +1 -0
  453. package/dist/shadowed.js +70 -0
  454. package/dist/shadowed.js.map +1 -0
  455. package/dist/slider.js +586 -0
  456. package/dist/slider.js.map +1 -0
  457. package/dist/sticky-footer.js +40 -0
  458. package/dist/sticky-footer.js.map +1 -0
  459. package/dist/store-BjiAd-KP.js +93 -0
  460. package/dist/store-BjiAd-KP.js.map +1 -0
  461. package/dist/store.js +4 -0
  462. package/dist/store.js.map +1 -0
  463. package/dist/switch.js +58 -0
  464. package/dist/switch.js.map +1 -0
  465. package/dist/tabs.js +458 -0
  466. package/dist/tabs.js.map +1 -0
  467. package/dist/toast.js +2 -0
  468. package/dist/toast.js.map +1 -0
  469. package/dist/toaster-DwprFZ1J.js +1518 -0
  470. package/dist/toaster-DwprFZ1J.js.map +1 -0
  471. package/dist/toggle-group.js +221 -0
  472. package/dist/toggle-group.js.map +1 -0
  473. package/dist/toggle.js +78 -0
  474. package/dist/toggle.js.map +1 -0
  475. package/dist/tooltip.js +422 -0
  476. package/dist/tooltip.js.map +1 -0
  477. package/dist/typeahead.js +233 -0
  478. package/dist/typeahead.js.map +1 -0
  479. package/dist/viewport.js +138 -0
  480. package/dist/viewport.js.map +1 -0
  481. package/dist/visually-hidden.js +49 -0
  482. package/dist/visually-hidden.js.map +1 -0
  483. package/dist/zoetrope.js +336 -0
  484. package/dist/zoetrope.js.map +1 -0
  485. package/package.json +101 -3
@@ -0,0 +1,1413 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { hash, array } from '@ember/helper';
4
+ import { registerDestructor } from '@ember/destroyable';
5
+ import Modifier, { modifier } from 'ember-modifier';
6
+ import { As } from './as.js';
7
+ import { controllable, ControllableState } from './controllable-state.js';
8
+ import { getDirection } from './direction.js';
9
+ import { dismissable } from './dismiss.js';
10
+ import { idFor } from './id.js';
11
+ import { topLayer } from './layer.js';
12
+ import { part } from './part.js';
13
+ import { Presence } from './presence.js';
14
+ import { State, Machine, region, transition, onExit } from '@switchyard-ts/core';
15
+ import { machine } from '@switchyard-ts/ember';
16
+ import { g, i, n } from 'decorator-transforms/runtime';
17
+ import { ignoreROError } from './resize-observer.js';
18
+ import { Typeahead, getNextMatch } from './typeahead.js';
19
+ import { b as buttonType, p as popperOptions, a as anchorContent, E as ElementRef, d as displayContents, e as ensureId } from './popper-BbTzV8dP.js';
20
+ import { translator } from './i18n.js';
21
+ import { isObject, isFunction, isString } from '@sindresorhus/is';
22
+ import { precompileTemplate } from '@ember/template-compilation';
23
+ import { setComponentTemplate } from '@ember/component';
24
+ import templateOnly from '@ember/component/template-only';
25
+
26
+ class ListPhase extends State {
27
+ /** The list is closed and its popup gone. */
28
+ static Closed = ListPhase.of('closed');
29
+ /** The list is open. */
30
+ static Open = ListPhase.of('open');
31
+ /** The list has closed and its popup is animating out, filtered by the frozen query. */
32
+ static Closing = ListPhase.of('closing');
33
+ }
34
+ class QueryMode extends State {
35
+ /** The input's text is what it was given (a single combobox's value's label): no filter yet. */
36
+ static Browsing = QueryMode.of('browsing');
37
+ /** The user has typed a query since the list opened. */
38
+ static Querying = QueryMode.of('querying');
39
+ }
40
+
41
+ /**
42
+ * A combobox list's modes, as Base UI's combobox keeps them in flags: where the popup is in
43
+ * its life, and whether the user has typed since it opened. Its events follow the committed
44
+ * `open` (sent after `openState.set()` took), never the request, so a controlled `@open` that
45
+ * refuses a change leaves nothing frozen.
46
+ */
47
+ let ComboboxList$1 = class ComboboxList extends Machine {
48
+ static {
49
+ g(this.prototype, "phase", [region(ListPhase)]);
50
+ }
51
+ #phase = (i(this, "phase"), void 0);
52
+ static {
53
+ g(this.prototype, "query", [region(QueryMode)]);
54
+ }
55
+ #query = (i(this, "query"), void 0);
56
+ static {
57
+ g(this.prototype, "frozenQuery", [tracked], function () {
58
+ return null;
59
+ });
60
+ }
61
+ #frozenQuery = (i(this, "frozenQuery"), void 0);
62
+ /** The query frozen while the popup animates out (or once an item is chosen), or `null`. */
63
+ get isQuerying() {
64
+ return this.matches(QueryMode.Querying);
65
+ }
66
+
67
+ // `opened` and `closed` come from any phase: a controlled `@open` can change without them.
68
+
69
+ /** It opened, maybe while still animating out. */
70
+ opened() {}
71
+
72
+ /** It closed: while a query was typed, the popup keeps showing what it matched. */
73
+ static {
74
+ n(this.prototype, "opened", [transition({
75
+ to: ListPhase.Open
76
+ })]);
77
+ }
78
+ closed(query) {
79
+ if (this.isQuerying) this.frozenQuery = query;
80
+ }
81
+
82
+ /** The popup has gone, after any exit animation: start afresh. */
83
+ static {
84
+ n(this.prototype, "closed", [transition({
85
+ to: ListPhase.Closing
86
+ })]);
87
+ }
88
+ unmounted() {
89
+ this.frozenQuery = null;
90
+ this.browse();
91
+ }
92
+
93
+ /** The user typed a query. */
94
+ static {
95
+ n(this.prototype, "unmounted", [transition({}), transition({
96
+ from: ListPhase.Closing,
97
+ to: ListPhase.Closed
98
+ })]);
99
+ }
100
+ typed() {}
101
+
102
+ /** Back to the given text, unfiltered. */
103
+ static {
104
+ n(this.prototype, "typed", [transition({
105
+ to: QueryMode.Querying
106
+ })]);
107
+ }
108
+ browse() {}
109
+
110
+ /** Freeze the query now (an item was chosen). */
111
+ static {
112
+ n(this.prototype, "browse", [transition({
113
+ to: QueryMode.Browsing
114
+ })]);
115
+ }
116
+ freeze(query) {
117
+ this.frozenQuery = query;
118
+ }
119
+ static {
120
+ n(this.prototype, "freeze", [transition({})]);
121
+ }
122
+ thaw() {
123
+ this.frozenQuery = null;
124
+ }
125
+ static {
126
+ n(this.prototype, "thaw", [onExit(ListPhase.Closing)]);
127
+ }
128
+ };
129
+
130
+ /** A started `ComboboxList`, stopped when `owner` is destroyed. */
131
+ function comboboxList(owner) {
132
+ return machine(owner, new ComboboxList$1());
133
+ }
134
+
135
+ /** Whether `items` is a list of groups (each has `items`), as Base UI decides it. */function isGroupedItems(items) {
136
+ const first = items?.[0];
137
+ return first != null && isObject(first) && !isFunction(first) && 'items' in first;
138
+ }
139
+ function serialize(value) {
140
+ if (value == null) return '';
141
+ if (isString(value)) return value;
142
+ try {
143
+ return JSON.stringify(value);
144
+ } catch {
145
+ return String(value);
146
+ }
147
+ }
148
+ /**
149
+ * An item's text, as Base UI's `stringifyAsLabel`: `itemToStringLabel`'s, or else the item's
150
+ * `label`, or its `value`, or the item itself.
151
+ */
152
+ function labelOf(item, itemToStringLabel) {
153
+ if (itemToStringLabel && item != null) return itemToStringLabel(item) ?? '';
154
+ if (item && isObject(item) && !isFunction(item)) {
155
+ const record = item;
156
+ if ('label' in record && record['label'] != null) return String(record['label']);
157
+ if ('value' in record) return String(record['value']);
158
+ }
159
+ return serialize(item);
160
+ }
161
+ /**
162
+ * An item's form value, as Base UI's `stringifyAsValue`: `itemToStringValue`'s, or else the
163
+ * `value` of an item with a `label` and a `value`, or the item itself.
164
+ */
165
+ function formValueOf(item, itemToStringValue) {
166
+ if (itemToStringValue && item != null) return itemToStringValue(item) ?? '';
167
+ if (item && isObject(item) && !isFunction(item) && 'value' in item && 'label' in item) {
168
+ return serialize(item['value']);
169
+ }
170
+ return serialize(item);
171
+ }
172
+ /** How Base UI matches text: an `Intl.Collator` for search, ignoring case, accents and punctuation. */
173
+
174
+ const filters = new Map();
175
+ /**
176
+ * Base UI's collator filter (`useFilter`): `contains`, `startsWith` and `endsWith`, comparing
177
+ * with `Intl.Collator` (`usage: 'search'`, `sensitivity: 'base'`, punctuation ignored), so
178
+ * "e" finds "É" and case doesn't matter.
179
+ */
180
+ function comboboxFilter(options = {}) {
181
+ const {
182
+ locale,
183
+ ...collatorOptions
184
+ } = options;
185
+ const merged = {
186
+ usage: 'search',
187
+ sensitivity: 'base',
188
+ ignorePunctuation: true,
189
+ ...collatorOptions
190
+ };
191
+ const key = `${locale ?? ''}|${JSON.stringify(merged)}`;
192
+ let filter = filters.get(key);
193
+ if (filter) return filter;
194
+ const collator = new Intl.Collator(locale, merged);
195
+ filter = {
196
+ contains(text, query) {
197
+ if (!query) return true;
198
+ for (let i = 0; i <= text.length - query.length; i += 1) {
199
+ if (collator.compare(text.slice(i, i + query.length), query) === 0) return true;
200
+ }
201
+ return false;
202
+ },
203
+ startsWith(text, query) {
204
+ if (!query) return true;
205
+ return collator.compare(text.slice(0, query.length), query) === 0;
206
+ },
207
+ endsWith(text, query) {
208
+ if (!query) return true;
209
+ return text.length >= query.length && collator.compare(text.slice(text.length - query.length), query) === 0;
210
+ }
211
+ };
212
+ filters.set(key, filter);
213
+ return filter;
214
+ }
215
+ /** A filter of your own: whether `item` matches `query`. */
216
+ function equal(a, b, isEqual) {
217
+ if (a == null || b == null) return Object.is(a, b);
218
+ return isEqual(a, b);
219
+ }
220
+ // ----- Arguments -----------------------------------------------------------------------------
221
+ /** What a `<Combobox>` takes: Base UI's Combobox props, by Joinery's names. */
222
+
223
+ /** Where the popup goes: Base UI's positioner arguments. */
224
+
225
+ const CONTENT_DEFAULTS = {
226
+ side: 'bottom',
227
+ align: 'center',
228
+ sideOffset: 0,
229
+ collisionPadding: 5
230
+ };
231
+ /** Whether the input's change came from typing (not autofill), as Base UI tells them apart. */function isTyped(event) {
232
+ if (!event) return false;
233
+ if (event.type === 'compositionend') return true;
234
+ const inputType = event.inputType;
235
+ return inputType != null && inputType !== '' && inputType !== 'insertReplacementText';
236
+ }
237
+ /** Base UI's anchor custom properties, from the ones `anchor` sets. */
238
+ function exposeAnchorProperties(element) {
239
+ const properties = [['--anchor-width', 'var(--jn-anchor-width)'], ['--anchor-height', 'var(--jn-anchor-height)'], ['--available-width', 'var(--jn-anchor-available-width)'], ['--available-height', 'var(--jn-anchor-available-height)'], ['--transform-origin', 'var(--jn-anchor-transform-origin)']];
240
+ for (const [property, value] of properties) element.style.setProperty(property, value);
241
+ return () => {
242
+ for (const [property] of properties) element.style.removeProperty(property);
243
+ };
244
+ }
245
+ function byDocumentOrder(a, b) {
246
+ if (a.element === b.element) return 0;
247
+ return a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
248
+ }
249
+ function isInteractive(element) {
250
+ return Boolean(element?.closest('button, a[href], input, select, textarea, [role="button"]'));
251
+ }
252
+ // ----- Items ---------------------------------------------------------------------------------
253
+
254
+ /** What an item yields: its indicator, bound to it, and its state. */
255
+
256
+ /**
257
+ * One item, `role="option"`: Base UI's `Combobox.Item`. Focus stays in the input: the item is
258
+ * highlighted (the input's `aria-activedescendant`) by the arrow keys or the pointer, and a
259
+ * press or Enter chooses it.
260
+ */
261
+ class ComboboxItem extends Component {
262
+ element;
263
+ #pointerStarted = false;
264
+ get combobox() {
265
+ return this.args.combobox;
266
+ }
267
+ get value() {
268
+ return this.args.value;
269
+ }
270
+ get isDisabled() {
271
+ return this.args.disabled ?? false;
272
+ }
273
+ get id() {
274
+ return idFor(this);
275
+ }
276
+ get index() {
277
+ return this.combobox.trackedItems.indexOf(this);
278
+ }
279
+ get isHighlighted() {
280
+ const index = this.combobox.activeIndex;
281
+ return index !== null && this.combobox.trackedItems[index] === this;
282
+ }
283
+ get isSelected() {
284
+ return this.combobox.isSelected(this.args.value);
285
+ }
286
+ choose = event => {
287
+ if (this.isDisabled || this.combobox.isReadOnly) return;
288
+ this.combobox.handleSelection(event, this.args.value);
289
+ };
290
+ part = part(() => ({
291
+ attributes: {
292
+ id: this.id,
293
+ role: 'option',
294
+ 'aria-selected': this.combobox.isSelectable ? String(this.isSelected) : undefined,
295
+ 'aria-disabled': this.isDisabled ? 'true' : undefined,
296
+ 'data-highlighted': this.isHighlighted,
297
+ 'data-selected': this.isSelected,
298
+ 'data-disabled': this.isDisabled,
299
+ 'data-test-jn-part': 'item',
300
+ 'data-test-jn-value': labelOf(this.args.value, this.combobox.args.itemToStringLabel)
301
+ },
302
+ on: {
303
+ // Focus stays in the input: a press on an item doesn't move it.
304
+ pointerdown: event => {
305
+ this.#pointerStarted = true;
306
+ event.preventDefault();
307
+ },
308
+ mousedown: event => event.preventDefault(),
309
+ click: this.choose,
310
+ mouseup: event => {
311
+ const started = this.#pointerStarted;
312
+ this.#pointerStarted = false;
313
+ // A press that started on the input and slid here, released on the highlighted item.
314
+ if (event.button !== 0 || started || !this.isHighlighted) return;
315
+ this.choose(event);
316
+ },
317
+ pointermove: () => {
318
+ if (this.combobox.highlightOnHover && !this.isHighlighted) {
319
+ this.combobox.highlight(this.index);
320
+ }
321
+ },
322
+ pointerleave: () => {
323
+ if (this.combobox.highlightOnHover && this.isHighlighted) this.combobox.highlight(null);
324
+ }
325
+ },
326
+ element: element => {
327
+ this.element = element;
328
+ return this.combobox.registerItem(this);
329
+ }
330
+ }));
331
+ static {
332
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{this.part}}>\n {{yield (hash ItemIndicator=(component ComboboxItemIndicator item=this) isSelected=this.isSelected isHighlighted=this.isHighlighted)}}\n</As>", {
333
+ strictMode: true,
334
+ scope: () => ({
335
+ As,
336
+ hash,
337
+ ComboboxItemIndicator
338
+ })
339
+ }), this);
340
+ }
341
+ }
342
+ /** Base UI's `Combobox.ItemIndicator`: rendered while its item is chosen, hidden from assistive technology. */const ComboboxItemIndicator = setComponentTemplate(precompileTemplate("{{#if @item.isSelected}}\n <As @as={{@as}} @tag=\"span\" aria-hidden=\"true\" data-test-jn-part=\"item-indicator\" ...attributes>{{yield}}</As>\n{{/if}}", {
343
+ strictMode: true,
344
+ scope: () => ({
345
+ As
346
+ })
347
+ }), templateOnly());
348
+ // ----- Chips ---------------------------------------------------------------------------------
349
+
350
+ /**
351
+ * One chosen item, in a multiple combobox: Base UI's `Combobox.Chip`. The arrow keys move
352
+ * between chips (from the input's start), and Backspace or Delete removes one.
353
+ */
354
+ class ComboboxChip extends Component {
355
+ element;
356
+ get combobox() {
357
+ return this.args.combobox;
358
+ }
359
+ remove = event => {
360
+ const combobox = this.combobox;
361
+ if (combobox.isDisabled || combobox.isReadOnly) return;
362
+ combobox.removeChip(this.args.value, 'chip-remove-press');
363
+ event.stopPropagation();
364
+ combobox.inputRef.current?.focus();
365
+ };
366
+ keyDown = event => {
367
+ const combobox = this.combobox;
368
+ if (combobox.isDisabled || combobox.isReadOnly) return;
369
+ const chips = combobox.chipItems;
370
+ const index = chips.indexOf(this);
371
+ const rtl = getDirection(this.element) === 'rtl';
372
+ const previous = rtl ? 'ArrowRight' : 'ArrowLeft';
373
+ const next = rtl ? 'ArrowLeft' : 'ArrowRight';
374
+ let target = index;
375
+ if (event.key === previous) {
376
+ event.preventDefault();
377
+ target = index > 0 ? index - 1 : undefined;
378
+ } else if (event.key === next) {
379
+ event.preventDefault();
380
+ target = index < chips.length - 1 ? index + 1 : undefined;
381
+ } else if (event.key === 'Backspace' || event.key === 'Delete') {
382
+ const count = chips.length;
383
+ const after = index >= count - 1 ? count - 2 : index;
384
+ target = after >= 0 ? after : undefined;
385
+ event.preventDefault();
386
+ event.stopPropagation();
387
+ combobox.highlight(null);
388
+ combobox.removeChip(this.args.value, 'none');
389
+ } else if (event.key === 'Enter' || event.key === ' ') {
390
+ event.preventDefault();
391
+ event.stopPropagation();
392
+ target = undefined;
393
+ } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
394
+ event.preventDefault();
395
+ event.stopPropagation();
396
+ combobox.setOpen(true, 'list-navigation');
397
+ target = undefined;
398
+ } else if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
399
+ // Typing goes back to the input.
400
+ target = undefined;
401
+ }
402
+ combobox.highlightedChip = target;
403
+ if (target === undefined) combobox.inputRef.current?.focus();else queueMicrotask(() => combobox.chipItems[target]?.element.focus());
404
+ };
405
+ part = part(() => ({
406
+ attributes: {
407
+ tabindex: '-1',
408
+ 'aria-disabled': this.combobox.isDisabled ? 'true' : undefined,
409
+ 'aria-readonly': this.combobox.isReadOnly ? 'true' : undefined,
410
+ 'data-disabled': this.combobox.isDisabled,
411
+ 'data-test-jn-part': 'chip',
412
+ 'data-test-jn-value': labelOf(this.args.value, this.combobox.args.itemToStringLabel)
413
+ },
414
+ on: {
415
+ keydown: this.keyDown
416
+ },
417
+ element: element => {
418
+ this.element = element;
419
+ return this.combobox.registerChip(this);
420
+ }
421
+ }));
422
+ removePart = part(() => ({
423
+ attributes: {
424
+ tabindex: '-1',
425
+ 'aria-disabled': this.combobox.isDisabled || this.combobox.isReadOnly ? 'true' : undefined,
426
+ 'data-test-jn-part': 'chip-remove'
427
+ },
428
+ on: {
429
+ mousedown: event => event.preventDefault(),
430
+ click: this.remove,
431
+ keydown: event => {
432
+ if (event.key === 'Enter' || event.key === ' ') {
433
+ event.preventDefault();
434
+ this.remove(event);
435
+ }
436
+ }
437
+ },
438
+ element: buttonType
439
+ }));
440
+ static {
441
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{this.part}}>\n {{yield (hash Remove=(component ComboboxChipRemove chip=this) remove=this.removePart)}}\n</As>", {
442
+ strictMode: true,
443
+ scope: () => ({
444
+ As,
445
+ hash,
446
+ ComboboxChipRemove
447
+ })
448
+ }), this);
449
+ }
450
+ }
451
+ /** Base UI's `Combobox.ChipRemove`: a button, out of the tab order, that removes its chip. */const ComboboxChipRemove = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"button\" type=\"button\" ...attributes {{@chip.removePart}}>{{yield}}</As>", {
452
+ strictMode: true,
453
+ scope: () => ({
454
+ As
455
+ })
456
+ }), templateOnly());
457
+ // ----- Simple parts --------------------------------------------------------------------------
458
+
459
+ /** The text input that filters the list: Base UI's `Combobox.Input`. */const ComboboxInput = setComponentTemplate(precompileTemplate("<input ...attributes {{@part}} />", {
460
+ strictMode: true
461
+ }), templateOnly());
462
+ /** A button that opens and closes the list: Base UI's `Combobox.Trigger`. */
463
+ const ComboboxTrigger = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"button\" type=\"button\" ...attributes {{@part}}>{{yield}}</As>", {
464
+ strictMode: true,
465
+ scope: () => ({
466
+ As
467
+ })
468
+ }), templateOnly());
469
+ /** A `<div>` that labels the group it is in: Base UI's `Combobox.GroupLabel`. */
470
+ const ComboboxGroupLabel = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{@part}}>{{yield}}</As>", {
471
+ strictMode: true,
472
+ scope: () => ({
473
+ As
474
+ })
475
+ }), templateOnly());
476
+ /**
477
+ * A line between items or groups: Base UI's `Combobox.Separator`. Base UI gives it
478
+ * `role="separator"`, which a listbox may not hold (axe's `aria-required-children`), so
479
+ * Joinery's is hidden from assistive technology instead, as Radix's Select separator is.
480
+ */
481
+ const ComboboxSeparator = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" aria-hidden=\"true\" ...attributes {{@part}}>{{yield}}</As>", {
482
+ strictMode: true,
483
+ scope: () => ({
484
+ As
485
+ })
486
+ }), templateOnly());
487
+ /**
488
+ * A button that clears the input and the value: Base UI's `Combobox.Clear`. It renders only
489
+ * while there is something to clear.
490
+ */
491
+ const ComboboxClear = setComponentTemplate(precompileTemplate("{{#if @combobox.hasValue}}\n <As @as={{@as}} @tag=\"button\" type=\"button\" ...attributes {{@combobox.clear}}>\n {{~#if (has-block)}}{{yield}}{{else}}x{{/if~}}\n </As>\n{{/if}}", {
492
+ strictMode: true,
493
+ scope: () => ({
494
+ As
495
+ })
496
+ }), templateOnly());
497
+ /**
498
+ * Says so when no item matches: Base UI's `Combobox.Empty`, a polite live region that shows its
499
+ * block only while the filtered list is empty.
500
+ */
501
+ const ComboboxEmpty = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" data-test-jn-part=\"empty\" ...attributes>{{#if @combobox.isEmpty}}{{yield}}{{/if}}</As>", {
502
+ strictMode: true,
503
+ scope: () => ({
504
+ As
505
+ })
506
+ }), templateOnly());
507
+ /**
508
+ * The chosen item's label, or the labels of the chosen items joined by commas, or
509
+ * `@placeholder`: Base UI's `Combobox.Value`. It renders no element. With a block, it yields the
510
+ * value (the array of values, with `@multiple`) to render yourself, as the chips do.
511
+ */
512
+ const ComboboxValue = setComponentTemplate(precompileTemplate("{{~#if (has-block)~}}\n {{yield @combobox.value}}\n{{~else if @combobox.hasValue~}}\n {{@combobox.valueLabel}}\n{{~else~}}\n {{@placeholder}}\n{{~/if~}}", {
513
+ strictMode: true
514
+ }), templateOnly());
515
+ /** Base UI's `Combobox.Collection`: renders each item, filtered. */const ComboboxCollection = setComponentTemplate(precompileTemplate("{{#each @items as |item index|}}{{yield item index}}{{/each}}", {
516
+ strictMode: true
517
+ }), templateOnly());
518
+ /** Items that belong together, `role="group"`, named by its label: Base UI's `Combobox.Group`. */const ComboboxGroup = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" role=\"group\" data-test-jn-part=\"group\" ...attributes>\n {{yield (hash Collection=(component ComboboxCollection items=(if @items @items (array))))}}\n</As>", {
519
+ strictMode: true,
520
+ scope: () => ({
521
+ As,
522
+ hash,
523
+ ComboboxCollection,
524
+ array
525
+ })
526
+ }), templateOnly());
527
+ /** The `role="listbox"` that holds the items: Base UI's `Combobox.List`. */const ComboboxList = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{@combobox.list}}>\n {{#if @combobox.hasItems}}\n {{#each @combobox.filteredItems as |item index|}}{{yield item index}}{{/each}}\n {{else}}\n {{yield undefined 0}}\n {{/if}}\n</As>", {
528
+ strictMode: true,
529
+ scope: () => ({
530
+ As
531
+ })
532
+ }), templateOnly());
533
+ // ----- Content -------------------------------------------------------------------------------
534
+
535
+ /**
536
+ * The popup's life: Base UI's anchor custom properties, focus into the input inside it (and
537
+ * back to the trigger) when the input is inside, and what happens once it has gone
538
+ * (`handleUnmount`, after any exit animation).
539
+ */
540
+ class PopupBehaviour extends Modifier {
541
+ #installed = false;
542
+ modify(element, _, {
543
+ combobox
544
+ }) {
545
+ if (this.#installed) return;
546
+ this.#installed = true;
547
+ combobox.popupRef.set(element);
548
+ const restore = exposeAnchorProperties(element);
549
+ // Its width follows its anchor's (`w-(--anchor-width)`), which anchoring sets from a resize
550
+ // observer: the browser's benign "ResizeObserver loop" message follows.
551
+ ignoreROError();
552
+ const onFocus = event => {
553
+ // Focus on the popup itself (or the list) goes to the input.
554
+ const target = event.target;
555
+ if (target === element || combobox.listRef.current?.contains(target)) {
556
+ combobox.inputRef.current?.focus();
557
+ }
558
+ };
559
+ element.addEventListener('focusin', onFocus);
560
+ // A popup with the input inside is a dialog, named by its trigger unless the caller named it.
561
+ const named = element.hasAttribute('aria-label') || element.hasAttribute('aria-labelledby');
562
+ let restoreTriggerId = () => {};
563
+ const trigger = combobox.triggerRef.current;
564
+ if (combobox.inputInsidePopup && !named && trigger) {
565
+ restoreTriggerId = ensureId(trigger, idFor(combobox, 'trigger'));
566
+ element.setAttribute('aria-labelledby', trigger.id);
567
+ }
568
+ if (combobox.inputInsidePopup) {
569
+ queueMicrotask(() => {
570
+ if (combobox.isOpen) combobox.inputRef.current?.focus();
571
+ });
572
+ }
573
+ registerDestructor(this, () => {
574
+ element.removeEventListener('focusin', onFocus);
575
+ if (!named) element.removeAttribute('aria-labelledby');
576
+ restoreTriggerId();
577
+ restore();
578
+ // Its input may have gone already, taking focus with it to the body.
579
+ const active = document.activeElement;
580
+ const focusInside = element.contains(active) || active === document.body || !active;
581
+ combobox.popupRef.release(element);
582
+ if (combobox.inputInsidePopup && focusInside) combobox.triggerRef.current?.focus();
583
+ combobox.unmounted();
584
+ });
585
+ }
586
+ }
587
+ /**
588
+ * The popup: Base UI's `Combobox.Positioner` and `Combobox.Popup` as one element, in the
589
+ * browser's top layer while open (and while it animates out), placed below the input (or the
590
+ * trigger, when the input is inside it, or `@anchor`). A press outside, Escape or focus leaving
591
+ * closes it.
592
+ */
593
+ class ComboboxContent extends Component {
594
+ get combobox() {
595
+ return this.args.combobox;
596
+ }
597
+ get anchorOptions() {
598
+ // Base UI's positioner doesn't keep the popup on its anchor (`sticky` off).
599
+ return popperOptions(this.args, {}, CONTENT_DEFAULTS, {});
600
+ }
601
+ get reference() {
602
+ return this.args.anchor ?? this.combobox.anchorElement;
603
+ }
604
+ dismiss = reason => {
605
+ this.combobox.setOpen(false, reason === 'escape-key' ? 'escape-key' : 'outside-press');
606
+ };
607
+ static {
608
+ setComponentTemplate(precompileTemplate("<Presence @present={{@combobox.isOpen}} as |presence|>\n <As @as={{@as}} @tag=\"div\" data-jn-combobox-popup ...attributes {{presence.ref}} {{@combobox.popup}} {{topLayer}} {{anchorContent this.reference this.anchorOptions}} {{dismissable enabled=@combobox.isOpen onDismiss=this.dismiss inside=@combobox.insideElements}} {{PopupBehaviour combobox=@combobox}}>{{yield}}</As>\n</Presence>", {
609
+ strictMode: true,
610
+ scope: () => ({
611
+ Presence,
612
+ As,
613
+ topLayer,
614
+ anchorContent,
615
+ dismissable,
616
+ PopupBehaviour
617
+ })
618
+ }), this);
619
+ }
620
+ }
621
+ // ----- The combobox --------------------------------------------------------------------------
622
+ /** What a `<Combobox>` yields: its parts, their modifiers, and its state. */
623
+
624
+ /**
625
+ * An input with a list of suggestions: Base UI's Combobox, which shadcn's is built on. It
626
+ * renders no box of its own, and yields its parts:
627
+ *
628
+ * <Combobox @items={{frameworks}} as |c|>
629
+ * <c.Input placeholder="Select a framework" />
630
+ * <c.Content>
631
+ * <c.Empty>No items found.</c.Empty>
632
+ * <c.List as |item|>
633
+ * <c.Item @value={{item}}>{{item}}</c.Item>
634
+ * </c.List>
635
+ * </c.Content>
636
+ * </Combobox>
637
+ *
638
+ * Typing filters `@items` (an `Intl.Collator` match anywhere in the label, as Base UI's) and
639
+ * opens the list; the arrow keys highlight an item while focus stays in the input, and Enter or
640
+ * a press chooses it. With `@multiple` the value is an array, shown as chips.
641
+ */
642
+ class Combobox extends Component {
643
+ openState = controllable(this, 'open', false);
644
+ valueState;
645
+ inputState;
646
+ inputRef = new ElementRef();
647
+ triggerRef = new ElementRef();
648
+ clearRef = new ElementRef();
649
+ chipsRef = new ElementRef();
650
+ popupRef = new ElementRef();
651
+ listRef = new ElementRef();
652
+ /** The highlighted item's index among the rendered items, or `null`. */
653
+ static {
654
+ g(this.prototype, "activeIndex", [tracked], function () {
655
+ return null;
656
+ });
657
+ }
658
+ #activeIndex = (i(this, "activeIndex"), void 0);
659
+ /** Where the list is in its life, whether a query was typed, and the query frozen as it goes. */listMode = comboboxList(this);
660
+ /** Whether an input outside the popup has registered (so the input isn't inside it). */
661
+ static {
662
+ g(this.prototype, "hasOutsideInput", [tracked], function () {
663
+ return false;
664
+ });
665
+ }
666
+ #hasOutsideInput = (i(this, "hasOutsideInput"), void 0);
667
+ /** The chip that has focus, for the arrow keys. */highlightedChip;
668
+ /** The key that opened the list, which decides the first highlight. */
669
+ #openKey = null;
670
+ #hadInputClear = false;
671
+ #triggerTypeahead = new Typeahead();
672
+ #items = new Set();
673
+ #chips = new Set();
674
+ static {
675
+ g(this.prototype, "itemsVersion", [tracked], function () {
676
+ return 0;
677
+ });
678
+ }
679
+ #itemsVersion = (i(this, "itemsVersion"), void 0);
680
+ #bumping = false;
681
+ constructor(owner, args) {
682
+ super(owner, args);
683
+ this.valueState = new ControllableState({
684
+ name: 'value',
685
+ value: () => this.args.value,
686
+ defaultValue: () => this.args.defaultValue,
687
+ onChange: () => this.args.onValueChange,
688
+ fallback: args.multiple ? [] : null
689
+ });
690
+ this.inputState = new ControllableState({
691
+ name: 'inputValue',
692
+ value: () => this.args.inputValue,
693
+ defaultValue: () => this.initialInputValue,
694
+ onChange: () => this.args.onInputValueChange,
695
+ fallback: ''
696
+ });
697
+ registerDestructor(this, () => this.#triggerTypeahead.dispose());
698
+ }
699
+ /** Without `@inputValue` or `@defaultInputValue`, a single combobox's input starts with its value's label. */
700
+ get initialInputValue() {
701
+ const args = this.args;
702
+ if (args.inputValue !== undefined || args.defaultInputValue !== undefined) {
703
+ return args.defaultInputValue;
704
+ }
705
+ if (this.isSingle) return labelOf(this.valueState.value, args.itemToStringLabel);
706
+ return undefined;
707
+ }
708
+ get id() {
709
+ return idFor(this);
710
+ }
711
+ get listId() {
712
+ return idFor(this, 'list');
713
+ }
714
+ get popupId() {
715
+ return idFor(this, 'popup');
716
+ }
717
+ // ----- State ---------------------------------------------------------------------------------
718
+ get isOpen() {
719
+ return this.openState.value;
720
+ }
721
+ get isMultiple() {
722
+ return this.args.multiple ?? false;
723
+ }
724
+ get isSingle() {
725
+ return !this.isMultiple;
726
+ }
727
+ get isSelectable() {
728
+ return true;
729
+ }
730
+ get isDisabled() {
731
+ return this.args.disabled ?? false;
732
+ }
733
+ get isReadOnly() {
734
+ return this.args.readOnly ?? false;
735
+ }
736
+ get highlightOnHover() {
737
+ return this.args.highlightItemOnHover ?? true;
738
+ }
739
+ get loopFocus() {
740
+ return this.args.loopFocus ?? true;
741
+ }
742
+ get autoHighlight() {
743
+ const auto = this.args.autoHighlight;
744
+ if (auto === 'always') return 'always';
745
+ return auto ? 'input-change' : false;
746
+ }
747
+ get value() {
748
+ return this.valueState.value;
749
+ }
750
+ get values() {
751
+ const value = this.value;
752
+ return Array.isArray(value) ? value : [];
753
+ }
754
+ get inputValue() {
755
+ return this.inputState.value;
756
+ }
757
+ /** Whether the input is inside the popup (as in shadcn's "Popup" example): no input outside it. */
758
+ get inputInsidePopup() {
759
+ return !this.hasOutsideInput;
760
+ }
761
+ get isEqual() {
762
+ return this.args.isItemEqualToValue ?? Object.is;
763
+ }
764
+ isSelected(item) {
765
+ if (this.isMultiple) return this.values.some(value => equal(item, value, this.isEqual));
766
+ return equal(item, this.value, this.isEqual);
767
+ }
768
+ /** Whether there is a value to clear (and so whether Clear renders). */
769
+ get hasValue() {
770
+ if (this.isMultiple) return this.values.length > 0;
771
+ return this.value != null;
772
+ }
773
+ /** The chosen item's label, or the chosen items' labels joined by commas. */
774
+ get valueLabel() {
775
+ const toLabel = this.args.itemToStringLabel;
776
+ if (this.isMultiple) return this.values.map(value => labelOf(value, toLabel)).join(', ');
777
+ return this.value == null ? '' : labelOf(this.value, toLabel);
778
+ }
779
+ // ----- Filtering -----------------------------------------------------------------------------
780
+ get hasItems() {
781
+ return this.args.items !== undefined || this.args.filteredItems !== undefined;
782
+ }
783
+ get isGrouped() {
784
+ return isGroupedItems(this.args.items);
785
+ }
786
+ get query() {
787
+ const frozen = this.listMode.frozenQuery;
788
+ if (frozen !== null) return frozen;
789
+ const value = this.inputValue;
790
+ return value === '' ? '' : value.trim();
791
+ }
792
+ get collator() {
793
+ return comboboxFilter({
794
+ locale: this.args.locale ?? translator(this)?.locale
795
+ });
796
+ }
797
+ get selectedLabel() {
798
+ return this.isSingle ? labelOf(this.value, this.args.itemToStringLabel) : '';
799
+ }
800
+ /**
801
+ * Whether to show every item though there is a query: a single combobox's input shows its
802
+ * value's label, which the user hasn't changed since it opened.
803
+ */
804
+ get bypassesFiltering() {
805
+ const query = this.query;
806
+ const selected = this.selectedLabel;
807
+ return this.isSingle && !this.listMode.isQuerying && query !== '' && selected !== '' && selected.length === query.length && this.collator.contains(selected, query);
808
+ }
809
+ get filter() {
810
+ const own = this.args.filter;
811
+ if (own === null) return () => true;
812
+ if (own !== undefined) return own;
813
+ const collator = this.collator;
814
+ const toLabel = this.args.itemToStringLabel;
815
+ if (this.isSingle && !this.listMode.isQuerying) {
816
+ const selected = this.value;
817
+ return (item, query) => {
818
+ if (item == null) return false;
819
+ if (!query) return true;
820
+ const text = labelOf(item, toLabel);
821
+ const selectedText = selected != null ? labelOf(selected, toLabel) : '';
822
+ if (selectedText && collator.contains(selectedText, query)) {
823
+ if (selectedText.length === query.length) return true;
824
+ }
825
+ return collator.contains(text, query);
826
+ };
827
+ }
828
+ return item => item != null && collator.contains(labelOf(item, toLabel), this.query);
829
+ }
830
+ /** What the list shows: the filtered items (or groups of them), limited to `@limit`. */
831
+ get filteredItems() {
832
+ const args = this.args;
833
+ if (args.filteredItems && !(args.items && this.bypassesFiltering)) return args.filteredItems;
834
+ const items = args.items;
835
+ if (!items) return [];
836
+ const query = this.bypassesFiltering ? '' : this.query;
837
+ const limit = args.limit ?? -1;
838
+ const filter = this.filter;
839
+ const toLabel = args.itemToStringLabel;
840
+ const matches = item => query === '' || filter(item, query, toLabel);
841
+ if (this.isGrouped) {
842
+ const groups = [];
843
+ let count = 0;
844
+ for (const group of items) {
845
+ if (limit > -1 && count >= limit) break;
846
+ const candidates = group.items.filter(matches);
847
+ if (!candidates.length) continue;
848
+ const taken = limit > -1 ? candidates.slice(0, limit - count) : candidates;
849
+ groups.push({
850
+ ...group,
851
+ items: taken
852
+ });
853
+ count += taken.length;
854
+ }
855
+ return groups;
856
+ }
857
+ const result = [];
858
+ for (const item of items) {
859
+ if (limit > -1 && result.length >= limit) break;
860
+ if (matches(item)) result.push(item);
861
+ }
862
+ return result;
863
+ }
864
+ get flatFilteredItems() {
865
+ const items = this.filteredItems;
866
+ return this.isGrouped && !this.args.filteredItems ? items.flatMap(group => group.items) : items;
867
+ }
868
+ get isEmpty() {
869
+ if (!this.hasItems) return false;
870
+ return this.flatFilteredItems.length === 0;
871
+ }
872
+ // ----- Items and chips -----------------------------------------------------------------------
873
+ /** The items rendered now, in document order. */
874
+ get items() {
875
+ return [...this.#items].filter(item => item.element).sort(byDocumentOrder);
876
+ }
877
+ get trackedItems() {
878
+ void this.itemsVersion;
879
+ return this.items;
880
+ }
881
+ get chipItems() {
882
+ return [...this.#chips].filter(chip => chip.element).sort(byDocumentOrder);
883
+ }
884
+ registerItem(item) {
885
+ this.#items.add(item);
886
+ this.#bump();
887
+ return () => {
888
+ this.#items.delete(item);
889
+ this.#bump();
890
+ };
891
+ }
892
+ registerChip(chip) {
893
+ this.#chips.add(chip);
894
+ return () => void this.#chips.delete(chip);
895
+ }
896
+ #bump() {
897
+ if (this.#bumping) return;
898
+ this.#bumping = true;
899
+ queueMicrotask(() => {
900
+ this.#bumping = false;
901
+ if (this.isDestroying || this.isDestroyed) return;
902
+ this.itemsVersion += 1;
903
+ this.#settleHighlight();
904
+ });
905
+ }
906
+ /** The highlighted item, if any. */
907
+ get activeItem() {
908
+ const index = this.activeIndex;
909
+ return index === null ? undefined : this.trackedItems[index];
910
+ }
911
+ /** The index of the (last) chosen item among the rendered items, or `null`. */
912
+ get selectedIndex() {
913
+ const items = this.items;
914
+ const target = this.isMultiple ? this.values.at(-1) : this.value;
915
+ if (target == null) return null;
916
+ const index = items.findIndex(item => equal(item.value, target, this.isEqual));
917
+ return index === -1 ? null : index;
918
+ }
919
+ highlight = index => {
920
+ if (this.activeIndex !== index) this.activeIndex = index;
921
+ if (index !== null) this.items[index]?.element.scrollIntoView?.({
922
+ block: 'nearest'
923
+ });
924
+ };
925
+ /** After the items change: keep the highlight in range, or make the first one. */
926
+ #settleHighlight() {
927
+ const count = this.items.length;
928
+ // With @items, the filtered data says how many there are, rendered or not yet.
929
+ const available = this.hasItems ? this.flatFilteredItems.length : count;
930
+ const index = this.activeIndex;
931
+ if (index !== null && index >= available) this.activeIndex = null;
932
+ if (this.isOpen && this.activeIndex === null && count > 0) {
933
+ if (this.autoHighlight === 'always') this.activeIndex = 0;else if (this.#openKey !== null) {
934
+ // Opened from the keyboard: the chosen item, or the first (the last for ArrowUp).
935
+ this.activeIndex = this.selectedIndex ?? (this.#openKey === 'ArrowUp' ? count - 1 : 0);
936
+ } else if (!this.listMode.isQuerying && this.selectedIndex !== null) {
937
+ this.activeIndex = this.selectedIndex;
938
+ }
939
+ this.#openKey = null;
940
+ }
941
+ if (this.isMultiple && this.isEmpty && this.autoHighlight) this.activeIndex = null;
942
+ }
943
+ // ----- Changes -------------------------------------------------------------------------------
944
+ setInputValue(next, reason, event) {
945
+ this.#hadInputClear = reason === 'input-clear';
946
+ if (reason === 'input-change' && isTyped(event)) {
947
+ const hasQuery = next.trim() !== '';
948
+ if (hasQuery) this.listMode.typed();
949
+ if (hasQuery && this.autoHighlight) this.activeIndex = 0;
950
+ }
951
+ this.inputState.set(next);
952
+ }
953
+ setOpen = (next, reason = 'none') => {
954
+ if (this.isOpen === next) return;
955
+ if (next && reason !== 'list-navigation') this.#openKey = null;
956
+ this.openState.set(next);
957
+ // A controlled `@open` may refuse: what follows goes with the committed value only.
958
+ if (this.isOpen !== next) return;
959
+ if (next) {
960
+ const reopened = this.listMode.frozenQuery !== null;
961
+ this.listMode.opened();
962
+ if (reopened && this.isMultiple && this.inputInsidePopup) {
963
+ this.listMode.browse();
964
+ if (this.inputValue !== '') this.setInputValue('', 'input-clear');
965
+ }
966
+ queueMicrotask(() => this.#settleHighlight());
967
+ return;
968
+ }
969
+ const wasQuerying = this.listMode.isQuerying;
970
+ this.listMode.closed(this.query);
971
+ if (!wasQuerying) return;
972
+ if (this.isSingle) {
973
+ if (this.query === '') this.listMode.browse();
974
+ } else if (this.inputInsidePopup) {
975
+ this.activeIndex = null;
976
+ } else {
977
+ this.setInputValue('', 'input-clear');
978
+ }
979
+ };
980
+ setSelectedValue(next, reason) {
981
+ this.valueState.set(next);
982
+ if (this.isSingle && !this.inputInsidePopup) {
983
+ this.setInputValue(labelOf(next, this.args.itemToStringLabel), reason);
984
+ }
985
+ if (this.isSingle && next != null && reason !== 'input-change' && this.listMode.isQuerying) {
986
+ this.listMode.freeze(this.query);
987
+ }
988
+ }
989
+ setValue = value => this.setSelectedValue(value, 'none');
990
+ /** An item was chosen: Base UI's `handleSelection`. */
991
+ handleSelection(event, item) {
992
+ const link = event.target?.closest?.('a')?.getAttribute('href');
993
+ if (link) {
994
+ if (link.startsWith('#')) this.setOpen(false, 'item-press');
995
+ return;
996
+ }
997
+ if (this.isMultiple) {
998
+ const current = this.values;
999
+ const chosen = current.some(value => equal(item, value, this.isEqual));
1000
+ const next = chosen ? current.filter(value => !equal(item, value, this.isEqual)) : [...current, item];
1001
+ this.setSelectedValue(next, 'item-press');
1002
+ const wasFiltering = (this.inputRef.current?.value.trim() ?? '') !== '';
1003
+ if (!wasFiltering) return;
1004
+ if (this.inputInsidePopup) this.setInputValue('', 'input-clear');else this.setOpen(false, 'item-press');
1005
+ } else {
1006
+ this.setSelectedValue(item, 'item-press');
1007
+ this.setOpen(false, 'item-press');
1008
+ }
1009
+ }
1010
+ removeChip(value, reason) {
1011
+ const active = this.activeItem;
1012
+ if (active && equal(active.value, value, this.isEqual)) this.highlight(null);
1013
+ this.setSelectedValue(this.values.filter(item => !equal(item, value, this.isEqual)), reason);
1014
+ }
1015
+ /** The popup has gone (after any exit animation): Base UI's `handleUnmount`. */
1016
+ unmounted() {
1017
+ if (this.isDestroying || this.isDestroyed) return;
1018
+ this.listMode.unmounted();
1019
+ this.activeIndex = null;
1020
+ const input = this.inputRef.current;
1021
+ if (this.isMultiple && input && input.value !== '' && !this.#hadInputClear) {
1022
+ this.setInputValue('', 'input-clear');
1023
+ }
1024
+ if (this.isSingle) {
1025
+ if (this.inputInsidePopup) {
1026
+ if (this.inputValue !== '') this.setInputValue('', 'input-clear');
1027
+ } else {
1028
+ const label = labelOf(this.value, this.args.itemToStringLabel);
1029
+ if (this.inputValue !== label) this.setInputValue(label, label === '' ? 'input-clear' : 'none');
1030
+ }
1031
+ }
1032
+ }
1033
+ // ----- Keyboard --------------------------------------------------------------------------------
1034
+ /** Base UI's list navigation, virtual: the arrows move the highlight, focus stays in the input. */
1035
+ navigate(event) {
1036
+ const forward = event.key === 'ArrowDown';
1037
+ if (!this.isOpen) {
1038
+ this.#openKey = event.key;
1039
+ this.setOpen(true, 'list-navigation');
1040
+ return;
1041
+ }
1042
+ const count = this.items.length;
1043
+ if (!count) return;
1044
+ const allowEscape = this.loopFocus && !this.autoHighlight;
1045
+ let index = this.activeIndex ?? -1;
1046
+ const max = count - 1;
1047
+ if (forward) {
1048
+ if (this.loopFocus && index >= max) index = allowEscape && index !== count ? -1 : 0;else index = Math.min(max, index + 1);
1049
+ } else if (this.loopFocus && index <= 0) {
1050
+ index = allowEscape && index !== -1 ? -1 : max;
1051
+ } else {
1052
+ index = Math.max(0, index - 1);
1053
+ }
1054
+ this.highlight(index === -1 ? null : index);
1055
+ }
1056
+ inputKeyDown = event => {
1057
+ if (this.isDisabled || this.isReadOnly) return;
1058
+ if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) return;
1059
+ const input = event.currentTarget;
1060
+ if (event.key === 'Home' || event.key === 'End') {
1061
+ // They move the caret, not the highlight.
1062
+ event.preventDefault();
1063
+ event.stopPropagation();
1064
+ const end = event.key === 'End';
1065
+ const cursor = end ? input.value.length : 0;
1066
+ input.setSelectionRange(cursor, cursor);
1067
+ return;
1068
+ }
1069
+ if (!this.isOpen && event.key === 'Escape') {
1070
+ // Escape on the closed list clears the input and the value.
1071
+ const wasClear = !this.hasValue;
1072
+ this.setInputValue('', 'escape-key');
1073
+ this.setSelectedValue(this.isMultiple ? [] : null, 'escape-key');
1074
+ if (!wasClear) event.stopPropagation();
1075
+ return;
1076
+ }
1077
+ if (this.chipsRef.current) {
1078
+ if (this.#chipKeyDown(event, input)) return;
1079
+ }
1080
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
1081
+ event.preventDefault();
1082
+ event.stopPropagation();
1083
+ this.navigate(event);
1084
+ return;
1085
+ }
1086
+ if (event.key === 'Enter' && this.isOpen) {
1087
+ const item = this.activeItem;
1088
+ // With nothing highlighted, Enter closes it and submits the form.
1089
+ if (!item) return this.setOpen(false, 'none');
1090
+ event.preventDefault();
1091
+ event.stopPropagation();
1092
+ item.element.click();
1093
+ }
1094
+ };
1095
+ /** The input's keys among chips: Backspace removes the last, the start arrow moves into them. */
1096
+ #chipKeyDown(event, input) {
1097
+ const chips = this.chipItems;
1098
+ const values = this.values;
1099
+ if (event.key === 'Backspace' && input.value === '' && values.length > 0) {
1100
+ event.preventDefault();
1101
+ this.highlight(null);
1102
+ const last = chips.at(-1)?.args.value ?? values.at(-1);
1103
+ this.setSelectedValue(values.filter(value => value !== last), 'none');
1104
+ return true;
1105
+ }
1106
+ const rtl = getDirection(input) === 'rtl';
1107
+ const previous = rtl ? 'ArrowRight' : 'ArrowLeft';
1108
+ if (event.key === previous && (input.selectionStart ?? 0) === 0 && chips.length > 0) {
1109
+ event.preventDefault();
1110
+ this.highlightedChip = chips.length - 1;
1111
+ chips.at(-1)?.element.focus();
1112
+ return true;
1113
+ }
1114
+ return false;
1115
+ }
1116
+ onInput = event => {
1117
+ const input = event.currentTarget;
1118
+ const value = input.value;
1119
+ this.setInputValue(value, 'input-change', event);
1120
+ if (value === '' && !this.inputInsidePopup) {
1121
+ if (this.isSingle) this.setSelectedValue(null, 'input-clear');
1122
+ if (!(this.args.openOnInputClick ?? true)) this.setOpen(false, 'input-clear');
1123
+ }
1124
+ const trimmed = value.trim();
1125
+ const typed = isTyped(event);
1126
+ if (!this.isReadOnly && !this.isDisabled && trimmed && typed) {
1127
+ this.setOpen(true, 'input-change');
1128
+ if (!this.autoHighlight) this.activeIndex = null;
1129
+ }
1130
+ if (this.isOpen && this.activeIndex !== null && !this.autoHighlight) this.activeIndex = null;
1131
+ };
1132
+ /** A press on the input (or the chips) opens the list, as Base UI's `useClick` on mousedown. */
1133
+ inputPress = event => {
1134
+ if (this.isReadOnly || this.isDisabled || event.button !== 0) return;
1135
+ if (this.args.openOnInputClick ?? true) this.setOpen(true, 'input-press');
1136
+ };
1137
+ // ----- The parts' modifiers ------------------------------------------------------------------
1138
+ input = part(() => {
1139
+ const open = this.isOpen;
1140
+ const active = open ? this.activeItem : undefined;
1141
+ return {
1142
+ attributes: {
1143
+ role: 'combobox',
1144
+ type: 'text',
1145
+ autocomplete: 'off',
1146
+ spellcheck: 'false',
1147
+ autocorrect: 'off',
1148
+ autocapitalize: 'none',
1149
+ 'aria-expanded': String(open),
1150
+ 'aria-haspopup': 'listbox',
1151
+ 'aria-controls': open ? this.listId : undefined,
1152
+ 'aria-autocomplete': 'list',
1153
+ 'aria-activedescendant': active?.id,
1154
+ 'aria-readonly': this.isReadOnly ? 'true' : undefined,
1155
+ 'aria-required': this.args.required ? 'true' : undefined,
1156
+ disabled: this.isDisabled,
1157
+ readonly: this.isReadOnly,
1158
+ 'data-popup-open': open,
1159
+ 'data-pressed': open,
1160
+ 'data-list-empty': this.isEmpty,
1161
+ 'data-disabled': this.isDisabled,
1162
+ 'data-readonly': this.isReadOnly,
1163
+ 'data-test-jn-part': 'input'
1164
+ },
1165
+ on: {
1166
+ input: this.onInput,
1167
+ keydown: this.inputKeyDown,
1168
+ mousedown: this.inputPress
1169
+ },
1170
+ element: element => {
1171
+ this.inputRef.set(element);
1172
+ // Inside the popup, or outside it: what the trigger and the popup do depends on it.
1173
+ const outside = !element.closest('[data-jn-combobox-popup]');
1174
+ if (outside) queueMicrotask(() => this.hasOutsideInput = true);
1175
+ // An input inside the popup starts empty, for a search, unless its text is given.
1176
+ const given = this.args.inputValue !== undefined || this.args.defaultInputValue !== undefined;
1177
+ if (!outside && !given && this.inputValue !== '') {
1178
+ queueMicrotask(() => this.setInputValue('', 'none'));
1179
+ }
1180
+ element.value = outside || given ? this.inputValue : '';
1181
+ return () => {
1182
+ this.inputRef.release(element);
1183
+ if (outside) queueMicrotask(() => this.hasOutsideInput = false);
1184
+ };
1185
+ }
1186
+ };
1187
+ });
1188
+ trigger = part(() => {
1189
+ const open = this.isOpen;
1190
+ const insidePopup = this.inputInsidePopup;
1191
+ return {
1192
+ attributes: {
1193
+ tabindex: insidePopup ? '0' : '-1',
1194
+ role: insidePopup ? 'combobox' : undefined,
1195
+ 'aria-expanded': String(open),
1196
+ 'aria-haspopup': insidePopup ? 'dialog' : 'listbox',
1197
+ 'aria-controls': open ? insidePopup ? this.popupId : this.listId : undefined,
1198
+ 'aria-required': insidePopup && this.args.required ? 'true' : undefined,
1199
+ disabled: this.isDisabled,
1200
+ 'data-popup-open': open,
1201
+ 'data-pressed': open,
1202
+ 'data-disabled': this.isDisabled,
1203
+ 'data-placeholder': !this.hasValue,
1204
+ 'data-test-jn-part': 'trigger'
1205
+ },
1206
+ on: {
1207
+ mousedown: event => {
1208
+ if (this.isDisabled || this.isReadOnly || event.button !== 0) return;
1209
+ if (!insidePopup) {
1210
+ // Focus goes to the input, not the trigger.
1211
+ this.inputRef.current?.focus();
1212
+ event.preventDefault();
1213
+ }
1214
+ this.setOpen(!this.isOpen, 'trigger-press');
1215
+ },
1216
+ keydown: event => {
1217
+ if (this.isDisabled || this.isReadOnly) return;
1218
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
1219
+ event.preventDefault();
1220
+ event.stopPropagation();
1221
+ this.#openKey = event.key;
1222
+ this.setOpen(true, 'list-navigation');
1223
+ this.inputRef.current?.focus();
1224
+ return;
1225
+ }
1226
+ if (insidePopup && (event.key === 'Enter' || event.key === ' ')) {
1227
+ event.preventDefault();
1228
+ this.setOpen(!this.isOpen, 'trigger-press');
1229
+ return;
1230
+ }
1231
+ // Typing on the closed trigger of a popup combobox chooses, as a select's does.
1232
+ if (!this.isOpen && this.isSingle && event.key.length === 1 && !event.ctrlKey) {
1233
+ this.#typeAhead(event.key);
1234
+ }
1235
+ }
1236
+ },
1237
+ element: element => {
1238
+ this.triggerRef.set(element);
1239
+ return buttonType(element);
1240
+ }
1241
+ };
1242
+ });
1243
+ #typeAhead(key) {
1244
+ const items = this.args.items ? this.flatFilteredItems : [];
1245
+ const toLabel = this.args.itemToStringLabel;
1246
+ const current = items.find(item => equal(item, this.value, this.isEqual));
1247
+ const next = getNextMatch(items, this.#triggerTypeahead.type(key), current, item => labelOf(item, toLabel));
1248
+ if (next !== undefined) this.setSelectedValue(next, 'none');
1249
+ }
1250
+ clear = part(() => ({
1251
+ attributes: {
1252
+ tabindex: '-1',
1253
+ disabled: this.isDisabled,
1254
+ 'data-test-jn-part': 'clear'
1255
+ },
1256
+ on: {
1257
+ // Focus stays in the input.
1258
+ mousedown: event => event.preventDefault(),
1259
+ click: () => {
1260
+ if (this.isDisabled || this.isReadOnly) return;
1261
+ this.setInputValue('', 'clear-press');
1262
+ this.setSelectedValue(this.isMultiple ? [] : null, 'clear-press');
1263
+ this.activeIndex = null;
1264
+ this.inputRef.current?.focus();
1265
+ }
1266
+ },
1267
+ element: element => {
1268
+ this.clearRef.set(element);
1269
+ const restoreType = buttonType(element);
1270
+ return () => {
1271
+ restoreType();
1272
+ this.clearRef.release(element);
1273
+ };
1274
+ }
1275
+ }));
1276
+ chipsPart = part(() => ({
1277
+ attributes: {
1278
+ // A toolbar keeps NVDA in focus mode while the arrows move between chips.
1279
+ role: this.hasValue ? 'toolbar' : undefined,
1280
+ 'data-test-jn-part': 'chips'
1281
+ },
1282
+ on: {
1283
+ mousedown: event => {
1284
+ const target = event.target;
1285
+ if (target !== event.currentTarget && isInteractive(target)) return;
1286
+ event.preventDefault();
1287
+ if (this.isDisabled || this.isReadOnly) return;
1288
+ this.inputRef.current?.focus();
1289
+ this.inputPress(event);
1290
+ }
1291
+ },
1292
+ element: element => {
1293
+ this.chipsRef.set(element);
1294
+ return () => this.chipsRef.release(element);
1295
+ }
1296
+ }));
1297
+ get chipsElement() {
1298
+ return this.chipsRef.value;
1299
+ }
1300
+ /** What the popup is placed against: the trigger when the input is inside it, else the input. */
1301
+ get anchorElement() {
1302
+ return this.inputInsidePopup ? this.triggerRef.value : this.inputRef.value;
1303
+ }
1304
+ /** What counts as inside the popup, for dismissal: the input and the buttons and chips around it. */
1305
+ get insideElements() {
1306
+ return [this.inputRef.value, this.triggerRef.value, this.clearRef.value, this.chipsRef.value, this.inputRef.value?.closest('[data-slot="input-group"]') ?? null];
1307
+ }
1308
+ popup = part(() => ({
1309
+ attributes: {
1310
+ id: this.inputInsidePopup ? this.popupId : undefined,
1311
+ role: this.inputInsidePopup ? 'dialog' : 'presentation',
1312
+ tabindex: '-1',
1313
+ 'data-open': this.isOpen,
1314
+ 'data-closed': !this.isOpen,
1315
+ 'data-empty': this.isEmpty,
1316
+ 'data-test-jn-part': 'content',
1317
+ 'data-test-jn-owner': this.id
1318
+ }
1319
+ }));
1320
+ list = part(() => ({
1321
+ attributes: {
1322
+ id: this.listId,
1323
+ role: 'listbox',
1324
+ tabindex: '-1',
1325
+ 'aria-multiselectable': this.isMultiple ? 'true' : undefined,
1326
+ 'data-empty': this.isEmpty,
1327
+ 'data-test-jn-part': 'list'
1328
+ },
1329
+ on: {
1330
+ keydown: event => {
1331
+ if (event.key !== 'Enter' || this.isDisabled || this.isReadOnly) return;
1332
+ const item = this.activeItem;
1333
+ if (!item) return;
1334
+ event.preventDefault();
1335
+ event.stopPropagation();
1336
+ item.element.click();
1337
+ }
1338
+ },
1339
+ element: element => {
1340
+ this.listRef.set(element);
1341
+ // Named as the input is: by its labels, or else its own name or placeholder.
1342
+ const input = this.inputRef.current;
1343
+ const named = element.hasAttribute('aria-label') || element.hasAttribute('aria-labelledby');
1344
+ if (!named && input) {
1345
+ const labels = [...(input.labels ?? [])].map(label => {
1346
+ if (!label.id) label.id = idFor(label, 'label');
1347
+ return label.id;
1348
+ });
1349
+ const name = input.getAttribute('aria-label') ?? input.getAttribute('placeholder') ?? undefined;
1350
+ if (labels.length) element.setAttribute('aria-labelledby', labels.join(' '));else if (name) element.setAttribute('aria-label', name);
1351
+ }
1352
+ return () => this.listRef.release(element);
1353
+ }
1354
+ }));
1355
+ groupLabel = part(() => ({
1356
+ attributes: {
1357
+ 'data-test-jn-part': 'group-label'
1358
+ },
1359
+ element: element => {
1360
+ if (!element.id) element.id = idFor(element, 'label');
1361
+ const group = element.closest('[role="group"]');
1362
+ const labelled = group && !group.hasAttribute('aria-labelledby');
1363
+ if (labelled) group.setAttribute('aria-labelledby', element.id);
1364
+ return () => {
1365
+ if (labelled && group.getAttribute('aria-labelledby') === element.id) {
1366
+ group.removeAttribute('aria-labelledby');
1367
+ }
1368
+ };
1369
+ }
1370
+ }));
1371
+ separator = part(() => ({
1372
+ attributes: {
1373
+ 'data-test-jn-part': 'separator'
1374
+ }
1375
+ }));
1376
+ // ----- Form ------------------------------------------------------------------------------------
1377
+ get formValues() {
1378
+ const toValue = this.args.itemToStringValue;
1379
+ if (this.isMultiple) return this.values.map(value => formValueOf(value, toValue));
1380
+ return [formValueOf(this.value, toValue)];
1381
+ }
1382
+ openWith = open => this.setOpen(open, 'none');
1383
+ static {
1384
+ setComponentTemplate(precompileTemplate("<div id={{this.id}} data-test-jn=\"combobox\" data-test-jn-name={{@name}} ...attributes {{displayContents}}>\n {{yield (hash Input=(component ComboboxInput part=this.input) Trigger=(component ComboboxTrigger part=this.trigger) Clear=(component ComboboxClear combobox=this) Value=(component ComboboxValue combobox=this) Content=(component ComboboxContent combobox=this) List=(component ComboboxList combobox=this) Item=(component ComboboxItem combobox=this) Group=(component ComboboxGroup combobox=this) GroupLabel=(component ComboboxGroupLabel part=this.groupLabel) Collection=ComboboxCollection Empty=(component ComboboxEmpty combobox=this) Separator=(component ComboboxSeparator part=this.separator) chips=this.chipsPart Chip=(component ComboboxChip combobox=this) input=this.input trigger=this.trigger clear=this.clear chipsElement=this.chipsElement value=this.value inputValue=this.inputValue isOpen=this.isOpen setOpen=this.openWith setValue=this.setValue)}}\n {{#if @formName}}\n {{#each this.formValues as |formValue|}}\n <input type=\"hidden\" name={{@formName}} value={{formValue}} form={{@form}} disabled={{@disabled}} data-test-jn-part=\"form-value\" />\n {{/each}}\n {{/if}}\n <span hidden {{this.syncInput this.inputValue}}></span>\n</div>", {
1385
+ strictMode: true,
1386
+ scope: () => ({
1387
+ displayContents,
1388
+ hash,
1389
+ ComboboxInput,
1390
+ ComboboxTrigger,
1391
+ ComboboxClear,
1392
+ ComboboxValue,
1393
+ ComboboxContent,
1394
+ ComboboxList,
1395
+ ComboboxItem,
1396
+ ComboboxGroup,
1397
+ ComboboxGroupLabel,
1398
+ ComboboxCollection,
1399
+ ComboboxEmpty,
1400
+ ComboboxSeparator,
1401
+ ComboboxChip
1402
+ })
1403
+ }), this);
1404
+ }
1405
+ /** Keeps the registered input's text the combobox's, whichever element it is. */
1406
+ syncInput = modifier((_element, [value]) => {
1407
+ const input = this.inputRef.current;
1408
+ if (input && input.value !== value) input.value = value;
1409
+ });
1410
+ }
1411
+
1412
+ export { Combobox, ComboboxChip, ComboboxContent, ComboboxItem, comboboxFilter, Combobox as default, formValueOf, isGroupedItems, labelOf };
1413
+ //# sourceMappingURL=combobox.js.map