@uvalib/web-components 1.9.0 → 1.10.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 (48) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +235 -14
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base.css +115 -2
  5. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  6. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  7. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  8. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  9. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  10. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  11. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
  12. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
  13. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  14. package/dist/custom-elements.json +7502 -6348
  15. package/dist/edition.css +758 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/styles/base.js +72 -1
  20. package/dist/styles/base.js.map +1 -1
  21. package/dist/styles/controls.js +2 -0
  22. package/dist/styles/controls.js.map +1 -1
  23. package/dist/styles/edition.d.ts +1 -0
  24. package/dist/styles/edition.js +747 -0
  25. package/dist/styles/edition.js.map +1 -0
  26. package/dist/styles/hidden.js +2 -0
  27. package/dist/styles/hidden.js.map +1 -1
  28. package/dist/styles/layout.d.ts +1 -0
  29. package/dist/styles/layout.js +92 -0
  30. package/dist/styles/layout.js.map +1 -0
  31. package/dist-cdn/base.css +115 -2
  32. package/dist-cdn/chunks/{base-CHMHBPeI.js → base-DXkGlSgH.js} +73 -2
  33. package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
  34. package/dist-cdn/custom-elements.json +7502 -6348
  35. package/dist-cdn/edition.css +758 -0
  36. package/dist-cdn/manifest.json +5 -3
  37. package/dist-cdn/site-page.js +1 -1
  38. package/dist-cdn/site-style.js +1 -1
  39. package/dist-cdn/skills/uvalib-web-components/SKILL.md +29 -8
  40. package/dist-cdn/skills/uvalib-web-components/reference/components.md +53 -1
  41. package/dist-cdn/uvalib-list-filter.js +451 -0
  42. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  43. package/dist-cdn/uvalib-pagefind-search.js +118 -48
  44. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  45. package/package.json +6 -1
  46. package/skills/uvalib-web-components/SKILL.md +29 -8
  47. package/skills/uvalib-web-components/reference/components.md +53 -1
  48. package/dist-cdn/chunks/base-CHMHBPeI.js.map +0 -1
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
- // Usage: npx @uvalib/web-components install-skill [--dir .claude/skills] [--force]
3
- // npx @uvalib/web-components install-skill --check [--dir .claude/skills] [--strict]
2
+ // Usage: npx @uvalib/web-components install-skill [--global] [--agent <names>] [--dir <dir>] [--force]
3
+ // npx @uvalib/web-components install-skill --check [--global] [--agent <names>] [--dir <dir>] [--strict]
4
+ // npx @uvalib/web-components install-skill --list [--global] [--agent <names>]
4
5
  import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
5
- import { dirname, join, resolve } from 'node:path';
6
+ import { homedir } from 'node:os';
7
+ import { dirname, join, relative, resolve } from 'node:path';
6
8
  import { fileURLToPath } from 'node:url';
7
9
 
8
10
  const PACKAGE = '@uvalib/web-components';
@@ -10,16 +12,50 @@ const SKILL = 'uvalib-web-components';
10
12
  /** Written next to SKILL.md in every installed copy. */
11
13
  const STAMP = 'installed.json';
12
14
 
13
- const usage = `Usage: npx ${PACKAGE} install-skill [--dir <skills-dir>] [--force]
14
- npx ${PACKAGE} install-skill --check [--dir <skills-dir>] [--strict]
15
+ /**
16
+ * Where each agent looks for skills (the Agent Skills format, a folder with a SKILL.md):
17
+ * `project` relative to the current folder, `global` relative to the home folder. `agents` is
18
+ * the shared `.agents/skills` folder of the open standard, read by Codex, Gemini CLI, GitHub
19
+ * Copilot, Cursor, Grok and others; the rest are each tool's own folder, for tools or versions
20
+ * that do not read the shared one.
21
+ */
22
+ const AGENTS = {
23
+ agents: {
24
+ project: '.agents/skills',
25
+ global: '.agents/skills',
26
+ reads: 'Codex, Gemini CLI, GitHub Copilot, Cursor, Grok and other Agent Skills tools',
27
+ },
28
+ claude: { project: '.claude/skills', global: '.claude/skills', reads: 'Claude Code' },
29
+ codex: { project: '.agents/skills', global: '.agents/skills', reads: 'OpenAI Codex' },
30
+ gemini: { project: '.gemini/skills', global: '.gemini/skills', reads: 'Gemini CLI' },
31
+ copilot: { project: '.github/skills', global: '.copilot/skills', reads: 'GitHub Copilot' },
32
+ cursor: { project: '.cursor/skills', global: '.cursor/skills', reads: 'Cursor' },
33
+ grok: { project: '.agents/skills', global: '.grok/skills', reads: 'Grok' },
34
+ };
35
+ /** Claude Code reads only its own folder; everything else reads the shared one. */
36
+ const DEFAULT_AGENTS = ['claude', 'agents'];
15
37
 
16
- Copies the ${SKILL} agent skill into <skills-dir>/${SKILL}
17
- (default: .claude/skills) and records the package version in ${STAMP}.
18
- Refuses to overwrite an existing copy without --force.
38
+ const usage = `Usage: npx ${PACKAGE} install-skill [--global] [--agent <names>] [--dir <dir>] [--force]
39
+ npx ${PACKAGE} install-skill --check [--global] [--agent <names>] [--dir <dir>] [--strict]
40
+ npx ${PACKAGE} install-skill --list [--global] [--agent <names>]
19
41
 
20
- --check compares an installed copy with the latest release on npm. It prints one
21
- line, with the update command, only when the copy is missing or out of date, and
22
- exits 0 (so it can run as a Claude Code SessionStart hook); --strict exits 1
42
+ Copies the ${SKILL} agent skill (an Agent Skills folder with SKILL.md) into
43
+ <skills-dir>/${SKILL} for each agent, and records the package version in ${STAMP}.
44
+
45
+ (default) this project: .claude/skills (Claude Code) and .agents/skills
46
+ (Codex, Gemini CLI, GitHub Copilot, Cursor, Grok and other tools
47
+ that read the shared Agent Skills folder)
48
+ --global, -g your home folder instead (~/.claude/skills and ~/.agents/skills),
49
+ for every project on this computer
50
+ --agent <names> comma-separated: ${Object.keys(AGENTS).join(', ')}, or all
51
+ (each tool's own folder; see --list)
52
+ --dir <dir> one skills folder of your choosing instead (overrides the above)
53
+ --force overwrite existing copies (an update)
54
+ --list print the folders it would use, and exit
55
+
56
+ --check compares the installed copies with the latest release on npm. It prints one
57
+ line per copy, with the update command, only when a copy is missing or out of date,
58
+ and exits 0 (so it can run from an agent's session-start hook); --strict exits 1
23
59
  instead. A network failure only warns.`;
24
60
 
25
61
  const args = process.argv.slice(2);
@@ -28,43 +64,116 @@ if (args[0] !== 'install-skill') {
28
64
  process.exit(args[0] === '--help' || args[0] === '-h' ? 0 : 1);
29
65
  }
30
66
 
31
- let dir = '.claude/skills';
67
+ let dir = null;
32
68
  let force = false;
33
69
  let check = false;
34
70
  let strict = false;
71
+ let list = false;
72
+ let global = false;
73
+ let agentNames = null;
35
74
  for (let i = 1; i < args.length; i++) {
36
- if (args[i] === '--force') force = true;
37
- else if (args[i] === '--check') check = true;
38
- else if (args[i] === '--strict') strict = true;
39
- else if (args[i] === '--dir' && args[i + 1]) dir = args[++i];
40
- else {
41
- console.error(usage);
42
- process.exit(1);
43
- }
75
+ const a = args[i];
76
+ if (a === '--force') force = true;
77
+ else if (a === '--check') check = true;
78
+ else if (a === '--strict') strict = true;
79
+ else if (a === '--list') list = true;
80
+ else if (a === '--global' || a === '-g') global = true;
81
+ else if (a === '--dir' && args[i + 1]) dir = args[++i];
82
+ else if (a === '--agent' && args[i + 1]) agentNames = args[++i];
83
+ else if (a.startsWith('--agent=')) agentNames = a.slice('--agent='.length);
84
+ else if (a.startsWith('--dir=')) dir = a.slice('--dir='.length);
85
+ else if (a === '--help' || a === '-h') {
86
+ console.log(usage);
87
+ process.exit(0);
88
+ } else fail(`Unknown option: ${a}`);
89
+ }
90
+ if (dir !== null && (agentNames !== null || global)) {
91
+ fail('--dir names one folder; use it without --agent or --global.');
44
92
  }
45
93
 
94
+ /** Every folder to use: `{ dir, shown, reads }`, one per distinct path. */
95
+ const targets = resolveTargets();
46
96
  const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
47
97
  const version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version;
48
- const dest = join(resolve(dir), SKILL);
49
- const updateCommand = `npx ${PACKAGE}@latest install-skill --dir ${dir} --force`;
98
+ const updateCommand = `npx ${PACKAGE}@latest install-skill${optionsText()} --force`;
50
99
 
100
+ if (list) {
101
+ for (const t of targets) console.log(`${join(t.shown, SKILL)} (${t.reads})`);
102
+ process.exit(0);
103
+ }
51
104
  if (check) await runCheck();
52
105
  else install();
53
106
 
107
+ function fail(message) {
108
+ console.error(`${message}\n\n${usage}`);
109
+ process.exit(1);
110
+ }
111
+
112
+ function resolveTargets() {
113
+ if (dir !== null) return [{ dir: resolve(dir), shown: dir, reads: 'the folder you named' }];
114
+ let names = DEFAULT_AGENTS;
115
+ if (agentNames !== null) {
116
+ names = agentNames
117
+ .split(',')
118
+ .map((n) => n.trim().toLowerCase())
119
+ .filter(Boolean);
120
+ if (names.includes('all')) names = Object.keys(AGENTS);
121
+ const unknown = names.filter((n) => !AGENTS[n]);
122
+ if (unknown.length || !names.length) {
123
+ fail(
124
+ `Unknown agent: ${unknown.join(', ') || '(none)'}. Known: ${Object.keys(AGENTS).join(', ')}, all.`,
125
+ );
126
+ }
127
+ }
128
+ const byPath = new Map();
129
+ for (const name of names) {
130
+ const sub = AGENTS[name][global ? 'global' : 'project'];
131
+ const abs = global ? join(homedir(), sub) : resolve(sub);
132
+ const shown = global ? join('~', sub) : sub;
133
+ const entry = byPath.get(abs);
134
+ if (entry) entry.readers.push(AGENTS[name].reads);
135
+ else byPath.set(abs, { dir: abs, shown, readers: [AGENTS[name].reads] });
136
+ }
137
+ return [...byPath.values()].map(({ dir, shown, readers }) => ({
138
+ dir,
139
+ shown,
140
+ // The shared folder's own description already names the tools that read it.
141
+ reads: readers.includes(AGENTS.agents.reads)
142
+ ? AGENTS.agents.reads
143
+ : [...new Set(readers)].join(', '),
144
+ }));
145
+ }
146
+
147
+ /** The options that chose the folders, to repeat in the update command. */
148
+ function optionsText() {
149
+ if (dir !== null) return ` --dir ${dir}`;
150
+ return `${global ? ' --global' : ''}${agentNames !== null ? ` --agent ${agentNames}` : ''}`;
151
+ }
152
+
54
153
  function install() {
55
154
  const src = join(pkgRoot, 'skills', SKILL);
56
- if (existsSync(dest)) {
57
- if (!force) {
58
- console.error(`${dest} already exists; pass --force to overwrite.`);
59
- process.exit(1);
60
- }
155
+ const existing = targets.filter((t) => existsSync(join(t.dir, SKILL)));
156
+ if (existing.length && !force) {
157
+ for (const t of existing) console.error(`${join(t.dir, SKILL)} already exists.`);
158
+ console.error('Pass --force to overwrite (nothing was changed).');
159
+ process.exit(1);
160
+ }
161
+ for (const t of targets) {
162
+ const dest = join(t.dir, SKILL);
61
163
  rmSync(dest, { recursive: true, force: true });
164
+ mkdirSync(t.dir, { recursive: true });
165
+ cpSync(src, dest, { recursive: true });
166
+ const stamp = { package: PACKAGE, version, installedAt: new Date().toISOString() };
167
+ writeFileSync(join(dest, STAMP), JSON.stringify(stamp, null, 2) + '\n');
168
+ console.log(`Installed ${SKILL} skill ${version} to ${shownPath(dest)} (${t.reads})`);
62
169
  }
63
- mkdirSync(dirname(dest), { recursive: true });
64
- cpSync(src, dest, { recursive: true });
65
- const stamp = { package: PACKAGE, version, installedAt: new Date().toISOString() };
66
- writeFileSync(join(dest, STAMP), JSON.stringify(stamp, null, 2) + '\n');
67
- console.log(`Installed ${SKILL} skill ${version} to ${dest}`);
170
+ }
171
+
172
+ /** A path as the user would type it: relative to here, or from ~. */
173
+ function shownPath(p) {
174
+ const home = homedir();
175
+ if (p === home || p.startsWith(home + '/')) return join('~', relative(home, p));
176
+ return relative(process.cwd(), p) || '.';
68
177
  }
69
178
 
70
179
  /** -1, 0 or 1 for x.y.z versions (a pre-release sorts before its release). */
@@ -110,30 +219,41 @@ async function latestVersion() {
110
219
  }
111
220
 
112
221
  async function runCheck() {
113
- const report = (message) => {
114
- console.log(message);
115
- process.exit(strict ? 1 : 0);
116
- };
117
- if (!existsSync(join(dest, 'SKILL.md'))) {
118
- report(`The ${SKILL} agent skill is not installed in ${dir}. Install it: ${updateCommand}`);
119
- }
120
- let installed = null;
121
- try {
122
- installed = JSON.parse(readFileSync(join(dest, STAMP), 'utf8')).version ?? null;
123
- } catch {
124
- // Copies installed before version stamps existed have none.
222
+ const messages = [];
223
+ const stamped = [];
224
+ for (const t of targets) {
225
+ const dest = join(t.dir, SKILL);
226
+ if (!existsSync(join(dest, 'SKILL.md'))) {
227
+ messages.push(
228
+ `The ${SKILL} agent skill is not installed in ${t.shown}. Install it: ${updateCommand}`,
229
+ );
230
+ continue;
231
+ }
232
+ let installed = null;
233
+ try {
234
+ installed = JSON.parse(readFileSync(join(dest, STAMP), 'utf8')).version ?? null;
235
+ } catch {
236
+ // Copies installed before version stamps existed have none.
237
+ }
238
+ stamped.push({ t, installed });
125
239
  }
126
- const latest = await latestVersion();
127
- if (!latest) process.exit(0);
128
- if (!installed) {
129
- report(
130
- `The ${SKILL} agent skill in ${dir} has no version stamp (it predates ${STAMP}); the latest is ${latest}. Update it: ${updateCommand}`,
131
- );
240
+ const latest = stamped.length ? await latestVersion() : null;
241
+ if (latest) {
242
+ for (const { t, installed } of stamped) {
243
+ if (!installed) {
244
+ messages.push(
245
+ `The ${SKILL} agent skill in ${t.shown} has no version stamp (it predates ${STAMP}); the latest is ${latest}. Update it: ${updateCommand}`,
246
+ );
247
+ } else if (compare(installed, latest) < 0) {
248
+ messages.push(
249
+ `The ${SKILL} agent skill in ${t.shown} is ${installed}; ${latest} is available. Update it: ${updateCommand}`,
250
+ );
251
+ }
252
+ }
132
253
  }
133
- if (compare(installed, latest) < 0) {
134
- report(
135
- `The ${SKILL} agent skill in ${dir} is ${installed}; ${latest} is available. Update it: ${updateCommand}`,
136
- );
254
+ if (messages.length) {
255
+ console.log(messages.join('\n'));
256
+ process.exit(strict ? 1 : 0);
137
257
  }
138
258
  process.exit(0);
139
259
  }
package/dist/base.css CHANGED
@@ -131,7 +131,8 @@
131
131
  uvalib-image-regions,
132
132
  uvalib-map,
133
133
  uvalib-filter-drawer,
134
- uvalib-filter
134
+ uvalib-filter,
135
+ uvalib-list-filter
135
136
  ):not(:defined)[hidden],
136
137
  :where(uvalib-combobox, uvalib-image-regions):not(:defined) > [hidden] {
137
138
  display: none;
@@ -277,6 +278,25 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
277
278
  font: inherit;
278
279
  line-height: 1.2;
279
280
  }
281
+ /* A list filter draws its label, a 44px field and a one-line count from attributes: hold
282
+ their height (less the label with hide-label, less the count with results-count), so the
283
+ list below does not move when it upgrades. The list itself is the page's and stays
284
+ fully shown until then. */
285
+ uvalib-list-filter:not(:defined) {
286
+ display: block;
287
+ font-size: 1rem;
288
+ line-height: 1.5;
289
+ min-block-size: calc(1.5em + 0.25rem + 44px + 0.25rem + 1.5em);
290
+ }
291
+ uvalib-list-filter[hide-label]:not(:defined) {
292
+ min-block-size: calc(44px + 0.25rem + 1.5em);
293
+ }
294
+ uvalib-list-filter[results-count]:not(:defined) {
295
+ min-block-size: calc(1.5em + 0.25rem + 44px);
296
+ }
297
+ uvalib-list-filter[hide-label][results-count]:not(:defined) {
298
+ min-block-size: 44px;
299
+ }
280
300
  /* Image regions: the image at its own width and the list beside it (or under it), the
281
301
  layout the element keeps once it upgrades, so the image does not move. */
282
302
  uvalib-image-regions:not(:defined) {
@@ -331,6 +351,57 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
331
351
  display: none;
332
352
  }
333
353
  }
354
+ /* A contents list before <uvalib-contents> upgrades (a .uvalib-sidebar-layout sidebar): the
355
+ headline's line held above, the links already padded as it pads them (the rules drawn
356
+ transparent while hidden), so the list does not move. Narrow (the default 64rem
357
+ collapse-below, closed): only its 44px button shows once it upgrades, so hold that and
358
+ clip the list; the reveal releases it, so the list still shows if the script never loads.
359
+ The [hidden] rule above still wins (it alone sets display). */
360
+ uvalib-contents:not(:defined) {
361
+ padding-block-start: calc(1.125rem * 1.3 + 0.5rem);
362
+ animation-name: uvalib-contents-reveal;
363
+ }
364
+ :where(uvalib-contents):not(:defined) :is(ol, ul) {
365
+ margin: 0;
366
+ padding: 0;
367
+ list-style: none;
368
+ }
369
+ :where(uvalib-contents):not(:defined) > :is(ol, ul) {
370
+ border-block: 1px solid transparent;
371
+ }
372
+ :where(uvalib-contents):not(:defined) > :is(ol, ul) > li + li {
373
+ border-block-start: 1px solid transparent;
374
+ }
375
+ :where(uvalib-contents):not(:defined) li > a {
376
+ display: block;
377
+ padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);
378
+ }
379
+ :where(uvalib-contents):not(:defined) li li > a {
380
+ padding-block: 0.25rem;
381
+ }
382
+ :where(uvalib-contents):not(:defined) li :is(ol, ul) {
383
+ padding-inline-start: 1rem;
384
+ border-inline-start: 2px solid transparent;
385
+ }
386
+ /* In light DOM (no-shadow-dom) a nested list is indented by a margin, with 0.5rem below. */
387
+ :where(uvalib-contents[no-shadow-dom]):not(:defined) li :is(ol, ul) {
388
+ margin: 0 0 0.5rem 0.75rem;
389
+ padding-inline-start: 0;
390
+ }
391
+ @media (max-width: 64rem) {
392
+ uvalib-contents:not([collapse-below], [open]):not(:defined) {
393
+ max-block-size: 44px;
394
+ padding-block-start: 0;
395
+ overflow: hidden;
396
+ }
397
+ }
398
+ @keyframes uvalib-contents-reveal {
399
+ to {
400
+ visibility: visible;
401
+ max-block-size: none;
402
+ overflow: visible;
403
+ }
404
+ }
334
405
  /* A dialog before <uvalib-dialog> upgrades: its children are the dialog's content, never
335
406
  shown in the page, so nothing flashes or moves. Once defined, a closed dialog renders
336
407
  nothing (its host is display: contents around a closed <dialog>). */
@@ -1119,8 +1190,50 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
1119
1190
  }
1120
1191
 
1121
1192
 
1193
+ .uvalib-sidebar-layout {
1194
+ container: uvalib-sidebar-layout / inline-size;
1195
+ display: flex;
1196
+ flex-wrap: wrap;
1197
+ align-items: stretch;
1198
+ gap: var(--uvalib-sidebar-stack-gap, 2rem) var(--uvalib-sidebar-gap, 3.5rem);
1199
+ }
1200
+ .uvalib-sidebar-layout > :is(.uvalib-sidebar-layout__sidebar, .uvalib-sidebar-layout__main) {
1201
+ flex: 1 1 100%;
1202
+ box-sizing: border-box;
1203
+ min-inline-size: 0;
1204
+ overflow-wrap: break-word;
1205
+ }
1206
+ @container uvalib-sidebar-layout (width >= 913px) {
1207
+ .uvalib-sidebar-layout > .uvalib-sidebar-layout__sidebar {
1208
+ flex: 0 0 var(--uvalib-sidebar-width, clamp(14rem, 25%, 20rem));
1209
+ }
1210
+ .uvalib-sidebar-layout > .uvalib-sidebar-layout__main {
1211
+ flex: 1 1 0;
1212
+ }
1213
+ .uvalib-sidebar-layout--sticky > .uvalib-sidebar-layout__sidebar {
1214
+ position: sticky;
1215
+ top: var(--uvalib-sidebar-sticky-top, 1rem);
1216
+ align-self: flex-start;
1217
+ max-block-size: calc(100dvh - 2 * var(--uvalib-sidebar-sticky-top, 1rem));
1218
+ overflow-y: auto;
1219
+ overscroll-behavior: contain;
1220
+ }
1221
+ }
1222
+ @media print {
1223
+ .uvalib-sidebar-layout > :is(.uvalib-sidebar-layout__sidebar, .uvalib-sidebar-layout__main) {
1224
+ flex: 1 1 100%;
1225
+ position: static;
1226
+ max-block-size: none;
1227
+ overflow: visible;
1228
+ }
1229
+ .uvalib-sidebar-layout--print-hide-sidebar > .uvalib-sidebar-layout__sidebar {
1230
+ display: none;
1231
+ }
1232
+ }
1233
+
1234
+
1122
1235
  /* hidden hides every base.css class, though each sets display (see hidden.ts). */
1123
- :where(.uvalib-button, .uvalib-input, .uvalib-search-form, .uvalib-badge, .uvalib-media, .uvalib-media__badges, .uvalib-toolbar, .uvalib-toolbar__field, .uvalib-toolbar__group, .uvalib-toolbar__summary, .uvalib-empty-state, .uvalib-skeleton, .uvalib-skeleton-text, .uvalib-message, .uvalib-message__icon, .uvalib-result-list, .uvalib-result, .uvalib-result__title, .uvalib-result__meta, .uvalib-result__snippet, .uvalib-result__actions, .uvalib-table, .uvalib-table-scroll, .uvalib-table-stack, .uvalib-help)[hidden],
1236
+ :where(.uvalib-button, .uvalib-input, .uvalib-search-form, .uvalib-badge, .uvalib-media, .uvalib-media__badges, .uvalib-toolbar, .uvalib-toolbar__field, .uvalib-toolbar__group, .uvalib-toolbar__summary, .uvalib-empty-state, .uvalib-skeleton, .uvalib-skeleton-text, .uvalib-message, .uvalib-message__icon, .uvalib-result-list, .uvalib-result, .uvalib-result__title, .uvalib-result__meta, .uvalib-result__snippet, .uvalib-result__actions, .uvalib-table, .uvalib-table-scroll, .uvalib-table-stack, .uvalib-sidebar-layout, .uvalib-help)[hidden],
1124
1237
  :where(.uvalib-media > :is(img, video, picture), .uvalib-table--stack > :is(tbody, tfoot, caption), .uvalib-table--stack > :is(tbody, tfoot) > tr, .uvalib-table--stack > :is(tbody, tfoot) > tr > :is(th, td))[hidden] {
1125
1238
  display: none !important;
1126
1239
  }
@@ -0,0 +1,162 @@
1
+ import { type PropertyValues } from 'lit';
2
+ import { UvalibElement } from '../../base/UvalibElement.js';
3
+ /** What `uvalib-list-filter-change` carries. */
4
+ export interface ListFilterChangeDetail {
5
+ /** The text in the field, as typed. */
6
+ query: string;
7
+ /** How many items match (are shown). */
8
+ shown: number;
9
+ /** How many items the list has. */
10
+ total: number;
11
+ }
12
+ /**
13
+ * How long (ms) the filter must stay put before it is announced and reported to analytics
14
+ * (as `<uvalib-results-count>` and the date range settle), and before it is written to the
15
+ * URL. Tests may shorten them.
16
+ */
17
+ export declare const listFilterTiming: {
18
+ settle: number;
19
+ url: number;
20
+ };
21
+ /** Case- and accent-insensitive form: “Ébène” and “ebene” match. */
22
+ export declare const fold: (s: string) => string;
23
+ /** The query's words, folded: every one must appear in an item, in any order. */
24
+ export declare const queryWords: (q: string) => string[];
25
+ /**
26
+ * A text field that filters a long list on the page as you type: a collection's 473 texts, a
27
+ * staff directory, a table of databases. The list is the page's own markup and stays fully
28
+ * visible without the script.
29
+ *
30
+ * `for` is the id of the list: any element whose children are the items (a `<ul>` or `<ol>`,
31
+ * a `<dl>` of `<div>` rows, a grid of cards; for a `<table>`, the rows of its bodies).
32
+ * `selector` picks the items instead (inside `for` when both are set, else in the page).
33
+ * An item matches when every word typed appears in its `data-filter-text`, or else its text,
34
+ * in any order, ignoring case and accents (“eneide” finds “Énéide”). Items that do not match
35
+ * get the `hidden` attribute (kept hidden whatever `display` the page gives them); clearing
36
+ * the field shows them all again. Thousands of items filter at once on every keystroke: the
37
+ * text is read once, and only items whose state changes are touched.
38
+ *
39
+ * Groups: give each group's wrapper `data-filter-group` (a `<section>` with its heading and
40
+ * its list) and point `selector` at the items; a group whose items are all hidden is hidden
41
+ * too, heading and all.
42
+ *
43
+ * The visible `label` (default “Filter”; `hide-label` hides it visually) names the field, and
44
+ * a Clear button (“Clear <label>”, 44px, shown only with text) or Escape empties it, keeping
45
+ * focus in the field. Under the field a count follows at once (“Showing 12 of 473 texts”;
46
+ * `noun`, plural, and `singular` name the items), and a polite status announces it once the
47
+ * typing settles (a second after the last keystroke), never on every key or at load. When
48
+ * nothing matches, a message says “No texts match “…”.” To put the count elsewhere, point
49
+ * `results-count` at a `<uvalib-results-count>` (give it `total` and `noun` in the markup):
50
+ * the element then sets its `shown` and `total` and leaves the count and announcement to it.
51
+ *
52
+ * With `query-param` (bare: `filter`) the filter is read from that URL parameter at start
53
+ * and written back with `history.replaceState` as you type, so a filtered list can be shared
54
+ * and Back returns to it. The list's content is read once; call `refresh()` after changing an
55
+ * item's text in script (added or removed items and `data-filter-text` changes are noticed).
56
+ *
57
+ * Before it upgrades, `base.css` holds the label, field and count's height, so nothing moves.
58
+ *
59
+ * @tagname uvalib-list-filter
60
+ * @fires uvalib-list-filter-change - The filter was applied with a new query (typing, Clear, Escape, `value` set in script, the URL at start, Back and Forward). `detail` is `{ query, shown, total }`. Not fired at load without a query. Bubbles and is composed.
61
+ * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's actions only: `['uvalib-list-filter', 'filter', '', <shown>]` once the typing settles on a new query, and `['uvalib-list-filter', 'clear']` when the visitor empties the field. Never the typed text. Bubbles and is composed.
62
+ * @csspart label - The visible label.
63
+ * @csspart field - The box around the field and its clear button.
64
+ * @csspart input - The text field.
65
+ * @csspart clear - The clear button.
66
+ * @csspart count - The visible count under the field.
67
+ * @csspart empty - The “No … match” message.
68
+ * @cssprop --uva-color-surface-raised - Dark-mode role token: field background (else #fff).
69
+ * @cssprop --uva-color-control-border - Dark-mode role token: field border (else `--uva-grey`, #808080).
70
+ * @cssprop --uva-color-input-text - Dark-mode role token: field text (else #2b2b2b).
71
+ * @cssprop --uva-color-text - Dark-mode role token: label text (else #2b2b2b).
72
+ * @cssprop --uva-color-text-muted - Dark-mode role token: placeholder, count and the clear icon (else #4f4f4f).
73
+ * @cssprop --uva-color-alert-info-bg - Dark-mode role token: the no-match message background.
74
+ * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).
75
+ */
76
+ export declare class UvalibListFilter extends UvalibElement {
77
+ static styles: import("lit").CSSResult[];
78
+ /** The id of the list whose children are the items (for a table, its body rows). */
79
+ htmlFor: string;
80
+ /** A CSS selector for the items, inside `for` when it is set, else in the page. */
81
+ selector: string;
82
+ /** The field's visible label and accessible name. */
83
+ label: string;
84
+ /** Hide the label visually (it still names the field), when a heading beside it says it. */
85
+ hideLabel: boolean;
86
+ /** Placeholder text in the empty field, such as “Title or author”. */
87
+ placeholder: string;
88
+ /** What the items are, plural: “items” by default. */
89
+ noun: string;
90
+ /** What one item is. Default: “item” when `noun` is unset, else `noun`. */
91
+ singular: string;
92
+ /** The id of a `<uvalib-results-count>` to drive instead of the element's own count. */
93
+ resultsCount: string;
94
+ /**
95
+ * The URL parameter to read the filter from and write it to; a bare attribute uses
96
+ * `filter`. Off by default.
97
+ */
98
+ queryParam: string | null;
99
+ /** The text in the field. Setting it filters the list (not reported to analytics). */
100
+ value: string;
101
+ private shownCount;
102
+ private totalCount;
103
+ /** The query the shown counts belong to. */
104
+ private appliedQuery;
105
+ private announcement;
106
+ private readonly uid;
107
+ private index?;
108
+ private started;
109
+ private warned;
110
+ private observer?;
111
+ private observed?;
112
+ /** The words of the last query reported to analytics (or restored), joined. */
113
+ private reported;
114
+ private settleTimer?;
115
+ private urlTimer?;
116
+ private clearing?;
117
+ /** How many items match now. */
118
+ get shown(): number;
119
+ /** How many items the list has. */
120
+ get total(): number;
121
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
122
+ connectedCallback(): void;
123
+ disconnectedCallback(): void;
124
+ /** The list may come after the element in a page still loading: wait for it then. */
125
+ private begin;
126
+ private start;
127
+ protected willUpdate(changed: PropertyValues<this>): void;
128
+ /** Read the list again (an item's text changed in script) and filter it with the current text. */
129
+ refresh(): void;
130
+ private reset;
131
+ private lookupRoot;
132
+ /** The `for` element, if any. */
133
+ private target;
134
+ private collect;
135
+ private build;
136
+ /** Added or removed items, and data-filter-text changes, read the list again. */
137
+ private observe;
138
+ private textOf;
139
+ /** Show or hide every item for the current text (`user`: typed, so settle, report and write the URL). */
140
+ private apply;
141
+ private showAll;
142
+ private externalCount;
143
+ private driveResultsCount;
144
+ private word;
145
+ /** The visible count: “Showing 12 of 473 texts”, “Showing all 473 texts”. */
146
+ get countText(): string;
147
+ private get emptyText();
148
+ /** The typing settled: announce the count, and report a new query. */
149
+ private settle;
150
+ private announce;
151
+ private get input();
152
+ private onInput;
153
+ private onKeydown;
154
+ private clear;
155
+ private get param();
156
+ /** The filter in the URL, or null with `query-param` off or the parameter missing. */
157
+ private urlQuery;
158
+ private flushUrl;
159
+ /** Back and Forward: follow the URL's filter. */
160
+ private onPopState;
161
+ protected render(): import("lit").TemplateResult<1>;
162
+ }