@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,1745 @@
1
+ import Component from '@glimmer/component';
2
+ import { hash } from '@ember/helper';
3
+ import { As } from './as.js';
4
+ import { nativeValue } from './native-value.js';
5
+ import { tracked } from '@glimmer/tracking';
6
+ import { isDestroying, isDestroyed } from '@ember/destroyable';
7
+ import { renderSettled } from '@ember/renderer';
8
+ import { buildWaiter } from '@ember/test-waiters';
9
+ import { macroCondition, isDevelopingApp } from '@embroider/macros';
10
+ import Modifier from 'ember-modifier';
11
+ import { ControllableState } from './controllable-state.js';
12
+ import { getDirection } from './direction.js';
13
+ import { idFor } from './id.js';
14
+ import { part, joinTokens } from './part.js';
15
+ import { translate, t } from './i18n.js';
16
+ import { messages } from './messages.js';
17
+ import { g, i } from 'decorator-transforms/runtime';
18
+ import { precompileTemplate } from '@ember/template-compilation';
19
+ import { setComponentTemplate } from '@ember/component';
20
+ import templateOnly from '@ember/component/template-only';
21
+
22
+ // Ported from shadcn-ui/ui `packages/react/src/questionnaire/utils.ts` and `collection.ts`
23
+ // (@shadcn/react's Questionnaire, MIT).
24
+
25
+ /** An item's answer state: nothing chosen, an answer chosen, or skipped on purpose. */
26
+
27
+ /** Which keys pick a fixed answer: `letters` (A–Z) or `numbers` (1–9). */
28
+
29
+ /** A fixed answer, as the root's `@items` describes it. */
30
+
31
+ /**
32
+ * An item, as the root's `@items` describes it: its name, whether it must be answered or is
33
+ * left out, and its fixed answers in order (for the shortcuts). Pass the collection to the
34
+ * root so progress, the actions and the shortcuts are right from the first render.
35
+ */
36
+
37
+ /** Whether a value has any text, as upstream's `hasInputValue`. */
38
+ function hasInputValue(value) {
39
+ if (Array.isArray(value)) return value.some(item => String(item).trim().length > 0);
40
+ return value !== undefined && value !== null && String(value).trim().length > 0;
41
+ }
42
+
43
+ /** The keys a shortcut mode gives out, in order. */
44
+ function shortcutKeys(shortcuts) {
45
+ if (shortcuts === 'letters') {
46
+ return Array.from({
47
+ length: 26
48
+ }, (_, index) => String.fromCharCode(65 + index));
49
+ }
50
+ if (shortcuts === 'numbers') return Array.from({
51
+ length: 9
52
+ }, (_, index) => String(index + 1));
53
+ return [];
54
+ }
55
+
56
+ /** The shortcut a key press names, or `null`: a letter in any case, or a digit. */
57
+ function shortcutFromKey(key, shortcuts) {
58
+ const normalized = shortcuts === 'letters' ? key.toUpperCase() : key;
59
+ return shortcutKeys(shortcuts).includes(normalized) ? normalized : null;
60
+ }
61
+
62
+ /** An answer's `aria-keyshortcuts`: its shortcut, and `Enter` once it is filled. */
63
+ function answerKeyShortcuts(shortcut, filled) {
64
+ return [shortcut, filled ? 'Enter' : null].filter(Boolean).join(' ') || undefined;
65
+ }
66
+
67
+ /** Whether a key press is typing into a field, which arrows and letters must be left to. */
68
+ function isTextEntryTarget(element) {
69
+ if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true;
70
+ if (element instanceof HTMLInputElement) {
71
+ return !['button', 'checkbox', 'radio', 'reset', 'submit'].includes(element.type);
72
+ }
73
+ return element instanceof HTMLElement && element.isContentEditable;
74
+ }
75
+
76
+ /** Whether an element is a radio, whose arrow keys the browser already handles. */
77
+ function isRadioTarget(element) {
78
+ return element instanceof HTMLInputElement && element.type === 'radio';
79
+ }
80
+
81
+ /** Sorts things with elements into document order; those without one go last. */
82
+ function byDocumentOrder(a, b) {
83
+ if (a.element === b.element) return 0;
84
+ if (!a.element) return 1;
85
+ if (!b.element) return -1;
86
+ const position = a.element.compareDocumentPosition(b.element);
87
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
88
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
89
+ return 0;
90
+ }
91
+
92
+ /** The item a questionnaire starts on: `defaultItem` when it names an enabled item, else the first. */
93
+ function initialItemName(items, defaultItem) {
94
+ if (!items) return defaultItem ?? null;
95
+ const named = defaultItem ? items.find(item => item.name === defaultItem) : undefined;
96
+ if (named && !named.disabled) return named.name;
97
+ return items.find(item => !item.disabled)?.name ?? null;
98
+ }
99
+
100
+ /** Each fixed answer's shortcut, from the item's definition: enabled choices, in order. */
101
+ function shortcutsByChoiceValue(item, shortcuts) {
102
+ const map = new Map();
103
+ if (!item || !shortcuts) return map;
104
+ const keys = shortcutKeys(shortcuts);
105
+ let index = 0;
106
+ for (const choice of item.choices ?? []) {
107
+ if (choice.disabled) continue;
108
+ const key = keys[index];
109
+ if (!key) break;
110
+ map.set(choice.value, key);
111
+ index += 1;
112
+ }
113
+ return map;
114
+ }
115
+
116
+ /**
117
+ * A rendered item, as the development warnings compare it with `@items`: its name, its own
118
+ * `@disabled` and `@required`, and its fixed answers in document order, each with its own
119
+ * `@disabled` (upstream's `ItemRegistration`).
120
+ */
121
+
122
+ /**
123
+ * What is wrong with `@items` and `@defaultItem` on their own: upstream's
124
+ * `getCollectionDefinitionWarnings`, its messages in Joinery's terms.
125
+ */
126
+ function collectionDefinitionWarnings(items, defaultItem) {
127
+ const warnings = [];
128
+ const names = new Set();
129
+ for (const item of items) {
130
+ if (names.has(item.name)) warnings.push(`Item name "${item.name}" is defined more than once.`);
131
+ names.add(item.name);
132
+ const values = new Set();
133
+ for (const choice of item.choices ?? []) {
134
+ if (values.has(choice.value)) {
135
+ warnings.push(`Choice value "${choice.value}" is defined more than once in item "${item.name}".`);
136
+ }
137
+ values.add(choice.value);
138
+ }
139
+ }
140
+ if (defaultItem) {
141
+ const named = items.find(item => item.name === defaultItem);
142
+ if (!named || named.disabled) {
143
+ warnings.push(`@defaultItem "${defaultItem}" does not identify an enabled item. The first enabled item will be used instead.`);
144
+ }
145
+ }
146
+ return warnings;
147
+ }
148
+
149
+ /**
150
+ * Where the rendered items and choices part from `@items`: upstream's
151
+ * `getCollectionRegistrationWarnings`, its messages in Joinery's terms.
152
+ */
153
+ function collectionRegistrationWarnings(items, registrations, shortcuts) {
154
+ const warnings = [];
155
+ const rendered = new Map(registrations.map(registration => [registration.name, registration]));
156
+ for (const definition of items) {
157
+ const registration = rendered.get(definition.name);
158
+ if (!registration) {
159
+ if (!definition.disabled) {
160
+ warnings.push(`Item "${definition.name}" is defined in @items but has no rendered Item.`);
161
+ }
162
+ continue;
163
+ }
164
+ if (registration.disabled !== Boolean(definition.disabled)) {
165
+ warnings.push(`Item "${definition.name}" has different disabled values in @items and its Item.`);
166
+ }
167
+ if (registration.required !== Boolean(definition.required)) {
168
+ warnings.push(`Item "${definition.name}" has different required values in @items and its Item.`);
169
+ }
170
+ const defined = definition.choices ?? [];
171
+ const definedByValue = new Map(defined.map(choice => [choice.value, choice]));
172
+ const renderedByValue = new Map(registration.choices.map(choice => [choice.value, choice]));
173
+ for (const choice of defined) {
174
+ const renderedChoice = renderedByValue.get(choice.value);
175
+ if (!renderedChoice) {
176
+ warnings.push(`Choice "${choice.value}" is defined for item "${definition.name}" but has no rendered Choice.`);
177
+ continue;
178
+ }
179
+ if (renderedChoice.disabled !== Boolean(choice.disabled)) {
180
+ warnings.push(`Choice "${choice.value}" in item "${definition.name}" has different disabled values in @items and its Choice.`);
181
+ }
182
+ }
183
+ if (!shortcuts) continue;
184
+ for (const choice of registration.choices) {
185
+ if (!definedByValue.has(choice.value)) {
186
+ warnings.push(`Rendered choice "${choice.value}" in item "${definition.name}" is missing from @items and will not receive a shortcut.`);
187
+ }
188
+ }
189
+ const definedOrder = defined.filter(choice => !choice.disabled).map(choice => choice.value);
190
+ const renderedOrder = registration.choices.filter(choice => !choice.disabled).map(choice => choice.value);
191
+ const sameChoices = definedOrder.length > 0 && definedOrder.length === renderedOrder.length && definedOrder.every(value => renderedOrder.includes(value));
192
+ if (sameChoices && definedOrder.some((value, index) => value !== renderedOrder[index])) {
193
+ warnings.push(`Choice order for item "${definition.name}" differs between @items and the rendered Choices.`);
194
+ }
195
+ }
196
+ const defined = new Set(items.map(item => item.name));
197
+ for (const registration of registrations) {
198
+ if (!registration.disabled && !defined.has(registration.name)) {
199
+ warnings.push(`Rendered item "${registration.name}" is missing from @items and is excluded from the questionnaire.`);
200
+ }
201
+ }
202
+ return warnings;
203
+ }
204
+
205
+ // A port of shadcn-ui/ui `packages/react/src/questionnaire` (@shadcn/react's headless
206
+ // Questionnaire, MIT): `use-questionnaire-root.ts`, `use-questionnaire-item.ts`,
207
+ // `use-questionnaire-choice.ts`, `use-questionnaire-input.ts` and `components.tsx`, as state
208
+ // classes whose parts `part()` puts on any element, so the headless components and the styled
209
+ // ones in `@ember-joinery/ember` render the same thing.
210
+ const waiter = buildWaiter('@ember-joinery/primitives:questionnaire');
211
+
212
+ /** A controlled input whose selection hasn't been put in step with its value yet. */
213
+ const NOT_SYNCED = Symbol('not synced');
214
+
215
+ /**
216
+ * Runs `callback` once the current render is over, holding the test waiter till then, unless
217
+ * `owner` has gone. Registration happens while rendering, and the change it makes is read by
218
+ * the same render, so it shows in a render of its own, right after.
219
+ */
220
+ function afterRender(owner, callback) {
221
+ const token = waiter.beginAsync();
222
+ queueMicrotask(() => {
223
+ try {
224
+ if (!isDestroying(owner) && !isDestroyed(owner)) callback();
225
+ } finally {
226
+ waiter.endAsync(token);
227
+ }
228
+ });
229
+ }
230
+
231
+ /** The state a navigation button renders: upstream's `QuestionnaireNavigationState`. */
232
+
233
+ /** Where a `QuestionnaireState` reads its settings. Each is a function, so it reads them live. */
234
+
235
+ /**
236
+ * A questionnaire's state and behaviour, as `@shadcn/react`'s Questionnaire has them: the
237
+ * ordered items, the active one, progress, validation, navigation and its keyboard. The root
238
+ * is a native `<form>`, and answers are read with `FormData`.
239
+ *
240
+ * questionnaire = new QuestionnaireState(this, {
241
+ * items: () => this.args.items,
242
+ * onSubmit: () => this.args.onSubmit,
243
+ * })
244
+ * <form {{this.questionnaire.root}} {{this.questionnaire.focusEffect this.questionnaire.activeName}}>
245
+ */
246
+ class QuestionnaireState {
247
+ #owner;
248
+ #options;
249
+ #items = new Set();
250
+ /** Bumped after items come or go, so what depends on them renders again. */
251
+ static {
252
+ g(this.prototype, "revision", [tracked], function () {
253
+ return 0;
254
+ });
255
+ }
256
+ #revision = (i(this, "revision"), void 0);
257
+ static {
258
+ g(this.prototype, "settledOn", [tracked], function () {
259
+ return null;
260
+ });
261
+ }
262
+ #settledOn = (i(this, "settledOn"), void 0);
263
+ /**
264
+ * The first item, taken without a word while the state, uncontrolled, has named none of its
265
+ * own yet (no `@items` and no `@defaultItem`, before the items render), as upstream does.
266
+ */
267
+ #bumping = false;
268
+ #pendingFocus = null;
269
+ #lastActive = undefined;
270
+ /** The development warnings last logged, so each is logged once while it holds. */
271
+ #warned = new Set();
272
+ /** The form, once rendered. */
273
+ element = null;
274
+
275
+ /** The active item's name, controlled (`@item`) or the questionnaire's own. */
276
+ active;
277
+
278
+ /** Put it on the `<form>`: its listeners and state attributes. */
279
+ root;
280
+ /** Put it on the progress element. */
281
+ progress;
282
+ /** The navigation buttons' parts. */
283
+ previous;
284
+ skip;
285
+ next;
286
+ submit;
287
+ /**
288
+ * Put it on the form with the active item's name (`{{q.focusEffect q.activeName}}`): after
289
+ * the questionnaire moves, it focuses the item it moved to (or, when it moved to report an
290
+ * invalid one, that item's first answer), as upstream's layout effect does. In development,
291
+ * it also warns where `@items` and the rendered items part, as upstream's effect does.
292
+ */
293
+ focusEffect;
294
+ constructor(owner, options = {}) {
295
+ this.#owner = owner;
296
+ this.#options = options;
297
+ this.active = new ControllableState({
298
+ name: 'item',
299
+ value: () => options.item?.(),
300
+ defaultValue: () => initialItemName(options.items?.(), options.defaultItem?.()),
301
+ onChange: () => options.onItemChange?.(),
302
+ fallback: null
303
+ });
304
+ this.root = part(() => this.rootSpec());
305
+ this.progress = part(() => this.progressSpec());
306
+ this.previous = part(named => this.navigationSpec('previous', named));
307
+ this.skip = part(named => this.navigationSpec('skip', named));
308
+ this.next = part(named => this.navigationSpec('next', named));
309
+ this.submit = part(named => this.navigationSpec('submit', named));
310
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- the modifier's class reads it
311
+ const questionnaire = this;
312
+ this.focusEffect = class FocusEffect extends Modifier {
313
+ modify(_element, [name]) {
314
+ questionnaire.#warnAboutCollection();
315
+ questionnaire.#afterActiveRendered(name);
316
+ }
317
+ };
318
+ }
319
+
320
+ // ----- Settings ----------------------------------------------------------------------------
321
+
322
+ /** The collection given as `@items`, if any. */
323
+ get definitions() {
324
+ return this.#options.items?.();
325
+ }
326
+
327
+ /** The definition of a named item, from `@items`. */
328
+ definition(name) {
329
+ return this.definitions?.find(item => item.name === name);
330
+ }
331
+
332
+ /** The shortcut mode, or `null` for none. */
333
+ get shortcuts() {
334
+ return this.#options.shortcuts?.() ?? null;
335
+ }
336
+
337
+ /** Whether the browser's own validation checks filled answers (`@noValidate={{false}}`). */
338
+ get nativeValidation() {
339
+ return this.#options.noValidate?.() === false;
340
+ }
341
+
342
+ // ----- Items -------------------------------------------------------------------------------
343
+
344
+ /** @internal An item comes; the returned function is for when it goes. */
345
+ register(item) {
346
+ this.#items.add(item);
347
+ this.bump();
348
+ return () => {
349
+ this.#items.delete(item);
350
+ this.bump();
351
+ };
352
+ }
353
+
354
+ /** @internal Re-renders what depends on the items, after the render that changed them. */
355
+ bump() {
356
+ if (this.#bumping) return;
357
+ this.#bumping = true;
358
+ afterRender(this.#owner, () => {
359
+ this.#bumping = false;
360
+ this.revision += 1;
361
+ });
362
+ }
363
+
364
+ /** The rendered items that aren't disabled, in document order. */
365
+ get runtimeItems() {
366
+ void this.revision;
367
+ return [...this.#items].filter(item => !item.disabled).sort(byDocumentOrder);
368
+ }
369
+
370
+ /** The rendered item with a name, unless it is disabled. */
371
+ itemNamed(name) {
372
+ if (name === null) return null;
373
+ return this.runtimeItems.find(item => item.name === name) ?? null;
374
+ }
375
+
376
+ /** The names of the items it steps through, in order: `@items`' enabled ones, or the rendered. */
377
+ get names() {
378
+ const definitions = this.definitions;
379
+ if (definitions) return definitions.filter(item => !item.disabled).map(item => item.name);
380
+ return this.runtimeItems.map(item => item.name);
381
+ }
382
+
383
+ /** The rendered items it steps through, in the collection's order. */
384
+ get orderedItems() {
385
+ const definitions = this.definitions;
386
+ if (!definitions) return this.runtimeItems;
387
+ return this.names.flatMap(name => {
388
+ const item = this.itemNamed(name);
389
+ return item ? [item] : [];
390
+ });
391
+ }
392
+
393
+ /**
394
+ * The active item's name. Where the state names no item it steps through (nothing yet, an
395
+ * unknown one, or one that is now disabled), the first stands in for the render, and then
396
+ * the questionnaire moves to it (see `#moveToFirst`).
397
+ */
398
+ get activeName() {
399
+ const name = this.#held;
400
+ const names = this.names;
401
+ if (!names.length) return name;
402
+ return name !== null && names.includes(name) ? name : names[0];
403
+ }
404
+
405
+ /** The name the state holds: `@item`, the questionnaire's own, or the first it settled on. */
406
+ get #held() {
407
+ const name = this.active.value;
408
+ return name === null && !this.active.isControlled ? this.settledOn : name;
409
+ }
410
+
411
+ /**
412
+ * Where the state names an item it doesn't step through, moves to the first, as upstream's
413
+ * layout effect does: without a word while it has named none of its own, else as `setItem`
414
+ * would, so `@onItemChange` hears it (a host that controls `@item` gets the first) and the
415
+ * item takes focus once it shows.
416
+ */
417
+ #moveToFirst() {
418
+ const names = this.names;
419
+ const first = names[0];
420
+ const held = this.#held;
421
+ if (first === undefined || held !== null && names.includes(held)) return;
422
+ if (held === null && !this.active.isControlled) {
423
+ this.settledOn = first;
424
+ return;
425
+ }
426
+ this.#pendingFocus = {
427
+ name: first,
428
+ target: 'item'
429
+ };
430
+ this.active.set(first);
431
+ }
432
+
433
+ /** The active item's position from 0, or -1 with none. */
434
+ get index() {
435
+ const name = this.activeName;
436
+ return name === null ? -1 : this.names.indexOf(name);
437
+ }
438
+
439
+ /** How many items it steps through. */
440
+ get total() {
441
+ return this.names.length;
442
+ }
443
+
444
+ /** The active item's position from 1, or 0 with none. */
445
+ get current() {
446
+ const index = this.index;
447
+ return index < 0 ? 0 : index + 1;
448
+ }
449
+
450
+ /** Whether the active item is the first. */
451
+ get first() {
452
+ return this.total > 0 && this.index === 0;
453
+ }
454
+
455
+ /** Whether the active item is the last. */
456
+ get last() {
457
+ return this.total > 0 && this.index === this.total - 1;
458
+ }
459
+
460
+ /** The active item, once it has rendered. */
461
+ get activeItem() {
462
+ return this.index < 0 ? null : this.itemNamed(this.activeName);
463
+ }
464
+
465
+ /** Whether the active item must be answered, or `null` with none. */
466
+ get activeRequired() {
467
+ if (this.index < 0) return null;
468
+ const definition = this.definition(this.activeName);
469
+ return definition ? Boolean(definition.required) : this.activeItem?.required ?? false;
470
+ }
471
+
472
+ /** The active item's status, or `null` with none. */
473
+ get activeStatus() {
474
+ if (this.index < 0) return null;
475
+ return this.activeItem?.status ?? 'unanswered';
476
+ }
477
+
478
+ // ----- Navigation --------------------------------------------------------------------------
479
+
480
+ /** Moves to a named item, focusing it (or its first answer) once it shows. */
481
+ setItem = (name, target = 'item') => {
482
+ if (name === this.activeName) return;
483
+ this.#pendingFocus = {
484
+ name,
485
+ target
486
+ };
487
+ this.active.set(name);
488
+ };
489
+
490
+ /** Moves to the item before the active one. */
491
+ goPrevious = () => {
492
+ const index = this.index;
493
+ if (index <= 0) return;
494
+ this.setItem(this.names[index - 1]);
495
+ };
496
+
497
+ /** Moves to the next item, once the active one is valid. */
498
+ goNext = () => {
499
+ const item = this.activeItem;
500
+ const index = this.index;
501
+ if (!item || index >= this.total - 1) return;
502
+ if (!item.validate()) {
503
+ item.focusInvalid();
504
+ return;
505
+ }
506
+ this.setItem(this.names[index + 1]);
507
+ };
508
+
509
+ /** Confirms the active item: moves on, or on the last, submits. */
510
+ confirm = () => {
511
+ const item = this.activeItem;
512
+ if (!item) return;
513
+ if (!item.validate()) {
514
+ item.focusInvalid();
515
+ return;
516
+ }
517
+ if (this.last) {
518
+ this.element?.requestSubmit();
519
+ return;
520
+ }
521
+ this.setItem(this.names[this.index + 1]);
522
+ };
523
+
524
+ /** Skips the active item, unless it is required, and moves on (or submits). */
525
+ skipCurrent = () => {
526
+ const item = this.activeItem;
527
+ if (!item || item.required) return;
528
+ item.skip();
529
+ if (!this.last) {
530
+ this.setItem(this.names[this.index + 1]);
531
+ return;
532
+ }
533
+ // Once the skip has rendered: a skipped item's answers lose their `name` then.
534
+ const token = waiter.beginAsync();
535
+ void renderSettled().then(() => {
536
+ try {
537
+ if (!isDestroying(this.#owner) && !isDestroyed(this.#owner)) this.element?.requestSubmit();
538
+ } finally {
539
+ waiter.endAsync(token);
540
+ }
541
+ });
542
+ };
543
+
544
+ /**
545
+ * After a render with a new active item: focus it, as upstream's layout effect. Where the
546
+ * first only stands in for the item the state holds, move to it first (`#moveToFirst`).
547
+ */
548
+ #afterActiveRendered(name) {
549
+ // Read here, so the effect runs again once the state holds the first, which it already shows.
550
+ const held = this.#held;
551
+ const previous = this.#lastActive;
552
+ this.#lastActive = name;
553
+ if (name !== null && held !== name) {
554
+ afterRender(this.#owner, () => this.#moveToFirst());
555
+ return;
556
+ }
557
+ if (previous === undefined) return;
558
+ const pending = this.#pendingFocus;
559
+ if (pending && pending.name === name) {
560
+ this.#pendingFocus = null;
561
+ afterRender(this.#owner, () => {
562
+ const item = this.itemNamed(name);
563
+ if (pending.target === 'invalid') item?.focusInvalid();else item?.focus();
564
+ });
565
+ return;
566
+ }
567
+ if (this.active.isControlled && previous !== name) {
568
+ this.#pendingFocus = null;
569
+ afterRender(this.#owner, () => this.itemNamed(name)?.focus());
570
+ }
571
+ }
572
+
573
+ // ----- Development warnings ----------------------------------------------------------------
574
+
575
+ /** The rendered items, disabled ones too, in document order, as upstream registers them. */
576
+ get registrations() {
577
+ void this.revision;
578
+ return [...this.#items].sort(byDocumentOrder).map(item => ({
579
+ name: item.name,
580
+ disabled: item.disabled,
581
+ required: item.required,
582
+ choices: item.controls.filter(answer => answer instanceof QuestionnaireChoiceState).map(choice => ({
583
+ value: choice.value,
584
+ disabled: choice.ownDisabled
585
+ }))
586
+ }));
587
+ }
588
+
589
+ /**
590
+ * Where `@items` (and `@defaultItem`) and the rendered items part: duplicate names, an unknown
591
+ * `@defaultItem`, an item or a choice on one side only, and shortcuts that won't match.
592
+ * None without `@items`.
593
+ */
594
+ get collectionWarnings() {
595
+ const definitions = this.definitions;
596
+ if (!definitions) return [];
597
+ return [...collectionDefinitionWarnings(definitions, this.#options.defaultItem?.()), ...collectionRegistrationWarnings(definitions, this.registrations, this.shortcuts)];
598
+ }
599
+
600
+ /**
601
+ * In development, logs each new collection warning with `console.warn` (`[Questionnaire] …`),
602
+ * as upstream does outside production: Ember's `warn()` is silent wherever an app loads
603
+ * Ember's production build of `@ember/debug`, so it isn't used. It reads them now, so the
604
+ * effect that calls it runs again when they could change, and logs them once the render (and
605
+ * the items' registration) is over, as upstream's microtask does. Production builds leave it
606
+ * out (`isDevelopingApp()`).
607
+ */
608
+ #warnAboutCollection() {
609
+ if (macroCondition(isDevelopingApp())) {
610
+ void this.collectionWarnings;
611
+ afterRender(this.#owner, () => {
612
+ const warnings = new Set(this.element ? this.collectionWarnings : []);
613
+ for (const warning of warnings) {
614
+ if (this.#warned.has(warning)) continue;
615
+ console.warn(`[Questionnaire] ${warning}`);
616
+ }
617
+ this.#warned = warnings;
618
+ });
619
+ }
620
+ }
621
+
622
+ // ----- The form ----------------------------------------------------------------------------
623
+
624
+ #handleSubmit = event => {
625
+ const invalid = this.orderedItems.find(item => !item.validate());
626
+ if (invalid) {
627
+ event.preventDefault();
628
+ if (invalid.name === this.activeName) {
629
+ invalid.focusInvalid();
630
+ this.#pendingFocus = null;
631
+ } else {
632
+ this.setItem(invalid.name, 'invalid');
633
+ }
634
+ return;
635
+ }
636
+ this.#options.onSubmit?.()?.(event);
637
+ };
638
+ #handleReset = event => {
639
+ this.#options.onReset?.()?.(event);
640
+ if (event.defaultPrevented) return;
641
+ for (const item of this.#items) item.reset();
642
+ const definitions = this.definitions;
643
+ const defaultItem = this.#options.defaultItem?.();
644
+ const name = definitions ? initialItemName(definitions, defaultItem) : this.runtimeItems.find(item => item.name === defaultItem)?.name ?? this.runtimeItems[0]?.name;
645
+ if (name) this.setItem(name);
646
+ };
647
+ #handleKeyDown = event => {
648
+ const item = this.activeItem;
649
+ const target = event.target;
650
+ if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return;
651
+ if (!item || !(target instanceof Element)) return;
652
+ if (event.key === 'Enter' && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey) {
653
+ event.preventDefault();
654
+ if (!event.repeat) this.confirm();
655
+ return;
656
+ }
657
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
658
+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
659
+ if (item.moveAnswerFocus(target, event.key === 'ArrowDown' ? 'next' : 'previous')) {
660
+ event.preventDefault();
661
+ return;
662
+ }
663
+ }
664
+ if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight') && !isTextEntryTarget(target) && !isRadioTarget(target)) {
665
+ event.preventDefault();
666
+ if (event.repeat) return;
667
+ // The arrow that points back goes back: left, or right to left, right.
668
+ const back = getDirection(target) === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
669
+ if (event.key === back) this.goPrevious();else if (item.status !== 'unanswered') this.goNext();
670
+ return;
671
+ }
672
+ if (event.key === 'Enter') {
673
+ const answer = item.answerByElement(target);
674
+ if (!answer) return;
675
+ event.preventDefault();
676
+ if (!event.repeat && answer.isAnswerFilled) this.confirm();
677
+ return;
678
+ }
679
+ const shortcuts = this.shortcuts;
680
+ if (!shortcuts || isTextEntryTarget(target)) return;
681
+ const shortcut = shortcutFromKey(event.key, shortcuts);
682
+ const answer = shortcut ? item.answerByShortcut(shortcut) : null;
683
+ if (!answer) return;
684
+ event.preventDefault();
685
+ if (event.repeat) return;
686
+ answer.element?.focus();
687
+ if (answer instanceof QuestionnaireChoiceState) answer.element?.click();
688
+ };
689
+
690
+ /** The `aria-keyshortcuts` names of the keys that go back and forward, in this direction. */
691
+ arrowKeys(element) {
692
+ return getDirection(element) === 'rtl' ? {
693
+ back: 'ArrowRight',
694
+ forward: 'ArrowLeft'
695
+ } : {
696
+ back: 'ArrowLeft',
697
+ forward: 'ArrowRight'
698
+ };
699
+ }
700
+
701
+ /** What the form renders: its state, as upstream's `data-*`, and its listeners. */
702
+ rootSpec() {
703
+ return {
704
+ attributes: {
705
+ novalidate: !this.nativeValidation,
706
+ 'data-shortcuts': this.shortcuts,
707
+ 'data-current': this.current,
708
+ 'data-total': this.total,
709
+ 'data-first': this.first,
710
+ 'data-last': this.last
711
+ },
712
+ on: {
713
+ keydown: this.#handleKeyDown,
714
+ submit: this.#handleSubmit,
715
+ reset: this.#handleReset
716
+ },
717
+ element: element => {
718
+ this.element = element;
719
+ return () => {
720
+ if (this.element === element) this.element = null;
721
+ };
722
+ }
723
+ };
724
+ }
725
+
726
+ /** The words a screen reader hears for the progress: `Question 2 of 3`. */
727
+ progressText(format) {
728
+ if (!this.total) return undefined;
729
+ const {
730
+ current,
731
+ total
732
+ } = this;
733
+ return format ? format(current, total) : translate(this.#owner, messages.questionnaireProgress, {
734
+ current,
735
+ total
736
+ });
737
+ }
738
+
739
+ /** What the progress element renders: a named, live progressbar. */
740
+ progressSpec() {
741
+ const total = this.total;
742
+ return {
743
+ attributes: {
744
+ role: 'progressbar',
745
+ 'aria-live': 'polite',
746
+ 'aria-valuemin': total ? 1 : undefined,
747
+ 'aria-valuemax': total || undefined,
748
+ 'aria-valuenow': total ? this.current : undefined,
749
+ 'data-current': this.current,
750
+ 'data-total': total,
751
+ 'data-first': this.first,
752
+ 'data-last': this.last,
753
+ 'data-test-jn-part': 'progress'
754
+ }
755
+ };
756
+ }
757
+
758
+ /** Whether a navigation button shows now. */
759
+ isVisible(kind) {
760
+ switch (kind) {
761
+ case 'previous':
762
+ return this.total > 1 && !this.first;
763
+ case 'skip':
764
+ return this.activeRequired === false;
765
+ case 'next':
766
+ return this.total > 1 && !this.last;
767
+ case 'submit':
768
+ return this.total > 0 && this.last;
769
+ }
770
+ }
771
+
772
+ /** What a navigation button renders: shown or hidden (and inert), and its click. */
773
+ navigationSpec(kind, {
774
+ disabled = false
775
+ }) {
776
+ const visible = this.isVisible(kind);
777
+ const confirms = kind === 'next' || kind === 'submit';
778
+ const shortcut = visible && !disabled && confirms ? 'Enter' : null;
779
+ const click = kind === 'previous' ? this.goPrevious : kind === 'skip' ? this.skipCurrent : this.goNext;
780
+ return {
781
+ attributes: {
782
+ type: kind === 'submit' ? 'submit' : 'button',
783
+ disabled,
784
+ hidden: !visible,
785
+ inert: !visible,
786
+ 'aria-hidden': visible ? undefined : 'true',
787
+ 'aria-keyshortcuts': shortcut,
788
+ tabindex: visible ? undefined : '-1',
789
+ 'data-disabled': disabled,
790
+ 'data-shortcut': shortcut,
791
+ 'data-status': this.activeStatus,
792
+ 'data-visible': visible,
793
+ 'data-hidden': !visible,
794
+ 'data-test-jn-part': kind
795
+ },
796
+ on: kind === 'submit' ? {} : {
797
+ click: () => click()
798
+ }
799
+ };
800
+ }
801
+ }
802
+
803
+ /** Where a `QuestionnaireItemState` reads its settings. */
804
+
805
+ /**
806
+ * One item of a questionnaire: a `<fieldset>` of answers (fixed choices and a freeform input),
807
+ * its status, and its validation, as `@shadcn/react`'s `Questionnaire.Item`.
808
+ */
809
+ class QuestionnaireItemState {
810
+ questionnaire;
811
+ #owner;
812
+ #options;
813
+ #answers = new Set();
814
+ #descriptions = new Set();
815
+ #errors = new Set();
816
+ /** Bumped after answers, descriptions or errors come or go. */
817
+ static {
818
+ g(this.prototype, "revision", [tracked], function () {
819
+ return 0;
820
+ });
821
+ }
822
+ #revision = (i(this, "revision"), void 0);
823
+ #bumping = false;
824
+ /** The selected answers' ids once someone has chosen; `null` while they are the defaults. */
825
+ static {
826
+ g(this.prototype, "selection", [tracked], function () {
827
+ return null;
828
+ });
829
+ }
830
+ #selection = (i(this, "selection"), void 0);
831
+ static {
832
+ g(this.prototype, "skipped", [tracked], function () {
833
+ return false;
834
+ });
835
+ }
836
+ #skipped = (i(this, "skipped"), void 0);
837
+ static {
838
+ g(this.prototype, "validationAttempted", [tracked], function () {
839
+ return false;
840
+ });
841
+ }
842
+ #validationAttempted = (i(this, "validationAttempted"), void 0);
843
+ #reported = 'unanswered';
844
+ /** The fieldset, once rendered. */
845
+ element = null;
846
+
847
+ /** Put it on the `<fieldset>`. */
848
+ item;
849
+ /** Put it on the title (a `<legend>`, or your own heading). */
850
+ title;
851
+ /** Put it on a description: the item's `aria-describedby` names it. */
852
+ description;
853
+ /** Put it on the element that holds the choices. */
854
+ choices;
855
+ /** Put it on the error message, shown while the item is invalid. */
856
+ error;
857
+ constructor(owner, questionnaire, options) {
858
+ this.#owner = owner;
859
+ this.questionnaire = questionnaire;
860
+ this.#options = options;
861
+ this.item = part(() => this.itemSpec());
862
+ this.title = part(() => this.titleSpec());
863
+ this.description = part(() => this.descriptionSpec());
864
+ this.choices = part(() => ({
865
+ attributes: {
866
+ 'data-shortcuts': this.questionnaire.shortcuts,
867
+ 'data-test-jn-part': 'choices'
868
+ }
869
+ }));
870
+ this.error = part(() => this.errorSpec());
871
+ }
872
+
873
+ /**
874
+ * Registers an element for `aria-describedby`. Its id is read once the render is over, so an
875
+ * id another part gives it (a dialog's description has the dialog's) is the one named; one
876
+ * with none then gets an id of its own.
877
+ */
878
+ #describe(element, elements) {
879
+ elements.add(element);
880
+ this.bump();
881
+ return () => {
882
+ elements.delete(element);
883
+ this.bump();
884
+ };
885
+ }
886
+
887
+ /** The ids of the registered elements, giving one with none an id of its own. */
888
+ #ids(elements) {
889
+ return [...elements].map(element => {
890
+ if (!element.id) element.id = idFor(element, 'questionnaire');
891
+ return element.id;
892
+ });
893
+ }
894
+ get name() {
895
+ return this.#options.name();
896
+ }
897
+ get required() {
898
+ return Boolean(this.#options.required?.());
899
+ }
900
+ get multiple() {
901
+ return Boolean(this.#options.multiple?.());
902
+ }
903
+ get disabled() {
904
+ return Boolean(this.#options.disabled?.());
905
+ }
906
+
907
+ /** Whether it is the item the questionnaire shows. */
908
+ get isActive() {
909
+ return !this.disabled && this.questionnaire.activeName === this.name;
910
+ }
911
+
912
+ /** @internal Re-renders what depends on the answers, after the render that changed them. */
913
+ bump() {
914
+ if (this.#bumping) return;
915
+ this.#bumping = true;
916
+ afterRender(this.#owner, () => {
917
+ this.#bumping = false;
918
+ this.revision += 1;
919
+ this.questionnaire.bump();
920
+ this.reportStatus();
921
+ });
922
+ }
923
+
924
+ /** @internal An answer comes; the returned function is for when it goes. */
925
+ register(answer) {
926
+ this.#answers.add(answer);
927
+ this.bump();
928
+ return () => {
929
+ this.#answers.delete(answer);
930
+ this.bump();
931
+ };
932
+ }
933
+
934
+ /** Every answer control, in document order. */
935
+ get controls() {
936
+ void this.revision;
937
+ return [...this.#answers].sort(byDocumentOrder);
938
+ }
939
+
940
+ /** The answers that aren't disabled, in document order. */
941
+ get answers() {
942
+ return this.controls.filter(answer => !answer.isDisabled);
943
+ }
944
+
945
+ /** Whether it has a freeform answer, which makes its fixed answers' `required` unneeded. */
946
+ get hasInputAnswer() {
947
+ return this.answers.some(answer => answer instanceof QuestionnaireInputState);
948
+ }
949
+
950
+ /** The answers selected by default: the first, for a single answer. */
951
+ get #defaults() {
952
+ const ids = this.controls.filter(answer => answer.defaultSelected).map(answer => answer.id);
953
+ return this.multiple ? ids : ids.slice(0, 1);
954
+ }
955
+
956
+ /** Whether an answer is selected: chosen, or for a controlled choice, its `@checked`. */
957
+ isSelected(answer) {
958
+ if (answer instanceof QuestionnaireChoiceState && answer.isControlled) {
959
+ return !this.skipped && answer.controlledChecked;
960
+ }
961
+ return (this.selection ?? this.#defaults).includes(answer.id);
962
+ }
963
+
964
+ /**
965
+ * @internal Puts a controlled answer's selection in step with its value, as upstream's
966
+ * `syncControlledAnswerSelection`: selected, it is no longer skipped; deselected, it leaves
967
+ * the rest as they are.
968
+ */
969
+ syncSelection(answer, selected) {
970
+ if (selected) {
971
+ this.select(answer, true);
972
+ return;
973
+ }
974
+ const current = this.selection ?? this.#defaults;
975
+ if (!current.includes(answer.id)) return;
976
+ this.selection = current.filter(id => id !== answer.id);
977
+ this.reportStatus();
978
+ }
979
+
980
+ /** Selects or deselects an answer, as someone choosing it does. It is no longer skipped. */
981
+ select(answer, selected) {
982
+ this.skipped = false;
983
+ const current = this.selection ?? this.#defaults;
984
+ if (!selected) this.selection = current.filter(id => id !== answer.id);else if (!this.multiple) this.selection = [answer.id];else this.selection = current.includes(answer.id) ? current : [...current, answer.id];
985
+ this.reportStatus();
986
+ }
987
+
988
+ /** Whether an answer is selected. */
989
+ get answered() {
990
+ return this.answers.some(answer => this.isSelected(answer));
991
+ }
992
+
993
+ /** `skipped`, `answered` or `unanswered`. */
994
+ get status() {
995
+ return this.skipped ? 'skipped' : this.answered ? 'answered' : 'unanswered';
996
+ }
997
+
998
+ /** Whether the caller's validation found it invalid (`@invalid`). */
999
+ get externallyInvalid() {
1000
+ return Boolean(this.#options.invalid?.());
1001
+ }
1002
+
1003
+ /** Whether it may be left: disabled, skipped on purpose, or answered (and not found invalid). */
1004
+ get valid() {
1005
+ const intentionallySkipped = this.status === 'skipped' && !this.required;
1006
+ return this.disabled || intentionallySkipped || !this.externallyInvalid && this.status === 'answered';
1007
+ }
1008
+
1009
+ /** Whether it shows as invalid: found invalid, or not valid once someone tried to leave it. */
1010
+ get invalid() {
1011
+ const intentionallySkipped = this.status === 'skipped' && !this.required;
1012
+ if (this.disabled || intentionallySkipped) return false;
1013
+ return this.externallyInvalid || this.validationAttempted && !this.valid;
1014
+ }
1015
+
1016
+ /** Calls `@onStatusChange`, once a render is over, when the status has changed. */
1017
+ reportStatus() {
1018
+ afterRender(this.#owner, () => {
1019
+ const status = this.status;
1020
+ if (status === this.#reported) return;
1021
+ this.#reported = status;
1022
+ this.#options.onStatusChange?.()?.(status);
1023
+ });
1024
+ }
1025
+
1026
+ /** Checks it may be left, showing its error when not. */
1027
+ validate() {
1028
+ this.validationAttempted = true;
1029
+ if (!this.valid) return false;
1030
+ if (!this.questionnaire.nativeValidation) return true;
1031
+ const invalid = this.answers.find(answer => answer.isAnswerFilled && answer.element?.willValidate && !answer.element.validity.valid);
1032
+ if (!invalid) return true;
1033
+ invalid.element.focus();
1034
+ invalid.element.reportValidity();
1035
+ return false;
1036
+ }
1037
+
1038
+ /** Focuses the item itself (its fieldset), as moving to it does. */
1039
+ focus() {
1040
+ this.element?.focus();
1041
+ }
1042
+
1043
+ /** Focuses its chosen freeform answer, else its first control, else itself. */
1044
+ focusInvalid() {
1045
+ const element = this.element;
1046
+ const filled = element?.querySelector('input[data-filled][name]:not(:disabled)');
1047
+ const first = element?.querySelector('input:not([type=hidden]):not(:disabled), textarea:not(:disabled)');
1048
+ (filled ?? first ?? element)?.focus();
1049
+ }
1050
+
1051
+ /** Puts its answers back to their defaults, as a form reset does. */
1052
+ reset() {
1053
+ this.validationAttempted = false;
1054
+ this.skipped = false;
1055
+ this.selection = null;
1056
+ for (const answer of this.#answers) answer.reset();
1057
+ this.reportStatus();
1058
+ }
1059
+
1060
+ /** Skips it on purpose, clearing its answers, unless it is required. */
1061
+ skip() {
1062
+ if (this.required) return;
1063
+ this.selection = [];
1064
+ this.skipped = true;
1065
+ this.reportStatus();
1066
+ }
1067
+
1068
+ /** The shortcut of each fixed answer by value, from `@items`, or `null` without it. */
1069
+ get shortcutsByValue() {
1070
+ const questionnaire = this.questionnaire;
1071
+ if (!questionnaire.definitions) return null;
1072
+ return shortcutsByChoiceValue(questionnaire.definition(this.name), questionnaire.shortcuts);
1073
+ }
1074
+
1075
+ /** A fixed answer's shortcut, or `null`. */
1076
+ shortcutFor(answer) {
1077
+ const byValue = this.shortcutsByValue;
1078
+ if (byValue) return byValue.get(answer.value) ?? null;
1079
+ const keys = shortcutKeys(this.questionnaire.shortcuts);
1080
+ const choices = this.answers.filter(other => other instanceof QuestionnaireChoiceState);
1081
+ const index = choices.indexOf(answer);
1082
+ return index < 0 ? null : keys[index] ?? null;
1083
+ }
1084
+
1085
+ /** The enabled answer whose control is `element`. */
1086
+ answerByElement(element) {
1087
+ return this.answers.find(answer => answer.element === element) ?? null;
1088
+ }
1089
+
1090
+ /** The enabled fixed answer a shortcut picks. */
1091
+ answerByShortcut(shortcut) {
1092
+ return this.answers.find(answer => answer instanceof QuestionnaireChoiceState && answer.shortcut === shortcut) ?? null;
1093
+ }
1094
+
1095
+ /**
1096
+ * Moves focus from `element` to the next or previous answer, wrapping, as the up and down
1097
+ * arrows do. A radio picks itself as it is focused. Between two radios the browser moves, so
1098
+ * this leaves them be; in a freeform answer with text, the arrows stay the caret's.
1099
+ */
1100
+ moveAnswerFocus(element, direction) {
1101
+ const answers = this.answers;
1102
+ const index = answers.findIndex(answer => answer.element === element);
1103
+ const current = index < 0 ? null : answers[index];
1104
+ const emptyInput = current instanceof QuestionnaireInputState && ['email', 'password', 'search', 'tel', 'text', 'url'].includes(current.element?.type ?? '') && !hasInputValue(current.element?.value);
1105
+ if (!answers.length || isTextEntryTarget(element) && !emptyInput || index < 0 && element !== this.element) {
1106
+ return false;
1107
+ }
1108
+ const next = index < 0 ? answers.find(answer => answer.isAnswerFilled) ?? (direction === 'next' ? answers[0] : answers[answers.length - 1]) : answers[(index + (direction === 'next' ? 1 : -1) + answers.length) % answers.length];
1109
+ if (!next?.element || next.element === element) return false;
1110
+ if (index >= 0 && isRadioTarget(element) && isRadioTarget(next.element)) return false;
1111
+ next.element.focus();
1112
+ if (next instanceof QuestionnaireChoiceState && isRadioTarget(next.element)) next.element.click();
1113
+ return true;
1114
+ }
1115
+
1116
+ /** The ids its `aria-describedby` names: its descriptions, and its errors while invalid. */
1117
+ get describedBy() {
1118
+ void this.revision;
1119
+ const ids = [...this.#ids(this.#descriptions), ...(this.invalid ? this.#ids(this.#errors) : [])];
1120
+ return ids.join(' ') || undefined;
1121
+ }
1122
+
1123
+ /** The keys it answers to while active, for `aria-keyshortcuts`. */
1124
+ get keyShortcuts() {
1125
+ if (!this.isActive) return undefined;
1126
+ const questionnaire = this.questionnaire;
1127
+ const {
1128
+ back,
1129
+ forward
1130
+ } = questionnaire.arrowKeys(this.element);
1131
+ return ['Meta+Enter Control+Enter', this.answers.length ? 'ArrowUp ArrowDown' : undefined, questionnaire.first ? undefined : back, !questionnaire.last && this.status !== 'unanswered' ? forward : undefined].filter(Boolean).join(' ') || undefined;
1132
+ }
1133
+
1134
+ /**
1135
+ * What the fieldset renders: hidden and inert unless active, and its state. A caller's own
1136
+ * `aria-describedby` and `aria-keyshortcuts` are kept, as upstream merges them: the item's
1137
+ * descriptions and errors come before the caller's ids, and the caller's keys before its own.
1138
+ */
1139
+ itemSpec() {
1140
+ const active = this.isActive;
1141
+ const invalid = this.invalid;
1142
+ const describedBy = this.describedBy;
1143
+ const keyShortcuts = this.keyShortcuts;
1144
+ return {
1145
+ attributes: {
1146
+ 'aria-describedby': own => joinTokens(describedBy, own),
1147
+ 'aria-invalid': invalid ? 'true' : undefined,
1148
+ 'aria-keyshortcuts': own => joinTokens(own, keyShortcuts),
1149
+ disabled: this.disabled,
1150
+ hidden: !active,
1151
+ inert: !active,
1152
+ tabindex: '-1',
1153
+ 'data-active': active,
1154
+ 'data-disabled': this.disabled,
1155
+ 'data-invalid': invalid,
1156
+ 'data-multiple': this.multiple,
1157
+ 'data-required': this.required,
1158
+ 'data-status': this.status,
1159
+ 'data-test-jn-part': 'item',
1160
+ 'data-test-jn-value': this.name
1161
+ },
1162
+ element: element => {
1163
+ this.element = element;
1164
+ this.questionnaire.bump();
1165
+ const unregister = this.questionnaire.register(this);
1166
+ return () => {
1167
+ unregister();
1168
+ if (this.element === element) this.element = null;
1169
+ };
1170
+ }
1171
+ };
1172
+ }
1173
+
1174
+ /** What the title renders. */
1175
+ titleSpec() {
1176
+ return {
1177
+ attributes: {
1178
+ 'data-test-jn-part': 'title'
1179
+ }
1180
+ };
1181
+ }
1182
+
1183
+ /** What a description renders: an id (its own, or one it is given) the item names. */
1184
+ descriptionSpec() {
1185
+ return {
1186
+ attributes: {
1187
+ 'data-test-jn-part': 'description'
1188
+ },
1189
+ element: element => this.#describe(element, this.#descriptions)
1190
+ };
1191
+ }
1192
+
1193
+ /** The default error message: the required or the optional one. */
1194
+ get defaultError() {
1195
+ return translate(this.#owner, this.required ? messages.questionnaireRequired : messages.questionnaireOptional);
1196
+ }
1197
+
1198
+ /** What the error renders: shown, as an alert, only while the item is invalid. */
1199
+ errorSpec() {
1200
+ const invalid = this.invalid;
1201
+ return {
1202
+ attributes: {
1203
+ hidden: !invalid,
1204
+ role: invalid ? 'alert' : undefined,
1205
+ 'data-invalid': invalid,
1206
+ 'data-test-jn-part': 'error'
1207
+ },
1208
+ element: element => this.#describe(element, this.#errors)
1209
+ };
1210
+ }
1211
+ }
1212
+
1213
+ /** A fixed answer or a freeform one: what an item's answers have in common. */
1214
+ class QuestionnaireAnswerState {
1215
+ item;
1216
+ /** The control's id, which a `<label>` around it doesn't need, but `aria-*` may. */
1217
+ id;
1218
+ /** The control (`<input>`), once rendered. */
1219
+ element = null;
1220
+ constructor(item) {
1221
+ this.item = item;
1222
+ this.id = idFor(this, 'answer');
1223
+ }
1224
+
1225
+ /** Whether it can't be chosen: its own `@disabled`, or its item's. */
1226
+
1227
+ /** Whether it is selected by default. */
1228
+
1229
+ /** Whether it counts as given, for Enter to confirm it. */
1230
+
1231
+ /** Puts its control back as it started, as a form reset does. */
1232
+
1233
+ /** Whether it is selected now. */
1234
+ get isSelected() {
1235
+ return this.item.isSelected(this);
1236
+ }
1237
+
1238
+ /** @internal Registers the control's element with its item. */
1239
+ attach(element) {
1240
+ this.element = element;
1241
+ const unregister = this.item.register(this);
1242
+ return () => {
1243
+ unregister();
1244
+ if (this.element === element) this.element = null;
1245
+ };
1246
+ }
1247
+ }
1248
+
1249
+ /** Where a `QuestionnaireChoiceState` reads its settings. */
1250
+
1251
+ /**
1252
+ * A fixed answer: a radio (or a checkbox, in an item that takes several) inside a `<label>`,
1253
+ * with the rest of the label its text, and its shortcut key, as `Questionnaire.Choice`.
1254
+ */
1255
+ class QuestionnaireChoiceState extends QuestionnaireAnswerState {
1256
+ #options;
1257
+
1258
+ /** Put it on the `<label>` around the choice. */
1259
+ choice;
1260
+ /** Put it on the `<input>`. */
1261
+ input;
1262
+ /** Put it on the element that holds the choice's text. */
1263
+ label;
1264
+ /** Put it on the element that shows its shortcut key. */
1265
+ shortcutKey;
1266
+ /**
1267
+ * Put it on the `<input>` after `input`: it keeps the control's `checked` (and the
1268
+ * `defaultChecked` a form reset returns to) in step with the questionnaire.
1269
+ */
1270
+ sync;
1271
+ constructor(item, options) {
1272
+ super(item);
1273
+ this.#options = options;
1274
+ this.choice = part(() => ({
1275
+ attributes: {
1276
+ ...this.stateAttributes,
1277
+ 'data-test-jn-part': 'choice',
1278
+ 'data-test-jn-value': this.value
1279
+ }
1280
+ }));
1281
+ this.input = part(() => this.inputSpec());
1282
+ this.label = part(() => ({
1283
+ attributes: {
1284
+ 'data-test-jn-part': 'choice-label'
1285
+ }
1286
+ }));
1287
+ this.shortcutKey = part(() => ({
1288
+ attributes: {
1289
+ 'aria-hidden': 'true',
1290
+ hidden: this.shortcut === null,
1291
+ 'data-shortcut': this.shortcut,
1292
+ 'data-test-jn-part': 'shortcut'
1293
+ }
1294
+ }));
1295
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- the modifier's class reads it
1296
+ const choice = this;
1297
+ this.sync = class SyncChecked extends Modifier {
1298
+ modify(element) {
1299
+ element.defaultChecked = choice.defaultCheckedProperty;
1300
+ if (element.checked !== choice.isChecked) element.checked = choice.isChecked;
1301
+ }
1302
+ };
1303
+ }
1304
+ get value() {
1305
+ return this.#options.value();
1306
+ }
1307
+
1308
+ /** Whether the caller controls it (`@checked`). */
1309
+ get isControlled() {
1310
+ return this.#options.checked?.() !== undefined;
1311
+ }
1312
+
1313
+ /** The caller's `@checked`. */
1314
+ get controlledChecked() {
1315
+ return Boolean(this.#options.checked?.());
1316
+ }
1317
+
1318
+ /** Its own `@disabled`. */
1319
+ get ownDisabled() {
1320
+ return Boolean(this.#options.disabled?.());
1321
+ }
1322
+ get isDisabled() {
1323
+ return this.item.disabled || this.ownDisabled;
1324
+ }
1325
+ get defaultSelected() {
1326
+ return !this.isControlled && Boolean(this.#options.defaultChecked?.());
1327
+ }
1328
+
1329
+ /** What a form reset puts back: the default, or for a controlled choice, its `@checked`. */
1330
+ get defaultCheckedProperty() {
1331
+ return this.isControlled ? this.controlledChecked : Boolean(this.#options.defaultChecked?.());
1332
+ }
1333
+
1334
+ /** Whether it is checked. */
1335
+ get isChecked() {
1336
+ return this.isSelected;
1337
+ }
1338
+ get isAnswerFilled() {
1339
+ return this.element?.checked ?? false;
1340
+ }
1341
+
1342
+ /** `checkbox` in an item that takes several answers, else `radio`. */
1343
+ get type() {
1344
+ return this.item.multiple ? 'checkbox' : 'radio';
1345
+ }
1346
+
1347
+ /** Its shortcut key, or `null`. */
1348
+ get shortcut() {
1349
+ return this.item.shortcutFor(this);
1350
+ }
1351
+ reset() {
1352
+ // The form's own reset puts the control back from `defaultChecked`; `sync` keeps it there.
1353
+ }
1354
+
1355
+ /** The state its label and input render, as upstream's `data-*`. */
1356
+ get stateAttributes() {
1357
+ const checked = this.isChecked;
1358
+ return {
1359
+ 'data-checked': checked,
1360
+ 'data-unchecked': !checked,
1361
+ 'data-disabled': this.isDisabled,
1362
+ 'data-invalid': this.item.invalid,
1363
+ 'data-shortcut': this.shortcut,
1364
+ 'data-type': this.type
1365
+ };
1366
+ }
1367
+ #handleChange = event => {
1368
+ const element = event.currentTarget;
1369
+ this.#options.onCheckedChange?.()?.(element.checked, event);
1370
+ if (!event.defaultPrevented) {
1371
+ if (!this.isControlled) this.item.select(this, element.checked);else if (this.item.skipped && this.controlledChecked === element.checked) {
1372
+ this.item.select(this, this.controlledChecked);
1373
+ }
1374
+ }
1375
+ // A controlled choice shows its `@checked` again, whatever the click did.
1376
+ afterRender(this, () => {
1377
+ if (element.checked !== this.isChecked) element.checked = this.isChecked;
1378
+ });
1379
+ };
1380
+
1381
+ /** What the `<input>` renders. */
1382
+ inputSpec() {
1383
+ const item = this.item;
1384
+ const disabled = this.isDisabled;
1385
+ return {
1386
+ attributes: {
1387
+ ...this.stateAttributes,
1388
+ id: this.id,
1389
+ type: this.type,
1390
+ name: item.status === 'skipped' ? undefined : item.name,
1391
+ value: this.value,
1392
+ disabled,
1393
+ required: item.required && !item.multiple && !item.hasInputAnswer,
1394
+ 'aria-invalid': item.invalid ? 'true' : undefined,
1395
+ 'aria-keyshortcuts': answerKeyShortcuts(this.shortcut, !disabled && this.isChecked),
1396
+ 'data-test-jn-part': 'choice-input'
1397
+ },
1398
+ on: {
1399
+ change: this.#handleChange
1400
+ },
1401
+ element: element => this.attach(element)
1402
+ };
1403
+ }
1404
+ }
1405
+
1406
+ /** Where a `QuestionnaireInputState` reads its settings. */
1407
+
1408
+ /**
1409
+ * A freeform answer: a text `<input>` beside the fixed answers, as `Questionnaire.Input`. It
1410
+ * is the item's answer while it has text and was the last answer given; only then does it
1411
+ * belong to the form (so it submits), and choosing a fixed answer of a single-answer item
1412
+ * takes over from it.
1413
+ */
1414
+ class QuestionnaireInputState extends QuestionnaireAnswerState {
1415
+ #options;
1416
+ /** Whether it has text, once someone has typed; `null` while it shows its default. */
1417
+ static {
1418
+ g(this.prototype, "typedFilled", [tracked], function () {
1419
+ return null;
1420
+ });
1421
+ }
1422
+ #typedFilled = (i(this, "typedFilled"), void 0);
1423
+ /** The controlled value its selection was last put in step with (`NOT_SYNCED` before that). */
1424
+ #synced = NOT_SYNCED;
1425
+
1426
+ /** Put it on the `<input>`, with `{{nativeValue}}` for its value. */
1427
+ input;
1428
+ constructor(item, options) {
1429
+ super(item);
1430
+ this.#options = options;
1431
+ this.input = part(() => this.inputSpec());
1432
+ }
1433
+ get isControlled() {
1434
+ return this.#options.value?.() !== undefined;
1435
+ }
1436
+ get isDisabled() {
1437
+ return this.item.disabled || Boolean(this.#options.disabled?.());
1438
+ }
1439
+ get defaultSelected() {
1440
+ return !this.isControlled && hasInputValue(this.#options.defaultValue?.());
1441
+ }
1442
+
1443
+ /** Whether it has text. */
1444
+ get filled() {
1445
+ if (this.isControlled) return hasInputValue(this.#options.value?.());
1446
+ return this.typedFilled ?? hasInputValue(this.#options.defaultValue?.());
1447
+ }
1448
+ get isAnswerFilled() {
1449
+ return Boolean(this.element?.hasAttribute('name')) && hasInputValue(this.element?.value);
1450
+ }
1451
+
1452
+ /**
1453
+ * Hears the text change: selects it while it has text, as typing an answer does. A controlled
1454
+ * one only tells `@onValueChange`: its selection follows the value it is given back.
1455
+ */
1456
+ onValueChange = value => {
1457
+ this.#options.onValueChange?.()?.(value);
1458
+ if (this.isControlled) return;
1459
+ const filled = hasInputValue(value);
1460
+ this.typedFilled = filled;
1461
+ this.item.select(this, filled);
1462
+ };
1463
+
1464
+ /**
1465
+ * A controlled input is the answer while its value has text: from the first render, and
1466
+ * again each time the value changes (typed and passed back, or set by its host), as
1467
+ * upstream's layout effect has it. A choice picked since leaves it unselected until then.
1468
+ */
1469
+ #syncControlled() {
1470
+ const value = this.#options.value?.();
1471
+ if (value === this.#synced) return;
1472
+ this.#synced = value;
1473
+ afterRender(this, () => {
1474
+ if (this.isControlled) this.item.syncSelection(this, this.filled);
1475
+ });
1476
+ }
1477
+ reset() {
1478
+ this.typedFilled = null;
1479
+ if (this.isControlled) {
1480
+ // The item's reset clears its selection; put the controlled value's back, as upstream's
1481
+ // effect does on a reset.
1482
+ this.#synced = NOT_SYNCED;
1483
+ afterRender(this, () => {
1484
+ if (this.isControlled) this.item.syncSelection(this, this.filled);
1485
+ });
1486
+ }
1487
+ // An input that wasn't the answer is outside the form, which can't reset it.
1488
+ const element = this.element;
1489
+ if (element && !this.isControlled) {
1490
+ const value = this.#options.defaultValue?.() ?? '';
1491
+ afterRender(this, () => {
1492
+ if (element.value !== value) element.value = value;
1493
+ });
1494
+ }
1495
+ }
1496
+
1497
+ /** What the `<input>` renders. */
1498
+ inputSpec() {
1499
+ if (this.isControlled) this.#syncControlled();
1500
+ const item = this.item;
1501
+ const disabled = this.isDisabled;
1502
+ const selected = this.isSelected;
1503
+ const filled = this.filled;
1504
+ return {
1505
+ attributes: {
1506
+ id: this.id,
1507
+ name: selected ? item.name : undefined,
1508
+ // Outside the form until it is the answer, so a draft doesn't submit.
1509
+ form: selected ? undefined : '',
1510
+ disabled,
1511
+ 'aria-invalid': item.invalid ? 'true' : undefined,
1512
+ 'aria-keyshortcuts': answerKeyShortcuts(null, !disabled && filled && selected),
1513
+ 'data-filled': filled,
1514
+ 'data-empty': !filled,
1515
+ 'data-disabled': disabled,
1516
+ 'data-invalid': item.invalid,
1517
+ 'data-test-jn-part': 'input'
1518
+ },
1519
+ element: element => this.attach(element)
1520
+ };
1521
+ }
1522
+ }
1523
+
1524
+ /**
1525
+ * The questionnaire's progress, yielded as `q.Progress`: a named, live progressbar that reads
1526
+ * `Question 2 of 3`. Give it a block to draw your own, from where it is:
1527
+ *
1528
+ * <q.Progress as |p|>{{p.current}} / {{p.total}}</q.Progress>
1529
+ */
1530
+ class QuestionnaireProgress extends Component {
1531
+ get text() {
1532
+ return this.args.questionnaire.progressText(this.args.formatValue);
1533
+ }
1534
+ get state() {
1535
+ const q = this.args.questionnaire;
1536
+ return {
1537
+ current: q.current,
1538
+ total: q.total,
1539
+ first: q.first,
1540
+ last: q.last
1541
+ };
1542
+ }
1543
+ static {
1544
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" aria-label={{if @label @label (t messages.questionnaireProgressLabel)}} aria-valuetext={{this.text}} ...attributes {{@questionnaire.progress}}>{{#if (has-block)}}{{yield this.state}}{{else}}{{this.text}}{{/if}}</As>", {
1545
+ strictMode: true,
1546
+ scope: () => ({
1547
+ As,
1548
+ t,
1549
+ messages
1550
+ })
1551
+ }), this);
1552
+ }
1553
+ }
1554
+ /** The item's question, yielded as `i.Title`: its fieldset's `<legend>`. */const QuestionnaireTitle = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"legend\" ...attributes {{@part}}>{{yield}}</As>", {
1555
+ strictMode: true,
1556
+ scope: () => ({
1557
+ As
1558
+ })
1559
+ }), templateOnly());
1560
+ /** More about the question, yielded as `i.Description`: the item's `aria-describedby` names it. */
1561
+ const QuestionnaireDescription = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"p\" ...attributes {{@part}}>{{yield}}</As>", {
1562
+ strictMode: true,
1563
+ scope: () => ({
1564
+ As
1565
+ })
1566
+ }), templateOnly());
1567
+ /** What holds the item's answers, yielded as `i.Choices`. */
1568
+ const QuestionnaireChoices = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{@part}}>{{yield}}</As>", {
1569
+ strictMode: true,
1570
+ scope: () => ({
1571
+ As
1572
+ })
1573
+ }), templateOnly());
1574
+ /**
1575
+ * The item's error, yielded as `i.Error`: hidden until the item is invalid, then an alert the
1576
+ * item's `aria-describedby` names. Its text is the block, else `@message`, else the default.
1577
+ */
1578
+ const QuestionnaireError = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"p\" ...attributes {{@item.error}}>\n {{~#if (has-block)~}}\n {{yield}}\n {{~else~}}\n {{if @message @message @item.defaultError}}\n {{~/if~}}\n</As>", {
1579
+ strictMode: true,
1580
+ scope: () => ({
1581
+ As
1582
+ })
1583
+ }), templateOnly());
1584
+ /** The choice's radio or checkbox, yielded as `c.Input`. */const QuestionnaireChoiceInput = setComponentTemplate(precompileTemplate("<input ...attributes {{@choice.input}} {{@choice.sync}} />", {
1585
+ strictMode: true
1586
+ }), templateOnly());
1587
+ /** The choice's text, yielded as `c.Label`. */const QuestionnaireChoiceLabel = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" ...attributes {{@choice.label}}>{{yield}}</As>", {
1588
+ strictMode: true,
1589
+ scope: () => ({
1590
+ As
1591
+ })
1592
+ }), templateOnly());
1593
+ /** The choice's shortcut key (hidden without one), yielded as `c.Shortcut`. */
1594
+ const QuestionnaireChoiceShortcut = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" ...attributes {{@choice.shortcutKey}}>\n {{~#if (has-block)}}{{yield}}{{else}}{{@choice.shortcut}}{{/if~}}\n</As>", {
1595
+ strictMode: true,
1596
+ scope: () => ({
1597
+ As
1598
+ })
1599
+ }), templateOnly());
1600
+ /** What `i.Choice` yields: its parts, and its state. */
1601
+
1602
+ /**
1603
+ * A fixed answer, yielded as `i.Choice`: a `<label>` around its radio (a checkbox, in an item
1604
+ * with `@multiple`), so the whole row picks it. Put its parts in it:
1605
+ *
1606
+ * <i.Choice @value="tests" as |c|>
1607
+ * <c.Input />
1608
+ * <c.Label>Run the relevant tests</c.Label>
1609
+ * <c.Shortcut />
1610
+ * </i.Choice>
1611
+ */
1612
+ class QuestionnaireChoice extends Component {
1613
+ choice = new QuestionnaireChoiceState(this.args.item, {
1614
+ value: () => this.args.value,
1615
+ checked: () => this.args.checked,
1616
+ defaultChecked: () => this.args.defaultChecked,
1617
+ disabled: () => this.args.disabled,
1618
+ onCheckedChange: () => this.args.onCheckedChange
1619
+ });
1620
+ static {
1621
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"label\" ...attributes {{this.choice.choice}}>\n {{yield (hash Input=(component QuestionnaireChoiceInput choice=this.choice) Label=(component QuestionnaireChoiceLabel choice=this.choice) Shortcut=(component QuestionnaireChoiceShortcut choice=this.choice) isChecked=this.choice.isChecked type=this.choice.type shortcut=this.choice.shortcut choice=this.choice)}}\n</As>", {
1622
+ strictMode: true,
1623
+ scope: () => ({
1624
+ As,
1625
+ hash,
1626
+ QuestionnaireChoiceInput,
1627
+ QuestionnaireChoiceLabel,
1628
+ QuestionnaireChoiceShortcut
1629
+ })
1630
+ }), this);
1631
+ }
1632
+ }
1633
+ /**
1634
+ * A freeform answer, yielded as `i.Input`: a text input beside the fixed answers. Name it, with
1635
+ * `aria-label` or a visible label: a placeholder is not a label. Give it `type` for another
1636
+ * kind of text (`email`, `number`…).
1637
+ */
1638
+ class QuestionnaireInput extends Component {
1639
+ answer = new QuestionnaireInputState(this.args.item, {
1640
+ value: () => this.args.value,
1641
+ defaultValue: () => this.args.defaultValue,
1642
+ disabled: () => this.args.disabled,
1643
+ onValueChange: () => this.args.onValueChange
1644
+ });
1645
+ static {
1646
+ setComponentTemplate(precompileTemplate("{{!-- Through As only for another tag: on 6.12, As is a classic component, with a block. --}}\n{{#if @as}}\n <As @as={{@as}} @tag=\"input\" ...attributes {{this.answer.input}} {{nativeValue value=@value defaultValue=@defaultValue onValueChange=this.answer.onValueChange}} />\n{{else}}\n <input type=\"text\" ...attributes {{this.answer.input}} {{nativeValue value=@value defaultValue=@defaultValue onValueChange=this.answer.onValueChange}} />\n{{/if}}", {
1647
+ strictMode: true,
1648
+ scope: () => ({
1649
+ As,
1650
+ nativeValue
1651
+ })
1652
+ }), this);
1653
+ }
1654
+ }
1655
+ /** What `q.Item` yields: its parts, each as a component and, where useful, a modifier. */
1656
+
1657
+ /**
1658
+ * One question, yielded as `q.Item`: a `<fieldset>`, hidden and inert unless it is the active
1659
+ * item. Its `@name` names its answers in the form, and the item in `@items`.
1660
+ */
1661
+ class QuestionnaireItem extends Component {
1662
+ item = new QuestionnaireItemState(this, this.args.questionnaire, {
1663
+ name: () => this.args.name,
1664
+ required: () => this.args.required,
1665
+ multiple: () => this.args.multiple,
1666
+ disabled: () => this.args.disabled,
1667
+ invalid: () => this.args.invalid,
1668
+ onStatusChange: () => this.args.onStatusChange
1669
+ });
1670
+ static {
1671
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"fieldset\" ...attributes {{this.item.item}}>\n {{yield (hash Title=(component QuestionnaireTitle part=this.item.title) Description=(component QuestionnaireDescription part=this.item.description) Choices=(component QuestionnaireChoices part=this.item.choices) Choice=(component QuestionnaireChoice item=this.item) Input=(component QuestionnaireInput item=this.item) Error=(component QuestionnaireError item=this.item) title=this.item.title description=this.item.description name=@name status=this.item.status isActive=this.item.isActive isInvalid=this.item.invalid item=this.item)}}\n</As>", {
1672
+ strictMode: true,
1673
+ scope: () => ({
1674
+ As,
1675
+ hash,
1676
+ QuestionnaireTitle,
1677
+ QuestionnaireDescription,
1678
+ QuestionnaireChoices,
1679
+ QuestionnaireChoice,
1680
+ QuestionnaireInput,
1681
+ QuestionnaireError
1682
+ })
1683
+ }), this);
1684
+ }
1685
+ }
1686
+ /**
1687
+ * A navigation button, yielded as `q.Previous`, `q.Skip`, `q.Next` and `q.Submit`. Each shows
1688
+ * only where it applies (and is hidden and inert otherwise): Previous after the first item,
1689
+ * Skip on an optional one, Next before the last, Submit on the last.
1690
+ */
1691
+ const QuestionnaireNavigation = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"button\" type=\"button\" ...attributes {{@part disabled=@disabled}}>\n {{~#if (has-block)}}{{yield}}{{else}}{{if @label @label @defaultLabel}}{{/if~}}\n</As>", {
1692
+ strictMode: true,
1693
+ scope: () => ({
1694
+ As
1695
+ })
1696
+ }), templateOnly());
1697
+ /** What `<Questionnaire>` yields. */
1698
+
1699
+ /**
1700
+ * A multi-step questionnaire with single-choice, multiple-choice, freeform and skippable
1701
+ * questions: `@shadcn/react`'s headless Questionnaire. It is a native `<form>`, so answers are
1702
+ * read with `FormData`; it owns the ordered items, the active one, answer state, validation,
1703
+ * progress and navigation, and the page around it owns closing, saving and branching.
1704
+ *
1705
+ * <Questionnaire @items={{items}} @onSubmit={{this.submit}} as |q|>
1706
+ * <q.Progress />
1707
+ * <q.Item @name="detail" @required={{true}} as |i|>
1708
+ * <i.Title>How much detail?</i.Title>
1709
+ * <i.Choices>
1710
+ * <i.Choice @value="focused" as |c|><c.Input /><c.Label>Focused</c.Label></i.Choice>
1711
+ * </i.Choices>
1712
+ * <i.Error />
1713
+ * </q.Item>
1714
+ * <q.Previous /><q.Skip /><q.Next /><q.Submit />
1715
+ * </Questionnaire>
1716
+ */
1717
+ class Questionnaire extends Component {
1718
+ questionnaire = new QuestionnaireState(this, {
1719
+ items: () => this.args.items,
1720
+ item: () => this.args.item,
1721
+ defaultItem: () => this.args.defaultItem,
1722
+ onItemChange: () => this.args.onItemChange,
1723
+ shortcuts: () => this.args.shortcuts,
1724
+ noValidate: () => this.args.noValidate,
1725
+ onSubmit: () => this.args.onSubmit,
1726
+ onReset: () => this.args.onReset
1727
+ });
1728
+ static {
1729
+ setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"form\" data-test-jn=\"questionnaire\" data-test-jn-name={{@name}} ...attributes {{this.questionnaire.root}} {{this.questionnaire.focusEffect this.questionnaire.activeName}}>\n {{yield (hash Progress=(component QuestionnaireProgress questionnaire=this.questionnaire) Item=(component QuestionnaireItem questionnaire=this.questionnaire) Previous=(component QuestionnaireNavigation part=this.questionnaire.previous defaultLabel=(t messages.questionnairePrevious)) Skip=(component QuestionnaireNavigation part=this.questionnaire.skip defaultLabel=(t messages.questionnaireSkip)) Next=(component QuestionnaireNavigation part=this.questionnaire.next defaultLabel=(t messages.questionnaireNext)) Submit=(component QuestionnaireNavigation part=this.questionnaire.submit defaultLabel=(t messages.questionnaireSubmit)) activeItem=this.questionnaire.activeName current=this.questionnaire.current total=this.questionnaire.total first=this.questionnaire.first last=this.questionnaire.last questionnaire=this.questionnaire)}}\n</As>", {
1730
+ strictMode: true,
1731
+ scope: () => ({
1732
+ As,
1733
+ hash,
1734
+ QuestionnaireProgress,
1735
+ QuestionnaireItem,
1736
+ QuestionnaireNavigation,
1737
+ t,
1738
+ messages
1739
+ })
1740
+ }), this);
1741
+ }
1742
+ }
1743
+
1744
+ export { Questionnaire as Q, QuestionnaireAnswerState as a, QuestionnaireChoice as b, QuestionnaireChoiceInput as c, QuestionnaireChoiceLabel as d, QuestionnaireChoiceShortcut as e, QuestionnaireChoiceState as f, QuestionnaireChoices as g, QuestionnaireDescription as h, QuestionnaireError as i, QuestionnaireInput as j, QuestionnaireInputState as k, QuestionnaireItem as l, QuestionnaireItemState as m, QuestionnaireNavigation as n, QuestionnaireProgress as o, QuestionnaireState as p, QuestionnaireTitle as q };
1745
+ //# sourceMappingURL=components-CWfg0cFs.js.map