motionary 0.0.0-stage → 6.2.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 (374) hide show
  1. package/CHANGELOG.md +803 -0
  2. package/LICENSE +21 -0
  3. package/README.md +218 -2
  4. package/README_ja.md +219 -0
  5. package/README_zh.md +219 -0
  6. package/bin/usa-codemod-5.mjs +79 -0
  7. package/bin/usa-codemod-6.mjs +146 -0
  8. package/dist/chunks/base-BaQV-2ha.cjs +436 -0
  9. package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
  10. package/dist/chunks/base-C_3cAoRz.js +404 -0
  11. package/dist/chunks/base-C_3cAoRz.js.map +1 -0
  12. package/dist/chunks/bind-B_CTL6Qn.js +22 -0
  13. package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
  14. package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
  15. package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
  16. package/dist/chunks/core-B5T0dhFH.cjs +920 -0
  17. package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
  18. package/dist/chunks/core-BGAyaY6L.cjs +265 -0
  19. package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
  20. package/dist/chunks/core-D7cVumUu.js +909 -0
  21. package/dist/chunks/core-D7cVumUu.js.map +1 -0
  22. package/dist/chunks/core-VEBw36QK.js +260 -0
  23. package/dist/chunks/core-VEBw36QK.js.map +1 -0
  24. package/dist/chunks/core-ps8uvYuN.js +181 -0
  25. package/dist/chunks/core-ps8uvYuN.js.map +1 -0
  26. package/dist/chunks/core-zq17EeCI.cjs +185 -0
  27. package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
  28. package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
  29. package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
  30. package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
  31. package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
  32. package/dist/chunks/generative-D2YyhaeO.js +336 -0
  33. package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
  34. package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
  35. package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
  36. package/dist/chunks/gpu-Bu7qwugO.js +380 -0
  37. package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
  38. package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
  39. package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
  40. package/dist/chunks/index-tags-DucKMQr_.js +26 -0
  41. package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
  42. package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
  43. package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
  44. package/dist/chunks/presets-BYBVJVeP.js +226 -0
  45. package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
  46. package/dist/chunks/presets-CUHys3sK.cjs +233 -0
  47. package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
  48. package/dist/chunks/registry-CKNLQpwd.js +121 -0
  49. package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
  50. package/dist/chunks/registry-DehBVRDV.cjs +131 -0
  51. package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
  52. package/dist/chunks/spring-CbvHfVtP.js +219 -0
  53. package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
  54. package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
  55. package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
  56. package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
  57. package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
  58. package/dist/chunks/stagger-DtMKo2SK.js +84 -0
  59. package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
  60. package/dist/chunks/variants-BhjyddG8.cjs +39 -0
  61. package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
  62. package/dist/chunks/variants-DRlKVHvu.js +35 -0
  63. package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
  64. package/dist/components/a11y.cjs +276 -0
  65. package/dist/components/a11y.cjs.map +1 -0
  66. package/dist/components/a11y.d.cts +131 -0
  67. package/dist/components/a11y.d.ts +131 -0
  68. package/dist/components/a11y.js +259 -0
  69. package/dist/components/a11y.js.map +1 -0
  70. package/dist/components/angular.cjs +76 -0
  71. package/dist/components/angular.cjs.map +1 -0
  72. package/dist/components/angular.d.cts +1734 -0
  73. package/dist/components/angular.d.ts +1734 -0
  74. package/dist/components/angular.js +70 -0
  75. package/dist/components/angular.js.map +1 -0
  76. package/dist/components/background.cjs +659 -0
  77. package/dist/components/background.cjs.map +1 -0
  78. package/dist/components/background.css +9 -0
  79. package/dist/components/background.d.cts +166 -0
  80. package/dist/components/background.d.ts +166 -0
  81. package/dist/components/background.js +647 -0
  82. package/dist/components/background.js.map +1 -0
  83. package/dist/components/bridge.cjs +154 -0
  84. package/dist/components/bridge.cjs.map +1 -0
  85. package/dist/components/bridge.d.cts +63 -0
  86. package/dist/components/bridge.d.ts +63 -0
  87. package/dist/components/bridge.js +147 -0
  88. package/dist/components/bridge.js.map +1 -0
  89. package/dist/components/cards.cjs +561 -0
  90. package/dist/components/cards.cjs.map +1 -0
  91. package/dist/components/cards.css +6 -0
  92. package/dist/components/cards.d.cts +115 -0
  93. package/dist/components/cards.d.ts +115 -0
  94. package/dist/components/cards.js +554 -0
  95. package/dist/components/cards.js.map +1 -0
  96. package/dist/components/click.cjs +877 -0
  97. package/dist/components/click.cjs.map +1 -0
  98. package/dist/components/click.css +9 -0
  99. package/dist/components/click.d.cts +218 -0
  100. package/dist/components/click.d.ts +218 -0
  101. package/dist/components/click.js +863 -0
  102. package/dist/components/click.js.map +1 -0
  103. package/dist/components/depth.cjs +250 -0
  104. package/dist/components/depth.cjs.map +1 -0
  105. package/dist/components/depth.css +3 -0
  106. package/dist/components/depth.d.cts +86 -0
  107. package/dist/components/depth.d.ts +86 -0
  108. package/dist/components/depth.js +242 -0
  109. package/dist/components/depth.js.map +1 -0
  110. package/dist/components/effects.cjs +2258 -0
  111. package/dist/components/effects.cjs.map +1 -0
  112. package/dist/components/effects.d.cts +545 -0
  113. package/dist/components/effects.d.ts +545 -0
  114. package/dist/components/effects.js +2200 -0
  115. package/dist/components/effects.js.map +1 -0
  116. package/dist/components/feedback.cjs +442 -0
  117. package/dist/components/feedback.cjs.map +1 -0
  118. package/dist/components/feedback.css +7 -0
  119. package/dist/components/feedback.d.cts +144 -0
  120. package/dist/components/feedback.d.ts +144 -0
  121. package/dist/components/feedback.js +433 -0
  122. package/dist/components/feedback.js.map +1 -0
  123. package/dist/components/fx-gpu.cjs +12 -0
  124. package/dist/components/fx-gpu.cjs.map +1 -0
  125. package/dist/components/fx-gpu.d.cts +63 -0
  126. package/dist/components/fx-gpu.d.ts +63 -0
  127. package/dist/components/fx-gpu.js +5 -0
  128. package/dist/components/fx-gpu.js.map +1 -0
  129. package/dist/components/fx.cjs +169 -0
  130. package/dist/components/fx.cjs.map +1 -0
  131. package/dist/components/fx.css +3 -0
  132. package/dist/components/fx.d.cts +114 -0
  133. package/dist/components/fx.d.ts +114 -0
  134. package/dist/components/fx.js +156 -0
  135. package/dist/components/fx.js.map +1 -0
  136. package/dist/components/fx2.cjs +25 -0
  137. package/dist/components/fx2.cjs.map +1 -0
  138. package/dist/components/fx2.d.cts +136 -0
  139. package/dist/components/fx2.d.ts +136 -0
  140. package/dist/components/fx2.js +17 -0
  141. package/dist/components/fx2.js.map +1 -0
  142. package/dist/components/gesture.cjs +209 -0
  143. package/dist/components/gesture.cjs.map +1 -0
  144. package/dist/components/gesture.css +3 -0
  145. package/dist/components/gesture.d.cts +134 -0
  146. package/dist/components/gesture.d.ts +134 -0
  147. package/dist/components/gesture.js +203 -0
  148. package/dist/components/gesture.js.map +1 -0
  149. package/dist/components/interaction.cjs +424 -0
  150. package/dist/components/interaction.cjs.map +1 -0
  151. package/dist/components/interaction.css +8 -0
  152. package/dist/components/interaction.d.cts +115 -0
  153. package/dist/components/interaction.d.ts +115 -0
  154. package/dist/components/interaction.js +416 -0
  155. package/dist/components/interaction.js.map +1 -0
  156. package/dist/components/jsx.cjs +3 -0
  157. package/dist/components/jsx.cjs.map +1 -0
  158. package/dist/components/jsx.d.cts +53 -0
  159. package/dist/components/jsx.d.ts +53 -0
  160. package/dist/components/jsx.js +2 -0
  161. package/dist/components/jsx.js.map +1 -0
  162. package/dist/components/layout.cjs +257 -0
  163. package/dist/components/layout.cjs.map +1 -0
  164. package/dist/components/layout.css +3 -0
  165. package/dist/components/layout.d.cts +99 -0
  166. package/dist/components/layout.d.ts +99 -0
  167. package/dist/components/layout.js +249 -0
  168. package/dist/components/layout.js.map +1 -0
  169. package/dist/components/lazy.cjs +92 -0
  170. package/dist/components/lazy.cjs.map +1 -0
  171. package/dist/components/lazy.d.cts +48 -0
  172. package/dist/components/lazy.d.ts +48 -0
  173. package/dist/components/lazy.js +87 -0
  174. package/dist/components/lazy.js.map +1 -0
  175. package/dist/components/lite.cjs +11095 -0
  176. package/dist/components/lite.cjs.map +1 -0
  177. package/dist/components/lite.d.cts +4 -0
  178. package/dist/components/lite.d.ts +4 -0
  179. package/dist/components/lite.js +10827 -0
  180. package/dist/components/lite.js.map +1 -0
  181. package/dist/components/packs.cjs +192 -0
  182. package/dist/components/packs.cjs.map +1 -0
  183. package/dist/components/packs.css +3 -0
  184. package/dist/components/packs.d.cts +72 -0
  185. package/dist/components/packs.d.ts +72 -0
  186. package/dist/components/packs.js +184 -0
  187. package/dist/components/packs.js.map +1 -0
  188. package/dist/components/page.cjs +824 -0
  189. package/dist/components/page.cjs.map +1 -0
  190. package/dist/components/page.css +11 -0
  191. package/dist/components/page.d.cts +249 -0
  192. package/dist/components/page.d.ts +249 -0
  193. package/dist/components/page.js +799 -0
  194. package/dist/components/page.js.map +1 -0
  195. package/dist/components/perf.cjs +120 -0
  196. package/dist/components/perf.cjs.map +1 -0
  197. package/dist/components/perf.d.cts +98 -0
  198. package/dist/components/perf.d.ts +98 -0
  199. package/dist/components/perf.js +110 -0
  200. package/dist/components/perf.js.map +1 -0
  201. package/dist/components/physics.cjs +448 -0
  202. package/dist/components/physics.cjs.map +1 -0
  203. package/dist/components/physics.css +5 -0
  204. package/dist/components/physics.d.cts +189 -0
  205. package/dist/components/physics.d.ts +189 -0
  206. package/dist/components/physics.js +430 -0
  207. package/dist/components/physics.js.map +1 -0
  208. package/dist/components/react.cjs +96 -0
  209. package/dist/components/react.cjs.map +1 -0
  210. package/dist/components/react.d.cts +18 -0
  211. package/dist/components/react.d.ts +18 -0
  212. package/dist/components/react.js +91 -0
  213. package/dist/components/react.js.map +1 -0
  214. package/dist/components/reveal.cjs +362 -0
  215. package/dist/components/reveal.cjs.map +1 -0
  216. package/dist/components/reveal.css +5 -0
  217. package/dist/components/reveal.d.cts +105 -0
  218. package/dist/components/reveal.d.ts +105 -0
  219. package/dist/components/reveal.js +353 -0
  220. package/dist/components/reveal.js.map +1 -0
  221. package/dist/components/solid.cjs +86 -0
  222. package/dist/components/solid.cjs.map +1 -0
  223. package/dist/components/solid.d.cts +1751 -0
  224. package/dist/components/solid.d.ts +1751 -0
  225. package/dist/components/solid.js +82 -0
  226. package/dist/components/solid.js.map +1 -0
  227. package/dist/components/svelte.cjs +68 -0
  228. package/dist/components/svelte.cjs.map +1 -0
  229. package/dist/components/svelte.d.cts +1733 -0
  230. package/dist/components/svelte.d.ts +1733 -0
  231. package/dist/components/svelte.js +64 -0
  232. package/dist/components/svelte.js.map +1 -0
  233. package/dist/components/svg.cjs +359 -0
  234. package/dist/components/svg.cjs.map +1 -0
  235. package/dist/components/svg.css +3 -0
  236. package/dist/components/svg.d.cts +113 -0
  237. package/dist/components/svg.d.ts +113 -0
  238. package/dist/components/svg.js +347 -0
  239. package/dist/components/svg.js.map +1 -0
  240. package/dist/components/text.cjs +968 -0
  241. package/dist/components/text.cjs.map +1 -0
  242. package/dist/components/text.css +8 -0
  243. package/dist/components/text.d.cts +342 -0
  244. package/dist/components/text.d.ts +342 -0
  245. package/dist/components/text.js +947 -0
  246. package/dist/components/text.js.map +1 -0
  247. package/dist/components/timeline.cjs +109 -0
  248. package/dist/components/timeline.cjs.map +1 -0
  249. package/dist/components/timeline.css +3 -0
  250. package/dist/components/timeline.d.cts +155 -0
  251. package/dist/components/timeline.d.ts +155 -0
  252. package/dist/components/timeline.js +103 -0
  253. package/dist/components/timeline.js.map +1 -0
  254. package/dist/components/tokens.cjs +226 -0
  255. package/dist/components/tokens.cjs.map +1 -0
  256. package/dist/components/tokens.d.cts +74 -0
  257. package/dist/components/tokens.d.ts +74 -0
  258. package/dist/components/tokens.js +211 -0
  259. package/dist/components/tokens.js.map +1 -0
  260. package/dist/components/transitions.cjs +430 -0
  261. package/dist/components/transitions.cjs.map +1 -0
  262. package/dist/components/transitions.css +5 -0
  263. package/dist/components/transitions.d.cts +126 -0
  264. package/dist/components/transitions.d.ts +126 -0
  265. package/dist/components/transitions.js +423 -0
  266. package/dist/components/transitions.js.map +1 -0
  267. package/dist/components/ui.cjs +1050 -0
  268. package/dist/components/ui.cjs.map +1 -0
  269. package/dist/components/ui.css +14 -0
  270. package/dist/components/ui.d.cts +224 -0
  271. package/dist/components/ui.d.ts +224 -0
  272. package/dist/components/ui.js +1034 -0
  273. package/dist/components/ui.js.map +1 -0
  274. package/dist/components/vue.cjs +67 -0
  275. package/dist/components/vue.cjs.map +1 -0
  276. package/dist/components/vue.d.cts +1722 -0
  277. package/dist/components/vue.d.ts +1722 -0
  278. package/dist/components/vue.js +64 -0
  279. package/dist/components/vue.js.map +1 -0
  280. package/dist/components/webgl.cjs +459 -0
  281. package/dist/components/webgl.cjs.map +1 -0
  282. package/dist/components/webgl.css +3 -0
  283. package/dist/components/webgl.d.cts +133 -0
  284. package/dist/components/webgl.d.ts +133 -0
  285. package/dist/components/webgl.js +442 -0
  286. package/dist/components/webgl.js.map +1 -0
  287. package/dist/components/widgets.cjs +591 -0
  288. package/dist/components/widgets.cjs.map +1 -0
  289. package/dist/components/widgets.d.cts +110 -0
  290. package/dist/components/widgets.d.ts +110 -0
  291. package/dist/components/widgets.js +581 -0
  292. package/dist/components/widgets.js.map +1 -0
  293. package/dist/components.cjs +351 -0
  294. package/dist/components.cjs.map +1 -0
  295. package/dist/components.css +75 -0
  296. package/dist/components.d.cts +2997 -0
  297. package/dist/components.d.ts +2997 -0
  298. package/dist/components.js +106 -0
  299. package/dist/components.js.map +1 -0
  300. package/dist/components.umd.js +23 -0
  301. package/dist/components.umd.js.map +1 -0
  302. package/dist/element.cjs +97 -0
  303. package/dist/element.cjs.map +1 -0
  304. package/dist/element.d.cts +215 -0
  305. package/dist/element.d.ts +215 -0
  306. package/dist/element.js +95 -0
  307. package/dist/element.js.map +1 -0
  308. package/dist/element.umd.js +2 -0
  309. package/dist/element.umd.js.map +1 -0
  310. package/dist/index.cjs +149 -0
  311. package/dist/index.cjs.map +1 -0
  312. package/dist/index.d.cts +425 -0
  313. package/dist/index.d.ts +425 -0
  314. package/dist/index.js +131 -0
  315. package/dist/index.js.map +1 -0
  316. package/dist/index.umd.js +15 -0
  317. package/dist/index.umd.js.map +1 -0
  318. package/dist/presets/extended.cjs +243 -0
  319. package/dist/presets/extended.cjs.map +1 -0
  320. package/dist/presets/extended.d.cts +37 -0
  321. package/dist/presets/extended.d.ts +37 -0
  322. package/dist/presets/extended.js +239 -0
  323. package/dist/presets/extended.js.map +1 -0
  324. package/dist/presets-extended.umd.js +2 -0
  325. package/dist/presets-extended.umd.js.map +1 -0
  326. package/dist/react.cjs +68 -0
  327. package/dist/react.cjs.map +1 -0
  328. package/dist/react.d.cts +158 -0
  329. package/dist/react.d.ts +158 -0
  330. package/dist/react.js +65 -0
  331. package/dist/react.js.map +1 -0
  332. package/dist/solid.cjs +93 -0
  333. package/dist/solid.cjs.map +1 -0
  334. package/dist/solid.d.cts +249 -0
  335. package/dist/solid.d.ts +249 -0
  336. package/dist/solid.js +89 -0
  337. package/dist/solid.js.map +1 -0
  338. package/dist/svelte.cjs +66 -0
  339. package/dist/svelte.cjs.map +1 -0
  340. package/dist/svelte.d.cts +243 -0
  341. package/dist/svelte.d.ts +243 -0
  342. package/dist/svelte.js +63 -0
  343. package/dist/svelte.js.map +1 -0
  344. package/dist/vue.cjs +62 -0
  345. package/dist/vue.cjs.map +1 -0
  346. package/dist/vue.d.cts +158 -0
  347. package/dist/vue.d.ts +158 -0
  348. package/dist/vue.js +60 -0
  349. package/dist/vue.js.map +1 -0
  350. package/dist/widgets.umd.js +2 -0
  351. package/dist/widgets.umd.js.map +1 -0
  352. package/docs/API.md +147 -0
  353. package/docs/ROADMAP.md +14 -0
  354. package/docs/accessibility.md +60 -0
  355. package/docs/components.md +564 -0
  356. package/docs/deprecations.md +30 -0
  357. package/docs/frameworks-ssr.md +100 -0
  358. package/docs/hybrid-apps.md +145 -0
  359. package/docs/images/showcase-detail.png +0 -0
  360. package/docs/images/showcase-grid.png +0 -0
  361. package/docs/images/showcase-mobile.png +0 -0
  362. package/docs/migration-from-aos.md +67 -0
  363. package/docs/migration-from-gsap-scrolltrigger.md +80 -0
  364. package/docs/motion-tokens.css +31 -0
  365. package/docs/motion-tokens.md +46 -0
  366. package/docs/motion.tokens.json +132 -0
  367. package/docs/performance.md +24 -0
  368. package/docs/presets.md +310 -0
  369. package/docs/upgrading-3.md +21 -0
  370. package/docs/upgrading-4.md +65 -0
  371. package/docs/upgrading-5.md +31 -0
  372. package/docs/upgrading-6.md +32 -0
  373. package/docs/windows-apps.md +119 -0
  374. package/package.json +562 -4
@@ -0,0 +1,863 @@
1
+ import { x as defineElement, y as EASE_OUT, k as clamp, l as caf, q as now, r as raf } from '../chunks/base-C_3cAoRz.js';
2
+ import { d as springEasing, c as createSpring } from '../chunks/spring-CbvHfVtP.js';
3
+ import { b as burst, c as confetti, h as haptic, s as shake } from '../chunks/fx-Bs6IrV4Q.js';
4
+
5
+ var css$6 = "usa-click{position:relative;display:inline-block;overflow:hidden;isolation:isolate;border-radius:inherit;-webkit-tap-highlight-color:transparent;touch-action:manipulation}usa-click[block]{display:block}usa-click .usa-click-wave{position:absolute;border-radius:50%;pointer-events:none;z-index:-1;transform:scale(0);background:radial-gradient(circle,var(--usa-wave) 0 55%,color-mix(in srgb,var(--usa-wave) 40%,transparent) 70%,transparent 72%)}";
6
+
7
+ const CLICK_EFFECTS = ['ripple', 'burst', 'confetti', 'squish', 'press-spring', 'shake'];
8
+ function defineClick(tag = 'usa-click') {
9
+ return defineElement(tag, (Base) => class UsaClick extends Base {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._press = null;
13
+ }
14
+ static get observedAttributes() {
15
+ return ['effect', 'disabled'];
16
+ }
17
+ get effects() {
18
+ return this.str('effect', 'ripple').split(/[\s,]+/).filter(Boolean);
19
+ }
20
+ mount() {
21
+ this.listen(this, 'pointerdown', (e) => {
22
+ if (this.flag('disabled') || (e.pointerType === 'mouse' && e.button !== 0))
23
+ return;
24
+ this.down();
25
+ if (this.effects.includes('ripple'))
26
+ this.ripple(e.clientX, e.clientY);
27
+ });
28
+ const up = () => this.up();
29
+ this.listen(this, 'pointerup', up);
30
+ this.listen(this, 'pointerleave', up);
31
+ this.listen(this, 'pointercancel', up);
32
+ this.listen(this, 'click', (e) => {
33
+ if (this.flag('disabled'))
34
+ return;
35
+ const kb = e.detail === 0;
36
+ const r = this.getBoundingClientRect();
37
+ const x = kb ? r.left + r.width / 2 : e.clientX;
38
+ const y = kb ? r.top + r.height / 2 : e.clientY;
39
+ if (kb && this.effects.includes('ripple'))
40
+ this.ripple(x, y);
41
+ this.play(x, y);
42
+ if (this.effects.includes('shake') && this.str('trigger') === 'click')
43
+ this.shake();
44
+ });
45
+ this.listen(this, 'keydown', (e) => {
46
+ if ((e.key === 'Enter' || e.key === ' ') && !e.repeat)
47
+ this.down();
48
+ });
49
+ this.listen(this, 'keyup', up);
50
+ if (this.effects.includes('shake'))
51
+ this.listen(this, 'invalid', () => this.shake(), { capture: true });
52
+ }
53
+ /** Particles + haptics at client (x, y) (default: centre). */
54
+ play(x, y) {
55
+ if (x === undefined || y === undefined) {
56
+ const r = this.getBoundingClientRect();
57
+ x = r.left + r.width / 2;
58
+ y = r.top + r.height / 2;
59
+ }
60
+ const fx = this.effects;
61
+ const colors = this.str('color') ? this.str('color').split(',') : undefined;
62
+ if (fx.includes('burst'))
63
+ burst(x, y, { count: this.num('count', 12), shape: this.str('shape', 'circle'), colors });
64
+ if (fx.includes('confetti'))
65
+ confetti({ x, y, count: this.num('count', 60), colors, spread: 90, velocity: 0.8 });
66
+ if (this.hasAttribute('haptic'))
67
+ haptic(this.num('haptic', 10));
68
+ this.emit('click-effect', { x, y, effects: fx });
69
+ }
70
+ shake() {
71
+ shake(this);
72
+ if (this.hasAttribute('haptic'))
73
+ haptic([30, 40, 30]);
74
+ }
75
+ ripple(x, y) {
76
+ if (this.reduced)
77
+ return;
78
+ const r = this.getBoundingClientRect();
79
+ const cx = x - r.left;
80
+ const cy = y - r.top;
81
+ const radius = Math.hypot(Math.max(cx, r.width - cx), Math.max(cy, r.height - cy));
82
+ const wave = document.createElement('span');
83
+ wave.className = 'usa-click-wave';
84
+ wave.setAttribute('aria-hidden', 'true');
85
+ wave.style.cssText = `width:${radius * 2}px;height:${radius * 2}px;left:${cx - radius}px;top:${cy - radius}px;--usa-wave:${this.str('color', 'currentColor').split(',')[0]}`;
86
+ this.append(wave);
87
+ const a = this.motion(wave, [{ transform: 'scale(0)', opacity: 0.35 }, { transform: 'scale(1)', opacity: 0.25, offset: 0.6 }, { transform: 'scale(1.05)', opacity: 0 }], {
88
+ duration: 650,
89
+ easing: EASE_OUT,
90
+ fill: 'forwards',
91
+ });
92
+ if (a)
93
+ a.onfinish = () => wave.remove();
94
+ else
95
+ wave.remove();
96
+ }
97
+ down() {
98
+ if (this.hasAttribute('data-pressed'))
99
+ return;
100
+ const fx = this.effects;
101
+ if (!fx.includes('squish') && !fx.includes('press-spring'))
102
+ return;
103
+ this.setAttribute('data-pressed', '');
104
+ this._press?.cancel();
105
+ const to = this.reduced ? { opacity: 0.75 } : fx.includes('squish') ? { transform: 'scale(1.08, 0.86)' } : { transform: 'scale(0.94)' };
106
+ const from = this.reduced ? { opacity: 1 } : { transform: 'none' };
107
+ this._press = this.motion(this, [from, to], {
108
+ duration: 110,
109
+ easing: 'ease-out',
110
+ fill: 'forwards',
111
+ });
112
+ }
113
+ up() {
114
+ if (!this.hasAttribute('data-pressed'))
115
+ return;
116
+ this.removeAttribute('data-pressed');
117
+ const fx = this.effects;
118
+ this._press?.cancel();
119
+ if (this.reduced) {
120
+ this._press = this.motion(this, [{ opacity: 0.75 }, { opacity: 1 }], { duration: 150 });
121
+ return;
122
+ }
123
+ const from = fx.includes('squish') ? 'scale(1.08, 0.86)' : 'scale(0.94)';
124
+ const frames = fx.includes('squish')
125
+ ? [{ transform: from }, { transform: 'scale(0.92, 1.1)', offset: 0.3 }, { transform: 'scale(1.03, 0.97)', offset: 0.6 }, { transform: 'none' }]
126
+ : [{ transform: from }, { transform: 'none' }];
127
+ this._press = this.motion(this, frames, fx.includes('squish') ? { duration: 520, easing: 'ease-out' } : springEasing('bouncy'));
128
+ }
129
+ }, { id: 'click', text: css$6 });
130
+ }
131
+
132
+ var css$5 = "usa-button{position:relative;display:inline-block;isolation:isolate;-webkit-tap-highlight-color:transparent;touch-action:manipulation;vertical-align:middle}usa-button[role=\"button\"]{cursor:pointer}usa-button .usa-button-face{position:relative;overflow:hidden;will-change:transform;transform-origin:50% 60%;white-space:nowrap}usa-button[deform~=\"gooey\"] .usa-button-face{overflow:visible}usa-button[deform~=\"dent\"] .usa-button-face::after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity 0.2s ease;background:radial-gradient(circle at var(--usa-dent-x,50%) var(--usa-dent-y,50%),rgb(0 0 0 / 0.28),transparent 60%)}usa-button[deform~=\"dent\"][data-pressed] .usa-button-face::after{opacity:1}usa-button .usa-button-goo{position:absolute;inset:0;z-index:-1;pointer-events:none;filter:url(#usa-goo)}usa-button .usa-button-goo i{position:absolute;width:22px;height:22px;border-radius:50%;background:var(--usa-goo-bg);transform:translate(-50%,-50%) scale(0.4)}usa-button .usa-button-face[data-shape=\"circle\"],usa-button .usa-button-face[data-shape=\"icon\"]{padding-inline:0;aspect-ratio:1;border-radius:999px;display:inline-grid;place-items:center}usa-button .usa-button-face [data-label],usa-button .usa-button-face [data-icon]{transition:opacity 0.2s ease}usa-button .usa-button-face[data-shape=\"circle\"] [data-label],usa-button .usa-button-face[data-shape=\"icon\"] [data-label]{position:absolute;opacity:0;pointer-events:none}usa-button .usa-button-face[data-shape=\"circle\"] [data-icon]{opacity:0}usa-button .usa-button-status{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}usa-button .usa-button-status svg{grid-area:1 / 1;width:1.25em;height:1.25em;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round;opacity:0}usa-button .usa-button-spin circle{stroke-dasharray:60 100;transform-origin:50% 50%;animation:usa-btn-spin 0.8s linear infinite}usa-button .usa-button-ok path,usa-button .usa-button-err path{stroke-dasharray:1;stroke-dashoffset:1;transition:stroke-dashoffset 0.35s ease 0.1s}usa-button .usa-button-face[data-state=\"loading\"] .usa-button-spin,usa-button .usa-button-face[data-state=\"success\"] .usa-button-ok,usa-button .usa-button-face[data-state=\"error\"] .usa-button-err{opacity:1}usa-button .usa-button-face[data-state=\"success\"] .usa-button-ok path,usa-button .usa-button-face[data-state=\"error\"] .usa-button-err path{stroke-dashoffset:0}usa-button .usa-button-face:is([data-state=\"loading\"],[data-state=\"success\"],[data-state=\"error\"])>:not(.usa-button-status){opacity:0}usa-button .usa-button-face[data-state=\"success\"]{background:#16a34a;border-color:#16a34a;color:#fff}usa-button .usa-button-face[data-state=\"error\"]{background:#e5484d;border-color:#e5484d;color:#fff}usa-button .usa-button-face[data-state]{transition:background-color 0.25s ease,color 0.25s ease,border-radius 0.3s ease}@keyframes usa-btn-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){usa-button .usa-button-spin circle{animation-duration:2.4s}usa-button .usa-button-face,usa-button .usa-button-face *{transition:none !important}}";
133
+
134
+ const BUTTON_DEFORMS = ['squash', 'wobble', 'gooey', 'dent'];
135
+ let gooInjected = false;
136
+ function injectGoo() {
137
+ if (gooInjected || typeof document === 'undefined')
138
+ return;
139
+ gooInjected = true;
140
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
141
+ svg.setAttribute('aria-hidden', 'true');
142
+ svg.setAttribute('width', '0');
143
+ svg.setAttribute('height', '0');
144
+ svg.style.position = 'absolute';
145
+ svg.innerHTML = '<filter id="usa-goo"><feGaussianBlur in="SourceGraphic" stdDeviation="6" result="b"/><feColorMatrix in="b" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -9" result="g"/><feComposite in="SourceGraphic" in2="g" operator="atop"/></filter>';
146
+ document.body.appendChild(svg);
147
+ }
148
+ function defineButton(tag = 'usa-button') {
149
+ return defineElement(tag, (Base) => class UsaButton extends Base {
150
+ constructor() {
151
+ super(...arguments);
152
+ this._press = null;
153
+ this._status = null;
154
+ this._shapeBefore = null;
155
+ }
156
+ static get observedAttributes() {
157
+ return ['deform', 'state', 'shape', 'disabled'];
158
+ }
159
+ get target() {
160
+ return this.querySelector(':scope > button, :scope > a, :scope > [role="button"]') || this;
161
+ }
162
+ deforms() {
163
+ return this.str('deform').split(/[\s,]+/).filter(Boolean);
164
+ }
165
+ get shape() {
166
+ return this.str('shape', 'pill') || 'pill';
167
+ }
168
+ set shape(v) {
169
+ this.morphTo(v);
170
+ }
171
+ get state() {
172
+ return this.str('state', 'idle') || 'idle';
173
+ }
174
+ set state(v) {
175
+ this.setAttribute('state', v);
176
+ }
177
+ mount() {
178
+ const t = this.target;
179
+ if (t === this) {
180
+ this.setAttribute('role', 'button');
181
+ if (!this.hasAttribute('tabindex'))
182
+ this.tabIndex = 0;
183
+ }
184
+ t.classList.add('usa-button-face');
185
+ if (this.str('morph') === 'submit' && !t.querySelector('.usa-button-status')) {
186
+ const s = document.createElement('span');
187
+ s.className = 'usa-button-status';
188
+ s.setAttribute('aria-hidden', 'true');
189
+ s.innerHTML =
190
+ '<svg class="usa-button-spin" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" pathLength="100"/></svg>' +
191
+ '<svg class="usa-button-ok" viewBox="0 0 24 24"><path d="M5 12.5l4.2 4.2L19 7" pathLength="1"/></svg>' +
192
+ '<svg class="usa-button-err" viewBox="0 0 24 24"><path d="M7 7l10 10M17 7L7 17" pathLength="1"/></svg>';
193
+ t.append(s);
194
+ const live = document.createElement('span');
195
+ live.className = 'usa-sr';
196
+ live.setAttribute('role', 'status');
197
+ this.append(live);
198
+ this._status = live;
199
+ }
200
+ if (this.deforms().includes('gooey'))
201
+ injectGoo();
202
+ this.applyState();
203
+ this.listen(t, 'pointerdown', (e) => {
204
+ if (this.isOff() || (e.pointerType === 'mouse' && e.button !== 0))
205
+ return;
206
+ this.down(e.clientX, e.clientY);
207
+ });
208
+ for (const ev of ['pointerup', 'pointerleave', 'pointercancel'])
209
+ this.listen(t, ev, () => this.up());
210
+ this.listen(t, 'keydown', (e) => (e.key === 'Enter' || e.key === ' ') && !e.repeat && this.down());
211
+ this.listen(t, 'keyup', () => this.up());
212
+ this.listen(t, 'click', (e) => {
213
+ if (this.isOff()) {
214
+ if (this.state === 'loading')
215
+ e.preventDefault();
216
+ return;
217
+ }
218
+ if (this.deforms().includes('wobble'))
219
+ this.wobble();
220
+ if (this.hasAttribute('haptic'))
221
+ haptic(this.num('haptic', 10));
222
+ if (this.str('morph') === 'submit' && this.state === 'idle')
223
+ this.submit();
224
+ });
225
+ if (t === this)
226
+ this.listen(this, 'keydown', (e) => {
227
+ if ((e.key === 'Enter' || e.key === ' ') && !e.repeat) {
228
+ e.preventDefault();
229
+ this.click();
230
+ }
231
+ });
232
+ }
233
+ unmount() {
234
+ clearTimeout(this._timer);
235
+ this._press?.cancel();
236
+ }
237
+ changed(name) {
238
+ if (name === 'state')
239
+ this.applyState();
240
+ else if (name === 'shape')
241
+ this.target.setAttribute('data-shape', this.shape);
242
+ else {
243
+ super.changed(name);
244
+ }
245
+ }
246
+ isOff() {
247
+ return this.flag('disabled') || this.state === 'loading';
248
+ }
249
+ /* ------------------------------------------------ press deformations */
250
+ down(x, y) {
251
+ if (this.reduced || this.hasAttribute('data-pressed'))
252
+ return;
253
+ const d = this.deforms();
254
+ if (!d.length)
255
+ return;
256
+ this.setAttribute('data-pressed', '');
257
+ const t = this.target;
258
+ const r = t.getBoundingClientRect();
259
+ const px = x === undefined ? 0.5 : clamp((x - r.left) / (r.width || 1), 0, 1);
260
+ const py = y === undefined ? 0.5 : clamp((y - r.top) / (r.height || 1), 0, 1);
261
+ t.style.setProperty('--usa-dent-x', `${(px * 100).toFixed(1)}%`);
262
+ t.style.setProperty('--usa-dent-y', `${(py * 100).toFixed(1)}%`);
263
+ const parts = [];
264
+ if (d.includes('dent'))
265
+ parts.push(`perspective(600px) rotateX(${((0.5 - py) * -14).toFixed(2)}deg) rotateY(${((px - 0.5) * 14).toFixed(2)}deg) scale(0.97)`);
266
+ if (d.includes('squash'))
267
+ parts.push('scale(1.12, 0.84)');
268
+ if (d.includes('gooey')) {
269
+ parts.push('scale(0.96)');
270
+ this.goo(px, py);
271
+ }
272
+ if (!parts.length)
273
+ return;
274
+ this._press?.cancel();
275
+ this._press = this.motion(t, [{ transform: 'none' }, { transform: parts.join(' ') }], { duration: 110, easing: 'ease-out', fill: 'forwards' });
276
+ }
277
+ up() {
278
+ if (!this.hasAttribute('data-pressed'))
279
+ return;
280
+ this.removeAttribute('data-pressed');
281
+ const t = this.target;
282
+ const a = this._press;
283
+ const from = a?.effect?.getKeyframes?.().slice(-1)[0]?.transform;
284
+ a?.cancel();
285
+ if (!from)
286
+ return;
287
+ this._press = this.motion(t, [{ transform: from }, { transform: 'none' }], { ...springEasing(this.deforms().includes('squash') ? 'bouncy' : 'wobbly') });
288
+ }
289
+ wobble() {
290
+ if (this.reduced)
291
+ return;
292
+ const t = this.target;
293
+ const r = getComputedStyle(t).borderRadius || '12px';
294
+ this.motion(t, [
295
+ { borderRadius: r },
296
+ { borderRadius: '42% 58% 50% 50% / 60% 45% 55% 40%', offset: 0.2 },
297
+ { borderRadius: '58% 42% 45% 55% / 40% 60% 40% 60%', offset: 0.45 },
298
+ { borderRadius: '48% 52% 52% 48% / 52% 48% 52% 48%', offset: 0.7 },
299
+ { borderRadius: r },
300
+ ], { duration: 700, easing: 'ease-out' });
301
+ }
302
+ goo(px, py) {
303
+ const t = this.target;
304
+ const layer = document.createElement('span');
305
+ layer.className = 'usa-button-goo';
306
+ layer.setAttribute('aria-hidden', 'true');
307
+ layer.style.setProperty('--usa-goo-bg', getComputedStyle(t).backgroundColor || 'currentColor');
308
+ const drops = [];
309
+ for (let i = 0; i < 4; i++) {
310
+ const d = document.createElement('i');
311
+ d.style.left = `${(px * 100).toFixed(1)}%`;
312
+ d.style.top = `${(py * 100).toFixed(1)}%`;
313
+ layer.append(d);
314
+ drops.push(d);
315
+ }
316
+ this.prepend(layer);
317
+ let left = drops.length;
318
+ drops.forEach((d, i) => {
319
+ const ang = (i / drops.length) * Math.PI * 2 + 0.6;
320
+ const dist = 26 + (i % 2) * 12;
321
+ const a = this.motion(d, [
322
+ { transform: 'translate(-50%, -50%) scale(0.4)' },
323
+ { transform: `translate(calc(-50% + ${(Math.cos(ang) * dist).toFixed(1)}px), calc(-50% + ${(Math.sin(ang) * dist).toFixed(1)}px)) scale(1)`, offset: 0.45 },
324
+ { transform: 'translate(-50%, -50%) scale(0.2)' },
325
+ ], { duration: 700, easing: 'cubic-bezier(0.34, 1.3, 0.64, 1)', fill: 'forwards' });
326
+ const end = () => --left === 0 && layer.remove();
327
+ if (a)
328
+ a.onfinish = end;
329
+ else
330
+ end();
331
+ });
332
+ }
333
+ /* ------------------------------------------------ shape morph */
334
+ async morphTo(shape) {
335
+ const t = this.target;
336
+ const before = t.getBoundingClientRect();
337
+ this.setAttribute('shape', shape);
338
+ t.setAttribute('data-shape', shape);
339
+ if (this.reduced)
340
+ return;
341
+ const after = t.getBoundingClientRect();
342
+ if (!before.width || !after.width || Math.abs(before.width - after.width) < 0.5)
343
+ return;
344
+ const a = this.motion(t, [{ width: `${before.width}px` }, { width: `${after.width}px` }], springEasing('stiff'));
345
+ await a?.finished.catch(() => undefined);
346
+ }
347
+ /* ------------------------------------------------ submit morph */
348
+ submit() {
349
+ let settled = false;
350
+ const done = (ok = true) => {
351
+ if (settled)
352
+ return;
353
+ settled = true;
354
+ this.state = ok ? 'success' : 'error';
355
+ };
356
+ this.state = 'loading';
357
+ this.emit('submit', { done });
358
+ }
359
+ applyState() {
360
+ if (this.str('morph') !== 'submit')
361
+ return;
362
+ const t = this.target;
363
+ const s = this.state;
364
+ clearTimeout(this._timer);
365
+ t.setAttribute('data-state', s);
366
+ if (s === 'loading') {
367
+ if (this._shapeBefore === null)
368
+ this._shapeBefore = this.shape;
369
+ t.setAttribute('aria-busy', 'true');
370
+ this.morphTo('circle');
371
+ }
372
+ else {
373
+ t.removeAttribute('aria-busy');
374
+ }
375
+ if (s === 'error') {
376
+ shake(t);
377
+ if (this.hasAttribute('haptic'))
378
+ haptic([30, 40, 30]);
379
+ }
380
+ if (s === 'success' && !this.reduced) {
381
+ const ok = t.querySelector('.usa-button-ok');
382
+ if (ok)
383
+ this.motion(ok, [{ transform: 'scale(0.4)' }, { transform: 'scale(1)' }], springEasing('bouncy'));
384
+ }
385
+ if (this._status)
386
+ this._status.textContent = s === 'loading' ? 'Loading…' : s === 'success' ? 'Done' : s === 'error' ? 'Failed' : '';
387
+ if (s === 'success' || s === 'error') {
388
+ this._timer = setTimeout(() => {
389
+ this.state = 'idle';
390
+ }, this.num('reset', 1800));
391
+ }
392
+ if (s === 'idle' && this._shapeBefore !== null) {
393
+ const back = this._shapeBefore;
394
+ this._shapeBefore = null;
395
+ this.morphTo(back);
396
+ }
397
+ this.emit('state', { state: s });
398
+ }
399
+ }, { id: 'button', text: css$5 });
400
+ }
401
+
402
+ var css$4 = "usa-icon-morph{display:inline-grid;place-items:center;line-height:0;color:inherit;-webkit-tap-highlight-color:transparent;vertical-align:middle}usa-icon-morph svg{fill:currentColor;overflow:visible}usa-icon-morph[toggle]{cursor:pointer;border-radius:8px}usa-icon-morph[toggle]:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:3px}";
403
+
404
+ const C = [[12, 12], [12, 12], [12, 12], [12, 12]];
405
+ /**
406
+ * Morphable icons: every icon is three quads (four points each) on a 24×24
407
+ * grid, so any icon can morph into any other by interpolating points.
408
+ */
409
+ const MORPH_ICONS = {
410
+ play: [[[7, 5], [12.5, 8.25], [12.5, 15.75], [7, 19]], [[12.5, 8.25], [19, 12], [19, 12], [12.5, 15.75]], C],
411
+ pause: [[[6, 5], [10, 5], [10, 19], [6, 19]], [[14, 5], [18, 5], [18, 19], [14, 19]], C],
412
+ menu: [[[4, 6], [20, 6], [20, 8], [4, 8]], [[4, 11], [20, 11], [20, 13], [4, 13]], [[4, 16], [20, 16], [20, 18], [4, 18]]],
413
+ close: [[[5.2, 6.6], [6.6, 5.2], [18.8, 17.4], [17.4, 18.8]], C, [[17.4, 5.2], [18.8, 6.6], [6.6, 18.8], [5.2, 17.4]]],
414
+ plus: [[[11, 4], [13, 4], [13, 20], [11, 20]], [[4, 11], [20, 11], [20, 13], [4, 13]], C],
415
+ minus: [[[4, 11], [20, 11], [20, 13], [4, 13]], [[4, 11], [20, 11], [20, 13], [4, 13]], C],
416
+ check: [[[4.3, 12.7], [5.7, 11.3], [10.4, 16], [9, 17.4]], [[9, 17.4], [7.6, 16], [18.3, 5.3], [19.7, 6.7]], C],
417
+ 'arrow-right': [[[4, 11], [17, 11], [17, 13], [4, 13]], [[12.6, 6.4], [14, 5], [21, 12], [19.6, 13.4]], [[19.6, 10.6], [21, 12], [14, 19], [12.6, 17.6]]],
418
+ };
419
+ /** SVG path data for an icon, or for the interpolation `t` (0–1) between two. */
420
+ function morphPath(from, to = from, t = 0) {
421
+ const a = MORPH_ICONS[from] || MORPH_ICONS.menu;
422
+ const b = MORPH_ICONS[to] || a;
423
+ return a
424
+ .map((q, i) => {
425
+ const pts = q.map((p, j) => {
426
+ const r = b[i][j];
427
+ return `${(p[0] + (r[0] - p[0]) * t).toFixed(2)} ${(p[1] + (r[1] - p[1]) * t).toFixed(2)}`;
428
+ });
429
+ return `M${pts.join('L')}Z`;
430
+ })
431
+ .join('');
432
+ }
433
+ function defineIconMorph(tag = 'usa-icon-morph') {
434
+ return defineElement(tag, (Base) => class UsaIconMorph extends Base {
435
+ constructor() {
436
+ super(...arguments);
437
+ this._i = 0;
438
+ this._from = 'play';
439
+ this._to = 'play';
440
+ }
441
+ static get observedAttributes() {
442
+ return ['icons', 'size', 'toggle'];
443
+ }
444
+ list() {
445
+ return this.str('icons', 'play,pause').split(',').map((s) => s.trim()).filter((s) => MORPH_ICONS[s]);
446
+ }
447
+ get index() {
448
+ return this._i;
449
+ }
450
+ set index(v) {
451
+ this.show(v);
452
+ }
453
+ get icon() {
454
+ return this.list()[this._i] || 'play';
455
+ }
456
+ draw(t) {
457
+ this.querySelector('path')?.setAttribute('d', morphPath(this._from, this._to, t));
458
+ }
459
+ mount() {
460
+ const size = this.num('size', 24);
461
+ this.innerHTML = `<svg viewBox="0 0 24 24" width="${size}" height="${size}" aria-hidden="true" focusable="false"><path/></svg>`;
462
+ this._i = Math.max(0, Math.min(this.list().length - 1, this.num('index', 0)));
463
+ this._from = this._to = this.icon;
464
+ this._t = createSpring({ value: 1, spring: this.str('preset', 'wobbly'), onUpdate: (v) => this.draw(v) });
465
+ this.draw(1);
466
+ if (this.flag('toggle')) {
467
+ this.setAttribute('role', 'button');
468
+ if (!this.hasAttribute('tabindex'))
469
+ this.tabIndex = 0;
470
+ this.listen(this, 'click', () => this.next());
471
+ this.listen(this, 'keydown', (e) => {
472
+ if ((e.key === 'Enter' || e.key === ' ') && !e.repeat) {
473
+ e.preventDefault();
474
+ this.next();
475
+ }
476
+ });
477
+ }
478
+ this.label();
479
+ }
480
+ unmount() {
481
+ this._t?.stop();
482
+ }
483
+ label() {
484
+ const labels = this.str('labels').split(',').map((s) => s.trim());
485
+ const l = labels[this._i];
486
+ if (l)
487
+ this.setAttribute('aria-label', l);
488
+ if (!this.flag('toggle') && !l)
489
+ this.setAttribute('aria-hidden', 'true');
490
+ }
491
+ show(icon) {
492
+ const list = this.list();
493
+ const i = typeof icon === 'number' ? ((icon % list.length) + list.length) % list.length : list.indexOf(icon);
494
+ if (i < 0 || !this._t)
495
+ return;
496
+ const name = list[i];
497
+ // morph from wherever we are now (interruptible)
498
+ const cur = this._t.value;
499
+ this._from = cur >= 0.5 ? this._to : this._from;
500
+ this._to = name;
501
+ this._i = i;
502
+ this._t.jump(0);
503
+ this._t.set(1);
504
+ this.label();
505
+ this.emit('change', { index: i, icon: name });
506
+ }
507
+ next() {
508
+ this.show(this._i + 1);
509
+ }
510
+ }, { id: 'icon-morph', text: css$4 });
511
+ }
512
+
513
+ var css$3 = "usa-like{--usa-like-color:#f43f5e;display:inline-flex;align-items:center;gap:0.35em;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;vertical-align:middle}usa-like .usa-like-heart{fill:transparent;stroke:currentColor;stroke-width:1.8;transition:fill 0.2s ease,stroke 0.2s ease;overflow:visible}usa-like[liked] .usa-like-heart{fill:var(--usa-like-color);stroke:var(--usa-like-color)}usa-like .usa-like-count{font-variant-numeric:tabular-nums}usa-like[disabled]{opacity:0.5;cursor:not-allowed}usa-like:focus-visible{outline:2px solid var(--usa-like-color);outline-offset:3px;border-radius:8px}";
514
+
515
+ const HEART = 'M12 21s-7.5-4.6-9.6-9.2C.9 8.4 3 4.5 6.7 4.5c2.1 0 3.6 1.2 5.3 3.2 1.7-2 3.2-3.2 5.3-3.2 3.7 0 5.8 3.9 4.3 7.3C19.5 16.4 12 21 12 21z';
516
+ function defineLike(tag = 'usa-like') {
517
+ return defineElement(tag, (Base) => class UsaLike extends Base {
518
+ static get observedAttributes() {
519
+ return ['liked', 'count', 'label', 'disabled'];
520
+ }
521
+ get liked() {
522
+ return this.flag('liked');
523
+ }
524
+ set liked(v) {
525
+ this.setFlag('liked', v);
526
+ }
527
+ get count() {
528
+ return this.hasAttribute('count') ? this.num('count', 0) : null;
529
+ }
530
+ set count(v) {
531
+ if (v === null)
532
+ this.removeAttribute('count');
533
+ else
534
+ this.setAttribute('count', String(v));
535
+ }
536
+ mount() {
537
+ if (!this.querySelector(':scope > .usa-like-heart')) {
538
+ const size = this.num('size', 24);
539
+ this.insertAdjacentHTML('afterbegin', `<svg class="usa-like-heart" viewBox="0 0 24 24" width="${size}" height="${size}" aria-hidden="true"><path d="${HEART}"/></svg><span class="usa-like-count" aria-hidden="true"></span>`);
540
+ }
541
+ if (this.str('color'))
542
+ this.style.setProperty('--usa-like-color', this.str('color'));
543
+ this.setAttribute('role', 'button');
544
+ if (!this.hasAttribute('tabindex'))
545
+ this.tabIndex = 0;
546
+ this.sync();
547
+ this.listen(this, 'click', () => this.toggle());
548
+ this.listen(this, 'keydown', (e) => {
549
+ if ((e.key === 'Enter' || e.key === ' ') && !e.repeat) {
550
+ e.preventDefault();
551
+ this.toggle();
552
+ }
553
+ });
554
+ }
555
+ changed() {
556
+ this.sync();
557
+ }
558
+ sync() {
559
+ const c = this.count;
560
+ const label = this.str('label', 'Like');
561
+ this.setAttribute('aria-pressed', String(this.liked));
562
+ this.setAttribute('aria-label', c === null ? label : `${label} (${c})`);
563
+ this.toggleAttribute('aria-disabled', this.flag('disabled'));
564
+ const out = this.querySelector('.usa-like-count');
565
+ if (out)
566
+ out.textContent = c === null ? '' : new Intl.NumberFormat().format(c);
567
+ }
568
+ toggle(force) {
569
+ if (this.flag('disabled'))
570
+ return;
571
+ const next = force === undefined ? !this.liked : force;
572
+ if (next === this.liked)
573
+ return;
574
+ this.liked = next;
575
+ if (this.count !== null)
576
+ this.count = Math.max(0, this.count + (next ? 1 : -1));
577
+ this.sync();
578
+ const heart = this.querySelector('.usa-like-heart');
579
+ if (next && heart && !this.reduced) {
580
+ this.motion(heart, [{ transform: 'scale(0.4)' }, { transform: 'scale(1)' }], springEasing('bouncy'));
581
+ const r = heart.getBoundingClientRect();
582
+ burst(r.left + r.width / 2, r.top + r.height / 2, { count: 10, distance: 28, size: 5, colors: [getComputedStyle(this).getPropertyValue('--usa-like-color').trim() || '#f43f5e', '#fb923c', '#facc15'] });
583
+ }
584
+ if (this.hasAttribute('haptic'))
585
+ haptic(this.num('haptic', 12));
586
+ this.dispatchEvent(new Event('change', { bubbles: true }));
587
+ this.emit('change', { liked: next, count: this.count });
588
+ }
589
+ }, { id: 'like', text: css$3 });
590
+ }
591
+
592
+ var css$2 = "usa-hold{--usa-hold-color:#e5484d;position:relative;display:inline-flex;align-items:center;gap:0.5em;cursor:pointer;user-select:none;-webkit-user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent}usa-hold .usa-hold-ring{width:1.6em;height:1.6em;transform:rotate(-90deg);flex:none}usa-hold .usa-hold-ring circle{fill:none;stroke-width:3.5;stroke-linecap:round}usa-hold .usa-hold-ring circle:first-child{stroke:color-mix(in srgb,currentColor 18%,transparent)}usa-hold .usa-hold-ring circle:last-child{stroke:var(--usa-hold-color);stroke-dasharray:100;stroke-dashoffset:100}usa-hold[data-holding]{transform:scale(calc(1 - var(--usa-hold,0) * 0.05))}usa-hold[data-done] .usa-hold-ring{animation:usa-hold-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)}@keyframes usa-hold-pop{50%{transform:rotate(-90deg) scale(1.3)}}usa-hold[disabled]{opacity:0.5;cursor:not-allowed}usa-hold:focus-visible{outline:2px solid var(--usa-hold-color);outline-offset:3px;border-radius:10px}@media (prefers-reduced-motion:reduce){usa-hold[data-holding]{transform:none}usa-hold[data-done] .usa-hold-ring{animation:none}}";
593
+
594
+ function defineHold(tag = 'usa-hold') {
595
+ return defineElement(tag, (Base) => class UsaHold extends Base {
596
+ constructor() {
597
+ super(...arguments);
598
+ this._p = 0;
599
+ this._frame = 0;
600
+ this._holding = false;
601
+ }
602
+ static get observedAttributes() {
603
+ return ['duration', 'disabled'];
604
+ }
605
+ get progress() {
606
+ return this._p;
607
+ }
608
+ set(p) {
609
+ this._p = p;
610
+ this.style.setProperty('--usa-hold', p.toFixed(4));
611
+ const c = this.querySelector('.usa-hold-ring circle:last-child');
612
+ if (c)
613
+ c.style.strokeDashoffset = String(100 - p * 100);
614
+ }
615
+ mount() {
616
+ if (!this.querySelector(':scope > .usa-hold-ring')) {
617
+ this.insertAdjacentHTML('beforeend', '<svg class="usa-hold-ring" viewBox="0 0 36 36" aria-hidden="true"><circle cx="18" cy="18" r="15.9" pathLength="100"/><circle cx="18" cy="18" r="15.9" pathLength="100"/></svg>');
618
+ }
619
+ if (this.str('color'))
620
+ this.style.setProperty('--usa-hold-color', this.str('color'));
621
+ this.setAttribute('role', 'button');
622
+ if (!this.hasAttribute('tabindex'))
623
+ this.tabIndex = 0;
624
+ if (this.str('label'))
625
+ this.setAttribute('aria-label', this.str('label'));
626
+ this.setAttribute('aria-description', 'Press and hold to confirm');
627
+ this.set(0);
628
+ this.listen(this, 'pointerdown', (e) => (e.pointerType !== 'mouse' || e.button === 0) && this.start());
629
+ for (const t of ['pointerup', 'pointerleave', 'pointercancel'])
630
+ this.listen(this, t, () => this.stop());
631
+ this.listen(this, 'keydown', (e) => {
632
+ if (e.key === 'Enter' || e.key === ' ') {
633
+ e.preventDefault();
634
+ if (!e.repeat)
635
+ this.start();
636
+ }
637
+ });
638
+ this.listen(this, 'keyup', (e) => (e.key === 'Enter' || e.key === ' ') && this.stop());
639
+ this.listen(this, 'contextmenu', (e) => this._holding && e.preventDefault());
640
+ }
641
+ unmount() {
642
+ caf(this._frame);
643
+ this._holding = false;
644
+ }
645
+ start() {
646
+ if (this.flag('disabled') || this._holding)
647
+ return;
648
+ this._holding = true;
649
+ this.setAttribute('data-holding', '');
650
+ const dur = Math.max(100, this.num('duration', 1200));
651
+ let last = now();
652
+ const tick = () => {
653
+ const t = now();
654
+ const p = Math.min(1, this._p + (t - last) / dur);
655
+ last = t;
656
+ this.set(p);
657
+ this.emit('progress', { progress: p });
658
+ if (p >= 1) {
659
+ this._holding = false;
660
+ this.removeAttribute('data-holding');
661
+ this.setAttribute('data-done', '');
662
+ if (this.hasAttribute('haptic'))
663
+ haptic(20);
664
+ this.emit('confirm');
665
+ setTimeout(() => {
666
+ this.removeAttribute('data-done');
667
+ this.rewind();
668
+ }, 700);
669
+ return;
670
+ }
671
+ this._frame = raf(tick);
672
+ };
673
+ this._frame = raf(tick);
674
+ }
675
+ stop() {
676
+ if (!this._holding)
677
+ return;
678
+ this._holding = false;
679
+ caf(this._frame);
680
+ this.removeAttribute('data-holding');
681
+ if (this._p < 1) {
682
+ this.emit('cancel', { progress: this._p });
683
+ this.rewind();
684
+ }
685
+ }
686
+ rewind() {
687
+ let last = now();
688
+ const back = () => {
689
+ if (this._holding)
690
+ return;
691
+ const t = now();
692
+ const p = Math.max(0, this._p - (t - last) / 250);
693
+ last = t;
694
+ this.set(p);
695
+ if (p > 0)
696
+ this._frame = raf(back);
697
+ };
698
+ this._frame = raf(back);
699
+ }
700
+ cancel() {
701
+ this.stop();
702
+ }
703
+ }, { id: 'hold', text: css$2 });
704
+ }
705
+
706
+ var css$1 = "usa-double-tap{position:relative;display:block;touch-action:manipulation;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}usa-double-tap .usa-double-tap-icon{position:absolute;pointer-events:none;font-size:64px;line-height:1;color:#f43f5e;transform:translate(-50%,-50%);text-shadow:0 6px 18px rgb(0 0 0 / 0.35);z-index:2}";
707
+
708
+ function defineDoubleTap(tag = 'usa-double-tap') {
709
+ return defineElement(tag, (Base) => class UsaDoubleTap extends Base {
710
+ mount() {
711
+ let last = 0;
712
+ let lx = 0;
713
+ let ly = 0;
714
+ this.listen(this, 'pointerup', (e) => {
715
+ if (this.flag('disabled'))
716
+ return;
717
+ const t = e.timeStamp || Date.now();
718
+ if (t - last < this.num('delay', 300) && Math.hypot(e.clientX - lx, e.clientY - ly) < 40) {
719
+ last = 0;
720
+ this.pop(e.clientX, e.clientY);
721
+ }
722
+ else {
723
+ last = t;
724
+ lx = e.clientX;
725
+ ly = e.clientY;
726
+ }
727
+ });
728
+ this.listen(this, 'dblclick', (e) => e.preventDefault());
729
+ this.listen(this, 'keydown', (e) => e.key.toLowerCase() === 'l' && !e.repeat && this.pop());
730
+ }
731
+ pop(x, y) {
732
+ const r = this.getBoundingClientRect();
733
+ if (x === undefined || y === undefined) {
734
+ x = r.left + r.width / 2;
735
+ y = r.top + r.height / 2;
736
+ }
737
+ const icon = document.createElement('span');
738
+ icon.className = 'usa-double-tap-icon';
739
+ icon.setAttribute('aria-hidden', 'true');
740
+ icon.textContent = this.str('icon', '♥');
741
+ icon.style.left = `${x - r.left}px`;
742
+ icon.style.top = `${y - r.top}px`;
743
+ if (this.str('color'))
744
+ icon.style.color = this.str('color');
745
+ this.append(icon);
746
+ const frames = this.reduced
747
+ ? [{ opacity: 0 }, { opacity: 1, offset: 0.3 }, { opacity: 0 }]
748
+ : [
749
+ { opacity: 0, transform: 'translate(-50%, -50%) scale(0.2) rotate(-15deg)' },
750
+ { opacity: 1, transform: 'translate(-50%, -50%) scale(1.15) rotate(5deg)', offset: 0.3 },
751
+ { opacity: 1, transform: 'translate(-50%, -50%) scale(1) rotate(0deg)', offset: 0.6 },
752
+ { opacity: 0, transform: 'translate(-50%, -110%) scale(0.9)' },
753
+ ];
754
+ const a = this.motion(icon, frames, { duration: 900, easing: 'ease-out', fill: 'forwards' });
755
+ if (a)
756
+ a.onfinish = () => icon.remove();
757
+ else
758
+ icon.remove();
759
+ burst(x, y, { count: 8, distance: 40, size: 5, colors: [this.str('color', '#f43f5e'), '#fb923c', '#facc15'] });
760
+ if (this.hasAttribute('haptic'))
761
+ haptic(15);
762
+ this.emit('double-tap', { x: x - r.left, y: y - r.top });
763
+ }
764
+ }, { id: 'double-tap', text: css$1 });
765
+ }
766
+
767
+ var css = "usa-checkbox{--usa-checkbox-on:var(--usa-accent,#7c5cff);display:inline-flex;align-items:center;gap:0.55em;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;vertical-align:middle}usa-checkbox .usa-checkbox-box{flex:none;width:1.25em;height:1.25em;border-radius:0.3em;border:1.5px solid color-mix(in srgb,currentColor 55%,transparent);display:grid;place-items:center;transition:background-color 0.2s ease,border-color 0.2s ease;box-sizing:border-box}usa-checkbox[shape=\"circle\"] .usa-checkbox-box{border-radius:50%}usa-checkbox svg{width:85%;height:85%;fill:none;stroke:#fff;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}usa-checkbox svg path{stroke-dasharray:1;stroke-dashoffset:1;transition:stroke-dashoffset 0.28s cubic-bezier(0.65,0,0.35,1) 0.05s}usa-checkbox[checked]:not([indeterminate]) .usa-checkbox-check,usa-checkbox[indeterminate] .usa-checkbox-dash{stroke-dashoffset:0}usa-checkbox[checked] .usa-checkbox-box,usa-checkbox[indeterminate] .usa-checkbox-box{background:var(--usa-checkbox-on);border-color:var(--usa-checkbox-on)}usa-checkbox[disabled]{opacity:0.45;cursor:not-allowed}usa-checkbox:focus-visible{outline:none}usa-checkbox:focus-visible .usa-checkbox-box{outline:2px solid var(--usa-checkbox-on);outline-offset:2px}@media (prefers-reduced-motion:reduce){usa-checkbox svg path,usa-checkbox .usa-checkbox-box{transition:none}}";
768
+
769
+ function defineCheckbox(tag = 'usa-checkbox') {
770
+ return defineElement(tag, (Base) => {
771
+ class UsaCheckbox extends Base {
772
+ static get observedAttributes() {
773
+ return ['checked', 'indeterminate', 'disabled', 'label'];
774
+ }
775
+ constructor() {
776
+ super();
777
+ this._internals = null;
778
+ try {
779
+ this._internals = this.attachInternals?.() ?? null;
780
+ }
781
+ catch {
782
+ this._internals = null;
783
+ }
784
+ }
785
+ get checked() {
786
+ return this.flag('checked');
787
+ }
788
+ set checked(v) {
789
+ this.setFlag('checked', v);
790
+ }
791
+ get indeterminate() {
792
+ return this.flag('indeterminate');
793
+ }
794
+ set indeterminate(v) {
795
+ this.setFlag('indeterminate', v);
796
+ }
797
+ mount() {
798
+ if (!this.querySelector(':scope > .usa-checkbox-box')) {
799
+ this.insertAdjacentHTML('afterbegin', '<span class="usa-checkbox-box" aria-hidden="true"><svg viewBox="0 0 24 24"><path class="usa-checkbox-check" d="M5 12.5l4.2 4.2L19 7" pathLength="1"/><path class="usa-checkbox-dash" d="M6 12h12" pathLength="1"/></svg></span>');
800
+ }
801
+ this.setAttribute('role', 'checkbox');
802
+ if (!this.hasAttribute('tabindex'))
803
+ this.tabIndex = 0;
804
+ this.sync();
805
+ this.listen(this, 'click', () => this.toggle());
806
+ this.listen(this, 'keydown', (e) => {
807
+ if (e.key === ' ' && !e.repeat) {
808
+ e.preventDefault();
809
+ this.toggle();
810
+ }
811
+ });
812
+ }
813
+ changed() {
814
+ this.sync();
815
+ }
816
+ sync() {
817
+ this.setAttribute('aria-checked', this.indeterminate ? 'mixed' : String(this.checked));
818
+ if (this.str('label'))
819
+ this.setAttribute('aria-label', this.str('label'));
820
+ this.toggleAttribute('aria-disabled', this.flag('disabled'));
821
+ this._internals?.setFormValue?.(this.checked ? this.str('value', 'on') : null);
822
+ }
823
+ toggle(force) {
824
+ if (this.flag('disabled'))
825
+ return;
826
+ const next = force === undefined ? !this.checked || this.indeterminate : force;
827
+ this.indeterminate = false;
828
+ this.checked = next;
829
+ this.sync();
830
+ const box = this.querySelector('.usa-checkbox-box');
831
+ if (box && !this.reduced)
832
+ this.motion(box, [{ transform: 'scale(0.75)' }, { transform: 'scale(1)' }], springEasing('bouncy'));
833
+ this.dispatchEvent(new Event('change', { bubbles: true }));
834
+ this.emit('change', { checked: next });
835
+ }
836
+ }
837
+ UsaCheckbox.formAssociated = true;
838
+ return UsaCheckbox;
839
+ }, { id: 'checkbox', text: css });
840
+ }
841
+
842
+ /**
843
+ * motionary/components/click — click & tap effects (v2.5).
844
+ * `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
845
+ * `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
846
+ * shape morph; submit → loading → success), `<usa-icon-morph>`,
847
+ * `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
848
+ * `haptic()`. 6.0: `burst()`, `confetti()` and `shake()` were removed — play
849
+ * the registered effects instead: `playEffect(el, 'burst' | 'confetti' | 'shake')`.
850
+ */
851
+ /** Register every component of this category under its default tag. */
852
+ function defineClickComponents() {
853
+ defineClick();
854
+ defineButton();
855
+ defineIconMorph();
856
+ defineLike();
857
+ defineHold();
858
+ defineDoubleTap();
859
+ defineCheckbox();
860
+ }
861
+
862
+ export { BUTTON_DEFORMS, CLICK_EFFECTS, MORPH_ICONS, defineButton, defineCheckbox, defineClick, defineClickComponents, defineDoubleTap, defineHold, defineIconMorph, defineLike, haptic, morphPath };
863
+ //# sourceMappingURL=click.js.map