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,276 @@
1
+ 'use strict';
2
+
3
+ var base = require('../chunks/base-BaQV-2ha.cjs');
4
+ var indexTags = require('../chunks/index-tags-wv0R_vkO.cjs');
5
+
6
+ /**
7
+ * 4.9 — the 5.0 modern-browser baseline. `baselineReport()` lists which
8
+ * required / progressive features this browser has; `warnBaseline()` logs
9
+ * once in development when a required one is missing.
10
+ */
11
+ /** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
12
+ function baselineReport() {
13
+ const w = (typeof window !== 'undefined' ? window : {});
14
+ const d = (typeof document !== 'undefined' ? document : {});
15
+ const css = (q) => typeof w.CSS?.supports === 'function' && w.CSS.supports(q);
16
+ return [
17
+ { id: 'custom-elements', required: true, supported: !!w.customElements },
18
+ { id: 'web-animations', required: true, supported: typeof w.Element?.prototype?.animate === 'function' },
19
+ { id: 'intersection-observer', required: true, supported: typeof w.IntersectionObserver === 'function' },
20
+ { id: 'resize-observer', required: true, supported: typeof w.ResizeObserver === 'function' },
21
+ { id: 'adopted-stylesheets', required: true, supported: 'adoptedStyleSheets' in d },
22
+ { id: 'view-transitions', required: false, supported: typeof d.startViewTransition === 'function' },
23
+ { id: 'scroll-driven-animations', required: false, supported: css('animation-timeline: view()') },
24
+ { id: 'webgl', required: false, supported: !!(d.createElement && (() => { try {
25
+ return d.createElement('canvas').getContext('webgl');
26
+ }
27
+ catch {
28
+ return null;
29
+ } })()) },
30
+ ];
31
+ }
32
+ /** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
33
+ function warnBaseline() {
34
+ const missing = baselineReport().filter((f) => f.required && !f.supported).map((f) => f.id);
35
+ if (missing.length)
36
+ base.deprecate('baseline', `this browser lacks ${missing.join(', ')}; motionary 5.0 requires them (modern-browser baseline, see docs/upgrading-5.md).`);
37
+ return missing;
38
+ }
39
+
40
+ /**
41
+ * motionary/components/a11y — accessibility toolkit (4.4).
42
+ *
43
+ * - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
44
+ * - Static alternatives: what every component shows when motion is off, and
45
+ * `staticAlternative(root)` to freeze any subtree at its final state.
46
+ * - `aria-live` conventions: one shared polite and one assertive region,
47
+ * `announce(message, { politeness })`.
48
+ * - `auditMotionA11y(root)`: the rules the automated regression tests run
49
+ * over every `<usa-*>` element — usable in your own tests too.
50
+ *
51
+ * ```ts
52
+ * import { setMotionSensitivity, announce, auditMotionA11y } from 'motionary/components/a11y';
53
+ * setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
54
+ * announce('3 items added to cart'); // polite live region
55
+ * expect(auditMotionA11y(document.body).errors).toEqual([]);
56
+ * ```
57
+ */
58
+ const KEY = 'usa:sensitivity';
59
+ /** What each level allows, for docs and settings UIs. */
60
+ const MOTION_SENSITIVITY = {
61
+ full: { en: 'All motion', zh: '全部动效', allows: ['fade', 'translate', 'scale', 'rotate', 'parallax', 'loop', 'flash'] },
62
+ gentle: { en: 'Gentle — no spins, zooms or parallax', zh: '温和 —— 无旋转、缩放与视差', allows: ['fade', 'translate', 'loop'] },
63
+ minimal: { en: 'Minimal — fades only', zh: '最少 —— 仅淡入淡出', allows: ['fade'] },
64
+ static: { en: 'Static — no animation', zh: '静态 —— 无动画', allows: [] },
65
+ };
66
+ /** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
67
+ const SENSITIVITY_CSS = 'html[data-usa-sensitivity="static"] *,html[data-usa-sensitivity="static"] *::before,html[data-usa-sensitivity="static"] *::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}' +
68
+ 'html[data-usa-sensitivity="minimal"] *,html[data-usa-sensitivity="minimal"] *::before,html[data-usa-sensitivity="minimal"] *::after{animation-duration:1ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}' +
69
+ 'html[data-usa-sensitivity="gentle"]{--usa-parallax:0;--usa-tilt:0}';
70
+ /**
71
+ * Set the motion-sensitivity level for every `<usa-*>` component and the page:
72
+ * sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
73
+ * with `persist` remembers the choice (`restoreMotionSensitivity()`).
74
+ * Dispatches `usa:sensitivity` on `document`.
75
+ */
76
+ function setMotionSensitivity(level, persist = false) {
77
+ if (!base.MOTION_SENSITIVITY_LEVELS.includes(level))
78
+ return;
79
+ base.configureComponents({ motionSensitivity: level });
80
+ base.adoptStyles('a11y-sensitivity', SENSITIVITY_CSS);
81
+ if (persist) {
82
+ try {
83
+ localStorage.setItem(KEY, level);
84
+ }
85
+ catch {
86
+ /* private mode */
87
+ }
88
+ }
89
+ if (level === 'static' && typeof document !== 'undefined')
90
+ staticAlternative(document.documentElement);
91
+ if (typeof document !== 'undefined')
92
+ document.dispatchEvent(new CustomEvent('usa:sensitivity', { detail: { level } }));
93
+ }
94
+ /** Re-apply a persisted level (call early on page load). Returns the active level. */
95
+ function restoreMotionSensitivity() {
96
+ try {
97
+ const v = localStorage.getItem(KEY);
98
+ if (v && base.MOTION_SENSITIVITY_LEVELS.includes(v))
99
+ setMotionSensitivity(v);
100
+ }
101
+ catch {
102
+ /* ignore */
103
+ }
104
+ return base.getMotionSensitivity();
105
+ }
106
+ /** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
107
+ function motionAllowed(kind, level = base.getMotionSensitivity()) {
108
+ return MOTION_SENSITIVITY[level].allows.includes(kind);
109
+ }
110
+ /** The static alternative of each category: what its elements show without motion. */
111
+ const STATIC_ALTERNATIVES = {
112
+ reveal: 'Content visible in place; progress bars show the current value.',
113
+ text: 'Full final text (screen readers always get a plain copy).',
114
+ interaction: 'Normal hover / focus styles; no tilt, magnet or ripple.',
115
+ feedback: 'Spinners become a static busy indicator; progress shows its value; toasts appear without sliding.',
116
+ background: 'A still frame of the background (gradient / pattern); particles and marquees stop.',
117
+ transitions: 'Dialogs, accordions and views switch instantly.',
118
+ physics: 'Values jump to their target; drag still works, without inertia.',
119
+ cards: 'Cards are shown flat and fully readable; stacks become lists.',
120
+ click: 'Clicks work and states are announced; no bursts, confetti or deformation.',
121
+ ui: 'Tabs, drawers, sheets and popovers open instantly with focus management intact.',
122
+ page: 'Page transitions are instant; cursors and ambient layers are hidden.',
123
+ timeline: 'Every step is shown at its final state.',
124
+ gesture: 'Buttons / keys provide the same actions as swipes and pinches.',
125
+ svg: 'Drawings and icons are shown complete.',
126
+ webgl: 'A static poster image or CSS gradient instead of the shader.',
127
+ depth: 'Flat, front-facing layout.',
128
+ layout: 'Items reflow instantly.',
129
+ packs: 'Roles are styled but not animated.',
130
+ fx: 'Effects are skipped or reduced to a short fade; the content is unchanged.',
131
+ };
132
+ /**
133
+ * Freeze a subtree at its static alternative: finishes running animations
134
+ * (`finish()`, so content lands on its final state), marks the root with
135
+ * `data-usa-static` and returns an undo that removes the mark.
136
+ */
137
+ function staticAlternative(root) {
138
+ const getAll = root.getAnimations;
139
+ if (typeof getAll === 'function') {
140
+ for (const a of getAll.call(root, { subtree: true })) {
141
+ try {
142
+ const it = a.effect?.getComputedTiming().iterations;
143
+ if (it === Infinity)
144
+ a.cancel();
145
+ else
146
+ a.finish();
147
+ }
148
+ catch {
149
+ /* finished already */
150
+ }
151
+ }
152
+ }
153
+ root.setAttribute('data-usa-static', '');
154
+ return () => root.removeAttribute('data-usa-static');
155
+ }
156
+ /** The ids of the shared live regions. */
157
+ const LIVE_REGION_IDS = { polite: 'usa-live-polite', assertive: 'usa-live-assertive' };
158
+ /** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
159
+ function liveRegion(politeness = 'polite') {
160
+ if (typeof document === 'undefined' || !document.body)
161
+ return null;
162
+ const id = LIVE_REGION_IDS[politeness];
163
+ let el = document.getElementById(id);
164
+ if (!el) {
165
+ el = document.createElement('div');
166
+ el.id = id;
167
+ el.className = 'usa-sr';
168
+ el.setAttribute('role', politeness === 'assertive' ? 'alert' : 'status');
169
+ el.setAttribute('aria-live', politeness);
170
+ el.setAttribute('aria-atomic', 'true');
171
+ document.body.appendChild(el);
172
+ }
173
+ return el;
174
+ }
175
+ let lastMsg = '';
176
+ let lastAt = 0;
177
+ /**
178
+ * Announce a message through the shared live region. Conventions: `polite`
179
+ * for results of the user's own actions (added, saved, copied), `assertive`
180
+ * only for errors that block them. Identical messages within `dedupe` ms
181
+ * (default 500) are dropped; the region is cleared first so repeats are read.
182
+ */
183
+ function announce(message, options = {}) {
184
+ const { politeness = 'polite', dedupe = 500 } = options;
185
+ const t = Date.now();
186
+ if (!message || (message === lastMsg && t - lastAt < dedupe))
187
+ return false;
188
+ lastMsg = message;
189
+ lastAt = t;
190
+ const el = liveRegion(politeness);
191
+ if (!el)
192
+ return false;
193
+ el.textContent = '';
194
+ el.textContent = message;
195
+ return true;
196
+ }
197
+ const FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
198
+ const NAMED_ROLES = ['button', 'switch', 'checkbox', 'slider', 'tab', 'progressbar', 'radiogroup', 'dialog'];
199
+ function accessibleName(el) {
200
+ const label = el.getAttribute('aria-label');
201
+ if (label)
202
+ return label;
203
+ const by = el.getAttribute('aria-labelledby');
204
+ if (by)
205
+ return by.split(/\s+/).map((id) => el.ownerDocument.getElementById(id)?.textContent || '').join(' ').trim();
206
+ return (el.textContent || el.getAttribute('title') || '').trim();
207
+ }
208
+ /**
209
+ * Check a subtree against the library's motion-a11y rules:
210
+ * - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
211
+ * - `role-name` (error): a widget role without an accessible name.
212
+ * - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
213
+ * - `img-alt` (error): an `<img>` without `alt`.
214
+ * - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
215
+ * - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
216
+ * page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
217
+ */
218
+ function auditMotionA11y(root) {
219
+ const issues = [];
220
+ const add = (rule, level, element, message) => issues.push({ rule, level, element, message });
221
+ const scope = root;
222
+ scope.querySelectorAll('[aria-hidden="true"]').forEach((h) => {
223
+ const f = (h.matches(FOCUSABLE) ? [h] : Array.from(h.querySelectorAll(FOCUSABLE))).filter((x) => !x.closest('[inert]'));
224
+ f.forEach((x) => add('aria-hidden-focusable', 'error', x, `focusable <${x.tagName.toLowerCase()}> inside aria-hidden`));
225
+ });
226
+ scope.querySelectorAll('[role]').forEach((el) => {
227
+ const role = el.getAttribute('role');
228
+ if (NAMED_ROLES.includes(role) && !accessibleName(el))
229
+ add('role-name', 'error', el, `role="${role}" has no accessible name`);
230
+ if (role === 'slider' && !el.hasAttribute('aria-valuenow'))
231
+ add('range-value', 'error', el, 'slider without aria-valuenow');
232
+ });
233
+ scope.querySelectorAll('img:not([alt])').forEach((el) => add('img-alt', 'error', el, '<img> without alt'));
234
+ scope.querySelectorAll('[aria-live="assertive"]').forEach((el) => {
235
+ if (el.getAttribute('role') !== 'alert')
236
+ add('assertive-live', 'warning', el, 'assertive live region outside role="alert"');
237
+ });
238
+ const doc = root.ownerDocument || root;
239
+ const anims = typeof root.getAnimations === 'function' ? root.getAnimations({ subtree: true }) : [];
240
+ const control = doc && (doc.querySelector('usa-motion-switch, [data-usa-pause]') || doc.documentElement.hasAttribute('data-usa-sensitivity'));
241
+ if (!control)
242
+ anims.forEach((a) => {
243
+ try {
244
+ if (a.effect?.getComputedTiming().iterations === Infinity) {
245
+ const t = a.effect.target;
246
+ if (t)
247
+ add('infinite-no-control', 'warning', t, 'endless animation and no motion control on the page');
248
+ }
249
+ }
250
+ catch {
251
+ /* ignore */
252
+ }
253
+ });
254
+ return { errors: issues.filter((i) => i.level === 'error'), warnings: issues.filter((i) => i.level === 'warning') };
255
+ }
256
+ /** Every `<usa-*>` tag, for sweeping audits. */
257
+ const ALL_TAGS = Object.values(indexTags.COMPONENT_CATEGORIES).flat();
258
+
259
+ exports.MOTION_SENSITIVITY_LEVELS = base.MOTION_SENSITIVITY_LEVELS;
260
+ exports.adaptKeyframes = base.adaptKeyframes;
261
+ exports.getMotionSensitivity = base.getMotionSensitivity;
262
+ exports.ALL_TAGS = ALL_TAGS;
263
+ exports.LIVE_REGION_IDS = LIVE_REGION_IDS;
264
+ exports.MOTION_SENSITIVITY = MOTION_SENSITIVITY;
265
+ exports.SENSITIVITY_CSS = SENSITIVITY_CSS;
266
+ exports.STATIC_ALTERNATIVES = STATIC_ALTERNATIVES;
267
+ exports.announce = announce;
268
+ exports.auditMotionA11y = auditMotionA11y;
269
+ exports.baselineReport = baselineReport;
270
+ exports.liveRegion = liveRegion;
271
+ exports.motionAllowed = motionAllowed;
272
+ exports.restoreMotionSensitivity = restoreMotionSensitivity;
273
+ exports.setMotionSensitivity = setMotionSensitivity;
274
+ exports.staticAlternative = staticAlternative;
275
+ exports.warnBaseline = warnBaseline;
276
+ //# sourceMappingURL=a11y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a11y.cjs","sources":["../../src/components/a11y/baseline.ts","../../src/components/a11y/index.ts"],"sourcesContent":["/**\n * 4.9 — the 5.0 modern-browser baseline. `baselineReport()` lists which\n * required / progressive features this browser has; `warnBaseline()` logs\n * once in development when a required one is missing.\n */\nimport { deprecate } from '../base';\n\nexport interface BaselineFeature {\n id: string;\n required: boolean;\n supported: boolean;\n}\n\n/** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */\nexport function baselineReport(): BaselineFeature[] {\n const w = (typeof window !== 'undefined' ? window : {}) as any;\n const d = (typeof document !== 'undefined' ? document : {}) as any;\n const css = (q: string) => typeof w.CSS?.supports === 'function' && w.CSS.supports(q);\n return [\n { id: 'custom-elements', required: true, supported: !!w.customElements },\n { id: 'web-animations', required: true, supported: typeof w.Element?.prototype?.animate === 'function' },\n { id: 'intersection-observer', required: true, supported: typeof w.IntersectionObserver === 'function' },\n { id: 'resize-observer', required: true, supported: typeof w.ResizeObserver === 'function' },\n { id: 'adopted-stylesheets', required: true, supported: 'adoptedStyleSheets' in d },\n { id: 'view-transitions', required: false, supported: typeof d.startViewTransition === 'function' },\n { id: 'scroll-driven-animations', required: false, supported: css('animation-timeline: view()') },\n { id: 'webgl', required: false, supported: !!(d.createElement && (() => { try { return d.createElement('canvas').getContext('webgl'); } catch { return null; } })()) },\n ];\n}\n\n/** Log (once) which required 5.0 features are missing here. Returns the missing ids. */\nexport function warnBaseline(): string[] {\n const missing = baselineReport().filter((f) => f.required && !f.supported).map((f) => f.id);\n if (missing.length) deprecate('baseline', `this browser lacks ${missing.join(', ')}; motionary 5.0 requires them (modern-browser baseline, see docs/upgrading-5.md).`);\n return missing;\n}\n","/**\n * motionary/components/a11y — accessibility toolkit (4.4).\n *\n * - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.\n * - Static alternatives: what every component shows when motion is off, and\n * `staticAlternative(root)` to freeze any subtree at its final state.\n * - `aria-live` conventions: one shared polite and one assertive region,\n * `announce(message, { politeness })`.\n * - `auditMotionA11y(root)`: the rules the automated regression tests run\n * over every `<usa-*>` element — usable in your own tests too.\n *\n * ```ts\n * import { setMotionSensitivity, announce, auditMotionA11y } from 'motionary/components/a11y';\n * setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered\n * announce('3 items added to cart'); // polite live region\n * expect(auditMotionA11y(document.body).errors).toEqual([]);\n * ```\n */\nimport {\n configureComponents,\n getMotionSensitivity,\n adaptKeyframes,\n adoptStyles,\n MOTION_SENSITIVITY_LEVELS,\n type MotionSensitivity,\n} from '../base';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from '../index-tags';\n\nexport { getMotionSensitivity, adaptKeyframes, MOTION_SENSITIVITY_LEVELS };\nexport { baselineReport, warnBaseline } from './baseline';\nexport type { BaselineFeature } from './baseline';\nexport type { MotionSensitivity };\n\nconst KEY = 'usa:sensitivity';\n\n/** What each level allows, for docs and settings UIs. */\nexport const MOTION_SENSITIVITY: Record<MotionSensitivity, { en: string; zh: string; allows: string[] }> = {\n full: { en: 'All motion', zh: '全部动效', allows: ['fade', 'translate', 'scale', 'rotate', 'parallax', 'loop', 'flash'] },\n gentle: { en: 'Gentle — no spins, zooms or parallax', zh: '温和 —— 无旋转、缩放与视差', allows: ['fade', 'translate', 'loop'] },\n minimal: { en: 'Minimal — fades only', zh: '最少 —— 仅淡入淡出', allows: ['fade'] },\n static: { en: 'Static — no animation', zh: '静态 —— 无动画', allows: [] },\n};\n\n/** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */\nexport const SENSITIVITY_CSS =\n 'html[data-usa-sensitivity=\"static\"] *,html[data-usa-sensitivity=\"static\"] *::before,html[data-usa-sensitivity=\"static\"] *::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}' +\n 'html[data-usa-sensitivity=\"minimal\"] *,html[data-usa-sensitivity=\"minimal\"] *::before,html[data-usa-sensitivity=\"minimal\"] *::after{animation-duration:1ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}' +\n 'html[data-usa-sensitivity=\"gentle\"]{--usa-parallax:0;--usa-tilt:0}';\n\n/**\n * Set the motion-sensitivity level for every `<usa-*>` component and the page:\n * sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and\n * with `persist` remembers the choice (`restoreMotionSensitivity()`).\n * Dispatches `usa:sensitivity` on `document`.\n */\nexport function setMotionSensitivity(level: MotionSensitivity, persist = false): void {\n if (!MOTION_SENSITIVITY_LEVELS.includes(level)) return;\n configureComponents({ motionSensitivity: level });\n adoptStyles('a11y-sensitivity', SENSITIVITY_CSS);\n if (persist) {\n try {\n localStorage.setItem(KEY, level);\n } catch {\n /* private mode */\n }\n }\n if (level === 'static' && typeof document !== 'undefined') staticAlternative(document.documentElement);\n if (typeof document !== 'undefined') document.dispatchEvent(new CustomEvent('usa:sensitivity', { detail: { level } }));\n}\n\n/** Re-apply a persisted level (call early on page load). Returns the active level. */\nexport function restoreMotionSensitivity(): MotionSensitivity {\n try {\n const v = localStorage.getItem(KEY) as MotionSensitivity | null;\n if (v && MOTION_SENSITIVITY_LEVELS.includes(v)) setMotionSensitivity(v);\n } catch {\n /* ignore */\n }\n return getMotionSensitivity();\n}\n\n/** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */\nexport function motionAllowed(kind: string, level: MotionSensitivity = getMotionSensitivity()): boolean {\n return MOTION_SENSITIVITY[level].allows.includes(kind);\n}\n\n/** The static alternative of each category: what its elements show without motion. */\nexport const STATIC_ALTERNATIVES: Record<ComponentCategory, string> = {\n reveal: 'Content visible in place; progress bars show the current value.',\n text: 'Full final text (screen readers always get a plain copy).',\n interaction: 'Normal hover / focus styles; no tilt, magnet or ripple.',\n feedback: 'Spinners become a static busy indicator; progress shows its value; toasts appear without sliding.',\n background: 'A still frame of the background (gradient / pattern); particles and marquees stop.',\n transitions: 'Dialogs, accordions and views switch instantly.',\n physics: 'Values jump to their target; drag still works, without inertia.',\n cards: 'Cards are shown flat and fully readable; stacks become lists.',\n click: 'Clicks work and states are announced; no bursts, confetti or deformation.',\n ui: 'Tabs, drawers, sheets and popovers open instantly with focus management intact.',\n page: 'Page transitions are instant; cursors and ambient layers are hidden.',\n timeline: 'Every step is shown at its final state.',\n gesture: 'Buttons / keys provide the same actions as swipes and pinches.',\n svg: 'Drawings and icons are shown complete.',\n webgl: 'A static poster image or CSS gradient instead of the shader.',\n depth: 'Flat, front-facing layout.',\n layout: 'Items reflow instantly.',\n packs: 'Roles are styled but not animated.',\n fx: 'Effects are skipped or reduced to a short fade; the content is unchanged.',\n};\n\n/**\n * Freeze a subtree at its static alternative: finishes running animations\n * (`finish()`, so content lands on its final state), marks the root with\n * `data-usa-static` and returns an undo that removes the mark.\n */\nexport function staticAlternative(root: Element): () => void {\n const getAll = (root as any).getAnimations as undefined | ((o: { subtree: boolean }) => Animation[]);\n if (typeof getAll === 'function') {\n for (const a of getAll.call(root, { subtree: true })) {\n try {\n const it = a.effect?.getComputedTiming().iterations;\n if (it === Infinity) a.cancel();\n else a.finish();\n } catch {\n /* finished already */\n }\n }\n }\n root.setAttribute('data-usa-static', '');\n return () => root.removeAttribute('data-usa-static');\n}\n\n// --- aria-live conventions ---------------------------------------------------\n\nexport type Politeness = 'polite' | 'assertive';\n/** The ids of the shared live regions. */\nexport const LIVE_REGION_IDS: Record<Politeness, string> = { polite: 'usa-live-polite', assertive: 'usa-live-assertive' };\n\n/** The shared live region (created once, visually hidden, `role=\"status\"` / `role=\"alert\"`). */\nexport function liveRegion(politeness: Politeness = 'polite'): HTMLElement | null {\n if (typeof document === 'undefined' || !document.body) return null;\n const id = LIVE_REGION_IDS[politeness];\n let el = document.getElementById(id);\n if (!el) {\n el = document.createElement('div');\n el.id = id;\n el.className = 'usa-sr';\n el.setAttribute('role', politeness === 'assertive' ? 'alert' : 'status');\n el.setAttribute('aria-live', politeness);\n el.setAttribute('aria-atomic', 'true');\n document.body.appendChild(el);\n }\n return el;\n}\n\nlet lastMsg = '';\nlet lastAt = 0;\n/**\n * Announce a message through the shared live region. Conventions: `polite`\n * for results of the user's own actions (added, saved, copied), `assertive`\n * only for errors that block them. Identical messages within `dedupe` ms\n * (default 500) are dropped; the region is cleared first so repeats are read.\n */\nexport function announce(message: string, options: { politeness?: Politeness; dedupe?: number } = {}): boolean {\n const { politeness = 'polite', dedupe = 500 } = options;\n const t = Date.now();\n if (!message || (message === lastMsg && t - lastAt < dedupe)) return false;\n lastMsg = message;\n lastAt = t;\n const el = liveRegion(politeness);\n if (!el) return false;\n el.textContent = '';\n el.textContent = message;\n return true;\n}\n\n// --- audit ---------------------------------------------------------------------\n\nexport interface A11yIssue {\n rule: string;\n level: 'error' | 'warning';\n element: Element;\n message: string;\n}\n\nconst FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\nconst NAMED_ROLES = ['button', 'switch', 'checkbox', 'slider', 'tab', 'progressbar', 'radiogroup', 'dialog'];\n\nfunction accessibleName(el: Element): string {\n const label = el.getAttribute('aria-label');\n if (label) return label;\n const by = el.getAttribute('aria-labelledby');\n if (by) return by.split(/\\s+/).map((id) => el.ownerDocument.getElementById(id)?.textContent || '').join(' ').trim();\n return (el.textContent || el.getAttribute('title') || '').trim();\n}\n\n/**\n * Check a subtree against the library's motion-a11y rules:\n * - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.\n * - `role-name` (error): a widget role without an accessible name.\n * - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.\n * - `img-alt` (error): an `<img>` without `alt`.\n * - `assertive-live` (warning): `aria-live=\"assertive\"` outside `role=\"alert\"`.\n * - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a\n * page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).\n */\nexport function auditMotionA11y(root: Element | Document): { errors: A11yIssue[]; warnings: A11yIssue[] } {\n const issues: A11yIssue[] = [];\n const add = (rule: string, level: A11yIssue['level'], element: Element, message: string) => issues.push({ rule, level, element, message });\n const scope = root as ParentNode;\n scope.querySelectorAll('[aria-hidden=\"true\"]').forEach((h) => {\n const f = (h.matches(FOCUSABLE) ? [h] : Array.from(h.querySelectorAll(FOCUSABLE))).filter((x) => !x.closest('[inert]'));\n f.forEach((x) => add('aria-hidden-focusable', 'error', x, `focusable <${x.tagName.toLowerCase()}> inside aria-hidden`));\n });\n scope.querySelectorAll('[role]').forEach((el) => {\n const role = el.getAttribute('role')!;\n if (NAMED_ROLES.includes(role) && !accessibleName(el)) add('role-name', 'error', el, `role=\"${role}\" has no accessible name`);\n if (role === 'slider' && !el.hasAttribute('aria-valuenow'))\n add('range-value', 'error', el, 'slider without aria-valuenow');\n });\n scope.querySelectorAll('img:not([alt])').forEach((el) => add('img-alt', 'error', el, '<img> without alt'));\n scope.querySelectorAll('[aria-live=\"assertive\"]').forEach((el) => {\n if (el.getAttribute('role') !== 'alert') add('assertive-live', 'warning', el, 'assertive live region outside role=\"alert\"');\n });\n const doc = (root as Node).ownerDocument || (root as Document);\n const anims = typeof (root as any).getAnimations === 'function' ? ((root as any).getAnimations({ subtree: true }) as Animation[]) : [];\n const control = doc && (doc.querySelector('usa-motion-switch, [data-usa-pause]') || doc.documentElement.hasAttribute('data-usa-sensitivity'));\n if (!control)\n anims.forEach((a) => {\n try {\n if (a.effect?.getComputedTiming().iterations === Infinity) {\n const t = (a.effect as KeyframeEffect).target;\n if (t) add('infinite-no-control', 'warning', t, 'endless animation and no motion control on the page');\n }\n } catch {\n /* ignore */\n }\n });\n return { errors: issues.filter((i) => i.level === 'error'), warnings: issues.filter((i) => i.level === 'warning') };\n}\n\n/** Every `<usa-*>` tag, for sweeping audits. */\nexport const ALL_TAGS: string[] = (Object.values(COMPONENT_CATEGORIES) as readonly (readonly string[])[]).flat();\n"],"names":["deprecate","MOTION_SENSITIVITY_LEVELS","configureComponents","adoptStyles","getMotionSensitivity","COMPONENT_CATEGORIES"],"mappings":";;;;;AAAA;;;;AAIG;AASH;SACgB,cAAc,GAAA;AAC5B,IAAA,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,GAAG,EAAE,CAAQ;AAC9D,IAAA,MAAM,CAAC,IAAI,OAAO,QAAQ,KAAK,WAAW,GAAG,QAAQ,GAAG,EAAE,CAAQ;IAClE,MAAM,GAAG,GAAG,CAAC,CAAS,KAAK,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrF,OAAO;AACL,QAAA,EAAE,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE;QACxE,EAAE,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,UAAU,EAAE;AACxG,QAAA,EAAE,EAAE,EAAE,uBAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,oBAAoB,KAAK,UAAU,EAAE;AACxG,QAAA,EAAE,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,cAAc,KAAK,UAAU,EAAE;AAC5F,QAAA,EAAE,EAAE,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,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AAC,CAAC,MAAyB,CAAC,MAAM;AAC7C,oBAAA,IAAI,CAAC;wBAAE,GAAG,CAAC,qBAAqB,EAAE,SAAS,EAAE,CAAC,EAAE,qDAAqD,CAAC;gBACxG;YACF;AAAE,YAAA,MAAM;;YAER;AACF,QAAA,CAAC,CAAC;AACJ,IAAA,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE;AACrH;AAEA;AACO,MAAM,QAAQ,GAAc,MAAM,CAAC,MAAM,CAACC,8BAAoB,CAAoC,CAAC,IAAI;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,131 @@
1
+ type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
2
+ declare const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[];
3
+ /** The current motion-sensitivity level (v4.4). */
4
+ declare function getMotionSensitivity(): MotionSensitivity;
5
+ /**
6
+ * Adapt keyframes to the sensitivity level: `gentle` drops transforms that
7
+ * spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps
8
+ * just the final frame. `full` returns them unchanged.
9
+ */
10
+ declare function adaptKeyframes(frames: Keyframe[], level?: MotionSensitivity): Keyframe[];
11
+
12
+ /** The component categories and their default tags. */
13
+ declare const COMPONENT_CATEGORIES: {
14
+ readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
15
+ readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate", "usa-wave-text", "usa-glitch", "usa-gradient-text", "usa-handwriting", "usa-scroll-highlight"];
16
+ readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
17
+ readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
18
+ readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
19
+ readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-view-switch"];
20
+ readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
21
+ readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
22
+ readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
23
+ readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
24
+ readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
25
+ readonly timeline: readonly ["usa-timeline"];
26
+ readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
27
+ readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
28
+ readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid", "usa-post-fx"];
29
+ readonly depth: readonly ["usa-cube", "usa-depth"];
30
+ readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
31
+ readonly packs: readonly ["usa-pack"];
32
+ readonly fx: readonly ["usa-fx"];
33
+ };
34
+ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
35
+
36
+ interface BaselineFeature {
37
+ id: string;
38
+ required: boolean;
39
+ supported: boolean;
40
+ }
41
+ /** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
42
+ declare function baselineReport(): BaselineFeature[];
43
+ /** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
44
+ declare function warnBaseline(): string[];
45
+
46
+ /**
47
+ * motionary/components/a11y — accessibility toolkit (4.4).
48
+ *
49
+ * - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
50
+ * - Static alternatives: what every component shows when motion is off, and
51
+ * `staticAlternative(root)` to freeze any subtree at its final state.
52
+ * - `aria-live` conventions: one shared polite and one assertive region,
53
+ * `announce(message, { politeness })`.
54
+ * - `auditMotionA11y(root)`: the rules the automated regression tests run
55
+ * over every `<usa-*>` element — usable in your own tests too.
56
+ *
57
+ * ```ts
58
+ * import { setMotionSensitivity, announce, auditMotionA11y } from 'motionary/components/a11y';
59
+ * setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
60
+ * announce('3 items added to cart'); // polite live region
61
+ * expect(auditMotionA11y(document.body).errors).toEqual([]);
62
+ * ```
63
+ */
64
+
65
+ /** What each level allows, for docs and settings UIs. */
66
+ declare const MOTION_SENSITIVITY: Record<MotionSensitivity, {
67
+ en: string;
68
+ zh: string;
69
+ allows: string[];
70
+ }>;
71
+ /** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
72
+ declare const SENSITIVITY_CSS: string;
73
+ /**
74
+ * Set the motion-sensitivity level for every `<usa-*>` component and the page:
75
+ * sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
76
+ * with `persist` remembers the choice (`restoreMotionSensitivity()`).
77
+ * Dispatches `usa:sensitivity` on `document`.
78
+ */
79
+ declare function setMotionSensitivity(level: MotionSensitivity, persist?: boolean): void;
80
+ /** Re-apply a persisted level (call early on page load). Returns the active level. */
81
+ declare function restoreMotionSensitivity(): MotionSensitivity;
82
+ /** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
83
+ declare function motionAllowed(kind: string, level?: MotionSensitivity): boolean;
84
+ /** The static alternative of each category: what its elements show without motion. */
85
+ declare const STATIC_ALTERNATIVES: Record<ComponentCategory, string>;
86
+ /**
87
+ * Freeze a subtree at its static alternative: finishes running animations
88
+ * (`finish()`, so content lands on its final state), marks the root with
89
+ * `data-usa-static` and returns an undo that removes the mark.
90
+ */
91
+ declare function staticAlternative(root: Element): () => void;
92
+ type Politeness = 'polite' | 'assertive';
93
+ /** The ids of the shared live regions. */
94
+ declare const LIVE_REGION_IDS: Record<Politeness, string>;
95
+ /** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
96
+ declare function liveRegion(politeness?: Politeness): HTMLElement | null;
97
+ /**
98
+ * Announce a message through the shared live region. Conventions: `polite`
99
+ * for results of the user's own actions (added, saved, copied), `assertive`
100
+ * only for errors that block them. Identical messages within `dedupe` ms
101
+ * (default 500) are dropped; the region is cleared first so repeats are read.
102
+ */
103
+ declare function announce(message: string, options?: {
104
+ politeness?: Politeness;
105
+ dedupe?: number;
106
+ }): boolean;
107
+ interface A11yIssue {
108
+ rule: string;
109
+ level: 'error' | 'warning';
110
+ element: Element;
111
+ message: string;
112
+ }
113
+ /**
114
+ * Check a subtree against the library's motion-a11y rules:
115
+ * - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
116
+ * - `role-name` (error): a widget role without an accessible name.
117
+ * - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
118
+ * - `img-alt` (error): an `<img>` without `alt`.
119
+ * - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
120
+ * - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
121
+ * page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
122
+ */
123
+ declare function auditMotionA11y(root: Element | Document): {
124
+ errors: A11yIssue[];
125
+ warnings: A11yIssue[];
126
+ };
127
+ /** Every `<usa-*>` tag, for sweeping audits. */
128
+ declare const ALL_TAGS: string[];
129
+
130
+ export { ALL_TAGS, LIVE_REGION_IDS, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, SENSITIVITY_CSS, STATIC_ALTERNATIVES, adaptKeyframes, announce, auditMotionA11y, baselineReport, getMotionSensitivity, liveRegion, motionAllowed, restoreMotionSensitivity, setMotionSensitivity, staticAlternative, warnBaseline };
131
+ export type { A11yIssue, BaselineFeature, MotionSensitivity, Politeness };
@@ -0,0 +1,131 @@
1
+ type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
2
+ declare const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[];
3
+ /** The current motion-sensitivity level (v4.4). */
4
+ declare function getMotionSensitivity(): MotionSensitivity;
5
+ /**
6
+ * Adapt keyframes to the sensitivity level: `gentle` drops transforms that
7
+ * spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps
8
+ * just the final frame. `full` returns them unchanged.
9
+ */
10
+ declare function adaptKeyframes(frames: Keyframe[], level?: MotionSensitivity): Keyframe[];
11
+
12
+ /** The component categories and their default tags. */
13
+ declare const COMPONENT_CATEGORIES: {
14
+ readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
15
+ readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate", "usa-wave-text", "usa-glitch", "usa-gradient-text", "usa-handwriting", "usa-scroll-highlight"];
16
+ readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
17
+ readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
18
+ readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
19
+ readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-view-switch"];
20
+ readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
21
+ readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
22
+ readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
23
+ readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
24
+ readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
25
+ readonly timeline: readonly ["usa-timeline"];
26
+ readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
27
+ readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
28
+ readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid", "usa-post-fx"];
29
+ readonly depth: readonly ["usa-cube", "usa-depth"];
30
+ readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
31
+ readonly packs: readonly ["usa-pack"];
32
+ readonly fx: readonly ["usa-fx"];
33
+ };
34
+ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
35
+
36
+ interface BaselineFeature {
37
+ id: string;
38
+ required: boolean;
39
+ supported: boolean;
40
+ }
41
+ /** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
42
+ declare function baselineReport(): BaselineFeature[];
43
+ /** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
44
+ declare function warnBaseline(): string[];
45
+
46
+ /**
47
+ * motionary/components/a11y — accessibility toolkit (4.4).
48
+ *
49
+ * - Motion-sensitivity levels: `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static')`.
50
+ * - Static alternatives: what every component shows when motion is off, and
51
+ * `staticAlternative(root)` to freeze any subtree at its final state.
52
+ * - `aria-live` conventions: one shared polite and one assertive region,
53
+ * `announce(message, { politeness })`.
54
+ * - `auditMotionA11y(root)`: the rules the automated regression tests run
55
+ * over every `<usa-*>` element — usable in your own tests too.
56
+ *
57
+ * ```ts
58
+ * import { setMotionSensitivity, announce, auditMotionA11y } from 'motionary/components/a11y';
59
+ * setMotionSensitivity('gentle', true); // no spins / zooms / parallax, remembered
60
+ * announce('3 items added to cart'); // polite live region
61
+ * expect(auditMotionA11y(document.body).errors).toEqual([]);
62
+ * ```
63
+ */
64
+
65
+ /** What each level allows, for docs and settings UIs. */
66
+ declare const MOTION_SENSITIVITY: Record<MotionSensitivity, {
67
+ en: string;
68
+ zh: string;
69
+ allows: string[];
70
+ }>;
71
+ /** CSS applied at the `static` / `minimal` / `gentle` levels (also stops your own CSS animations under `static`). */
72
+ declare const SENSITIVITY_CSS: string;
73
+ /**
74
+ * Set the motion-sensitivity level for every `<usa-*>` component and the page:
75
+ * sets `data-usa-sensitivity` on `<html>`, adapts component keyframes, and
76
+ * with `persist` remembers the choice (`restoreMotionSensitivity()`).
77
+ * Dispatches `usa:sensitivity` on `document`.
78
+ */
79
+ declare function setMotionSensitivity(level: MotionSensitivity, persist?: boolean): void;
80
+ /** Re-apply a persisted level (call early on page load). Returns the active level. */
81
+ declare function restoreMotionSensitivity(): MotionSensitivity;
82
+ /** `true` when the current level allows a kind of motion (`'rotate'`, `'parallax'`, `'loop'`…). */
83
+ declare function motionAllowed(kind: string, level?: MotionSensitivity): boolean;
84
+ /** The static alternative of each category: what its elements show without motion. */
85
+ declare const STATIC_ALTERNATIVES: Record<ComponentCategory, string>;
86
+ /**
87
+ * Freeze a subtree at its static alternative: finishes running animations
88
+ * (`finish()`, so content lands on its final state), marks the root with
89
+ * `data-usa-static` and returns an undo that removes the mark.
90
+ */
91
+ declare function staticAlternative(root: Element): () => void;
92
+ type Politeness = 'polite' | 'assertive';
93
+ /** The ids of the shared live regions. */
94
+ declare const LIVE_REGION_IDS: Record<Politeness, string>;
95
+ /** The shared live region (created once, visually hidden, `role="status"` / `role="alert"`). */
96
+ declare function liveRegion(politeness?: Politeness): HTMLElement | null;
97
+ /**
98
+ * Announce a message through the shared live region. Conventions: `polite`
99
+ * for results of the user's own actions (added, saved, copied), `assertive`
100
+ * only for errors that block them. Identical messages within `dedupe` ms
101
+ * (default 500) are dropped; the region is cleared first so repeats are read.
102
+ */
103
+ declare function announce(message: string, options?: {
104
+ politeness?: Politeness;
105
+ dedupe?: number;
106
+ }): boolean;
107
+ interface A11yIssue {
108
+ rule: string;
109
+ level: 'error' | 'warning';
110
+ element: Element;
111
+ message: string;
112
+ }
113
+ /**
114
+ * Check a subtree against the library's motion-a11y rules:
115
+ * - `aria-hidden-focusable` (error): focusable content inside `aria-hidden`.
116
+ * - `role-name` (error): a widget role without an accessible name.
117
+ * - `range-value` (error): a slider / determinate progressbar without `aria-valuenow`.
118
+ * - `img-alt` (error): an `<img>` without `alt`.
119
+ * - `assertive-live` (warning): `aria-live="assertive"` outside `role="alert"`.
120
+ * - `infinite-no-control` (warning, WCAG 2.2.2): an endless animation on a
121
+ * page with no way to pause motion (`<usa-motion-switch>` or `[data-usa-pause]`).
122
+ */
123
+ declare function auditMotionA11y(root: Element | Document): {
124
+ errors: A11yIssue[];
125
+ warnings: A11yIssue[];
126
+ };
127
+ /** Every `<usa-*>` tag, for sweeping audits. */
128
+ declare const ALL_TAGS: string[];
129
+
130
+ export { ALL_TAGS, LIVE_REGION_IDS, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, SENSITIVITY_CSS, STATIC_ALTERNATIVES, adaptKeyframes, announce, auditMotionA11y, baselineReport, getMotionSensitivity, liveRegion, motionAllowed, restoreMotionSensitivity, setMotionSensitivity, staticAlternative, warnBaseline };
131
+ export type { A11yIssue, BaselineFeature, MotionSensitivity, Politeness };