@k2b/ui 0.57.0 → 0.58.0
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/dist/browser/actions/Dropdown.js +4 -3
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/menu-rows.js +1 -1
- package/dist/browser/actions/menu-rows.js.map +1 -1
- package/dist/browser/content/PdfPages.js +159 -44
- package/dist/browser/content/PdfPages.js.map +1 -1
- package/dist/browser/content/PdfViewer.js +59 -21
- package/dist/browser/content/PdfViewer.js.map +1 -1
- package/dist/browser/content/pdf-viewer-engine.js +1 -1
- package/dist/browser/layout/FloatingWindow.js +122 -75
- package/dist/browser/layout/FloatingWindow.js.map +1 -1
- package/dist/browser/layout/Panes.js +640 -212
- package/dist/browser/layout/Panes.js.map +1 -1
- package/dist/browser/layout/index.js +1 -1
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/panes-layout.js +169 -0
- package/dist/browser/layout/panes-layout.js.map +1 -1
- package/dist/browser/layout/panes-messages.js +108 -2
- package/dist/browser/layout/panes-messages.js.map +1 -1
- package/dist/ssr/actions/Dropdown.js +4 -4
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/menu-rows.js +1 -1
- package/dist/ssr/actions/menu-rows.js.map +1 -1
- package/dist/ssr/content/PdfPages.js +159 -44
- package/dist/ssr/content/PdfPages.js.map +1 -1
- package/dist/ssr/content/PdfViewer.js +40 -8
- package/dist/ssr/content/PdfViewer.js.map +1 -1
- package/dist/ssr/layout/FloatingWindow.js +37 -15
- package/dist/ssr/layout/FloatingWindow.js.map +1 -1
- package/dist/ssr/layout/Panes.js +396 -41
- package/dist/ssr/layout/Panes.js.map +1 -1
- package/dist/ssr/layout/index.js +1 -1
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/panes-layout.js +169 -0
- package/dist/ssr/layout/panes-layout.js.map +1 -1
- package/dist/ssr/layout/panes-messages.js +108 -2
- package/dist/ssr/layout/panes-messages.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Dropdown.d.ts +4 -3
- package/dist/types/content/PdfPages.d.ts +8 -3
- package/dist/types/content/PdfViewer.d.ts +12 -4
- package/dist/types/layout/FloatingWindow.d.ts +6 -0
- package/dist/types/layout/Panes.d.ts +15 -0
- package/dist/types/layout/index.d.ts +2 -2
- package/dist/types/layout/panes-layout.d.ts +51 -0
- package/dist/types/layout/panes-messages.d.ts +55 -0
- package/package.json +1 -1
package/dist/ssr/layout/Panes.js
CHANGED
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
import { ssrStyleProperty as _$ssrStyleProperty } from "solid-js/web";
|
|
2
2
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
-
import {
|
|
3
|
+
import { memo as _$memo } from "solid-js/web";
|
|
4
4
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
5
5
|
import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
|
|
6
|
+
import { ssr as _$ssr } from "solid-js/web";
|
|
6
7
|
import { escape as _$escape } from "solid-js/web";
|
|
7
|
-
var _tmpl$ = ["<
|
|
8
|
-
_tmpl$2 = ["<
|
|
9
|
-
_tmpl$3 = ["<div class=\"k2b-
|
|
10
|
-
_tmpl$4 = ["<
|
|
11
|
-
_tmpl$5 = "<
|
|
12
|
-
_tmpl$6 =
|
|
13
|
-
_tmpl$7 = ["<
|
|
14
|
-
_tmpl$8 = ["<
|
|
15
|
-
_tmpl$9 = "<i class=\"ti ti-
|
|
16
|
-
_tmpl$0 = ["<div class=\"k2b-
|
|
17
|
-
_tmpl$1 = ["<
|
|
18
|
-
_tmpl$10 = ["<div class=\"k2b-
|
|
19
|
-
_tmpl$11 =
|
|
8
|
+
var _tmpl$ = ["<kbd class=\"k2b-panes__shortcut\">", "</kbd>"],
|
|
9
|
+
_tmpl$2 = ["<strong>", "</strong>"],
|
|
10
|
+
_tmpl$3 = ["<div class=\"", "\" data-k2b-panes", " role=\"group\"", ">", "", "", "</div>"],
|
|
11
|
+
_tmpl$4 = ["<button type=\"button\" class=\"k2b-panes__add\"", "><i class=\"ti ti-plus\" aria-hidden=\"true\"></i><span>", "</span></button>"],
|
|
12
|
+
_tmpl$5 = ["<div class=\"k2b-panes__empty\"><span class=\"k2b-panes__empty-mark\" aria-hidden=\"true\"><i class=\"ti ti-layout-columns\"></i></span><p>", "</p>", "</div>"],
|
|
13
|
+
_tmpl$6 = "<i class=\"ti ti-layout-columns\" aria-hidden=\"true\"></i>",
|
|
14
|
+
_tmpl$7 = ["<span>", "</span>"],
|
|
15
|
+
_tmpl$8 = ["<div class=\"k2b-panes__split\"", "><div class=\"k2b-panes__split-child\" style=\"", "\">", "</div><button type=\"button\" role=\"separator\"", " class=\"k2b-panes__separator\"", "><span aria-hidden=\"true\"></span></button>", "<div class=\"k2b-panes__split-child\" style=\"", "\">", "</div></div>"],
|
|
16
|
+
_tmpl$9 = "<i class=\"ti ti-plus\" aria-hidden=\"true\"></i>",
|
|
17
|
+
_tmpl$0 = ["<div class=\"k2b-panes__tabs-scrollbar\" style=\"", "\" aria-hidden=\"true\"><span style=\"", "\"></span></div>"],
|
|
18
|
+
_tmpl$1 = ["<div class=\"k2b-panes__drop-targets\" aria-hidden=\"true\">", "</div>"],
|
|
19
|
+
_tmpl$10 = ["<section class=\"k2b-panes__group\"", "><div class=\"k2b-panes__head\"><div class=\"k2b-panes__tabs\" role=\"tablist\"", " aria-orientation=\"horizontal\">", "", "", "</div>", "</div>", "<div class=\"k2b-panes__body\"><div", " class=\"k2b-panes__panel\" role=\"tabpanel\"", ">", "</div></div>", "</section>"],
|
|
20
|
+
_tmpl$11 = "<i class=\"ti ti-grip-vertical k2b-panes__grip\" aria-hidden=\"true\"></i>",
|
|
21
|
+
_tmpl$12 = "<i class=\"ti ti-x\" aria-hidden=\"true\"></i>",
|
|
22
|
+
_tmpl$13 = ["<div class=\"k2b-panes__tab\"", ">", "<button", " type=\"button\" class=\"k2b-panes__tab-button\" role=\"tab\"", ">", "<span class=\"k2b-ui k2b-panes__drag-surface k2b-panes__drag-preview\" data-dnd-preview><i class=\"", "\" aria-hidden=\"true\"></i><span>", "</span></span></button>", "</div>"],
|
|
23
|
+
_tmpl$14 = ["<div class=\"k2b-panes__drop-target\"", " aria-hidden=\"true\">", "", "</div>"],
|
|
24
|
+
_tmpl$15 = ["<i", " aria-hidden=\"true\"></i>"];
|
|
20
25
|
import { dnd } from "@k2b/stdlib/solid";
|
|
21
26
|
import { createEffect, createMemo, createSignal, createUniqueId, For, onCleanup, onMount, Show } from "solid-js";
|
|
27
|
+
import { Dropdown } from "../actions/Dropdown";
|
|
28
|
+
import { announce } from "../feedback/announce";
|
|
29
|
+
import { MovedHint } from "../feedback/MovedHint";
|
|
22
30
|
import { Tooltip } from "../feedback/Tooltip";
|
|
23
31
|
import { suppressTextSelection } from "../internal/text-selection";
|
|
24
32
|
import { useUiMessages } from "../intl/messages";
|
|
25
|
-
import { activatePanesItem, applyPanesIntent, getPanesDropTargets, PANES_MAX_ID_LENGTH, PANES_MIN_RATIO, parsePanesLayout, resizePanesSplit, samePanesIntent } from "./panes-layout";
|
|
33
|
+
import { activatePanesItem, applyPanesIntent, applyPanesPreset, canApplyPanesPreset, getPanesDropTargets, getPanesMoves, getPanesPreset, getPanesSplitRatio, PANES_MAX_ID_LENGTH, PANES_MIN_RATIO, PANES_PRESETS, panesItemOrder, parsePanesLayout, projectPanesLayout, resizePanesSplit, samePanesArrangement, samePanesIntent, samePanesSizes } from "./panes-layout";
|
|
26
34
|
import { usePanesMessages } from "./panes-messages";
|
|
27
35
|
import { assertUniqueStableUiIds } from "./stable-id";
|
|
36
|
+
/** Below this width of its own container, Panes shows every item as one row of tabs and never stores that. */
|
|
37
|
+
export const PANES_NARROW_WIDTH = 640;
|
|
38
|
+
const PRESET_ICONS = {
|
|
39
|
+
two: "ti ti-layout-columns",
|
|
40
|
+
three: "ti ti-columns-3",
|
|
41
|
+
stacked: "ti ti-layout-board-split",
|
|
42
|
+
tabs: "ti ti-app-window"
|
|
43
|
+
};
|
|
44
|
+
const SIDE_ICONS = {
|
|
45
|
+
top: "ti ti-layout-navbar",
|
|
46
|
+
bottom: "ti ti-layout-bottombar",
|
|
47
|
+
left: "ti ti-layout-sidebar",
|
|
48
|
+
right: "ti ti-layout-sidebar-right"
|
|
49
|
+
};
|
|
50
|
+
const MOVE_ORDER = {
|
|
51
|
+
split: 0,
|
|
52
|
+
group: 1,
|
|
53
|
+
tab: 2
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** The group that hosts the Arrange button: the top group at the trailing edge. */
|
|
57
|
+
const arrangeHostGroup = node => {
|
|
58
|
+
if (!node) return null;
|
|
59
|
+
if (node.type === "group") return node;
|
|
60
|
+
return arrangeHostGroup(node.direction === "horizontal" ? node.second : node.first);
|
|
61
|
+
};
|
|
62
|
+
const firstGroupOf = node => {
|
|
63
|
+
if (!node) return null;
|
|
64
|
+
return node.type === "group" ? node : firstGroupOf(node.first);
|
|
65
|
+
};
|
|
28
66
|
const PANES_RESIZE_SNAP_DISTANCE = 8;
|
|
29
67
|
const PANES_RESIZE_UNSNAP_DISTANCE = 12;
|
|
30
68
|
const PANES_RESIZE_NEIGHBOR_GAP = 16;
|
|
@@ -129,9 +167,39 @@ export default function Panes(props) {
|
|
|
129
167
|
for (const id of collectLayoutItemIds(props.layout.root)) requireItem(items(), id);
|
|
130
168
|
return props.layout;
|
|
131
169
|
});
|
|
132
|
-
|
|
170
|
+
let rootElement;
|
|
171
|
+
// A narrow container shows one row of tabs. It is measured after the first render, so server HTML and the first
|
|
172
|
+
// client render agree; a hidden container (width 0) keeps the last answer.
|
|
173
|
+
const [narrow, setNarrow] = createSignal(false);
|
|
174
|
+
onMount(() => {
|
|
175
|
+
const measure = () => {
|
|
176
|
+
const width = rootElement?.getBoundingClientRect().width ?? 0;
|
|
177
|
+
if (width > 0) setNarrow(width < PANES_NARROW_WIDTH);
|
|
178
|
+
};
|
|
179
|
+
measure();
|
|
180
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
181
|
+
if (rootElement) observer?.observe(rootElement);
|
|
182
|
+
onCleanup(() => observer?.disconnect());
|
|
183
|
+
});
|
|
184
|
+
// The tab the person chose last, by click, focus, or working in its pane: the Arrange menu moves it, and a narrow
|
|
185
|
+
// container opens on it.
|
|
186
|
+
const [chosen, setChosen] = createSignal(null);
|
|
187
|
+
const [projectedActive, setProjectedActive] = createSignal(null);
|
|
188
|
+
const inLayout = itemId => itemId !== null && collectLayoutItemIds(layout().root).includes(itemId) ? itemId : null;
|
|
189
|
+
const shown = createMemo(() => narrow() ? projectPanesLayout(layout(), inLayout(projectedActive()) ?? inLayout(chosen()) ?? firstGroupOf(layout().root)?.active ?? null) : layout());
|
|
190
|
+
const canMove = () => (props.movable ?? true) && !narrow();
|
|
133
191
|
const canResize = () => props.resizable ?? true;
|
|
134
192
|
const split = () => props.split ?? "both";
|
|
193
|
+
// Presets arrange the open items in the application's order.
|
|
194
|
+
const itemOrder = createMemo(() => {
|
|
195
|
+
const open = new Set(panesItemOrder(layout()));
|
|
196
|
+
return props.items.map(item => item.id).filter(id => open.has(id));
|
|
197
|
+
});
|
|
198
|
+
const canArrange = () => canMove() && itemOrder().length > 1;
|
|
199
|
+
const hostGroupKey = createMemo(() => canArrange() ? arrangeHostGroup(shown().root)?.items[0] ?? null : null);
|
|
200
|
+
const menuItemFor = () => inLayout(chosen()) ?? arrangeHostGroup(layout().root)?.active ?? null;
|
|
201
|
+
const tabElementId = itemId => `${instanceId}-${itemId}-tab`;
|
|
202
|
+
const focusTab = itemId => queueMicrotask(() => document.getElementById(tabElementId(itemId))?.focus());
|
|
135
203
|
const [draggedItemId, setDraggedItemId] = createSignal(null);
|
|
136
204
|
const [dragMode, setDragMode] = createSignal(null);
|
|
137
205
|
const dropTargets = createMemo(() => {
|
|
@@ -156,10 +224,24 @@ export default function Panes(props) {
|
|
|
156
224
|
setDraggedItemId(active.meta.itemId);
|
|
157
225
|
},
|
|
158
226
|
announcements: {
|
|
159
|
-
dragStart: active =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
227
|
+
dragStart: active => panesMessages().pickedUp({
|
|
228
|
+
name: active.meta.label
|
|
229
|
+
}),
|
|
230
|
+
dragOver: (active, over) => over ? panesMessages().dragOver({
|
|
231
|
+
name: active.meta.label,
|
|
232
|
+
place: over.meta.label
|
|
233
|
+
}) : panesMessages().notOverPane({
|
|
234
|
+
name: active.meta.label
|
|
235
|
+
}),
|
|
236
|
+
drop: (active, over) => over ? panesMessages().dropped({
|
|
237
|
+
name: active.meta.label,
|
|
238
|
+
place: over.meta.label
|
|
239
|
+
}) : panesMessages().notMoved({
|
|
240
|
+
name: active.meta.label
|
|
241
|
+
}),
|
|
242
|
+
cancel: active => panesMessages().cancelled({
|
|
243
|
+
name: active.meta.label
|
|
244
|
+
})
|
|
163
245
|
},
|
|
164
246
|
onDrop: ({
|
|
165
247
|
intent,
|
|
@@ -171,8 +253,9 @@ export default function Panes(props) {
|
|
|
171
253
|
const current = layout();
|
|
172
254
|
const next = applyPanesIntent(current, intent);
|
|
173
255
|
if (next === current) return;
|
|
256
|
+
setChosen(intent.itemId);
|
|
174
257
|
props.onLayoutChange(next);
|
|
175
|
-
if (mode === "keyboard")
|
|
258
|
+
if (mode === "keyboard") focusTab(intent.itemId);
|
|
176
259
|
},
|
|
177
260
|
onCancel: () => {
|
|
178
261
|
setDragMode(null);
|
|
@@ -180,29 +263,169 @@ export default function Panes(props) {
|
|
|
180
263
|
}
|
|
181
264
|
});
|
|
182
265
|
const activate = itemId => {
|
|
266
|
+
setChosen(itemId);
|
|
267
|
+
if (narrow()) {
|
|
268
|
+
setProjectedActive(itemId);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
// A choice in the wide layout is newer than one in the narrow row.
|
|
272
|
+
setProjectedActive(null);
|
|
183
273
|
const current = layout();
|
|
184
274
|
const next = activatePanesItem(current, itemId);
|
|
185
275
|
if (next !== current) props.onLayoutChange(next);
|
|
186
276
|
};
|
|
187
277
|
const requestAdd = targetItemId => props.onAddItem?.(targetItemId);
|
|
188
|
-
|
|
278
|
+
const title = itemId => requireItem(items(), itemId).title;
|
|
279
|
+
const moveLabel = (move, messages) => {
|
|
280
|
+
if (move.kind === "split") return messages.moveBeside({
|
|
281
|
+
side: move.side,
|
|
282
|
+
name: title(move.targetItemId)
|
|
283
|
+
});
|
|
284
|
+
if (move.kind === "group") return messages.moveIntoGroup({
|
|
285
|
+
name: title(move.targetItemId)
|
|
286
|
+
});
|
|
287
|
+
return move.direction === "previous" ? messages.moveTabPrevious : messages.moveTabNext;
|
|
288
|
+
};
|
|
289
|
+
const move = (itemId, intent, place) => {
|
|
290
|
+
const current = layout();
|
|
291
|
+
const next = applyPanesIntent(current, intent);
|
|
292
|
+
if (next === current) return;
|
|
293
|
+
setChosen(itemId);
|
|
294
|
+
props.onLayoutChange(next);
|
|
295
|
+
focusTab(itemId);
|
|
296
|
+
announce(panesMessages().moved({
|
|
297
|
+
name: title(itemId),
|
|
298
|
+
place
|
|
299
|
+
}));
|
|
300
|
+
};
|
|
301
|
+
const moveWithinGroup = (itemId, direction) => {
|
|
302
|
+
const step = getPanesMoves(layout(), itemId, {
|
|
303
|
+
movable: canMove(),
|
|
304
|
+
split: split()
|
|
305
|
+
}).find(entry => entry.kind === "tab" && entry.direction === direction);
|
|
306
|
+
if (!step) return false;
|
|
307
|
+
move(itemId, step.intent, moveLabel(step, panesMessages()));
|
|
308
|
+
return true;
|
|
309
|
+
};
|
|
310
|
+
const arrange = (preset, itemId) => {
|
|
311
|
+
const next = applyPanesPreset(preset, itemOrder(), {
|
|
312
|
+
active: itemId ?? undefined,
|
|
313
|
+
fallback: props.defaultLayout
|
|
314
|
+
});
|
|
315
|
+
// Choosing the current preset again restores its sizes.
|
|
316
|
+
if (!next || samePanesSizes(next, layout())) return;
|
|
317
|
+
props.onLayoutChange(next);
|
|
318
|
+
if (itemId) focusTab(itemId);
|
|
319
|
+
announce(panesMessages().arranged({
|
|
320
|
+
preset: panesMessages().preset({
|
|
321
|
+
preset
|
|
322
|
+
})
|
|
323
|
+
}));
|
|
324
|
+
};
|
|
325
|
+
// A default that names other items than the open ones, such as a pane the application closed, cannot be restored.
|
|
326
|
+
const resettable = () => {
|
|
327
|
+
const fallback = props.defaultLayout;
|
|
328
|
+
if (!fallback) return false;
|
|
329
|
+
const open = panesItemOrder(layout()).toSorted();
|
|
330
|
+
const stored = panesItemOrder(fallback).toSorted();
|
|
331
|
+
return open.length === stored.length && open.every((id, index) => id === stored[index]);
|
|
332
|
+
};
|
|
333
|
+
const reset = itemId => {
|
|
334
|
+
const fallback = props.defaultLayout;
|
|
335
|
+
if (!fallback || !resettable() || samePanesSizes(fallback, layout())) return;
|
|
336
|
+
props.onLayoutChange(fallback);
|
|
337
|
+
const focus = itemId && collectLayoutItemIds(fallback.root).includes(itemId) ? itemId : null;
|
|
338
|
+
if (focus) focusTab(focus);
|
|
339
|
+
};
|
|
340
|
+
const menuItems = itemId => {
|
|
341
|
+
const messages = panesMessages();
|
|
342
|
+
const current = layout();
|
|
343
|
+
const order = itemOrder();
|
|
344
|
+
const selected = getPanesPreset(current, order);
|
|
345
|
+
const sections = [];
|
|
346
|
+
const presets = PANES_PRESETS.filter(preset => canApplyPanesPreset(preset, order.length, split()));
|
|
347
|
+
if (presets.length > 0) {
|
|
348
|
+
sections.push({
|
|
349
|
+
sectionLabel: messages.arrangement,
|
|
350
|
+
layout: "tiles",
|
|
351
|
+
items: presets.map(preset => ({
|
|
352
|
+
choice: "radio",
|
|
353
|
+
label: messages.preset({
|
|
354
|
+
preset
|
|
355
|
+
}),
|
|
356
|
+
icon: PRESET_ICONS[preset],
|
|
357
|
+
checked: selected === preset,
|
|
358
|
+
action: () => arrange(preset, itemId)
|
|
359
|
+
}))
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (itemId) {
|
|
363
|
+
const moves = getPanesMoves(current, itemId, {
|
|
364
|
+
movable: canMove(),
|
|
365
|
+
split: split()
|
|
366
|
+
}).sort((left, right) => MOVE_ORDER[left.kind] - MOVE_ORDER[right.kind]);
|
|
367
|
+
if (moves.length > 0) {
|
|
368
|
+
sections.push({
|
|
369
|
+
sectionLabel: messages.moveNamed({
|
|
370
|
+
name: title(itemId)
|
|
371
|
+
}),
|
|
372
|
+
items: moves.map(entry => {
|
|
373
|
+
const label = moveLabel(entry, messages);
|
|
374
|
+
return {
|
|
375
|
+
label,
|
|
376
|
+
icon: entry.kind === "split" ? SIDE_ICONS[entry.side] : entry.kind === "group" ? "ti ti-arrows-move" : entry.direction === "previous" ? "ti ti-arrow-left" : "ti ti-arrow-right",
|
|
377
|
+
trailing: entry.kind === "tab" ? _$ssr(_tmpl$, `${_$escape(messages.ctrlKey)} ⇧ ${entry.direction === "previous" ? "←" : "→"}`) : undefined,
|
|
378
|
+
action: () => move(itemId, entry.intent, label)
|
|
379
|
+
};
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (resettable()) {
|
|
385
|
+
const atDefault = samePanesSizes(props.defaultLayout, current);
|
|
386
|
+
sections.push({
|
|
387
|
+
items: [atDefault ? {
|
|
388
|
+
label: messages.resetArrangement,
|
|
389
|
+
icon: "ti ti-restore",
|
|
390
|
+
disabled: true
|
|
391
|
+
} : {
|
|
392
|
+
label: messages.resetArrangement,
|
|
393
|
+
icon: "ti ti-restore",
|
|
394
|
+
action: () => reset(itemId)
|
|
395
|
+
}]
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return sections;
|
|
399
|
+
};
|
|
400
|
+
// One menu for right clicks, Shift+F10 and the hint; the Arrange button has its own trigger with the same entries.
|
|
401
|
+
const [contextItemId, setContextItemId] = createSignal(null);
|
|
402
|
+
let openContextMenu;
|
|
403
|
+
const openMenu = (itemId, anchor, returnFocus) => {
|
|
404
|
+
if (!canArrange()) return;
|
|
405
|
+
if (itemId) setChosen(itemId);
|
|
406
|
+
setContextItemId(itemId);
|
|
407
|
+
openContextMenu?.(anchor, returnFocus);
|
|
408
|
+
};
|
|
409
|
+
let firstGrip;
|
|
410
|
+
let arrangeButton;
|
|
411
|
+
return _$ssr(_tmpl$3, `k2b-panes ${_$escape(props.class ?? "", true)}`, _$ssrAttribute("data-narrow", narrow() ? "true" : _$escape(undefined, true), false), _$ssrAttribute("aria-label", _$escape(props.ariaLabel ?? panesMessages().paneWorkspace, true), false), _$escape(_$createComponent(Show, {
|
|
189
412
|
get when() {
|
|
190
|
-
return
|
|
413
|
+
return shown().root;
|
|
191
414
|
},
|
|
192
415
|
get fallback() {
|
|
193
|
-
return _$ssr(_tmpl$
|
|
416
|
+
return _$ssr(_tmpl$5, _$escape(panesMessages().noPane), _$escape(_$createComponent(Show, {
|
|
194
417
|
get when() {
|
|
195
418
|
return props.onAddItem !== undefined;
|
|
196
419
|
},
|
|
197
420
|
get children() {
|
|
198
|
-
return _$ssr(_tmpl$
|
|
421
|
+
return _$ssr(_tmpl$4, _$ssrAttribute("aria-label", _$escape(panesMessages().addPane, true), false), _$escape(panesMessages().addPane));
|
|
199
422
|
}
|
|
200
423
|
})));
|
|
201
424
|
},
|
|
202
425
|
children: root => _$createComponent(PanesNodeRenderer, {
|
|
203
426
|
node: root,
|
|
204
427
|
path: [],
|
|
205
|
-
layout:
|
|
428
|
+
layout: shown,
|
|
206
429
|
itemById: items,
|
|
207
430
|
dnd: paneDnd,
|
|
208
431
|
dropTargetIndex: dropTargetIndex,
|
|
@@ -214,8 +437,80 @@ export default function Panes(props) {
|
|
|
214
437
|
onActivate: activate,
|
|
215
438
|
get onLayoutChange() {
|
|
216
439
|
return props.onLayoutChange;
|
|
440
|
+
},
|
|
441
|
+
defaultRatio: (path, direction) => (props.defaultLayout && samePanesArrangement(props.defaultLayout, layout()) ? getPanesSplitRatio(props.defaultLayout, path, direction) : null) ?? 0.5,
|
|
442
|
+
onChoose: setChosen,
|
|
443
|
+
onMenu: openMenu,
|
|
444
|
+
onMoveWithinGroup: moveWithinGroup,
|
|
445
|
+
hostGroupKey: hostGroupKey,
|
|
446
|
+
arrange: () => _$createComponent(Dropdown, {
|
|
447
|
+
get items() {
|
|
448
|
+
return menuItems(menuItemFor());
|
|
449
|
+
},
|
|
450
|
+
position: "bottom-right",
|
|
451
|
+
get label() {
|
|
452
|
+
return panesMessages().arrange;
|
|
453
|
+
},
|
|
454
|
+
get note() {
|
|
455
|
+
return panesMessages().arrangeNote;
|
|
456
|
+
},
|
|
457
|
+
menuClass: "k2b-panes__menu",
|
|
458
|
+
lazy: true,
|
|
459
|
+
get children() {
|
|
460
|
+
return _$createComponent(Dropdown.Trigger, {
|
|
461
|
+
"class": "k2b-panes__arrange",
|
|
462
|
+
variant: "ghost",
|
|
463
|
+
size: "sm",
|
|
464
|
+
tooltip: false,
|
|
465
|
+
get children() {
|
|
466
|
+
return [_$ssr(_tmpl$6), _$ssr(_tmpl$7, _$escape(panesMessages().arrange))];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}),
|
|
471
|
+
registerFirstGrip: element => {
|
|
472
|
+
firstGrip = element;
|
|
217
473
|
}
|
|
218
474
|
})
|
|
475
|
+
})), _$escape(_$createComponent(Dropdown, {
|
|
476
|
+
get items() {
|
|
477
|
+
return menuItems(contextItemId());
|
|
478
|
+
},
|
|
479
|
+
get label() {
|
|
480
|
+
return panesMessages().arrange;
|
|
481
|
+
},
|
|
482
|
+
menuClass: "k2b-panes__menu",
|
|
483
|
+
lazy: true,
|
|
484
|
+
openAt: open => {
|
|
485
|
+
openContextMenu = open;
|
|
486
|
+
}
|
|
487
|
+
})), _$escape(_$createComponent(Show, {
|
|
488
|
+
get when() {
|
|
489
|
+
return _$memo(() => !!props.arrangeHint)() && canArrange();
|
|
490
|
+
},
|
|
491
|
+
get children() {
|
|
492
|
+
return _$createComponent(MovedHint
|
|
493
|
+
// Hidden while a tab is dragged, so it never covers a drop target; it comes back afterwards.
|
|
494
|
+
, {
|
|
495
|
+
get open() {
|
|
496
|
+
return _$memo(() => !!(props.arrangeHint?.open ?? false))() && draggedItemId() === null;
|
|
497
|
+
},
|
|
498
|
+
onDismiss: () => props.arrangeHint?.onDismiss(),
|
|
499
|
+
target: () => firstGrip,
|
|
500
|
+
get action() {
|
|
501
|
+
return {
|
|
502
|
+
label: panesMessages().arrange,
|
|
503
|
+
onClick: () => {
|
|
504
|
+
const button = arrangeButton;
|
|
505
|
+
if (button) openMenu(menuItemFor(), button, button);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
},
|
|
509
|
+
get children() {
|
|
510
|
+
return [_$ssr(_tmpl$2, _$escape(panesMessages().arrangeHint)), " ", panesMessages().arrangeHintDetail];
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
219
514
|
})));
|
|
220
515
|
}
|
|
221
516
|
function PanesNodeRenderer(props) {
|
|
@@ -249,6 +544,7 @@ function PanesSplitRenderer(props) {
|
|
|
249
544
|
let separatorElement;
|
|
250
545
|
let stopResize;
|
|
251
546
|
let finishResize;
|
|
547
|
+
const [resizing, setResizing] = createSignal(false);
|
|
252
548
|
const stopActiveResize = () => {
|
|
253
549
|
stopResize?.();
|
|
254
550
|
stopResize = undefined;
|
|
@@ -335,7 +631,9 @@ function PanesSplitRenderer(props) {
|
|
|
335
631
|
if (end.pointerId === pointerId) finishActiveResize();
|
|
336
632
|
};
|
|
337
633
|
const releaseTextSelection = suppressTextSelection(pointerId);
|
|
634
|
+
setResizing(true);
|
|
338
635
|
stopResize = () => {
|
|
636
|
+
setResizing(false);
|
|
339
637
|
releaseTextSelection();
|
|
340
638
|
if (frame !== undefined) cancelAnimationFrame(frame);
|
|
341
639
|
frame = undefined;
|
|
@@ -356,8 +654,16 @@ function PanesSplitRenderer(props) {
|
|
|
356
654
|
window.addEventListener("pointercancel", onEnd);
|
|
357
655
|
window.addEventListener("blur", finishActiveResize);
|
|
358
656
|
};
|
|
657
|
+
const resetRatio = () => {
|
|
658
|
+
if (props.canResize()) commitRatio(props.defaultRatio(props.path, props.node().direction));
|
|
659
|
+
};
|
|
359
660
|
const onResizeKeyDown = event => {
|
|
360
661
|
if (!props.canResize()) return;
|
|
662
|
+
if (event.key === "Enter") {
|
|
663
|
+
event.preventDefault();
|
|
664
|
+
resetRatio();
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
361
667
|
const step = event.shiftKey ? 0.08 : 0.02;
|
|
362
668
|
let ratio = null;
|
|
363
669
|
if (event.key === "Home") ratio = PANES_MIN_RATIO;
|
|
@@ -377,12 +683,29 @@ function PanesSplitRenderer(props) {
|
|
|
377
683
|
}
|
|
378
684
|
commitRatio(ratio);
|
|
379
685
|
};
|
|
380
|
-
return _$ssr(_tmpl$
|
|
686
|
+
return _$ssr(_tmpl$8, _$ssrAttribute("data-direction", _$escape(props.node().direction, true), false), _$ssrStyleProperty("flex:", `${_$escape(props.node().ratio, true)} 1 0`), _$escape(_$createComponent(PanesNodeRenderer, _$mergeProps(props, {
|
|
381
687
|
node: () => props.node().first,
|
|
382
688
|
get path() {
|
|
383
689
|
return [...props.path, "first"];
|
|
384
690
|
}
|
|
385
|
-
}))), _$ssrAttribute("aria-orientation", props.node().direction === "horizontal" ? "vertical" : "horizontal", false) + _$ssrAttribute("aria-valuemin", _$escape(Math.round(PANES_MIN_RATIO * 100), true), false) + _$ssrAttribute("aria-valuemax", _$escape(Math.round((1 - PANES_MIN_RATIO) * 100), true), false) + _$ssrAttribute("aria-valuenow", _$escape(Math.round(props.node().ratio * 100), true), false) + _$ssrAttribute("aria-disabled", !props.canResize(), false) + _$ssrAttribute("tabindex", props.canResize() ? 0 : -1, false), _$ssrAttribute("data-direction", _$escape(props.node().direction, true), false) + _$ssrAttribute("aria-label", _$escape(panesMessages().resizePanes, true), false)
|
|
691
|
+
}))), _$ssrAttribute("aria-orientation", props.node().direction === "horizontal" ? "vertical" : "horizontal", false) + _$ssrAttribute("aria-valuemin", _$escape(Math.round(PANES_MIN_RATIO * 100), true), false) + _$ssrAttribute("aria-valuemax", _$escape(Math.round((1 - PANES_MIN_RATIO) * 100), true), false) + _$ssrAttribute("aria-valuenow", _$escape(Math.round(props.node().ratio * 100), true), false) + _$ssrAttribute("aria-disabled", !props.canResize(), false) + _$ssrAttribute("tabindex", props.canResize() ? 0 : -1, false), _$ssrAttribute("data-direction", _$escape(props.node().direction, true), false) + _$ssrAttribute("aria-label", _$escape(panesMessages().resizePanes, true), false) + _$ssrAttribute("aria-keyshortcuts", props.canResize() ? "Enter" : _$escape(undefined, true), false) + _$ssrAttribute("data-active", resizing() ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
|
|
692
|
+
get when() {
|
|
693
|
+
return props.canResize();
|
|
694
|
+
},
|
|
695
|
+
get children() {
|
|
696
|
+
return _$createComponent(Tooltip, {
|
|
697
|
+
get content() {
|
|
698
|
+
return panesMessages().resizeHint({
|
|
699
|
+
direction: props.node().direction
|
|
700
|
+
});
|
|
701
|
+
},
|
|
702
|
+
target: () => separatorElement,
|
|
703
|
+
get placement() {
|
|
704
|
+
return props.node().direction === "horizontal" ? "right" : "bottom";
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
})), _$ssrStyleProperty("flex:", `${1 - _$escape(props.node().ratio, true)} 1 0`), _$escape(_$createComponent(PanesNodeRenderer, _$mergeProps(props, {
|
|
386
709
|
node: () => props.node().second,
|
|
387
710
|
get path() {
|
|
388
711
|
return [...props.path, "second"];
|
|
@@ -454,7 +777,8 @@ function PanesGroupRenderer(props) {
|
|
|
454
777
|
const [scrollbar, setScrollbar] = createSignal({
|
|
455
778
|
overflow: false,
|
|
456
779
|
left: 0,
|
|
457
|
-
width: 0
|
|
780
|
+
width: 0,
|
|
781
|
+
track: 0
|
|
458
782
|
});
|
|
459
783
|
const syncScrollbar = () => {
|
|
460
784
|
if (!tabsElement) return;
|
|
@@ -467,16 +791,19 @@ function PanesGroupRenderer(props) {
|
|
|
467
791
|
setScrollbar({
|
|
468
792
|
overflow: false,
|
|
469
793
|
left: 0,
|
|
470
|
-
width: 0
|
|
794
|
+
width: 0,
|
|
795
|
+
track: 0
|
|
471
796
|
});
|
|
472
797
|
return;
|
|
473
798
|
}
|
|
474
799
|
const width = Math.min(clientWidth, Math.max(24, clientWidth * clientWidth / scrollWidth));
|
|
475
800
|
const left = scrollLeft / (scrollWidth - clientWidth) * (clientWidth - width);
|
|
801
|
+
// The track spans the tab row only, not the Arrange button beside it, so thumb and drag share one range.
|
|
476
802
|
setScrollbar({
|
|
477
803
|
overflow: true,
|
|
478
804
|
left,
|
|
479
|
-
width
|
|
805
|
+
width,
|
|
806
|
+
track: clientWidth
|
|
480
807
|
});
|
|
481
808
|
};
|
|
482
809
|
const scrollFromPointer = event => {
|
|
@@ -516,6 +843,8 @@ function PanesGroupRenderer(props) {
|
|
|
516
843
|
props.canAdd();
|
|
517
844
|
queueMicrotask(syncScrollbar);
|
|
518
845
|
});
|
|
846
|
+
const isHost = () => props.hostGroupKey() !== null && props.hostGroupKey() === itemIds()[0];
|
|
847
|
+
const isFirstGroup = () => props.path.every(segment => segment === "first");
|
|
519
848
|
const tabId = itemId => `${props.instanceId}-${itemId}-tab`;
|
|
520
849
|
const panelId = itemId => `${props.instanceId}-${itemId}-panel`;
|
|
521
850
|
const focusTab = index => {
|
|
@@ -532,6 +861,18 @@ function PanesGroupRenderer(props) {
|
|
|
532
861
|
item.onClose();
|
|
533
862
|
return;
|
|
534
863
|
}
|
|
864
|
+
if (props.canMove() && (event.shiftKey && event.key === "F10" || event.key === "ContextMenu")) {
|
|
865
|
+
event.preventDefault();
|
|
866
|
+
const tab = event.currentTarget;
|
|
867
|
+
props.onMenu(itemId, tab, () => document.getElementById(tabId(itemId)) ?? undefined);
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
// The reorder keys never fall through to tab navigation, also at either end where the tab cannot move.
|
|
871
|
+
if (props.canMove() && (event.ctrlKey || event.metaKey) && event.shiftKey && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
872
|
+
event.preventDefault();
|
|
873
|
+
props.onMoveWithinGroup(itemId, event.key === "ArrowLeft" ? "previous" : "next");
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
535
876
|
const count = itemIds().length;
|
|
536
877
|
let next = null;
|
|
537
878
|
if (event.key === "ArrowLeft") next = (index - 1 + count) % count;
|
|
@@ -560,14 +901,14 @@ function PanesGroupRenderer(props) {
|
|
|
560
901
|
name: targetItem.title
|
|
561
902
|
});
|
|
562
903
|
};
|
|
563
|
-
return _$ssr(_tmpl$
|
|
904
|
+
return _$ssr(_tmpl$10, _$ssrAttribute("data-arrange", isHost() ? "true" : _$escape(undefined, true), false), _$ssrAttribute("aria-label", _$escape(panesMessages().paneTabs, true), false), _$escape(_$createComponent(For, {
|
|
564
905
|
get each() {
|
|
565
906
|
return itemIds();
|
|
566
907
|
},
|
|
567
908
|
children: (itemId, index) => {
|
|
568
909
|
const item = () => requireItem(props.itemById(), itemId);
|
|
569
910
|
const active = () => props.node().active === itemId;
|
|
570
|
-
return _$ssr(_tmpl$
|
|
911
|
+
return _$ssr(_tmpl$13, _$ssrAttribute("data-active", active() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-closable", item().onClose !== undefined ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-movable", props.canMove() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-dnd-active", props.dnd.activeId() === draggableId(itemId) ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
|
|
571
912
|
get when() {
|
|
572
913
|
return targetBefore(itemId);
|
|
573
914
|
},
|
|
@@ -583,7 +924,14 @@ function PanesGroupRenderer(props) {
|
|
|
583
924
|
},
|
|
584
925
|
placement: "tab"
|
|
585
926
|
})
|
|
586
|
-
})), _$ssrAttribute("id", _$escape(tabId(itemId), true), false), _$ssrAttribute("aria-label", _$escape(item().title, true), false) + _$ssrAttribute("aria-selected", _$escape(active(), true), false) + _$ssrAttribute("aria-controls", active() ? _$escape(panelId(itemId), true) : _$escape(undefined, true), false) + _$ssrAttribute("aria-posinset", _$escape(index(), true) + 1, false) + _$ssrAttribute("aria-setsize", _$escape(itemIds().length, true), false) + _$ssrAttribute("aria-keyshortcuts", item().onClose ? "Delete Backspace" : _$escape(undefined, true), false) + _$ssrAttribute("tabindex", active() ? 0 : -1, false) + _$ssrAttribute("title", _$escape(item().title, true), false)
|
|
927
|
+
})), _$ssrAttribute("id", _$escape(tabId(itemId), true), false), _$ssrAttribute("aria-label", _$escape(item().title, true), false) + _$ssrAttribute("aria-selected", _$escape(active(), true), false) + _$ssrAttribute("aria-controls", active() ? _$escape(panelId(itemId), true) : _$escape(undefined, true), false) + _$ssrAttribute("aria-posinset", _$escape(index(), true) + 1, false) + _$ssrAttribute("aria-setsize", _$escape(itemIds().length, true), false) + _$ssrAttribute("aria-keyshortcuts", item().onClose ? "Delete Backspace" : _$escape(undefined, true), false) + _$ssrAttribute("tabindex", active() ? 0 : -1, false) + _$ssrAttribute("title", _$escape(item().title, true), false) + _$ssrAttribute("aria-haspopup", props.canMove() ? "menu" : _$escape(undefined, true), false), _$escape(_$createComponent(Show, {
|
|
928
|
+
get when() {
|
|
929
|
+
return props.canMove();
|
|
930
|
+
},
|
|
931
|
+
get children() {
|
|
932
|
+
return _$ssr(_tmpl$11);
|
|
933
|
+
}
|
|
934
|
+
})), `${_$escape(iconClass(item().icon), true)} k2b-panes__icon`, _$escape(item().title), _$escape(_$createComponent(Show, {
|
|
587
935
|
get when() {
|
|
588
936
|
return item().onClose !== undefined;
|
|
589
937
|
},
|
|
@@ -607,7 +955,7 @@ function PanesGroupRenderer(props) {
|
|
|
607
955
|
item().onClose?.();
|
|
608
956
|
},
|
|
609
957
|
get children() {
|
|
610
|
-
return _$ssr(_tmpl$
|
|
958
|
+
return _$ssr(_tmpl$12);
|
|
611
959
|
}
|
|
612
960
|
});
|
|
613
961
|
}
|
|
@@ -645,16 +993,23 @@ function PanesGroupRenderer(props) {
|
|
|
645
993
|
},
|
|
646
994
|
onClick: () => props.addItem(props.node().active),
|
|
647
995
|
get children() {
|
|
648
|
-
return _$ssr(_tmpl$
|
|
996
|
+
return _$ssr(_tmpl$9);
|
|
649
997
|
}
|
|
650
998
|
});
|
|
651
999
|
}
|
|
1000
|
+
})), _$escape(_$createComponent(Show, {
|
|
1001
|
+
get when() {
|
|
1002
|
+
return isHost();
|
|
1003
|
+
},
|
|
1004
|
+
get children() {
|
|
1005
|
+
return props.arrange();
|
|
1006
|
+
}
|
|
652
1007
|
})), _$escape(_$createComponent(Show, {
|
|
653
1008
|
get when() {
|
|
654
1009
|
return scrollbar().overflow;
|
|
655
1010
|
},
|
|
656
1011
|
get children() {
|
|
657
|
-
return _$ssr(_tmpl$
|
|
1012
|
+
return _$ssr(_tmpl$0, _$ssrStyleProperty("width:", `${_$escape(scrollbar().track, true)}px`) + _$ssrStyleProperty(";right:", "auto"), _$ssrStyleProperty("--k2b-panes-scroll-left:", `${_$escape(scrollbar().left, true)}px`) + _$ssrStyleProperty(";--k2b-panes-scroll-width:", `${_$escape(scrollbar().width, true)}px`));
|
|
658
1013
|
}
|
|
659
1014
|
})), _$ssrAttribute("id", _$escape(panelId(props.node().active), true), false), _$ssrAttribute("aria-labelledby", _$escape(tabId(props.node().active), true), false), _$escape(_$createComponent(Show, {
|
|
660
1015
|
get when() {
|
|
@@ -672,7 +1027,7 @@ function PanesGroupRenderer(props) {
|
|
|
672
1027
|
return bodyTargets().length > 0;
|
|
673
1028
|
},
|
|
674
1029
|
get children() {
|
|
675
|
-
return _$ssr(_tmpl$
|
|
1030
|
+
return _$ssr(_tmpl$1, _$escape(_$createComponent(For, {
|
|
676
1031
|
get each() {
|
|
677
1032
|
return bodyTargets();
|
|
678
1033
|
},
|
|
@@ -699,18 +1054,18 @@ function PanesDropTargetView(props) {
|
|
|
699
1054
|
if (props.target.side === "left") return "ti ti-column-insert-left";
|
|
700
1055
|
return "ti ti-column-insert-right";
|
|
701
1056
|
};
|
|
702
|
-
return _$ssr(_tmpl$
|
|
1057
|
+
return _$ssr(_tmpl$14, _$ssrAttribute("data-kind", _$escape(props.target.kind, true), false) + _$ssrAttribute("data-placement", _$escape(props.placement, true), false) + _$ssrAttribute("data-zone", _$escape(props.target.side, true), false) + _$ssrAttribute("data-active", props.dnd.overId() === `panes-target:${props.target.id}` ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("title", _$escape(props.label, true), false), _$escape(_$createComponent(Show, {
|
|
703
1058
|
get when() {
|
|
704
1059
|
return icon();
|
|
705
1060
|
},
|
|
706
1061
|
keyed: true,
|
|
707
|
-
children: iconClass => _$ssr(_tmpl$
|
|
1062
|
+
children: iconClass => _$ssr(_tmpl$15, _$ssrAttribute("class", _$escape(iconClass, true), false))
|
|
708
1063
|
})), _$escape(_$createComponent(Show, {
|
|
709
1064
|
get when() {
|
|
710
1065
|
return props.target.kind === "split";
|
|
711
1066
|
},
|
|
712
1067
|
get children() {
|
|
713
|
-
return _$ssr(_tmpl$
|
|
1068
|
+
return _$ssr(_tmpl$7, _$escape(props.label));
|
|
714
1069
|
}
|
|
715
1070
|
})));
|
|
716
1071
|
}
|