@kerfjs/ui 5.0.0-beta.50 → 5.0.0-beta.51
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/README.md +29 -5
- package/ai/compile-time-contracts-v1.json +5 -2
- package/ai/component-catalog-v2.d.ts +19 -1
- package/ai/component-catalog-v2.json +842 -127
- package/ai/component-catalog-v2.schema.json +33 -1
- package/ai/component-catalog.json +603 -126
- package/ai/component-catalog.schema.json +21 -1
- package/ai/public-api-signatures-v1.md +201 -29
- package/ai/skill.md +12 -9
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/index.mjs +105 -35
- package/dist/app-tab.js +1 -1
- package/dist/catalog-resources.d.ts +1 -1
- package/dist/catalog.d.ts +28 -5
- package/dist/catalog.js +66 -25
- package/dist/catalog.js.map +1 -1
- package/dist/{chunk-COUPLRZG.js → chunk-5FZZMIMD.js} +3 -3
- package/dist/{chunk-COUPLRZG.js.map → chunk-5FZZMIMD.js.map} +1 -1
- package/dist/{chunk-DARTMI5Z.js → chunk-5PMGQDG7.js} +2 -2
- package/dist/{chunk-DARTMI5Z.js.map → chunk-5PMGQDG7.js.map} +1 -1
- package/dist/{chunk-V6RZWDII.js → chunk-7GUQYHKA.js} +19 -2
- package/dist/chunk-7GUQYHKA.js.map +1 -0
- package/dist/{chunk-ZNZ2JDBW.js → chunk-7IUSV4XG.js} +1 -1
- package/dist/chunk-7IUSV4XG.js.map +1 -0
- package/dist/{chunk-ELRMBQEC.js → chunk-AEPXGCNF.js} +17 -2
- package/dist/chunk-AEPXGCNF.js.map +1 -0
- package/dist/{chunk-5CE64WGC.js → chunk-D547PH4L.js} +3 -3
- package/dist/{chunk-5CE64WGC.js.map → chunk-D547PH4L.js.map} +1 -1
- package/dist/{chunk-S6ZTTTV7.js → chunk-DVZCMMB3.js} +3 -3
- package/dist/{chunk-S6ZTTTV7.js.map → chunk-DVZCMMB3.js.map} +1 -1
- package/dist/chunk-EKYZCRCX.js +256 -0
- package/dist/chunk-EKYZCRCX.js.map +1 -0
- package/dist/{chunk-3V75EQIP.js → chunk-JM53SMVF.js} +3 -3
- package/dist/{chunk-3V75EQIP.js.map → chunk-JM53SMVF.js.map} +1 -1
- package/dist/{chunk-2WMSE4MK.js → chunk-JMGKM7RK.js} +2 -2
- package/dist/{chunk-2WMSE4MK.js.map → chunk-JMGKM7RK.js.map} +1 -1
- package/dist/{chunk-2YOUUEWR.js → chunk-KX7DP2GO.js} +4 -4
- package/dist/{chunk-2YOUUEWR.js.map → chunk-KX7DP2GO.js.map} +1 -1
- package/dist/{chunk-OL4TC3U2.js → chunk-MO56ZZLG.js} +6 -2
- package/dist/chunk-MO56ZZLG.js.map +1 -0
- package/dist/{chunk-OQI7RCRP.js → chunk-MTM43SJO.js} +7 -1
- package/dist/chunk-MTM43SJO.js.map +1 -0
- package/dist/{chunk-ZSYLBVWG.js → chunk-NMGTHYW3.js} +3 -3
- package/dist/{chunk-ZSYLBVWG.js.map → chunk-NMGTHYW3.js.map} +1 -1
- package/dist/{chunk-AQSKJ6U6.js → chunk-NZXWU4R5.js} +21 -2
- package/dist/chunk-NZXWU4R5.js.map +1 -0
- package/dist/{chunk-DJKWFYAA.js → chunk-O3RCCSQJ.js} +3 -3
- package/dist/{chunk-DJKWFYAA.js.map → chunk-O3RCCSQJ.js.map} +1 -1
- package/dist/{chunk-UMGY5JSP.js → chunk-S4QRSBFI.js} +22 -2
- package/dist/chunk-S4QRSBFI.js.map +1 -0
- package/dist/{chunk-KKNK3JUT.js → chunk-UBH743HV.js} +5 -5
- package/dist/chunk-UBH743HV.js.map +1 -0
- package/dist/{chunk-54HM36IQ.js → chunk-ULCDZTWL.js} +2 -2
- package/dist/{chunk-54HM36IQ.js.map → chunk-ULCDZTWL.js.map} +1 -1
- package/dist/{chunk-SIU2AC5W.js → chunk-UPZ6EEJN.js} +3 -3
- package/dist/{chunk-SIU2AC5W.js.map → chunk-UPZ6EEJN.js.map} +1 -1
- package/dist/collapsible-panel.d.ts +1 -1
- package/dist/collapsible-panel.js.map +1 -1
- package/dist/css-values.d.ts +39 -3
- package/dist/css-values.js +1 -1
- package/dist/grid.d.ts +15 -1
- package/dist/grid.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -19
- package/dist/list-action-row.js +1 -1
- package/dist/list-header.js +1 -1
- package/dist/list-item.js +1 -1
- package/dist/list.d.ts +21 -2
- package/dist/list.js +2 -1
- package/dist/nav-stack.js +1 -1
- package/dist/pane.d.ts +17 -2
- package/dist/pane.js +1 -1
- package/dist/row.d.ts +19 -1
- package/dist/row.js +2 -1
- package/dist/segmented-control.js +1 -1
- package/dist/select.d.ts +13 -3
- package/dist/select.js +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/spacer.js +1 -1
- package/dist/split-view.js +1 -1
- package/dist/state-banner.js +1 -1
- package/dist/styles/catalog/components/catalog-example-stack.css +4 -1
- package/dist/styles/catalog/components/catalog-example.css +145 -0
- package/dist/styles/collapsible-panel.css +132 -4
- package/dist/styles/document.css +23 -0
- package/dist/styles/foundation.css +21 -7
- package/dist/styles/grid.css +10 -0
- package/dist/styles/list-header.css +45 -0
- package/dist/styles/list-inset-control.css +8 -1
- package/dist/styles/list-item.css +6 -0
- package/dist/styles/list.css +11 -0
- package/dist/styles/nav-stack.css +89 -2
- package/dist/styles/pane.css +86 -1
- package/dist/styles/resizable-region.css +93 -5
- package/dist/styles/row.css +10 -0
- package/dist/styles/select.css +39 -4
- package/dist/styles/split-view.css +107 -1
- package/dist/styles/tab-scaffold.css +64 -1
- package/dist/styles/text.css +6 -0
- package/dist/styles/toolbar-control-group.css +90 -11
- package/dist/styles/toolbar-text.css +4 -1
- package/dist/styles/toolbar.css +130 -38
- package/dist/styles/webawesome.css +48 -2
- package/dist/styles/workbench.css +136 -4
- package/dist/text.d.ts +4 -3
- package/dist/text.js +1 -1
- package/dist/toolbar-text.js +1 -1
- package/dist/toolbar.d.ts +24 -3
- package/dist/toolbar.js +1 -1
- package/dist/{types-CzgSrFXP.d.ts → types-CEsieBZi.d.ts} +6 -1
- package/dist/value-table.js +1 -1
- package/dist/wire-resizable-regions.js +1 -1
- package/dist/wire-sidebar.d.ts +18 -3
- package/dist/wire-sidebar.js +95 -14
- package/dist/wire-sidebar.js.map +1 -1
- package/docs/accessibility.md +45 -8
- package/docs/app-layouts.md +73 -0
- package/docs/catalog.md +23 -2
- package/docs/collapsible-panel.md +81 -8
- package/docs/component-contract.md +28 -9
- package/docs/component-integration.md +9 -4
- package/docs/component-selection.md +25 -6
- package/docs/design/templates/list/stack-dark.svg +1 -1
- package/docs/design/templates/list/stack.svg +1 -1
- package/docs/design/templates/list-dark.svg +1 -1
- package/docs/design/templates/list-header/action-dark.svg +1 -1
- package/docs/design/templates/list-header/action.svg +1 -1
- package/docs/design/templates/list-header/count-dark.svg +1 -1
- package/docs/design/templates/list-header/count.svg +1 -1
- package/docs/design/templates/list-header/inline-action-dark.svg +1 -1
- package/docs/design/templates/list-header/inline-action.svg +1 -1
- package/docs/design/templates/list-header/toggle-expanded-dark.svg +1 -1
- package/docs/design/templates/list-header/toggle-expanded.svg +1 -1
- package/docs/design/templates/list-header-dark.svg +1 -1
- package/docs/design/templates/list-header.svg +1 -1
- package/docs/design/templates/list.svg +1 -1
- package/docs/design/templates/state-banner/info-badge-dark.svg +1 -1
- package/docs/design/templates/state-banner/info-badge.svg +1 -1
- package/docs/design/templates/state-banner-dark.svg +1 -1
- package/docs/design/templates/state-banner.svg +1 -1
- package/docs/design/templates/toolbar/title-and-actions-dark.svg +1 -1
- package/docs/design/templates/toolbar/title-and-actions.svg +1 -1
- package/docs/design/templates/toolbar-control-group/with-text-dark.svg +1 -1
- package/docs/design/templates/toolbar-control-group/with-text.svg +1 -1
- package/docs/design/templates/toolbar-control-group-dark.svg +1 -1
- package/docs/design/templates/toolbar-control-group.svg +1 -1
- package/docs/design/templates/toolbar-dark.svg +1 -1
- package/docs/design/templates/toolbar-text/default-dark.svg +1 -1
- package/docs/design/templates/toolbar-text/default.svg +1 -1
- package/docs/design/templates/toolbar-text/large-dark.svg +1 -1
- package/docs/design/templates/toolbar-text/large.svg +1 -1
- package/docs/design/templates/toolbar-text/small-dark.svg +1 -1
- package/docs/design/templates/toolbar-text/small.svg +1 -1
- package/docs/design/templates/toolbar-text-dark.svg +1 -1
- package/docs/design/templates/toolbar-text.svg +1 -1
- package/docs/design/templates/toolbar.svg +1 -1
- package/docs/document-baseline.md +31 -0
- package/docs/layout.md +86 -21
- package/docs/nav-stack.md +8 -0
- package/docs/recipes.md +78 -43
- package/docs/split-view.md +8 -0
- package/docs/tab-scaffold.md +4 -2
- package/docs/type-contracts.md +21 -17
- package/docs/ui-analyzer.md +19 -0
- package/docs/ui-evaluator.md +17 -0
- package/docs/ux-demo.md +4 -4
- package/docs/webawesome-theme.md +20 -2
- package/docs/workbench.md +20 -1
- package/evaluator/index.mjs +73 -8
- package/llms.txt +32 -14
- package/package.json +4 -2
- package/ux-demo/recipes/app-shell.tsx +209 -178
- package/ux-demo/recipes/collapsible-sidebar.tsx +188 -159
- package/ux-demo/recipes/compact-toolbar.tsx +48 -35
- package/ux-demo/recipes/composer-form.tsx +85 -79
- package/ux-demo/recipes/list-detail-dialog.tsx +124 -142
- package/ux-demo/recipes/list-workspace-states.tsx +83 -83
- package/ux-demo/recipes/loaders.ts +5 -2
- package/ux-demo/recipes/loading-inspector.tsx +157 -160
- package/ux-demo/recipes/navigation-sidebar.tsx +111 -109
- package/ux-demo/recipes/navigation-stack.tsx +50 -49
- package/ux-demo/recipes/types.ts +14 -0
- package/ux-demo/recipes/workspace-header.tsx +73 -56
- package/dist/chunk-AQSKJ6U6.js.map +0 -1
- package/dist/chunk-ELRMBQEC.js.map +0 -1
- package/dist/chunk-J3EE6XWD.js +0 -115
- package/dist/chunk-J3EE6XWD.js.map +0 -1
- package/dist/chunk-KKNK3JUT.js.map +0 -1
- package/dist/chunk-OL4TC3U2.js.map +0 -1
- package/dist/chunk-OQI7RCRP.js.map +0 -1
- package/dist/chunk-UMGY5JSP.js.map +0 -1
- package/dist/chunk-V6RZWDII.js.map +0 -1
- package/dist/chunk-ZNZ2JDBW.js.map +0 -1
- package/ux-demo/recipes/app-shell.css +0 -87
- package/ux-demo/recipes/collapsible-sidebar.css +0 -83
- package/ux-demo/recipes/compact-toolbar.css +0 -35
- package/ux-demo/recipes/composer-form.css +0 -19
- package/ux-demo/recipes/list-detail-dialog.css +0 -42
- package/ux-demo/recipes/list-workspace-states.css +0 -30
- package/ux-demo/recipes/loading-inspector.css +0 -7
- package/ux-demo/recipes/navigation-sidebar.css +0 -12
- package/ux-demo/recipes/navigation-stack.css +0 -12
- package/ux-demo/recipes/recipe-root.css +0 -67
- package/ux-demo/recipes/recipe-root.tsx +0 -87
- package/ux-demo/recipes/workspace-header.css +0 -7
package/dist/text.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as kerfjs from 'kerfjs';
|
|
|
2
2
|
import { KerfBaseAttrs } from 'kerfjs/jsx-runtime';
|
|
3
3
|
import { K as KerfUiContent } from './semantic-content-BbzjvSu9.js';
|
|
4
4
|
|
|
5
|
-
type TextVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p';
|
|
5
|
+
type TextVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span';
|
|
6
6
|
type TextTone = 'default' | 'quiet' | 'danger';
|
|
7
7
|
type TextSize = 'default' | 'compact';
|
|
8
8
|
type TextFont = 'default' | 'monospace';
|
|
9
9
|
type TextBorder = 'transparent' | 'none';
|
|
10
10
|
type TextContent = KerfUiContent | string | number | readonly TextContent[];
|
|
11
11
|
type TextProps = Omit<KerfBaseAttrs, 'children' | 'class' | 'className'> & {
|
|
12
|
-
/** Native heading or
|
|
12
|
+
/** Native heading, paragraph, or inline span element to render. Defaults to `p`. */
|
|
13
13
|
variant?: TextVariant;
|
|
14
14
|
/** Semantic foreground treatment. Defaults to the inherited foreground. */
|
|
15
15
|
tone?: TextTone;
|
|
@@ -24,7 +24,8 @@ type TextProps = Omit<KerfBaseAttrs, 'children' | 'class' | 'className'> & {
|
|
|
24
24
|
className?: string;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* Semantic heading or
|
|
27
|
+
* Semantic heading, paragraph, or inline text. Block variants use the standard
|
|
28
|
+
* content-item padding; `span` adds no box geometry.
|
|
28
29
|
* All ordinary native heading/paragraph attributes pass through to the element.
|
|
29
30
|
*/
|
|
30
31
|
declare function Text({ variant: Variant, tone, size, font, border, children, class: classValue, className, ...attributes }: TextProps): kerfjs.SafeHtml;
|
package/dist/text.js
CHANGED
package/dist/toolbar-text.js
CHANGED
package/dist/toolbar.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as kerfjs from 'kerfjs';
|
|
2
2
|
import { D as DividerSides } from './divider-sides-BzB6rphT.js';
|
|
3
|
+
import { PaneSeparatorSide } from './pane.js';
|
|
3
4
|
import { K as KerfUiContent } from './semantic-content-BbzjvSu9.js';
|
|
4
5
|
|
|
5
6
|
interface ToolbarProps {
|
|
@@ -11,14 +12,34 @@ interface ToolbarProps {
|
|
|
11
12
|
dividerSides?: DividerSides;
|
|
12
13
|
/** Horizontal treatment of the center zone. Defaults to centered content. */
|
|
13
14
|
centerAlign?: 'center' | 'stretch';
|
|
14
|
-
/**
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Component-owned responsive layout; applications choose the policy rather
|
|
17
|
+
* than restyling toolbar internals. Under every policy the trailing zone
|
|
18
|
+
* wraps its groups instead of clipping an action.
|
|
19
|
+
* - `none` keeps one row; the leading identity truncates first.
|
|
20
|
+
* - `stack` stacks the zones at `responsiveAt`, wrapping stacked control
|
|
21
|
+
* groups onto further rows.
|
|
22
|
+
* - `wrap` keeps one row while every zone fits at its natural width, and
|
|
23
|
+
* otherwise moves the trailing zone below a whole leading identity.
|
|
24
|
+
* - `center-priority` gives an expanded center control the full row.
|
|
25
|
+
*/
|
|
26
|
+
responsive?: 'none' | 'stack' | 'wrap' | 'center-priority';
|
|
16
27
|
/** Container width at which `responsive="stack"` activates. */
|
|
17
28
|
responsiveAt?: 'compact' | 'narrow';
|
|
29
|
+
/**
|
|
30
|
+
* Screen edges this toolbar claims for device safe-area compensation, for an
|
|
31
|
+
* app bar or bottom bar that sits directly at a screen edge rather than in a
|
|
32
|
+
* Pane header or footer. Each listed side pads by the inset its surrounding
|
|
33
|
+
* layout reports through `--kui-edge-inset-*`, or the full device inset when
|
|
34
|
+
* nothing routes that edge, while the toolbar's box and dividers paint
|
|
35
|
+
* through. Omitted, the toolbar pads only the inline edges an owner such as
|
|
36
|
+
* a Pane header hands it, and never a block edge.
|
|
37
|
+
*/
|
|
38
|
+
safeAreaEdges?: readonly PaneSeparatorSide[];
|
|
18
39
|
className?: string;
|
|
19
40
|
/** Native named-slot assignment when composed inside a web component. */
|
|
20
41
|
slot?: string;
|
|
21
42
|
}
|
|
22
|
-
declare function Toolbar({ leading, center, trailing, label, dividerSides, centerAlign, responsive, responsiveAt, className, slot, }: ToolbarProps): kerfjs.SafeHtml;
|
|
43
|
+
declare function Toolbar({ leading, center, trailing, label, dividerSides, centerAlign, responsive, responsiveAt, safeAreaEdges, className, slot, }: ToolbarProps): kerfjs.SafeHtml;
|
|
23
44
|
|
|
24
45
|
export { DividerSides, Toolbar, type ToolbarProps };
|
package/dist/toolbar.js
CHANGED
|
@@ -40,6 +40,9 @@ interface CatalogBrand {
|
|
|
40
40
|
/** Logo image URL (rendered decorative). Omit for a text-only brand. */
|
|
41
41
|
logoUrl?: string;
|
|
42
42
|
}
|
|
43
|
+
type CatalogStageRootAttributes = Readonly<Record<`data-${string}`, string | undefined> & {
|
|
44
|
+
'data-catalog-stage'?: never;
|
|
45
|
+
}>;
|
|
43
46
|
interface CatalogProps {
|
|
44
47
|
brand: CatalogBrand;
|
|
45
48
|
sections: readonly CatalogSection[];
|
|
@@ -52,6 +55,8 @@ interface CatalogProps {
|
|
|
52
55
|
sidebarFooter?: KerfUiContent;
|
|
53
56
|
status?: KerfUiContent;
|
|
54
57
|
geometryOverlay?: boolean;
|
|
58
|
+
/** Consumer-owned data attributes applied to the preview stage. */
|
|
59
|
+
stageRootAttributes?: CatalogStageRootAttributes;
|
|
55
60
|
selectAction?: string;
|
|
56
61
|
toggleSidebarAction?: string;
|
|
57
62
|
toggleThemeAction?: string;
|
|
@@ -61,4 +66,4 @@ interface CatalogProps {
|
|
|
61
66
|
slot?: string;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
export type { CatalogResource as C, CatalogProps as a, CatalogBrand as b, CatalogEntry as c, CatalogRelated as d, CatalogSecondaryGroup as e, CatalogSection as f };
|
|
69
|
+
export type { CatalogResource as C, CatalogProps as a, CatalogBrand as b, CatalogEntry as c, CatalogRelated as d, CatalogSecondaryGroup as e, CatalogSection as f, CatalogStageRootAttributes as g };
|
package/dist/value-table.js
CHANGED
package/dist/wire-sidebar.d.ts
CHANGED
|
@@ -14,9 +14,18 @@ interface WireSidebarPanel {
|
|
|
14
14
|
collapsed: Signal<boolean>;
|
|
15
15
|
/** `data-action` value the panel's toggle button(s) carry. */
|
|
16
16
|
toggleAction: string;
|
|
17
|
-
/** When set, the collapsed state is loaded from and saved to
|
|
18
|
-
* this key (a persistence hook), so the panel remembers
|
|
17
|
+
/** When set, the panel's inline collapsed state is loaded from and saved to
|
|
18
|
+
* `storage` under this key (a persistence hook), so the panel remembers the
|
|
19
|
+
* user's inline choice. A compact overlay's open/closed state is transient
|
|
20
|
+
* and is never persisted. */
|
|
19
21
|
storageKey?: string;
|
|
22
|
+
/** The panel's inline (non-compact) collapsed state when `storage` holds no
|
|
23
|
+
* choice for it; wire-up seeds the signal with it. Defaults to the signal's
|
|
24
|
+
* own value. Set it when the app seeds the signal from the device class
|
|
25
|
+
* (`signal(device.value.compact)`) so a compact first render already starts
|
|
26
|
+
* collapsed while a later crossing to a wide class still restores this
|
|
27
|
+
* inline default. */
|
|
28
|
+
inlineCollapsed?: boolean;
|
|
20
29
|
}
|
|
21
30
|
interface WireSidebarOptions {
|
|
22
31
|
panels: readonly WireSidebarPanel[];
|
|
@@ -26,6 +35,12 @@ interface WireSidebarOptions {
|
|
|
26
35
|
* dismissable backdrop, Escape and backdrop-click collapse it, and focus is
|
|
27
36
|
* trapped within the open panel (the ARIA dialog pattern). Without it the panel
|
|
28
37
|
* is always inline.
|
|
38
|
+
*
|
|
39
|
+
* An overlay is transient and user-initiated: whenever the compact overlay
|
|
40
|
+
* presentation begins (wire-up on a compact device, or a crossing from a wide
|
|
41
|
+
* class), every panel starts collapsed so nothing blocks the page until the
|
|
42
|
+
* user opens it. The inline state is remembered and restored when the device
|
|
43
|
+
* crosses back to a wide class (and on disposal).
|
|
29
44
|
*/
|
|
30
45
|
deviceClass?: ReadonlySignal<DeviceClass>;
|
|
31
46
|
/** Compact devices either overlay the panels (default) or hide them in favor
|
|
@@ -41,7 +56,7 @@ interface WireSidebarOptions {
|
|
|
41
56
|
* delegation with focus restore, focus-into on open, an optional compact overlay
|
|
42
57
|
* (backdrop + Escape + focus trap) driven by {@link deviceClass}, and an optional
|
|
43
58
|
* persistence hook. The app owns each `collapsed` signal and the layout; this wire
|
|
44
|
-
* owns the interaction. Returns a disposer. See `docs/
|
|
59
|
+
* owns the interaction. Returns a disposer. See `ui/docs/collapsible-panel.md` and `docs/23-app-layouts.md`.
|
|
45
60
|
*/
|
|
46
61
|
declare function wireSidebar(root: HTMLElement, { panels, deviceClass, compactPresentation, exclusiveCompact, storage, }: WireSidebarOptions): () => void;
|
|
47
62
|
|
package/dist/wire-sidebar.js
CHANGED
|
@@ -23,14 +23,41 @@ function wireSidebar(root, {
|
|
|
23
23
|
const byAction = new Map(panels.map((panel) => [panel.toggleAction, panel]));
|
|
24
24
|
const returnFocus = /* @__PURE__ */ new Map();
|
|
25
25
|
const disposers = [];
|
|
26
|
+
const adapting = /* @__PURE__ */ new Set();
|
|
27
|
+
const overlayActive = () => Boolean(deviceClass?.value.compact) && compactPresentation === "overlay";
|
|
28
|
+
let inlineState;
|
|
29
|
+
const setAll = (value) => {
|
|
30
|
+
for (const panel of panels) {
|
|
31
|
+
const next = value(panel);
|
|
32
|
+
if (panel.collapsed.peek() === next) continue;
|
|
33
|
+
adapting.add(panel);
|
|
34
|
+
panel.collapsed.value = next;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const restoreInline = () => {
|
|
38
|
+
const remembered = inlineState;
|
|
39
|
+
if (!remembered) return;
|
|
40
|
+
inlineState = void 0;
|
|
41
|
+
setAll((panel) => remembered.get(panel));
|
|
42
|
+
};
|
|
43
|
+
if (overlayActive()) inlineState = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const panel of panels) {
|
|
45
|
+
const stored = panel.storageKey && storage ? storage.getItem(panel.storageKey) : null;
|
|
46
|
+
const seed = stored === "true" || stored === "false" ? stored === "true" : panel.inlineCollapsed;
|
|
47
|
+
if (inlineState) {
|
|
48
|
+
inlineState.set(panel, seed ?? panel.collapsed.peek());
|
|
49
|
+
panel.collapsed.value = true;
|
|
50
|
+
} else if (seed !== void 0) {
|
|
51
|
+
panel.collapsed.value = seed;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
26
54
|
for (const panel of panels) {
|
|
27
55
|
if (!panel.storageKey || !storage) continue;
|
|
28
|
-
const stored = storage.getItem(panel.storageKey);
|
|
29
|
-
if (stored === "true" || stored === "false")
|
|
30
|
-
panel.collapsed.value = stored === "true";
|
|
31
56
|
disposers.push(
|
|
32
57
|
effect(() => {
|
|
33
|
-
|
|
58
|
+
const collapsed = panel.collapsed.value;
|
|
59
|
+
if (overlayActive()) return;
|
|
60
|
+
storage.setItem(panel.storageKey, String(collapsed));
|
|
34
61
|
})
|
|
35
62
|
);
|
|
36
63
|
}
|
|
@@ -47,12 +74,21 @@ function wireSidebar(root, {
|
|
|
47
74
|
returnFocus.set(panel.id, trigger);
|
|
48
75
|
const next = !panel.collapsed.value;
|
|
49
76
|
panel.collapsed.value = next;
|
|
50
|
-
if (!next && exclusiveCompact &&
|
|
77
|
+
if (!next && exclusiveCompact && overlayActive()) {
|
|
51
78
|
for (const other of panels)
|
|
52
79
|
if (other !== panel) other.collapsed.value = true;
|
|
53
80
|
}
|
|
54
81
|
})
|
|
55
82
|
);
|
|
83
|
+
const restoreFocus = (panel) => {
|
|
84
|
+
const element = panelElement(panel.id);
|
|
85
|
+
const trigger = returnFocus.get(panel.id);
|
|
86
|
+
const target = trigger?.isConnected && !element?.contains(trigger) ? trigger : [...root.querySelectorAll("[data-action]")].find(
|
|
87
|
+
(candidate) => candidate.dataset.action === panel.toggleAction && !element?.contains(candidate)
|
|
88
|
+
);
|
|
89
|
+
target?.focus();
|
|
90
|
+
return target !== void 0;
|
|
91
|
+
};
|
|
56
92
|
for (const panel of panels) {
|
|
57
93
|
let previous = panel.collapsed.value;
|
|
58
94
|
disposers.push(
|
|
@@ -61,48 +97,92 @@ function wireSidebar(root, {
|
|
|
61
97
|
if (collapsed === previous) return;
|
|
62
98
|
previous = collapsed;
|
|
63
99
|
const element = panelElement(panel.id);
|
|
100
|
+
if (adapting.delete(panel)) {
|
|
101
|
+
if (collapsed && element?.contains(ownerDocument.activeElement))
|
|
102
|
+
restoreFocus(panel);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
64
105
|
const replaced = deviceClass?.value.compact && compactPresentation === "hidden";
|
|
65
106
|
if (!collapsed && element && !replaced) {
|
|
66
107
|
(focusables(element)[0] ?? element).focus();
|
|
67
|
-
} else if (collapsed) {
|
|
68
|
-
|
|
108
|
+
} else if (collapsed && !restoreFocus(panel)) {
|
|
109
|
+
globalThis.queueMicrotask(() => {
|
|
110
|
+
if (panel.collapsed.peek()) restoreFocus(panel);
|
|
111
|
+
});
|
|
69
112
|
}
|
|
70
113
|
})
|
|
71
114
|
);
|
|
72
115
|
}
|
|
73
116
|
if (deviceClass) {
|
|
74
117
|
let backdrop;
|
|
118
|
+
let hostResponsive;
|
|
119
|
+
let hostOverlay;
|
|
120
|
+
let backdropFor;
|
|
75
121
|
const openPanel = () => panels.find((panel) => !panel.collapsed.value);
|
|
76
122
|
const removeBackdrop = () => {
|
|
77
123
|
backdrop?.remove();
|
|
78
124
|
backdrop = void 0;
|
|
125
|
+
backdropFor = void 0;
|
|
126
|
+
};
|
|
127
|
+
const setHostData = (name, value) => {
|
|
128
|
+
if (root.dataset[name] === value) return;
|
|
129
|
+
if (value === void 0) delete root.dataset[name];
|
|
130
|
+
else root.dataset[name] = value;
|
|
131
|
+
};
|
|
132
|
+
const syncHost = () => {
|
|
133
|
+
setHostData("collapsibleResponsive", hostResponsive);
|
|
134
|
+
setHostData("collapsibleOverlay", hostOverlay);
|
|
135
|
+
if (!backdrop || backdropFor === void 0) return;
|
|
136
|
+
const element = panelElement(backdropFor);
|
|
137
|
+
if (element && backdrop.nextElementSibling !== element)
|
|
138
|
+
element.parentElement?.insertBefore(backdrop, element);
|
|
79
139
|
};
|
|
80
140
|
disposers.push(
|
|
81
141
|
effect(() => {
|
|
82
142
|
const compact = deviceClass.value.compact;
|
|
83
143
|
const overlay = compact && compactPresentation === "overlay";
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
144
|
+
for (const panel of panels) void panel.collapsed.value;
|
|
145
|
+
if (overlay && !inlineState) {
|
|
146
|
+
inlineState = new Map(
|
|
147
|
+
panels.map((panel) => [panel, panel.collapsed.peek()])
|
|
148
|
+
);
|
|
149
|
+
setAll(() => true);
|
|
150
|
+
} else if (!overlay) {
|
|
151
|
+
restoreInline();
|
|
152
|
+
}
|
|
153
|
+
const open = overlay ? panels.find((panel) => !panel.collapsed.peek()) : void 0;
|
|
154
|
+
hostResponsive = compact ? compactPresentation : "inline";
|
|
155
|
+
hostOverlay = compact ? String(overlay) : void 0;
|
|
156
|
+
if (open) {
|
|
88
157
|
if (!backdrop) {
|
|
89
158
|
backdrop = ownerDocument.createElement("button");
|
|
90
159
|
backdrop.type = "button";
|
|
91
160
|
backdrop.className = "kui-collapsible-panel__backdrop";
|
|
92
161
|
backdrop.setAttribute("aria-label", "Close");
|
|
162
|
+
backdrop.dataset.morphPreserve = "";
|
|
93
163
|
backdrop.addEventListener("click", () => {
|
|
94
164
|
const current = openPanel();
|
|
95
165
|
if (current) collapse(current);
|
|
96
166
|
});
|
|
97
|
-
const element = panelElement(open.id);
|
|
98
|
-
element?.parentElement?.insertBefore(backdrop, element);
|
|
99
167
|
}
|
|
168
|
+
backdropFor = open.id;
|
|
100
169
|
} else {
|
|
101
170
|
removeBackdrop();
|
|
102
|
-
if (!compact) delete root.dataset.collapsibleOverlay;
|
|
103
171
|
}
|
|
172
|
+
syncHost();
|
|
104
173
|
})
|
|
105
174
|
);
|
|
175
|
+
const observer = new MutationObserver(syncHost);
|
|
176
|
+
observer.observe(root, {
|
|
177
|
+
attributes: true,
|
|
178
|
+
attributeFilter: [
|
|
179
|
+
"data-collapsible-responsive",
|
|
180
|
+
"data-collapsible-overlay"
|
|
181
|
+
],
|
|
182
|
+
childList: true,
|
|
183
|
+
subtree: true
|
|
184
|
+
});
|
|
185
|
+
disposers.push(() => observer.disconnect());
|
|
106
186
|
const onKeydown = (event) => {
|
|
107
187
|
if (!deviceClass.value.compact || compactPresentation !== "overlay")
|
|
108
188
|
return;
|
|
@@ -137,6 +217,7 @@ function wireSidebar(root, {
|
|
|
137
217
|
}
|
|
138
218
|
return () => {
|
|
139
219
|
for (const dispose of disposers.splice(0)) dispose();
|
|
220
|
+
restoreInline();
|
|
140
221
|
delete root.dataset.collapsibleOverlay;
|
|
141
222
|
delete root.dataset.collapsibleResponsive;
|
|
142
223
|
};
|
package/dist/wire-sidebar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wire-sidebar.ts"],"names":[],"mappings":";;;AA0CA,IAAM,SAAA,GACJ,iJAAA;AAEF,SAAS,WAAW,KAAA,EAAmC;AAIrD,EAAA,OAAO,CAAC,GAAG,KAAA,CAAM,gBAAA,CAA8B,SAAS,CAAC,CAAA;AA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AO,KAAA,CAAM,KAAA,CAAM,MAAA,GAAS,CAAC,CAAA;AACnC,MAAA,MAAM,SAAS,aAAA,CAAc,aAAA;AAC7B,MAAA,IAAI,KAAA,CAAM,QAAA,IAAY,MAAA,KAAW,KAAA,EAAO;AACtC,QAAA,KAAA,CAAM,cAAA,EAAe;AACrB,QAAA,IAAA,CAAK,KAAA,EAAM;AAAA,MACb,CAAA,MAAA,IAAW,CAAC,KAAA,CAAM,QAAA,IAAY,WAAW,IAAA,EAAM;AAC7C,QAAA,KAAA,CAAM,cAAA,EAAe;AACrB,QAAA,KAAA,CAAM,KAAA,EAAM;AAAA,MACd;AAAA,IACF,CAAA;AACA,IAAA,aAAA,CAAc,gBAAA,CAAiB,WAAW,SAAS,CAAA;AACnD,IAAA,SAAA,CAAU,IAAA;AAAA,MAAK,MACb,aAAA,CAAc,mBAAA,CAAoB,SAAA,EAAW,SAAS;AAAA,KACxD;AACA,IAAA,SAAA,CAAU,KAAK,cAAc,CAAA;AAAA,EAC/B;AAEA,EAAA,OAAO,MAAM;AACX,IAAA,KAAA,MAAW,OAAA,IAAW,SAAA,CAAU,MAAA,CAAO,CAAC,GAAG,OAAA,EAAQ;AACnD,IAAA,OAAO,KAAK,OAAA,CAAQ,kBAAA;AACpB,IAAA,OAAO,KAAK,OAAA,CAAQ,qBAAA;AAAA,EACtB,CAAA;AACF","file":"wire-sidebar.js","sourcesContent":["import { delegate, effect, type ReadonlySignal, type Signal } from 'kerfjs';\n\nimport type { DeviceClass } from './device-class.js';\n\n/** Minimal `localStorage`-shaped store, so the persistence hook is testable. */\nexport interface SidebarStorage {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n}\n\nexport interface WireSidebarPanel {\n /** The panel id — matches `CollapsiblePanel`'s `id` and a toggle's `panelId`. */\n id: string;\n /** The app-owned collapsed signal. `wireSidebar` reads it (focus, overlay) and\n * writes it (toggle, Escape, backdrop, persistence). */\n collapsed: Signal<boolean>;\n /** `data-action` value the panel's toggle button(s) carry. */\n toggleAction: string;\n /** When set, the collapsed state is loaded from and saved to `storage` under\n * this key (a persistence hook), so the panel remembers its state. */\n storageKey?: string;\n}\n\nexport interface WireSidebarOptions {\n panels: readonly WireSidebarPanel[];\n /**\n * When provided, the sidebar adopts a compact **overlay** presentation while\n * `deviceClass.compact` is true: an open panel floats over the content with a\n * dismissable backdrop, Escape and backdrop-click collapse it, and focus is\n * trapped within the open panel (the ARIA dialog pattern). Without it the panel\n * is always inline.\n */\n deviceClass?: ReadonlySignal<DeviceClass>;\n /** Compact devices either overlay the panels (default) or hide them in favor\n * of an application-owned responsive replacement. */\n compactPresentation?: 'overlay' | 'hidden';\n /** Collapse the other panels when one opens in compact overlay mode. */\n exclusiveCompact?: boolean;\n /** Persistence store (default `globalThis.localStorage`, if present). */\n storage?: SidebarStorage;\n}\n\nconst FOCUSABLE =\n 'a[href],area[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction focusables(panel: HTMLElement): HTMLElement[] {\n // Focus only ever targets an OPEN panel, so the selector (which already drops\n // disabled controls and tabindex=\"-1\") is sufficient without a layout-based\n // visibility check that a headless DOM can't answer.\n return [...panel.querySelectorAll<HTMLElement>(FOCUSABLE)];\n}\n\nfunction defaultStorage(): SidebarStorage | undefined {\n try {\n return globalThis.localStorage ?? undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The reusable sidebar-semantics layer for {@link CollapsiblePanel}s: toggle\n * delegation with focus restore, focus-into on open, an optional compact overlay\n * (backdrop + Escape + focus trap) driven by {@link deviceClass}, and an optional\n * persistence hook. The app owns each `collapsed` signal and the layout; this wire\n * owns the interaction. Returns a disposer. See `docs/24-collapsible-panel.md`.\n */\nexport function wireSidebar(\n root: HTMLElement,\n {\n panels,\n deviceClass,\n compactPresentation = 'overlay',\n exclusiveCompact = true,\n storage = defaultStorage(),\n }: WireSidebarOptions,\n): () => void {\n const ownerDocument = root.ownerDocument;\n const byAction = new Map(panels.map((panel) => [panel.toggleAction, panel]));\n const returnFocus = new Map<string, HTMLElement>();\n const disposers: Array<() => void> = [];\n\n // Persistence: seed from storage, then mirror on change.\n for (const panel of panels) {\n if (!panel.storageKey || !storage) continue;\n const stored = storage.getItem(panel.storageKey);\n if (stored === 'true' || stored === 'false')\n panel.collapsed.value = stored === 'true';\n disposers.push(\n effect(() => {\n storage.setItem(panel.storageKey!, String(panel.collapsed.value));\n }),\n );\n }\n\n const panelElement = (id: string): HTMLElement | null =>\n root.querySelector<HTMLElement>(`[data-collapsible-panel=\"${id}\"]`);\n\n const collapse = (panel: WireSidebarPanel): void => {\n if (panel.collapsed.value) return;\n panel.collapsed.value = true;\n };\n\n // Toggle delegation. The trigger is remembered so focus restores to it on close.\n disposers.push(\n delegate(root, 'click', '[data-action]', (_event, element) => {\n const trigger = element as HTMLElement;\n const panel = byAction.get(trigger.dataset.action ?? '');\n if (!panel) return;\n returnFocus.set(panel.id, trigger);\n const next = !panel.collapsed.value;\n panel.collapsed.value = next;\n if (\n !next &&\n exclusiveCompact &&\n deviceClass?.value.compact &&\n compactPresentation === 'overlay'\n ) {\n for (const other of panels)\n if (other !== panel) other.collapsed.value = true;\n }\n }),\n );\n\n // Focus: move into the panel when it opens; restore to the trigger when it closes.\n for (const panel of panels) {\n let previous = panel.collapsed.value;\n disposers.push(\n effect(() => {\n const collapsed = panel.collapsed.value;\n if (collapsed === previous) return;\n previous = collapsed;\n const element = panelElement(panel.id);\n const replaced =\n deviceClass?.value.compact && compactPresentation === 'hidden';\n if (!collapsed && element && !replaced) {\n (focusables(element)[0] ?? element).focus();\n } else if (collapsed) {\n returnFocus.get(panel.id)?.focus();\n }\n }),\n );\n }\n\n // Compact overlay: a dismissable backdrop + Escape + focus trap while compact\n // and a panel is open.\n if (deviceClass) {\n let backdrop: HTMLButtonElement | undefined;\n const openPanel = (): WireSidebarPanel | undefined =>\n panels.find((panel) => !panel.collapsed.value);\n const removeBackdrop = (): void => {\n backdrop?.remove();\n backdrop = undefined;\n };\n disposers.push(\n effect(() => {\n const compact = deviceClass.value.compact;\n const overlay = compact && compactPresentation === 'overlay';\n const open = overlay ? openPanel() : undefined;\n root.dataset.collapsibleResponsive = compact\n ? compactPresentation\n : 'inline';\n root.dataset.collapsibleOverlay = String(overlay);\n if (overlay && open) {\n if (!backdrop) {\n backdrop = ownerDocument.createElement('button');\n backdrop.type = 'button';\n backdrop.className = 'kui-collapsible-panel__backdrop';\n backdrop.setAttribute('aria-label', 'Close');\n backdrop.addEventListener('click', () => {\n const current = openPanel();\n if (current) collapse(current);\n });\n const element = panelElement(open.id);\n element?.parentElement?.insertBefore(backdrop, element);\n }\n } else {\n removeBackdrop();\n if (!compact) delete root.dataset.collapsibleOverlay;\n }\n }),\n );\n\n const onKeydown = (event: KeyboardEvent): void => {\n if (!deviceClass.value.compact || compactPresentation !== 'overlay')\n return;\n const open = openPanel();\n if (!open) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n collapse(open);\n return;\n }\n if (event.key !== 'Tab') return;\n const element = panelElement(open.id);\n if (!element) return;\n const items = focusables(element);\n if (items.length === 0) return;\n const first = items[0]!;\n const last = items[items.length - 1]!;\n const active = ownerDocument.activeElement;\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n ownerDocument.addEventListener('keydown', onKeydown);\n disposers.push(() =>\n ownerDocument.removeEventListener('keydown', onKeydown),\n );\n disposers.push(removeBackdrop);\n }\n\n return () => {\n for (const dispose of disposers.splice(0)) dispose();\n delete root.dataset.collapsibleOverlay;\n delete root.dataset.collapsibleResponsive;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/wire-sidebar.ts"],"names":[],"mappings":";;;AAyDA,IAAM,SAAA,GACJ,iJAAA;AAEF,SAAS,WAAW,KAAA,EAAmC;AAIrD,EAAA,OAAO,CAAC,GAAG,KAAA,CAAM,gBAAA,CAA8B,SAAS,CAAC,CAA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,IAAI,KAAA,CAAM,QAAA,IAAY,MAAA,KAAW,KAAA,EAAO;AACtC,QAAA,KAAA,CAAM,cAAA,EAAe;AACrB,QAAA,IAAA,CAAK,KAAA,EAAM;AAAA,MACb,CAAA,MAAA,IAAW,CAAC,KAAA,CAAM,QAAA,IAAY,WAAW,IAAA,EAAM;AAC7C,QAAA,KAAA,CAAM,cAAA,EAAe;AACrB,QAAA,KAAA,CAAM,KAAA,EAAM;AAAA,MACd;AAAA,IACF,CAAA;AACA,IAAA,aAAA,CAAc,gBAAA,CAAiB,WAAW,SAAS,CAAA;AACnD,IAAA,SAAA,CAAU,IAAA;AAAA,MAAK,MACb,aAAA,CAAc,mBAAA,CAAoB,SAAA,EAAW,SAAS;AAAA,KACxD;AACA,IAAA,SAAA,CAAU,KAAK,cAAc,CAAA;AAAA,EAC/B;AAEA,EAAA,OAAO,MAAM;AACX,IAAA,KAAA,MAAW,OAAA,IAAW,SAAA,CAAU,MAAA,CAAO,CAAC,GAAG,OAAA,EAAQ;AAGnD,IAAA,aAAA,EAAc;AACd,IAAA,OAAO,KAAK,OAAA,CAAQ,kBAAA;AACpB,IAAA,OAAO,KAAK,OAAA,CAAQ,qBAAA;AAAA,EACtB,CAAA;AACF","file":"wire-sidebar.js","sourcesContent":["import { delegate, effect, type ReadonlySignal, type Signal } from 'kerfjs';\n\nimport type { DeviceClass } from './device-class.js';\n\n/** Minimal `localStorage`-shaped store, so the persistence hook is testable. */\nexport interface SidebarStorage {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n}\n\nexport interface WireSidebarPanel {\n /** The panel id — matches `CollapsiblePanel`'s `id` and a toggle's `panelId`. */\n id: string;\n /** The app-owned collapsed signal. `wireSidebar` reads it (focus, overlay) and\n * writes it (toggle, Escape, backdrop, persistence). */\n collapsed: Signal<boolean>;\n /** `data-action` value the panel's toggle button(s) carry. */\n toggleAction: string;\n /** When set, the panel's inline collapsed state is loaded from and saved to\n * `storage` under this key (a persistence hook), so the panel remembers the\n * user's inline choice. A compact overlay's open/closed state is transient\n * and is never persisted. */\n storageKey?: string;\n /** The panel's inline (non-compact) collapsed state when `storage` holds no\n * choice for it; wire-up seeds the signal with it. Defaults to the signal's\n * own value. Set it when the app seeds the signal from the device class\n * (`signal(device.value.compact)`) so a compact first render already starts\n * collapsed while a later crossing to a wide class still restores this\n * inline default. */\n inlineCollapsed?: boolean;\n}\n\nexport interface WireSidebarOptions {\n panels: readonly WireSidebarPanel[];\n /**\n * When provided, the sidebar adopts a compact **overlay** presentation while\n * `deviceClass.compact` is true: an open panel floats over the content with a\n * dismissable backdrop, Escape and backdrop-click collapse it, and focus is\n * trapped within the open panel (the ARIA dialog pattern). Without it the panel\n * is always inline.\n *\n * An overlay is transient and user-initiated: whenever the compact overlay\n * presentation begins (wire-up on a compact device, or a crossing from a wide\n * class), every panel starts collapsed so nothing blocks the page until the\n * user opens it. The inline state is remembered and restored when the device\n * crosses back to a wide class (and on disposal).\n */\n deviceClass?: ReadonlySignal<DeviceClass>;\n /** Compact devices either overlay the panels (default) or hide them in favor\n * of an application-owned responsive replacement. */\n compactPresentation?: 'overlay' | 'hidden';\n /** Collapse the other panels when one opens in compact overlay mode. */\n exclusiveCompact?: boolean;\n /** Persistence store (default `globalThis.localStorage`, if present). */\n storage?: SidebarStorage;\n}\n\nconst FOCUSABLE =\n 'a[href],area[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction focusables(panel: HTMLElement): HTMLElement[] {\n // Focus only ever targets an OPEN panel, so the selector (which already drops\n // disabled controls and tabindex=\"-1\") is sufficient without a layout-based\n // visibility check that a headless DOM can't answer.\n return [...panel.querySelectorAll<HTMLElement>(FOCUSABLE)];\n}\n\nfunction defaultStorage(): SidebarStorage | undefined {\n try {\n return globalThis.localStorage ?? undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The reusable sidebar-semantics layer for {@link CollapsiblePanel}s: toggle\n * delegation with focus restore, focus-into on open, an optional compact overlay\n * (backdrop + Escape + focus trap) driven by {@link deviceClass}, and an optional\n * persistence hook. The app owns each `collapsed` signal and the layout; this wire\n * owns the interaction. Returns a disposer. See `ui/docs/collapsible-panel.md` and `docs/23-app-layouts.md`.\n */\nexport function wireSidebar(\n root: HTMLElement,\n {\n panels,\n deviceClass,\n compactPresentation = 'overlay',\n exclusiveCompact = true,\n storage = defaultStorage(),\n }: WireSidebarOptions,\n): () => void {\n const ownerDocument = root.ownerDocument;\n const byAction = new Map(panels.map((panel) => [panel.toggleAction, panel]));\n const returnFocus = new Map<string, HTMLElement>();\n const disposers: Array<() => void> = [];\n // Panels whose next collapsed change is presentation-driven, not a user\n // action, so it must not move focus the way a toggle does. A set rather than\n // a flag: writes made inside an effect are batched, so the focus effects run\n // after the writer returns.\n const adapting = new Set<WireSidebarPanel>();\n const overlayActive = (): boolean =>\n Boolean(deviceClass?.value.compact) && compactPresentation === 'overlay';\n\n // Initial-state contract: an overlay is transient and only ever opens on a\n // user action. Entering the overlay presentation (at wire-up or on a wide →\n // compact crossing) remembers each panel's inline state and collapses it;\n // leaving it (compact → wide, or disposal) restores the remembered state.\n let inlineState: Map<WireSidebarPanel, boolean> | undefined;\n const setAll = (value: (panel: WireSidebarPanel) => boolean): void => {\n for (const panel of panels) {\n const next = value(panel);\n if (panel.collapsed.peek() === next) continue;\n adapting.add(panel);\n panel.collapsed.value = next;\n }\n };\n const restoreInline = (): void => {\n const remembered = inlineState;\n if (!remembered) return;\n inlineState = undefined;\n setAll((panel) => remembered.get(panel)!);\n };\n\n // Seed each panel's inline state from storage or `inlineCollapsed`. On a\n // compact overlay device the seed is only remembered: the panel starts\n // collapsed, synchronously and before any effect exists, so the first render\n // after wire-up already has no overlay open.\n if (overlayActive()) inlineState = new Map();\n for (const panel of panels) {\n const stored =\n panel.storageKey && storage ? storage.getItem(panel.storageKey) : null;\n const seed =\n stored === 'true' || stored === 'false'\n ? stored === 'true'\n : panel.inlineCollapsed;\n if (inlineState) {\n inlineState.set(panel, seed ?? panel.collapsed.peek());\n panel.collapsed.value = true;\n } else if (seed !== undefined) {\n panel.collapsed.value = seed;\n }\n }\n\n // Persistence mirrors inline changes only. An overlay's open/closed state is\n // transient, so it is never written.\n for (const panel of panels) {\n if (!panel.storageKey || !storage) continue;\n disposers.push(\n effect(() => {\n const collapsed = panel.collapsed.value;\n if (overlayActive()) return;\n storage.setItem(panel.storageKey!, String(collapsed));\n }),\n );\n }\n\n const panelElement = (id: string): HTMLElement | null =>\n root.querySelector<HTMLElement>(`[data-collapsible-panel=\"${id}\"]`);\n\n const collapse = (panel: WireSidebarPanel): void => {\n if (panel.collapsed.value) return;\n panel.collapsed.value = true;\n };\n\n // Toggle delegation. The trigger is remembered so focus restores to it on close.\n disposers.push(\n delegate(root, 'click', '[data-action]', (_event, element) => {\n const trigger = element as HTMLElement;\n const panel = byAction.get(trigger.dataset.action ?? '');\n if (!panel) return;\n returnFocus.set(panel.id, trigger);\n const next = !panel.collapsed.value;\n panel.collapsed.value = next;\n if (!next && exclusiveCompact && overlayActive()) {\n for (const other of panels)\n if (other !== panel) other.collapsed.value = true;\n }\n }),\n );\n\n // Where focus goes when a panel closes: the trigger that toggled it, unless\n // that trigger sits inside the now-hidden panel (the documented\n // collapse-inside placement) or was re-rendered away. Then it goes to the\n // panel's toggle outside it — the always-visible expand toggle, which an app\n // may render only while the panel is collapsed. Returns whether it moved.\n const restoreFocus = (panel: WireSidebarPanel): boolean => {\n const element = panelElement(panel.id);\n const trigger = returnFocus.get(panel.id);\n const target =\n trigger?.isConnected && !element?.contains(trigger)\n ? trigger\n : [...root.querySelectorAll<HTMLElement>('[data-action]')].find(\n (candidate) =>\n candidate.dataset.action === panel.toggleAction &&\n !element?.contains(candidate),\n );\n target?.focus();\n return target !== undefined;\n };\n\n // Focus: move into the panel when it opens; restore it when it closes.\n for (const panel of panels) {\n let previous = panel.collapsed.value;\n disposers.push(\n effect(() => {\n const collapsed = panel.collapsed.value;\n if (collapsed === previous) return;\n previous = collapsed;\n const element = panelElement(panel.id);\n if (adapting.delete(panel)) {\n // A presentation change, not a user action: only rescue focus that\n // the collapse would strand inside the now-hidden panel.\n if (collapsed && element?.contains(ownerDocument.activeElement))\n restoreFocus(panel);\n return;\n }\n const replaced =\n deviceClass?.value.compact && compactPresentation === 'hidden';\n if (!collapsed && element && !replaced) {\n (focusables(element)[0] ?? element).focus();\n } else if (collapsed && !restoreFocus(panel)) {\n // An app that renders after this effect has not produced its\n // expand toggle yet; look again once the current batch settles.\n globalThis.queueMicrotask(() => {\n if (panel.collapsed.peek()) restoreFocus(panel);\n });\n }\n }),\n );\n }\n\n // Compact overlay: a dismissable backdrop + Escape + focus trap while compact\n // and a panel is open.\n if (deviceClass) {\n let backdrop: HTMLButtonElement | undefined;\n // The host state this wire owns, recorded so it can be re-applied: the\n // app re-renders (and morphs) the root for reasons that never touch a\n // panel signal (a nav selection, say), and a morph strips attributes and\n // nodes the template doesn't emit.\n let hostResponsive: string | undefined;\n let hostOverlay: string | undefined;\n let backdropFor: string | undefined;\n const openPanel = (): WireSidebarPanel | undefined =>\n panels.find((panel) => !panel.collapsed.value);\n const removeBackdrop = (): void => {\n backdrop?.remove();\n backdrop = undefined;\n backdropFor = undefined;\n };\n const setHostData = (\n name: 'collapsibleResponsive' | 'collapsibleOverlay',\n value: string | undefined,\n ): void => {\n if (root.dataset[name] === value) return;\n if (value === undefined) delete root.dataset[name];\n else root.dataset[name] = value;\n };\n // Idempotent, so the observer below settles after one corrective write.\n const syncHost = (): void => {\n setHostData('collapsibleResponsive', hostResponsive);\n setHostData('collapsibleOverlay', hostOverlay);\n if (!backdrop || backdropFor === undefined) return;\n const element = panelElement(backdropFor);\n if (element && backdrop.nextElementSibling !== element)\n element.parentElement?.insertBefore(backdrop, element);\n };\n disposers.push(\n effect(() => {\n const compact = deviceClass.value.compact;\n const overlay = compact && compactPresentation === 'overlay';\n // A crossing adapts the panels here, in the same effect that owns the\n // host state. Every panel's state is read so an open or close moves\n // the backdrop; re-renders that touch no panel are covered by the\n // observer below.\n for (const panel of panels) void panel.collapsed.value;\n if (overlay && !inlineState) {\n inlineState = new Map(\n panels.map((panel) => [panel, panel.collapsed.peek()]),\n );\n setAll(() => true);\n } else if (!overlay) {\n restoreInline();\n }\n const open = overlay\n ? panels.find((panel) => !panel.collapsed.peek())\n : undefined;\n hostResponsive = compact ? compactPresentation : 'inline';\n hostOverlay = compact ? String(overlay) : undefined;\n if (open) {\n if (!backdrop) {\n backdrop = ownerDocument.createElement('button');\n backdrop.type = 'button';\n backdrop.className = 'kui-collapsible-panel__backdrop';\n backdrop.setAttribute('aria-label', 'Close');\n // Injected after render: the morph's removal pass must skip it.\n backdrop.dataset.morphPreserve = '';\n backdrop.addEventListener('click', () => {\n const current = openPanel();\n if (current) collapse(current);\n });\n }\n backdropFor = open.id;\n } else {\n removeBackdrop();\n }\n syncHost();\n }),\n );\n const observer = new MutationObserver(syncHost);\n observer.observe(root, {\n attributes: true,\n attributeFilter: [\n 'data-collapsible-responsive',\n 'data-collapsible-overlay',\n ],\n childList: true,\n subtree: true,\n });\n disposers.push(() => observer.disconnect());\n\n const onKeydown = (event: KeyboardEvent): void => {\n if (!deviceClass.value.compact || compactPresentation !== 'overlay')\n return;\n const open = openPanel();\n if (!open) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n collapse(open);\n return;\n }\n if (event.key !== 'Tab') return;\n const element = panelElement(open.id);\n if (!element) return;\n const items = focusables(element);\n if (items.length === 0) return;\n const first = items[0]!;\n const last = items[items.length - 1]!;\n const active = ownerDocument.activeElement;\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n ownerDocument.addEventListener('keydown', onKeydown);\n disposers.push(() =>\n ownerDocument.removeEventListener('keydown', onKeydown),\n );\n disposers.push(removeBackdrop);\n }\n\n return () => {\n for (const dispose of disposers.splice(0)) dispose();\n // After every effect is gone, so handing the inline state back cannot\n // re-create overlay chrome or persist anything.\n restoreInline();\n delete root.dataset.collapsibleOverlay;\n delete root.dataset.collapsibleResponsive;\n };\n}\n"]}
|
package/docs/accessibility.md
CHANGED
|
@@ -10,7 +10,7 @@ These are normative contracts for package components and consuming applications.
|
|
|
10
10
|
- `ListHeader` owns action naming, disabled state, and disclosure `aria-expanded`. Toggle mode supplies one decorative 18px `DisclosureArrow` when `actionIcon` is omitted; it mirrors `expanded` while the native button's accessible name stays stable. The application must update that controlled state and reveal or hide real content. A valid `count` is visually rendered in an `aria-hidden` neutral pill while the required localized `countLabel` becomes part of the owning heading or disclosure button's accessible name; zero remains a real count. Its narrow `triggerAttributes` slot may describe a native popover or controlled-content relationship with `popoverTarget`, `popoverTargetAction`, `aria-controls`, and `aria-haspopup`; the application owns the target surface and its focus/dismissal behavior.
|
|
11
11
|
- Dispose `wireTabBars` and `wireTokenSearchFields` with their owning view. Disposal cancels queued controlled-render focus restoration, so a torn-down view cannot reclaim focus from its successor.
|
|
12
12
|
- `wireNavStack` moves focus into every newly active top view and remembers the last focused descendant of each mounted view for pop restoration. Mark a preferred initial heading or control with `data-nav-focus` (and `tabindex="-1"` when it is not normally tabbable); otherwise the helper uses the first enabled focusable descendant, then a programmatically focusable view-container fallback.
|
|
13
|
-
- In any `.kui-pane`, menu rows, `ListHeader` actions, and toolbar groups keep a minimum 44px target in both dimensions. A `ListHeader` fills the available inline width and keeps that action at the logical end, including in RTL. Its action visual defaults to 18px through `--kui-list-header-action-icon-size
|
|
13
|
+
- In any `.kui-pane`, menu rows, `ListHeader` actions, and toolbar groups keep a minimum 44px target in both dimensions. A `ListHeader` fills the available inline width and keeps that action at the logical end, including in RTL. Its action visual defaults to 18px through `--kui-list-header-action-icon-size` inside a fitted 36px hover square; a transparent hit layer extends the pointer target to at least 44 × 44 around that square without moving layout or enlarging the painted surface. Compact headers are 36px tall like the rest of the compact List family, so their action target is 44px wide and clamped to the 36px header height instead of reaching into a neighboring row. Do not reduce the target to the visible icon, and do not force the button itself to 44px.
|
|
14
14
|
- `LoadingSpinner` is either labeled (`role="img"`) or hidden. Its rotation stops for reduced motion.
|
|
15
15
|
- `StateBanner` defaults to polite `role="status"`; use `urgency="alert"` only for an attention-requiring failure. Its optional `badge` is persistent inline status/count content beside the title and is announced as part of the banner; keep it terse and do not rely on color alone for its meaning.
|
|
16
16
|
- `EmptyState` reports busy state through `aria-busy` and never relies on an illustration as its label.
|
|
@@ -29,10 +29,23 @@ adding height or spacing. This also applies to `renderSelected`: selected conten
|
|
|
29
29
|
stays separate from the control's stable accessible name. Applications do not
|
|
30
30
|
need shadow-DOM patches or extra label styling.
|
|
31
31
|
|
|
32
|
-
Use `presentation="toolbar-borderless"`
|
|
33
|
-
`
|
|
34
|
-
composed focus ring. `selectedPresentation="icon-only"` hides
|
|
35
|
-
selected label—the required `label` or `ariaLabel` still names
|
|
32
|
+
Use `presentation="toolbar-borderless"` inside a `ToolbarControlGroup`, with
|
|
33
|
+
`size="compact"` in a compact group; set `focusRingOwner="group"` when that
|
|
34
|
+
parent paints the composed focus ring. `selectedPresentation="icon-only"` hides
|
|
35
|
+
only the visible selected label—the required `label` or `ariaLabel` still names
|
|
36
|
+
the combobox. An icon-only trigger keeps its disclosure caret: the selected icon
|
|
37
|
+
and caret form one pill with the same geometry as a popup-menu `wa-dropdown`
|
|
38
|
+
trigger (8px inline padding on both sides, 12px from the icon to the caret, a
|
|
39
|
+
40px default or 32px compact control height), so the caret still signals a
|
|
40
|
+
choice list. Inside a group the trigger is inset evenly on every side (2px in a
|
|
41
|
+
default group, 1px in a compact one) with a concentric radius; the group grows
|
|
42
|
+
to the trigger's width, so a single group is wider than it is tall and its
|
|
43
|
+
focus ring follows the pill while focused and while its listbox is open.
|
|
44
|
+
Beside other controls in one group, the icon-only trigger is one more segment:
|
|
45
|
+
it keeps the group's gap and its siblings' block inset, height, item radius,
|
|
46
|
+
and hover pill. In a group with per-control rings (`focusRing="control"`, the
|
|
47
|
+
default) it paints the same ring as its sibling buttons, even when
|
|
48
|
+
`focusRingOwner="group"` was set, because no group ring would show focus.
|
|
36
49
|
Navigation selects can use intrinsic `presentation="navigation"` plus
|
|
37
50
|
`labelMaxWidth` for component-owned ellipsis. These props own the control's
|
|
38
51
|
appearance; its parent continues to own outer placement.
|
|
@@ -96,7 +109,27 @@ The handle exposes separator role, orientation, name, minimum, maximum, and curr
|
|
|
96
109
|
- Shift+Arrow in 64 px steps;
|
|
97
110
|
- Home and End for minimum and maximum;
|
|
98
111
|
- primary-pointer drag with clamping;
|
|
99
|
-
-
|
|
112
|
+
- a visible maximum: when a parent clamps the track below the requested size
|
|
113
|
+
(a `max-width` stage, a narrow container), pointer and keyboard resizing stop
|
|
114
|
+
at the size actually shown, and the handle announces that size in
|
|
115
|
+
`aria-valuenow` and that bound in `aria-valuemax`. Focusing the handle
|
|
116
|
+
reports a stale larger committed size as the shown size without committing
|
|
117
|
+
it, so the first key press moves the visible separator. The reported values
|
|
118
|
+
also stay current at rest: a `ResizeObserver` on each region and its parent
|
|
119
|
+
re-clamps them when the space changes, and a `MutationObserver` re-clamps
|
|
120
|
+
them after a re-render writes the rendered props back, so assistive
|
|
121
|
+
technology never reads an unclamped size between interactions (the
|
|
122
|
+
disposer disconnects both observers);
|
|
123
|
+
- a whole hit target and focus ring at a clamped edge: when the separator has
|
|
124
|
+
less room past it than the handle's 10px overhang (a parent clamps the track
|
|
125
|
+
to its own edge), the region carries `data-handle-inset` and the handle sits
|
|
126
|
+
wholly inside it, so a clipping ancestor cannot cut off half the handle or
|
|
127
|
+
its focus ring. The ring is drawn inside the handle's box, so the region's
|
|
128
|
+
ends meeting a clipping edge never shave it either;
|
|
129
|
+
- preview callbacks while dragging and one commit callback on release;
|
|
130
|
+
- a live size that also resizes slide-motion content, so the content tracks the
|
|
131
|
+
separator during a drag or key press instead of waiting for the app to
|
|
132
|
+
re-render the committed size.
|
|
100
133
|
|
|
101
134
|
The application owns persistence and collapsed/expanded policy. Keep the last expanded size outside the component and restore it when reopening. An optional `handleIcon` replaces only decorative dormant content; it must not contain controls or interactive roles because the separator remains the sole focus and interaction owner.
|
|
102
135
|
|
|
@@ -247,9 +280,13 @@ standard per-side collapse/expand glyph (`PanelLeft*` / `PanelRight*` /
|
|
|
247
280
|
`PanelBottom*`); place a collapse toggle inside the panel and an expand toggle in
|
|
248
281
|
an always-visible location so it is reachable while collapsed. `wireSidebar()`
|
|
249
282
|
moves focus into the panel when it opens and restores it to the trigger when it
|
|
250
|
-
closes
|
|
283
|
+
closes; a trigger inside the now-hidden panel hands focus to the panel's toggle
|
|
284
|
+
outside it instead, so an app may render the expand toggle only while the panel
|
|
285
|
+
is collapsed. When a `deviceClass()` reports `compact`, an open panel becomes an overlay
|
|
251
286
|
with a dismissable backdrop, Escape and backdrop-click collapse it, and Tab is
|
|
252
|
-
trapped within it (the ARIA dialog pattern).
|
|
287
|
+
trapped within it (the ARIA dialog pattern). That modal state only ever begins
|
|
288
|
+
from a user action: at wire-up on a compact device and on a wide → compact
|
|
289
|
+
crossing, every panel starts collapsed, so no page load or resize traps focus. The application owns each `collapsed`
|
|
253
290
|
signal, the panels, their sizes, and content; the wire may persist the collapsed
|
|
254
291
|
state per panel.
|
|
255
292
|
|
package/docs/app-layouts.md
CHANGED
|
@@ -19,6 +19,79 @@ Derive responsiveness from `deviceClass()`: `compact` (a handset or portrait
|
|
|
19
19
|
tablet) means "one pane at a time"; `atLeast('tablet')` / `atLeast('desktop')`
|
|
20
20
|
gate the roomier presentations.
|
|
21
21
|
|
|
22
|
+
Full-height shells retain `height: 100%` so they remain embeddable. Give a
|
|
23
|
+
top-level shell a definite height chain by importing `@kerfjs/ui/document.css`
|
|
24
|
+
and applying `.kui-app-root` to the direct mount container; see the
|
|
25
|
+
[document baseline](document-baseline.md). Do not replace an embeddable shell's
|
|
26
|
+
height with `100dvh`.
|
|
27
|
+
|
|
28
|
+
## Safe areas
|
|
29
|
+
|
|
30
|
+
On a device with unsafe areas (a notch, rounded corners, a home indicator) and a
|
|
31
|
+
page that opts into them with `<meta name="viewport" content="…, viewport-fit=cover">`,
|
|
32
|
+
the layouts handle the insets for you. There is nothing to configure:
|
|
33
|
+
|
|
34
|
+
- **Surfaces paint edge to edge.** Pane and panel backgrounds, separators, and
|
|
35
|
+
dividers run through the unsafe area. A collapsible rail or drawer grows by
|
|
36
|
+
the inset it reaches, so its content keeps its configured width or height.
|
|
37
|
+
- **Content is padded on the sides it touches.** Inline insets pad the sides a
|
|
38
|
+
region actually reaches. Block insets become padding _inside_ the scroll
|
|
39
|
+
container (with matching `scroll-padding`), so content scrolls under the
|
|
40
|
+
status bar or home indicator but its first and last items can always be
|
|
41
|
+
scrolled clear.
|
|
42
|
+
- **Interior edges get nothing.** A `Workbench` center next to an expanded rail,
|
|
43
|
+
a `SplitView` detail beside its list, or a `NavStack` view under its chrome is
|
|
44
|
+
not inset on that edge. Collapse the rail and the center picks up the edge.
|
|
45
|
+
- **No double inset.** Whichever region applies an inset clears it for its
|
|
46
|
+
descendants. A layout region whose only child is a `Pane` or another layout
|
|
47
|
+
lets that child own the insets. A `Pane` header or footer whose only child is
|
|
48
|
+
a `Toolbar` hands the inline insets to the toolbar, so the toolbar's dividers
|
|
49
|
+
still reach the edge.
|
|
50
|
+
|
|
51
|
+
A plain `Pane` follows the same rules. It assumes it may touch every screen edge
|
|
52
|
+
unless its layout says otherwise. When your own markup puts panes side by side,
|
|
53
|
+
say which sides each pane reaches with `safeAreaEdges`:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<div class="app-columns">
|
|
57
|
+
<Pane label="Library" safeAreaEdges={['block-start', 'block-end', 'inline-start']}>…</Pane>
|
|
58
|
+
<Pane label="Reader" safeAreaEdges={['block-start', 'block-end', 'inline-end']}>…</Pane>
|
|
59
|
+
</div>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
An app bar or bottom bar that sits directly at a screen edge, outside any
|
|
63
|
+
`Pane` header or footer, claims its edges the same way. A `Toolbar` only pads
|
|
64
|
+
the inline edges an owner hands it until you list the sides it reaches:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<List fill>
|
|
68
|
+
<Toolbar
|
|
69
|
+
label="App bar"
|
|
70
|
+
safeAreaEdges={['block-start', 'inline-start', 'inline-end']}
|
|
71
|
+
leading={<ToolbarText text="Atlas" />}
|
|
72
|
+
/>
|
|
73
|
+
<Row gap="none" flex>…panes that list block-end and their outer side…</Row>
|
|
74
|
+
</List>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Each claimed side pads by the edge context, or the full device inset when
|
|
78
|
+
nothing routes that edge, while the bar's surface and divider still reach the
|
|
79
|
+
screen edge. A claimed toolbar inside a `Pane` header or footer adds nothing
|
|
80
|
+
extra, because the pane already owns those edges.
|
|
81
|
+
|
|
82
|
+
Pass `safeAreaEdges={[]}` for a pane that never sits at a screen edge. For a
|
|
83
|
+
region you own, set `--kui-edge-inset-block-start`, `--kui-edge-inset-block-end`,
|
|
84
|
+
`--kui-edge-inset-inline-start`, or `--kui-edge-inset-inline-end` to `0px` on the
|
|
85
|
+
region for each edge it does not reach, and kerf descendants follow. A
|
|
86
|
+
`CollapsiblePanel` does this for its direct flex siblings automatically. A
|
|
87
|
+
panel wrapped in your own grid cell cannot see its siblings, so route those
|
|
88
|
+
edges yourself.
|
|
89
|
+
|
|
90
|
+
The device insets come from `--kui-safe-area-block-start`, `-block-end`,
|
|
91
|
+
`-inline-start`, and `-inline-end`, which default to `env(safe-area-inset-*)`.
|
|
92
|
+
Override them on `:root` to reserve room for app-owned chrome or to simulate a
|
|
93
|
+
device in tests.
|
|
94
|
+
|
|
22
95
|
## Decision matrix
|
|
23
96
|
|
|
24
97
|
| Situation | Layout | Device threshold |
|