@ember-joinery/primitives 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/CHANGELOG.md +472 -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 +307 -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
package/dist/drawer.js ADDED
@@ -0,0 +1,1456 @@
1
+ import Component from '@glimmer/component';
2
+ import { hash } from '@ember/helper';
3
+ import { g as DialogController, c as DialogContent, d as DialogOverlay, D as DialogClose, a as DialogDescription, b as DialogTitle, e as DialogTrigger, f as displayContents } from './dialog-3gfz_8NA.js';
4
+ import { tracked } from '@glimmer/tracking';
5
+ import { waitForPromise } from '@ember/test-waiters';
6
+ import { ControllableState } from './controllable-state.js';
7
+ import { isRTL } from './direction.js';
8
+ import { part } from './part.js';
9
+ import { isString, isNumber } from '@sindresorhus/is';
10
+ import { State, Machine, region, transition, after } from '@switchyard-ts/core';
11
+ import { machine } from '@switchyard-ts/ember';
12
+ import { g, i, n } from 'decorator-transforms/runtime';
13
+ import Modifier from 'ember-modifier';
14
+ import { registerDestructor } from '@ember/destroyable';
15
+ import { precompileTemplate } from '@ember/template-compilation';
16
+ import { setComponentTemplate } from '@ember/component';
17
+ import templateOnly from '@ember/component/template-only';
18
+
19
+ // A drawer's modes and timers, as a Switchyard chart. Whether it is open stays with the
20
+ // DialogController's ControllableState; this only follows what was committed. Bundled into
21
+ // @ember-joinery/primitives/drawer; it isn't a subpath of its own.
22
+ const DURATION$1 = 500;
23
+ const LONG_HANDLE_PRESS_TIMEOUT = 250;
24
+ const DOUBLE_TAP_TIMEOUT = 120;
25
+ class Lifecycle extends State {
26
+ static Closed = Lifecycle.of('closed');
27
+ /** It opened: its slide in is running. */
28
+ static Opening = Lifecycle.of('opening');
29
+ static Open = Lifecycle.of('open');
30
+ /** It closed: its slide out is running. */
31
+ static Closing = Lifecycle.of('closing');
32
+ }
33
+ class Gesture extends State {
34
+ static Idle = Gesture.of('idle');
35
+ /** A pointer went down on it: maybe a drag. */
36
+ static Pressed = Gesture.of('pressed');
37
+ /** It moves with the pointer until let go. */
38
+ static Dragging = Gesture.of('dragging');
39
+ }
40
+ class HandlePress extends State {
41
+ static Idle = HandlePress.of('idle');
42
+ /** A pointer is down on the handle: a tap, unless it stays down long. */
43
+ static Down = HandlePress.of('down');
44
+ /** Down long enough that it isn't a tap. */
45
+ static LongPress = HandlePress.of('long-press');
46
+ }
47
+ class HandleTap extends State {
48
+ static Idle = HandleTap.of('idle');
49
+ /** The handle was clicked: it cycles once the double-tap wait is out. */
50
+ static Pending = HandleTap.of('pending');
51
+ }
52
+
53
+ /** A timer whose effect lands once the animation is over. */
54
+ class Settle extends State {
55
+ static Idle = Settle.of('idle');
56
+ static Waiting = Settle.of('waiting');
57
+ }
58
+
59
+ /** What the chart's timers act on. */
60
+
61
+ /**
62
+ * vaul's flags and timeouts as parallel regions: the open lifecycle (each half `DURATION`
63
+ * long), the drag, the handle's long press and tap, and the waits after a nested drawer closes
64
+ * and after the background is put back. Leaving a state drops its timer, so a close cancels
65
+ * the open's animation end and `stop()` cancels everything.
66
+ */
67
+ class DrawerMachine extends Machine {
68
+ static {
69
+ g(this.prototype, "lifecycle", [region(Lifecycle)]);
70
+ }
71
+ #lifecycle = (i(this, "lifecycle"), void 0);
72
+ static {
73
+ g(this.prototype, "gesture", [region(Gesture)]);
74
+ }
75
+ #gesture = (i(this, "gesture"), void 0);
76
+ static {
77
+ g(this.prototype, "handlePress", [region(HandlePress)]);
78
+ }
79
+ #handlePress = (i(this, "handlePress"), void 0);
80
+ static {
81
+ g(this.prototype, "handleTap", [region(HandleTap)]);
82
+ }
83
+ #handleTap = (i(this, "handleTap"), void 0);
84
+ static {
85
+ g(this.prototype, "nested", [region(Settle)]);
86
+ }
87
+ #nested = (i(this, "nested"), void 0);
88
+ static {
89
+ g(this.prototype, "background", [region(Settle)]);
90
+ }
91
+ #background = (i(this, "background"), void 0);
92
+ host;
93
+ constructor(host) {
94
+ super();
95
+ this.host = host;
96
+ }
97
+
98
+ /** Whether it is pressed or dragged (vaul's `isDragging`). */
99
+ get isDragging() {
100
+ return this.gesture !== Gesture.Idle;
101
+ }
102
+
103
+ /** Whether the drag has begun moving it (vaul's `isAllowedToDrag`). */
104
+ get isMoving() {
105
+ return this.gesture === Gesture.Dragging;
106
+ }
107
+
108
+ /** Whether the handle is held long enough that a click isn't a tap. */
109
+ get isLongPress() {
110
+ return this.handlePress === HandlePress.LongPress;
111
+ }
112
+
113
+ // ----- Opening and closing ---------------------------------------------------------------
114
+
115
+ opened() {}
116
+
117
+ /** It was open from the start: nothing slides in. */
118
+ static {
119
+ n(this.prototype, "opened", [transition({
120
+ from: [Lifecycle.Closed, Lifecycle.Closing],
121
+ to: Lifecycle.Opening
122
+ })]);
123
+ }
124
+ startedOpen() {}
125
+ static {
126
+ n(this.prototype, "startedOpen", [transition({
127
+ from: Lifecycle.Closed,
128
+ to: Lifecycle.Open
129
+ })]);
130
+ }
131
+ closed() {}
132
+ static {
133
+ n(this.prototype, "closed", [transition({
134
+ from: [Lifecycle.Opening, Lifecycle.Open],
135
+ to: Lifecycle.Closing
136
+ })]);
137
+ }
138
+ finishedOpening() {
139
+ this.host.animationEnded(true);
140
+ }
141
+ static {
142
+ n(this.prototype, "finishedOpening", [after(DURATION$1, {
143
+ from: Lifecycle.Opening,
144
+ to: Lifecycle.Open
145
+ })]);
146
+ }
147
+ finishedClosing() {
148
+ this.host.animationEnded(false);
149
+ }
150
+
151
+ // ----- Dragging --------------------------------------------------------------------------
152
+ static {
153
+ n(this.prototype, "finishedClosing", [after(DURATION$1, {
154
+ from: Lifecycle.Closing,
155
+ to: Lifecycle.Closed
156
+ })]);
157
+ }
158
+ press() {}
159
+ static {
160
+ n(this.prototype, "press", [transition({
161
+ from: [Gesture.Idle, Gesture.Pressed, Gesture.Dragging],
162
+ to: Gesture.Pressed
163
+ })]);
164
+ }
165
+ move() {}
166
+
167
+ /** Let go, or stopped: either way the drag is over. */
168
+ static {
169
+ n(this.prototype, "move", [transition({
170
+ from: Gesture.Dragging
171
+ }), transition({
172
+ from: Gesture.Pressed,
173
+ to: Gesture.Dragging
174
+ })]);
175
+ }
176
+ release() {}
177
+
178
+ // ----- The handle ------------------------------------------------------------------------
179
+ static {
180
+ n(this.prototype, "release", [transition({
181
+ from: [Gesture.Pressed, Gesture.Dragging],
182
+ to: Gesture.Idle
183
+ })]);
184
+ }
185
+ handleDown() {}
186
+
187
+ /** vaul's handleCancelInteraction: the long press is forgotten. */
188
+ static {
189
+ n(this.prototype, "handleDown", [transition({
190
+ from: [HandlePress.Idle, HandlePress.Down, HandlePress.LongPress],
191
+ to: HandlePress.Down,
192
+ reenter: true
193
+ })]);
194
+ }
195
+ handleCancel() {}
196
+ static {
197
+ n(this.prototype, "handleCancel", [transition({
198
+ from: HandlePress.Idle
199
+ }), transition({
200
+ from: [HandlePress.Down, HandlePress.LongPress],
201
+ to: HandlePress.Idle
202
+ })]);
203
+ }
204
+ heldLong() {}
205
+
206
+ /** Clicks on the handle waiting out the double-tap wait. */
207
+ static {
208
+ n(this.prototype, "heldLong", [after(LONG_HANDLE_PRESS_TIMEOUT, {
209
+ from: HandlePress.Down,
210
+ to: HandlePress.LongPress
211
+ })]);
212
+ }
213
+ taps = 0;
214
+
215
+ /**
216
+ * A click on the handle: it cycles after the double-tap wait. A second click within the wait
217
+ * cycles once more, as vaul's (whose timers each cycle), rather than cancelling the first.
218
+ */
219
+ tap() {
220
+ this.taps++;
221
+ }
222
+ static {
223
+ n(this.prototype, "tap", [transition({
224
+ from: HandleTap.Pending
225
+ }), transition({
226
+ from: HandleTap.Idle,
227
+ to: HandleTap.Pending
228
+ })]);
229
+ }
230
+ tapped() {
231
+ const taps = this.taps;
232
+ this.taps = 0;
233
+ // The first tap's cycle forgets the long press (vaul's handleCancelInteraction); the
234
+ // cancel it sends is queued, so the later taps are told so.
235
+ for (let tap = 0; tap < taps; tap++) this.host.cycleSnapPoints(tap === 0 && this.isLongPress);
236
+ }
237
+
238
+ // ----- Waits for the animation ----------------------------------------------------------
239
+
240
+ /** A nested drawer closed: pin this one in place once it has come forward. */
241
+ static {
242
+ n(this.prototype, "tapped", [after(DOUBLE_TAP_TIMEOUT, {
243
+ from: HandleTap.Pending,
244
+ to: HandleTap.Idle
245
+ })]);
246
+ }
247
+ nestedClosed() {}
248
+ static {
249
+ n(this.prototype, "nestedClosed", [transition({
250
+ from: [Settle.Idle, Settle.Waiting],
251
+ to: Settle.Waiting,
252
+ in: 'nested',
253
+ reenter: true
254
+ })]);
255
+ }
256
+ nestedOpened() {}
257
+ static {
258
+ n(this.prototype, "nestedOpened", [transition({
259
+ from: [Settle.Idle, Settle.Waiting],
260
+ to: Settle.Idle,
261
+ in: 'nested'
262
+ })]);
263
+ }
264
+ nestedSettled() {
265
+ this.host.pinNested();
266
+ }
267
+
268
+ /** The background was put back: restore the body's colour once it has scaled up. */
269
+ static {
270
+ n(this.prototype, "nestedSettled", [after(DURATION$1, {
271
+ from: Settle.Waiting,
272
+ to: Settle.Idle,
273
+ in: 'nested'
274
+ })]);
275
+ }
276
+ backgroundReleased() {}
277
+ static {
278
+ n(this.prototype, "backgroundReleased", [transition({
279
+ from: [Settle.Idle, Settle.Waiting],
280
+ to: Settle.Waiting,
281
+ in: 'background',
282
+ reenter: true
283
+ })]);
284
+ }
285
+ backgroundScaled() {}
286
+ static {
287
+ n(this.prototype, "backgroundScaled", [transition({
288
+ from: [Settle.Idle, Settle.Waiting],
289
+ to: Settle.Idle,
290
+ in: 'background'
291
+ })]);
292
+ }
293
+ backgroundSettled() {
294
+ this.host.restoreBackground();
295
+ }
296
+ static {
297
+ n(this.prototype, "backgroundSettled", [after(DURATION$1, {
298
+ from: Settle.Waiting,
299
+ to: Settle.Idle,
300
+ in: 'background'
301
+ })]);
302
+ }
303
+ }
304
+
305
+ /** A started `DrawerMachine`, stopped (its timers with it) when `owner` is destroyed. */
306
+ function drawerMachine(owner, host) {
307
+ return machine(owner, new DrawerMachine(host));
308
+ }
309
+
310
+ // A drawer's state and behaviour: vaul's Root, Content, Overlay and Handle (vaul 1.1.2, which
311
+ // shadcn/ui's Drawer is built on), as a DialogController with gestures. This file is bundled
312
+ // into @ember-joinery/primitives/drawer; it isn't a subpath of its own.
313
+ // vaul's constants.
314
+ const DURATION = 0.5;
315
+ const EASE = 'cubic-bezier(0.32,0.72,0,1)';
316
+ const VELOCITY_THRESHOLD = 0.4;
317
+ const CLOSE_THRESHOLD = 0.25;
318
+ const SCROLL_LOCK_TIMEOUT = 100;
319
+ const BORDER_RADIUS = 8;
320
+ const NESTED_DISPLACEMENT = 16;
321
+ const WINDOW_TOP_OFFSET = 26;
322
+
323
+ /** The class a drawer has while it is dragged. */
324
+ const DRAG_CLASS = 'vaul-dragging';
325
+
326
+ /** The selectors vaul finds the background to scale by. */
327
+ const WRAPPER = '[data-vaul-drawer-wrapper], [vaul-drawer-wrapper]';
328
+ const transformTransition = `transform ${DURATION}s ${EASE}`;
329
+ const opacityTransition = `opacity ${DURATION}s ${EASE}`;
330
+
331
+ /** HTML input types that don't open a phone's keyboard. */
332
+ const NON_TEXT_INPUTS = new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']);
333
+ function isVertical(direction) {
334
+ return direction === 'top' || direction === 'bottom';
335
+ }
336
+
337
+ /** Whether an element opens a phone's keyboard when it has focus. */
338
+ function isInput(target) {
339
+ return target instanceof HTMLInputElement && !NON_TEXT_INPUTS.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
340
+ }
341
+ function isMobileFirefox() {
342
+ const userAgent = navigator.userAgent;
343
+ return /Firefox/.test(userAgent) && /Mobile/.test(userAgent) || /FxiOS/.test(userAgent);
344
+ }
345
+ /** Sets styles through the CSSOM, which a strict Content Security Policy allows. */
346
+ function setStyles(element, styles) {
347
+ if (!(element instanceof HTMLElement)) return;
348
+ for (const [name, value] of Object.entries(styles)) element.style.setProperty(name, value);
349
+ }
350
+
351
+ /** Sets styles, and returns a function that puts the element's whole style back. */
352
+ function assignStyles(element, styles) {
353
+ const previous = element.style.cssText;
354
+ setStyles(element, styles);
355
+ return () => {
356
+ element.style.cssText = previous;
357
+ };
358
+ }
359
+
360
+ /** How far an element is translated along a direction's axis, from its computed transform. */
361
+ function getTranslate(element, direction) {
362
+ if (!element) return null;
363
+ const transform = getComputedStyle(element).transform;
364
+ let matrix = /^matrix3d\((.+)\)$/.exec(transform);
365
+ if (matrix) return parseFloat(matrix[1].split(', ')[isVertical(direction) ? 13 : 12]);
366
+ matrix = /^matrix\((.+)\)$/.exec(transform);
367
+ return matrix ? parseFloat(matrix[1].split(', ')[isVertical(direction) ? 5 : 4]) : null;
368
+ }
369
+
370
+ /** vaul's rubber band, for a drag past fully open. */
371
+ function dampen(value) {
372
+ return 8 * (Math.log(value + 1) - 2);
373
+ }
374
+ function translate(direction, value) {
375
+ const amount = isNumber(value) ? `${value}px` : value;
376
+ return isVertical(direction) ? `translate3d(0, ${amount}, 0)` : `translate3d(${amount}, 0, 0)`;
377
+ }
378
+
379
+ /**
380
+ * One drawer's state and parts: a Dialog's (`DialogController`), with vaul's gestures. The
381
+ * content follows a drag along its axis and closes when let go far or fast enough, rests at its
382
+ * snap points, fades the overlay as it goes, scales the page behind it, and moves a drawer it is
383
+ * nested in back a step.
384
+ */
385
+ class DrawerController extends DialogController {
386
+ activeSnapPointState;
387
+
388
+ /** The window's size, kept as it resizes (snap points are measured against it). */
389
+ static {
390
+ g(this.prototype, "viewportSize", [tracked], function () {
391
+ return null;
392
+ });
393
+ }
394
+ #viewportSize = (i(this, "viewportSize"), void 0);
395
+ /** Untracked on purpose, as vaul's ref: its enter animation is skipped when it starts open. */
396
+ #shouldAnimate;
397
+ #openTime = null;
398
+ #dragStartTime = null;
399
+ #lastTimeDragPrevented = null;
400
+ #pointerStart = 0;
401
+ #keyboardIsOpen = false;
402
+ #previousDiffFromInitial = 0;
403
+ #drawerHeight = 0;
404
+ #drawerWidth = 0;
405
+ #initialDrawerHeight = 0;
406
+ // The content's own pointer tracking (vaul's Content).
407
+ #contentPointerStart = null;
408
+ #lastKnownPointerEvent = null;
409
+ #wasBeyondThePoint = false;
410
+ /** Whether the pending tap on the handle came from one with `preventCycle`. */
411
+ #preventCycle = false;
412
+ /** Whether it closed itself (vaul's closeDrawer), so it goes back to its first snap point. */
413
+ #resetOnClose = false;
414
+ /** The body whose background a scaled background put back, and the colour to restore. */
415
+ #body = null;
416
+ #previousScrollBehavior = null;
417
+
418
+ /** The Dialog's own `setOpen`, which this one wraps. */
419
+ #setDialogOpen = this.setOpen;
420
+ /** Its modes and timers: the open lifecycle, the drag, the handle's taps. */
421
+ #machine;
422
+ constructor(owner) {
423
+ super(owner);
424
+ this.#shouldAnimate = !owner.args.defaultOpen;
425
+ this.activeSnapPointState = new ControllableState({
426
+ value: () => this.args.activeSnapPoint,
427
+ defaultValue: () => this.args.defaultActiveSnapPoint ?? this.args.snapPoints?.[0],
428
+ onChange: () => this.args.onActiveSnapPointChange,
429
+ fallback: null,
430
+ name: 'activeSnapPoint'
431
+ });
432
+ this.#machine = drawerMachine(owner, {
433
+ animationEnded: open => this.#animationEnded(open),
434
+ cycleSnapPoints: isLongPress => this.#cycleSnapPoints(isLongPress),
435
+ pinNested: () => this.#pinNested(),
436
+ restoreBackground: () => this.#restoreBackground()
437
+ });
438
+ }
439
+
440
+ /** Whether it is being dragged now (or pressed, about to be). */
441
+ get isDragging() {
442
+ return this.#machine.isDragging;
443
+ }
444
+
445
+ // ----- Arguments, with vaul's defaults ----------------------------------------------------
446
+
447
+ get args() {
448
+ return super.args;
449
+ }
450
+ get slot() {
451
+ return 'drawer';
452
+ }
453
+ get direction() {
454
+ return this.args.direction ?? 'bottom';
455
+ }
456
+
457
+ /**
458
+ * The physical edge it is on: its direction, but with left and right swapped right to left
459
+ * (where `left`, the inline start, is on the right).
460
+ */
461
+ get side() {
462
+ const direction = this.direction;
463
+ if (isVertical(direction)) return direction;
464
+ const element = this.contentElement ?? this.triggerElement;
465
+ if (!isRTL(element)) return direction;
466
+ return direction === 'left' ? 'right' : 'left';
467
+ }
468
+ get dismissible() {
469
+ return this.args.dismissible ?? true;
470
+ }
471
+ get snapPoints() {
472
+ return this.args.snapPoints;
473
+ }
474
+ get hasSnapPoints() {
475
+ return (this.snapPoints?.length ?? 0) > 0;
476
+ }
477
+ get fadeFromIndex() {
478
+ const snapPoints = this.snapPoints;
479
+ return this.args.fadeFromIndex ?? (snapPoints ? snapPoints.length - 1 : undefined);
480
+ }
481
+ get closeThreshold() {
482
+ return this.args.closeThreshold ?? CLOSE_THRESHOLD;
483
+ }
484
+ get scrollLockTimeout() {
485
+ return this.args.scrollLockTimeout ?? SCROLL_LOCK_TIMEOUT;
486
+ }
487
+ get repositionInputs() {
488
+ return this.args.repositionInputs ?? true;
489
+ }
490
+
491
+ // ----- Snap points (vaul's useSnapPoints) -------------------------------------------------
492
+
493
+ get activeSnapPoint() {
494
+ return this.activeSnapPointState.value;
495
+ }
496
+ setActiveSnapPoint = snapPoint => {
497
+ this.activeSnapPointState.set(snapPoint);
498
+ };
499
+ get activeSnapPointIndex() {
500
+ return this.snapPoints?.findIndex(point => point === this.activeSnapPoint) ?? null;
501
+ }
502
+ get isLastSnapPoint() {
503
+ const snapPoints = this.snapPoints;
504
+ return Boolean(snapPoints && this.activeSnapPoint === snapPoints[snapPoints.length - 1]);
505
+ }
506
+
507
+ /** Whether the overlay shows: always without snap points, else from `fadeFromIndex` on. */
508
+ get shouldFade() {
509
+ const snapPoints = this.snapPoints;
510
+ if (!snapPoints) return true;
511
+ const index = this.fadeFromIndex;
512
+ return snapPoints.length > 0 && index !== undefined && !Number.isNaN(index) && snapPoints[index] === this.activeSnapPoint;
513
+ }
514
+ get #viewport() {
515
+ const window = this.contentElement?.ownerDocument.defaultView ?? globalThis.window;
516
+ return this.viewportSize ?? {
517
+ width: window.innerWidth,
518
+ height: window.innerHeight
519
+ };
520
+ }
521
+
522
+ /** Called when the window resizes, so the snap points are measured again. */
523
+ measure = () => {
524
+ const window = this.contentElement?.ownerDocument.defaultView ?? globalThis.window;
525
+ this.viewportSize = {
526
+ width: window.innerWidth,
527
+ height: window.innerHeight
528
+ };
529
+ };
530
+
531
+ /** Each snap point as the translation, in pixels along its axis, that rests the drawer there. */
532
+ get snapPointsOffset() {
533
+ const side = this.side;
534
+ const {
535
+ width,
536
+ height
537
+ } = this.#viewport;
538
+ return (this.snapPoints ?? []).map(snapPoint => {
539
+ const isPx = isString(snapPoint);
540
+ const value = isPx ? parseInt(snapPoint, 10) : 0;
541
+ if (isVertical(side)) {
542
+ const size = isPx ? value : snapPoint * height;
543
+ return side === 'bottom' ? height - size : -height + size;
544
+ }
545
+ const size = isPx ? value : snapPoint * width;
546
+ return side === 'right' ? width - size : -width + size;
547
+ });
548
+ }
549
+ get activeSnapPointOffset() {
550
+ const index = this.activeSnapPointIndex;
551
+ return index !== null ? this.snapPointsOffset[index] ?? null : null;
552
+ }
553
+
554
+ /** Rests the drawer at the snap point with this offset, and makes it the active one. */
555
+ snapToPoint(dimension) {
556
+ const offsets = this.snapPointsOffset;
557
+ const index = dimension === undefined ? -1 : offsets.indexOf(dimension);
558
+ this.applySnapPoint(index);
559
+ this.setActiveSnapPoint(this.snapPoints?.[Math.max(index, 0)] ?? null);
560
+ }
561
+
562
+ /** Moves the drawer to a snap point and fades the overlay to match, as vaul's snapToPoint. */
563
+ applySnapPoint(index) {
564
+ const offsets = this.snapPointsOffset;
565
+ const dimension = offsets[index];
566
+ // At the last snap point it may scroll, so it can't be dragged for a moment (vaul's
567
+ // onSnapPointChange).
568
+ if (this.snapPoints && index === offsets.length - 1) this.#openTime = Date.now();
569
+ if (dimension === undefined) return;
570
+ setStyles(this.contentElement, {
571
+ transition: transformTransition,
572
+ transform: translate(this.side, dimension)
573
+ });
574
+ const fadeFrom = this.fadeFromIndex;
575
+ const transparent = index !== offsets.length - 1 && fadeFrom !== undefined && index !== fadeFrom && index < fadeFrom;
576
+ setStyles(this.overlayElement, {
577
+ transition: opacityTransition,
578
+ opacity: transparent ? '0' : '1'
579
+ });
580
+ }
581
+ #releaseSnapPoints(draggedDistance, velocity) {
582
+ const fadeFrom = this.fadeFromIndex;
583
+ const offsets = this.snapPointsOffset;
584
+ if (fadeFrom === undefined || offsets.length === 0) return;
585
+ const side = this.side;
586
+ const snapPoints = this.snapPoints ?? [];
587
+ const activeOffset = this.activeSnapPointOffset ?? 0;
588
+ const activeIndex = this.activeSnapPointIndex;
589
+ const currentPosition = side === 'bottom' || side === 'right' ? activeOffset - draggedDistance : activeOffset + draggedDistance;
590
+ const isOverlaySnapPoint = activeIndex === fadeFrom - 1;
591
+ const isFirst = activeIndex === 0;
592
+ const hasDraggedUp = draggedDistance > 0;
593
+ if (isOverlaySnapPoint) setStyles(this.overlayElement, {
594
+ transition: opacityTransition
595
+ });
596
+ if (!this.args.snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
597
+ if (this.dismissible) this.closeDrawer();else this.snapToPoint(offsets[0]);
598
+ return;
599
+ }
600
+ if (!this.args.snapToSequentialPoint && velocity > 2 && hasDraggedUp) {
601
+ this.snapToPoint(offsets[snapPoints.length - 1]);
602
+ return;
603
+ }
604
+
605
+ // The snap point nearest to where it was let go.
606
+ const closest = offsets.reduce((previous, current) => Math.abs(current - currentPosition) < Math.abs(previous - currentPosition) ? current : previous);
607
+ const {
608
+ width,
609
+ height
610
+ } = this.#viewport;
611
+ const dimension = isVertical(side) ? height : width;
612
+ if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dimension * 0.4) {
613
+ const dragDirection = hasDraggedUp ? 1 : -1;
614
+ // Swiped open at the last snap point: stay there.
615
+ if (dragDirection > 0 && this.isLastSnapPoint) {
616
+ this.snapToPoint(offsets[snapPoints.length - 1]);
617
+ return;
618
+ }
619
+ if (isFirst && dragDirection < 0 && this.dismissible) this.closeDrawer();
620
+ if (activeIndex === null) return;
621
+ this.snapToPoint(offsets[activeIndex + dragDirection]);
622
+ return;
623
+ }
624
+ this.snapToPoint(closest);
625
+ }
626
+ #dragSnapPoints(draggedDistance) {
627
+ const activeOffset = this.activeSnapPointOffset;
628
+ if (activeOffset === null) return;
629
+ const side = this.side;
630
+ const offsets = this.snapPointsOffset;
631
+ const last = offsets[offsets.length - 1];
632
+ const value = side === 'bottom' || side === 'right' ? activeOffset - draggedDistance : activeOffset + draggedDistance;
633
+ // Not past the last (largest) snap point.
634
+ if ((side === 'bottom' || side === 'right') && value < last) return;
635
+ if ((side === 'top' || side === 'left') && value > last) return;
636
+ setStyles(this.contentElement, {
637
+ transform: translate(side, value)
638
+ });
639
+ }
640
+ #snapPointsPercentageDragged(absDraggedDistance, isDraggingDown) {
641
+ const snapPoints = this.snapPoints;
642
+ const activeIndex = this.activeSnapPointIndex;
643
+ const fadeFrom = this.fadeFromIndex;
644
+ const offsets = this.snapPointsOffset;
645
+ if (!snapPoints || !isNumber(activeIndex) || fadeFrom === undefined) return null;
646
+ // Dragging to a snap point that is supposed to have an overlay.
647
+ const isOverlaySnapPoint = activeIndex === fadeFrom - 1;
648
+ const isOverlaySnapPointOrHigher = activeIndex >= fadeFrom;
649
+ if (isOverlaySnapPointOrHigher && isDraggingDown) return 0;
650
+ // Don't animate, but still use this one when dragging away from the overlay snap point.
651
+ if (isOverlaySnapPoint && !isDraggingDown) return 1;
652
+ if (!this.shouldFade && !isOverlaySnapPoint) return null;
653
+ const target = isOverlaySnapPoint ? activeIndex + 1 : activeIndex - 1;
654
+ const distance = isOverlaySnapPoint ? offsets[target] - offsets[target - 1] : offsets[target + 1] - offsets[target];
655
+ const percentageDragged = absDraggedDistance / Math.abs(distance);
656
+ return isOverlaySnapPoint ? 1 - percentageDragged : percentageDragged;
657
+ }
658
+
659
+ // ----- Opening and closing -------------------------------------------------------------------
660
+
661
+ /** Opens or closes it, whatever `@dismissible` says (your own code calling it decides). */
662
+ setOpen = open => {
663
+ const was = this.isOpen;
664
+ if (was && !open) this.cancelDrag();
665
+ this.#setDialogOpen(open);
666
+ // Only once the close is committed: a controlled `@open` may refuse it.
667
+ if (was && !this.isOpen) this.#resetOnClose = true;
668
+ };
669
+
670
+ /** A close part, a `<form method="dialog">`: closes it, if it is dismissible. */
671
+ hide = () => {
672
+ if (this.dismissible) this.setOpen(false);
673
+ };
674
+
675
+ /** The trigger: opens it, or closes it if it is dismissible. */
676
+ toggle = () => {
677
+ if (this.isOpen) this.hide();else this.setOpen(true);
678
+ };
679
+
680
+ /** Escape or a press outside: closes it, if it is dismissible. */
681
+ dismiss = () => this.hide();
682
+
683
+ /** Closes it after a drag (vaul's closeDrawer). */
684
+ closeDrawer() {
685
+ this.setOpen(false);
686
+ }
687
+
688
+ /**
689
+ * Called by the root when it has opened or closed, however that came about: `initial` when it
690
+ * renders open, where nothing slides in (and, as vaul's, `onAnimationEnd` isn't called).
691
+ */
692
+ openChanged(open, initial = false) {
693
+ const root = (this.contentElement ?? this.triggerElement)?.ownerDocument.documentElement;
694
+ if (open) {
695
+ this.#openTime = Date.now();
696
+ this.#resetOnClose = false;
697
+ if (root) {
698
+ this.#previousScrollBehavior = root.style.scrollBehavior;
699
+ root.style.scrollBehavior = 'auto';
700
+ }
701
+ } else if (root && this.#previousScrollBehavior !== null) {
702
+ root.style.scrollBehavior = this.#previousScrollBehavior;
703
+ this.#previousScrollBehavior = null;
704
+ }
705
+ this.args.parent?.onNestedOpenChange(open);
706
+ if (!open) this.#machine.closed();else if (initial) this.#machine.startedOpen();else this.#machine.opened();
707
+ }
708
+
709
+ /** It finished opening or closing; if it closed itself, it goes back to its first snap point. */
710
+ #animationEnded(open) {
711
+ const snapPoints = this.snapPoints;
712
+ if (!open && this.#resetOnClose && snapPoints) this.setActiveSnapPoint(snapPoints[0] ?? null);
713
+ this.#resetOnClose = false;
714
+ this.args.onAnimationEnd?.(open);
715
+ }
716
+
717
+ /** Called by the root once it has rendered, a frame after which opening animates. */
718
+ rendered() {
719
+ requestAnimationFrame(() => this.#shouldAnimate = true);
720
+ }
721
+ teardown() {
722
+ this.#machine.stop();
723
+ // The wait for the body's background died with the machine.
724
+ this.#restoreBackground();
725
+ }
726
+
727
+ // ----- Focus and presses outside, as vaul's Content passes them to Radix's ------------------
728
+
729
+ /** Focus goes to the drawer itself, unless `@autoFocus` asks for its first focusable element. */
730
+ onOpenAutoFocus(event, handler) {
731
+ handler?.(event);
732
+ if (event.defaultPrevented || this.args.autoFocus) return;
733
+ event.preventDefault();
734
+ this.contentElement?.focus({
735
+ preventScroll: true
736
+ });
737
+ }
738
+ onPointerDownOutside(event, handler) {
739
+ handler?.(event);
740
+ // A press outside a non-modal drawer leaves it open.
741
+ if (!this.isModal || event.defaultPrevented) {
742
+ event.preventDefault();
743
+ return;
744
+ }
745
+ this.#keyboardIsOpen = false;
746
+ super.onPointerDownOutside(event);
747
+ }
748
+
749
+ /** Focus moving outside never closes a drawer. */
750
+ onFocusOutside(event, handler) {
751
+ handler?.(event);
752
+ event.preventDefault();
753
+ }
754
+
755
+ // ----- Dragging (vaul's Root) ------------------------------------------------------------
756
+
757
+ /** A pointer went down on the drawer: it may be the start of a drag. */
758
+ onPress(event) {
759
+ const drawer = this.contentElement;
760
+ if (!this.dismissible && !this.snapPoints) return;
761
+ if (drawer && !(event.target instanceof Node && drawer.contains(event.target))) return;
762
+ const rect = drawer?.getBoundingClientRect();
763
+ this.#drawerHeight = rect?.height ?? 0;
764
+ this.#drawerWidth = rect?.width ?? 0;
765
+ this.#machine.press();
766
+ this.#dragStartTime = Date.now();
767
+ // Keep the pointer while it leaves the drawer. A pointer that isn't active (an event a test
768
+ // dispatches) can't be captured.
769
+ try {
770
+ if (event.target instanceof Element) event.target.setPointerCapture(event.pointerId);
771
+ } catch {
772
+ // Nothing to capture.
773
+ }
774
+ this.#pointerStart = isVertical(this.side) ? event.pageY : event.pageX;
775
+ }
776
+
777
+ /** Whether a drag that started on `element` moves the drawer, rather than scrolling. */
778
+ #shouldDrag(element, isDraggingInDirection) {
779
+ const drawer = this.contentElement;
780
+ const side = this.side;
781
+ const highlightedText = element.ownerDocument.getSelection()?.toString();
782
+ const swipeAmount = drawer ? getTranslate(drawer, side) : null;
783
+ const now = Date.now();
784
+ if (element.tagName === 'SELECT') return false;
785
+ if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) {
786
+ return false;
787
+ }
788
+ if (side === 'right' || side === 'left') return true;
789
+ // Still opening: let it scroll.
790
+ if (this.#openTime && now - this.#openTime < 500) return false;
791
+ if (swipeAmount !== null && (side === 'bottom' ? swipeAmount > 0 : swipeAmount < 0)) {
792
+ return true;
793
+ }
794
+ // Text is selected.
795
+ if (highlightedText && highlightedText.length > 0) return false;
796
+ // It scrolled a moment ago.
797
+ if (this.#lastTimeDragPrevented && now - this.#lastTimeDragPrevented < this.scrollLockTimeout && swipeAmount === 0) {
798
+ this.#lastTimeDragPrevented = now;
799
+ return false;
800
+ }
801
+ // Dragging it open: scroll instead.
802
+ if (isDraggingInDirection) {
803
+ this.#lastTimeDragPrevented = now;
804
+ return false;
805
+ }
806
+ // Up through its ancestors: a scrolled one scrolls rather than drags. vaul climbs to the
807
+ // document, past its portal; this drawer stays where it is rendered (in the top layer), so
808
+ // the climb stops at the drawer, and a scrolled page or app container doesn't stop a drag.
809
+ let current = element;
810
+ while (current instanceof Element) {
811
+ if (current.scrollHeight > current.clientHeight) {
812
+ if (current.scrollTop !== 0) {
813
+ this.#lastTimeDragPrevented = Date.now();
814
+ return false;
815
+ }
816
+ if (current.getAttribute('role') === 'dialog') return true;
817
+ }
818
+ if (current === drawer) break;
819
+ current = current.parentNode;
820
+ }
821
+ return true;
822
+ }
823
+
824
+ /** The pointer moved while pressed: the drawer follows it. */
825
+ onDrag(event) {
826
+ const drawer = this.contentElement;
827
+ if (!drawer || !this.isDragging) return;
828
+ const side = this.side;
829
+ const multiplier = side === 'bottom' || side === 'right' ? 1 : -1;
830
+ const draggedDistance = (this.#pointerStart - (isVertical(side) ? event.pageY : event.pageX)) * multiplier;
831
+ const isDraggingInDirection = draggedDistance > 0;
832
+ const snapPoints = this.snapPoints;
833
+ const activeIndex = this.activeSnapPointIndex;
834
+ const fadeFrom = this.fadeFromIndex;
835
+
836
+ // A drawer that can't be dismissed can't be dragged closed past its first snap point.
837
+ const noCloseSnapPoints = Boolean(snapPoints && !this.dismissible && !isDraggingInDirection);
838
+ if (noCloseSnapPoints && activeIndex === 0) return;
839
+ const absDraggedDistance = Math.abs(draggedDistance);
840
+ const wrapper = drawer.ownerDocument.querySelector(WRAPPER);
841
+ const dimension = isVertical(side) ? this.#drawerHeight : this.#drawerWidth;
842
+ // How far toward closed, where 1 is closed.
843
+ let percentageDragged = absDraggedDistance / dimension;
844
+ const snapPercentage = this.#snapPointsPercentageDragged(absDraggedDistance, isDraggingInDirection);
845
+ if (snapPercentage !== null) percentageDragged = snapPercentage;
846
+ if (noCloseSnapPoints && percentageDragged >= 1) return;
847
+ if (!this.#machine.isMoving && !this.#shouldDrag(event.target, isDraggingInDirection)) return;
848
+ drawer.classList.add(DRAG_CLASS);
849
+ // Once it drags, it keeps dragging until let go.
850
+ this.#machine.move();
851
+ setStyles(drawer, {
852
+ transition: 'none'
853
+ });
854
+ setStyles(this.overlayElement, {
855
+ transition: 'none'
856
+ });
857
+ if (snapPoints) this.#dragSnapPoints(draggedDistance);
858
+
859
+ // Past fully open, without snap points: a rubber band.
860
+ if (isDraggingInDirection && !snapPoints) {
861
+ const value = Math.min(dampen(draggedDistance) * -1, 0) * multiplier;
862
+ setStyles(drawer, {
863
+ transform: translate(side, value)
864
+ });
865
+ return;
866
+ }
867
+ const opacity = 1 - percentageDragged;
868
+ if (this.shouldFade || fadeFrom && activeIndex === fadeFrom - 1) {
869
+ this.args.onDrag?.(event, percentageDragged);
870
+ this.args.parent?.onNestedDrag(percentageDragged);
871
+ setStyles(this.overlayElement, {
872
+ opacity: `${opacity}`,
873
+ transition: 'none'
874
+ });
875
+ }
876
+ if (wrapper && this.overlayElement && this.args.shouldScaleBackground) {
877
+ const scale = Math.min(this.#scale() + percentageDragged * (1 - this.#scale()), 1);
878
+ const radius = 8 - percentageDragged * 8;
879
+ const offset = Math.max(0, 14 - percentageDragged * 14);
880
+ setStyles(wrapper, {
881
+ 'border-radius': `${radius}px`,
882
+ transform: isVertical(side) ? `scale(${scale}) translate3d(0, ${offset}px, 0)` : `scale(${scale}) translate3d(${offset}px, 0, 0)`,
883
+ transition: 'none'
884
+ });
885
+ }
886
+ if (!snapPoints) {
887
+ setStyles(drawer, {
888
+ transform: translate(side, absDraggedDistance * multiplier)
889
+ });
890
+ }
891
+ }
892
+
893
+ /** The scale of the page behind, while the drawer is open over it. */
894
+ #scale() {
895
+ const width = this.#viewport.width;
896
+ return (width - WINDOW_TOP_OFFSET) / width;
897
+ }
898
+
899
+ /** Stops a drag without letting it go anywhere. */
900
+ cancelDrag() {
901
+ const drawer = this.contentElement;
902
+ if (!this.isDragging || !drawer) return;
903
+ drawer.classList.remove(DRAG_CLASS);
904
+ this.#machine.release();
905
+ }
906
+
907
+ /** Puts it back where it rests, after a drag that didn't close it. */
908
+ resetDrawer() {
909
+ const drawer = this.contentElement;
910
+ if (!drawer) return;
911
+ const side = this.side;
912
+ const wrapper = drawer.ownerDocument.querySelector(WRAPPER);
913
+ const swipeAmount = getTranslate(drawer, side);
914
+ setStyles(drawer, {
915
+ transform: 'translate3d(0, 0, 0)',
916
+ transition: transformTransition
917
+ });
918
+ setStyles(this.overlayElement, {
919
+ transition: opacityTransition,
920
+ opacity: '1'
921
+ });
922
+ // Swiped open: the background stays as it is.
923
+ if (this.args.shouldScaleBackground && swipeAmount && swipeAmount > 0 && this.isOpen) {
924
+ setStyles(wrapper, {
925
+ 'border-radius': `${BORDER_RADIUS}px`,
926
+ overflow: 'hidden',
927
+ ...(isVertical(side) ? {
928
+ transform: `scale(${this.#scale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
929
+ 'transform-origin': 'top'
930
+ } : {
931
+ transform: `scale(${this.#scale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
932
+ 'transform-origin': 'left'
933
+ }),
934
+ 'transition-property': 'transform, border-radius',
935
+ 'transition-duration': `${DURATION}s`,
936
+ 'transition-timing-function': EASE
937
+ });
938
+ }
939
+ }
940
+
941
+ /** The pointer let go: close it, snap it, or put it back. */
942
+ onRelease(event) {
943
+ const drawer = this.contentElement;
944
+ if (!this.isDragging || !drawer) return;
945
+ drawer.classList.remove(DRAG_CLASS);
946
+ this.#machine.release();
947
+ const dragEndTime = Date.now();
948
+ const side = this.side;
949
+ const swipeAmount = getTranslate(drawer, side);
950
+ if (!event || !(event.target instanceof Element) || !this.#shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;
951
+ if (this.#dragStartTime === null) return;
952
+ const timeTaken = dragEndTime - this.#dragStartTime;
953
+ const distMoved = this.#pointerStart - (isVertical(side) ? event.pageY : event.pageX);
954
+ const velocity = Math.abs(distMoved) / Math.max(timeTaken, 1);
955
+ const pointerEvent = event;
956
+ if (this.snapPoints) {
957
+ const multiplier = side === 'bottom' || side === 'right' ? 1 : -1;
958
+ this.#releaseSnapPoints(distMoved * multiplier, velocity);
959
+ this.#released(pointerEvent, true);
960
+ return;
961
+ }
962
+
963
+ // Moved toward open: nothing to do but put it back.
964
+ if (side === 'bottom' || side === 'right' ? distMoved > 0 : distMoved < 0) {
965
+ this.resetDrawer();
966
+ this.#released(pointerEvent, true);
967
+ return;
968
+ }
969
+ if (velocity > VELOCITY_THRESHOLD) {
970
+ this.closeDrawer();
971
+ this.#released(pointerEvent, false);
972
+ return;
973
+ }
974
+ const window = drawer.ownerDocument.defaultView ?? globalThis.window;
975
+ const rect = drawer.getBoundingClientRect();
976
+ const visibleHeight = Math.min(rect.height, window.innerHeight);
977
+ const visibleWidth = Math.min(rect.width, window.innerWidth);
978
+ const visible = side === 'left' || side === 'right' ? visibleWidth : visibleHeight;
979
+ if (Math.abs(swipeAmount) >= visible * this.closeThreshold) {
980
+ this.closeDrawer();
981
+ this.#released(pointerEvent, false);
982
+ return;
983
+ }
984
+ this.#released(pointerEvent, true);
985
+ this.resetDrawer();
986
+ }
987
+ #released(event, open) {
988
+ this.args.onRelease?.(event, open);
989
+ this.args.parent?.onNestedRelease(open);
990
+ }
991
+
992
+ // ----- A drawer nested in this one (vaul's NestedRoot) -----------------------------------
993
+
994
+ /** A drawer nested in this one opened or closed: step this one back, or forward again. */
995
+ onNestedOpenChange(open) {
996
+ const drawer = this.contentElement;
997
+ const width = this.#viewport.width;
998
+ const scale = open ? (width - NESTED_DISPLACEMENT) / width : 1;
999
+ const initialTranslate = open ? -NESTED_DISPLACEMENT : 0;
1000
+ setStyles(drawer, {
1001
+ transition: transformTransition,
1002
+ transform: `scale(${scale}) ${translate(this.side, initialTranslate)}`
1003
+ });
1004
+ if (!open && drawer) this.#machine.nestedClosed();else this.#machine.nestedOpened();
1005
+ }
1006
+
1007
+ /** Half a second after a nested drawer closed: pin this one where it came forward to. */
1008
+ #pinNested() {
1009
+ const drawer = this.contentElement;
1010
+ if (!drawer) return;
1011
+ const side = this.side;
1012
+ const value = getTranslate(drawer, side) ?? 0;
1013
+ setStyles(drawer, {
1014
+ transition: 'none',
1015
+ transform: translate(side, value)
1016
+ });
1017
+ }
1018
+
1019
+ /** A drawer nested in this one is dragged: this one comes forward as it goes. */
1020
+ onNestedDrag(percentageDragged) {
1021
+ if (percentageDragged < 0) return;
1022
+ const width = this.#viewport.width;
1023
+ const initialScale = (width - NESTED_DISPLACEMENT) / width;
1024
+ const scale = initialScale + percentageDragged * (1 - initialScale);
1025
+ const offset = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
1026
+ setStyles(this.contentElement, {
1027
+ transform: `scale(${scale}) ${translate(this.side, offset)}`,
1028
+ transition: 'none'
1029
+ });
1030
+ }
1031
+
1032
+ /** A drawer nested in this one was let go: if it stays open, this one steps back again. */
1033
+ onNestedRelease(open) {
1034
+ if (!open) return;
1035
+ const side = this.side;
1036
+ const {
1037
+ width,
1038
+ height
1039
+ } = this.#viewport;
1040
+ const dimension = isVertical(side) ? height : width;
1041
+ const scale = (dimension - NESTED_DISPLACEMENT) / dimension;
1042
+ setStyles(this.contentElement, {
1043
+ transition: transformTransition,
1044
+ transform: `scale(${scale}) ${translate(side, -NESTED_DISPLACEMENT)}`
1045
+ });
1046
+ }
1047
+
1048
+ // ----- The scaled background (vaul's useScaleBackground) ----------------------------------
1049
+
1050
+ /** Scales the background back, while it is open; returns the function that undoes it. */
1051
+ scaleBackground(element) {
1052
+ const document = element.ownerDocument;
1053
+ const wrapper = document.querySelector(WRAPPER);
1054
+ if (!(wrapper instanceof HTMLElement)) return undefined;
1055
+ this.#afterRender(() => this.#machine.backgroundScaled());
1056
+ const body = document.body;
1057
+ const initialBackground = body.style.backgroundColor;
1058
+ const vertical = isVertical(this.side);
1059
+ if (this.args.setBackgroundColorOnScale !== false && !this.args.noBodyStyles) {
1060
+ assignStyles(body, {
1061
+ background: 'black'
1062
+ });
1063
+ }
1064
+ assignStyles(wrapper, {
1065
+ 'transform-origin': vertical ? 'top' : 'left',
1066
+ 'transition-property': 'transform, border-radius',
1067
+ 'transition-duration': `${DURATION}s`,
1068
+ 'transition-timing-function': EASE
1069
+ });
1070
+ const restoreWrapper = assignStyles(wrapper, {
1071
+ 'border-radius': `${BORDER_RADIUS}px`,
1072
+ overflow: 'hidden',
1073
+ transform: vertical ? `scale(${this.#scale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)` : `scale(${this.#scale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
1074
+ });
1075
+ return () => {
1076
+ restoreWrapper();
1077
+ this.#body = {
1078
+ element: body,
1079
+ background: initialBackground
1080
+ };
1081
+ // Torn down with the drawer, there is no machine left to wait: restore it now.
1082
+ if (this.#machine.status === 'active') this.#afterRender(() => this.#machine.backgroundReleased());else this.#restoreBackground();
1083
+ };
1084
+ }
1085
+
1086
+ /**
1087
+ * Sends to the machine once the render is over: the modifier that scales the background runs
1088
+ * in a render that has read the machine, and a render can't change state it has read.
1089
+ */
1090
+ #afterRender(send) {
1091
+ void waitForPromise(Promise.resolve().then(() => {
1092
+ if (this.#machine.status === 'active') send();else this.#restoreBackground();
1093
+ }));
1094
+ }
1095
+ #restoreBackground() {
1096
+ const body = this.#body;
1097
+ this.#body = null;
1098
+ if (!body) return;
1099
+ if (body.background) body.element.style.background = body.background;else body.element.style.removeProperty('background');
1100
+ }
1101
+
1102
+ // ----- A phone's keyboard (vaul's repositionInputs) ----------------------------------------
1103
+
1104
+ /** The visual viewport resized: if a phone's keyboard opened over an input, keep it in view. */
1105
+ onVisualViewportChange = () => {
1106
+ const drawer = this.contentElement;
1107
+ if (!drawer || !this.repositionInputs) return;
1108
+ const window = drawer.ownerDocument.defaultView ?? globalThis.window;
1109
+ if (!isInput(drawer.ownerDocument.activeElement) && !this.#keyboardIsOpen) return;
1110
+ const visualViewportHeight = window.visualViewport?.height || 0;
1111
+ const totalHeight = window.innerHeight;
1112
+ // The keyboard's height.
1113
+ let diffFromInitial = totalHeight - visualViewportHeight;
1114
+ const drawerHeight = drawer.getBoundingClientRect().height || 0;
1115
+ const isTallEnough = drawerHeight > totalHeight * 0.8;
1116
+ if (!this.#initialDrawerHeight) this.#initialDrawerHeight = drawerHeight;
1117
+ const offsetFromTop = drawer.getBoundingClientRect().top;
1118
+ // A change of 60px or more means the keyboard really opened or closed.
1119
+ if (Math.abs(this.#previousDiffFromInitial - diffFromInitial) > 60) {
1120
+ this.#keyboardIsOpen = !this.#keyboardIsOpen;
1121
+ }
1122
+ const snapPoints = this.snapPoints;
1123
+ const activeIndex = this.activeSnapPointIndex;
1124
+ if (snapPoints && snapPoints.length > 0 && activeIndex) {
1125
+ diffFromInitial += this.snapPointsOffset[activeIndex] || 0;
1126
+ }
1127
+ this.#previousDiffFromInitial = diffFromInitial;
1128
+ if (drawerHeight > visualViewportHeight || this.#keyboardIsOpen) {
1129
+ const height = drawer.getBoundingClientRect().height;
1130
+ let newDrawerHeight = height;
1131
+ if (height > visualViewportHeight) {
1132
+ newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
1133
+ }
1134
+ if (this.args.fixed) {
1135
+ drawer.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
1136
+ } else {
1137
+ drawer.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
1138
+ }
1139
+ } else if (!isMobileFirefox()) {
1140
+ drawer.style.height = `${this.#initialDrawerHeight}px`;
1141
+ }
1142
+ if (snapPoints && snapPoints.length > 0 && !this.#keyboardIsOpen) {
1143
+ drawer.style.bottom = '0px';
1144
+ } else {
1145
+ drawer.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
1146
+ }
1147
+ };
1148
+
1149
+ // ----- The content's pointer (vaul's Content) ----------------------------------------------
1150
+
1151
+ /** Whether a pointer that has moved by `delta` is dragging along the drawer's axis. */
1152
+ #isDeltaInDirection(delta, threshold) {
1153
+ if (this.#wasBeyondThePoint) return true;
1154
+ const side = this.side;
1155
+ const deltaY = Math.abs(delta.y);
1156
+ const deltaX = Math.abs(delta.x);
1157
+ const isDeltaX = deltaX > deltaY;
1158
+ const factor = side === 'bottom' || side === 'right' ? 1 : -1;
1159
+ if (side === 'left' || side === 'right') {
1160
+ const isReverseDirection = delta.x * factor < 0;
1161
+ if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) return isDeltaX;
1162
+ } else {
1163
+ const isReverseDirection = delta.y * factor < 0;
1164
+ if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) return !isDeltaX;
1165
+ }
1166
+ this.#wasBeyondThePoint = true;
1167
+ return true;
1168
+ }
1169
+ #contentPointerDown = event => {
1170
+ if (this.args.handleOnly) return;
1171
+ this.#contentPointerStart = {
1172
+ x: event.pageX,
1173
+ y: event.pageY
1174
+ };
1175
+ this.onPress(event);
1176
+ };
1177
+ #contentPointerMove = event => {
1178
+ this.#lastKnownPointerEvent = event;
1179
+ if (this.args.handleOnly || !this.#contentPointerStart) return;
1180
+ const y = event.pageY - this.#contentPointerStart.y;
1181
+ const x = event.pageX - this.#contentPointerStart.x;
1182
+ const threshold = event.pointerType === 'touch' ? 10 : 2;
1183
+ if (this.#isDeltaInDirection({
1184
+ x,
1185
+ y
1186
+ }, threshold)) this.onDrag(event);else if (Math.abs(x) > threshold || Math.abs(y) > threshold) this.#contentPointerStart = null;
1187
+ };
1188
+ #contentPointerUp = event => {
1189
+ this.#contentPointerStart = null;
1190
+ this.#wasBeyondThePoint = false;
1191
+ this.onRelease(event);
1192
+ };
1193
+ #contentPointerOut = () => this.#contentPointerUp(this.#lastKnownPointerEvent);
1194
+ #contentContextMenu = () => {
1195
+ if (this.#lastKnownPointerEvent) this.#contentPointerUp(this.#lastKnownPointerEvent);
1196
+ };
1197
+
1198
+ // ----- The parts' attributes and listeners, beside a Dialog's ------------------------------
1199
+
1200
+ /** vaul's attributes and pointer listeners on the content, beside the Dialog's content part. */
1201
+ drawerContent = part(() => ({
1202
+ attributes: {
1203
+ 'data-vaul-drawer': '',
1204
+ 'data-vaul-drawer-direction': this.direction,
1205
+ 'data-vaul-snap-points': this.isOpen && this.hasSnapPoints ? 'true' : 'false',
1206
+ 'data-vaul-custom-container': 'false',
1207
+ 'data-vaul-animate': this.#shouldAnimate ? 'true' : 'false',
1208
+ 'data-snap-point': this.hasSnapPoints ? String(this.activeSnapPoint) : undefined
1209
+ },
1210
+ // The Dialog's content part keeps the element too, but it is installed after this one, and
1211
+ // the drawer's own modifiers need it from the start.
1212
+ element: element => {
1213
+ this.contentElement = element;
1214
+ return () => {
1215
+ if (this.contentElement === element) this.contentElement = null;
1216
+ };
1217
+ },
1218
+ on: {
1219
+ pointerdown: this.#contentPointerDown,
1220
+ pointermove: this.#contentPointerMove,
1221
+ pointerup: this.#contentPointerUp,
1222
+ pointerout: this.#contentPointerOut,
1223
+ contextmenu: this.#contentContextMenu
1224
+ }
1225
+ }));
1226
+
1227
+ /** vaul's attributes on the overlay, beside the Dialog's overlay part. */
1228
+ drawerOverlay = part(() => ({
1229
+ attributes: {
1230
+ 'data-vaul-overlay': '',
1231
+ 'data-vaul-snap-points': this.isOpen && this.hasSnapPoints ? 'true' : 'false',
1232
+ 'data-vaul-snap-points-overlay': this.isOpen && this.shouldFade ? 'true' : 'false',
1233
+ 'data-vaul-animate': this.#shouldAnimate ? 'true' : 'false'
1234
+ },
1235
+ on: {
1236
+ mouseup: event => this.onRelease(event)
1237
+ }
1238
+ }));
1239
+
1240
+ // ----- The handle (vaul's Handle) ----------------------------------------------------------
1241
+
1242
+ #cancelHandleInteraction = () => this.#machine.handleCancel();
1243
+
1244
+ /** A tap on the handle: the next snap point, or closed after the last. */
1245
+ #cycleSnapPoints(isLongPress) {
1246
+ // A tap while dragging, or a long press, isn't a tap.
1247
+ if (this.isDragging || this.#preventCycle || isLongPress) {
1248
+ this.#cancelHandleInteraction();
1249
+ return;
1250
+ }
1251
+ this.#cancelHandleInteraction();
1252
+ const snapPoints = this.snapPoints;
1253
+ // Without snap points there is nothing to cycle. (vaul 1.1.2 closes a drawer that isn't
1254
+ // dismissible here, which its own `dismissible` contradicts; Joinery doesn't.)
1255
+ if (!snapPoints || snapPoints.length === 0) return;
1256
+ if (this.isLastSnapPoint && this.dismissible) {
1257
+ this.closeDrawer();
1258
+ return;
1259
+ }
1260
+ const index = snapPoints.findIndex(point => point === this.activeSnapPoint);
1261
+ if (index === -1) return;
1262
+ this.setActiveSnapPoint(snapPoints[index + 1] ?? null);
1263
+ }
1264
+
1265
+ /** Makes your own element the handle: `<div {{d.handle}}>`. */
1266
+ handle = part(named => ({
1267
+ attributes: {
1268
+ 'data-vaul-drawer-visible': this.isOpen ? 'true' : 'false',
1269
+ 'data-vaul-handle': '',
1270
+ 'aria-hidden': 'true',
1271
+ 'data-slot': `${this.slot}-handle`,
1272
+ 'data-test-jn-part': 'handle'
1273
+ },
1274
+ on: {
1275
+ click: () => {
1276
+ // A click that ends a long press isn't a tap (vaul's shouldCancelInteraction).
1277
+ if (this.#machine.isLongPress) {
1278
+ this.#cancelHandleInteraction();
1279
+ return;
1280
+ }
1281
+ this.#preventCycle = Boolean(named.preventCycle);
1282
+ this.#machine.tap();
1283
+ },
1284
+ pointercancel: this.#cancelHandleInteraction,
1285
+ pointerdown: event => {
1286
+ if (this.args.handleOnly) this.onPress(event);
1287
+ // Held long, it isn't a tap.
1288
+ this.#machine.handleDown();
1289
+ },
1290
+ pointermove: event => {
1291
+ if (this.args.handleOnly) this.onDrag(event);
1292
+ }
1293
+ }
1294
+ }));
1295
+ }
1296
+
1297
+ // The parts a Drawer renders beside a Dialog's: its content, overlay and handle, and the
1298
+ // modifiers that run vaul's effects on them. Bundled into @ember-joinery/primitives/drawer.
1299
+ /**
1300
+ * What vaul's Content does as its state changes: its snap point's offset as
1301
+ * `--snap-point-height`, `data-vaul-delayed-snap-points` a frame after it mounts (so it slides
1302
+ * to its first snap point), a move to each new snap point, the scaled background while it is
1303
+ * open, and the window and keyboard listeners its snap points and inputs need.
1304
+ */
1305
+ class DrawerContentEffects extends Modifier {
1306
+ #element;
1307
+ #snapPoint;
1308
+ #unscale;
1309
+ #frame;
1310
+ modify(element, _, {
1311
+ drawer
1312
+ }) {
1313
+ if (!this.#element) this.#install(element, drawer);
1314
+ // vaul renders these on every render; they are read here, so a change runs this again.
1315
+ const offsets = drawer.snapPointsOffset;
1316
+ const index = drawer.activeSnapPointIndex;
1317
+ const offset = offsets[Math.max(index ?? 0, 0)];
1318
+ if (offsets.length > 0) element.style.setProperty('--snap-point-height', `${offset}px`);else element.style.removeProperty('--snap-point-height');
1319
+ // A new snap point, or the old one measured again: move there (but not as it mounts, where
1320
+ // its CSS slides it in from off screen).
1321
+ const previous = this.#snapPoint;
1322
+ this.#snapPoint = {
1323
+ index,
1324
+ offset: index === null ? undefined : offsets[index]
1325
+ };
1326
+ if (previous && index !== null && index !== -1 && (previous.index !== index || previous.offset !== offsets[index])) {
1327
+ drawer.applySnapPoint(index);
1328
+ }
1329
+ const scale = drawer.isOpen && Boolean(drawer.args.shouldScaleBackground);
1330
+ if (scale && !this.#unscale) this.#unscale = drawer.scaleBackground(element) ?? (() => {});else if (!scale && this.#unscale) this.#release();
1331
+ }
1332
+ #install(element, drawer) {
1333
+ this.#element = element;
1334
+ element.setAttribute('data-vaul-delayed-snap-points', 'false');
1335
+ const window = element.ownerDocument.defaultView;
1336
+ if (drawer.hasSnapPoints && window) {
1337
+ this.#frame = window.requestAnimationFrame(() => {
1338
+ element.setAttribute('data-vaul-delayed-snap-points', 'true');
1339
+ });
1340
+ }
1341
+ window?.addEventListener('resize', drawer.measure);
1342
+ window?.visualViewport?.addEventListener('resize', drawer.onVisualViewportChange);
1343
+ registerDestructor(this, () => {
1344
+ if (this.#frame !== undefined) window?.cancelAnimationFrame(this.#frame);
1345
+ window?.removeEventListener('resize', drawer.measure);
1346
+ window?.visualViewport?.removeEventListener('resize', drawer.onVisualViewportChange);
1347
+ this.#release();
1348
+ });
1349
+ }
1350
+ #release() {
1351
+ const unscale = this.#unscale;
1352
+ this.#unscale = undefined;
1353
+ unscale?.();
1354
+ }
1355
+ }
1356
+ /** On the root: tells the drawer each time it opens or closes, however that came about. */class DrawerRoot extends Modifier {
1357
+ #open;
1358
+ modify(_, __, {
1359
+ drawer
1360
+ }) {
1361
+ const open = drawer.isOpen;
1362
+ if (this.#open === undefined) {
1363
+ this.#open = open;
1364
+ if (open) drawer.openChanged(true, true);
1365
+ drawer.rendered();
1366
+ registerDestructor(this, () => drawer.teardown());
1367
+ return;
1368
+ }
1369
+ if (open === this.#open) return;
1370
+ this.#open = open;
1371
+ drawer.openChanged(open);
1372
+ }
1373
+ }
1374
+ /**
1375
+ * The drawer itself: a Dialog's content (in the top layer, with its role, focus and dismissal),
1376
+ * with vaul's attributes, and its pointer listeners, which drag it.
1377
+ */
1378
+ const DrawerContent = setComponentTemplate(precompileTemplate("<DialogContent @dialog={{@drawer}} @as={{@as}} @forceMount={{@forceMount}} @onOpenAutoFocus={{@onOpenAutoFocus}} @onCloseAutoFocus={{@onCloseAutoFocus}} @onEscapeKeyDown={{@onEscapeKeyDown}} @onPointerDownOutside={{@onPointerDownOutside}} @onFocusOutside={{@onFocusOutside}} @onInteractOutside={{@onInteractOutside}} ...attributes {{@drawer.drawerContent}} {{DrawerContentEffects drawer=@drawer}}>{{yield}}</DialogContent>", {
1379
+ strictMode: true,
1380
+ scope: () => ({
1381
+ DialogContent,
1382
+ DrawerContentEffects
1383
+ })
1384
+ }), templateOnly());
1385
+ /** What covers the page behind a modal drawer, fading as the drawer is dragged. */const DrawerOverlay = setComponentTemplate(precompileTemplate("<DialogOverlay @dialog={{@drawer}} @as={{@as}} @forceMount={{@forceMount}} ...attributes {{@drawer.drawerOverlay}} />", {
1386
+ strictMode: true,
1387
+ scope: () => ({
1388
+ DialogOverlay
1389
+ })
1390
+ }), templateOnly());
1391
+ /**
1392
+ * vaul's Handle: a bar to grab. A tap moves the drawer to its next snap point (and closes it
1393
+ * after the last), and with `@handleOnly` it is the only place a drag starts. It is hidden from
1394
+ * screen readers, as vaul's is: the keyboard has the drawer's own controls.
1395
+ */
1396
+ const DrawerHandle = setComponentTemplate(precompileTemplate("<div ...attributes {{@drawer.handle preventCycle=@preventCycle}}>\n <span data-vaul-handle-hitarea aria-hidden=\"true\">{{yield}}</span>\n</div>", {
1397
+ strictMode: true
1398
+ }), templateOnly());
1399
+
1400
+ /** What a `<Drawer>` yields: a Dialog's parts and state, with vaul's. */
1401
+
1402
+ /** A `<button type="button">`, or `@as`, that opens the drawer. */const DrawerTrigger = DialogTrigger;
1403
+ /**
1404
+ * A panel that slides in from an edge of the screen and follows a drag, as vaul's Drawer (which
1405
+ * shadcn's Drawer is built on), covering ember-primitives' Drawer too. It is a
1406
+ * [Dialog](./dialog) underneath, so it renders no box of its own, and yields its parts:
1407
+ *
1408
+ * <Drawer as |d|>
1409
+ * <d.Trigger>Open</d.Trigger>
1410
+ * <d.Overlay />
1411
+ * <d.Content>
1412
+ * <d.Handle />
1413
+ * <d.Title>Move goal</d.Title>
1414
+ * <d.Description>Set your daily activity goal.</d.Description>
1415
+ * <d.Close>Done</d.Close>
1416
+ * </d.Content>
1417
+ * </Drawer>
1418
+ *
1419
+ * Everything a Dialog does, it does: the top layer, Escape and a press outside, focus in and
1420
+ * back, the inert page and its locked scroll. Beside that, as vaul's:
1421
+ *
1422
+ * - a drag along its axis moves it, and letting go fast enough, or far enough (a quarter of it,
1423
+ * `@closeThreshold`), closes it, while a short one springs back;
1424
+ * - `@snapPoints` gives it places to rest (`[0.25, 0.5, 1]`, fractions of the screen, or
1425
+ * `'148px'`), and the overlay fades in from `@fadeFromIndex`;
1426
+ * - `@shouldScaleBackground` scales the element marked `data-vaul-drawer-wrapper` back while
1427
+ * it is open;
1428
+ * - `d.Nested` is a drawer that steps this one back as it opens.
1429
+ *
1430
+ * Its slides and its resting places at the snap points are vaul's CSS, keyed on its
1431
+ * `data-vaul-*` attributes; Joinery's styled Drawer ships it in joinery.css.
1432
+ */
1433
+ class Drawer extends Component {
1434
+ drawer = new DrawerController(this);
1435
+ static {
1436
+ setComponentTemplate(precompileTemplate("<div id={{this.drawer.id}} data-test-jn={{this.drawer.slot}} data-test-jn-name={{@name}} ...attributes {{displayContents}} {{DrawerRoot drawer=this.drawer}}>\n {{yield (hash Trigger=(component DrawerTrigger part=this.drawer.trigger) Overlay=(component DrawerOverlay drawer=this.drawer) Content=(component DrawerContent drawer=this.drawer) Handle=(component DrawerHandle drawer=this.drawer) Title=(component DialogTitle part=this.drawer.title) Description=(component DialogDescription part=this.drawer.description) Close=(component DialogClose part=this.drawer.close) Nested=(component Drawer parent=this.drawer) trigger=this.drawer.trigger close=this.drawer.close title=this.drawer.title description=this.drawer.description handle=this.drawer.handle isOpen=this.drawer.isOpen isModal=this.drawer.isModal isDragging=this.drawer.isDragging direction=this.drawer.direction activeSnapPoint=this.drawer.activeSnapPoint setActiveSnapPoint=this.drawer.setActiveSnapPoint open=this.drawer.show toggle=this.drawer.toggle setOpen=this.drawer.setOpen returnValue=this.drawer.returnValue controller=this.drawer)}}\n</div>", {
1437
+ strictMode: true,
1438
+ scope: () => ({
1439
+ displayContents,
1440
+ DrawerRoot,
1441
+ hash,
1442
+ DrawerTrigger,
1443
+ DrawerOverlay,
1444
+ DrawerContent,
1445
+ DrawerHandle,
1446
+ DialogTitle,
1447
+ DialogDescription,
1448
+ DialogClose,
1449
+ Drawer
1450
+ })
1451
+ }), this);
1452
+ }
1453
+ }
1454
+
1455
+ export { DRAG_CLASS, Drawer, DrawerController };
1456
+ //# sourceMappingURL=drawer.js.map