@uvalib/web-components 1.9.0 → 1.11.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 (57) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +277 -18
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base.css +121 -2
  5. package/dist/components/uvalib-contents/UvalibContents.d.ts +66 -2
  6. package/dist/components/uvalib-contents/UvalibContents.js +277 -29
  7. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  8. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  9. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  10. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  11. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  12. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  13. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  14. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +54 -1
  15. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +230 -3
  16. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  17. package/dist/custom-elements.json +7757 -6209
  18. package/dist/edition.css +758 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/pagefind.css +144 -0
  23. package/dist/styles/base.js +78 -1
  24. package/dist/styles/base.js.map +1 -1
  25. package/dist/styles/controls.js +2 -0
  26. package/dist/styles/controls.js.map +1 -1
  27. package/dist/styles/edition.d.ts +1 -0
  28. package/dist/styles/edition.js +747 -0
  29. package/dist/styles/edition.js.map +1 -0
  30. package/dist/styles/hidden.js +2 -0
  31. package/dist/styles/hidden.js.map +1 -1
  32. package/dist/styles/layout.d.ts +1 -0
  33. package/dist/styles/layout.js +92 -0
  34. package/dist/styles/layout.js.map +1 -0
  35. package/dist/styles/pagefind.js +150 -0
  36. package/dist/styles/pagefind.js.map +1 -1
  37. package/dist-cdn/base.css +121 -2
  38. package/dist-cdn/chunks/{base-CHMHBPeI.js → base-DmImIMld.js} +79 -2
  39. package/dist-cdn/chunks/base-DmImIMld.js.map +1 -0
  40. package/dist-cdn/custom-elements.json +7757 -6209
  41. package/dist-cdn/edition.css +758 -0
  42. package/dist-cdn/manifest.json +5 -3
  43. package/dist-cdn/pagefind.css +144 -0
  44. package/dist-cdn/site-page.js +1 -1
  45. package/dist-cdn/site-style.js +1 -1
  46. package/dist-cdn/skills/uvalib-web-components/SKILL.md +29 -8
  47. package/dist-cdn/skills/uvalib-web-components/reference/components.md +65 -4
  48. package/dist-cdn/uvalib-contents.js +185 -47
  49. package/dist-cdn/uvalib-contents.js.map +1 -1
  50. package/dist-cdn/uvalib-list-filter.js +451 -0
  51. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  52. package/dist-cdn/uvalib-pagefind-search.js +149 -49
  53. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  54. package/package.json +6 -1
  55. package/skills/uvalib-web-components/SKILL.md +29 -8
  56. package/skills/uvalib-web-components/reference/components.md +65 -4
  57. 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,63 @@ 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
+ /* With full-href (issue #38): the full-contents link's line held below the list (0.5rem
365
+ above a 44px link). A window="N" list is not held: the whole list shows until it upgrades
366
+ (in a sidebar beside the content, nothing else moves). */
367
+ uvalib-contents[full-href]:not(:defined) {
368
+ padding-block-end: calc(44px + 0.5rem);
369
+ }
370
+ :where(uvalib-contents):not(:defined) :is(ol, ul) {
371
+ margin: 0;
372
+ padding: 0;
373
+ list-style: none;
374
+ }
375
+ :where(uvalib-contents):not(:defined) > :is(ol, ul) {
376
+ border-block: 1px solid transparent;
377
+ }
378
+ :where(uvalib-contents):not(:defined) > :is(ol, ul) > li + li {
379
+ border-block-start: 1px solid transparent;
380
+ }
381
+ :where(uvalib-contents):not(:defined) li > a {
382
+ display: block;
383
+ padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);
384
+ }
385
+ :where(uvalib-contents):not(:defined) li li > a {
386
+ padding-block: 0.25rem;
387
+ }
388
+ :where(uvalib-contents):not(:defined) li :is(ol, ul) {
389
+ padding-inline-start: 1rem;
390
+ border-inline-start: 2px solid transparent;
391
+ }
392
+ /* In light DOM (no-shadow-dom) a nested list is indented by a margin, with 0.5rem below. */
393
+ :where(uvalib-contents[no-shadow-dom]):not(:defined) li :is(ol, ul) {
394
+ margin: 0 0 0.5rem 0.75rem;
395
+ padding-inline-start: 0;
396
+ }
397
+ @media (max-width: 64rem) {
398
+ uvalib-contents:not([collapse-below], [open]):not(:defined) {
399
+ max-block-size: 44px;
400
+ padding-block: 0;
401
+ overflow: hidden;
402
+ }
403
+ }
404
+ @keyframes uvalib-contents-reveal {
405
+ to {
406
+ visibility: visible;
407
+ max-block-size: none;
408
+ overflow: visible;
409
+ }
410
+ }
334
411
  /* A dialog before <uvalib-dialog> upgrades: its children are the dialog's content, never
335
412
  shown in the page, so nothing flashes or moves. Once defined, a closed dialog renders
336
413
  nothing (its host is display: contents around a closed <dialog>). */
@@ -1119,8 +1196,50 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
1119
1196
  }
1120
1197
 
1121
1198
 
1199
+ .uvalib-sidebar-layout {
1200
+ container: uvalib-sidebar-layout / inline-size;
1201
+ display: flex;
1202
+ flex-wrap: wrap;
1203
+ align-items: stretch;
1204
+ gap: var(--uvalib-sidebar-stack-gap, 2rem) var(--uvalib-sidebar-gap, 3.5rem);
1205
+ }
1206
+ .uvalib-sidebar-layout > :is(.uvalib-sidebar-layout__sidebar, .uvalib-sidebar-layout__main) {
1207
+ flex: 1 1 100%;
1208
+ box-sizing: border-box;
1209
+ min-inline-size: 0;
1210
+ overflow-wrap: break-word;
1211
+ }
1212
+ @container uvalib-sidebar-layout (width >= 913px) {
1213
+ .uvalib-sidebar-layout > .uvalib-sidebar-layout__sidebar {
1214
+ flex: 0 0 var(--uvalib-sidebar-width, clamp(14rem, 25%, 20rem));
1215
+ }
1216
+ .uvalib-sidebar-layout > .uvalib-sidebar-layout__main {
1217
+ flex: 1 1 0;
1218
+ }
1219
+ .uvalib-sidebar-layout--sticky > .uvalib-sidebar-layout__sidebar {
1220
+ position: sticky;
1221
+ top: var(--uvalib-sidebar-sticky-top, 1rem);
1222
+ align-self: flex-start;
1223
+ max-block-size: calc(100dvh - 2 * var(--uvalib-sidebar-sticky-top, 1rem));
1224
+ overflow-y: auto;
1225
+ overscroll-behavior: contain;
1226
+ }
1227
+ }
1228
+ @media print {
1229
+ .uvalib-sidebar-layout > :is(.uvalib-sidebar-layout__sidebar, .uvalib-sidebar-layout__main) {
1230
+ flex: 1 1 100%;
1231
+ position: static;
1232
+ max-block-size: none;
1233
+ overflow: visible;
1234
+ }
1235
+ .uvalib-sidebar-layout--print-hide-sidebar > .uvalib-sidebar-layout__sidebar {
1236
+ display: none;
1237
+ }
1238
+ }
1239
+
1240
+
1122
1241
  /* 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],
1242
+ :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
1243
  :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
1244
  display: none !important;
1126
1245
  }
@@ -48,13 +48,30 @@ export interface ContentsItem {
48
48
  * `items` win while they give a list. Without JavaScript there is no list: a list rendered
49
49
  * at build time, as children, works everywhere.
50
50
  *
51
+ * A very long contents (a text with hundreds of sections, each its own page) can show only
52
+ * part of the list, with a link to the whole. `full-href` adds that link after the list: not
53
+ * an entry but a call to action (bold, underlined, with an arrow), its text `full-label`
54
+ * ("Full contents") followed by the count when `total` (the entries in the full contents) is
55
+ * set: "Full contents (243 sections)" (`noun`, "sections" by default; `singular` for one). A
56
+ * static site writes only the entries near the current one (with their parents) and sets
57
+ * these. `window="12"` does it in the browser when the whole list is given: only the current
58
+ * entry and the 12 before and after it in document order (25 entries, shifted at either end)
59
+ * are shown, with their parents so the nesting still makes sense; the others are hidden, not
60
+ * removed, and a gap between the entries shown is marked with an ellipsis (hidden from
61
+ * assistive technology). It follows the current entry, and applies to `items` and
62
+ * `headings-from` too. Without `full-href`, a "Show all 243 sections" button shows the rest in
63
+ * place ("Show fewer" goes back). While part of the list is shown, a visually hidden line
64
+ * before it says so ("Showing 25 of 243 sections."); the headline and the landmark keep the
65
+ * visible label as their name. On narrow screens the link and the button are inside the
66
+ * disclosure.
67
+ *
51
68
  * Single-page apps: the list is drawn from copies of the children, so a router's own click
52
69
  * handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in
53
70
  * place; hash links need nothing.
54
71
  *
55
72
  * @tagname uvalib-contents
56
- * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`; never the label or URL. Bubbles and is composed.
57
- * @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.
73
+ * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), on the full-contents link, `['uvalib-contents', 'full-contents-click']`, opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`, and the window's button, `['uvalib-contents', 'show-all' | 'show-fewer']`; never the label or URL. Bubbles and is composed.
74
+ * @fires uvalib-contents-navigate - A plain click on an entry or the full-contents link: `detail` is `{ href, level }` (href as written; level 0 for the full-contents link). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.
58
75
  * @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.
59
76
  * @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.
60
77
  * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.
@@ -65,6 +82,7 @@ export interface ContentsItem {
65
82
  * @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).
66
83
  * @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).
67
84
  * @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).
85
+ * @cssprop --uva-color-text-muted - Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f).
68
86
  * @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).
69
87
  * @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).
70
88
  * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).
@@ -110,6 +128,30 @@ export declare class UvalibContents extends UvalibElement {
110
128
  * nothing is shown.
111
129
  */
112
130
  min: number;
131
+ /**
132
+ * The URL of the full contents, when the list is only part of it: a "Full contents" link
133
+ * after the list (`full-label`, with the count from `total`).
134
+ */
135
+ fullHref?: string;
136
+ /** The full-contents link's text, before the count: "Full contents" by default. */
137
+ fullLabel: string;
138
+ /**
139
+ * How many entries the full contents has, for the link ("Full contents (243 sections)") and
140
+ * the screen-reader line ("Showing 25 of 243 sections."). With `window`, the whole list's
141
+ * count when unset.
142
+ */
143
+ total?: number;
144
+ /** What the entries are, plural, in the counts: "sections" by default. */
145
+ noun: string;
146
+ /** What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. */
147
+ singular: string;
148
+ /**
149
+ * Show only the current entry and this many before and after it in document order (and
150
+ * their parents); the others are hidden. Unset or blank: every entry.
151
+ */
152
+ windowSize?: number;
153
+ /** Whether "Show all" was pressed (a window without `full-href`). */
154
+ private expanded;
113
155
  /** The entries built from the headings (`headings-from`). */
114
156
  private headingItems;
115
157
  private headingsObserver?;
@@ -126,6 +168,8 @@ export declare class UvalibContents extends UvalibElement {
126
168
  private warned;
127
169
  private readonly panelId;
128
170
  private mql?;
171
+ /** Whether the last render drew the full-contents link or the window's button. */
172
+ private hasMore;
129
173
  /** What was last scrolled into view, so the list is not scrolled again on every update. */
130
174
  private scrolledTo?;
131
175
  constructor();
@@ -172,6 +216,18 @@ export declare class UvalibContents extends UvalibElement {
172
216
  /** The current entries: the page's and its section's. */
173
217
  private currentOf;
174
218
  private get level();
219
+ /** The noun for `n` entries. */
220
+ private word;
221
+ /** The safe `full-href`, or undefined (unset, blank, or not http(s), mailto, tel or relative). */
222
+ private get fullLink();
223
+ /**
224
+ * With `window`: the entries shown (the current one, `window` before and after it in
225
+ * document order, shifted at either end, and their parents), or undefined when every entry
226
+ * shows. The current entry is the section's (`location`), else the page's; with none, the
227
+ * window starts at the top.
228
+ */
229
+ private windowOf;
230
+ private showAll;
175
231
  private toggle;
176
232
  /**
177
233
  * A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that
@@ -183,5 +239,13 @@ export declare class UvalibContents extends UvalibElement {
183
239
  /** Scroll the list (never the page) so the current entry shows, once per entry and opening. */
184
240
  private reveal;
185
241
  private renderList;
242
+ private renderEntry;
243
+ /** The count of entries shown (all, or the window's). */
244
+ private static size;
245
+ /**
246
+ * After the list: the full-contents link, or a window's Show all / Show fewer button; and
247
+ * the visually hidden line before the list that says it is partial.
248
+ */
249
+ private renderMore;
186
250
  protected render(): TemplateResult;
187
251
  }