@aliens-syndicate/cli 0.1.1 → 0.1.3

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 (29) hide show
  1. package/README.md +122 -93
  2. package/package.json +6 -2
  3. package/tools/build.mjs +326 -26
  4. package/tools/cli.mjs +31 -9
  5. package/tools/create.mjs +38 -12
  6. package/tools/icon-docs.mjs +132 -0
  7. package/tools/runtime.mjs +216 -8
  8. package/tools/starter/ai/agents/codingbot.agent +5 -0
  9. package/tools/starter/ai/rules/architecture.rule +11 -0
  10. package/tools/starter/ai/skills/create-element.skill +6 -0
  11. package/tools/starter/app/elements/molecules/kit-card-link/kit-card-link.markup +0 -2
  12. package/tools/starter/app/pages/kit-overview/kit-overview.markup +6 -6
  13. package/tools/starter/app/pages/style-guide/style-guide.style +57 -57
  14. package/tools/starter/styles/components/alerts.style +6 -5
  15. package/tools/starter/styles/components/badges.style +6 -5
  16. package/tools/starter/styles/components/borders.style +2 -1
  17. package/tools/starter/styles/components/buttons.style +14 -13
  18. package/tools/starter/styles/components/cards.style +1 -1
  19. package/tools/starter/styles/components/feedback.style +3 -2
  20. package/tools/starter/styles/components/forms.style +5 -4
  21. package/tools/starter/styles/components/tables.style +4 -3
  22. package/tools/starter/styles/components/typography.style +6 -5
  23. package/tools/starter/styles/generic/ui-base.style +1 -1
  24. package/tools/starter/styles/objects/ui-layout.style +1 -1
  25. package/tools/style-docs.mjs +274 -0
  26. package/tools/vscode-space/package.json +5 -8
  27. package/tools/vscode-space/space.tmLanguage.json +1 -1
  28. package/tools/vscode-space/syntax.cjs +103 -62
  29. package/tools/watch.mjs +48 -0
@@ -0,0 +1,132 @@
1
+ // Generates the Icons page (project/app/pages/icon-docs) from the catalog of the icon package that .config declares
2
+ // under icons: from:. The sidebar lists every category; the runtime fills each one with its icons when the page opens,
3
+ // so the catalog stays out of index.html. Run it after updating the package: node tools/icon-docs.mjs
4
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
5
+ import { createRequire } from 'node:module';
6
+ import { join, resolve } from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
8
+
9
+ const workspace = resolve(import.meta.dirname, '..');
10
+ const config = await readFile(join(workspace, '.config'), 'utf8');
11
+ const from = /^icons:\n(?: {3}.*\n)*? {3}from: (.+)$/m.exec(config)?.[1].trim();
12
+ if (!from) throw new Error('icon-docs: declare the icon package in .config under icons: from:.');
13
+ const entry = /^\.{1,2}\//.test(from) ? join(workspace, from, 'index.mjs') : createRequire(join(workspace, 'package.json')).resolve(from);
14
+ const { createIconRenderer, readCatalog } = await import(pathToFileURL(entry).href);
15
+ const { categories, icons } = await readCatalog();
16
+ const { families } = createIconRenderer();
17
+ const page = join(workspace, 'project/app/pages/icon-docs');
18
+ const total = Object.keys(icons).length;
19
+ const number = value => value.toLocaleString('en-US');
20
+
21
+ const indent = level => ' '.repeat(level);
22
+ const lines = [];
23
+ const add = (level, text) => lines.push(indent(level) + text);
24
+ const title = word => word[0].toUpperCase() + word.slice(1);
25
+
26
+ lines.push('Markup IconDocs');
27
+ add(1, 'article variant="home-view" id="icon-docs" data-view data-search-entry hidden tabindex="-1"');
28
+ add(2, 'aside id="icon-docs-sidebar"');
29
+ add(3, 'div id="icon-docs-finder"');
30
+ add(4, 'form id="icon-docs-finder-form" role="search"');
31
+ add(5, 'label={@iconDocs.searchLabel} for="icon-docs-finder-input" id="icon-docs-finder-label"');
32
+ add(5, 'icon search-01 id="icon-docs-finder-icon"');
33
+ add(5, 'input type="search" id="icon-docs-finder-input" placeholder={@iconDocs.searchPlaceholder} autocomplete="off" spellcheck="false" data-filter');
34
+ add(4, 'p id="icon-docs-finder-status" data-filter-status aria-live="polite" hidden');
35
+ add(5, 'span text="0" id="icon-docs-finder-count" data-filter-count');
36
+ add(5, 'span={@iconDocs.searchResults}');
37
+ add(3, 'nav id="icon-docs-nav" aria-label={@iconDocs.navLabel} data-toc');
38
+ add(4, 'p={@iconDocs.groupStart} variant="icon-docs-nav-title"');
39
+ for (const [anchor, key] of [['overview', 'overviewNav'], ['styles', 'stylesNav'], ['usage', 'usageNav']]) {
40
+ add(4, `a={@iconDocs.${key}} href="#icon-docs-${anchor}" variant="icon-docs-nav-link"`);
41
+ }
42
+ add(4, 'p={@iconDocs.categoriesNav} variant="icon-docs-nav-title"');
43
+ add(4, 'for category in categories');
44
+ add(5, 'a href={$category.href} variant="icon-docs-nav-link"');
45
+ add(6, 'span={$category.label}');
46
+ add(6, 'span={$category.count} variant="icon-docs-nav-count"');
47
+
48
+ add(2, 'div id="icon-docs-main"');
49
+ add(3, 'header id="icon-docs-overview"');
50
+ add(4, 'p variant="home-breadcrumb"');
51
+ add(5, 'a={@nav.home} href="#home-guide"');
52
+ add(5, 'span={/} aria-hidden="true"');
53
+ add(5, 'span={@nav.icons}');
54
+ add(4, 'p={@iconDocs.eyebrow} id="icon-docs-eyebrow"');
55
+ add(4, 'h1={@iconDocs.title} data-search-label');
56
+ add(4, 'p={@iconDocs.lead} variant="home-topic-lead" data-search-summary');
57
+ add(4, 'ul id="icon-docs-stats"');
58
+ for (const [value, key] of [[number(total), 'statIcons'], [String(families.reduce((sum, [, kinds]) => sum + kinds.length, 0)), 'statStyles'],
59
+ [String(categories.length), 'statCategories']]) {
60
+ add(5, 'li');
61
+ add(6, `strong={${value}}`);
62
+ add(6, `span={@iconDocs.${key}}`);
63
+ }
64
+
65
+ // The picker groups the styles as hugeicons.com does: Rounded, Standard and Sharp. The runtime keeps one pressed.
66
+ add(3, 'section variant="icon-docs-block" id="icon-docs-styles"');
67
+ add(4, 'h2={@iconDocs.stylesTitle}');
68
+ add(4, 'p={@iconDocs.stylesDetail} variant="icon-docs-lead"');
69
+ add(4, 'div id="icon-docs-picker" role="group" aria-label={@iconDocs.stylesTitle}');
70
+ for (const [family, kinds] of families) {
71
+ add(5, 'div variant="icon-docs-family"');
72
+ add(6, `span={${title(family)}:} variant="icon-docs-family-label"`);
73
+ add(6, 'div variant="icon-docs-family-styles"');
74
+ for (const kind of kinds) add(7, `button={${title(kind)}} variant="icon-docs-style" data-icon-style="${kind}-${family}" aria-pressed="false"`);
75
+ }
76
+ add(4, 'p={@iconDocs.stylesNote} variant="icon-docs-note"');
77
+
78
+ add(3, 'section variant="icon-docs-block" id="icon-docs-usage"');
79
+ add(4, 'h2={@iconDocs.usageTitle}');
80
+ add(4, 'p={@iconDocs.usageDetail} variant="icon-docs-lead"');
81
+ add(4, 'ol variant="icon-docs-steps"');
82
+ for (const [key, code] of [['usageInstall', 'npm install @aliens-syndicate/icons'], ['usageConfig', null], ['usageVariant', null]]) {
83
+ add(5, 'li');
84
+ add(6, `p={@iconDocs.${key}}`);
85
+ if (code) {
86
+ add(6, 'pre variant="icon-docs-code" tabindex="0"');
87
+ add(7, `code={${code}}`);
88
+ } else if (key === 'usageConfig') {
89
+ add(6, 'pre variant="icon-docs-code" tabindex="0"');
90
+ add(7, 'code');
91
+ add(8, 'span={icons:} variant="icon-docs-code-line"');
92
+ add(8, 'span={ from: @aliens-syndicate/icons} variant="icon-docs-code-line"');
93
+ add(8, 'span variant="icon-docs-code-line"');
94
+ add(9, 'span={ style: }');
95
+ add(9, 'span={stroke-rounded} data-icon-style-name');
96
+ } else {
97
+ add(6, 'pre variant="icon-docs-code" tabindex="0"');
98
+ add(7, 'code');
99
+ add(8, 'span={icon search-01} variant="icon-docs-code-line"');
100
+ add(8, 'span variant="icon-docs-code-line"');
101
+ add(9, 'span={icon search-01 }');
102
+ add(9, 'span={stroke-rounded} data-icon-style-name');
103
+ add(9, 'span={ size-6 blue-600 blue-200}');
104
+ add(8, 'span={icon search-01 disabled} variant="icon-docs-code-line"');
105
+ }
106
+ }
107
+ add(4, 'p={@iconDocs.usageCopy} variant="icon-docs-note"');
108
+
109
+ add(3, 'p={@iconDocs.searchEmpty} id="icon-docs-finder-empty" data-filter-empty hidden');
110
+ add(3, 'p={@iconDocs.loading} id="icon-docs-loading" aria-live="polite"');
111
+ add(3, 'div id="icon-docs-catalog" data-icon-catalog="./icons.json" data-icon-copied={@iconDocs.copied}');
112
+ add(4, 'for category in categories');
113
+ add(5, 'section variant="icon-docs-category" id={$category.anchor} data-filter-group');
114
+ add(6, 'h2');
115
+ add(7, 'span={$category.label}');
116
+ add(7, 'span={$category.count} variant="icon-docs-category-count"');
117
+ add(6, 'ul variant="icon-docs-grid" data-icon-category={$category.key}');
118
+ add(3, 'p id="icon-docs-toast" role="status" aria-live="polite" hidden');
119
+ add(3, 'p={@iconDocs.license} variant="icon-docs-note" id="icon-docs-license"');
120
+
121
+ await mkdir(page, { recursive: true });
122
+ await writeFile(join(page, 'icon-docs.markup'), lines.join('\n') + '\n');
123
+ await writeFile(join(page, 'icon-docs.logic'), `Logic IconDocs
124
+ # Generated by tools/icon-docs.mjs from the catalog of ${from}. Update the package, not this file.
125
+ list categories:
126
+ ${categories.map(({ id, label, icons: names }) => ` ${id}:
127
+ label: ${label}
128
+ count: ${names.length}
129
+ anchor: icon-docs-${id}
130
+ href: #icon-docs-${id}`).join('\n')}
131
+ `);
132
+ console.log(`Icons page generated: ${number(total)} icons in ${categories.length} categories.`);
package/tools/runtime.mjs CHANGED
@@ -38,7 +38,8 @@ function render(instance) {
38
38
  for (const { node, name, read } of current.binds) {
39
39
  const value = read.call(current.state);
40
40
  if (name === 'text') node.textContent = String(value);
41
- if (name === 'show') node.hidden = !value;
41
+ // toggleAttribute also reaches the svg of an icon tag, which has no hidden property.
42
+ if (name === 'show') node.toggleAttribute('hidden', !value);
42
43
  if (name === 'pressed' || name === 'expanded') node.setAttribute('aria-' + name, String(Boolean(value)));
43
44
  if (name.startsWith('_')) node.classList.toggle(node.id + name, Boolean(value));
44
45
  }
@@ -89,13 +90,19 @@ const copyButtons = [...document.querySelectorAll('pre')].map(pre => {
89
90
  frame.className = 'space-copy-frame';
90
91
  button.type = 'button';
91
92
  button.className = 'space-copy';
92
- button.textContent = '⧉';
93
+ // With an icon package in .config the button shows the icons the build drew; without one it shows the word.
94
+ const copy = copyIcons?.copy ?? '';
95
+ const copied = copyIcons?.copied ?? '✓';
96
+ button.innerHTML = copy;
93
97
  let timer;
94
98
  button.addEventListener('click', () => {
95
99
  navigator.clipboard?.writeText(pre.textContent).catch(() => {});
96
- button.textContent = '✓';
100
+ button.innerHTML = copied;
97
101
  clearTimeout(timer);
98
- timer = setTimeout(() => { button.textContent = '⧉'; }, 1600);
102
+ timer = setTimeout(() => {
103
+ button.innerHTML = copy;
104
+ if (!copyIcons) button.textContent = button.title;
105
+ }, 1600);
99
106
  });
100
107
  pre.replaceWith(frame);
101
108
  frame.append(pre, button);
@@ -108,6 +115,7 @@ function applyLocale(locale) {
108
115
  for (const button of copyButtons) {
109
116
  button.setAttribute('aria-label', dictionary['code.copy']);
110
117
  button.title = dictionary['code.copy'];
118
+ if (!copyIcons) button.textContent = dictionary['code.copy'];
111
119
  }
112
120
  document.documentElement.lang = locale;
113
121
  document.title = dictionary['site.title'];
@@ -144,8 +152,8 @@ function applyTheme(name, persist = false) {
144
152
  if (persist) savePreference(themeKey, theme);
145
153
  }
146
154
 
147
- // Short fragments from older links: #agent opens type-index-agent, #logic opens logic-guide.
148
- const shortViews = new Map([['home', 'home-guide'], ['logic', 'logic-guide'], ['markup', 'markup-reference']]);
155
+ // Short fragments from older links: #logic opens logic-guide, #mock opens type-index-mock.
156
+ const shortViews = new Map([['home', 'home-guide'], ['logic', 'logic-guide'], ['markup', 'markup-reference'], ['search', 'site-search']]);
149
157
  const legacyViews = new Map([...shortViews, ['style-kit', 'kit-overview'], ['styles', 'type-index-style'], ['mockup', 'type-index-mock']]);
150
158
  // The search shows a view by its short name: type-index-agent is .agent, logic-guide is .logic.
151
159
  function shortName(id) {
@@ -232,13 +240,193 @@ function setupSearch(form) {
232
240
 
233
241
  const searchForm = document.querySelector('[data-doc-search]');
234
242
  const refreshSearch = searchForm && setupSearch(searchForm);
243
+
244
+ // A field with data-filter filters its view while the reader types. Each [data-filter-group] stays when its heading
245
+ // or lead matches every word, showing all its [data-filter-item]s, or when some of its items match, showing only those.
246
+ // A group without items matches by its whole text. A [data-filter-set] stays while one of its groups stays, and the
247
+ // links of a [data-toc] follow the sections they point to.
248
+ function setupFilter(input) {
249
+ const view = input.closest('[data-view]') ?? document.body;
250
+ const form = input.closest('form');
251
+ const status = view.querySelector('[data-filter-status]');
252
+ const count = view.querySelector('[data-filter-count]');
253
+ const empty = view.querySelector('[data-filter-empty]');
254
+ const toc = view.querySelector('[data-toc]');
255
+ const text = element => normalizeSearch(element?.textContent ?? '');
256
+ const heading = element => text(element.querySelector('h2, h3')) + ' ' + text(element.querySelector(':scope > p'));
257
+
258
+ function refresh() {
259
+ const terms = normalizeSearch(input.value).split(/\s+/).filter(Boolean);
260
+ const matches = value => terms.every(term => value.includes(term));
261
+ let total = 0;
262
+ for (const group of view.querySelectorAll('[data-filter-group]')) {
263
+ const items = [...group.querySelectorAll('[data-filter-item]')];
264
+ if (!terms.length) {
265
+ group.hidden = false;
266
+ for (const item of items) item.hidden = false;
267
+ continue;
268
+ }
269
+ const set = group.closest('[data-filter-set]');
270
+ const titled = matches(heading(group)) || Boolean(set && matches(text(set.querySelector('h2'))));
271
+ if (items.length) {
272
+ let shown = 0;
273
+ for (const item of items) {
274
+ item.hidden = !titled && !matches(text(item));
275
+ if (!item.hidden) shown++;
276
+ }
277
+ group.hidden = shown === 0;
278
+ total += shown;
279
+ } else {
280
+ group.hidden = !titled && !matches(text(group));
281
+ if (!group.hidden) total++;
282
+ }
283
+ }
284
+ for (const set of view.querySelectorAll('[data-filter-set]')) {
285
+ set.hidden = terms.length > 0 && !set.querySelector('[data-filter-group]:not([hidden])');
286
+ }
287
+ if (toc) {
288
+ let title = null;
289
+ let titleHasLinks = false;
290
+ const closeTitle = () => { if (title) title.hidden = !titleHasLinks; };
291
+ for (const child of toc.children) {
292
+ if (child.tagName !== 'A') {
293
+ closeTitle();
294
+ title = child;
295
+ titleHasLinks = false;
296
+ continue;
297
+ }
298
+ const target = child.hash && view.querySelector(child.hash);
299
+ child.hidden = Boolean(target?.closest('[hidden]') && target.closest('[data-view]') === view);
300
+ if (!child.hidden) titleHasLinks = true;
301
+ }
302
+ closeTitle();
303
+ }
304
+ if (count) count.textContent = String(total);
305
+ if (status) status.hidden = !terms.length;
306
+ if (empty) empty.hidden = !terms.length || total > 0;
307
+ // The first section left by the search comes into view when the reader is past it or below it.
308
+ const first = terms.length && view.querySelector('[data-filter-group]:not([hidden])');
309
+ if (first) {
310
+ const { top } = first.getBoundingClientRect();
311
+ if (top < 0 || top > window.innerHeight) first.scrollIntoView();
312
+ }
313
+ }
314
+
315
+ input.addEventListener('input', refresh);
316
+ form?.addEventListener('submit', event => {
317
+ event.preventDefault();
318
+ view.querySelector('[data-filter-group]:not([hidden])')?.scrollIntoView();
319
+ });
320
+ input.addEventListener('keydown', event => {
321
+ if (event.key !== 'Escape' || !input.value) return;
322
+ event.preventDefault();
323
+ input.value = '';
324
+ refresh();
325
+ });
326
+ return refresh;
327
+ }
328
+ const filterRefreshers = [...document.querySelectorAll('[data-filter]')].map(setupFilter);
329
+
330
+ // A [data-icon-catalog] lists the icons of the package that .config declares. It loads the catalog the first time its
331
+ // view opens, draws each [data-icon-category] list with the icons of that category, and redraws them in the style of
332
+ // the pressed [data-icon-style] button. A click on an icon copies the markup that shows it.
333
+ const iconStyleKey = 'aliens-docs-icon-style';
334
+ function setupIconCatalog(root) {
335
+ const view = root.closest('[data-view]') ?? document.body;
336
+ const buttons = [...view.querySelectorAll('[data-icon-style]')];
337
+ const names = [...view.querySelectorAll('[data-icon-style-name]')];
338
+ const loading = view.querySelector('#icon-docs-loading');
339
+ const toast = view.querySelector('#icon-docs-toast');
340
+ const saved = preference(iconStyleKey);
341
+ let style = iconRenderer.styles.includes(saved) ? saved : iconStyle;
342
+ let icons = null;
343
+ let state = 'idle';
344
+ let toastTimer;
345
+
346
+ function paint() {
347
+ for (const button of buttons) button.setAttribute('aria-pressed', String(button.dataset.iconStyle === style));
348
+ for (const name of names) name.textContent = style;
349
+ if (!icons) return;
350
+ let index = 0;
351
+ for (const glyph of root.querySelectorAll('[data-icon]')) {
352
+ glyph.firstElementChild.outerHTML = iconRenderer.svg(icons[glyph.dataset.icon], style, 'catalog' + index++)
353
+ .replace('<svg ', '<svg aria-hidden="true" focusable="false" ');
354
+ }
355
+ }
356
+
357
+ async function load() {
358
+ if (state !== 'idle') return;
359
+ state = 'loading';
360
+ try {
361
+ const catalog = await fetch(root.dataset.iconCatalog).then(response => {
362
+ if (!response.ok) throw new Error(response.statusText);
363
+ return response.json();
364
+ });
365
+ icons = catalog.icons;
366
+ const lists = new Map([...root.querySelectorAll('[data-icon-category]')].map(list => [list.dataset.iconCategory, list]));
367
+ for (const { id, icons: members } of catalog.categories) {
368
+ lists.get(id)?.replaceChildren(...members.map(name => {
369
+ const item = document.createElement('li');
370
+ const button = document.createElement('button');
371
+ const label = document.createElement('span');
372
+ item.dataset.filterItem = '';
373
+ button.type = 'button';
374
+ button.dataset.icon = name;
375
+ button.title = name;
376
+ label.textContent = name;
377
+ button.append(document.createElement('svg'), label);
378
+ item.append(button);
379
+ return item;
380
+ }));
381
+ }
382
+ state = 'ready';
383
+ if (loading) loading.hidden = true;
384
+ paint();
385
+ for (const refreshFilter of filterRefreshers) refreshFilter();
386
+ } catch {
387
+ state = 'idle';
388
+ if (loading) loading.textContent = 'The icon catalog could not be loaded.';
389
+ }
390
+ }
391
+
392
+ view.addEventListener('click', event => {
393
+ const choice = event.target.closest('[data-icon-style]');
394
+ if (choice && view.contains(choice)) {
395
+ style = choice.dataset.iconStyle;
396
+ savePreference(iconStyleKey, style);
397
+ paint();
398
+ return;
399
+ }
400
+ const icon = event.target.closest('[data-icon]');
401
+ if (!icon || !root.contains(icon)) return;
402
+ const markup = style === iconStyle ? `icon ${icon.dataset.icon}` : `icon ${icon.dataset.icon} ${style}`;
403
+ navigator.clipboard?.writeText(markup).catch(() => {});
404
+ for (const copied of root.querySelectorAll('[data-copied]')) delete copied.dataset.copied;
405
+ icon.dataset.copied = '';
406
+ if (toast) {
407
+ toast.textContent = `${root.dataset.iconCopied} ${markup}`;
408
+ toast.hidden = false;
409
+ clearTimeout(toastTimer);
410
+ toastTimer = setTimeout(() => {
411
+ toast.hidden = true;
412
+ delete icon.dataset.copied;
413
+ }, 1800);
414
+ }
415
+ });
416
+ paint();
417
+ return { load, visible: () => !view.hidden };
418
+ }
419
+ const iconCatalogs = iconRenderer ? [...document.querySelectorAll('[data-icon-catalog]')].map(setupIconCatalog) : [];
235
420
  // ⌘K on Apple devices, Ctrl+K elsewhere, focuses the documentation search from anywhere on the page.
236
421
  const searchShortcut = document.getElementById('doc-search-shortcut');
237
422
  if (searchShortcut && !/Mac|iPhone|iPad/.test(navigator.platform)) searchShortcut.textContent = 'Ctrl K';
423
+ // When the search lives in its own view, the shortcut opens that view first.
238
424
  document.addEventListener('keydown', event => {
239
425
  if (!searchForm || event.key.toLowerCase() !== 'k' || !(event.metaKey || event.ctrlKey)) return;
240
426
  event.preventDefault();
241
- searchForm.querySelector('input').focus();
427
+ const view = searchForm.closest('[data-view]');
428
+ if (view?.hidden) location.hash = view.id;
429
+ else searchForm.querySelector('input').focus();
242
430
  });
243
431
  const views = [...document.querySelectorAll('[data-view]')];
244
432
  const navigation = [...document.querySelectorAll('[data-nav]')];
@@ -257,13 +445,32 @@ function showView({ scroll = false } = {}) {
257
445
  const requested = target?.closest('[data-view]') ?? views[0];
258
446
  for (const view of views) view.hidden = view !== requested;
259
447
  for (const link of navigation) {
260
- if (link.hash === '#' + requested?.id) link.setAttribute('aria-current', 'page');
448
+ // A short fragment such as #search marks its link as current like the full view id does.
449
+ if (link.hash === '#' + requested?.id || shortViews.get(link.hash.slice(1)) === requested?.id) link.setAttribute('aria-current', 'page');
261
450
  else link.removeAttribute('aria-current');
262
451
  }
452
+ // A table of contents (data-toc) marks the link to the section in the address as the current location.
453
+ for (const link of document.querySelectorAll('[data-toc] a')) {
454
+ if (link.hash !== location.hash || !location.hash) {
455
+ link.removeAttribute('aria-current');
456
+ continue;
457
+ }
458
+ link.setAttribute('aria-current', 'location');
459
+ // Keeps the current link visible inside a scrolling table of contents, without moving the page.
460
+ let box = link.parentElement;
461
+ while (box && box !== document.body && box.scrollHeight <= box.clientHeight) box = box.parentElement;
462
+ if (box && box !== document.body) {
463
+ const offset = link.getBoundingClientRect().top - box.getBoundingClientRect().top;
464
+ if (offset < 0 || offset > box.clientHeight - link.offsetHeight) box.scrollTop += offset - box.clientHeight / 2;
465
+ }
466
+ }
263
467
  if (scroll && target && !target.closest('[hidden]')) {
264
468
  target.scrollIntoView();
265
469
  target.focus({ preventScroll: true });
266
470
  }
471
+ // A view that holds the search focuses its field, ready to type.
472
+ requested?.querySelector('[data-doc-search] input')?.focus({ preventScroll: true });
473
+ for (const catalog of iconCatalogs) if (catalog.visible()) catalog.load();
267
474
  }
268
475
 
269
476
  document.addEventListener('click', event => {
@@ -278,6 +485,7 @@ document.addEventListener('click', event => {
278
485
  const updatedLocale = localeModel.state[localeField];
279
486
  applyLocale(updatedLocale);
280
487
  refreshSearch?.();
488
+ for (const refreshFilter of filterRefreshers) refreshFilter();
281
489
  savePreference(localeKey, updatedLocale);
282
490
  }
283
491
  if (handler === themeModel) {
@@ -0,0 +1,5 @@
1
+ Agent Codingbot
2
+ # CodingBot starts every task at ai/.map and follows the rules in ai/rules/.
3
+ # Before editing a file, it reads that file's entries under directives: in ai/.map; they come from #AGENT comments.
4
+ # It edits only the Space files of the Element involved and runs node tools/build.mjs after each change.
5
+ # It fixes each build error by file and line until the build passes.
@@ -0,0 +1,11 @@
1
+ Rule Architecture
2
+ # Use Space for every Aliens application, page, Element, and named source file.
3
+ # Start each named file with its type and PascalCase name, derived from its filename.
4
+ # The declaration for project/app/app.markup is Markup App. Other examples are Style App and Pipe Currency.
5
+ # Use three spaces per indentation level, explicit types for logic and contracts, and declarative comments.
6
+ # Keep app, assets, language, and styles in project. Keep README.md, .config, and ai at the workspace root.
7
+ # Place pages under project/app/pages and reusable Elements under project/app/elements.
8
+ # Compose atoms into molecules, organisms, and templates. A reusable Element does not depend on a page.
9
+ # Keep the .markup, .logic, .style, and .test files of an Element together in its folder.
10
+ # Use .style for element stylesheets and the global layers declared in project/styles/main.style.
11
+ # In .style, write plain CSS as property: value. Utility class names, like flex gap-4 md:flex-row, need npm install @aliens-syndicate/style and style: from: @aliens-syndicate/style in .config.
@@ -0,0 +1,6 @@
1
+ Skill CreateElement
2
+ # Create an Element in project/app/elements/<level>/<name>/, where level is atoms, molecules, organisms, or templates.
3
+ # Name every file after its folder: <name>.markup renders, <name>.logic behaves, <name>.style styles, <name>.test lists checks.
4
+ # Start each file with its declaration, like Markup ProductCard for product-card.markup.
5
+ # Prefix every id and variant with the Element name, like product-card-title.
6
+ # Run node tools/build.mjs and fix each error by file and line.
@@ -1,6 +1,4 @@
1
1
  Markup KitCardLink
2
2
  a href={$href} variant="space-card kit-card-link space-focus"
3
- span={$preview} variant="kit-card-link-icon" aria-hidden="true"
4
3
  h3={$label} variant="space-h5"
5
4
  span={$caption} variant="kit-card-link-caption"
6
- span={↗} variant="kit-card-link-arrow" aria-hidden="true"
@@ -17,9 +17,9 @@ Markup KitOverview
17
17
  section id="kit-overview-section" variant="space-stack"
18
18
  h2={@kit.explore} variant="space-h3"
19
19
  div id="kit-overview-entry-grid" variant="space-grid"
20
- kit-card-link href="#kit-color" label={@kit.color} caption={@kit.colorDesc} preview="●"
21
- kit-card-link href="#kit-space" label={@kit.spacing} caption={@kit.spacingDesc} preview="⟷"
22
- kit-card-link href="#kit-radius" label={@kit.radius} caption={@kit.radiusDesc} preview="◜"
23
- kit-card-link href="#kit-border" label={@kit.borders} caption={@kit.borderDesc} preview="□"
24
- kit-card-link href="#kit-type" label={@kit.typography} caption={@kit.typeDesc} preview="Aa"
25
- kit-card-link href="#kit-components" label={@kit.components} caption={@kit.componentDesc} preview="▥"
20
+ kit-card-link href="#kit-color" label={@kit.color} caption={@kit.colorDesc}
21
+ kit-card-link href="#kit-space" label={@kit.spacing} caption={@kit.spacingDesc}
22
+ kit-card-link href="#kit-radius" label={@kit.radius} caption={@kit.radiusDesc}
23
+ kit-card-link href="#kit-border" label={@kit.borders} caption={@kit.borderDesc}
24
+ kit-card-link href="#kit-type" label={@kit.typography} caption={@kit.typeDesc}
25
+ kit-card-link href="#kit-components" label={@kit.components} caption={@kit.componentDesc}