@kerfjs/ui 5.0.0-beta.53 → 5.0.0-beta.54
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 +1 -0
- package/ai/application-ui-diagnostic-ids-v1.json +1 -0
- package/ai/component-catalog-v2.json +82 -6
- package/ai/component-catalog-v2.schema.json +2 -1
- package/ai/component-catalog.json +105 -10
- package/ai/public-api-signatures-v1.md +204 -18
- package/ai/skill.md +23 -17
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/index.mjs +48 -0
- package/analyzer/loud-pairs.d.mts +49 -0
- package/analyzer/loud-pairs.mjs +357 -0
- package/dist/app-tab.d.ts +7 -5
- package/dist/app-tab.js +1 -1
- package/dist/{chunk-EKYZCRCX.js → chunk-3CGQ7ZNO.js} +54 -22
- package/dist/chunk-3CGQ7ZNO.js.map +1 -0
- package/dist/{chunk-UKKSMZYT.js → chunk-46263QLK.js} +51 -1
- package/dist/chunk-46263QLK.js.map +1 -0
- package/dist/{chunk-NDUGJ4TU.js → chunk-5NDQABWK.js} +1 -1
- package/dist/{chunk-NDUGJ4TU.js.map → chunk-5NDQABWK.js.map} +1 -1
- package/dist/{chunk-CCMKJWLX.js → chunk-NE5JAOQS.js} +7 -7
- package/dist/chunk-NE5JAOQS.js.map +1 -0
- package/dist/chunk-PSHUSWQH.js +18 -0
- package/dist/chunk-PSHUSWQH.js.map +1 -0
- package/dist/{chunk-VOCPXGQN.js → chunk-VHADGP3B.js} +9 -8
- package/dist/chunk-VHADGP3B.js.map +1 -0
- package/dist/chunk-XQV2B4IL.js +14 -0
- package/dist/chunk-XQV2B4IL.js.map +1 -0
- package/dist/collapsible-panel.d.ts +6 -2
- package/dist/collapsible-panel.js +1 -0
- package/dist/collapsible-panel.js.map +1 -1
- package/dist/floating-toolbar.d.ts +5 -2
- package/dist/floating-toolbar.js +1 -1
- package/dist/index.js +6 -5
- package/dist/resizable-region.d.ts +4 -1
- package/dist/resizable-region.js +1 -1
- package/dist/split-view.js +1 -1
- package/dist/styles/collapsible-panel.css +88 -10
- package/dist/styles/floating-toolbar.css +11 -6
- package/dist/styles/resizable-region.css +81 -13
- package/dist/styles/workbench.css +472 -10
- package/dist/wire-resizable-regions.d.ts +2 -1
- package/dist/wire-resizable-regions.js +2 -1
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-workbench.d.ts +109 -0
- package/dist/wire-workbench.js +355 -0
- package/dist/wire-workbench.js.map +1 -0
- package/dist/workbench.d.ts +65 -6
- package/dist/workbench.js +180 -76
- package/dist/workbench.js.map +1 -1
- package/docs/accessibility.md +54 -9
- package/docs/app-layouts.md +12 -1
- package/docs/collapsible-panel.md +59 -1
- package/docs/component-selection.md +16 -6
- package/docs/document-baseline.md +4 -0
- package/docs/layout.md +5 -1
- package/docs/recipes.md +5 -3
- package/docs/type-contracts.md +2 -1
- package/docs/ui-analyzer.md +94 -19
- package/docs/ui-doctor.md +6 -0
- package/docs/ux-demo.md +1 -1
- package/docs/webawesome-theme.md +11 -2
- package/docs/workbench.md +302 -7
- package/llms.txt +7 -3
- package/package.json +5 -1
- package/ux-demo/recipes/collapsible-sidebar.tsx +8 -7
- package/dist/chunk-CCMKJWLX.js.map +0 -1
- package/dist/chunk-EKYZCRCX.js.map +0 -1
- package/dist/chunk-UKKSMZYT.js.map +0 -1
- package/dist/chunk-VOCPXGQN.js.map +0 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { workbenchRegionId } from './chunk-PSHUSWQH.js';
|
|
2
|
+
import { wireResizeHandles } from './chunk-3CGQ7ZNO.js';
|
|
3
|
+
|
|
4
|
+
import { effect } from 'kerfjs';
|
|
5
|
+
|
|
6
|
+
var PANEL_SELECTORS = {
|
|
7
|
+
leftRail: ':scope > [data-workbench-rail="left"]',
|
|
8
|
+
rightRail: ':scope > [data-workbench-rail="right"]',
|
|
9
|
+
bottomDrawer: ":scope > .kui-workbench__center > [data-workbench-drawer]"
|
|
10
|
+
};
|
|
11
|
+
var RESTORE_PANELS = {
|
|
12
|
+
leftRail: "left",
|
|
13
|
+
rightRail: "right",
|
|
14
|
+
bottomDrawer: "bottom"
|
|
15
|
+
};
|
|
16
|
+
var FOCUSABLE = 'a[href],area[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
17
|
+
var focusables = (element) => [...element.querySelectorAll(FOCUSABLE)].filter(
|
|
18
|
+
(control) => typeof control.checkVisibility !== "function" || control.checkVisibility()
|
|
19
|
+
);
|
|
20
|
+
function wireWorkbenchOverlays(root, findWorkbench, panels, exclusive = false) {
|
|
21
|
+
const ownerDocument = root.ownerDocument;
|
|
22
|
+
const disposers = [];
|
|
23
|
+
const openOrder = [];
|
|
24
|
+
const openers = /* @__PURE__ */ new Map();
|
|
25
|
+
let pressedFocus;
|
|
26
|
+
const panelElement = (panel) => findWorkbench()?.querySelector(PANEL_SELECTORS[panel.key]) ?? null;
|
|
27
|
+
const responsive = (element) => element.dataset.presentation === "inline" && element.hasAttribute("data-responsive-overlay-at") && globalThis.getComputedStyle(element).position === "absolute";
|
|
28
|
+
const overlaid = (element) => element.dataset.presentation === "overlay" || responsive(element);
|
|
29
|
+
const restoreTarget = (panel, element) => {
|
|
30
|
+
const opener = openers.get(panel);
|
|
31
|
+
if (opener?.isConnected && !element?.contains(opener) && !panels.some(
|
|
32
|
+
(other) => other.collapsed.peek() && panelElement(other)?.contains(opener)
|
|
33
|
+
))
|
|
34
|
+
return opener;
|
|
35
|
+
const side = RESTORE_PANELS[panel.key];
|
|
36
|
+
const restore = findWorkbench()?.querySelector(
|
|
37
|
+
`.kui-workbench__restore[data-panel="${side}"]`
|
|
38
|
+
)?.querySelector(FOCUSABLE);
|
|
39
|
+
return restore ?? (element ? controller(element) : void 0);
|
|
40
|
+
};
|
|
41
|
+
const controller = (element) => {
|
|
42
|
+
const ids = new Set(
|
|
43
|
+
[element, ...element.querySelectorAll("[id]")].map((node) => node.id)
|
|
44
|
+
);
|
|
45
|
+
ids.delete("");
|
|
46
|
+
return [
|
|
47
|
+
...ownerDocument.querySelectorAll("[aria-controls]")
|
|
48
|
+
].find(
|
|
49
|
+
(control) => !element.contains(control) && control.matches(FOCUSABLE) && control.getAttribute("aria-controls").split(/\s+/).some((id) => ids.has(id))
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
const rescueFocus = (panel) => {
|
|
53
|
+
const element = panelElement(panel);
|
|
54
|
+
const target = restoreTarget(panel, element);
|
|
55
|
+
if (target) {
|
|
56
|
+
target.focus();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
globalThis.queueMicrotask(() => {
|
|
60
|
+
if (!panel.collapsed.peek()) return;
|
|
61
|
+
const later = restoreTarget(panel, panelElement(panel));
|
|
62
|
+
const active = ownerDocument.activeElement;
|
|
63
|
+
if (later) later.focus();
|
|
64
|
+
else if (active instanceof HTMLElement && element?.contains(active))
|
|
65
|
+
active.blur();
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const adapt = (panel, element, collapsed) => {
|
|
69
|
+
if (panel.collapsed.peek() === collapsed) return;
|
|
70
|
+
const stranded = collapsed && element.contains(ownerDocument.activeElement);
|
|
71
|
+
panel.collapsed.value = collapsed;
|
|
72
|
+
const content = element.querySelector(
|
|
73
|
+
":scope > .kui-workbench__panel-content"
|
|
74
|
+
);
|
|
75
|
+
content.style.transition = "none";
|
|
76
|
+
void globalThis.getComputedStyle(content).transform;
|
|
77
|
+
content.removeAttribute("style");
|
|
78
|
+
if (stranded && element.contains(ownerDocument.activeElement))
|
|
79
|
+
rescueFocus(panel);
|
|
80
|
+
};
|
|
81
|
+
const inlineState = /* @__PURE__ */ new Map();
|
|
82
|
+
const sync = () => {
|
|
83
|
+
for (const panel of panels) {
|
|
84
|
+
const element = panelElement(panel);
|
|
85
|
+
if (!element) continue;
|
|
86
|
+
const active = responsive(element);
|
|
87
|
+
if (active && !inlineState.has(panel)) {
|
|
88
|
+
inlineState.set(panel, panel.collapsed.peek());
|
|
89
|
+
adapt(panel, element, true);
|
|
90
|
+
} else if (!active && inlineState.has(panel)) {
|
|
91
|
+
const remembered = inlineState.get(panel);
|
|
92
|
+
inlineState.delete(panel);
|
|
93
|
+
adapt(panel, element, remembered);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
let observed = null;
|
|
98
|
+
const resizeObserver = typeof globalThis.ResizeObserver === "function" ? new globalThis.ResizeObserver(() => sync()) : void 0;
|
|
99
|
+
const track = () => {
|
|
100
|
+
const workbench = findWorkbench();
|
|
101
|
+
if (workbench === observed) return false;
|
|
102
|
+
if (observed) resizeObserver?.unobserve(observed);
|
|
103
|
+
observed = workbench;
|
|
104
|
+
if (workbench) resizeObserver?.observe(workbench);
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
const mutationObserver = new MutationObserver((records) => {
|
|
108
|
+
if (track() || records.some((record) => record.type === "attributes"))
|
|
109
|
+
sync();
|
|
110
|
+
});
|
|
111
|
+
mutationObserver.observe(root, {
|
|
112
|
+
attributes: true,
|
|
113
|
+
attributeFilter: ["data-presentation", "data-responsive-overlay-at"],
|
|
114
|
+
childList: true,
|
|
115
|
+
subtree: true
|
|
116
|
+
});
|
|
117
|
+
disposers.push(() => {
|
|
118
|
+
mutationObserver.disconnect();
|
|
119
|
+
resizeObserver?.disconnect();
|
|
120
|
+
});
|
|
121
|
+
track();
|
|
122
|
+
sync();
|
|
123
|
+
for (const panel of panels) {
|
|
124
|
+
let previous = panel.collapsed.peek();
|
|
125
|
+
if (!previous) openOrder.push(panel);
|
|
126
|
+
disposers.push(
|
|
127
|
+
effect(() => {
|
|
128
|
+
const collapsed = panel.collapsed.value;
|
|
129
|
+
if (collapsed === previous) return;
|
|
130
|
+
previous = collapsed;
|
|
131
|
+
const index = openOrder.indexOf(panel);
|
|
132
|
+
if (index >= 0) openOrder.splice(index, 1);
|
|
133
|
+
if (collapsed) {
|
|
134
|
+
const active2 = ownerDocument.activeElement;
|
|
135
|
+
if (panelElement(panel)?.contains(active2) || pressedFocus === panel && (active2 === null || active2 === ownerDocument.body))
|
|
136
|
+
rescueFocus(panel);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
openOrder.push(panel);
|
|
140
|
+
const element = panelElement(panel);
|
|
141
|
+
const active = ownerDocument.activeElement;
|
|
142
|
+
if (active instanceof HTMLElement && active !== ownerDocument.body && !element?.contains(active))
|
|
143
|
+
openers.set(panel, active);
|
|
144
|
+
else openers.delete(panel);
|
|
145
|
+
if (!element || !overlaid(element)) return;
|
|
146
|
+
if (exclusive) {
|
|
147
|
+
for (const [other] of openOverlays())
|
|
148
|
+
if (other !== panel) other.collapsed.value = true;
|
|
149
|
+
}
|
|
150
|
+
(focusables(element)[0] ?? element).focus({ preventScroll: true });
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const openOverlays = () => openOrder.flatMap((panel) => {
|
|
155
|
+
const element = panelElement(panel);
|
|
156
|
+
return !panel.collapsed.peek() && element && overlaid(element) ? [[panel, element]] : [];
|
|
157
|
+
});
|
|
158
|
+
const onKeydown = (event) => {
|
|
159
|
+
if (event.key !== "Escape" && event.key !== "Tab" || event.defaultPrevented)
|
|
160
|
+
return;
|
|
161
|
+
const open = openOverlays();
|
|
162
|
+
if (open.length === 0) return;
|
|
163
|
+
const active = ownerDocument.activeElement;
|
|
164
|
+
const [panel, element] = open.find(([, candidate]) => candidate.contains(active)) ?? open[open.length - 1];
|
|
165
|
+
if (event.key === "Escape") {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
panel.collapsed.value = true;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const items = focusables(element);
|
|
171
|
+
if (items.length === 0) return;
|
|
172
|
+
const first = items[0];
|
|
173
|
+
const last = items[items.length - 1];
|
|
174
|
+
const inside = element.contains(active);
|
|
175
|
+
if (event.shiftKey && (!inside || active === first)) {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
last.focus();
|
|
178
|
+
} else if (!event.shiftKey && (!inside || active === last)) {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
first.focus();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
let pressed = [];
|
|
184
|
+
const onPointerdown = (event) => {
|
|
185
|
+
const path = event.composedPath();
|
|
186
|
+
pressed = openOverlays().filter(([, element]) => !path.includes(element)).map(([panel]) => panel);
|
|
187
|
+
const active = ownerDocument.activeElement;
|
|
188
|
+
pressedFocus = panels.find((panel) => {
|
|
189
|
+
if (panel.collapsed.peek()) return false;
|
|
190
|
+
const element = panelElement(panel);
|
|
191
|
+
return !!element && path.includes(element) && element.contains(active);
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const onFocusin = () => {
|
|
195
|
+
pressedFocus = void 0;
|
|
196
|
+
};
|
|
197
|
+
const onClick = (event) => {
|
|
198
|
+
const candidates = pressed;
|
|
199
|
+
pressed = [];
|
|
200
|
+
const path = event.composedPath();
|
|
201
|
+
for (const [panel, element] of openOverlays())
|
|
202
|
+
if (candidates.includes(panel) && !path.includes(element))
|
|
203
|
+
panel.collapsed.value = true;
|
|
204
|
+
};
|
|
205
|
+
ownerDocument.addEventListener("keydown", onKeydown);
|
|
206
|
+
ownerDocument.addEventListener("pointerdown", onPointerdown, true);
|
|
207
|
+
ownerDocument.addEventListener("click", onClick);
|
|
208
|
+
ownerDocument.addEventListener("focusin", onFocusin, true);
|
|
209
|
+
disposers.push(() => {
|
|
210
|
+
ownerDocument.removeEventListener("keydown", onKeydown);
|
|
211
|
+
ownerDocument.removeEventListener("pointerdown", onPointerdown, true);
|
|
212
|
+
ownerDocument.removeEventListener("click", onClick);
|
|
213
|
+
ownerDocument.removeEventListener("focusin", onFocusin, true);
|
|
214
|
+
});
|
|
215
|
+
return () => {
|
|
216
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
217
|
+
for (const [panel, remembered] of inlineState) {
|
|
218
|
+
const element = panelElement(panel);
|
|
219
|
+
if (element) adapt(panel, element, remembered);
|
|
220
|
+
else panel.collapsed.value = remembered;
|
|
221
|
+
}
|
|
222
|
+
inlineState.clear();
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/wire-workbench.ts
|
|
227
|
+
function defaultStorage() {
|
|
228
|
+
try {
|
|
229
|
+
return globalThis.localStorage ?? void 0;
|
|
230
|
+
} catch {
|
|
231
|
+
return void 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function storedSize(text) {
|
|
235
|
+
if (text === null) return void 0;
|
|
236
|
+
const size = Number(text);
|
|
237
|
+
return Number.isFinite(size) && size > 0 ? Math.round(size) : void 0;
|
|
238
|
+
}
|
|
239
|
+
var quoted = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
240
|
+
var px = (value) => Number.parseFloat(value) || 0;
|
|
241
|
+
var mainRoomLimit = (region, { max }) => {
|
|
242
|
+
const horizontal = region.dataset.axis === "horizontal";
|
|
243
|
+
const container = region.parentElement;
|
|
244
|
+
const workbench = horizontal ? container : container?.parentElement;
|
|
245
|
+
const mainMin = Number(
|
|
246
|
+
horizontal ? workbench?.dataset.mainMinSize : workbench?.dataset.mainMinHeight
|
|
247
|
+
);
|
|
248
|
+
if (!container || !(mainMin > 0)) return max;
|
|
249
|
+
const box = container.getBoundingClientRect();
|
|
250
|
+
const room = horizontal ? box.width : box.height;
|
|
251
|
+
if (room <= 0) return max;
|
|
252
|
+
let others = 0;
|
|
253
|
+
if (horizontal)
|
|
254
|
+
for (const rail of container.children) {
|
|
255
|
+
if (rail === region || !rail.matches(".kui-workbench__rail") || globalThis.getComputedStyle(rail).position === "absolute")
|
|
256
|
+
continue;
|
|
257
|
+
others += rail.getBoundingClientRect().width;
|
|
258
|
+
}
|
|
259
|
+
const style = globalThis.getComputedStyle(region);
|
|
260
|
+
const size = px(region.style.getPropertyValue("--kui-resizable-region-size"));
|
|
261
|
+
const border = style.boxSizing === "border-box" ? 0 : horizontal ? px(style.borderInlineStartWidth) + px(style.borderInlineEndWidth) : px(style.borderBlockStartWidth) + px(style.borderBlockEndWidth);
|
|
262
|
+
const extent = px(style.flexBasis) - size + border;
|
|
263
|
+
return Math.floor(room - Math.min(mainMin, room) - others - extent);
|
|
264
|
+
};
|
|
265
|
+
function wireWorkbench(root, {
|
|
266
|
+
id,
|
|
267
|
+
panels,
|
|
268
|
+
deviceClass,
|
|
269
|
+
storage = defaultStorage(),
|
|
270
|
+
step,
|
|
271
|
+
largeStep,
|
|
272
|
+
onResize,
|
|
273
|
+
dismissOverlays = true,
|
|
274
|
+
exclusiveOverlays = true
|
|
275
|
+
}) {
|
|
276
|
+
const keys = Object.keys(panels);
|
|
277
|
+
const entries = keys.flatMap((key) => {
|
|
278
|
+
const size = panels[key]?.size;
|
|
279
|
+
return size ? [
|
|
280
|
+
{
|
|
281
|
+
key,
|
|
282
|
+
size,
|
|
283
|
+
storageKey: panels[key].storageKey,
|
|
284
|
+
regionId: workbenchRegionId(id, key)
|
|
285
|
+
}
|
|
286
|
+
] : [];
|
|
287
|
+
});
|
|
288
|
+
const byRegion = new Map(entries.map((entry) => [entry.regionId, entry]));
|
|
289
|
+
const disposers = [];
|
|
290
|
+
for (const { size, storageKey } of entries) {
|
|
291
|
+
if (!storageKey || !storage) continue;
|
|
292
|
+
const seed = storedSize(storage.getItem(storageKey));
|
|
293
|
+
if (seed !== void 0) size.value = seed;
|
|
294
|
+
disposers.push(
|
|
295
|
+
effect(() => {
|
|
296
|
+
storage.setItem(storageKey, String(size.value));
|
|
297
|
+
})
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
const selector = entries.map(
|
|
301
|
+
({ regionId }) => `[data-resizable="true"][data-region-id=${quoted(regionId)}]`
|
|
302
|
+
).join(", ");
|
|
303
|
+
const start = () => wireResizeHandles(
|
|
304
|
+
root,
|
|
305
|
+
{
|
|
306
|
+
step,
|
|
307
|
+
largeStep,
|
|
308
|
+
onCommit: ({ id: regionId, size, source }) => {
|
|
309
|
+
const entry = byRegion.get(regionId);
|
|
310
|
+
entry.size.value = size;
|
|
311
|
+
onResize?.({ panel: entry.key, size, source });
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
selector,
|
|
315
|
+
mainRoomLimit
|
|
316
|
+
);
|
|
317
|
+
let stopResize;
|
|
318
|
+
if (selector) {
|
|
319
|
+
if (deviceClass) {
|
|
320
|
+
disposers.push(
|
|
321
|
+
effect(() => {
|
|
322
|
+
const compact = deviceClass.value.compact;
|
|
323
|
+
stopResize?.();
|
|
324
|
+
stopResize = compact ? void 0 : start();
|
|
325
|
+
})
|
|
326
|
+
);
|
|
327
|
+
} else {
|
|
328
|
+
stopResize = start();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const overlayPanels = keys.flatMap((key) => {
|
|
332
|
+
const collapsed = panels[key]?.collapsed;
|
|
333
|
+
return collapsed ? [{ key, collapsed }] : [];
|
|
334
|
+
});
|
|
335
|
+
if (dismissOverlays && overlayPanels.length > 0) {
|
|
336
|
+
const selector2 = `[data-component="workbench"][id=${quoted(id)}]`;
|
|
337
|
+
disposers.push(
|
|
338
|
+
wireWorkbenchOverlays(
|
|
339
|
+
root,
|
|
340
|
+
() => root.matches(selector2) ? root : root.querySelector(selector2),
|
|
341
|
+
overlayPanels,
|
|
342
|
+
exclusiveOverlays
|
|
343
|
+
)
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return () => {
|
|
347
|
+
stopResize?.();
|
|
348
|
+
stopResize = void 0;
|
|
349
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export { wireWorkbench };
|
|
354
|
+
|
|
355
|
+
//# sourceMappingURL=wire-workbench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/workbench-overlays.ts","../src/wire-workbench.ts"],"names":["active","effect","selector"],"mappings":";;;;;AAiBA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,QACE,IAAA;AAAA,QACA,MACE,KAAK,OAAA,CAAQA,SAAQ,IACjB,IAAA,GACA,IAAA,CAAK,cAA2BA,SAAQ,CAAA;AAAA,QAC9C,aAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAM;AACX,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":"wire-workbench.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}\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 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 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 for (const panel of panels) {\n const element = panelElement(panel);\n if (!element) continue;\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 }\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: ['data-presentation', 'data-responsive-overlay-at'],\n childList: true,\n subtree: true,\n });\n disposers.push(() => {\n mutationObserver.disconnect();\n resizeObserver?.disconnect();\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 if (\n panelElement(panel)?.contains(active) ||\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 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 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 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 onPointerdown = (event: PointerEvent): void => {\n const path = event.composedPath();\n pressed = openOverlays()\n .filter(([, element]) => !path.includes(element))\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) && !path.includes(element))\n panel.collapsed.value = true;\n };\n ownerDocument.addEventListener('keydown', onKeydown);\n ownerDocument.addEventListener('pointerdown', onPointerdown, 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', onClick);\n ownerDocument.removeEventListener('focusin', onFocusin, true);\n });\n\n return () => {\n for (const dispose of disposers.splice(0)) dispose();\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\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 ? [{ key, collapsed }] : [];\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"]}
|
package/dist/workbench.d.ts
CHANGED
|
@@ -2,24 +2,64 @@ import { SafeHtml } from 'kerfjs';
|
|
|
2
2
|
import { ResizableRegionSeparator, ResizableRegionCollapseMotion, ResizableRegionContentOverflow, ResizableRegionPresentation, ResizableRegionRestorePosition } from './resizable-region.js';
|
|
3
3
|
import { K as KerfUiContent } from './semantic-content-BbzjvSu9.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The Workbench container breakpoint below which a panel presents as an
|
|
7
|
+
* overlay: `narrow` (704px or less) or `compact` (448px or less) — the same
|
|
8
|
+
* breakpoints as `ResizableRegion`'s `responsiveFillAt`.
|
|
9
|
+
*/
|
|
10
|
+
type WorkbenchResponsiveOverlayAt = 'compact' | 'narrow';
|
|
11
|
+
/** Drag-resize limits for a resizable Workbench panel, in px. */
|
|
12
|
+
interface WorkbenchPanelResizable {
|
|
13
|
+
/** Smallest size (default 180 for a rail, 120 for the drawer). */
|
|
14
|
+
min?: number;
|
|
15
|
+
/** Largest size (default 480). */
|
|
16
|
+
max?: number;
|
|
17
|
+
}
|
|
5
18
|
/** A collapsible Workbench panel — a side rail or the bottom drawer. */
|
|
6
19
|
interface WorkbenchPanel {
|
|
7
20
|
content: KerfUiContent;
|
|
8
21
|
/** Whether the panel is currently collapsed (the app owns this). */
|
|
9
22
|
collapsed?: boolean;
|
|
10
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Rail width, or drawer height, in px. Overrides the CSS default. For a
|
|
25
|
+
* resizable panel it is the current size (default 280 for a rail, 220 for
|
|
26
|
+
* the drawer), clamped to the limits; the app owns it and `wireWorkbench`
|
|
27
|
+
* reports each resize.
|
|
28
|
+
*/
|
|
11
29
|
size?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Opt in to drag and keyboard resizing on the panel's inner separator:
|
|
32
|
+
* `true` for the default limits, or `{ min, max }`. Off by default. Pair it
|
|
33
|
+
* with `wireWorkbench` from `@kerfjs/ui/wire-workbench`.
|
|
34
|
+
*/
|
|
35
|
+
resizable?: boolean | WorkbenchPanelResizable;
|
|
12
36
|
/** Accessible name for the panel region. */
|
|
13
37
|
label?: string;
|
|
14
38
|
separator?: ResizableRegionSeparator;
|
|
15
39
|
collapseMotion?: ResizableRegionCollapseMotion;
|
|
16
40
|
contentOverflow?: ResizableRegionContentOverflow;
|
|
17
41
|
presentation?: ResizableRegionPresentation;
|
|
18
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Present the panel as an overlay, without a separator, below a Workbench
|
|
44
|
+
* container breakpoint, and inline above it — the CSS decides, so the app
|
|
45
|
+
* needs no device-class check. A rail overlays from its side at full
|
|
46
|
+
* height; the bottom drawer overlays the bottom of the work-area column.
|
|
47
|
+
*/
|
|
48
|
+
responsiveOverlayAt?: WorkbenchResponsiveOverlayAt;
|
|
49
|
+
/**
|
|
50
|
+
* Control shown while collapsed, in a safe-area-aware corner of the
|
|
51
|
+
* Workbench (not the viewport); the bottom drawer's sits in the work-area
|
|
52
|
+
* column.
|
|
53
|
+
*/
|
|
19
54
|
restoreControl?: SafeHtml;
|
|
20
55
|
restorePosition?: ResizableRegionRestorePosition;
|
|
21
56
|
}
|
|
22
57
|
interface WorkbenchProps {
|
|
58
|
+
/**
|
|
59
|
+
* The Workbench's `id`. Each panel's `id` derives from it —
|
|
60
|
+
* `<id>-left-rail`, `<id>-right-rail`, `<id>-bottom-drawer` — so a toggle
|
|
61
|
+
* can name the panel it shows and hides with `aria-controls`.
|
|
62
|
+
*/
|
|
23
63
|
id: string;
|
|
24
64
|
label: string;
|
|
25
65
|
/** The central work area. */
|
|
@@ -27,6 +67,22 @@ interface WorkbenchProps {
|
|
|
27
67
|
leftRail?: WorkbenchPanel;
|
|
28
68
|
rightRail?: WorkbenchPanel;
|
|
29
69
|
bottomDrawer?: WorkbenchPanel;
|
|
70
|
+
/**
|
|
71
|
+
* Minimum width, in px, the work area keeps beside the inline rails, fixed
|
|
72
|
+
* or `resizable` (default 320; `0` turns it off). Resizing a rail stops
|
|
73
|
+
* where the work area would drop below it, and inline rails shrink
|
|
74
|
+
* proportionally when the Workbench gets narrower. Workbenches without a
|
|
75
|
+
* rail ignore it.
|
|
76
|
+
*/
|
|
77
|
+
mainMinSize?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Minimum height, in px, the work area keeps above an inline bottom drawer,
|
|
80
|
+
* fixed or `resizable` (default 120; `0` turns it off) — the drawer's
|
|
81
|
+
* counterpart of `mainMinSize`. Resizing the drawer stops where the work
|
|
82
|
+
* area would drop below it, and the drawer shrinks when the Workbench gets
|
|
83
|
+
* shorter. Workbenches without a drawer ignore it.
|
|
84
|
+
*/
|
|
85
|
+
mainMinHeight?: number;
|
|
30
86
|
className?: string;
|
|
31
87
|
/** Native named-slot assignment when composed inside a web component. */
|
|
32
88
|
slot?: string;
|
|
@@ -38,9 +94,12 @@ interface WorkbenchProps {
|
|
|
38
94
|
* a composited transform — the instant-width / sliding-content technique, so the
|
|
39
95
|
* work area relayouts once, not per frame. Bottom-drawer content stays anchored
|
|
40
96
|
* to the shell's stable bottom edge throughout that transition. The app owns
|
|
41
|
-
* each `collapsed` flag; the collapse is pure CSS
|
|
42
|
-
* `
|
|
97
|
+
* each `collapsed` flag; the collapse is pure CSS. A collapsed panel renders
|
|
98
|
+
* `inert` and `aria-hidden`, so neither Tab nor assistive technology reaches
|
|
99
|
+
* controls that have slid out of view or an empty landmark (its restore control
|
|
100
|
+
* lives outside it and stays reachable). A panel may opt in to drag and keyboard resizing with
|
|
101
|
+
* `resizable`, which `wireWorkbench` drives. See `docs/23-app-layouts.md` §3.3.
|
|
43
102
|
*/
|
|
44
|
-
declare function Workbench({ id, label, main, leftRail, rightRail, bottomDrawer, className, slot, }: WorkbenchProps): SafeHtml;
|
|
103
|
+
declare function Workbench({ id, label, main, leftRail, rightRail, bottomDrawer, mainMinSize, mainMinHeight, className, slot, }: WorkbenchProps): SafeHtml;
|
|
45
104
|
|
|
46
|
-
export { Workbench, type WorkbenchPanel, type WorkbenchProps };
|
|
105
|
+
export { Workbench, type WorkbenchPanel, type WorkbenchPanelResizable, type WorkbenchProps, type WorkbenchResponsiveOverlayAt };
|