@kerfjs/ui 5.0.0-beta.63 → 5.0.0-beta.64
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 +5 -0
- package/ai/component-composition.json +6 -0
- package/ai/components/workbench.md +1 -0
- package/ai/public-api-signatures-v1.md +17 -8
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/{chunk-UCKKT6KO.js → chunk-2EKHENQK.js} +7 -1
- package/dist/chunk-2EKHENQK.js.map +1 -0
- package/dist/{chunk-ZRWXFDDS.js → chunk-J3KGJ6P6.js} +1 -1
- package/dist/{chunk-ZRWXFDDS.js.map → chunk-J3KGJ6P6.js.map} +1 -1
- package/dist/{chunk-R75GGNWY.js → chunk-M5H2RMCH.js} +44 -8
- package/dist/chunk-M5H2RMCH.js.map +1 -0
- package/dist/{chunk-RTJNJTG3.js → chunk-NSVLUDUW.js} +18 -3
- package/dist/chunk-NSVLUDUW.js.map +1 -0
- package/dist/{chunk-7AKGPBCC.js → chunk-SH6F3CCG.js} +5 -1
- package/dist/chunk-SH6F3CCG.js.map +1 -0
- package/dist/{chunk-OBAFAH5B.js → chunk-TJK44RQC.js} +33 -8
- package/dist/chunk-TJK44RQC.js.map +1 -0
- package/dist/content-item.d.ts +5 -1
- package/dist/content-item.js +1 -1
- package/dist/grid.d.ts +5 -1
- package/dist/grid.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/popup-menu-register.js +181 -5
- package/dist/popup-menu-register.js.map +1 -1
- package/dist/popup-menu.d.ts +2 -1
- package/dist/popup-menu.js +1 -1
- package/dist/styles/catalog/components/catalog-example.css +4 -0
- package/dist/styles/content-item.css +11 -2
- package/dist/styles/grid.css +7 -0
- package/dist/styles/popup-menu.css +9 -0
- package/dist/styles/segmented-control.css +3 -0
- package/dist/styles/token-search-field.css +22 -5
- package/dist/styles/toolbar-control-group.css +14 -0
- package/dist/styles/workbench.css +7 -25
- package/dist/{token-search-field-DvgFLhLL.d.ts → token-search-field-Xk8jiw8Y.d.ts} +18 -4
- package/dist/token-search-field.d.ts +1 -1
- package/dist/token-search-field.js +1 -1
- package/dist/token-search-model.d.ts +1 -1
- package/dist/wire-catalog.js +1 -1
- package/dist/wire-content-items.js +9 -5
- package/dist/wire-content-items.js.map +1 -1
- package/dist/wire-token-search-fields.d.ts +1 -1
- package/dist/wire-token-search-fields.js +1 -1
- package/dist/wire-workbench.js +1 -1
- package/docs/accessibility.md +10 -2
- package/docs/catalog.md +6 -2
- package/docs/component-contract.md +34 -2
- package/docs/component-selection.md +7 -0
- package/docs/layout.md +30 -10
- package/docs/surface-scaffold.md +6 -3
- package/docs/ux-demo.md +1 -0
- package/docs/workbench.md +5 -1
- package/package.json +1 -1
- package/dist/chunk-7AKGPBCC.js.map +0 -1
- package/dist/chunk-OBAFAH5B.js.map +0 -1
- package/dist/chunk-R75GGNWY.js.map +0 -1
- package/dist/chunk-RTJNJTG3.js.map +0 -1
- package/dist/chunk-UCKKT6KO.js.map +0 -1
|
@@ -60,6 +60,12 @@ interface TokenSearchToken {
|
|
|
60
60
|
offset?: number;
|
|
61
61
|
accessibleLabel?: string;
|
|
62
62
|
}
|
|
63
|
+
interface TokenSearchTrailingAction {
|
|
64
|
+
icon: SafeHtml;
|
|
65
|
+
label: string;
|
|
66
|
+
action: string;
|
|
67
|
+
id?: string;
|
|
68
|
+
}
|
|
63
69
|
type TokenSearchEditorAttributes = Readonly<Record<`data-${string}`, string | undefined> & {
|
|
64
70
|
'data-component'?: never;
|
|
65
71
|
'data-key'?: never;
|
|
@@ -88,8 +94,9 @@ interface TokenSearchFieldBaseProps {
|
|
|
88
94
|
tokenPlaceholder?: string;
|
|
89
95
|
disabled?: boolean;
|
|
90
96
|
autofocus?: boolean;
|
|
97
|
+
/** Let an expanded collapsible field consume the available inline width. */
|
|
98
|
+
fill?: boolean;
|
|
91
99
|
leading?: KerfUiContent;
|
|
92
|
-
trailing?: KerfUiContent;
|
|
93
100
|
/** Standalone field chrome or the inset visual layer of a configured toolbar group. */
|
|
94
101
|
presentation?: 'standalone' | 'toolbar-group';
|
|
95
102
|
editAction?: string;
|
|
@@ -103,6 +110,13 @@ interface TokenSearchFieldBaseProps {
|
|
|
103
110
|
/** Native named-slot assignment when composed inside a web component. */
|
|
104
111
|
slot?: string;
|
|
105
112
|
}
|
|
113
|
+
type TokenSearchTrailingProps = {
|
|
114
|
+
trailing?: KerfUiContent;
|
|
115
|
+
trailingAction?: never;
|
|
116
|
+
} | {
|
|
117
|
+
trailing?: never;
|
|
118
|
+
trailingAction: TokenSearchTrailingAction;
|
|
119
|
+
};
|
|
106
120
|
type TokenSearchCollapsibleProps = {
|
|
107
121
|
/** Allow an empty field to render as one iconic action. */
|
|
108
122
|
collapsible: true;
|
|
@@ -116,15 +130,15 @@ type TokenSearchCollapsibleProps = {
|
|
|
116
130
|
expandAction?: never;
|
|
117
131
|
expandLabel?: never;
|
|
118
132
|
};
|
|
119
|
-
type TokenSearchFieldProps = TokenSearchFieldBaseProps & TokenSearchCollapsibleProps;
|
|
133
|
+
type TokenSearchFieldProps = TokenSearchFieldBaseProps & TokenSearchCollapsibleProps & TokenSearchTrailingProps;
|
|
120
134
|
interface TokenSearchFieldValue {
|
|
121
135
|
query: string;
|
|
122
136
|
tokens: TokenSearchToken[];
|
|
123
137
|
}
|
|
124
|
-
declare function TokenSearchField({ id, label, query, tokens, model, revision, placeholder, tokenPlaceholder, disabled, autofocus, collapsible, expanded, expandAction, expandLabel, leading, trailing, presentation, editAction, removeAction, clearAction, clearLabel, clearIcon, className, editorAttributes, slot, }: TokenSearchFieldProps): SafeHtml;
|
|
138
|
+
declare function TokenSearchField({ id, label, query, tokens, model, revision, placeholder, tokenPlaceholder, disabled, autofocus, fill, collapsible, expanded, expandAction, expandLabel, leading, trailing, trailingAction, presentation, editAction, removeAction, clearAction, clearLabel, clearIcon, className, editorAttributes, slot, }: TokenSearchFieldProps): SafeHtml;
|
|
125
139
|
/** Read editable text and ordered token offsets from a rendered TokenSearchField editor. */
|
|
126
140
|
declare function readTokenSearchField(editor: HTMLElement, knownTokens?: readonly TokenSearchToken[]): TokenSearchFieldValue;
|
|
127
141
|
/** Focus an editor and place its caret at a text offset, skipping atomic token chips. */
|
|
128
142
|
declare function placeTokenSearchCaret(editor: HTMLElement, offset?: number): void;
|
|
129
143
|
|
|
130
|
-
export { type TokenSearchEditorAttributes as T, TokenSearchField as a, type TokenSearchFieldProps as b, type TokenSearchFieldValue as c, type TokenSearchModel as d, type TokenSearchModelOptions as e, type TokenSearchResolvedToken as f, type TokenSearchRule as g, type TokenSearchState as h, type TokenSearchSuggestion as i, type TokenSearchToken as j,
|
|
144
|
+
export { type TokenSearchEditorAttributes as T, TokenSearchField as a, type TokenSearchFieldProps as b, type TokenSearchFieldValue as c, type TokenSearchModel as d, type TokenSearchModelOptions as e, type TokenSearchResolvedToken as f, type TokenSearchRule as g, type TokenSearchState as h, type TokenSearchSuggestion as i, type TokenSearchToken as j, type TokenSearchTrailingAction as k, createTokenSearchModel as l, placeTokenSearchCaret as p, readTokenSearchField as r };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'kerfjs';
|
|
2
2
|
import './semantic-content-BbzjvSu9.js';
|
|
3
|
-
export { T as TokenSearchEditorAttributes, a as TokenSearchField, b as TokenSearchFieldProps, c as TokenSearchFieldValue, j as TokenSearchToken, p as placeTokenSearchCaret, r as readTokenSearchField } from './token-search-field-
|
|
3
|
+
export { T as TokenSearchEditorAttributes, a as TokenSearchField, b as TokenSearchFieldProps, c as TokenSearchFieldValue, j as TokenSearchToken, k as TokenSearchTrailingAction, p as placeTokenSearchCaret, r as readTokenSearchField } from './token-search-field-Xk8jiw8Y.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'kerfjs';
|
|
2
|
-
export { d as TokenSearchModel, e as TokenSearchModelOptions, f as TokenSearchResolvedToken, g as TokenSearchRule, h as TokenSearchState, i as TokenSearchSuggestion,
|
|
2
|
+
export { d as TokenSearchModel, e as TokenSearchModelOptions, f as TokenSearchResolvedToken, g as TokenSearchRule, h as TokenSearchState, i as TokenSearchSuggestion, l as createTokenSearchModel } from './token-search-field-Xk8jiw8Y.js';
|
|
3
3
|
import './semantic-content-BbzjvSu9.js';
|
package/dist/wire-catalog.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// src/wire-content-items.ts
|
|
2
2
|
var ITEM_SELECTOR = '[data-component="content-item"][data-interactive="true"]';
|
|
3
3
|
var NESTED_CONTROL_SELECTOR = 'button, a[href], input, select, textarea, [contenteditable="true"], [role="button"]';
|
|
4
|
-
function actionItem(root,
|
|
4
|
+
function actionItem(root, event) {
|
|
5
|
+
const target = event.target;
|
|
5
6
|
if (!(target instanceof Element)) return null;
|
|
6
7
|
const item = target.closest(ITEM_SELECTOR);
|
|
7
8
|
if (!item || !root.contains(item) || item.dataset.disabled === "true")
|
|
8
9
|
return null;
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
for (const node of event.composedPath()) {
|
|
11
|
+
if (node === item) break;
|
|
12
|
+
if (node instanceof Element && node.matches(NESTED_CONTROL_SELECTOR))
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
11
15
|
return item;
|
|
12
16
|
}
|
|
13
17
|
function wireContentItems(root) {
|
|
@@ -19,7 +23,7 @@ function wireContentItems(root) {
|
|
|
19
23
|
const keydown = (event) => {
|
|
20
24
|
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey)
|
|
21
25
|
return;
|
|
22
|
-
const item = actionItem(root, event
|
|
26
|
+
const item = actionItem(root, event);
|
|
23
27
|
if (!item) return;
|
|
24
28
|
if (event.key === "Enter") {
|
|
25
29
|
event.preventDefault();
|
|
@@ -40,7 +44,7 @@ function wireContentItems(root) {
|
|
|
40
44
|
if (!item) return;
|
|
41
45
|
event.preventDefault();
|
|
42
46
|
clearSpace();
|
|
43
|
-
if (item === actionItem(root, event
|
|
47
|
+
if (item === actionItem(root, event) && item.ownerDocument.activeElement === item)
|
|
44
48
|
item.click();
|
|
45
49
|
};
|
|
46
50
|
const focusout = (event) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wire-content-items.ts"],"names":[],"mappings":";AAAA,IAAM,aAAA,GACJ,0DAAA;AACF,IAAM,uBAAA,GACJ,qFAAA;AAEF,SAAS,UAAA,CAAW,MAAmB,
|
|
1
|
+
{"version":3,"sources":["../src/wire-content-items.ts"],"names":[],"mappings":";AAAA,IAAM,aAAA,GACJ,0DAAA;AACF,IAAM,uBAAA,GACJ,qFAAA;AAEF,SAAS,UAAA,CAAW,MAAmB,KAAA,EAAc;AACnD,EAAA,MAAM,SAAS,KAAA,CAAM,MAAA;AACrB,EAAA,IAAI,EAAE,MAAA,YAAkB,OAAA,CAAA,EAAU,OAAO,IAAA;AACzC,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,OAAA,CAAqB,aAAa,CAAA;AACtD,EAAA,IAAI,CAAC,QAAQ,CAAC,IAAA,CAAK,SAAS,IAAI,CAAA,IAAK,IAAA,CAAK,OAAA,CAAQ,QAAA,KAAa,MAAA;AAC7D,IAAA,OAAO,IAAA;AAGT,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,YAAA,EAAa,EAAG;AACvC,IAAA,IAAI,SAAS,IAAA,EAAM;AACnB,IAAA,IAAI,IAAA,YAAgB,OAAA,IAAW,IAAA,CAAK,OAAA,CAAQ,uBAAuB,CAAA;AACjE,MAAA,OAAO,IAAA;AAAA,EACX;AACA,EAAA,OAAO,IAAA;AACT;AAQO,SAAS,iBAAiB,IAAA,EAA+B;AAC9D,EAAA,IAAI,YAAA,GAAmC,IAAA;AAEvC,EAAA,MAAM,aAAa,MAAM;AACvB,IAAA,YAAA,EAAc,gBAAgB,kBAAkB,CAAA;AAChD,IAAA,YAAA,GAAe,IA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AA,EAAc,UAAA,EAAW;AAAA,EAChD,CAAA;AAEA,EAAA,IAAA,CAAK,gBAAA,CAAiB,WAAW,OAAO,CAAA;AACxC,EAAA,IAAA,CAAK,gBAAA,CAAiB,SAAS,KAAK,CAAA;AACpC,EAAA,IAAA,CAAK,gBAAA,CAAiB,YAAY,QAAQ,CAAA;AAC1C,EAAA,OAAO,MAAM;AACX,IAAA,UAAA,EAAW;AACX,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,OAAO,CAAA;AAC3C,IAAA,IAAA,CAAK,mBAAA,CAAoB,SAAS,KAAK,CAAA;AACvC,IAAA,IAAA,CAAK,mBAAA,CAAoB,YAAY,QAAQ,CAAA;AAAA,EAC/C,CAAA;AACF","file":"wire-content-items.js","sourcesContent":["const ITEM_SELECTOR =\n '[data-component=\"content-item\"][data-interactive=\"true\"]';\nconst NESTED_CONTROL_SELECTOR =\n 'button, a[href], input, select, textarea, [contenteditable=\"true\"], [role=\"button\"]';\n\nfunction actionItem(root: HTMLElement, event: Event) {\n const target = event.target;\n if (!(target instanceof Element)) return null;\n const item = target.closest<HTMLElement>(ITEM_SELECTOR);\n if (!item || !root.contains(item) || item.dataset.disabled === 'true')\n return null;\n // Composed events expose native controls inside a custom element's shadow\n // root even though event.target is retargeted to its host here.\n for (const node of event.composedPath()) {\n if (node === item) break;\n if (node instanceof Element && node.matches(NESTED_CONTROL_SELECTOR))\n return null;\n }\n return item;\n}\n\n/**\n * Give interactive ContentItems native-like Enter/Space activation with one\n * delegated listener pair. Space activates on release and is cancelled if\n * focus moves; the item's own `data-action` still goes through the app's\n * ordinary delegated click handler. Returns a disposer.\n */\nexport function wireContentItems(root: HTMLElement): () => void {\n let pendingSpace: HTMLElement | null = null;\n\n const clearSpace = () => {\n pendingSpace?.removeAttribute('data-kui-pressed');\n pendingSpace = null;\n };\n\n const keydown = (event: KeyboardEvent) => {\n if (\n event.defaultPrevented ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey\n )\n return;\n const item = actionItem(root, event);\n if (!item) return;\n if (event.key === 'Enter') {\n event.preventDefault();\n item.click();\n return;\n }\n if (event.key === ' ' || event.key === 'Spacebar') {\n event.preventDefault();\n if (event.repeat) return;\n clearSpace();\n pendingSpace = item;\n item.setAttribute('data-kui-pressed', 'true');\n }\n };\n\n const keyup = (event: KeyboardEvent) => {\n if (event.key !== ' ' && event.key !== 'Spacebar') return;\n const item = pendingSpace;\n if (!item) return;\n event.preventDefault();\n clearSpace();\n if (\n item === actionItem(root, event) &&\n item.ownerDocument.activeElement === item\n )\n item.click();\n };\n\n const focusout = (event: FocusEvent) => {\n if (event.target === pendingSpace) clearSpace();\n };\n\n root.addEventListener('keydown', keydown);\n root.addEventListener('keyup', keyup);\n root.addEventListener('focusout', focusout);\n return () => {\n clearSpace();\n root.removeEventListener('keydown', keydown);\n root.removeEventListener('keyup', keyup);\n root.removeEventListener('focusout', focusout);\n };\n}\n"]}
|
package/dist/wire-workbench.js
CHANGED
package/docs/accessibility.md
CHANGED
|
@@ -206,10 +206,14 @@ are presentational. A keyboard-focused item is the menu's current row, painted
|
|
|
206
206
|
with the Select's current-option fill rather than a second focus ring inside the
|
|
207
207
|
open popup. A disabled item stays in the menu but cannot be
|
|
208
208
|
chosen; disable the whole trigger only when every command is unavailable.
|
|
209
|
+
Clicking outside dismisses a context `PopupMenu`, including one reopened while
|
|
210
|
+
its previous hide animation is still finishing.
|
|
209
211
|
Nested items use Web Awesome's submenu pointer and Left/Right arrow routing;
|
|
210
212
|
headings and dividers can separate nested groups without becoming keyboard
|
|
211
213
|
choices. A rapid ArrowDown or ArrowUp after opening a submenu keeps the chosen
|
|
212
|
-
item focused when its show animation finishes.
|
|
214
|
+
item focused when its show animation finishes. If a submenu is reopened during
|
|
215
|
+
its close animation, it remains visible; pointer and ArrowRight actions also
|
|
216
|
+
recover a submenu left hidden with an open state. Set `checked` to `true` or `false` for checkbox menu semantics; omit it
|
|
213
217
|
for a plain command. `details` supplies optional
|
|
214
218
|
trailing visual content without changing a command's accessible label. A
|
|
215
219
|
`context` menu's invisible anchor is outside the accessibility tree and normal
|
|
@@ -432,7 +436,11 @@ it) with `data-token-search-keep-open`, or pass `collapsible.keepOpenOn(target)`
|
|
|
432
436
|
so focus or pointer activation moving into it does not collapse an empty field.
|
|
433
437
|
The helper preserves the pointer target when a browser omits
|
|
434
438
|
`focusout.relatedTarget`, preventing the field or target from disappearing
|
|
435
|
-
between pointerdown and click.
|
|
439
|
+
between pointerdown and click. For an empty field losing focus during a pointer
|
|
440
|
+
press, managed collapse waits until that press's click has dispatched (or the
|
|
441
|
+
press ends without a click), then rechecks focus and content before closing.
|
|
442
|
+
This keeps a shifting search row from moving the pressed control mid-click.
|
|
443
|
+
`wireTokenSearchFields`
|
|
436
444
|
can also, opt-in via `keyboard`, own atomic-chip editing keys: from a collapsed
|
|
437
445
|
caret with no selection, Backspace removes the token before the caret and Delete
|
|
438
446
|
the token after it (reported through `onRemoveToken` for the app to apply to its
|
package/docs/catalog.md
CHANGED
|
@@ -117,8 +117,12 @@ own overlay implementation.
|
|
|
117
117
|
spacing wrapper. A composition row may place the composition root there.
|
|
118
118
|
|
|
119
119
|
Use `align="glyph"` for a bare glyph/text specimen, `align="inline-control"`
|
|
120
|
-
for a control whose own inline padding contributes about 8px, and
|
|
121
|
-
|
|
120
|
+
for a control whose own inline padding contributes about 8px, and
|
|
121
|
+
`align="text-trigger"` for a Web Awesome dropdown's text trigger whose visible
|
|
122
|
+
label needs an 8px inset (such as a plain `PopupMenu` trigger). The dropdown host
|
|
123
|
+
has no layout box, so this inset applies to its button child. Use
|
|
124
|
+
`align="none"` (the default) for a content item or composition that owns its
|
|
125
|
+
geometry.
|
|
122
126
|
|
|
123
127
|
```tsx
|
|
124
128
|
import { CatalogExample, CatalogExampleStack } from "@kerfjs/ui/catalog";
|
|
@@ -428,7 +428,9 @@ tones can be rethemed globally with
|
|
|
428
428
|
segmented-control, app-tab, and tab-bar colors likewise use their public
|
|
429
429
|
`--kui-*-*` variables. `SegmentedControl` exposes surface, border, foreground,
|
|
430
430
|
hover, and selected-state variables, so rounded, pill, and toolbar presentations
|
|
431
|
-
remain opinionated but locally overridable.
|
|
431
|
+
remain opinionated but locally overridable. Its label color switches with the
|
|
432
|
+
theme without Web Awesome's native button color transition, so a dark filled
|
|
433
|
+
track never briefly pairs with an interpolated low-contrast label.
|
|
432
434
|
|
|
433
435
|
Inset hover and selection surfaces follow the outer control shape instead of
|
|
434
436
|
choosing an independent radius. `--kui-layout-highlight-inset` is the full
|
|
@@ -481,6 +483,15 @@ declarations.
|
|
|
481
483
|
one child 8px inline margin, a real 1px border, 8px padding, and 12px corners;
|
|
482
484
|
the border stays transparent unless `frame="framed"`, so framing never changes
|
|
483
485
|
geometry. `shape="pill"` selects the 22px radius.
|
|
486
|
+
`flush` removes block padding and borders while preserving inline geometry;
|
|
487
|
+
`title` passes through as the native tooltip. Interactive hover uses the normal
|
|
488
|
+
neutral fill so it remains visible on a lowered surface. For a card with
|
|
489
|
+
multiple actions, put sibling buttons in a static ContentItem (or use
|
|
490
|
+
`ListActionRow` for a simple two-action row).
|
|
491
|
+
For an interactive ContentItem, `wireContentItems` activates the card on Enter
|
|
492
|
+
or Space only when the key event originated from the card itself. A nested
|
|
493
|
+
native control, including one inside a custom element's shadow root, keeps its
|
|
494
|
+
own keyboard activation.
|
|
484
495
|
|
|
485
496
|
`ToolbarControlGroup` is the unit of toolbar organization, even for dormant
|
|
486
497
|
text. Each group reserves `calc(2px + remify(42px))`, or 44px, with 8px between
|
|
@@ -510,11 +521,23 @@ own inset (8px for a raw `wa-dropdown`, the Select listbox's 4px for a
|
|
|
510
521
|
open popup, fade-in surface, surface inset, row height and padding, current-row
|
|
511
522
|
fill, and group titles, all read from one private popup-choice contract in
|
|
512
523
|
`foundation.css`. Checkbox items reserve a check column; plain commands start
|
|
513
|
-
at the checkmark's leading edge
|
|
524
|
+
at the checkmark's leading edge, beside the group title rather than the
|
|
525
|
+
farther-in Select option label. Checked submenu items keep their checkmark and
|
|
526
|
+
label inside the submenu surface. Compact mixed controls retain the standard
|
|
514
527
|
item padding, omit an internal separator, and let the raised selected item paint
|
|
515
528
|
over the outer border instead of shrinking to an inset highlight. The Web
|
|
516
529
|
Awesome trigger's shadow base owns max-content sizing, so icons, localized text,
|
|
517
530
|
and the shadow caret determine the width without a fixed host measurement.
|
|
531
|
+
With `popup-menu/register` loaded, PopupMenu and a raw dropdown inside
|
|
532
|
+
`PopupSurface` preserve item navigation made during the Web Awesome show
|
|
533
|
+
animation across its final initial-focus handoff.
|
|
534
|
+
At viewport widths of 480px or less, `PopupMenu` places an open submenu above
|
|
535
|
+
or below its parent menu, choosing the side with room and constraining the
|
|
536
|
+
submenu to the viewport. It never paints over the parent list. The submenu
|
|
537
|
+
remains a native Web Awesome `menu`: the reverse horizontal arrow (ArrowLeft in
|
|
538
|
+
LTR, ArrowRight in RTL) returns focus to its parent item, Escape dismisses the
|
|
539
|
+
menu, and choosing a child dispatches the normal
|
|
540
|
+
`data-action` and `wa-select` events. Wider viewports retain the side cascade.
|
|
518
541
|
The enclosing `Toolbar` owns zone alignment and responsive topology: use
|
|
519
542
|
`centerAlign="stretch"` when the center group should consume its track, and
|
|
520
543
|
choose `responsive="stack"` with `responsiveAt="compact" | "narrow"`,
|
|
@@ -585,6 +608,15 @@ render, hands in its own via `collapsible.signals`, drives it through
|
|
|
585
608
|
UI is consistent by default without every app reinventing it. A collapsed
|
|
586
609
|
field may reveal its editor after the current microtask; the helper keeps a
|
|
587
610
|
bounded render-frame focus handoff for that reveal and cancels it on disposal.
|
|
611
|
+
`TokenSearchField.trailingAction` supplies an icon, accessible `label`, delegated
|
|
612
|
+
`action`, and optional `id`; the field renders a 24px wide button that fills its
|
|
613
|
+
34px line slot, including the hit target, disabled state, hover, and focus ring.
|
|
614
|
+
Use `trailing` for passive content. The two props are mutually exclusive.
|
|
615
|
+
For a collapsible search in a stretched Toolbar center, `fill` lets the expanded
|
|
616
|
+
field and its enclosing search `ToolbarControlGroup` consume the available width;
|
|
617
|
+
the collapsed action retains its fixed icon width.
|
|
618
|
+
Grammar suggestion rows align their labels to one leading edge inside the
|
|
619
|
+
anchored popover, including when the labels have different lengths.
|
|
588
620
|
|
|
589
621
|
A public subpath that exposes several visual components is a folder-backed
|
|
590
622
|
surface. Put each component in its own source file and give each visual
|
|
@@ -333,6 +333,13 @@ For common structured search, use `createTokenSearchModel` from `@kerfjs/ui/toke
|
|
|
333
333
|
For a sibling date picker or other app helper, call `model.commit(value)` while a `name:` prefix is active. It parses and commits that value for the active rule even when it is absent from suggestions, replacing the unfinished prefix text. Invalid values and calls without an active prefix leave the query unchanged; `choose(value)` remains restricted to suggested tokens.
|
|
334
334
|
To apply a saved search or restore a query programmatically, call `model.replace({ query, tokens })`. It publishes parsed state and rebuilds the DOM-owned editor text even when no chip changed. For a field without a model, change the field's `revision` prop when setting `query` yourself.
|
|
335
335
|
When one root contains both kinds of field, a registered model enables chip keyboard behavior only for its own field. Other fields keep native editing unless the root opts into `keyboard` with an application removal callback.
|
|
336
|
+
For an icon action at the end of the field, pass `trailingAction` with `icon`,
|
|
337
|
+
accessible `label`, and delegated `action` (plus optional `id`). The component
|
|
338
|
+
renders a button that fills the trailing hit target. Reserve `trailing` for
|
|
339
|
+
passive content such as a shortcut hint.
|
|
340
|
+
Set `fill` on a collapsible `TokenSearchField` in a stretched Toolbar center to
|
|
341
|
+
use the available width when expanded; the field and its search group retain
|
|
342
|
+
their compact widths when collapsed.
|
|
336
343
|
|
|
337
344
|
## Toolbar composition
|
|
338
345
|
|
package/docs/layout.md
CHANGED
|
@@ -188,6 +188,7 @@ import { ContentItem } from "@kerfjs/ui/content-item";
|
|
|
188
188
|
<Pane label="Inspector">
|
|
189
189
|
<ContentItem>{details}</ContentItem>
|
|
190
190
|
<ContentItem frame="framed">{pendingChanges}</ContentItem>
|
|
191
|
+
<ContentItem flush>{markdownPreview}</ContentItem>
|
|
191
192
|
<ContentItem shape="pill">{summary}</ContentItem>
|
|
192
193
|
</Pane>;
|
|
193
194
|
```
|
|
@@ -202,7 +203,10 @@ needs to align with neighboring items is `ListInsetText`. Safe `data-*`
|
|
|
202
203
|
metadata goes in `rootAttributes`. Pass `ariaLabel` only for a distinct named
|
|
203
204
|
region (`role="region"`), and `focusTarget` to make the item a programmatic
|
|
204
205
|
focus target (`tabindex="-1"`), for example a NavStack view's `data-nav-focus`
|
|
205
|
-
target.
|
|
206
|
+
target. `flush` removes block padding and both block borders while retaining
|
|
207
|
+
the inline margin, padding, and border. Use it for content such as a markdown
|
|
208
|
+
preview that must reach the item's top and bottom edges. `title` passes through
|
|
209
|
+
to the root element as a native tooltip.
|
|
206
210
|
|
|
207
211
|
For a selectable card, set `interactive`, a delegated `action`, and an optional
|
|
208
212
|
`itemId`. Wire `wireContentItems(root)` once on the containing app root; it
|
|
@@ -211,13 +215,19 @@ the app's ordinary `data-action` handler. `selectionMode="toggle"` maps
|
|
|
211
215
|
`selected` to a button's `aria-pressed`; `selectionMode="single"` maps it to an
|
|
212
216
|
option's `aria-selected` and belongs in an app-owned `role="listbox"` container.
|
|
213
217
|
An interactive card is a Tab stop, and `disabled` removes its action and Tab
|
|
214
|
-
stop while exposing `aria-disabled`.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
stop while exposing `aria-disabled`. Hover uses the normal neutral fill so it
|
|
219
|
+
remains visible on a lowered surface; hover, pressed, focus, and selected paints
|
|
220
|
+
do not change geometry. A single-action card has no interactive descendants.
|
|
221
|
+
For a rich card with a primary and secondary action, render a static
|
|
222
|
+
`ContentItem` with sibling buttons inside it. Each button then has its own
|
|
223
|
+
focus stop and action without nesting controls inside an interactive card.
|
|
224
|
+
`ListActionRow` already packages this pattern for a simple two-action row.
|
|
225
|
+
`rootAttributes` still accepts safe app `data-*` metadata, while the card owns
|
|
226
|
+
its interaction data.
|
|
227
|
+
|
|
228
|
+
The rendered classes — `.kui-content-item`, `.kui-content-item--framed`,
|
|
229
|
+
`.kui-content-item--pill`, and `.kui-content-item--flush` — stay public for the
|
|
230
|
+
rare element that must carry the
|
|
221
231
|
geometry itself (for example a `<ul>` list or a `Text` paragraph in an
|
|
222
232
|
application-owned adapter). Prefer `ContentItem` everywhere else so the framing
|
|
223
233
|
choice is typed. A plain `<div class="kui-content-item">` is exactly what
|
|
@@ -410,14 +420,24 @@ import { px } from "@kerfjs/ui/css-values";
|
|
|
410
420
|
<label>Provider <input /></label>
|
|
411
421
|
<label>Endpoint <input /></label>
|
|
412
422
|
</Grid>;
|
|
423
|
+
|
|
424
|
+
<Grid minColumnWidth={px(160)} autoFill gap="m">
|
|
425
|
+
<DocumentTile />
|
|
426
|
+
</Grid>;
|
|
413
427
|
```
|
|
414
428
|
|
|
415
429
|
`columns` must be a positive safe integer; invalid counts throw instead of
|
|
416
430
|
silently producing invalid CSS. Import `px` from `@kerfjs/ui/css-values` for a
|
|
417
431
|
pixel minimum. `columns` and `minColumnWidth` are mutually exclusive. In the
|
|
418
432
|
responsive mode, the container width decides how many equal tracks fit; constrain
|
|
419
|
-
the Grid's outer width when the form should have a maximum count.
|
|
420
|
-
|
|
433
|
+
the Grid's outer width when the form should have a maximum count.
|
|
434
|
+
`autoFill` keeps the unoccupied responsive tracks so one or two tiles retain
|
|
435
|
+
their shared track width rather than expanding across an otherwise empty row.
|
|
436
|
+
It requires `minColumnWidth`; the default `auto-fit` keeps the existing form
|
|
437
|
+
behavior. When Grid is a direct child of a flex-owned `ListInsetControl`, pass
|
|
438
|
+
`flex` so the Grid takes the available row width instead of shrink-wrapping.
|
|
439
|
+
Grid is layout-only and adds no ARIA grid role. The application owns child
|
|
440
|
+
semantics.
|
|
421
441
|
Use application-owned CSS grid for intrinsic, asymmetric, spanning, or masonry
|
|
422
442
|
tracks, and use `ResizableRegion` when people must adjust a boundary.
|
|
423
443
|
|
package/docs/surface-scaffold.md
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
`DialogSurface` and `PopupSurface` configure recurring Web Awesome surface
|
|
4
4
|
geometry without application `::part()` overrides. They do not replace Web
|
|
5
|
-
Awesome behavior: the application still owns open state,
|
|
6
|
-
|
|
5
|
+
Awesome behavior: the application still owns open state, dismissal policy, ids,
|
|
6
|
+
labels, and content. With `@kerfjs/ui/popup-menu/register` imported, a dropdown
|
|
7
|
+
inside `PopupSurface` also keeps keyboard item navigation made during its show
|
|
8
|
+
animation when Web Awesome completes its initial focus handoff.
|
|
7
9
|
|
|
8
10
|
Wrap one `wa-dialog` with `DialogSurface`. Choose `size` (`small`, `medium`, or
|
|
9
11
|
`large`), `presentation` (`modal`, `side-sheet`, or `fullscreen`), and independent
|
|
@@ -22,4 +24,5 @@ Wrap one `PopupMenu` (or another single `wa-dropdown`) with `PopupSurface`. `ins
|
|
|
22
24
|
padding for a child that already owns row insets, `compact` uses 4px, and
|
|
23
25
|
`standard` uses the shared 8px surface inset. Keep the dropdown trigger named and
|
|
24
26
|
preserve `data-morph-skip-children` when its upgraded light-DOM items must retain
|
|
25
|
-
identity across Kerf rerenders.
|
|
27
|
+
identity across Kerf rerenders. Import `@kerfjs/ui/popup-menu/register` once for
|
|
28
|
+
the focus handoff fix when wrapping a raw `wa-dropdown`.
|
package/docs/ux-demo.md
CHANGED
|
@@ -22,6 +22,7 @@ deterministic state, and semantic layout owners from the [recipe guide](./recipe
|
|
|
22
22
|
|
|
23
23
|
- It imports public component subpaths, exercising their browser-selected reachable CSS rather than a catalog-only style path.
|
|
24
24
|
- The `ListActionRow` route demonstrates sibling primary/trailing native controls, independent disabled states, controlled selection, first-line leading-icon alignment for wrapped labels, and an application-owned native popover relationship without nesting controls. The `ListItem` route demonstrates the same multiline leading-icon anchor alongside its single-control navigation contract.
|
|
25
|
+
- The `PopupMenu` route's context example opens one app-owned menu either at the row's right-click point or below its adjacent, keyboard-operable Demand actions button. Its interactive row/button composition opts out of the catalog geometry overlay so the overlay's border and margin highlights do not masquerade as a row inset during activation. The Nested decisions example shows the automatic phone-width submenu placement above or below its parent list, with native ArrowLeft return, Escape dismissal, and child selection.
|
|
25
26
|
- The `AppTab` and `TabBar` routes are focused component specimens: AppTab shows its selected, compact, segmented, icon-only, truncation, placeholder, pending, metadata, and close-icon axes inside the required tablist context; TabBar shows its rail, segmented, inspector, allocation, placement, and accessory-zone axes, including an adjacent action plus a separately pinned end action whose tabs overflow at narrow widths, without application readouts. The separate `Application tabs` composition route demonstrates controlled selection, matching panel content, overflow, adding (a new tab opens `pending` with a spinner and stays selectable while its panel shows a `Skeleton` heading until a simulated load completes), closing, keyboard/pointer reordering, and application-owned ordering. The `ResizableRegion` route likewise replaces only the decorative handle glyph while retaining separator semantics and shared wiring.
|
|
26
27
|
- Every first-party visual component and every free Web Awesome 3.12 component has its own stable `?component=<id>` URL and focused demo. Composite header, menu, and feedback scenarios remain addressable alongside their subcomponents; the root opens the first Kerf component. The former aggregate Web Awesome theme specimen is intentionally omitted because its component families are covered by those focused routes.
|
|
27
28
|
- `ai/component-catalog.json` is the canonical catalog metadata. A deterministic checked-in projection supplies the demo's unique id, category, kind (`component`, `composition`, or `recipe`), source (`kerf` or `webawesome`), name, description, recommendation, direct `uses` dependencies, existing documentation path, and demo-source path; first-party, recipe, and Web Awesome renderer maps are exhaustively typed against its generated id unions. Functional groups follow their authored importance order; components precede compositions inside each group, equal-importance entries use alphabetical order, and the Recipes group comes last. Composition names stay concise and project a visible `Composition` sidebar tag. Non-supported Web Awesome recommendations project to a visible `Discouraged` tag, with Popup as the deliberate conditional exception. Demo paths resolve to the matching `ui/ux-demo/demos/<id>.tsx` or `ui/ux-demo/recipes/*.tsx` file, or to `ui/ux-demo/webawesome-demos.tsx` for Web Awesome entries. `ui/ux-demo/main.tsx` owns only the catalog shell, shared state, routing, and interaction wiring. First-party component entries additionally derive `ui/src/<public-subpath>.tsx` from their canonical `delivery.browserImport` or opt-in `delivery.moduleImport`.
|
package/docs/workbench.md
CHANGED
|
@@ -379,7 +379,11 @@ const stop = wireWorkbench(root, {
|
|
|
379
379
|
full-size overlay over the work area rather than squeezing beside it (see
|
|
380
380
|
the catalog's resizable and responsive-drawer Workbench examples).
|
|
381
381
|
A numeric value measures the Workbench container, not the viewport. If the
|
|
382
|
-
|
|
382
|
+
app has no numeric Workbench breakpoint, the overlay wiring does not measure
|
|
383
|
+
the Workbench on ordinary panel updates. For numeric breakpoints the wiring
|
|
384
|
+
mirrors the active panel state onto the Workbench root, keeping work-area
|
|
385
|
+
styles local to actual overlay transitions. If the rest of an app switches
|
|
386
|
+
by viewport width and its Workbench can be narrower
|
|
383
387
|
than the viewport, keep the app's viewport decision in
|
|
384
388
|
`presentation: "overlay"` and pass its `collapsed` signals to
|
|
385
389
|
`wireWorkbench`. On entering that mode, collapse the panels; after leaving,
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/content-item.tsx"],"names":[],"mappings":";;;AAWA,IAAM,8BAAA,mBAAiC,IAAI,GAAA,CAAI,CAAC,gBAAgB,CAAC,CAAA;AACjE,IAAM,8BAAA,uBAAqC,GAAA,CAAI;AAAA,EAC7C,gBAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAC,CAAA;AA+EM,SAAS,WAAA,CAAY;AAAA,EAC1B,QAAA;AAAA,EACA,KAAA,GAAQ,MAAA;AAAA,EACR,KAAA,GAAQ,SAAA;AAAA,EACR,SAAA;AAAA,EACA,WAAA,GAAc,KAAA;AAAA,EACd,WAAA,GAAc,KAAA;AAAA,EACd,MAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA,GAAgB,MAAA;AAAA,EAChB,QAAA,GAAW,KAAA;AAAA,EACX,QAAA,GAAW,KAAA;AAAA,EACX,SAAA,GAAY,EAAA;AAAA,EACZ,iBAAiB,EAAC;AAAA,EAClB;AACF,CAAA,EAAqB;AACnB,EAAA,MAAM,kBAAA,G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gBACE,WAAA,IAAe,aAAA,KAAkB,QAAA,GAAW,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAAA,MAEjE,eAAA,EAAe,WAAA,IAAe,QAAA,GAAW,MAAA,GAAS,MAAA;AAAA,MAClD,UACE,WAAA,GAAe,QAAA,GAAW,IAAA,GAAO,GAAA,GAAO,cAAc,IAAA,GAAO,MAAA;AAAA,MAE/D,IAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"chunk-7AKGPBCC.js","sourcesContent":["import { filterDataAttributes } from './extension-attributes.js';\nimport type { KerfUiContent } from './semantic-content.js';\n\n/** Whether the item's always-reserved 1px border is transparent or visible. */\nexport type ContentItemFrame = 'none' | 'framed';\n\n/** Corner shape: the 12px rounded rectangle or the 22px pill. */\nexport type ContentItemShape = 'rounded' | 'pill';\n/** `single` uses option selection; `toggle` uses a pressed button. */\nexport type ContentItemSelectionMode = 'none' | 'single' | 'toggle';\n\nconst contentItemProtectedAttributes = new Set(['data-component']);\nconst interactiveProtectedAttributes = new Set([\n 'data-component',\n 'data-action',\n 'data-item-id',\n 'data-interactive',\n 'data-selected',\n 'data-disabled',\n 'data-selection-mode',\n 'data-kui-pressed',\n]);\n\ntype ContentItemRootAttributes = Readonly<\n Record<`data-${string}`, string | undefined> & {\n 'data-component'?: never;\n }\n>;\n\ntype ContentItemInteractiveRootAttributes = Readonly<\n Record<`data-${string}`, string | undefined> & {\n 'data-component'?: never;\n 'data-action'?: never;\n 'data-item-id'?: never;\n 'data-interactive'?: never;\n 'data-selected'?: never;\n 'data-disabled'?: never;\n 'data-selection-mode'?: never;\n 'data-kui-pressed'?: never;\n }\n>;\n\ninterface ContentItemBaseProps {\n /** Item content; a plain string is allowed for bare copy. */\n children?: KerfUiContent | string;\n /**\n * `framed` paints the standard neutral border in the 1px the item always\n * reserves, so framing never changes geometry. Frame only an item that\n * marks a real distinction. Defaults to `none` (transparent border).\n */\n frame?: ContentItemFrame;\n /** Corner shape. Defaults to `rounded`. */\n shape?: ContentItemShape;\n /**\n * Names the item as a distinct region (`role=\"region\"`). Omit it for an\n * ordinary item, which stays a non-landmark grouping.\n */\n ariaLabel?: string;\n /**\n * Makes the item a programmatic focus target (`tabindex=\"-1\"`, never a tab\n * stop), for example the preferred initial focus of a NavStack view when\n * combined with `data-nav-focus` in `rootAttributes`.\n */\n focusTarget?: boolean;\n className?: string;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\nexport type ContentItemProps = ContentItemBaseProps &\n (\n | {\n interactive?: false;\n action?: never;\n itemId?: never;\n selectionMode?: never;\n selected?: never;\n disabled?: never;\n /** Existing static `data-*` metadata remains available. */\n rootAttributes?: ContentItemRootAttributes;\n }\n | {\n /** Enable a keyboard reachable card; wire `wireContentItems` once on its containing root. */\n interactive: true;\n /** Delegated action dispatched by pointer, Enter, or Space. */\n action: string;\n itemId?: string;\n selectionMode?: ContentItemSelectionMode;\n selected?: boolean;\n disabled?: boolean;\n /** Safe app metadata; interaction attributes are component-owned. */\n rootAttributes?: ContentItemInteractiveRootAttributes;\n }\n );\n\n/**\n * One self-contained `.kui-content` child: an 8px inline margin, a real 1px\n * border (transparent unless `framed`), 8px padding, and a rounded or pill\n * radius. It owns that whole geometry, so wrappers must not add more.\n */\nexport function ContentItem({\n children,\n frame = 'none',\n shape = 'rounded',\n ariaLabel,\n focusTarget = false,\n interactive = false,\n action,\n itemId,\n selectionMode = 'none',\n selected = false,\n disabled = false,\n className = '',\n rootAttributes = {},\n slot,\n}: ContentItemProps) {\n const safeRootAttributes = filterDataAttributes(\n rootAttributes,\n interactive\n ? interactiveProtectedAttributes\n : contentItemProtectedAttributes,\n );\n if (interactive && !action) {\n throw new Error('Interactive ContentItem requires an action');\n }\n if (interactive && selected && selectionMode === 'none') {\n throw new Error('Selected ContentItem requires a selectionMode');\n }\n const cls = [\n 'kui-content-item',\n shape === 'pill' ? 'kui-content-item--pill' : '',\n frame === 'framed' ? 'kui-content-item--framed' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n const interactiveAttributes = interactive\n ? {\n 'data-interactive': 'true',\n 'data-action': disabled ? undefined : action,\n 'data-item-id': itemId,\n 'data-selection-mode': selectionMode,\n 'data-selected':\n selectionMode === 'none' ? undefined : String(selected),\n 'data-disabled': disabled ? 'true' : undefined,\n }\n : {};\n return (\n <div\n {...safeRootAttributes}\n {...interactiveAttributes}\n class={cls}\n data-component=\"content-item\"\n role={\n interactive\n ? selectionMode === 'single'\n ? 'option'\n : 'button'\n : ariaLabel\n ? 'region'\n : undefined\n }\n aria-label={ariaLabel}\n aria-selected={\n interactive && selectionMode === 'single' ? String(selected) : undefined\n }\n aria-pressed={\n interactive && selectionMode === 'toggle' ? String(selected) : undefined\n }\n aria-disabled={interactive && disabled ? 'true' : undefined}\n tabindex={\n interactive ? (disabled ? '-1' : '0') : focusTarget ? '-1' : undefined\n }\n slot={slot}\n >\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/workbench-overlays.ts","../src/wire-workbench.ts"],"names":["active","element","panel","inside","effect","selector"],"mappings":";;;;AAkBA,IAAM,eAAA,GAAqD;AAAA,EACzD,QAAA,EAAU,uCAAA;AAAA,EACV,SAAA,EAAW,wCAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAEA,IAAM,cAAA,GAAoD;AAAA,EACxD,QAAA,EAAU,MAAA;AAAA,EACV,SAAA,EAAW,OAAA;AAAA,EACX,YAAA,EAAc;AAChB,CAAA;AAEA,IAAM,SAAA,GACJ,iJAAA;AAUF,IAAM,UAAA,GAAa,CAAC,OAAA,KAClB,CAAC,GAAG,OAAA,CAAQ,gBAAA,CAA8B,SAAS,CAAC,CAAA,CAAE,MAAA;AAAA,EACpD,CAAC,OAAA,KACC,OAAO,QAAQ,eAAA,KAAoB,UAAA,IACnC,QAAQ,eAAA;AACZ,CAAA;AAwCK,SAAS,qBAAA,CACd,IAAA,EACA,aAAA,EACA,MAAA,EACA,Y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,IAAA,UAAA,IAAa;AACb,IAAA,UAAA,GAAa,MAAA;AACb,IAAA,KAAA,MAAW,OAAA,IAAW,SAAA,CAAU,MAAA,CAAO,CAAC,GAAG,OAAA,EAAQ;AAAA,EACrD,CAAA;AACF","file":"chunk-OBAFAH5B.js","sourcesContent":["// The transient-overlay behavior `wireWorkbench` gives Workbench panels that\n// present as overlays: a responsive overlay starts collapsed when its\n// breakpoint begins to apply, an open overlay takes focus and keeps Tab inside\n// it, and it closes on Escape or a press outside it. It mirrors `wireSidebar`'s\n// compact overlay (the ARIA dialog pattern). Internal.\n\nimport { effect, type Signal } from 'kerfjs';\n\nimport type { WorkbenchPanelKey } from './workbench-resize.js';\n\n/** A Workbench panel whose app-owned `collapsed` signal the wiring may write. */\nexport interface WorkbenchOverlayPanel {\n key: WorkbenchPanelKey;\n collapsed: Signal<boolean>;\n keepOpenOn?: (target: Node) => boolean;\n}\n\n/** Each panel's own element, never a nested Workbench's. */\nconst PANEL_SELECTORS: Record<WorkbenchPanelKey, string> = {\n leftRail: ':scope > [data-workbench-rail=\"left\"]',\n rightRail: ':scope > [data-workbench-rail=\"right\"]',\n bottomDrawer: ':scope > .kui-workbench__center > [data-workbench-drawer]',\n};\n\nconst RESTORE_PANELS: Record<WorkbenchPanelKey, string> = {\n leftRail: 'left',\n rightRail: 'right',\n bottomDrawer: 'bottom',\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\n/**\n * The panel's focusable controls, in tab order. Only an open panel is ever\n * asked. The selector drops disabled controls and `tabindex=\"-1\"`; a\n * rendered control the CSS hides (the separator of a panel whose responsive\n * overlay breakpoint applies is `display: none`) is dropped too, or Tab would\n * wrap from a control focus can never reach. Where `checkVisibility` is\n * missing, every matched control counts.\n */\nconst focusables = (element: HTMLElement): HTMLElement[] =>\n [...element.querySelectorAll<HTMLElement>(FOCUSABLE)].filter(\n (control) =>\n typeof control.checkVisibility !== 'function' ||\n control.checkVisibility(),\n );\n\n/**\n * Wire transient overlay behavior for the given panels of the Workbench that\n * `findWorkbench` returns (looked up on use, so the Workbench may render after\n * wire-up). The app still owns each `collapsed` signal; this wiring only\n * writes it:\n *\n * - When a panel's `responsiveOverlayAt` breakpoint begins to apply (at\n * wire-up, on first render, or on a crossing), its inline collapsed state is\n * remembered and the panel collapses, so no overlay covers the work area\n * until the user opens it. When the breakpoint stops applying (or on\n * disposal) the remembered state comes back. These presentation changes\n * skip the collapse motion.\n * - A panel that opens while it presents as an overlay takes focus: its\n * first focusable control (else the panel itself) is focused, without\n * scrolling its sliding content. While an overlay is open, Tab and\n * Shift+Tab cycle through the controls of the overlay that holds focus\n * (else the most recently opened one) and never reach the work area it\n * covers — the ARIA dialog pattern `wireSidebar`'s compact overlay follows.\n * Inline panels are left alone.\n * - Escape closes the open overlay panel that holds focus, else the most\n * recently opened one; a press that starts and ends outside an open overlay\n * panel closes it. Static `presentation: \"overlay\"` panels are included.\n * - Focus stranded in a panel that closes — however it closed, including\n * through the app's own control inside it — returns to the control that\n * had it when the panel opened, else to the panel's restore control, else\n * to a control outside it whose `aria-controls` names the panel (or an\n * element inside it). The last covers a panel that was already open at\n * wire-up, which has no recorded opener. Focus a press inside the panel\n * dropped to the body counts as stranded too: Safari and macOS WebKit\n * never focus a clicked button, so pressing the panel's own close control\n * blurs the focused control before the click closes the panel. Focus the\n * user has since moved to any element is left where it is.\n * - With `exclusive`, a panel that opens while it presents as an overlay\n * closes every other open overlay panel, so overlays never cover each\n * other's controls. Inline panels are never closed by it.\n *\n * Returns a disposer.\n */\nexport function wireWorkbenchOverlays(\n root: HTMLElement,\n findWorkbench: () => HTMLElement | null,\n panels: readonly WorkbenchOverlayPanel[],\n exclusive = false,\n): () => void {\n const ownerDocument = root.ownerDocument;\n const disposers: Array<() => void> = [];\n // Open panels, most recently opened last, and each one's opener: the\n // control that had focus when it opened.\n const openOrder: WorkbenchOverlayPanel[] = [];\n const openers = new Map<WorkbenchOverlayPanel, HTMLElement>();\n // The open panel the latest press started in while focus was inside it,\n // until focus next lands anywhere. Safari and macOS WebKit never focus a\n // clicked button, so pressing a panel's own close control blurs the focused\n // control to the body before the click closes the panel; this is how the\n // close still counts as leaving focus stranded in it.\n let pressedFocus: WorkbenchOverlayPanel | undefined;\n /**\n * The `aria-controls` control a click just activated, kept for a couple of\n * frames: the toggle a panel opens or closes from, even once the app's\n * render has removed it.\n */\n let activated: HTMLElement | undefined;\n\n const panelElement = (panel: WorkbenchOverlayPanel): HTMLElement | null =>\n findWorkbench()?.querySelector<HTMLElement>(PANEL_SELECTORS[panel.key]) ??\n null;\n /** Whether the panel's responsive overlay breakpoint currently applies. */\n const responsive = (element: HTMLElement): boolean =>\n element.dataset.presentation === 'inline' &&\n element.hasAttribute('data-responsive-overlay-at') &&\n globalThis.getComputedStyle(element).position === 'absolute';\n const overlaid = (element: HTMLElement): boolean =>\n element.dataset.presentation === 'overlay' || responsive(element);\n\n /** Where focus goes when a panel it was in closes. */\n const restoreTarget = (\n panel: WorkbenchOverlayPanel,\n element: HTMLElement | null,\n ): HTMLElement | undefined => {\n const opener = openers.get(panel);\n // An opener inside another panel that has closed since (an exclusive\n // overlay closes the one it was opened from) would strand focus there too.\n if (\n opener?.isConnected &&\n !element?.contains(opener) &&\n !panels.some(\n (other) =>\n other.collapsed.peek() && panelElement(other)?.contains(opener),\n )\n )\n return opener;\n const side = RESTORE_PANELS[panel.key];\n const restore = findWorkbench()\n ?.querySelector<HTMLElement>(\n `.kui-workbench__restore[data-panel=\"${side}\"]`,\n )\n ?.querySelector<HTMLElement>(FOCUSABLE);\n return restore ?? (element ? controller(element) : undefined);\n };\n /**\n * A control outside the panel that names it, or an element inside it, in\n * its `aria-controls`: the app's toggle for a panel with no opener.\n */\n const controller = (element: HTMLElement): HTMLElement | undefined => {\n const ids = new Set(\n [element, ...element.querySelectorAll('[id]')].map((node) => node.id),\n );\n ids.delete('');\n return [\n ...ownerDocument.querySelectorAll<HTMLElement>('[aria-controls]'),\n ].find(\n (control) =>\n !element.contains(control) &&\n control.matches(FOCUSABLE) &&\n control\n .getAttribute('aria-controls')!\n .split(/\\s+/)\n .some((id) => ids.has(id)),\n );\n };\n /** Whether a control's `aria-controls` (always present) names panel `id`. */\n const namesPanel = (control: Element, id: string): boolean =>\n control.getAttribute('aria-controls')!.split(/\\s+/).includes(id);\n /** The panel's own control for itself: its toggle inside it. */\n const controlInside = (element: HTMLElement): HTMLElement | undefined =>\n [...element.querySelectorAll<HTMLElement>('[aria-controls]')].find(\n (control) =>\n control.matches(FOCUSABLE) && namesPanel(control, element.id),\n );\n const rescueFocus = (panel: WorkbenchOverlayPanel): void => {\n const element = panelElement(panel);\n const target = restoreTarget(panel, element);\n if (target) {\n target.focus();\n return;\n }\n // An app that renders its restore control after this write has not\n // produced it yet; look again once the current batch settles.\n globalThis.queueMicrotask(() => {\n if (!panel.collapsed.peek()) return;\n const later = restoreTarget(panel, panelElement(panel));\n const active = ownerDocument.activeElement;\n if (later) later.focus();\n else if (active instanceof HTMLElement && element?.contains(active))\n active.blur();\n });\n };\n\n /**\n * A presentation-driven write: no collapse motion, because nothing the user\n * did moved the panel. The app's render has normally applied the new state\n * by the time the write returns, so the content's transition is suspended\n * across one style flush.\n */\n const adapt = (\n panel: WorkbenchOverlayPanel,\n element: HTMLElement,\n collapsed: boolean,\n ): void => {\n if (panel.collapsed.peek() === collapsed) return;\n const stranded = collapsed && element.contains(ownerDocument.activeElement);\n panel.collapsed.value = collapsed;\n // Every Workbench panel renders its content wrapper, and never with a\n // style of its own, so the attribute goes again once the flush is done.\n const content = element.querySelector<HTMLElement>(\n ':scope > .kui-workbench__panel-content',\n )!;\n content.style.transition = 'none';\n void globalThis.getComputedStyle(content).transform;\n content.removeAttribute('style');\n // The collapse effect has normally returned the focus already; on\n // disposal, after the effects are gone, this is what returns it.\n if (stranded && element.contains(ownerDocument.activeElement))\n rescueFocus(panel);\n };\n\n // The inline collapsed state of each panel whose responsive overlay\n // currently applies, restored when it stops applying.\n const inlineState = new Map<WorkbenchOverlayPanel, boolean>();\n const sync = (): void => {\n const workbench = findWorkbench();\n const width = workbench?.getBoundingClientRect().width ?? 0;\n for (const panel of panels) {\n const element = panelElement(panel);\n if (!element) continue;\n // CSS container queries cannot take a runtime pixel value. For a\n // numeric threshold the same measured Workbench width drives the CSS\n // presentation hook and the collapsed-state transition below.\n const at = Number(element.dataset.responsiveOverlayAt);\n const custom =\n element.dataset.responsiveOverlayAt !== undefined &&\n Number.isFinite(at) &&\n at > 0;\n const customActive =\n custom && element.dataset.presentation === 'inline' && width <= at;\n if (customActive) {\n if (element.dataset.responsiveOverlayActive !== 'true')\n element.dataset.responsiveOverlayActive = 'true';\n } else if (element.hasAttribute('data-responsive-overlay-active'))\n element.removeAttribute('data-responsive-overlay-active');\n const active = responsive(element);\n if (active && !inlineState.has(panel)) {\n inlineState.set(panel, panel.collapsed.peek());\n adapt(panel, element, true);\n } else if (!active && inlineState.has(panel)) {\n const remembered = inlineState.get(panel)!;\n inlineState.delete(panel);\n adapt(panel, element, remembered);\n }\n // A signal write can patch or replace the panel synchronously. Preserve\n // the measured presentation marker on the rendered element too.\n const rendered = panelElement(panel);\n if (\n rendered &&\n customActive &&\n rendered.dataset.responsiveOverlayActive !== 'true'\n )\n rendered.dataset.responsiveOverlayActive = 'true';\n }\n };\n\n // The Workbench is its own breakpoint container, so its size is what moves a\n // panel across the breakpoint. It may render after wire-up or be replaced,\n // and the app may change a presentation, so both are observed too.\n let observed: HTMLElement | null = null;\n const resizeObserver =\n typeof globalThis.ResizeObserver === 'function'\n ? new globalThis.ResizeObserver(() => sync())\n : undefined;\n /** Observe the current Workbench; whether it changed. */\n const track = (): boolean => {\n const workbench = findWorkbench();\n if (workbench === observed) return false;\n if (observed) resizeObserver?.unobserve(observed);\n observed = workbench;\n if (workbench) resizeObserver?.observe(workbench);\n return true;\n };\n const mutationObserver = new MutationObserver((records) => {\n if (track() || records.some((record) => record.type === 'attributes'))\n sync();\n });\n mutationObserver.observe(root, {\n attributes: true,\n attributeFilter: [\n 'data-presentation',\n 'data-responsive-overlay-at',\n 'data-responsive-overlay-active',\n ],\n childList: true,\n subtree: true,\n });\n // The breakpoints are in rem, so a root font-size change (a text-size\n // setting applied after load) moves a panel across them without resizing\n // the Workbench. A 1rem probe outside the app's tree reports that change.\n const remProbe = ownerDocument.createElement('div');\n remProbe.setAttribute('aria-hidden', 'true');\n remProbe.style.cssText =\n 'position:absolute;width:1rem;height:0;overflow:hidden;visibility:hidden;pointer-events:none';\n if (resizeObserver) {\n ownerDocument.body.append(remProbe);\n resizeObserver.observe(remProbe);\n }\n disposers.push(() => {\n mutationObserver.disconnect();\n resizeObserver?.disconnect();\n remProbe.remove();\n });\n track();\n sync();\n\n for (const panel of panels) {\n let previous = panel.collapsed.peek();\n if (!previous) openOrder.push(panel);\n disposers.push(\n effect(() => {\n const collapsed = panel.collapsed.value;\n if (collapsed === previous) return;\n previous = collapsed;\n const index = openOrder.indexOf(panel);\n if (index >= 0) openOrder.splice(index, 1);\n if (collapsed) {\n // Whatever closed the panel — Escape, an outside press, a\n // breakpoint, or the app's own control inside it — focus left in\n // it would be stranded in a hidden panel. So would focus that a\n // press inside it dropped to the body (see `pressedFocus`).\n const active = ownerDocument.activeElement;\n const element = panelElement(panel);\n if (\n element?.contains(active) ||\n // The panel's own control closed it (focused or not), so hand\n // focus to the control that reopens it.\n (activated !== undefined && element?.contains(activated)) ||\n (pressedFocus === panel &&\n (active === null || active === ownerDocument.body))\n )\n rescueFocus(panel);\n return;\n }\n openOrder.push(panel);\n const element = panelElement(panel);\n const active = ownerDocument.activeElement;\n if (\n active instanceof HTMLElement &&\n active !== ownerDocument.body &&\n !element?.contains(active)\n )\n openers.set(panel, active);\n else openers.delete(panel);\n // A focused toggle the app's render removes as the panel opens — a\n // Workbench toolbar toggle leaves the work-area toolbar for the\n // panel's own — would drop focus to the body. Hand it to the panel's\n // own control for it, so a keyboard user keeps their place. The\n // render may land before this effect (the toggle is gone already, so\n // the activated control stands in for the opener) or after it, in a\n // microtask or a later frame.\n const toggle =\n openers.get(panel) ??\n (activated && element && namesPanel(activated, element.id)\n ? activated\n : undefined);\n if (toggle) {\n const handOff = (frames: number): void => {\n const focused = ownerDocument.activeElement;\n if (panel.collapsed.peek()) return;\n if (toggle.isConnected) {\n if (toggle === focused && frames > 0)\n globalThis.requestAnimationFrame(() => handOff(frames - 1));\n return;\n }\n if (focused !== null && focused !== ownerDocument.body) return;\n const current = panelElement(panel);\n if (current) controlInside(current)?.focus({ preventScroll: true });\n };\n globalThis.queueMicrotask(() => handOff(5));\n }\n if (!element || !overlaid(element)) return;\n // Opening an overlay closes the others. Their collapse effects run\n // after this one, by which time focus has moved into this panel, so\n // none of them hands it back to an opener.\n if (exclusive)\n for (const [other] of openOverlays())\n if (other !== panel) other.collapsed.value = true;\n // An overlay covers the work area, so focus moves in with it rather\n // than staying on a control it may cover. Without preventScroll the\n // browser scrolls the panel's clipped, still-sliding content to reveal\n // the target, which then unwinds as the slide finishes.\n (focusables(element)[0] ?? element).focus({ preventScroll: true });\n }),\n );\n }\n\n /** The open overlay panels with their elements, most recent last. */\n const openOverlays = (): Array<[WorkbenchOverlayPanel, HTMLElement]> =>\n openOrder.flatMap((panel): Array<[WorkbenchOverlayPanel, HTMLElement]> => {\n const element = panelElement(panel);\n return !panel.collapsed.peek() && element && overlaid(element)\n ? [[panel, element]]\n : [];\n });\n\n const inAllowedPortal = (\n panel: WorkbenchOverlayPanel,\n path: EventTarget[],\n ): boolean => {\n const keepOpenOn = panel.keepOpenOn;\n return Boolean(\n keepOpenOn &&\n path.some((target) => target instanceof Node && keepOpenOn(target)),\n );\n };\n\n const onKeydown = (event: KeyboardEvent): void => {\n if (\n (event.key !== 'Escape' && event.key !== 'Tab') ||\n event.defaultPrevented\n )\n return;\n const open = openOverlays();\n if (open.length === 0) return;\n // A dialog or menu launched from a panel owns its own keyboard handling.\n if (open.some(([panel]) => inAllowedPortal(panel, event.composedPath())))\n return;\n const active = ownerDocument.activeElement;\n const [panel, element] =\n open.find(([, candidate]) => candidate.contains(active)) ??\n open[open.length - 1]!;\n if (event.key === 'Escape') {\n event.preventDefault();\n // The collapse effect returns focus stranded inside it.\n panel.collapsed.value = true;\n return;\n }\n // Tab stays inside the open overlay: it wraps at either end, and focus\n // that is somewhere else (the app moved it, or the panel had no control\n // to take it when it opened) comes back in.\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 inside = element.contains(active);\n if (event.shiftKey && (!inside || active === first)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && (!inside || active === last)) {\n event.preventDefault();\n first.focus();\n }\n };\n\n // An outside press closes an open overlay when it both starts and ends\n // outside it. Deciding at the click lets an app toggle that closes the panel\n // run first, and a press that opens a panel never closes it.\n let pressed: WorkbenchOverlayPanel[] = [];\n const inside = (\n panel: WorkbenchOverlayPanel,\n element: HTMLElement,\n path: EventTarget[],\n ): boolean => path.includes(element) || inAllowedPortal(panel, path);\n const onPointerdown = (event: PointerEvent): void => {\n const path = event.composedPath();\n pressed = openOverlays()\n .filter(([panel, element]) => !inside(panel, element, path))\n .map(([panel]) => panel);\n // Before the press's default action moves focus: the open panel it\n // started in, when focus was inside that panel too.\n const active = ownerDocument.activeElement;\n pressedFocus = panels.find((panel) => {\n if (panel.collapsed.peek()) return false;\n const element = panelElement(panel);\n return !!element && path.includes(element) && element.contains(active);\n });\n };\n // Focus landing anywhere is a deliberate move the rescue must not undo.\n const onFocusin = (): void => {\n pressedFocus = undefined;\n };\n const onClick = (event: MouseEvent): void => {\n const candidates = pressed;\n pressed = [];\n const path = event.composedPath();\n for (const [panel, element] of openOverlays())\n if (candidates.includes(panel) && !inside(panel, element, path))\n panel.collapsed.value = true;\n };\n const onActivate = (event: MouseEvent): void => {\n const target = event.target;\n const control =\n target instanceof Element\n ? target.closest<HTMLElement>('[aria-controls]')\n : null;\n // Recorded whether or not it took focus: Safari and macOS WebKit never\n // focus a clicked button.\n if (!control) return;\n activated = control;\n // The collapse effect may run after the click's dispatch (the app can\n // batch its write), so keep the control for a couple of frames.\n globalThis.requestAnimationFrame(() =>\n globalThis.requestAnimationFrame(() => {\n if (activated === control) activated = undefined;\n }),\n );\n };\n ownerDocument.addEventListener('keydown', onKeydown);\n ownerDocument.addEventListener('pointerdown', onPointerdown, true);\n ownerDocument.addEventListener('click', onActivate, true);\n ownerDocument.addEventListener('click', onClick);\n ownerDocument.addEventListener('focusin', onFocusin, true);\n disposers.push(() => {\n ownerDocument.removeEventListener('keydown', onKeydown);\n ownerDocument.removeEventListener('pointerdown', onPointerdown, true);\n ownerDocument.removeEventListener('click', onActivate, true);\n ownerDocument.removeEventListener('click', onClick);\n ownerDocument.removeEventListener('focusin', onFocusin, true);\n });\n\n return () => {\n for (const dispose of disposers.splice(0)) dispose();\n for (const panel of panels)\n panelElement(panel)?.removeAttribute('data-responsive-overlay-active');\n // After every observer and effect is gone, so handing the inline state\n // back cannot re-enter the wiring.\n for (const [panel, remembered] of inlineState) {\n const element = panelElement(panel);\n if (element) adapt(panel, element, remembered);\n else panel.collapsed.value = remembered;\n }\n inlineState.clear();\n };\n}\n","import { effect, type ReadonlySignal, type Signal } from 'kerfjs';\n\nimport type { DeviceClass } from './device-class.js';\nimport { type ResizeLimit, wireResizeHandles } from './resize-wiring.js';\nimport {\n wireWorkbenchOverlays,\n type WorkbenchOverlayPanel,\n} from './workbench-overlays.js';\nimport {\n type WorkbenchPanelKey,\n workbenchRegionId,\n} from './workbench-resize.js';\n\nexport type { WorkbenchPanelKey };\n\n/** Minimal `localStorage`-shaped store, so the persistence hook is testable. */\nexport interface WorkbenchStorage {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n}\n\n/** One Workbench panel's app-owned state. */\nexport interface WireWorkbenchPanel {\n /**\n * The app-owned size signal a `resizable` panel renders as its `size`.\n * `wireWorkbench` writes each committed resize here; collapsing never\n * touches it, so an expanded panel returns at the size it had. Omit it for\n * a panel that is not resizable.\n */\n size?: Signal<number>;\n /**\n * When set with `size`, the size is loaded from and saved to `storage`\n * under this key, so the panel remembers the user's size.\n */\n storageKey?: string;\n /**\n * The app-owned signal the panel renders as its `collapsed`. With it (and\n * `dismissOverlays`, on by default) `wireWorkbench` treats the panel as a\n * transient overlay while it presents as one: it collapses when its\n * `responsiveOverlayAt` breakpoint begins to apply and gets its inline state\n * back when the breakpoint stops applying, an open overlay takes focus and\n * keeps Tab inside it, and it closes on Escape or a press outside it.\n */\n collapsed?: Signal<boolean>;\n /**\n * Treat presses in a portal surface launched by this panel (for example a\n * body-level menu or dialog) as inside it. The predicate receives each Node\n * in the press's composed path; return true for the portal root. Ordinary\n * presses outside the panel and its allowed surfaces still dismiss it.\n */\n keepOpenOn?: (target: Node) => boolean;\n}\n\n/** A resize the user made, after `wireWorkbench` wrote it to the size signal. */\nexport interface WorkbenchResize {\n panel: WorkbenchPanelKey;\n size: number;\n source: 'keyboard' | 'pointer';\n}\n\nexport interface WireWorkbenchOptions {\n /** The `id` the `Workbench` was rendered with. */\n id: string;\n /**\n * The wired panels, keyed like the `Workbench` props. Render a panel given\n * a `size` with `resizable` and `size={panel.size.value}`, and one given a\n * `collapsed` signal with `collapsed={panel.collapsed.value}`.\n */\n panels: Partial<Record<WorkbenchPanelKey, WireWorkbenchPanel>>;\n /**\n * When provided, resizing is suspended while `deviceClass.compact` is true —\n * the classes where rails become overlay drawers or are replaced.\n */\n deviceClass?: ReadonlySignal<DeviceClass>;\n /** Persistence store (default `globalThis.localStorage`, if present). */\n storage?: WorkbenchStorage;\n /** Keyboard step in px (default 16). */\n step?: number;\n /** Shift+arrow step in px (default 64). */\n largeStep?: number;\n /** Called after each committed resize. */\n onResize?: (change: WorkbenchResize) => void;\n /**\n * Treat the panels given a `collapsed` signal as transient overlays while\n * they present as overlays (default `true`), like `wireSidebar`'s compact\n * overlay: a panel whose `responsiveOverlayAt` breakpoint begins to apply\n * starts collapsed, with no collapse motion, and gets its inline collapsed\n * state back when the breakpoint stops applying (and on disposal); an open\n * overlay panel, responsive or `presentation: \"overlay\"`, closes on Escape\n * or a press that starts and ends outside it. A panel that opens as an\n * overlay takes focus on its first focusable control, and while it is open\n * Tab and Shift+Tab cycle through its controls instead of reaching the\n * work area it covers (the ARIA dialog pattern of `wireSidebar`'s compact\n * overlay); inline panels never move focus. Focus stranded in a closing\n * panel — however it closed, the app's own control inside it included —\n * returns to the control that had it when the panel opened, else to the\n * panel's restore control, else to a control outside the panel whose\n * `aria-controls` names it (each panel's `id` is its region id, e.g.\n * `studio-left-rail`) — the fallback for a panel already open at wire-up.\n * An opener inside a panel that has closed since is skipped. `false` leaves\n * every `collapsed` write and all focus handling to the app.\n */\n dismissOverlays?: boolean;\n /**\n * Keep overlays exclusive (default `true`), like `wireSidebar`'s\n * `exclusiveCompact`: when a panel opens while it presents as an overlay,\n * every other open overlay panel — rails and the bottom drawer alike —\n * closes, so one overlay never covers another's controls. Panels presenting\n * inline are never closed by it. Applies only with `dismissOverlays`.\n */\n exclusiveOverlays?: boolean;\n}\n\nfunction defaultStorage(): WorkbenchStorage | undefined {\n try {\n return globalThis.localStorage ?? undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A stored size, or undefined when the stored text is not a usable size. */\nfunction storedSize(text: string | null) {\n if (text === null) return undefined;\n const size = Number(text);\n return Number.isFinite(size) && size > 0 ? Math.round(size) : undefined;\n}\n\n/** A double-quoted CSS attribute-selector value. */\nconst quoted = (value: string) =>\n `\"${value.replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"')}\"`;\n\nconst px = (value: string) => Number.parseFloat(value) || 0;\n\n/**\n * The largest size a resizable panel may take while the work area keeps its\n * minimum: for a rail, its minimum width (the Workbench's `mainMinSize`,\n * rendered as `data-main-min-size`) — the Workbench width, less that minimum,\n * the other in-flow rails as shown, and the rail's own safe-area extent and\n * border; for the bottom drawer, its minimum height (`mainMinHeight`, rendered\n * as `data-main-min-height`) — the work-area column's height, less that\n * minimum and the drawer's own safe-area extent and border. A panel the\n * container has already squeezed is held at the size it shows, so it can\n * shrink but not grow. Without layout (no box yet) or a minimum, the panel's\n * own maximum stands.\n */\nconst mainRoomLimit: ResizeLimit = (region, { max }) => {\n const horizontal = region.dataset.axis === 'horizontal';\n // A rail's parent is the Workbench; the drawer's is the work-area column.\n const container = region.parentElement;\n const workbench = horizontal ? container : container?.parentElement;\n const mainMin = Number(\n horizontal\n ? workbench?.dataset.mainMinSize\n : workbench?.dataset.mainMinHeight,\n );\n if (!container || !(mainMin > 0)) return max;\n const box = container.getBoundingClientRect();\n const room = horizontal ? box.width : box.height;\n if (room <= 0) return max;\n let others = 0;\n if (horizontal)\n for (const rail of container.children) {\n if (\n rail === region ||\n !rail.matches('.kui-workbench__rail') ||\n globalThis.getComputedStyle(rail).position === 'absolute'\n )\n continue;\n others += rail.getBoundingClientRect().width;\n }\n const style = globalThis.getComputedStyle(region);\n const size = px(region.style.getPropertyValue('--kui-resizable-region-size'));\n const border =\n style.boxSizing === 'border-box'\n ? 0\n : horizontal\n ? px(style.borderInlineStartWidth) + px(style.borderInlineEndWidth)\n : px(style.borderBlockStartWidth) + px(style.borderBlockEndWidth);\n // The track is the size plus the panel's safe-area extent (its flex basis).\n const extent = px(style.flexBasis) - size + border;\n return Math.floor(room - Math.min(mainMin, room) - others - extent);\n};\n\n/**\n * Wire a `Workbench`'s panels. For `resizable` panels given a `size` signal:\n * pointer drags and arrow / Shift+arrow / Home / End on each panel's\n * separator, clamped to the panel's limits and to the room that leaves the\n * work area its minimum width and height, committed to the app-owned size signals.\n * Optional persistence loads and saves each size; optional `deviceClass`\n * suspends resizing on compact classes. Collapse stays the app's `collapsed`\n * flag and never changes a size. For panels given a `collapsed` signal,\n * overlays are transient (`dismissOverlays`): a responsive overlay starts\n * collapsed, an open overlay takes focus and keeps Tab inside it, it closes\n * on Escape or an outside press, and\n * opening one overlay closes the others (`exclusiveOverlays`). Returns a disposer. See `docs/23-app-layouts.md` §3.3.\n */\nexport function wireWorkbench(\n root: HTMLElement,\n {\n id,\n panels,\n deviceClass,\n storage = defaultStorage(),\n step,\n largeStep,\n onResize,\n dismissOverlays = true,\n exclusiveOverlays = true,\n }: WireWorkbenchOptions,\n): () => void {\n const keys = Object.keys(panels) as WorkbenchPanelKey[];\n const entries = keys.flatMap((key) => {\n const size = panels[key]?.size;\n return size\n ? [\n {\n key,\n size,\n storageKey: panels[key]!.storageKey,\n regionId: workbenchRegionId(id, key),\n },\n ]\n : [];\n });\n const byRegion = new Map(entries.map((entry) => [entry.regionId, entry]));\n const disposers: Array<() => void> = [];\n\n // Seed from storage before any effect runs, so the first render after\n // wire-up already has the remembered size; then mirror every size change.\n for (const { size, storageKey } of entries) {\n if (!storageKey || !storage) continue;\n const seed = storedSize(storage.getItem(storageKey));\n if (seed !== undefined) size.value = seed;\n disposers.push(\n effect(() => {\n storage.setItem(storageKey, String(size.value));\n }),\n );\n }\n\n // Each panel is matched by its own region id, so this wiring never drives a\n // ResizableRegion or another Workbench below the same root.\n const selector = entries\n .map(\n ({ regionId }) =>\n `[data-resizable=\"true\"][data-region-id=${quoted(regionId)}]`,\n )\n .join(', ');\n const start = () =>\n wireResizeHandles(\n root,\n {\n step,\n largeStep,\n onCommit: ({ id: regionId, size, source }) => {\n // The selector only matches configured panels.\n const entry = byRegion.get(regionId)!;\n entry.size.value = size;\n onResize?.({ panel: entry.key, size, source });\n },\n },\n selector,\n mainRoomLimit,\n );\n\n let stopResize: (() => void) | undefined;\n if (selector) {\n if (deviceClass) {\n disposers.push(\n effect(() => {\n const compact = deviceClass.value.compact;\n stopResize?.();\n stopResize = compact ? undefined : start();\n }),\n );\n } else {\n stopResize = start();\n }\n }\n\n const overlayPanels = keys.flatMap((key): WorkbenchOverlayPanel[] => {\n const collapsed = panels[key]?.collapsed;\n return collapsed\n ? [{ key, collapsed, keepOpenOn: panels[key]?.keepOpenOn }]\n : [];\n });\n if (dismissOverlays && overlayPanels.length > 0) {\n const selector = `[data-component=\"workbench\"][id=${quoted(id)}]`;\n disposers.push(\n wireWorkbenchOverlays(\n root,\n () =>\n root.matches(selector)\n ? root\n : root.querySelector<HTMLElement>(selector),\n overlayPanels,\n exclusiveOverlays,\n ),\n );\n }\n\n return () => {\n stopResize?.();\n stopResize = undefined;\n for (const dispose of disposers.splice(0)) dispose();\n };\n}\n"]}
|