@kerfjs/ui 5.0.0-beta.129 → 5.0.0-beta.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/component-catalog.json +14 -9
- package/ai/component-composition-rules.json +1 -1
- package/ai/component-composition.d.ts +17 -0
- package/ai/component-composition.json +4 -3
- package/ai/component-composition.schema.json +326 -80
- package/ai/component-props-overlay.json +8568 -628
- package/ai/component-props-overlay.schema.json +15 -1
- package/ai/component-props.json +6221 -2069
- package/ai/component-props.schema.json +7 -0
- package/ai/components/radio-group.md +5 -1
- package/ai/components/state-banner.md +1 -1
- package/ai/components/surface-scaffold.md +3 -2
- package/ai/components/tab-bar.md +1 -1
- package/ai/components/toolbar-control-group.md +1 -1
- package/ai/public-api-signatures-v1.md +205 -42
- package/ai/skill.md +21 -8
- package/ai/view-document.schema.json +140 -86
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/dist/browser/column-explorer.js +5 -1
- package/dist/browser/radio-group.js +1 -0
- package/dist/catalog-resources.d.ts +2 -2
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js +5 -5
- package/dist/{chunk-E2MTHHLS.js → chunk-2FA3SX57.js} +2 -2
- package/dist/{chunk-E2MTHHLS.js.map → chunk-2FA3SX57.js.map} +1 -1
- package/dist/{chunk-ZC4KSRAF.js → chunk-4CYCJ3NY.js} +6 -4
- package/dist/chunk-4CYCJ3NY.js.map +1 -0
- package/dist/{chunk-IMXLOMTF.js → chunk-76BLSFEA.js} +30 -12
- package/dist/chunk-76BLSFEA.js.map +1 -0
- package/dist/{chunk-IR32NI2O.js → chunk-ALBFHXMZ.js} +3 -3
- package/dist/chunk-ALBFHXMZ.js.map +1 -0
- package/dist/{chunk-3ZWYGGEC.js → chunk-ASU4ODOH.js} +38 -7
- package/dist/chunk-ASU4ODOH.js.map +1 -0
- package/dist/chunk-BMUYZKXW.js +155 -0
- package/dist/chunk-BMUYZKXW.js.map +1 -0
- package/dist/{chunk-GQUDCWOD.js → chunk-D2KHQNJ6.js} +49 -23
- package/dist/chunk-D2KHQNJ6.js.map +1 -0
- package/dist/{chunk-34FWYJX6.js → chunk-ECJHCPBN.js} +8 -2
- package/dist/chunk-ECJHCPBN.js.map +1 -0
- package/dist/{chunk-DBCDYBZP.js → chunk-HHEBNP6Z.js} +2 -2
- package/dist/{chunk-DBCDYBZP.js.map → chunk-HHEBNP6Z.js.map} +1 -1
- package/dist/{chunk-3ZKUXWAV.js → chunk-IPYQYLSX.js} +16 -9
- package/dist/chunk-IPYQYLSX.js.map +1 -0
- package/dist/{chunk-SJEPM5ZU.js → chunk-LETAE6SX.js} +2 -2
- package/dist/{chunk-SJEPM5ZU.js.map → chunk-LETAE6SX.js.map} +1 -1
- package/dist/chunk-MVWR5WRX.js +99 -0
- package/dist/chunk-MVWR5WRX.js.map +1 -0
- package/dist/{chunk-6T7AX365.js → chunk-OSL4LQ7T.js} +52 -23
- package/dist/chunk-OSL4LQ7T.js.map +1 -0
- package/dist/{chunk-OHT2AXER.js → chunk-QSJAIXLM.js} +19 -3
- package/dist/chunk-QSJAIXLM.js.map +1 -0
- package/dist/{chunk-UQ4FRQ6M.js → chunk-R4JK2C6D.js} +13 -3
- package/dist/chunk-R4JK2C6D.js.map +1 -0
- package/dist/{chunk-5A2DN3LR.js → chunk-SGYBIKQA.js} +3 -1
- package/dist/chunk-SGYBIKQA.js.map +1 -0
- package/dist/{chunk-K3C35KGR.js → chunk-XO5IOPM5.js} +2 -2
- package/dist/{chunk-K3C35KGR.js.map → chunk-XO5IOPM5.js.map} +1 -1
- package/dist/collapsible-panel.d.ts +2 -2
- package/dist/collapsible-panel.js +2 -2
- package/dist/column-explorer.d.ts +5 -1
- package/dist/column-explorer.js +5 -1
- package/dist/column-track.d.ts +3 -1
- package/dist/column-track.js +1 -1
- package/dist/editor.d.ts +87 -2
- package/dist/editor.js +2249 -1320
- package/dist/editor.js.map +1 -1
- package/dist/index.js +12 -12
- package/dist/list-detail-dialog.d.ts +2 -2
- package/dist/list-detail-dialog.js +4 -4
- package/dist/list-header.d.ts +47 -5
- package/dist/list-header.js +1 -1
- package/dist/message-composer.js +1 -1
- package/dist/{nav-stack-vQ3ieerq.d.ts → nav-stack-DKrvqFjA.d.ts} +1 -1
- package/dist/nav-stack.d.ts +2 -2
- package/dist/nav-stack.js +1 -1
- package/dist/{panel-toolbar-vg6Ir5Dy.d.ts → panel-toolbar-CEcHHDkn.d.ts} +8 -0
- package/dist/radio-group.d.ts +19 -2
- package/dist/radio-group.js +3 -1
- package/dist/split-view.d.ts +2 -2
- package/dist/split-view.js +1 -1
- package/dist/styles/column-track.css +7 -2
- package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +11 -4
- package/dist/styles/components/collections/list-header/list-header.css +50 -0
- package/dist/styles/components/collections/list-item/list-item.css +6 -1
- package/dist/styles/components/collections/tree-list/tree-list.css +3 -2
- package/dist/styles/components/forms/radio-group/radio-group.css +107 -0
- package/dist/styles/components/layout/column-track/column-track.css +7 -2
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +30 -1
- package/dist/styles/editor/editor.css +0 -23
- package/dist/styles/list-header.css +50 -0
- package/dist/styles/list-item.css +6 -1
- package/dist/styles/radio-group.css +107 -0
- package/dist/styles/surface-scaffold.css +30 -1
- package/dist/styles/toolbar-control-group.css +11 -4
- package/dist/styles/tree-list.css +3 -2
- package/dist/surface-scaffold-register.js +1 -1
- package/dist/surface-scaffold.d.ts +46 -11
- package/dist/surface-scaffold.js +2 -2
- package/dist/toolbar-control-group.d.ts +10 -1
- package/dist/toolbar-control-group.js +1 -1
- package/dist/tree-list.d.ts +7 -1
- package/dist/tree-list.js +1 -1
- package/dist/view-runtime.d.ts +9 -0
- package/dist/view-runtime.js +8 -0
- package/dist/view-runtime.js.map +1 -0
- package/dist/wire-catalog.d.ts +2 -2
- package/dist/wire-catalog.js +1 -1
- package/dist/wire-search-fields.js +1 -1
- package/dist/wire-tab-bars.d.ts +10 -0
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-tag-fields.js +1 -1
- package/dist/wire-workbench.d.ts +17 -1
- package/dist/wire-workbench.js +1 -1
- package/dist/workbench-dialog.d.ts +2 -2
- package/dist/workbench-dialog.js +4 -4
- package/dist/workbench.d.ts +10 -2
- package/dist/workbench.js +1 -1
- package/docs/accessibility.md +1 -1
- package/docs/column-explorer.md +4 -0
- package/docs/component-contract.md +10 -4
- package/docs/component-integration.md +7 -3
- package/docs/component-selection.md +2 -1
- package/docs/design/sketch/Kerf-UI.sketch +0 -0
- package/docs/design/sketch/coverage.md +7 -6
- package/docs/design/sketch/forms/README.md +5 -4
- package/docs/design/sketch/unified/pages/forms.png +0 -0
- package/docs/design/templates/radio-group/tiles-dark.svg +1 -0
- package/docs/design/templates/radio-group/tiles.svg +1 -0
- package/docs/design/templates/radio-group-dark.svg +1 -1
- package/docs/design/templates/radio-group.svg +1 -1
- package/docs/editor-host.md +90 -5
- package/docs/interaction-conventions.md +2 -0
- package/docs/layout.md +1 -1
- package/docs/surface-scaffold.md +49 -2
- package/docs/tree-list.md +10 -0
- package/docs/workbench.md +16 -0
- package/evaluator/firefox-app-data.d.mts +4 -0
- package/evaluator/firefox-app-data.mjs +35 -0
- package/evaluator/index.mjs +19 -5
- package/llms.txt +20 -4
- package/package.json +8 -1
- package/props/component-props.d.mts +3 -0
- package/view/cli.mjs +36 -5
- package/view/contract.mjs +3 -0
- package/view/generate.mjs +8 -7
- package/view/index.d.mts +14 -0
- package/view/project-types-worker.mjs +55 -0
- package/view/project-types.d.mts +43 -0
- package/view/project-types.mjs +618 -0
- package/view/type-expression.d.mts +15 -0
- package/view/type-expression.mjs +162 -0
- package/view/types.mjs +4 -0
- package/view/validate.mjs +20 -1
- package/vite-editor.d.mts +31 -3
- package/vite-editor.mjs +168 -4
- package/dist/chunk-34FWYJX6.js.map +0 -1
- package/dist/chunk-3ZKUXWAV.js.map +0 -1
- package/dist/chunk-3ZWYGGEC.js.map +0 -1
- package/dist/chunk-5A2DN3LR.js.map +0 -1
- package/dist/chunk-6T7AX365.js.map +0 -1
- package/dist/chunk-BMOZSNDU.js +0 -133
- package/dist/chunk-BMOZSNDU.js.map +0 -1
- package/dist/chunk-GQUDCWOD.js.map +0 -1
- package/dist/chunk-IMXLOMTF.js.map +0 -1
- package/dist/chunk-IR32NI2O.js.map +0 -1
- package/dist/chunk-MLDO7WLA.js +0 -82
- package/dist/chunk-MLDO7WLA.js.map +0 -1
- package/dist/chunk-OHT2AXER.js.map +0 -1
- package/dist/chunk-UQ4FRQ6M.js.map +0 -1
- package/dist/chunk-ZC4KSRAF.js.map +0 -1
package/docs/editor-host.md
CHANGED
|
@@ -33,7 +33,8 @@ the editor reopens it on your next visit. The plugin's file endpoint
|
|
|
33
33
|
the project, outside `node_modules` and `.git`, and only for requests the
|
|
34
34
|
editor itself makes. A host that mounts the editor itself passes
|
|
35
35
|
`createEditor({ catalog, storage: devServerStorage() })` and adds
|
|
36
|
-
`editorFileMiddleware(root)` to its server
|
|
36
|
+
`editorFileMiddleware(root)` to its server (and calls the middleware's
|
|
37
|
+
`dispose()` when the server closes). The same middleware lists the
|
|
37
38
|
project's documents (GET `/__kerf-ui-editor/api/files`: every `.kui.json`
|
|
38
39
|
outside `node_modules`, `dist`, `test-results`, and dot-folders), which
|
|
39
40
|
Add a child's **Existing document…** offers in a picker.
|
|
@@ -83,12 +84,12 @@ Options:
|
|
|
83
84
|
|
|
84
85
|
```ts
|
|
85
86
|
// src/kerf-ui-registry.ts
|
|
86
|
-
import {
|
|
87
|
+
import { CustomOrderCard } from "./custom-order-card.js";
|
|
87
88
|
|
|
88
89
|
export default {
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// Replace the real function, including canvas and play rendering.
|
|
91
|
+
// Use libraryPreviews below for Library-only sample data.
|
|
92
|
+
"orders-app:order-card": CustomOrderCard,
|
|
92
93
|
};
|
|
93
94
|
```
|
|
94
95
|
|
|
@@ -310,3 +311,87 @@ A handler may also open an overlay. A handler that throws (or rejects) is
|
|
|
310
311
|
logged, and the view keeps running. An action with no handler is only
|
|
311
312
|
logged. The play bar's **Action log** counts the actions you haven't seen
|
|
312
313
|
and lists them, newest first, with whether a handler ran.
|
|
314
|
+
|
|
315
|
+
## Project TypeScript parameters
|
|
316
|
+
|
|
317
|
+
The Params rail opens a text editor in a dialog. Its completions and live errors
|
|
318
|
+
come from the owning project's TypeScript configuration and source exports.
|
|
319
|
+
A unique exported name is saved as a portable inline `import()` type. Formatting
|
|
320
|
+
runs on blur, and the dialog's NavStack explores object fields, array items and
|
|
321
|
+
union members. Define new named types in application source.
|
|
322
|
+
|
|
323
|
+
`devServerStorage()` includes the project compiler transport. The plugin serves
|
|
324
|
+
`KERF_UI_EDITOR_TYPES_API` (`/__kerf-ui-editor/api/types`), a JSON POST endpoint
|
|
325
|
+
requiring `X-Kerf-UI-Editor: 1`. Requests name a project-relative `.kui.json`
|
|
326
|
+
source. Analysis requests carry
|
|
327
|
+
`{ action: "analyze", source, text, cursor?, suggest? }`; `suggest: false`
|
|
328
|
+
skips completion suggestions, the costliest part of an analysis, and the
|
|
329
|
+
editor sends it whenever it only formats a draft.
|
|
330
|
+
validation requests carry `{ action: "validate", source, document }`. The server
|
|
331
|
+
uses TypeScript's Node API; compiler code never enters the browser bundle.
|
|
332
|
+
TypeScript runs in a worker thread that `editorFileMiddleware` starts on the
|
|
333
|
+
first type request, one per project root, so an analysis never delays the
|
|
334
|
+
server's other responses (a Play page, a save). A worker crash fails the
|
|
335
|
+
requests in flight with a 500 and the next request starts a new worker. The
|
|
336
|
+
worker never keeps the process alive; a host that adds the middleware itself
|
|
337
|
+
calls its `dispose()` when its server closes, as the plugin does.
|
|
338
|
+
|
|
339
|
+
A custom host can pass `createEditor({ typeService })`, a `ProjectTypeService`
|
|
340
|
+
function that answers the same typed requests. Export of compiler-backed
|
|
341
|
+
parameters waits for whole-document checking against actual generated bindings
|
|
342
|
+
and defaults. An unavailable compiler or a failed check prevents that export.
|
|
343
|
+
Legacy parameter descriptors continue to work without a compiler service.
|
|
344
|
+
|
|
345
|
+
## Library-only component previews
|
|
346
|
+
|
|
347
|
+
Use `defineLibraryPreviews` from `@kerfjs/ui/editor` with a literal map of your
|
|
348
|
+
component functions. It checks each catalog key and each sample prop against the
|
|
349
|
+
component's real interface:
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
352
|
+
import "./library-previews.css";
|
|
353
|
+
import { defineLibraryPreviews } from "@kerfjs/ui/editor";
|
|
354
|
+
import { MapPin } from "lucide";
|
|
355
|
+
import { OrderCard, OrderWorkspace, OrderMarker } from "./orders.js";
|
|
356
|
+
|
|
357
|
+
export default defineLibraryPreviews({
|
|
358
|
+
"orders:card": OrderCard,
|
|
359
|
+
"orders:workspace": OrderWorkspace,
|
|
360
|
+
"orders:marker": OrderMarker,
|
|
361
|
+
}, {
|
|
362
|
+
"orders:card": { sampleProps: () => ({ title: "Order #1042", total: 4200 }) },
|
|
363
|
+
"orders:workspace": { render: () => <svg viewBox="0 0 96 72" width="100%" height="100%" aria-hidden="true">{/* schematic */}</svg>, fit: "fill" },
|
|
364
|
+
"orders:marker": { icon: MapPin },
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Pass that map through `createEditorCatalog({ libraryPreviews })` or
|
|
369
|
+
`createEditor({ libraryPreviews })`. For Vite, put its default export in
|
|
370
|
+
`src/kerf-ui-library-previews.ts`, or name a module with
|
|
371
|
+
`kerfUiEditor({ libraryPreviews: "src/library-previews.tsx" })`. Installed package
|
|
372
|
+
composition catalogs may name their editor-only ESM module with
|
|
373
|
+
`libraryPreviewModule` (relative to the catalog or an installed package export).
|
|
374
|
+
Their `libraryPreviews` JSON field contains only `{ props: { ...literalJSON } }`
|
|
375
|
+
entries by component key. JSON does not evaluate `$param`, `$css`, `$icon`,
|
|
376
|
+
functions or JavaScript. Use executable factory samples for SafeHtml content,
|
|
377
|
+
functions, models or signals. A custom host imports executable maps explicitly.
|
|
378
|
+
|
|
379
|
+
Precedence is built-ins, catalog JSON samples, package modules in catalog order,
|
|
380
|
+
catalog host overrides, then editor host overrides. Later registrations replace
|
|
381
|
+
whole entries; `{}` restores automatic live rendering. A static renderer runs
|
|
382
|
+
before ordinary seeded rendering, with sampled props. Thrown, undefined, invalid
|
|
383
|
+
or empty renderer results fall back to ordinary rendering; incompatible samples
|
|
384
|
+
retry ordinary props. Visually empty markup shows the configured icon or the
|
|
385
|
+
generic component icon. For visible but unhelpful ordinary output, supply a
|
|
386
|
+
schematic or a static LucideIcon renderer. `fit: "contain"` is the default;
|
|
387
|
+
`"fill"` is for schematics authored to occupy the complete 4:3 tile.
|
|
388
|
+
|
|
389
|
+
Factories/renderers are synchronous, pure and static; thumbnail output is cached
|
|
390
|
+
per editor. No widgets are mounted or wired there. Output stays inert and hidden
|
|
391
|
+
from accessibility APIs inside an isolated shadow root; the tile itself keeps the
|
|
392
|
+
component's accessible name. Import preview CSS and assets from the module as
|
|
393
|
+
usual: readable page stylesheets are shared into thumbnails, inherited theme
|
|
394
|
+
variables remain available, and asset load/content resize events refit them.
|
|
395
|
+
Samples and overrides never alter document defaults, inserted nodes, canvas or
|
|
396
|
+
play rendering, or generated production views. The `registry` option continues
|
|
397
|
+
to replace real component functions; use `libraryPreviews` for Library-only data.
|
|
@@ -29,6 +29,8 @@ Use the spacing scale by relationship: 8px within a group, 16px between like gro
|
|
|
29
29
|
|
|
30
30
|
- Use ordinary row selection for browsing. Checkboxes mean multi-selection for a bulk task, not the default way to open an item. Keep selected, focused, disabled, loading, and error cues distinct and accessible without color alone.
|
|
31
31
|
- Put secondary row actions in a meaningful “…” menu and expose the same actions through the row's context menu. Every actionable menu entry has an icon from the application's shared icon set. Double-click opens an editable item; always offer a keyboard and visible edit route too.
|
|
32
|
+
- A collapsible section that has its own commands shows them from one trailing overflow button on its header; the header's label and arrow toggle the section, and the overflow button never does (`ListHeader` `toggle` with `overflowAction`).
|
|
33
|
+
- A section header above summary rows starts its label on the rows' leading-content edge; the header and the rows compact together (`ListHeader` `leadingEdge="summary-row"`).
|
|
32
34
|
- Reordering uses drag and drop when the order has meaning. Supply an accessible keyboard route and visible position feedback. Do not expose internal database or provider IDs as ordinary row copy.
|
|
33
35
|
- Reuse a semantic component for the same feature in different contexts, with explicit presentation or read-only variants. A list row and a board card should keep the same identity and actions. An enabled control in a demo must work in its shipped parent composition.
|
|
34
36
|
|
package/docs/layout.md
CHANGED
|
@@ -904,7 +904,7 @@ equally but never narrow below `minColumnWidth` (250px), so a narrow board
|
|
|
904
904
|
scrolls sideways instead of crushing them. `layout="paged"` gives each column
|
|
905
905
|
nearly the visible width, lets the next one `peek` in (24px), snaps to column
|
|
906
906
|
starts, hides the scrollbar, and scrolls smoothly unless reduced motion is
|
|
907
|
-
preferred. Choose the layout per device class in the app.
|
|
907
|
+
preferred. Choose the layout per device class in the app. Set `inset="none"` for an edge-to-edge column viewport without changing the content insets of its columns.
|
|
908
908
|
|
|
909
909
|
Name a board with `ariaLabel`: the track becomes a `role="region"` with that
|
|
910
910
|
name. Name each column the same way: a column `List` takes
|
package/docs/surface-scaffold.md
CHANGED
|
@@ -59,8 +59,11 @@ openDialog(document.getElementById('edit-workspace') as HTMLDialogElement);
|
|
|
59
59
|
`openDialog(dialog)`: it opens modally in the top layer, the rest of the
|
|
60
60
|
page is inert, and focus moves to an `autofocus` element or else the panel.
|
|
61
61
|
`closeDialog(dialog)` closes it after its exit motion; the browser returns
|
|
62
|
-
focus to the element that opened it.
|
|
63
|
-
|
|
62
|
+
focus to the element that opened it. The latest request wins: calling
|
|
63
|
+
`openDialog` while it closes, even after the exit motion but before the
|
|
64
|
+
browser delivers `close`, keeps it open, and that superseded close never
|
|
65
|
+
fires. Do not toggle its `open` attribute, which opens a dialog without
|
|
66
|
+
modality.
|
|
64
67
|
- **Close requests.** The close button, any element inside with
|
|
65
68
|
`data-dialog-close` (a Cancel button), Escape, and, with `lightDismiss`, a
|
|
66
69
|
press on the backdrop ask to close: the dialog dispatches a cancelable
|
|
@@ -580,6 +583,13 @@ hand-built draggable panel. It takes the same geometry props as
|
|
|
580
583
|
the viewport caps. Bottom-edge resizing keeps the current pin state; the
|
|
581
584
|
chosen size survives closing, reopening, and unpinning.
|
|
582
585
|
|
|
586
|
+
`minHeight` accepts a branded `CssLength` and protects fixed controls plus a
|
|
587
|
+
useful content region while resizing. CSS resolves the length and caps the
|
|
588
|
+
minimum by `maxHeight` and the available dynamic viewport. Resizable overlays
|
|
589
|
+
default to 160px; the editor Library configures 320px for its header, view tabs,
|
|
590
|
+
search field, and visible result rows. Keyboard resize reports the actual
|
|
591
|
+
constrained box, so stored height agrees with what the person sees.
|
|
592
|
+
|
|
583
593
|
The surface is `popover="manual"`, so the controller provides its light
|
|
584
594
|
dismiss; changing an `auto` popover into a pinned one is not possible while
|
|
585
595
|
it is open. The title is the move handle: a focusable button named by the
|
|
@@ -607,6 +617,41 @@ const stop = wirePinnablePopover(document.getElementById('library')!, {
|
|
|
607
617
|
});
|
|
608
618
|
```
|
|
609
619
|
|
|
620
|
+
### Persistent floating panels
|
|
621
|
+
|
|
622
|
+
A panel that an application control shows and hides — a feature detached from
|
|
623
|
+
a sidebar into a floating window — takes two props:
|
|
624
|
+
|
|
625
|
+
- `pinnable={false}` renders it always pinned, with no Pin toggle. It never
|
|
626
|
+
re-anchors below an opener or closes on a press outside, and
|
|
627
|
+
`pinPopover(surface, false)` does nothing. It still drags by its title,
|
|
628
|
+
moves with the arrow keys, resizes, and stays inside the viewport gutter, and
|
|
629
|
+
`onChange` still reports moves and resizes.
|
|
630
|
+
- `closable={false}` omits the header Close button. The application hides it
|
|
631
|
+
(`hidePopover()`, or a `popoverTarget` toggle that it owns), and Escape no
|
|
632
|
+
longer closes it unless `wirePinnablePopover` is given `closeOnEscape: true`.
|
|
633
|
+
`closeOnEscape: false` likewise turns Escape off for a closable surface.
|
|
634
|
+
|
|
635
|
+
`headerActions` stay in the header (a Reattach or Dock control), and the title
|
|
636
|
+
stays the accessible move handle. Opened with nothing stored, a persistent
|
|
637
|
+
panel appears centered; pass its stored `placement` to restore it.
|
|
638
|
+
|
|
639
|
+
```tsx
|
|
640
|
+
<PinnablePopoverSurface
|
|
641
|
+
id="announcer"
|
|
642
|
+
label="Announcer"
|
|
643
|
+
pinnable={false}
|
|
644
|
+
closable={false}
|
|
645
|
+
headerActions={
|
|
646
|
+
<ToolbarControlGroup appearance="borderless" single>
|
|
647
|
+
<ToolbarButton ariaLabel="Reattach" icon={<LucideIcon icon={PanelLeftClose} name="panel-left-close" size="m" />} action="reattach" />
|
|
648
|
+
</ToolbarControlGroup>
|
|
649
|
+
}
|
|
650
|
+
>
|
|
651
|
+
{announcer}
|
|
652
|
+
</PinnablePopoverSurface>;
|
|
653
|
+
```
|
|
654
|
+
|
|
610
655
|
The controller keeps its pinned state, placement, and the Pin toggle's
|
|
611
656
|
`aria-pressed` across application re-renders. An application that closes the
|
|
612
657
|
panel after a task (a drop from a library) checks `isPopoverPinned()` first.
|
|
@@ -628,3 +673,5 @@ grabber, and restoring that measured state after an application re-render).
|
|
|
628
673
|
Import `@kerfjs/ui/surface-scaffold/register` once when a dialog may be opened
|
|
629
674
|
without `openDialog` and should still take close requests. Rendering a
|
|
630
675
|
`DialogSurface` has no side effects and registers no custom element.
|
|
676
|
+
|
|
677
|
+
`PinnablePopoverSurface bodyInset` uses the shared surface inset vocabulary: `default` keeps 8px body clearance, `none` delegates all clearance to the body content, and `comfortable` uses the container inset. Use `none` for edge-to-edge scrolling columns whose rows own their own insets.
|
package/docs/tree-list.md
CHANGED
|
@@ -44,10 +44,20 @@ re-renders), a `label`, and optionally a `description`, an `icon` (an unsized
|
|
|
44
44
|
node `hasChildren` to make it expandable before its children are loaded, and
|
|
45
45
|
load them when `toggleAction` expands it.
|
|
46
46
|
|
|
47
|
+
Default rendering composes as ordinary markup, including inside an enclosing
|
|
48
|
+
`each()` row. Opt into native keyed reconciliation with `keyedRows` for large
|
|
49
|
+
standalone trees. In that mode, keep unchanged node objects stable and replace a
|
|
50
|
+
node when its content changes. Expansion, selection, and row position update
|
|
51
|
+
independently, preserving unaffected row DOM and avoiding repeated row rendering.
|
|
52
|
+
Do not enable `keyedRows` inside an enclosing `each()` row; render its default
|
|
53
|
+
markup so the outer row owns updates. HTML ids retain their normal unrestricted
|
|
54
|
+
character set in either mode; keyed list identities are encoded internally.
|
|
55
|
+
|
|
47
56
|
## Props
|
|
48
57
|
|
|
49
58
|
- `id` and `label` (required): the tree's identity and accessible name.
|
|
50
59
|
- `nodes` and `expanded` (required): the hierarchy and the ids of open nodes.
|
|
60
|
+
- `keyedRows`: opt into native keyed rows; default false. Requires immutable node identities and placement outside an enclosing `each()` row.
|
|
51
61
|
- `selected`: the chosen node's id. It is the tree's Tab stop; when it sits
|
|
52
62
|
inside a collapsed node, its nearest visible ancestor is.
|
|
53
63
|
- `action` and `toggleAction` (required): delegated actions for choosing a
|
package/docs/workbench.md
CHANGED
|
@@ -499,6 +499,22 @@ presents as one, mirroring `wireSidebar`'s compact overlay:
|
|
|
499
499
|
path, so matching the portal root keeps the panel open when the press starts
|
|
500
500
|
or ends anywhere inside the portal. Escape and Tab inside that portal remain
|
|
501
501
|
with its own keyboard handler. Other outside presses still close the panel.
|
|
502
|
+
- **Keep a focused panel:** by default a panel collapses when its overlay
|
|
503
|
+
breakpoint begins to apply. Set `keepFocusedOpen: true` on a panel in
|
|
504
|
+
`wireWorkbench` (an inspector or form panel) to keep it open as the overlay,
|
|
505
|
+
focus and all, when it holds focus at that moment. A narrowing window then
|
|
506
|
+
never takes away the field being edited. Without focus inside, it collapses
|
|
507
|
+
as any panel does.
|
|
508
|
+
- **Name the return from an overlay:** give a panel's `toolbar.toggle` an
|
|
509
|
+
`overlayLabel` naming the work area its closing returns to ("Preview"),
|
|
510
|
+
pass an app-owned `overlay` signal to the panel in `wireWorkbench`, and
|
|
511
|
+
render it as the panel's `overlaid` (`overlaid={overlay.value}`). The
|
|
512
|
+
wiring keeps the signal equal to whether the panel presents as an overlay,
|
|
513
|
+
through `presentation: "overlay"` or its breakpoint. While the panel is
|
|
514
|
+
open and overlaid, its toggle shows that text beside its icon, which then
|
|
515
|
+
names it. Inline, or collapsed in the work area's toolbar, it stays the
|
|
516
|
+
icon-only Show/Hide toggle. Use it where the overlay is a focused surface
|
|
517
|
+
covering the work area; it is still the panel's only collapse control.
|
|
502
518
|
- **Focus:** when a panel closes with focus inside it — whatever closed it,
|
|
503
519
|
including the app's own control inside the panel — focus returns to the
|
|
504
520
|
control that had it when the panel opened (typically its toggle; one inside
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// KF-SVM8Z6: a temporary profile alone still reaches Firefox's shared macOS
|
|
2
|
+
// app data. Keep automated runs out of the person's protected Firefox data.
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import process from 'node:process';
|
|
7
|
+
|
|
8
|
+
export function createFirefoxAppData({
|
|
9
|
+
platform = process.platform,
|
|
10
|
+
env = process.env,
|
|
11
|
+
} = {}) {
|
|
12
|
+
const environment = { ...env };
|
|
13
|
+
if (
|
|
14
|
+
platform !== 'darwin' ||
|
|
15
|
+
(environment.MOZ_APP_DATA && environment.MOZ_LOCAL_APP_DATA)
|
|
16
|
+
)
|
|
17
|
+
return { env: environment, dispose() {} };
|
|
18
|
+
|
|
19
|
+
const root = mkdtempSync(join(tmpdir(), 'kerf-firefox-app-data-'));
|
|
20
|
+
const dispose = () => {
|
|
21
|
+
process.removeListener('exit', dispose);
|
|
22
|
+
rmSync(root, { recursive: true, force: true });
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
environment.MOZ_APP_DATA = join(root, 'data');
|
|
26
|
+
environment.MOZ_LOCAL_APP_DATA = join(root, 'cache');
|
|
27
|
+
mkdirSync(environment.MOZ_APP_DATA);
|
|
28
|
+
mkdirSync(environment.MOZ_LOCAL_APP_DATA);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
dispose();
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
process.once('exit', dispose);
|
|
34
|
+
return { env: environment, dispose };
|
|
35
|
+
}
|
package/evaluator/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { dirname, relative, resolve } from 'node:path';
|
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
|
|
8
8
|
import { loadApplicationUiProfile } from '../ai/application-ui-profile.mjs';
|
|
9
|
+
import { createFirefoxAppData } from './firefox-app-data.mjs';
|
|
9
10
|
|
|
10
11
|
export const UI_EVALUATION_SCHEMA_VERSION = 1;
|
|
11
12
|
|
|
@@ -1034,14 +1035,21 @@ export async function evaluateUi({
|
|
|
1034
1035
|
if (!browserType)
|
|
1035
1036
|
throw new Error(`Unknown Playwright browser ${browserName}.`);
|
|
1036
1037
|
let browser;
|
|
1038
|
+
const appData = browserName === 'firefox' ? createFirefoxAppData() : null;
|
|
1037
1039
|
try {
|
|
1038
1040
|
try {
|
|
1039
|
-
const launch = browserType.launch(
|
|
1041
|
+
const launch = browserType.launch(
|
|
1042
|
+
appData ? { env: appData.env } : {},
|
|
1043
|
+
);
|
|
1040
1044
|
void launch.then(
|
|
1041
1045
|
(candidate) => {
|
|
1042
|
-
if (signal?.aborted)
|
|
1046
|
+
if (signal?.aborted)
|
|
1047
|
+
void candidate.close().then(
|
|
1048
|
+
() => appData?.dispose(),
|
|
1049
|
+
() => appData?.dispose(),
|
|
1050
|
+
);
|
|
1043
1051
|
},
|
|
1044
|
-
() =>
|
|
1052
|
+
() => appData?.dispose(),
|
|
1045
1053
|
);
|
|
1046
1054
|
browser = await abortable(launch, signal);
|
|
1047
1055
|
activeBrowser = browser;
|
|
@@ -1149,8 +1157,14 @@ export async function evaluateUi({
|
|
|
1149
1157
|
});
|
|
1150
1158
|
}
|
|
1151
1159
|
} finally {
|
|
1152
|
-
|
|
1153
|
-
|
|
1160
|
+
try {
|
|
1161
|
+
await browser?.close();
|
|
1162
|
+
} finally {
|
|
1163
|
+
// Cancellation may win while launch is pending. Its settlement
|
|
1164
|
+
// handler closes that late browser before removing its app data.
|
|
1165
|
+
if (browser || !signal?.aborted) appData?.dispose();
|
|
1166
|
+
activeBrowser = undefined;
|
|
1167
|
+
}
|
|
1154
1168
|
}
|
|
1155
1169
|
}
|
|
1156
1170
|
} catch (error) {
|
package/llms.txt
CHANGED
|
@@ -371,6 +371,10 @@ headingLevel`, `SearchField clearIcon`, `ContentItem frame="framed"` for a
|
|
|
371
371
|
tokens tune section density. A semantic `count` requires `countLabel` and
|
|
372
372
|
excludes other indicators; `badge` and `status` may render together, and
|
|
373
373
|
either may be explicitly `undefined` in conditional app state.
|
|
374
|
+
A `toggle` header whose section has its own commands takes one trailing
|
|
375
|
+
overflow button (`overflowAction`, `overflowLabel`, `overflowIcon`,
|
|
376
|
+
optional `overflowDisabled`/`overflowTriggerAttributes`): its own focus
|
|
377
|
+
stop outside the disclosure button, which never toggles the section.
|
|
374
378
|
For a filled command list, scope `--kui-list-item-background`,
|
|
375
379
|
`--kui-list-item-color`, `--kui-list-item-border`,
|
|
376
380
|
`--kui-list-item-hover-background`, `--kui-list-item-hover-border`,
|
|
@@ -700,7 +704,8 @@ headingLevel`, `SearchField clearIcon`, `ContentItem frame="framed"` for a
|
|
|
700
704
|
(mark a preferred new-view target with `data-nav-focus`), `wireTabBars` the
|
|
701
705
|
overflow autoscroll, drag preview,
|
|
702
706
|
replacement focus after controlled automatic tab activation, and the
|
|
703
|
-
`onFitChange` tab-fit report (overflow
|
|
707
|
+
`onFitChange` tab-fit report (overflow, zone widths, and the room beside an
|
|
708
|
+
adjacent strip) an app reads instead of
|
|
704
709
|
measuring TabBar's parts,
|
|
705
710
|
`wireResizableRegions` the live drag preview, `wireScrollDividers` the
|
|
706
711
|
scroll-state attributes from which a `Pane` draws its chrome dividers and a
|
|
@@ -841,6 +846,9 @@ headingLevel`, `SearchField clearIcon`, `ContentItem frame="framed"` for a
|
|
|
841
846
|
recovery button, set `semanticRole="group"` and `ariaLabel`; the root is not
|
|
842
847
|
a Tab stop and only the button activates. Set `draggable` on an option row or
|
|
843
848
|
card for a native drag source on that same selection root.
|
|
849
|
+
A `ListHeader` above the rows in their container takes
|
|
850
|
+
`leadingEdge="summary-row"`: it starts its label on their leading-content
|
|
851
|
+
edge and compacts with them; never mirror their inset in app CSS.
|
|
844
852
|
- **Group settings rows in `FramedList`.** For rows of arbitrary content in
|
|
845
853
|
one rounded frame with dividers between them (settings, account cards,
|
|
846
854
|
shortcut lists), compose `FramedListRow`s; `ValueTable` is the same frame for
|
|
@@ -883,7 +891,9 @@ headingLevel`, `SearchField clearIcon`, `ContentItem frame="framed"` for a
|
|
|
883
891
|
`wireCheckboxes(root)` from `@kerfjs/ui/wire-checkboxes`),
|
|
884
892
|
`@kerfjs/ui/checkbox-group` (`label`, `name`, `choices`, an array `value`;
|
|
885
893
|
a labeled set laid out like RadioGroup), `@kerfjs/ui/radio-group` (`label`,
|
|
886
|
-
`name`, `choices`, `value`; one Tab stop, arrow keys
|
|
894
|
+
`name`, `choices`, `value`; one Tab stop, arrow keys;
|
|
895
|
+
`presentation="tiles"` with a decorative `preview` per choice draws framed
|
|
896
|
+
preview tiles, as for a Theme picker), and
|
|
887
897
|
`@kerfjs/ui/switch` (`role="switch"`, only for a setting that applies
|
|
888
898
|
immediately) draw Kerf boxes over native inputs with hint and error text.
|
|
889
899
|
Stack standalone Checkboxes in a `List gap="xs"`: 8px apart, the same 28px
|
|
@@ -958,7 +968,7 @@ created, input }`. Never use a hand-styled `<input list>` + `<datalist>`.
|
|
|
958
968
|
(`@kerfjs/ui/column-explorer`): a macOS-style column view over TreeList's
|
|
959
969
|
nodes in a ColumnTrack. Pass `nodes`, `path`, and `action`, set
|
|
960
970
|
`path = treeListPath(nodes, id)` when a row is chosen, and call
|
|
961
|
-
`wireColumnExplorer(root)`; `layout="paged"` on a phone, `preview` for a leaf.
|
|
971
|
+
`wireColumnExplorer(root)`; `layout="paged"` on a phone, `preview` for a leaf, and `rootHeading="Project"` for quiet parent names that move with each column. `inset="none"` removes track edge clearance; compose it with `PinnablePopoverSurface bodyInset="none"` for edge-to-edge columns.
|
|
962
972
|
- **Page one panel region between presentations with `PagedView`**
|
|
963
973
|
(`@kerfjs/ui/paged-view`): full-size swipeable pages with page dots floating
|
|
964
974
|
at the bottom. Pass `id`, `label`, `pages` (`{ id, label, content }`), and the
|
|
@@ -1216,8 +1226,14 @@ Key conditional `StateBanner` siblings with `rootAttributes={{ "data-key": "…"
|
|
|
1216
1226
|
|
|
1217
1227
|
Key sibling `DialogSurface`s that render conditionally with `rootAttributes={{ "data-key": "…" }}` so a re-render morphs each dialog into itself; never wrap one in a keyed app `div`. Modal `DialogSurface` bounds use typed `viewportGutter` and `maxHeight` (`CssLength` or `"viewport"`); explicit caps stay within the dynamic viewport minus both gutters. Omitted props keep the default caps (20px clear of each edge, 80% of the viewport height at 420px wide or narrower). Application render state chooses responsive values, and preview layout remains application-owned. `height` sets a definite bounded modal size and `bodyLayout="fill"` lets one child fill the body; `bodyLayout="fill-last"` keeps leading rows at their height above one filling last child, and `footerPresentation="floating"` (with a typed `footerOffset`) floats a chat composer over the body while the body reserves its measured height; give the transcript `scrollClearance="block-end"` (a `scrollable` `List` or a `Pane`) to let it scroll beneath the composer, with the last message still resting above it, through the published `--kui-scroll-clearance-block-end` context (overlaying chrome publishes `--kui-scroll-clearance-block-start` / `-end`; one scroller per covered edge opts in; a composed Pane opts in through `PaneConfig.scrollClearance` on a Workbench `mainPane` or panel `pane`, a `CollapsiblePanel` `pane`, or a `NavStack` view's `pane`). `headerPresentation="floating"` lays the title bar over the body on the translucent `--kui-chrome-material-raised` (opaque under reduced transparency, increased contrast, and forced colors); the register measures it and the body reserves it, and a `fill` body's only child with `scrollClearance="both"` scrolls beneath both the title bar and a floating composer through the published `--kui-scroll-clearance-block-start`. `presentation="bottom-sheet"` attaches the dialog to the bottom edge with square bottom corners, safe-area and virtual-keyboard clearance behind the panel, and a slide in/out (`enterMotion` / `exitMotion`); `resizable` adds a top grabber separator bounded by `minHeight` and `maxHeight`. `PopoverDialogSurface` is the non-modal, light-dismiss counterpart on the native Popover API, with the same size props and an `embedded` in-flow presentation; `describedBy` sets its `aria-describedby` (usually a title `ToolbarText`'s `descriptionId`).
|
|
1218
1228
|
Render a non-modal dialog as `PopoverDialogSurface`; `dismiss="manual"` keeps a request open until it is answered, and `anchorName` docks it to an app region named with the same CSS `anchor-name`.
|
|
1219
|
-
Render a panel the person can pin and move (a library, a palette) as `PinnablePopoverSurface` and call `wirePinnablePopover(surface, { pinned, placement, onChange })`: transient below its `popoverTarget` control with light dismiss; pinned (its Pin toggle or `pinPopover`, read with `isPopoverPinned`) it stays open, drags by its title, moves with the arrow keys, resizes, and stays in the viewport gutter; the app stores what `onChange` reports. `resizeFromBottom` enables pointer/keyboard resizing in either state without pinning; saved dimensions survive reopening and unpinning.
|
|
1229
|
+
Render a panel the person can pin and move (a library, a palette) as `PinnablePopoverSurface` and call `wirePinnablePopover(surface, { pinned, placement, onChange })`: transient below its `popoverTarget` control with light dismiss; pinned (its Pin toggle or `pinPopover`, read with `isPopoverPinned`) it stays open, drags by its title, moves with the arrow keys, resizes, and stays in the viewport gutter; the app stores what `onChange` reports. `resizeFromBottom` enables pointer/keyboard resizing in either state without pinning; saved dimensions survive reopening and unpinning. Typed `minHeight` protects fixed controls and content while shrinking, capped by `maxHeight` and the viewport; resizable panels default to 160px and Library uses 320px. `pinnable={false}` makes it a persistent floating panel (always pinned, no Pin toggle, no light dismiss) and `closable={false}` drops its Close X so an app control owns its visibility (Escape closes it only with `closeOnEscape: true`).
|
|
1220
1230
|
|
|
1221
1231
|
Render a modal dialog as `DialogSurface` itself, a native `<dialog>` (`alert` renders `role="alertdialog"` for a destructive confirmation; pair it with `describedBy` on the message): `label` (or `labelledBy` with a `heading`, such as an xl `ToolbarText` with a description) names it, `describedBy` (the heading ToolbarText's `descriptionId`, or app-owned summary copy) describes it as `aria-describedby`, `children` is its body, `footer` holds its buttons, and `headerActions` sit before its close button (`withoutHeader` drops the header for content that owns its heading and close control). Open it with `openDialog(dialog)` and close it with `closeDialog(dialog)` from `@kerfjs/ui/surface-scaffold`; never toggle its `open` attribute. The close button, any `data-dialog-close` element inside (a Cancel button), Escape, and, with `lightDismiss`, a backdrop press dispatch a cancelable `kui-request-close` (`detail.source`: `close-button`, `escape`, or `backdrop`); cancel it to keep the dialog open (the panel pulses). The native `close` event fires once it closes. `openDialog` installs the listeners and, while the dialog is open, measures its floating header/footer, follows a bottom sheet's keyboard and grabber, and keeps that state across re-renders; import `@kerfjs/ui/surface-scaffold/register` only when a dialog may open some other way. Do not write `wa-dialog` inside a `DialogSurface`.
|
|
1222
1232
|
|
|
1223
1233
|
Toolbar visibility measurement probes and invisible state children are helper-owned and survive Kerf rerenders through `data-morph-preserve`. Actual CSS visibility stays stable while rendering removes transient parent markers, preventing geometry-driven render feedback and repeated probe recreation. Toolbar replacement, explicit internal-node removal and disposal retain their existing behavior.
|
|
1234
|
+
|
|
1235
|
+
Parameter authoring (KF-26P9FT, KF-B8YSHV, KF-MB5FFZ, KF-AFW3ZA) uses compact name/type rows and a DialogSurface/NavStack with TypeScript text entry, project completion and formatting. `ui/view/project-types.mjs` runs the owning project’s Node-only TypeScript language service; persisted expression/import metadata accompanies a structural navigation projection. Editor export and CLI generation check actual generated bindings/defaults. `validateView` alone reports KUI-H002 for deferred project checking. Legacy descriptors remain supported.
|
|
1236
|
+
|
|
1237
|
+
Generated views share the browser-only `kuiComponent` helper at `@kerfjs/ui/view-runtime` (KF-4DR6XR). Preserve its curried component-call boundary: it retains generic prop inference and the SafeHtml contract while keeping Rollup effect analysis linear for large catalog trees. TS/JS output imports it only for actual component calls; declarations-only and component-free output omit it. The helper has no generator/compiler dependency. Tests: `ui/tests/unit/view-runtime.test.ts`, `ui/tests/unit/view-generate.test.ts`, consumer type contracts and browser bundle boundaries.
|
|
1238
|
+
|
|
1239
|
+
Library previews (KF-RQJ15M) expose `defineLibraryPreviews`, component-keyed samples/static renderers/icon fallbacks, and catalog/editor `libraryPreviews` overrides. Composition catalogs carry literal JSON samples plus an optional `libraryPreviewModule`; the Vite host imports package modules and a local override separately. Built-in schematics/icons use the same registrations. `ui/src/editor/library-previews.ts`, `library-preview-defaults.ts` and `library-thumbnail-renderer.ts` own registration/isolated rendering; palette thumbnail wiring owns inert shadow fitting, asset/content resize refits and RAF/observer cleanup. Insertion/defaults/canvas/production rendering remain separate. Requirements: `docs/28-library-previews.md`; downstream example: `editor/fixtures/app/`; tests: Library preview/lifecycle units, typed+packed consumers, Vite host units and `editor/tests/browser/library-previews.spec.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerfjs/ui",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.130",
|
|
4
4
|
"description": "Accessible, composable UI primitives for kerf applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"types": "./catalog-projection.d.mts",
|
|
60
60
|
"import": "./catalog-projection.mjs"
|
|
61
61
|
},
|
|
62
|
+
"./view-runtime": {
|
|
63
|
+
"types": "./dist/view-runtime.d.ts",
|
|
64
|
+
"import": "./dist/view-runtime.js"
|
|
65
|
+
},
|
|
62
66
|
"./view": {
|
|
63
67
|
"types": "./view/index.d.mts",
|
|
64
68
|
"import": "./view/index.mjs"
|
|
@@ -882,5 +886,8 @@
|
|
|
882
886
|
"typescript7": "npm:typescript@^7.0.2",
|
|
883
887
|
"vite": "^7.3.7",
|
|
884
888
|
"vitest": "^4.1.12"
|
|
889
|
+
},
|
|
890
|
+
"overrides": {
|
|
891
|
+
"minimatch@>=7 <11.0.1": "^11.0.5"
|
|
885
892
|
}
|
|
886
893
|
}
|
|
@@ -54,6 +54,9 @@ export interface PropDescriptor {
|
|
|
54
54
|
cssValue?: { grammar: string; helpers?: string[]; rawPolicy?: string };
|
|
55
55
|
control?: string;
|
|
56
56
|
group?: string;
|
|
57
|
+
/** The task-facing name the Inspector shows (Button text). */
|
|
58
|
+
label?: string;
|
|
59
|
+
subgroup?: string;
|
|
57
60
|
order?: number;
|
|
58
61
|
}
|
|
59
62
|
|
package/view/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// formatter — never part of a consumer's build.
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
8
8
|
import process from 'node:process';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
|
|
@@ -19,6 +19,8 @@ import { contractOf, diffContracts } from './contract.mjs';
|
|
|
19
19
|
import { generateView, readViewHeader, viewModulePath } from './generate.mjs';
|
|
20
20
|
import { createViewCatalog } from './catalog.mjs';
|
|
21
21
|
import { validateView } from './validate.mjs';
|
|
22
|
+
import { createProjectTypeService, projectTypeRoot } from './project-types.mjs';
|
|
23
|
+
import { hasTypeExpressions } from './type-expression.mjs';
|
|
22
24
|
|
|
23
25
|
const USAGE = `Usage: kerf-ui-view <command> <document.kui.json...> [options]
|
|
24
26
|
|
|
@@ -181,10 +183,10 @@ export function run(argv) {
|
|
|
181
183
|
try {
|
|
182
184
|
for (const documentPath of documents) {
|
|
183
185
|
const catalog = loadCatalog(options, documentPath);
|
|
184
|
-
|
|
186
|
+
let document = readJson(documentPath);
|
|
185
187
|
const resolveView = viewResolver(documentPath);
|
|
186
|
-
|
|
187
|
-
if (!validation.valid) {
|
|
188
|
+
let validation = validateView(document, catalog, { resolveView });
|
|
189
|
+
if (!validation.valid && !hasTypeExpressions(document)) {
|
|
188
190
|
failed = true;
|
|
189
191
|
for (const item of validation.diagnostics) {
|
|
190
192
|
lines.push(
|
|
@@ -193,14 +195,43 @@ export function run(argv) {
|
|
|
193
195
|
}
|
|
194
196
|
continue;
|
|
195
197
|
}
|
|
198
|
+
let typeSource;
|
|
199
|
+
if (hasTypeExpressions(document)) {
|
|
200
|
+
const root = projectTypeRoot(documentPath);
|
|
201
|
+
typeSource = relative(root, resolve(documentPath))
|
|
202
|
+
.split('\\')
|
|
203
|
+
.join('/');
|
|
204
|
+
const service = createProjectTypeService(root);
|
|
205
|
+
let checked;
|
|
206
|
+
try {
|
|
207
|
+
checked = service.validateDocument(document, catalog, typeSource, {
|
|
208
|
+
resolveView,
|
|
209
|
+
});
|
|
210
|
+
} finally {
|
|
211
|
+
service.dispose();
|
|
212
|
+
}
|
|
213
|
+
if (checked.diagnostics.length) {
|
|
214
|
+
failed = true;
|
|
215
|
+
for (const item of checked.diagnostics)
|
|
216
|
+
lines.push(
|
|
217
|
+
`${documentPath}: ${item.code} ${item.path}: ${item.message}`,
|
|
218
|
+
);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
document = checked.document;
|
|
222
|
+
validation = validateView(document, catalog, { resolveView });
|
|
223
|
+
}
|
|
196
224
|
// Hints are advice: printed, never a failure.
|
|
197
|
-
for (const item of validation.hints
|
|
225
|
+
for (const item of validation.hints.filter(
|
|
226
|
+
(item) => item.code !== 'KUI-H002',
|
|
227
|
+
))
|
|
198
228
|
lines.push(
|
|
199
229
|
`${documentPath}: hint ${item.code} ${item.path}: ${item.message}`,
|
|
200
230
|
);
|
|
201
231
|
const modulePath = viewModulePath(documentPath, options.target);
|
|
202
232
|
const generated = generateView(document, catalog, {
|
|
203
233
|
source: basename(documentPath),
|
|
234
|
+
typeSource,
|
|
204
235
|
resolveView,
|
|
205
236
|
target: options.target,
|
|
206
237
|
declarationsOnly: options.declarationsOnly,
|
package/view/contract.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// by the generator and the runtime interpreter so both compute the same digest.
|
|
5
5
|
import { childKind } from './child-kind.mjs';
|
|
6
6
|
import { eachTemplates, validateView } from './validate.mjs';
|
|
7
|
+
import { typeExpressionText } from './type-expression.mjs';
|
|
7
8
|
|
|
8
9
|
const MASK_64 = 0xffffffffffffffffn;
|
|
9
10
|
const FNV_OFFSET = 0xcbf29ce484222325n;
|
|
@@ -41,6 +42,8 @@ export function viewDigest(text) {
|
|
|
41
42
|
|
|
42
43
|
/** The TypeScript spelling of a document param or slot-input type. */
|
|
43
44
|
export function typeText(type) {
|
|
45
|
+
if (type?.typescript)
|
|
46
|
+
return typeExpressionText(type, '__kerf_contract__.kui.json');
|
|
44
47
|
switch (type?.kind) {
|
|
45
48
|
case 'string':
|
|
46
49
|
case 'number':
|
package/view/generate.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { childKind } from './child-kind.mjs';
|
|
22
22
|
import { parseCssCall } from './css-grammar.mjs';
|
|
23
23
|
import { composedViewPath, eachNodes } from './validate.mjs';
|
|
24
|
+
import { typeExpressionText } from './type-expression.mjs';
|
|
24
25
|
|
|
25
26
|
export const GENERATOR_VERSION = 1;
|
|
26
27
|
const HEADER_LINES = 3;
|
|
@@ -686,6 +687,11 @@ export function generateView(document, catalog, options = {}) {
|
|
|
686
687
|
// A prop-typed input is that component prop's own type, read from the
|
|
687
688
|
// component function so the app's value is checked against it (KF-H3CB2P).
|
|
688
689
|
const types = typesBlock(name, contract, (input) => {
|
|
690
|
+
if (input.shape.typescript)
|
|
691
|
+
return typeExpressionText(
|
|
692
|
+
input.shape,
|
|
693
|
+
options.typeSource ?? input.shape.typescript.source,
|
|
694
|
+
);
|
|
689
695
|
if (input.shape.kind !== 'prop') return input.type;
|
|
690
696
|
const owner = catalog.components.get(input.shape.component).component;
|
|
691
697
|
imports.type(
|
|
@@ -695,11 +701,8 @@ export function generateView(document, catalog, options = {}) {
|
|
|
695
701
|
return `Parameters<typeof ${owner.export}>[0][${literal(input.shape.prop)}]`;
|
|
696
702
|
});
|
|
697
703
|
const contractLine = `export const ${camel}Contract = ${literal(digest)};`;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
? 'function kuiComponent<P>(component: (props: P) => SafeHtml): (props: P) => SafeHtml {\n return (props) => component(props);\n}'
|
|
701
|
-
: 'function kuiComponent(component) {\n return (props) => component(props);\n}'
|
|
702
|
-
: undefined;
|
|
704
|
+
if (usesKerfComponent)
|
|
705
|
+
imports.value('@kerfjs/ui/view-runtime', 'kuiComponent');
|
|
703
706
|
|
|
704
707
|
const assemble = (body) =>
|
|
705
708
|
`${header(sourceName, contract, sourceDigest, body)}\n${body}`;
|
|
@@ -708,7 +711,6 @@ export function generateView(document, catalog, options = {}) {
|
|
|
708
711
|
imports.render(true),
|
|
709
712
|
types,
|
|
710
713
|
contractLine,
|
|
711
|
-
componentHelper,
|
|
712
714
|
functionsBlock(name, contract, rootExpr, true),
|
|
713
715
|
]
|
|
714
716
|
.filter(Boolean)
|
|
@@ -718,7 +720,6 @@ export function generateView(document, catalog, options = {}) {
|
|
|
718
720
|
const code = [
|
|
719
721
|
imports.render(false),
|
|
720
722
|
contractLine,
|
|
721
|
-
componentHelper,
|
|
722
723
|
functionsBlock(name, contract, rootExpr, false),
|
|
723
724
|
]
|
|
724
725
|
.filter(Boolean)
|
package/view/index.d.mts
CHANGED
|
@@ -18,6 +18,18 @@ export interface ViewType {
|
|
|
18
18
|
component?: string;
|
|
19
19
|
/** `kind: 'prop'`: that component's prop. */
|
|
20
20
|
prop?: string;
|
|
21
|
+
/** Project-checked expression; the other fields are a navigation projection. */
|
|
22
|
+
typescript?: {
|
|
23
|
+
readonly text: string;
|
|
24
|
+
/** Project-relative source used to resolve inline import() types. */
|
|
25
|
+
readonly source: string;
|
|
26
|
+
/** Compiler-identified module literal tokens, including their quotes. */
|
|
27
|
+
readonly references: readonly {
|
|
28
|
+
start: number;
|
|
29
|
+
length: number;
|
|
30
|
+
module: string;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
/** A value in a node's `props`, a `$each` source, or a `$slot` input. */
|
|
@@ -382,6 +394,8 @@ export function generateView(
|
|
|
382
394
|
options?: {
|
|
383
395
|
/** The document file name recorded in the header. */
|
|
384
396
|
source?: string;
|
|
397
|
+
/** Project-relative output source for rebasing TypeScript type imports. */
|
|
398
|
+
typeSource?: string;
|
|
385
399
|
resolveView?: (src: string, path: string) => unknown;
|
|
386
400
|
target?: 'ts' | 'js';
|
|
387
401
|
declarationsOnly?: boolean;
|