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