use-scroll-animate 7.8.0 → 7.9.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.9.0] - 2026-10-08
11
+
12
+ ### Added
13
+ - **2 new components (7.9)** in `motionary/components/widgets` (also in `dist/widgets.umd.js`):
14
+ - `<usa-command-palette>` — ⌘K command palette on the native `<dialog>` (top layer, Esc, focus returns): scales in, fuzzy filtering with highlighted letters, results stagger in, a highlight glides between rows (↑ / ↓ / Enter, hover, click), groups. Commands from child `<option value data-group data-keys>` or `setCommands([{ id, label, group, keys }])`; `hotkey` (default `mod+k`, `none`), `inline` (rendered open in the page, no dialog), `placeholder`, `label`; `show()`, `close()`, `toggle()`, `opened`; `usa:run` { id, label }, `usa:open`, `usa:close`. Helpers `fuzzyMatch()`, `keyLabels()`, `matchesKeys()`.
15
+ - `<usa-shortcut keys="mod+k">` — keyboard-shortcut hint as keycaps (⌘ / ⇧ / ⌥ on Apple platforms, Ctrl / Shift / Alt elsewhere) with an optional `label`; pressing the combination anywhere presses the caps one after another and fires `usa:trigger` (`for="id"` clicks that element, `listen="false"` only displays); `press()`.
16
+ - **`npx usa-codemod-8`** (new bin) and **[docs/upgrading-8.md](./docs/upgrading-8.md)**.
17
+ - `<usa-star-rating>` is now form-associated (`name` submits the value) and also fires a native `change`; `icon` accepts the old `<usa-rating>` characters (★ ♥).
18
+ - Showcase: 2 new gallery cards with copyable code, live demos and live Store thumbnails; Animation Store 331 → 333 items.
19
+
20
+ ### Deprecated (removed in 8.0 — warns once in the console)
21
+ - `<usa-rating>` / `defineRating()` → `<usa-star-rating>` / `defineStarRating()` (same `value`, `max`, `readonly`, `label`, `name`; `icon="♥"` → `icon="heart"`; `--usa-rating-on` → `--usa-star-on`). `npx usa-codemod-8 --write src` rewrites tags, icons and the CSS variable (manual report for `defineRating`, `createElement` and CSS selectors).
22
+
23
+ ### Accessibility
24
+ - Palette: `combobox` input with `aria-activedescendant` over a `listbox` of `option`s (`aria-selected`), group headings are presentational, "No results" is shown as text. Shortcut: keycaps are one `role="img"` with a spoken label ("Command K" / "Control K"). Reduced motion: no scale, stagger, glide or key press.
25
+
10
26
  ## [7.8.0] - 2026-10-08
11
27
 
12
28
  ### Added
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ // motionary 7.x → 8.0 codemod.
3
+ // npx usa-codemod-8 [--write] [paths…] (default: ./src; dry run without --write)
4
+ // Rewrites (7.9 deprecations, removed in 8.0):
5
+ // 1. <usa-rating …> → <usa-star-rating …> (value / max / readonly / label / name unchanged;
6
+ // icon="♥" → icon="heart", icon="★" → icon="star"; a variant="…" attribute is dropped).
7
+ // 2. --usa-rating-on → --usa-star-on (CSS custom property).
8
+ // Reported for a manual change:
9
+ // 3. defineRating imports (use defineStarRating from motionary/components/widgets),
10
+ // document.createElement('usa-rating'), CSS selectors on usa-rating / .usa-rating-star.
11
+ import { readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs';
12
+ import { join, extname } from 'node:path';
13
+ import { pathToFileURL } from 'node:url';
14
+
15
+ const EXT = new Set(['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.mts', '.cts', '.vue', '.svelte', '.html', '.astro', '.md', '.mdx', '.css', '.scss']);
16
+ export const TAGS = { 'usa-rating': 'usa-star-rating' };
17
+ const ICONS = { '★': 'star', '☆': 'star', '♥': 'heart', '❤': 'heart', '❤️': 'heart' };
18
+
19
+ /** Apply every rewrite to one file's source. Returns { code, changes, manual }. */
20
+ export function transform(source) {
21
+ const changes = [];
22
+ const manual = [];
23
+ let code = source;
24
+ let n = 0;
25
+ code = code.replace(/<usa-rating(?=[\s>/])([^>]*)>/g, (_, attrs) => {
26
+ n++;
27
+ const a = attrs
28
+ .replace(/\sicon=(["'])(.*?)\1/g, (m, q, v) => (ICONS[v] ? ` icon=${q}${ICONS[v]}${q}` : m))
29
+ .replace(/\svariant=(["']).*?\1/g, '');
30
+ return `<usa-star-rating${a}>`;
31
+ });
32
+ const closes = (code.match(/<\/usa-rating>/g) || []).length;
33
+ code = code.replace(/<\/usa-rating>/g, '</usa-star-rating>');
34
+ if (n || closes) changes.push(`<usa-rating> → <usa-star-rating> (${Math.max(n, closes)}×)`);
35
+ const vars = (code.match(/--usa-rating-on\b/g) || []).length;
36
+ if (vars) {
37
+ code = code.replace(/--usa-rating-on\b/g, '--usa-star-on');
38
+ changes.push(`--usa-rating-on → --usa-star-on (${vars}×)`);
39
+ }
40
+ if (/createElement\((['"`])usa-rating\1\)/.test(code)) manual.push("document.createElement('usa-rating') — use 'usa-star-rating' (removed in 8.0)");
41
+ if (/(^|[\s,{}>+~])usa-rating(?=[\s.:#[{,>+~)]|$)|\.usa-rating-star\b/m.test(code.replace(/<\/?[a-z][^>]*>/g, ''))) manual.push('CSS selectors on usa-rating / .usa-rating-star — restyle <usa-star-rating> (.usa-star, --usa-star-on)');
42
+ if (/\bdefineRating\b/.test(code)) manual.push("defineRating() is removed in 8.0 — import { defineStarRating } from 'motionary/components/widgets'");
43
+ return { code, changes, manual };
44
+ }
45
+
46
+ function* walk(p) {
47
+ const st = statSync(p);
48
+ if (st.isDirectory()) {
49
+ for (const f of readdirSync(p)) if (!['node_modules', 'dist', '.git'].includes(f)) yield* walk(join(p, f));
50
+ } else if (EXT.has(extname(p))) yield p;
51
+ }
52
+
53
+ export function run(args) {
54
+ const write = args.includes('--write');
55
+ const paths = args.filter((a) => !a.startsWith('--'));
56
+ let files = 0;
57
+ let edits = 0;
58
+ let todo = 0;
59
+ for (const root of paths.length ? paths : ['src'])
60
+ for (const f of walk(root)) {
61
+ const src = readFileSync(f, 'utf8');
62
+ const { code, changes, manual } = transform(src);
63
+ if (!changes.length && !manual.length) continue;
64
+ files++;
65
+ edits += changes.length;
66
+ todo += manual.length;
67
+ console.log(`${f}${changes.map((c) => `\n - ${c}`).join('')}${manual.map((c) => `\n ! manual: ${c}`).join('')}`);
68
+ if (write && changes.length) writeFileSync(f, code);
69
+ }
70
+ console.log(`\n${files} file(s), ${edits} rewrite(s)${write ? ' applied' : ' (dry run — pass --write to apply)'}, ${todo} manual change(s).`);
71
+ return { files, edits, todo };
72
+ }
73
+
74
+ if (import.meta.url === pathToFileURL(process.argv[1] || '').href) run(process.argv.slice(2));
@@ -1130,6 +1130,10 @@ interface UsaSliderElement extends UsaElement {
1130
1130
  * Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
1131
1131
  * ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
1132
1132
  * Reduced motion: no pop.
1133
+ *
1134
+ * @deprecated 7.9 — removed in 8.0. Use `<usa-star-rating>` (6.4; same
1135
+ * `value` / `max` / `readonly` / `label` / `name`, `icon="heart"` for ♥).
1136
+ * `npx usa-codemod-8 --write src` rewrites the tags.
1133
1137
  */
1134
1138
  interface UsaRatingElement extends UsaElement {
1135
1139
  value: number;
@@ -1130,6 +1130,10 @@ interface UsaSliderElement extends UsaElement {
1130
1130
  * Attributes: `value` (0), `max` (5), `icon` (★), `readonly`, `label`
1131
1131
  * ("Rating"), `name` (form value), `variant`. Events: `change`, `usa:change` (`{ value }`).
1132
1132
  * Reduced motion: no pop.
1133
+ *
1134
+ * @deprecated 7.9 — removed in 8.0. Use `<usa-star-rating>` (6.4; same
1135
+ * `value` / `max` / `readonly` / `label` / `name`, `icon="heart"` for ♥).
1136
+ * `npx usa-codemod-8 --write src` rewrites the tags.
1133
1137
  */
1134
1138
  interface UsaRatingElement extends UsaElement {
1135
1139
  value: number;
@@ -7025,6 +7025,7 @@ function defineRating(tag = 'usa-rating') {
7025
7025
  this.sync();
7026
7026
  }
7027
7027
  mount() {
7028
+ deprecate('usa-rating', '<usa-rating> is deprecated and removed in 8.0 — use <usa-star-rating> (same value / max / readonly / label / name; icon="heart"). Run `npx usa-codemod-8 --write src`.');
7028
7029
  const max = this.num('max', 5);
7029
7030
  this.innerHTML = Array.from({ length: max }, (_, i) => `<span class="usa-rating-star" data-i="${i + 1}" aria-hidden="true">${this.str('icon', '★')}</span>`).join('');
7030
7031
  this.setAttribute('role', 'slider');