use-scroll-animate 6.1.1 → 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 (104) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/chunks/{base-Yno7N2eC.js → base-C_3cAoRz.js} +2 -2
  3. package/dist/chunks/{base-Yno7N2eC.js.map → base-C_3cAoRz.js.map} +1 -1
  4. package/dist/chunks/{core-CUGCsMsJ.js → core-VEBw36QK.js} +2 -2
  5. package/dist/chunks/{core-CUGCsMsJ.js.map → core-VEBw36QK.js.map} +1 -1
  6. package/dist/chunks/{core-BIOaYdgN.js → core-ps8uvYuN.js} +2 -2
  7. package/dist/chunks/{core-BIOaYdgN.js.map → core-ps8uvYuN.js.map} +1 -1
  8. package/dist/chunks/{fx-BqDeFywO.js → fx-Bs6IrV4Q.js} +2 -2
  9. package/dist/chunks/{fx-BqDeFywO.js.map → fx-Bs6IrV4Q.js.map} +1 -1
  10. package/dist/chunks/generative-D2YyhaeO.js +336 -0
  11. package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
  12. package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
  13. package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
  14. package/dist/chunks/gpu-Bu7qwugO.js +380 -0
  15. package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
  16. package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
  17. package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
  18. package/dist/chunks/registry-CKNLQpwd.js +121 -0
  19. package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
  20. package/dist/chunks/registry-DehBVRDV.cjs +131 -0
  21. package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
  22. package/dist/chunks/{spring-DfQO5USi.js → spring-CbvHfVtP.js} +2 -2
  23. package/dist/chunks/{spring-DfQO5USi.js.map → spring-CbvHfVtP.js.map} +1 -1
  24. package/dist/chunks/{variants-VNscPeTD.js → variants-DRlKVHvu.js} +2 -2
  25. package/dist/chunks/{variants-VNscPeTD.js.map → variants-DRlKVHvu.js.map} +1 -1
  26. package/dist/components/a11y.js +2 -2
  27. package/dist/components/angular.cjs +1 -0
  28. package/dist/components/angular.cjs.map +1 -1
  29. package/dist/components/angular.js +7 -6
  30. package/dist/components/angular.js.map +1 -1
  31. package/dist/components/background.js +2 -2
  32. package/dist/components/bridge.js +1 -1
  33. package/dist/components/cards.js +2 -2
  34. package/dist/components/click.js +3 -3
  35. package/dist/components/depth.js +3 -3
  36. package/dist/components/effects.cjs +71 -403
  37. package/dist/components/effects.cjs.map +1 -1
  38. package/dist/components/effects.js +8 -339
  39. package/dist/components/effects.js.map +1 -1
  40. package/dist/components/feedback.js +1 -1
  41. package/dist/components/fx-gpu.cjs +12 -0
  42. package/dist/components/fx-gpu.cjs.map +1 -0
  43. package/dist/components/fx-gpu.d.cts +63 -0
  44. package/dist/components/fx-gpu.d.ts +63 -0
  45. package/dist/components/fx-gpu.js +5 -0
  46. package/dist/components/fx-gpu.js.map +1 -0
  47. package/dist/components/fx.cjs +13 -133
  48. package/dist/components/fx.cjs.map +1 -1
  49. package/dist/components/fx.js +6 -125
  50. package/dist/components/fx.js.map +1 -1
  51. package/dist/components/fx2.cjs +25 -0
  52. package/dist/components/fx2.cjs.map +1 -0
  53. package/dist/components/fx2.d.cts +136 -0
  54. package/dist/components/fx2.d.ts +136 -0
  55. package/dist/components/fx2.js +17 -0
  56. package/dist/components/fx2.js.map +1 -0
  57. package/dist/components/gesture.js +4 -4
  58. package/dist/components/interaction.js +1 -1
  59. package/dist/components/layout.js +1 -1
  60. package/dist/components/lite.cjs +5 -9
  61. package/dist/components/lite.cjs.map +1 -1
  62. package/dist/components/lite.js +5 -9
  63. package/dist/components/lite.js.map +1 -1
  64. package/dist/components/packs.js +1 -1
  65. package/dist/components/page.js +3 -3
  66. package/dist/components/perf.js +2 -2
  67. package/dist/components/physics.js +3 -3
  68. package/dist/components/reveal.js +1 -1
  69. package/dist/components/solid.cjs +1 -0
  70. package/dist/components/solid.cjs.map +1 -1
  71. package/dist/components/solid.js +7 -6
  72. package/dist/components/solid.js.map +1 -1
  73. package/dist/components/svelte.cjs +1 -0
  74. package/dist/components/svelte.cjs.map +1 -1
  75. package/dist/components/svelte.js +7 -6
  76. package/dist/components/svelte.js.map +1 -1
  77. package/dist/components/svg.js +1 -1
  78. package/dist/components/text.js +2 -2
  79. package/dist/components/timeline.js +3 -3
  80. package/dist/components/transitions.js +1 -1
  81. package/dist/components/ui.js +4 -4
  82. package/dist/components/vue.cjs +1 -0
  83. package/dist/components/vue.cjs.map +1 -1
  84. package/dist/components/vue.js +7 -6
  85. package/dist/components/vue.js.map +1 -1
  86. package/dist/components/webgl.js +1 -1
  87. package/dist/components/widgets.cjs +591 -0
  88. package/dist/components/widgets.cjs.map +1 -0
  89. package/dist/components/widgets.d.cts +110 -0
  90. package/dist/components/widgets.d.ts +110 -0
  91. package/dist/components/widgets.js +581 -0
  92. package/dist/components/widgets.js.map +1 -0
  93. package/dist/components.cjs +10 -9
  94. package/dist/components.cjs.map +1 -1
  95. package/dist/components.js +10 -9
  96. package/dist/components.js.map +1 -1
  97. package/dist/components.umd.js +2 -2
  98. package/dist/components.umd.js.map +1 -1
  99. package/dist/index.js +2 -2
  100. package/dist/widgets.umd.js +2 -0
  101. package/dist/widgets.umd.js.map +1 -0
  102. package/docs/ROADMAP.md +10 -11
  103. package/docs/components.md +29 -0
  104. package/package.json +31 -1
@@ -0,0 +1,581 @@
1
+ import { x as defineElement } from '../chunks/base-C_3cAoRz.js';
2
+ import { d as springEasing } from '../chunks/spring-CbvHfVtP.js';
3
+
4
+ /** Helpers shared by the 6.x widgets (`motionary/components/widgets`). */
5
+ const clampN = (v, a, b) => Math.min(b, Math.max(a, v));
6
+ /** Children of `el` that are elements and not created by the widget itself. */
7
+ const ownChildren = (el, skip = '[data-usa-part]') => Array.from(el.children).filter((c) => c instanceof HTMLElement && !c.matches(skip));
8
+ /** Create a part element (marked so re-mounts can find / skip it). */
9
+ function part(tag, cls, attrs = {}, html = '') {
10
+ const n = document.createElement(tag);
11
+ n.className = cls;
12
+ n.setAttribute('data-usa-part', '');
13
+ for (const [k, v] of Object.entries(attrs))
14
+ n.setAttribute(k, v);
15
+ if (html)
16
+ n.innerHTML = html;
17
+ return n;
18
+ }
19
+ /** Remove the parts a previous mount created. */
20
+ const dropParts = (el) => el.querySelectorAll(':scope > [data-usa-part]').forEach((n) => n.remove());
21
+ let uid = 0;
22
+ /** A document-unique id with a prefix. */
23
+ const nextId = (p) => `${p}-${++uid}`;
24
+ /** Roving arrow-key focus over `items` (horizontal or vertical); returns the new index or -1. */
25
+ function arrowIndex(e, i, n, vertical = false) {
26
+ const prev = vertical ? 'ArrowUp' : 'ArrowLeft';
27
+ const next = vertical ? 'ArrowDown' : 'ArrowRight';
28
+ if (e.key === prev)
29
+ return (i - 1 + n) % n;
30
+ if (e.key === next)
31
+ return (i + 1) % n;
32
+ if (e.key === 'Home')
33
+ return 0;
34
+ if (e.key === 'End')
35
+ return n - 1;
36
+ return -1;
37
+ }
38
+
39
+ var css$3 = "usa-carousel{display:block;position:relative;--usa-carousel-dur:520ms;--usa-carousel-ease:cubic-bezier(.22,1,.36,1);overflow:hidden;border-radius:var(--usa-radius,14px);touch-action:pan-y}.usa-carousel-viewport{position:relative;overflow:hidden;height:100%;min-height:inherit}.usa-carousel-track{display:flex;height:100%;transition:transform var(--usa-carousel-dur) var(--usa-carousel-ease);will-change:transform}.usa-carousel-track>*{flex:0 0 100%;min-width:0;box-sizing:border-box}usa-carousel:not([data-effect=\"slide\"]) .usa-carousel-track{display:grid}usa-carousel:not([data-effect=\"slide\"]) .usa-carousel-track>*{grid-area:1/1;transition:opacity var(--usa-carousel-dur) ease,transform var(--usa-carousel-dur) var(--usa-carousel-ease),filter var(--usa-carousel-dur) ease}usa-carousel[data-effect=\"cards\"] .usa-carousel-viewport{perspective:900px}usa-carousel[data-dragging] .usa-carousel-track,usa-carousel[data-dragging] .usa-carousel-track>*{transition:none}.usa-carousel-nav{position:absolute;top:50%;translate:0 -50%;z-index:2;width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.85);color:#111;font:600 18px/1 system-ui;cursor:pointer;display:grid;place-items:center;box-shadow:0 4px 14px rgba(0,0,0,.18);transition:transform .2s}.usa-carousel-nav:hover{transform:scale(1.08)}.usa-carousel-nav:focus-visible{outline:2px solid #7c5cff;outline-offset:2px}.usa-carousel-prev{left:10px}.usa-carousel-next{right:10px}.usa-carousel-dots{position:absolute;left:0;right:0;bottom:10px;display:flex;justify-content:center;gap:6px;z-index:2}.usa-carousel-dot{width:8px;height:8px;padding:0;border:0;border-radius:99px;background:rgba(255,255,255,.55);cursor:pointer;transition:width .35s var(--usa-carousel-ease),background .35s}.usa-carousel-dot[aria-current=\"true\"]{width:22px;background:#fff}@media (prefers-reduced-motion:reduce){usa-carousel .usa-carousel-track,usa-carousel .usa-carousel-track>*,.usa-carousel-dot{transition:none!important}}usa-carousel[data-reduced] .usa-carousel-track,usa-carousel[data-reduced] .usa-carousel-track>*{transition:none!important}";
40
+
41
+ const CAROUSEL_EFFECTS = ['slide', 'fade', 'scale', 'cards'];
42
+ function defineCarousel(tag = 'usa-carousel') {
43
+ return defineElement(tag, (Base) => {
44
+ class UsaCarousel extends Base {
45
+ constructor() {
46
+ super(...arguments);
47
+ this._i = 0;
48
+ this._slides = [];
49
+ this._track = null;
50
+ this._timer = 0;
51
+ this._hold = false;
52
+ this._dots = [];
53
+ }
54
+ static get observedAttributes() {
55
+ return ['effect', 'autoplay', 'loop', 'no-controls', 'no-dots'];
56
+ }
57
+ get length() {
58
+ return this._slides.length;
59
+ }
60
+ get index() {
61
+ return this._i;
62
+ }
63
+ set index(v) {
64
+ this.goTo(v);
65
+ }
66
+ get effect() {
67
+ const e = this.str('effect', 'slide');
68
+ return CAROUSEL_EFFECTS.includes(e) ? e : 'slide';
69
+ }
70
+ mount() {
71
+ this.dataset.effect = this.effect; // (not the observed attribute: no re-mount loop)
72
+ this.toggleAttribute('data-reduced', this.reduced);
73
+ const old = this.querySelector(':scope > .usa-carousel-viewport');
74
+ this._slides = old ? ownChildren(old.firstElementChild) : ownChildren(this);
75
+ dropParts(this);
76
+ const vp = part('div', 'usa-carousel-viewport', { 'aria-live': this.num('autoplay', 0) ? 'off' : 'polite' });
77
+ const track = part('div', 'usa-carousel-track');
78
+ this._track = track;
79
+ vp.append(track);
80
+ const n = this._slides.length;
81
+ this._slides.forEach((s, i) => {
82
+ s.setAttribute('role', 'group');
83
+ s.setAttribute('aria-roledescription', 'slide');
84
+ s.setAttribute('aria-label', `${i + 1} of ${n}`);
85
+ track.append(s);
86
+ });
87
+ this.prepend(vp);
88
+ this.setAttribute('role', 'region');
89
+ this.setAttribute('aria-roledescription', 'carousel');
90
+ this.setAttribute('aria-label', this.str('label', 'Carousel'));
91
+ if (!this.hasAttribute('tabindex'))
92
+ this.tabIndex = 0;
93
+ if (n > 1 && !this.flag('no-controls')) {
94
+ const prev = part('button', 'usa-carousel-nav usa-carousel-prev', { type: 'button', 'aria-label': 'Previous slide' }, '‹');
95
+ const next = part('button', 'usa-carousel-nav usa-carousel-next', { type: 'button', 'aria-label': 'Next slide' }, '›');
96
+ this.listen(prev, 'click', () => this.prev());
97
+ this.listen(next, 'click', () => this.next());
98
+ this.append(prev, next);
99
+ }
100
+ this._dots = [];
101
+ if (n > 1 && !this.flag('no-dots')) {
102
+ const dots = part('div', 'usa-carousel-dots', { role: 'group', 'aria-label': 'Choose slide' });
103
+ for (let i = 0; i < n; i++) {
104
+ const d = part('button', 'usa-carousel-dot', { type: 'button', 'aria-label': `Slide ${i + 1}` });
105
+ this.listen(d, 'click', () => this.goTo(i));
106
+ this._dots.push(d);
107
+ dots.append(d);
108
+ }
109
+ this.append(dots);
110
+ }
111
+ this._i = clampN(Math.round(this.num('index', 0)), 0, Math.max(0, n - 1));
112
+ this.layout(0);
113
+ this.listen(this, 'keydown', (e) => {
114
+ if (e.key === 'ArrowRight')
115
+ (e.preventDefault(), this.next());
116
+ else if (e.key === 'ArrowLeft')
117
+ (e.preventDefault(), this.prev());
118
+ });
119
+ this.drag(vp);
120
+ const ms = this.num('autoplay', 0);
121
+ if (ms > 0 && n > 1 && !this.reduced) {
122
+ let visible = true;
123
+ this.inView((v) => (visible = v));
124
+ const pause = (on) => () => (this._hold = on);
125
+ this.listen(this, 'pointerenter', pause(true));
126
+ this.listen(this, 'pointerleave', pause(false));
127
+ this.listen(this, 'focusin', pause(true));
128
+ this.listen(this, 'focusout', pause(false));
129
+ this._timer = window.setInterval(() => {
130
+ if (visible && !this._hold && !document.hidden)
131
+ this.next();
132
+ }, Math.max(1200, ms));
133
+ this.onCleanup(() => clearInterval(this._timer));
134
+ }
135
+ }
136
+ drag(vp) {
137
+ let x0 = 0;
138
+ let dx = 0;
139
+ let id = -1;
140
+ this.listen(vp, 'pointerdown', (e) => {
141
+ if (this.length < 2 || e.target.closest('button,a,input'))
142
+ return;
143
+ id = e.pointerId;
144
+ x0 = e.clientX;
145
+ dx = 0;
146
+ this.setAttribute('data-dragging', '');
147
+ });
148
+ this.listen(window, 'pointermove', (e) => {
149
+ if (e.pointerId !== id)
150
+ return;
151
+ dx = e.clientX - x0;
152
+ this.layout(dx / Math.max(1, vp.clientWidth));
153
+ });
154
+ const end = (e) => {
155
+ if (e.pointerId !== id)
156
+ return;
157
+ id = -1;
158
+ this.removeAttribute('data-dragging');
159
+ const w = Math.max(1, vp.clientWidth);
160
+ if (Math.abs(dx) > w * 0.18)
161
+ dx < 0 ? this.next() : this.prev();
162
+ else
163
+ this.layout(0);
164
+ };
165
+ this.listen(window, 'pointerup', end);
166
+ this.listen(window, 'pointercancel', end);
167
+ }
168
+ /** Position the slides (`drag` = fraction of a slide the pointer moved). */
169
+ layout(drag) {
170
+ const n = this.length;
171
+ const i = this._i;
172
+ const fx = this.effect;
173
+ if (this._track)
174
+ this._track.style.transform = fx === 'slide' ? `translateX(${(-i + drag) * 100}%)` : '';
175
+ this._slides.forEach((s, k) => {
176
+ let off = k - i + drag;
177
+ if (this.flag('loop') && n > 2) {
178
+ if (off > n / 2)
179
+ off -= n;
180
+ if (off < -n / 2)
181
+ off += n;
182
+ }
183
+ const active = k === i;
184
+ s.toggleAttribute('data-active', active);
185
+ s.setAttribute('aria-hidden', String(!active));
186
+ s.inert = !active;
187
+ if (fx === 'slide') {
188
+ s.style.transform = s.style.opacity = s.style.zIndex = s.style.filter = '';
189
+ return;
190
+ }
191
+ const a = Math.abs(off);
192
+ if (fx === 'fade') {
193
+ s.style.opacity = String(clampN(1 - a, 0, 1));
194
+ s.style.transform = '';
195
+ }
196
+ else if (fx === 'scale') {
197
+ s.style.opacity = String(clampN(1 - a, 0, 1));
198
+ s.style.transform = `scale(${1 + Math.min(1, a) * (off < 0 ? 0.12 : -0.12)})`;
199
+ }
200
+ else {
201
+ s.style.opacity = a > 2.2 ? '0' : String(1 - Math.min(a, 2) * 0.28);
202
+ s.style.transform = `translateX(${off * 58}%) translateZ(${-a * 140}px) rotateY(${clampN(-off * 38, -60, 60)}deg)`;
203
+ s.style.filter = a > 0.5 ? `brightness(${1 - Math.min(a, 2) * 0.18})` : '';
204
+ }
205
+ s.style.zIndex = String(100 - Math.round(a * 10));
206
+ });
207
+ this._dots.forEach((d, k) => d.setAttribute('aria-current', String(k === i)));
208
+ }
209
+ goTo(to) {
210
+ const n = this.length;
211
+ if (!n)
212
+ return;
213
+ const t = this.flag('loop') ? ((Math.round(to) % n) + n) % n : clampN(Math.round(to), 0, n - 1);
214
+ const from = this._i;
215
+ this._i = t;
216
+ this.layout(0);
217
+ if (t !== from)
218
+ this.emit('change', { index: t, from });
219
+ }
220
+ next() {
221
+ this.goTo(this._i + 1 >= this.length && !this.flag('loop') ? 0 : this._i + 1);
222
+ }
223
+ prev() {
224
+ this.goTo(this._i - 1 < 0 && !this.flag('loop') ? this.length - 1 : this._i - 1);
225
+ }
226
+ }
227
+ return UsaCarousel;
228
+ }, { id: 'carousel', text: css$3 });
229
+ }
230
+
231
+ var css$2 = "usa-tab-bar{display:block;--usa-tab-accent:#7c5cff;--usa-tab-ease:cubic-bezier(.22,1,.36,1)}.usa-tab-bar-list{position:relative;display:flex;gap:4px;padding:4px;border-radius:12px;background:rgba(127,127,127,.12);isolation:isolate;overflow-x:auto;scrollbar-width:none}.usa-tab-bar-list::-webkit-scrollbar{display:none}.usa-tab-bar-list>[role=\"tab\"]{position:relative;z-index:1;flex:1 0 auto;border:0;background:none;color:inherit;font:inherit;font-weight:600;padding:8px 14px;border-radius:9px;cursor:pointer;opacity:.7;transition:opacity .25s,color .25s;white-space:nowrap}.usa-tab-bar-list>[role=\"tab\"][aria-selected=\"true\"]{opacity:1}.usa-tab-bar-list>[role=\"tab\"]:focus-visible{outline:2px solid var(--usa-tab-accent);outline-offset:1px}.usa-tab-bar-ink{position:absolute;z-index:0;left:0;top:4px;bottom:4px;width:0;border-radius:9px;background:var(--usa-tab-accent);pointer-events:none}usa-tab-bar[data-indicator=\"pill\"] [aria-selected=\"true\"]{color:#fff}usa-tab-bar[data-indicator=\"underline\"] .usa-tab-bar-list{background:none;border-bottom:1px solid rgba(127,127,127,.25);border-radius:0}usa-tab-bar[data-indicator=\"underline\"] .usa-tab-bar-ink{top:auto;bottom:0;height:3px;border-radius:3px}usa-tab-bar[data-indicator=\"glow\"] .usa-tab-bar-ink{background:transparent;box-shadow:0 0 0 2px var(--usa-tab-accent),0 0 18px var(--usa-tab-accent)}usa-tab-bar[data-indicator=\"gooey\"] .usa-tab-bar-ink{filter:blur(.5px);border-radius:999px}usa-tab-bar[data-indicator=\"gooey\"] [aria-selected=\"true\"]{color:#fff}.usa-tab-bar-panel{padding:14px 2px}.usa-tab-bar-panel[hidden]{display:none}";
232
+
233
+ const TAB_INDICATORS = ['pill', 'underline', 'glow', 'gooey'];
234
+ function defineTabBar(tag = 'usa-tab-bar') {
235
+ return defineElement(tag, (Base) => {
236
+ class UsaTabBar extends Base {
237
+ constructor() {
238
+ super(...arguments);
239
+ this._tabs = [];
240
+ this._panels = [];
241
+ this._ink = null;
242
+ this._i = 0;
243
+ }
244
+ static get observedAttributes() {
245
+ return ['indicator'];
246
+ }
247
+ get selected() {
248
+ return this._i;
249
+ }
250
+ set selected(v) {
251
+ this.select(v);
252
+ }
253
+ mount() {
254
+ const ind = this.str('indicator', 'pill');
255
+ this.dataset.indicator = TAB_INDICATORS.includes(ind) ? ind : 'pill';
256
+ let list = this.querySelector(':scope > .usa-tab-bar-list');
257
+ if (!list) {
258
+ list = part('div', 'usa-tab-bar-list');
259
+ this.prepend(list);
260
+ }
261
+ list.setAttribute('role', 'tablist');
262
+ list.setAttribute('aria-label', this.str('label', 'Tabs'));
263
+ const kids = ownChildren(this);
264
+ this._panels = kids.filter((k) => k.hasAttribute('data-panel'));
265
+ for (const k of kids)
266
+ if (!k.hasAttribute('data-panel') && k.matches('button,[data-tab]'))
267
+ list.append(k);
268
+ this._tabs = Array.from(list.children).filter((c) => c instanceof HTMLElement && !c.classList.contains('usa-tab-bar-ink'));
269
+ this._ink = list.querySelector('.usa-tab-bar-ink') || part('span', 'usa-tab-bar-ink', { 'aria-hidden': 'true' });
270
+ list.prepend(this._ink);
271
+ this._tabs.forEach((t, i) => {
272
+ t.setAttribute('role', 'tab');
273
+ if (t.localName === 'button' && !t.hasAttribute('type'))
274
+ t.setAttribute('type', 'button');
275
+ t.id || (t.id = nextId('usa-tab'));
276
+ const p = this._panels[i];
277
+ if (p) {
278
+ p.id || (p.id = nextId('usa-tabpanel'));
279
+ p.classList.add('usa-tab-bar-panel');
280
+ p.setAttribute('role', 'tabpanel');
281
+ p.setAttribute('aria-labelledby', t.id);
282
+ p.tabIndex = 0;
283
+ t.setAttribute('aria-controls', p.id);
284
+ }
285
+ this.listen(t, 'click', () => this.select(i));
286
+ });
287
+ this.listen(list, 'keydown', (e) => {
288
+ const n = arrowIndex(e, this._i, this._tabs.length);
289
+ if (n < 0)
290
+ return;
291
+ e.preventDefault();
292
+ this.select(n);
293
+ this._tabs[n].focus();
294
+ });
295
+ this._i = Math.min(Math.max(0, Math.round(this.num('selected', 0))), Math.max(0, this._tabs.length - 1));
296
+ this.sync(-1);
297
+ if (typeof ResizeObserver === 'function') {
298
+ const ro = new ResizeObserver(() => this.place());
299
+ ro.observe(list);
300
+ this.onCleanup(() => ro.disconnect());
301
+ }
302
+ }
303
+ rect(i) {
304
+ const t = this._tabs[i];
305
+ return t ? [t.offsetLeft, t.offsetWidth] : [0, 0];
306
+ }
307
+ place() {
308
+ if (!this._ink)
309
+ return;
310
+ const [x, w] = this.rect(this._i);
311
+ this._ink.style.transform = `translateX(${x}px)`;
312
+ this._ink.style.width = `${w}px`;
313
+ }
314
+ sync(from) {
315
+ this._tabs.forEach((t, k) => {
316
+ t.setAttribute('aria-selected', String(k === this._i));
317
+ t.tabIndex = k === this._i ? 0 : -1;
318
+ });
319
+ this._panels.forEach((p, k) => (p.hidden = k !== this._i));
320
+ this.place();
321
+ if (from < 0 || from === this._i || !this._ink || this.reduced)
322
+ return;
323
+ // stretchy travel: the leading edge arrives first, the trailing edge follows
324
+ const [x0, w0] = this.rect(from);
325
+ const [x1, w1] = this.rect(this._i);
326
+ const right = x1 > x0;
327
+ const mid = right ? { transform: `translateX(${x0}px)`, width: `${x1 + w1 - x0}px` } : { transform: `translateX(${x1}px)`, width: `${x0 + w0 - x1}px` };
328
+ this.motion(this._ink, [{ transform: `translateX(${x0}px)`, width: `${w0}px` }, { ...mid, offset: 0.45 }, { transform: `translateX(${x1}px)`, width: `${w1}px` }], { duration: 480, easing: 'cubic-bezier(.22,1,.36,1)' });
329
+ const p = this._panels[this._i];
330
+ if (p)
331
+ this.motion(p, [{ opacity: 0, transform: `translateX(${right ? 24 : -24}px)` }, { opacity: 1, transform: 'none' }], { duration: 320, easing: 'cubic-bezier(.22,1,.36,1)' });
332
+ }
333
+ select(i) {
334
+ const n = Math.min(Math.max(0, Math.round(i)), this._tabs.length - 1);
335
+ if (n === this._i || n < 0)
336
+ return;
337
+ const from = this._i;
338
+ this._i = n;
339
+ this.sync(from);
340
+ this.emit('change', { index: n, from });
341
+ }
342
+ }
343
+ return UsaTabBar;
344
+ }, { id: 'tab-bar', text: css$2 });
345
+ }
346
+
347
+ var css$1 = "usa-disclosure{display:block;--usa-disclosure-accent:#7c5cff}usa-disclosure>details{border-bottom:1px solid rgba(127,127,127,.25);overflow:hidden}usa-disclosure>details>summary{list-style:none;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 4px;font-weight:600}usa-disclosure>details>summary::-webkit-details-marker{display:none}usa-disclosure>details>summary::after{content:\"\";flex:none;width:9px;height:9px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;rotate:45deg;translate:0 -3px;transition:rotate .35s cubic-bezier(.34,1.56,.64,1),translate .35s}usa-disclosure>details[open]>summary::after{rotate:225deg;translate:0 2px}usa-disclosure>details>summary:focus-visible{outline:2px solid var(--usa-disclosure-accent);outline-offset:2px;border-radius:6px}usa-disclosure>details>:not(summary){padding:0 4px 12px}usa-disclosure[variant=\"cards\"]>details{border:1px solid rgba(127,127,127,.25);border-radius:12px;margin-bottom:8px;padding:0 10px;transition:box-shadow .3s,border-color .3s}usa-disclosure[variant=\"cards\"]>details[open]{border-color:var(--usa-disclosure-accent);box-shadow:0 8px 24px rgba(124,92,255,.16)}@media (prefers-reduced-motion:reduce){usa-disclosure>details>summary::after{transition:none}}";
348
+
349
+ function defineDisclosure(tag = 'usa-disclosure') {
350
+ return defineElement(tag, (Base) => {
351
+ class UsaDisclosure extends Base {
352
+ constructor() {
353
+ super(...arguments);
354
+ this._anims = new WeakMap();
355
+ }
356
+ get items() {
357
+ return Array.from(this.children).filter((c) => c.localName === 'details');
358
+ }
359
+ mount() {
360
+ this.listen(this, 'click', (e) => {
361
+ const s = e.target.closest('summary');
362
+ const d = s?.parentElement;
363
+ if (!s || !d || d.parentElement !== this)
364
+ return;
365
+ e.preventDefault();
366
+ this.set(d, !d.open);
367
+ });
368
+ }
369
+ set(d, open) {
370
+ if (open && !this.flag('multiple'))
371
+ for (const o of this.items)
372
+ if (o !== d && o.open)
373
+ this.set(o, false);
374
+ if (d.open === open && !this._anims.get(d))
375
+ return;
376
+ const summary = d.querySelector('summary');
377
+ const closedH = summary ? summary.offsetHeight : 0;
378
+ const startH = d.offsetHeight;
379
+ this._anims.get(d)?.cancel();
380
+ if (open)
381
+ d.open = true;
382
+ const endH = open ? d.scrollHeight : closedH;
383
+ const sp = springEasing(this.str('spring', 'gentle'));
384
+ const a = this.reduced ? null : this.motion(d, [{ height: `${startH}px` }, { height: `${endH}px` }], { duration: Math.min(sp.duration, 700), easing: sp.easing, fill: 'forwards' });
385
+ const body = Array.from(d.children).filter((c) => c.localName !== 'summary');
386
+ if (open && !this.reduced)
387
+ body.forEach((b) => this.motion(b, [{ opacity: 0, transform: 'translateY(-6px)' }, { opacity: 1, transform: 'none' }], { duration: 300, delay: 60, easing: 'ease-out' }));
388
+ const done = () => {
389
+ this._anims.delete(d);
390
+ if (!open)
391
+ d.open = false;
392
+ a?.cancel();
393
+ };
394
+ if (a) {
395
+ this._anims.set(d, a);
396
+ a.finished.then(() => this._anims.get(d) === a && done(), () => undefined);
397
+ }
398
+ else
399
+ done();
400
+ this.emit('toggle', { index: this.items.indexOf(d), open });
401
+ }
402
+ toggle(i, force) {
403
+ const d = this.items[i];
404
+ if (d)
405
+ this.set(d, force ?? !d.open);
406
+ }
407
+ openAll() {
408
+ this.items.forEach((d) => (d.open = true));
409
+ }
410
+ closeAll() {
411
+ this.items.forEach((d) => this.set(d, false));
412
+ }
413
+ }
414
+ return UsaDisclosure;
415
+ }, { id: 'disclosure', text: css$1 });
416
+ }
417
+
418
+ var css = "usa-stories{display:block;position:relative;overflow:hidden;border-radius:var(--usa-radius,16px);background:#111;color:#fff;aspect-ratio:9/14;max-height:520px;user-select:none;-webkit-user-select:none;touch-action:manipulation}usa-stories>:not([data-usa-part]){position:absolute;inset:0;opacity:0;transition:opacity .35s ease,transform .5s cubic-bezier(.22,1,.36,1);transform:scale(1.04);pointer-events:none;box-sizing:border-box}usa-stories>[data-active]:not([data-usa-part]){opacity:1;transform:none;pointer-events:auto}usa-stories>img:not([data-usa-part]){width:100%;height:100%;object-fit:cover}.usa-stories-bars{position:absolute;z-index:3;top:8px;left:8px;right:48px;display:flex;gap:4px}.usa-stories-bar{flex:1;height:3px;border-radius:3px;background:rgba(255,255,255,.35);overflow:hidden}.usa-stories-bar>i{display:block;height:100%;width:100%;background:#fff;transform-origin:left;transform:scaleX(0)}.usa-stories-bar[data-done]>i{transform:scaleX(1)}.usa-stories-toggle{position:absolute;z-index:3;top:2px;right:6px;width:36px;height:30px;border:0;background:none;color:#fff;font:700 14px/1 system-ui;cursor:pointer;border-radius:8px}.usa-stories-toggle:focus-visible{outline:2px solid #fff}@media (prefers-reduced-motion:reduce){usa-stories>*{transition:none!important;transform:none!important}}";
419
+
420
+ function defineStories(tag = 'usa-stories') {
421
+ return defineElement(tag, (Base) => {
422
+ class UsaStories extends Base {
423
+ constructor() {
424
+ super(...arguments);
425
+ this._i = 0;
426
+ this._items = [];
427
+ this._bars = [];
428
+ this._fill = null;
429
+ this._btn = null;
430
+ }
431
+ static get observedAttributes() {
432
+ return ['duration', 'loop'];
433
+ }
434
+ get index() {
435
+ return this._i;
436
+ }
437
+ mount() {
438
+ dropParts(this);
439
+ this._items = ownChildren(this);
440
+ const bars = part('div', 'usa-stories-bars', { 'aria-hidden': 'true' });
441
+ this._bars = this._items.map(() => {
442
+ const b = part('div', 'usa-stories-bar', {}, '<i></i>');
443
+ bars.append(b);
444
+ return b;
445
+ });
446
+ this._btn = part('button', 'usa-stories-toggle', { type: 'button' });
447
+ this.listen(this._btn, 'click', (e) => {
448
+ e.stopPropagation();
449
+ this.hasAttribute('paused') ? this.play() : this.pause();
450
+ });
451
+ this.append(bars, this._btn);
452
+ this.setAttribute('role', 'region');
453
+ this.setAttribute('aria-roledescription', 'stories');
454
+ if (!this.hasAttribute('aria-label'))
455
+ this.setAttribute('aria-label', 'Stories');
456
+ if (!this.hasAttribute('tabindex'))
457
+ this.tabIndex = 0;
458
+ if (this.reduced)
459
+ this.setAttribute('paused', '');
460
+ let held = false;
461
+ let downAt = 0;
462
+ this.listen(this, 'pointerdown', (e) => {
463
+ if (e.target.closest('button,a'))
464
+ return;
465
+ downAt = performance.now();
466
+ held = !this.hasAttribute('paused');
467
+ if (held)
468
+ this._fill?.pause();
469
+ });
470
+ this.listen(this, 'pointerup', (e) => {
471
+ if (e.target.closest('button,a') || !downAt)
472
+ return;
473
+ const long = performance.now() - downAt > 350;
474
+ downAt = 0;
475
+ if (held && !this.hasAttribute('paused'))
476
+ this._fill?.play();
477
+ if (long)
478
+ return;
479
+ const r = this.getBoundingClientRect();
480
+ e.clientX - r.left < r.width / 3 ? this.prev() : this.next();
481
+ });
482
+ this.listen(this, 'keydown', (e) => {
483
+ if (e.key === 'ArrowRight')
484
+ this.next();
485
+ else if (e.key === 'ArrowLeft')
486
+ this.prev();
487
+ else if (e.key === ' ')
488
+ (e.preventDefault(), this.hasAttribute('paused') ? this.play() : this.pause());
489
+ });
490
+ this.onCleanup(() => this._fill?.cancel());
491
+ this.goTo(Math.min(this._i, Math.max(0, this._items.length - 1)), true);
492
+ }
493
+ label() {
494
+ if (this._btn) {
495
+ const p = this.hasAttribute('paused');
496
+ this._btn.textContent = p ? '▶' : '❚❚';
497
+ this._btn.setAttribute('aria-label', p ? 'Play stories' : 'Pause stories');
498
+ }
499
+ }
500
+ goTo(i, initial = false) {
501
+ const n = this._items.length;
502
+ if (!n)
503
+ return;
504
+ if (i >= n && !this.flag('loop')) {
505
+ this.emit('end');
506
+ this.pause();
507
+ return;
508
+ }
509
+ const t = ((i % n) + n) % n;
510
+ const changed = t !== this._i || initial;
511
+ this._i = t;
512
+ this._items.forEach((s, k) => {
513
+ s.toggleAttribute('data-active', k === t);
514
+ s.setAttribute('aria-hidden', String(k !== t));
515
+ });
516
+ this._bars.forEach((b, k) => b.toggleAttribute('data-done', k < t));
517
+ this._fill?.cancel();
518
+ const fillEl = this._bars[t]?.firstElementChild;
519
+ this._fill = fillEl ? fillEl.animate?.([{ transform: 'scaleX(0)' }, { transform: 'scaleX(1)' }], { duration: Math.max(800, this.num('duration', 5000)), fill: 'forwards' }) ?? null : null;
520
+ if (this._fill) {
521
+ const a = this._fill;
522
+ a.onfinish = () => this._fill === a && this.goTo(this._i + 1);
523
+ if (this.hasAttribute('paused'))
524
+ a.pause();
525
+ }
526
+ this.label();
527
+ if (changed && !initial)
528
+ this.emit('change', { index: t });
529
+ }
530
+ next() {
531
+ this.goTo(this._i + 1);
532
+ }
533
+ prev() {
534
+ this.goTo(Math.max(0, this._i - 1));
535
+ }
536
+ pause() {
537
+ this.setAttribute('paused', '');
538
+ this._fill?.pause();
539
+ this.label();
540
+ }
541
+ play() {
542
+ this.removeAttribute('paused');
543
+ if (this._fill?.playState === 'finished')
544
+ this.goTo(this._i + 1 >= this._items.length ? 0 : this._i + 1);
545
+ else
546
+ this._fill?.play();
547
+ this.label();
548
+ }
549
+ }
550
+ return UsaStories;
551
+ }, { id: 'stories', text: css });
552
+ }
553
+
554
+ /**
555
+ * motionary/components/widgets — the 6.x animated UI widgets, in their own
556
+ * entry so `motionary/components` and `components/lite` keep their size
557
+ * budgets. Every widget is reduced-motion safe and keyboard accessible.
558
+ *
559
+ * ```ts
560
+ * import { defineWidgets } from 'motionary/components/widgets';
561
+ * defineWidgets(); // or defineCarousel(), defineTabBar(), …
562
+ * ```
563
+ * No build step: `<script src="https://unpkg.com/motionary@6/dist/widgets.umd.js">`
564
+ * (registers every widget and every 6.x effect pack; `window.UsaWidgets`).
565
+ */
566
+ /** The widgets by release (tag → define function). */
567
+ const WIDGETS = {
568
+ '6.2': { 'usa-carousel': defineCarousel, 'usa-tab-bar': defineTabBar, 'usa-disclosure': defineDisclosure, 'usa-stories': defineStories },
569
+ };
570
+ /** Every widget tag, in release order. */
571
+ const WIDGET_TAGS = Object.values(WIDGETS).flatMap((g) => Object.keys(g));
572
+ /** Register every widget (or only those of one release, e.g. `'6.2'`) under its default tag. */
573
+ function defineWidgets(release) {
574
+ for (const [v, group] of Object.entries(WIDGETS))
575
+ if (!release || release === v)
576
+ for (const [tag, fn] of Object.entries(group))
577
+ fn(tag);
578
+ }
579
+
580
+ export { CAROUSEL_EFFECTS, TAB_INDICATORS, WIDGETS, WIDGET_TAGS, defineCarousel, defineDisclosure, defineStories, defineTabBar, defineWidgets };
581
+ //# sourceMappingURL=widgets.js.map