@kerfjs/ui 5.0.0-beta.132 → 5.0.0-beta.133

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 (85) hide show
  1. package/README.md +26 -1
  2. package/ai/choice-wiring-mode.cjs +68 -0
  3. package/ai/component-catalog.json +4 -2
  4. package/ai/component-composition.json +6 -1
  5. package/ai/components/combobox.md +1 -1
  6. package/ai/components/popup-menu.md +1 -0
  7. package/ai/components/switch.md +1 -1
  8. package/ai/public-api-signatures-v1.md +49 -9
  9. package/ai/webawesome-jsx-signatures-v1.md +1 -1
  10. package/dist/catalog-library.d.ts +26 -0
  11. package/dist/catalog-library.js +2484 -0
  12. package/dist/catalog-library.js.map +1 -0
  13. package/dist/catalog-resources.d.ts +1 -1
  14. package/dist/catalog-resources.js +1 -20
  15. package/dist/catalog-resources.js.map +1 -1
  16. package/dist/catalog.d.ts +3 -2
  17. package/dist/catalog.js +140 -13
  18. package/dist/catalog.js.map +1 -1
  19. package/dist/{chunk-DUKE3PLH.js → chunk-DXZA7OC6.js} +57 -13
  20. package/dist/chunk-DXZA7OC6.js.map +1 -0
  21. package/dist/{chunk-RYBJ7OZB.js → chunk-IXT2ARIM.js} +2 -2
  22. package/dist/{chunk-RYBJ7OZB.js.map → chunk-IXT2ARIM.js.map} +1 -1
  23. package/dist/{chunk-4YXKDS6I.js → chunk-PBXTHYB4.js} +1 -1
  24. package/dist/chunk-PBXTHYB4.js.map +1 -0
  25. package/dist/{chunk-FJAAOIMP.js → chunk-PIYFVFPL.js} +8 -2
  26. package/dist/chunk-PIYFVFPL.js.map +1 -0
  27. package/dist/{chunk-H2XGWH4V.js → chunk-QNB5DKKP.js} +2 -2
  28. package/dist/{chunk-H2XGWH4V.js.map → chunk-QNB5DKKP.js.map} +1 -1
  29. package/dist/{chunk-TNJGPG6R.js → chunk-QWAAR5JX.js} +2 -2
  30. package/dist/{chunk-TNJGPG6R.js.map → chunk-QWAAR5JX.js.map} +1 -1
  31. package/dist/{chunk-Z4PGAYO7.js → chunk-XNSYDA6G.js} +4 -4
  32. package/dist/{chunk-Z4PGAYO7.js.map → chunk-XNSYDA6G.js.map} +1 -1
  33. package/dist/chunk-YM7VF5SY.js +22 -0
  34. package/dist/chunk-YM7VF5SY.js.map +1 -0
  35. package/dist/{chunk-5L3MLWD5.js → chunk-YRQ4KKLG.js} +11 -2
  36. package/dist/chunk-YRQ4KKLG.js.map +1 -0
  37. package/dist/{chunk-EWCTBJ5O.js → chunk-ZDI5I2HT.js} +2 -2
  38. package/dist/{chunk-EWCTBJ5O.js.map → chunk-ZDI5I2HT.js.map} +1 -1
  39. package/dist/collapsible-panel.js +2 -2
  40. package/dist/combobox.d.ts +5 -1
  41. package/dist/combobox.js +1 -1
  42. package/dist/compose-B_GFfFhm.d.ts +36 -0
  43. package/dist/index.js +9 -9
  44. package/dist/list-action-row.js +1 -1
  45. package/dist/list-detail-dialog.js +2 -2
  46. package/dist/nav-stack.js +1 -1
  47. package/dist/popup-menu-register.js +7 -1
  48. package/dist/popup-menu-register.js.map +1 -1
  49. package/dist/popup-menu.d.ts +2 -0
  50. package/dist/popup-menu.js +1 -1
  51. package/dist/select-register.js +2 -1
  52. package/dist/select-register.js.map +1 -1
  53. package/dist/split-view.js +1 -1
  54. package/dist/styles/components/actions/popup-menu/popup-menu.css +12 -1
  55. package/dist/styles/components/data-display/value-table/value-table.css +3 -1
  56. package/dist/styles/components/forms/switch/switch.css +9 -0
  57. package/dist/styles/popup-menu.css +12 -1
  58. package/dist/styles/switch.css +9 -0
  59. package/dist/styles/value-table.css +3 -1
  60. package/dist/switch.d.ts +3 -1
  61. package/dist/switch.js +1 -1
  62. package/dist/{types-DmHWkSd6.d.ts → types-CuKf5G87.d.ts} +6 -2
  63. package/dist/wire-catalog.d.ts +3 -3
  64. package/dist/wire-catalog.js +11 -2
  65. package/dist/wire-catalog.js.map +1 -1
  66. package/dist/workbench-dialog.js +1 -1
  67. package/dist/workbench.js +1 -1
  68. package/docs/catalog.md +59 -0
  69. package/docs/component-selection.md +6 -1
  70. package/docs/examples/composed-catalog.tsx +113 -0
  71. package/docs/examples/scoped-combobox.ts +99 -0
  72. package/docs/examples/typed-action-table.tsx +34 -0
  73. package/docs/forms-and-validation.md +2 -0
  74. package/docs/investigations/combobox-seed-ownership.md +49 -0
  75. package/docs/investigations/measure-scoped-combobox.mjs +87 -0
  76. package/docs/investigations/scoped-combobox.md +98 -0
  77. package/docs/switch.md +21 -0
  78. package/docs/ui-doctor.md +16 -0
  79. package/doctor/cli.mjs +38 -25
  80. package/doctor/explain-use.mjs +320 -0
  81. package/package.json +5 -2
  82. package/dist/chunk-4YXKDS6I.js.map +0 -1
  83. package/dist/chunk-5L3MLWD5.js.map +0 -1
  84. package/dist/chunk-DUKE3PLH.js.map +0 -1
  85. package/dist/chunk-FJAAOIMP.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ import { Combobox, type ComboboxProps } from '@kerfjs/ui/combobox';
2
+ import {
3
+ type ComboboxCommit,
4
+ wireComboboxes,
5
+ } from '@kerfjs/ui/wire-comboboxes';
6
+
7
+ type RenderProps = Omit<ComboboxProps, 'id' | 'value'>;
8
+ type FieldOptions = {
9
+ id: string;
10
+ initialValue?: string;
11
+ onCommit: (commit: ComboboxCommit) => void;
12
+ };
13
+
14
+ const boundary = 'data-example-combobox-owner';
15
+ const selector = `[${boundary}]`;
16
+
17
+ /** Consumer recipe. Create once outside mount's repeating render callback. */
18
+ export function createComboboxOwner(commitKeys: readonly string[] = [',']) {
19
+ const fields = new Map<
20
+ string,
21
+ { token: symbol; commit: FieldOptions['onCommit'] }
22
+ >();
23
+ const keys = [...commitKeys];
24
+ let root: HTMLElement | undefined;
25
+ let unwire: (() => void) | undefined;
26
+ let disposed = false;
27
+
28
+ function ensureLive() {
29
+ if (disposed) throw new Error('Combobox owner was disposed');
30
+ }
31
+
32
+ function startWiring() {
33
+ if (!root || unwire || fields.size === 0) return;
34
+ unwire = wireComboboxes(root, {
35
+ commitKeys: keys,
36
+ onCommit: (event) => fields.get(event.id)?.commit(event),
37
+ });
38
+ }
39
+
40
+ function closeFocused(id?: string) {
41
+ const focused = root?.ownerDocument.activeElement;
42
+ if (
43
+ focused &&
44
+ root?.contains(focused) &&
45
+ fields.has(focused.id) &&
46
+ (id === undefined || id === focused.id)
47
+ ) {
48
+ // The wire's focusout closes the popover and stops following its anchor.
49
+ (focused as HTMLElement).blur();
50
+ }
51
+ }
52
+
53
+ function stopWiring() {
54
+ unwire?.();
55
+ unwire = undefined;
56
+ }
57
+
58
+ return {
59
+ field({ id, initialValue = '', onCommit }: FieldOptions) {
60
+ ensureLive();
61
+ if (fields.has(id)) throw new Error(`Duplicate Combobox id: ${id}`);
62
+ const token = Symbol();
63
+ fields.set(id, { token, commit: onCommit });
64
+ startWiring();
65
+ return {
66
+ render(props: RenderProps) {
67
+ if (fields.get(id)?.token !== token)
68
+ throw new Error('Combobox field was disposed');
69
+ return Combobox({ ...props, id, value: initialValue });
70
+ },
71
+ dispose() {
72
+ if (fields.get(id)?.token !== token) return;
73
+ closeFocused(id);
74
+ fields.delete(id);
75
+ if (!fields.size) stopWiring();
76
+ },
77
+ };
78
+ },
79
+ connect(host: HTMLElement) {
80
+ ensureLive();
81
+ if (root || host.closest(selector) || host.querySelector(selector))
82
+ throw new Error(
83
+ 'Overlapping Combobox owners must share the outer owner',
84
+ );
85
+ host.setAttribute(boundary, '');
86
+ root = host;
87
+ startWiring();
88
+ },
89
+ dispose() {
90
+ if (disposed) return;
91
+ disposed = true;
92
+ closeFocused();
93
+ stopWiring();
94
+ fields.clear();
95
+ root?.removeAttribute(boundary);
96
+ root = undefined;
97
+ },
98
+ };
99
+ }
@@ -0,0 +1,34 @@
1
+ import { Button } from '@kerfjs/ui/button';
2
+ import { mount, signal } from 'kerfjs';
3
+ import { action, type ActionHandler, delegateActions } from 'kerfjs/actions';
4
+
5
+ /** A command name must belong to the table that handles this event. */
6
+ export function mountCounter(root: HTMLElement): () => void {
7
+ const count = signal(0);
8
+ const clicks = {
9
+ increment: () => {
10
+ count.value += 1;
11
+ },
12
+ reset: () => {
13
+ count.value = 0;
14
+ },
15
+ } satisfies Record<string, ActionHandler<HTMLButtonElement>>;
16
+ const click = action<keyof typeof clicks>;
17
+ const increment = click('increment');
18
+ const reset = click('reset');
19
+
20
+ const unmount = mount(root, () => (
21
+ <section>
22
+ <output>{count}</output>
23
+ <Button action={increment.value}>Increment</Button>
24
+ <button type="button" {...reset.attrs}>
25
+ Reset
26
+ </button>
27
+ </section>
28
+ ));
29
+ const unwire = delegateActions(root, 'click', clicks);
30
+ return () => {
31
+ unwire();
32
+ unmount();
33
+ };
34
+ }
@@ -10,6 +10,8 @@ Keep an unavailable choice or action visible and disabled when that helps explai
10
10
 
11
11
  See [accessibility contracts](./accessibility.md#textfield) for field behavior, [interaction conventions](./interaction-conventions.md) for dialog and action order, and [application testing](./testing-applications.md) for form assertions.
12
12
 
13
+ For immediately applied settings, see the [Switch layout and accessibility requirements](./switch.md).
14
+
13
15
  ## Form
14
16
 
15
17
  Group fields that are saved or sent together in a `Form` from `@kerfjs/ui/form`, not a raw `<form>`. It renders a native `form` with no inset, chrome, or layout of its own (`display: contents`), so its children lay out as the parent's own; put a `List`, `Row`, or `Grid` inside it for rhythm. A parent rule that selects its direct children does not reach through it.
@@ -0,0 +1,49 @@
1
+ # Combobox input ownership
2
+
3
+ A field can take initial text and then let the person edit it. In Kerf, a
4
+ component function returns HTML and has no persistent instance. For an
5
+ uncontrolled Combobox, obtain the seed outside the repeating render and pass
6
+ that stable string as `value`. Changing suggestions can then rerender the
7
+ field without moving the caret or replacing an edit.
8
+
9
+ ## What the browser does today
10
+
11
+ The Chromium case in `ui/tests/browser/combobox-seed.spec.ts` uses the
12
+ published entry points inside a mounted form with the normal keyboard wiring.
13
+ The native input's `defaultValue` and its `value` attribute agree throughout.
14
+
15
+ | Action | Visible text | Native reset value |
16
+ | ----------------------------------------------------- | --------------- | ------------------ |
17
+ | Mount with `value="first"` | first | first |
18
+ | Type "draft", set the caret at 2, refresh suggestions | draft (caret 2) | first |
19
+ | Render `value="second"` while focused | draft | second |
20
+ | Blur, render `value="third"` | third | third |
21
+ | Type again, reset the form | third | third |
22
+ | Type again, replace the form with a new key | third | third |
23
+
24
+ ## Proposed contract for review
25
+
26
+ Capture `initialValue` outside the repeating render, on the same per-field
27
+ owner that registers the commit callback in the scoped Combobox pilot.
28
+ One live owner holds a scalar seed and can render updated suggestions,
29
+ disabled status, and hint. A new field identity takes a fresh seed. Native
30
+ form reset restores the seed captured for the current field. Resolve
31
+ `initialValue ?? value ?? ''` at creation if both spellings are accepted,
32
+ so an explicit empty string wins. Render the seed through the existing escaped
33
+ input attribute for server and client. Capture it in the field owner, never
34
+ in a process-wide map keyed on a DOM id. A browser can host multiple
35
+ independent roots and a server can render multiple requests at once.
36
+
37
+ A direct `initialValue` alias on today's function would still set the new
38
+ value attribute on each coarse render. A blurred field would lose its edit.
39
+ The JSX `defaultValue` spelling aliases to that same attribute. An observer
40
+ can run after the morph has overwritten the property. Skipping the whole
41
+ input during morph would also freeze disabled status, placeholder and accessible
42
+ relationships. A general initial-only attribute in the core renderer deserves
43
+ its own evaluation across full and granular reconciliation and the supported
44
+ runtime versions.
45
+
46
+ For an owner-based API, verify changing suggestions and unrelated parent
47
+ props before and after blur, accessible label/hint changes, reset, remount,
48
+ a second independent root, and escaped initial text in SSR. Compare that
49
+ authoring cost with keeping a stable `value` in the existing API.
@@ -0,0 +1,87 @@
1
+ import assert from 'node:assert/strict';
2
+ import console from 'node:console';
3
+ import process from 'node:process';
4
+ import { fileURLToPath, URL } from 'node:url';
5
+ import { TextDecoder } from 'node:util';
6
+ import { gzipSync } from 'node:zlib';
7
+
8
+ import { build, version } from 'esbuild';
9
+
10
+ const ui = fileURLToPath(new URL('../../', import.meta.url));
11
+ const common = `
12
+ import { mount } from 'kerfjs';
13
+ import '@kerfjs/ui/combobox.css';
14
+ const props = { label: 'Tag', suggestions: ['blue'] };
15
+ `;
16
+ const manual =
17
+ common +
18
+ `
19
+ import { Combobox } from '@kerfjs/ui/combobox';
20
+ import { wireComboboxes } from '@kerfjs/ui/wire-comboboxes';
21
+ export function app(root, onCommit, initialValue) {
22
+ const stop = mount(root, () => Combobox({ ...props, id: 'tag', value: initialValue }));
23
+ const release = wireComboboxes(root, { onCommit });
24
+ return () => { release(); stop(); };
25
+ }
26
+ `;
27
+ const recipe =
28
+ common +
29
+ `
30
+ import { createComboboxOwner } from './docs/examples/scoped-combobox.ts';
31
+ export function app(root, onCommit, initialValue) {
32
+ const owner = createComboboxOwner();
33
+ const tag = owner.field({ id: 'tag', initialValue, onCommit });
34
+ const stop = mount(root, () => tag.render(props));
35
+ owner.connect(root);
36
+ return () => { owner.dispose(); stop(); };
37
+ }
38
+ `;
39
+ const button = `
40
+ import { mount } from 'kerfjs';
41
+ import { Button } from '@kerfjs/ui/button';
42
+ import '@kerfjs/ui/button.css';
43
+ export const app = (root) => mount(root, () => Button({ children: 'Save' }));
44
+ `;
45
+
46
+ async function bundle(contents) {
47
+ const result = await build({
48
+ stdin: { contents, resolveDir: ui },
49
+ tsconfigRaw: {},
50
+ bundle: true,
51
+ minify: true,
52
+ platform: 'browser',
53
+ format: 'esm',
54
+ target: 'es2022',
55
+ write: false,
56
+ outdir: 'out',
57
+ legalComments: 'none',
58
+ });
59
+ return result.outputFiles.map((file) => file.contents);
60
+ }
61
+
62
+ console.log(`Node ${process.versions.node}, esbuild ${version}, default gzip`);
63
+ for (const [name, code] of Object.entries({ manual, recipe, button })) {
64
+ const [js, css] = await bundle(code);
65
+ console.log(name, {
66
+ js: js.length,
67
+ jsGzip: gzipSync(js).length,
68
+ css: css.length,
69
+ cssGzip: gzipSync(css).length,
70
+ });
71
+ if (name === 'button') {
72
+ const unusedOwner =
73
+ "import { createComboboxOwner } from './docs/examples/scoped-combobox.ts';";
74
+ const [trimmedJs, trimmedCss] = await bundle(unusedOwner + code);
75
+ assert.doesNotMatch(
76
+ new TextDecoder().decode(trimmedJs),
77
+ /data-example-combobox-owner|kui-combobox__input/,
78
+ );
79
+ assert.doesNotMatch(new TextDecoder().decode(css), /\.kui-combobox\{/);
80
+ console.log('button with unused owner import', {
81
+ js: trimmedJs.length,
82
+ jsGzip: gzipSync(trimmedJs).length,
83
+ css: trimmedCss.length,
84
+ cssGzip: gzipSync(trimmedCss).length,
85
+ });
86
+ }
87
+ }
@@ -0,0 +1,98 @@
1
+ # Scoped Combobox pilot
2
+
3
+ Retain the public `Combobox` and `wireComboboxes` entries. Use the typed
4
+ [scoped recipe](../examples/scoped-combobox.ts) as a reference for applications
5
+ that dynamically add fields with independent callbacks. It makes the seed and
6
+ callback lifetime explicit and costs 403 additional gzip bytes in the measured
7
+ one-field app. A single-field consumer already gets the same listener count with
8
+ less source. A browser reproduced duplicate commits when the two wiring styles
9
+ were mixed. Resolve that ownership ambiguity before adding an API to the package
10
+ (KF-Z9RA3T).
11
+
12
+ ## One field, two authoring patterns
13
+
14
+ The current public recipe captures the initial string in its surrounding
15
+ function. Each additional field routes through the common commit callback.
16
+
17
+ ```ts
18
+ const unmount = mount(root, () => Combobox({ id, value: initialValue, ...props() }));
19
+ const release = wireComboboxes(root, { onCommit: handleCommit });
20
+ // On teardown
21
+ release();
22
+ unmount();
23
+ ```
24
+
25
+ The scoped example registers a field outside the repeating render. Dynamic
26
+ suggestions, accessible names and hints still belong in the render. The caller
27
+ can locally determine which callback receives each field's commits.
28
+
29
+ ```ts
30
+ const owner = createComboboxOwner();
31
+ const tag = owner.field({ id, initialValue, onCommit: addTag });
32
+ const unmount = mount(root, () => tag.render(props()));
33
+ owner.connect(root);
34
+ // On teardown
35
+ owner.dispose();
36
+ unmount();
37
+ ```
38
+
39
+ ## Ownership and limits
40
+
41
+ - A registration captures its seed once and owns one callback. A surviving
42
+ input retains its draft through focused and blurred renders. Form reset
43
+ uses the captured seed. Re-register after removal to take a new seed.
44
+ The server renders escaped text with no host, global registry or document.
45
+ - Use one owner per mounted application root and document-unique HTML ids.
46
+ Multiple nested feature components use the same owner and can register
47
+ independently. An ancestor/descendant or second same-host connection
48
+ throws before installing. Sibling roots operate independently. The
49
+ overlap check consults ancestors and the proposed host's own subtree
50
+ on connection. Keep the host outside the repeating render and dispose
51
+ before reparenting a connected root.
52
+ - The owner fixes commit keys on creation. Every field uses that policy.
53
+ A sibling root may choose different keys. Registrations accept field
54
+ options only. Duplicate live IDs and renders from disposed handles throw.
55
+ A stale disposer checks the registration's token before removal.
56
+ - Register before rendering. On removal, dispose a field while its input is
57
+ connected, then remove its markup. The last field releases the installation.
58
+ Disposing the owner clears registrations and releases all wiring. Dispose
59
+ before unmount so focusout can close an open list and stop anchor tracking.
60
+ A raw removal bypasses that ordering. The token protects field handles;
61
+ it cannot distinguish stray live markup reusing a registered HTML id.
62
+ - Manual wiring delegates to every Combobox underneath its root and publishes
63
+ no ownership marker. It can consume keys on unregistered fields, and installing
64
+ it alongside an owner can invoke both callbacks. Keep a whole delegated
65
+ region under one wiring style. Independently movable child applications or
66
+ per-field delimiter sets need a stronger routing contract.
67
+
68
+ ## Measurements
69
+
70
+ Production package browser conditions, ES2022 ESM, esbuild 0.25.12, Node
71
+ 22.23.5, minified, gzip defaults. These bytes include a mounted app and its
72
+ component stylesheet dependencies. Run `node ui/docs/investigations/measure-scoped-combobox.mjs`
73
+ after building root and UI packages. The script contains the executable
74
+ before/after apps.
75
+
76
+ | Mounted consumer | JS bytes | JS gzip | CSS bytes | CSS gzip |
77
+ | ----------------------------------- | -------: | ------: | --------: | -------: |
78
+ | Manual Combobox | 66,258 | 24,595 | 19,343 | 3,803 |
79
+ | Scoped Combobox | 67,280 | 24,998 | 19,343 | 3,803 |
80
+ | Button only | 49,363 | 18,030 | 31,043 | 5,559 |
81
+ | Button plus an unused scoped import | 49,362 | 17,995 | 33,160 | 5,933 |
82
+
83
+ The last row is a deliberate unused import. esbuild removes the owner logic,
84
+ but the browser component entry includes a CSS side effect. This adds 374
85
+ gzip CSS bytes. A Button-only application that omits the import contains
86
+ neither Combobox CSS nor the recipe.
87
+
88
+ | Fields on one root | Live root listeners | Subtree observers | Removed listeners / disconnected observers after final release |
89
+ | ------------------ | ------------------: | ----------------: | -------------------------------------------------------------: |
90
+ | 1 | 5 | 1 | 5 / 1 |
91
+ | 50 | 5 | 1 | 5 / 1 |
92
+
93
+ Counts exclude anchor positioning for an open popover. The browser fixture
94
+ exercises sibling roots, nested fields, a late registration, pointer and
95
+ keyboard routing, a composing Enter, active-option restoration after reorder,
96
+ field removal and id reuse, native reset, and repeated disposal. The legacy
97
+ Combobox suite supplies the filtering and create-policy coverage. The Node
98
+ test renders escaped seeds independently without a browser global.
package/docs/switch.md ADDED
@@ -0,0 +1,21 @@
1
+ # Switch placement
2
+
3
+ Use a Switch for a setting that takes effect immediately. Its native checkbox supplies keyboard and form behavior. Listen for the input's `change` event to persist the new value.
4
+
5
+ ```tsx
6
+ import { Switch } from "@kerfjs/ui/switch";
7
+
8
+ <Switch
9
+ label="Group new tickets automatically"
10
+ hint="Keep related tickets together as they arrive."
11
+ labelPlacement="start"
12
+ checked={groupTickets.value}
13
+ action="toggle-group-tickets"
14
+ />;
15
+ ```
16
+
17
+ ## Layout and accessibility requirements
18
+
19
+ - Omit `labelPlacement` or use `"end"` for the compact inline layout with the track before the label.
20
+ - Use `"start"` in settings rows. The label and hint share the leading text column. The track stays at the trailing edge of the available width, including when the text wraps. Both edges follow the writing direction.
21
+ - Default and compact sizes use the same placement rules. The visible label provides the switch's name and its hint provides the description. Clicking the label activates the switch, Space toggles a focused switch, and the focus ring follows the track. A disabled switch retains its native disabled behavior.
package/docs/ui-doctor.md CHANGED
@@ -368,3 +368,19 @@ process.exitCode = report.exitCode;
368
368
  `--package` accepts either a workspace package name or a workspace-relative package path. The doctor uses the selected package for compiler, lint, profile-discovery start, and analyzer scope, while workspace profile precedence and root lockfiles remain authoritative.
369
369
 
370
370
  A repair agent should run JSON mode, apply only source-located safe changes, and rerun until exit `0`. Do not treat exit `2`, a skipped required stage, or an empty changed selection as clean. Browser evidence is objective input; the evaluator's named subjective rubric still requires human review.
371
+
372
+ ## Explain one JSX use
373
+
374
+ `kerf-ui-doctor --root . --explain-use src/picker.tsx:12:7 --format json`
375
+ inspects a one-based position inside a Combobox or ChoiceChips opening tag.
376
+ The version 1 response includes the component contract, active mode,
377
+ application-owned state, event, candidate wiring roots and source locations
378
+ of cleanup calls. Text format is the default. A native wrapping ChoiceChips
379
+ group needs no behavior installation. Its listbox or scrolling mode uses
380
+ `wireChoiceChips`. A dynamic mode reports the unresolved alternatives.
381
+
382
+ The project's TypeScript source graph supplies evidence of calls. Even when
383
+ the same root binding appears in both locations, verify that setup executes
384
+ for this mount and its owner invokes cleanup. Unknown wrappers need manual
385
+ inspection. Use the returned component card, exact prop signatures, and
386
+ catalog route to check a proposed change with the keyboard.
package/doctor/cli.mjs CHANGED
@@ -34,6 +34,7 @@ try {
34
34
  console.log(`Usage: kerf-ui-doctor [--full | --changed] [options]
35
35
 
36
36
  Options:
37
+ --explain-use <file:line:column> Explain this JSX opening tag and its wiring
37
38
  --root <path> Workspace root (default: current directory)
38
39
  --package <name|path> Select one workspace package
39
40
  --path <path> Restrict changed mode (repeatable)
@@ -53,6 +54,7 @@ Exit codes: 0 clean, 1 findings, 2 configuration/tool failure, 130 cancelled.`);
53
54
  const { options } = parseCliArguments(args, {
54
55
  values: {
55
56
  '--root': 'root',
57
+ '--explain-use': 'explainUse',
56
58
  '--package': 'package',
57
59
  '--path': 'paths',
58
60
  '--config': 'config',
@@ -91,31 +93,42 @@ Exit codes: 0 clean, 1 findings, 2 configuration/tool failure, 130 cancelled.`);
91
93
  throw new Error('--fail-on must be error, review, or warning.');
92
94
  if (!['recommended-ui', 'strict-ui'].includes(eslintConfig))
93
95
  throw new Error('--eslint must be recommended-ui or strict-ui.');
94
- const abort = new globalThis.AbortController();
95
- process.once('SIGINT', () => abort.abort());
96
- const paths =
97
- changed && !explicitPaths.length ? await changedPaths(root) : explicitPaths;
98
- const report = await runUiDoctor({
99
- root,
100
- package: packageSelector,
101
- mode: changed ? 'changed' : full ? 'full' : undefined,
102
- paths,
103
- configPath,
104
- cache: !noCache,
105
- signal: abort.signal,
106
- eslintConfig,
107
- failOn,
108
- browser: url
109
- ? { url, browsers: browserList?.split(',').map((item) => item.trim()) }
110
- : undefined,
111
- });
112
- const rendered =
113
- format === 'json'
114
- ? JSON.stringify(report, null, 2)
115
- : formatUiDoctorText(report);
116
- if (output) await writeFile(resolve(root, output), `${rendered}\n`);
117
- else console.log(rendered);
118
- process.exitCode = report.exitCode;
96
+ if (options.explainUse) {
97
+ const { explainUse, formatUse } = await import('./explain-use.mjs');
98
+ const report = explainUse(root, options.explainUse);
99
+ const rendered =
100
+ format === 'json' ? JSON.stringify(report, null, 2) : formatUse(report);
101
+ if (output) await writeFile(resolve(root, output), rendered + '\n');
102
+ else console.log(rendered);
103
+ } else {
104
+ const abort = new globalThis.AbortController();
105
+ process.once('SIGINT', () => abort.abort());
106
+ const paths =
107
+ changed && !explicitPaths.length
108
+ ? await changedPaths(root)
109
+ : explicitPaths;
110
+ const report = await runUiDoctor({
111
+ root,
112
+ package: packageSelector,
113
+ mode: changed ? 'changed' : full ? 'full' : undefined,
114
+ paths,
115
+ configPath,
116
+ cache: !noCache,
117
+ signal: abort.signal,
118
+ eslintConfig,
119
+ failOn,
120
+ browser: url
121
+ ? { url, browsers: browserList?.split(',').map((item) => item.trim()) }
122
+ : undefined,
123
+ });
124
+ const rendered =
125
+ format === 'json'
126
+ ? JSON.stringify(report, null, 2)
127
+ : formatUiDoctorText(report);
128
+ if (output) await writeFile(resolve(root, output), `${rendered}\n`);
129
+ else console.log(rendered);
130
+ process.exitCode = report.exitCode;
131
+ }
119
132
  } catch (error) {
120
133
  console.error(`kerf-ui-doctor: ${error.message}`);
121
134
  process.exitCode =