@nvidia-elements/core 2.22.5 → 2.23.1
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/CHANGELOG.md +15 -0
- package/dist/accordion/accordion2.js +4 -4
- package/dist/alert/alert-group2.js +1 -1
- package/dist/alert/alert2.js +1 -1
- package/dist/avatar/avatar-group2.js +1 -1
- package/dist/avatar/avatar2.js +1 -1
- package/dist/badge/badge2.js +1 -1
- package/dist/breadcrumb/breadcrumb2.js +1 -1
- package/dist/bundle.d.ts +4 -0
- package/dist/bundles/index.d.ts +357 -1
- package/dist/bundles/index.js +14 -14
- package/dist/button/button2.js +1 -1
- package/dist/button-group/button-group2.js +1 -1
- package/dist/card/card2.js +4 -4
- package/dist/chat-message/chat-message2.js +1 -1
- package/dist/checkbox/checkbox-group2.js +1 -1
- package/dist/checkbox/checkbox2.js +1 -1
- package/dist/color/color2.js +6 -6
- package/dist/combobox/combobox2.js +1 -1
- package/dist/copy-button/copy-button2.js +1 -1
- package/dist/custom-elements-jsx.d.ts +189 -0
- package/dist/custom-elements-vue.d.ts +189 -0
- package/dist/custom-elements.json +6561 -339
- package/dist/data.html.json +133 -0
- package/dist/date/date2.js +6 -6
- package/dist/datetime/datetime2.js +6 -6
- package/dist/dialog/dialog-footer2.js +1 -1
- package/dist/dialog/dialog-header2.js +1 -1
- package/dist/dialog/dialog2.js +1 -1
- package/dist/divider/divider2.js +1 -1
- package/dist/dot/dot2.js +1 -1
- package/dist/drag-handle/drag-handle2.js +1 -1
- package/dist/drawer/drawer-content2.js +1 -1
- package/dist/drawer/drawer-footer2.js +1 -1
- package/dist/drawer/drawer-header2.js +1 -1
- package/dist/drawer/drawer2.js +1 -1
- package/dist/dropdown/dropdown-footer2.js +1 -1
- package/dist/dropdown/dropdown-header2.js +1 -1
- package/dist/dropdown/dropdown2.js +1 -1
- package/dist/dropdown-group/dropdown-group.js +1 -1
- package/dist/dropzone/dropzone2.js +1 -1
- package/dist/file/file2.js +1 -1
- package/dist/format-bytes/format-bytes2.js +1 -1
- package/dist/format-datetime/format-datetime2.js +1 -1
- package/dist/format-number/format-number2.js +1 -1
- package/dist/format-relative-time/format-relative-time2.js +1 -1
- package/dist/format-truncate/format-truncate2.js +1 -1
- package/dist/forms/control/control2.js +1 -1
- package/dist/forms/control-group/control-group2.js +1 -1
- package/dist/forms/control-message/control-message2.js +1 -1
- package/dist/forms/utils/layout.d.ts +0 -1
- package/dist/forms/utils/layout.js.map +1 -1
- package/dist/forms/utils/states.d.ts +0 -1
- package/dist/forms/utils/states.js.map +1 -1
- package/dist/gauge/gauge2.js +1 -1
- package/dist/ghost/define.d.ts +6 -0
- package/dist/ghost/define.js +6 -0
- package/dist/ghost/define.js.map +1 -0
- package/dist/ghost/ghost.d.ts +27 -0
- package/dist/ghost/ghost.examples.js +5 -0
- package/dist/ghost/ghost.examples.js.map +1 -0
- package/dist/ghost/ghost.examples.json +37 -0
- package/dist/ghost/ghost.js +5 -0
- package/dist/ghost/ghost.js.map +1 -0
- package/dist/ghost/ghost2.js +28 -0
- package/dist/ghost/ghost2.js.map +1 -0
- package/dist/ghost/index.d.ts +1 -0
- package/dist/ghost/index.js +1 -0
- package/dist/grid/cell/cell2.js +1 -1
- package/dist/grid/column/column2.js +1 -1
- package/dist/grid/footer/footer2.js +1 -1
- package/dist/grid/grid2.js +1 -1
- package/dist/grid/header/header2.js +1 -1
- package/dist/grid/placeholder/placeholder2.js +1 -1
- package/dist/grid/row/row2.js +1 -1
- package/dist/icon/icon2.js +2 -2
- package/dist/icon-button/icon-button2.js +1 -1
- package/dist/iframe/iframe2.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/input/input-group2.js +1 -1
- package/dist/input/input2.js +1 -1
- package/dist/internal/controllers/keynav-spatial.controller.d.ts +0 -1
- package/dist/internal/controllers/keynav-spatial.controller.js.map +1 -1
- package/dist/internal/controllers/type-native-popover.utils.d.ts +0 -1
- package/dist/internal/controllers/type-native-popover.utils.js.map +1 -1
- package/dist/internal/index.d.ts +0 -1
- package/dist/internal/index.js +116 -128
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/types/index.d.ts +37 -3
- package/dist/internal/types/index.js.map +1 -1
- package/dist/internal/utils/audit-logs.d.ts +0 -1
- package/dist/internal/utils/audit-logs.js.map +1 -1
- package/dist/internal/utils/dom.d.ts +0 -5
- package/dist/internal/utils/dom.js +30 -46
- package/dist/internal/utils/dom.js.map +1 -1
- package/dist/internal/utils/events.d.ts +0 -1
- package/dist/internal/utils/events.js +4 -7
- package/dist/internal/utils/events.js.map +1 -1
- package/dist/internal/utils/keynav.d.ts +0 -1
- package/dist/internal/utils/keynav.js +2 -5
- package/dist/internal/utils/keynav.js.map +1 -1
- package/dist/internal/utils/objects.d.ts +0 -2
- package/dist/internal/utils/objects.js +2 -8
- package/dist/internal/utils/objects.js.map +1 -1
- package/dist/joystick/joystick2.js +5 -5
- package/dist/logo/logo2.js +1 -1
- package/dist/menu/menu-group2.js +1 -1
- package/dist/menu/menu-item2.js +1 -1
- package/dist/menu/menu2.js +1 -1
- package/dist/month/month2.js +6 -6
- package/dist/notification/notification-group2.js +1 -1
- package/dist/notification/notification2.js +1 -1
- package/dist/page/page-panel/page-panel-content2.js +1 -1
- package/dist/page/page-panel/page-panel-footer2.js +1 -1
- package/dist/page/page-panel/page-panel-header2.js +1 -1
- package/dist/page/page-panel/page-panel2.js +1 -1
- package/dist/page/page2.js +1 -1
- package/dist/page-header/page-header2.js +1 -1
- package/dist/page-loader/page-loader2.js +1 -1
- package/dist/pagination/pagination2.js +1 -1
- package/dist/panel/panel2.js +4 -4
- package/dist/password/password2.js +6 -6
- package/dist/preferences-input/preferences-input2.js +5 -5
- package/dist/progress-bar/progress-bar2.js +1 -1
- package/dist/progress-dot/progress-dot2.js +1 -1
- package/dist/progress-ring/progress-ring2.js +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip2.js +1 -1
- package/dist/pulse/pulse2.js +1 -1
- package/dist/radio/radio-group2.js +1 -1
- package/dist/radio/radio2.js +1 -1
- package/dist/range/range2.js +1 -1
- package/dist/resize-handle/resize-handle2.js +5 -5
- package/dist/search/search2.js +6 -6
- package/dist/select/select2.js +1 -1
- package/dist/skeleton/skeleton2.js +1 -1
- package/dist/sort-button/sort-button2.js +1 -1
- package/dist/sparkline/sparkline2.js +1 -1
- package/dist/star-rating/star-rating2.js +1 -1
- package/dist/steps/steps2.js +6 -6
- package/dist/switch/switch-group2.js +1 -1
- package/dist/switch/switch2.js +1 -1
- package/dist/tabs/tabs-group2.js +1 -1
- package/dist/tabs/tabs-item-group2.js +1 -1
- package/dist/tabs/tabs2.js +2 -2
- package/dist/tag/tag2.js +5 -5
- package/dist/textarea/textarea2.js +1 -1
- package/dist/time/time2.js +6 -6
- package/dist/toast/toast2.js +1 -1
- package/dist/toggletip/toggletip-footer2.js +1 -1
- package/dist/toggletip/toggletip-header2.js +1 -1
- package/dist/toggletip/toggletip2.js +1 -1
- package/dist/toolbar/toolbar2.js +1 -1
- package/dist/tooltip/tooltip2.js +1 -1
- package/dist/tree/tree-node2.js +1 -1
- package/dist/tree/tree2.js +1 -1
- package/dist/week/week2.js +6 -6
- package/dist/workspace/controllers/workspace-command.controller.d.ts +34 -0
- package/dist/workspace/controllers/workspace-command.controller.js +87 -0
- package/dist/workspace/controllers/workspace-command.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-composition.controller.d.ts +54 -0
- package/dist/workspace/controllers/workspace-composition.controller.js +169 -0
- package/dist/workspace/controllers/workspace-composition.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-fullscreen.controller.d.ts +25 -0
- package/dist/workspace/controllers/workspace-fullscreen.controller.js +84 -0
- package/dist/workspace/controllers/workspace-fullscreen.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-measurement.controller.d.ts +19 -0
- package/dist/workspace/controllers/workspace-measurement.controller.js +188 -0
- package/dist/workspace/controllers/workspace-measurement.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-rearrange.controller.d.ts +40 -0
- package/dist/workspace/controllers/workspace-rearrange.controller.js +385 -0
- package/dist/workspace/controllers/workspace-rearrange.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-resize.controller.d.ts +43 -0
- package/dist/workspace/controllers/workspace-resize.controller.js +168 -0
- package/dist/workspace/controllers/workspace-resize.controller.js.map +1 -0
- package/dist/workspace/controllers/workspace-restoration.controller.d.ts +24 -0
- package/dist/workspace/controllers/workspace-restoration.controller.js +193 -0
- package/dist/workspace/controllers/workspace-restoration.controller.js.map +1 -0
- package/dist/workspace/define.d.ts +10 -0
- package/dist/workspace/define.js +9 -0
- package/dist/workspace/define.js.map +1 -0
- package/dist/workspace/index.d.ts +11 -0
- package/dist/workspace/index.js +6 -0
- package/dist/workspace/panel/panel.d.ts +48 -0
- package/dist/workspace/panel/panel.js +5 -0
- package/dist/workspace/panel/panel.js.map +1 -0
- package/dist/workspace/panel/panel2.js +53 -0
- package/dist/workspace/panel/panel2.js.map +1 -0
- package/dist/workspace/panel-content/panel-content.d.ts +20 -0
- package/dist/workspace/panel-content/panel-content.js +5 -0
- package/dist/workspace/panel-content/panel-content.js.map +1 -0
- package/dist/workspace/panel-content/panel-content2.js +22 -0
- package/dist/workspace/panel-content/panel-content2.js.map +1 -0
- package/dist/workspace/panel-footer/panel-footer.d.ts +24 -0
- package/dist/workspace/panel-footer/panel-footer.js +5 -0
- package/dist/workspace/panel-footer/panel-footer.js.map +1 -0
- package/dist/workspace/panel-footer/panel-footer2.js +28 -0
- package/dist/workspace/panel-footer/panel-footer2.js.map +1 -0
- package/dist/workspace/panel-header/panel-header.d.ts +61 -0
- package/dist/workspace/panel-header/panel-header.js +5 -0
- package/dist/workspace/panel-header/panel-header.js.map +1 -0
- package/dist/workspace/panel-header/panel-header2.js +102 -0
- package/dist/workspace/panel-header/panel-header2.js.map +1 -0
- package/dist/workspace/utils/evaluation.utils.d.ts +83 -0
- package/dist/workspace/utils/evaluation.utils.js +294 -0
- package/dist/workspace/utils/evaluation.utils.js.map +1 -0
- package/dist/workspace/utils/geometry/allocation.utils.d.ts +40 -0
- package/dist/workspace/utils/geometry/allocation.utils.js +73 -0
- package/dist/workspace/utils/geometry/allocation.utils.js.map +1 -0
- package/dist/workspace/utils/geometry/partition.utils.d.ts +10 -0
- package/dist/workspace/utils/geometry/partition.utils.js +40 -0
- package/dist/workspace/utils/geometry/partition.utils.js.map +1 -0
- package/dist/workspace/utils/geometry/sizing.utils.d.ts +35 -0
- package/dist/workspace/utils/geometry/sizing.utils.js +42 -0
- package/dist/workspace/utils/geometry/sizing.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/boundary.utils.d.ts +40 -0
- package/dist/workspace/utils/interaction/boundary.utils.js +91 -0
- package/dist/workspace/utils/interaction/boundary.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/command.utils.d.ts +74 -0
- package/dist/workspace/utils/interaction/command.utils.js +189 -0
- package/dist/workspace/utils/interaction/command.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/drag-preview.utils.d.ts +79 -0
- package/dist/workspace/utils/interaction/drag-preview.utils.js +16 -0
- package/dist/workspace/utils/interaction/drag-preview.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/insertion-offers.utils.d.ts +58 -0
- package/dist/workspace/utils/interaction/insertion-offers.utils.js +259 -0
- package/dist/workspace/utils/interaction/insertion-offers.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/placement-decision.utils.d.ts +55 -0
- package/dist/workspace/utils/interaction/placement-decision.utils.js +242 -0
- package/dist/workspace/utils/interaction/placement-decision.utils.js.map +1 -0
- package/dist/workspace/utils/interaction/resize-input.utils.d.ts +1 -0
- package/dist/workspace/utils/interaction/resize-input.utils.js +17 -0
- package/dist/workspace/utils/interaction/resize-input.utils.js.map +1 -0
- package/dist/workspace/utils/model/layout.utils.d.ts +22 -0
- package/dist/workspace/utils/model/layout.utils.js +41 -0
- package/dist/workspace/utils/model/layout.utils.js.map +1 -0
- package/dist/workspace/utils/model/membership.utils.d.ts +14 -0
- package/dist/workspace/utils/model/membership.utils.js +17 -0
- package/dist/workspace/utils/model/membership.utils.js.map +1 -0
- package/dist/workspace/utils/model/operations.utils.d.ts +31 -0
- package/dist/workspace/utils/model/operations.utils.js +178 -0
- package/dist/workspace/utils/model/operations.utils.js.map +1 -0
- package/dist/workspace/utils/model/projection.utils.d.ts +7 -0
- package/dist/workspace/utils/model/projection.utils.js +87 -0
- package/dist/workspace/utils/model/projection.utils.js.map +1 -0
- package/dist/workspace/utils/model/value.utils.d.ts +5 -0
- package/dist/workspace/utils/model/value.utils.js +68 -0
- package/dist/workspace/utils/model/value.utils.js.map +1 -0
- package/dist/workspace/utils/placement/acquisition-sizing.utils.d.ts +32 -0
- package/dist/workspace/utils/placement/acquisition-sizing.utils.js +152 -0
- package/dist/workspace/utils/placement/acquisition-sizing.utils.js.map +1 -0
- package/dist/workspace/utils/placement/context.utils.d.ts +36 -0
- package/dist/workspace/utils/placement/context.utils.js +135 -0
- package/dist/workspace/utils/placement/context.utils.js.map +1 -0
- package/dist/workspace/utils/placement/group-insertion.utils.d.ts +26 -0
- package/dist/workspace/utils/placement/group-insertion.utils.js +171 -0
- package/dist/workspace/utils/placement/group-insertion.utils.js.map +1 -0
- package/dist/workspace/utils/placement/origin.utils.d.ts +13 -0
- package/dist/workspace/utils/placement/origin.utils.js +49 -0
- package/dist/workspace/utils/placement/origin.utils.js.map +1 -0
- package/dist/workspace/utils/placement/planner.utils.d.ts +22 -0
- package/dist/workspace/utils/placement/planner.utils.js +184 -0
- package/dist/workspace/utils/placement/planner.utils.js.map +1 -0
- package/dist/workspace/utils/placement/preparation.utils.d.ts +28 -0
- package/dist/workspace/utils/placement/preparation.utils.js +140 -0
- package/dist/workspace/utils/placement/preparation.utils.js.map +1 -0
- package/dist/workspace/utils/placement/region.utils.d.ts +15 -0
- package/dist/workspace/utils/placement/region.utils.js +111 -0
- package/dist/workspace/utils/placement/region.utils.js.map +1 -0
- package/dist/workspace/utils/placement/split-sizing.utils.d.ts +18 -0
- package/dist/workspace/utils/placement/split-sizing.utils.js +108 -0
- package/dist/workspace/utils/placement/split-sizing.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/composition.utils.d.ts +17 -0
- package/dist/workspace/utils/presentation/composition.utils.js +95 -0
- package/dist/workspace/utils/presentation/composition.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/groups.utils.d.ts +91 -0
- package/dist/workspace/utils/presentation/groups.utils.js +169 -0
- package/dist/workspace/utils/presentation/groups.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/header-configuration.utils.d.ts +11 -0
- package/dist/workspace/utils/presentation/header-configuration.utils.js +7 -0
- package/dist/workspace/utils/presentation/header-configuration.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/measurements.utils.d.ts +21 -0
- package/dist/workspace/utils/presentation/measurements.utils.js +28 -0
- package/dist/workspace/utils/presentation/measurements.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/offers.utils.d.ts +43 -0
- package/dist/workspace/utils/presentation/offers.utils.js +137 -0
- package/dist/workspace/utils/presentation/offers.utils.js.map +1 -0
- package/dist/workspace/utils/presentation/preview.utils.d.ts +6 -0
- package/dist/workspace/utils/presentation/preview.utils.js +36 -0
- package/dist/workspace/utils/presentation/preview.utils.js.map +1 -0
- package/dist/workspace/workspace.d.ts +103 -0
- package/dist/workspace/workspace.examples.js +5 -0
- package/dist/workspace/workspace.examples.js.map +1 -0
- package/dist/workspace/workspace.examples.json +133 -0
- package/dist/workspace/workspace.js +5 -0
- package/dist/workspace/workspace.js.map +1 -0
- package/dist/workspace/workspace.types.d.ts +3 -0
- package/dist/workspace/workspace2.js +518 -0
- package/dist/workspace/workspace2.js.map +1 -0
- package/package.json +27 -3
- package/dist/internal/utils/supports.d.ts +0 -3
- package/dist/internal/utils/supports.js +0 -13
- package/dist/internal/utils/supports.js.map +0 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { getPanelIds as e, normalizeLayout as t, normalizeOwnedLayout as n } from "./layout.utils.js";
|
|
2
|
+
import { sameSerializedWorkspaceLayout as r } from "./value.utils.js";
|
|
3
|
+
// src/workspace/utils/model/operations.utils.ts
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
if (e) {
|
|
6
|
+
if (e.type === "group") return t === void 0 || e.panels.includes(t) ? e : void 0;
|
|
7
|
+
for (let n of e.children) {
|
|
8
|
+
let e = i(n, t);
|
|
9
|
+
if (e) return e;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function a(e, t) {
|
|
14
|
+
if (!e) return null;
|
|
15
|
+
if (e.type === "group") {
|
|
16
|
+
let n = t(e);
|
|
17
|
+
return n?.type !== "group" || n.panels !== e.panels ? n : {
|
|
18
|
+
...n,
|
|
19
|
+
panels: [...n.panels]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
let r = [], i = [];
|
|
23
|
+
return e.children.forEach((n, o) => {
|
|
24
|
+
let s = a(n, t), c = e.weights[o];
|
|
25
|
+
s && c !== void 0 && (r.push(s), i.push(c));
|
|
26
|
+
}), r.length ? r.length === 1 ? r[0] ?? null : n({
|
|
27
|
+
type: "split",
|
|
28
|
+
axis: e.axis,
|
|
29
|
+
children: r,
|
|
30
|
+
weights: i
|
|
31
|
+
}) : null;
|
|
32
|
+
}
|
|
33
|
+
function o(e, t) {
|
|
34
|
+
let n = e.panels.filter(t), r = n[0];
|
|
35
|
+
return r === void 0 ? null : {
|
|
36
|
+
type: "group",
|
|
37
|
+
panels: n,
|
|
38
|
+
active: n.includes(e.active) ? e.active : r
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function s(e, t, n) {
|
|
42
|
+
if (!t.length) return e;
|
|
43
|
+
let r = i(e);
|
|
44
|
+
return r ? a(e, (e) => ({
|
|
45
|
+
...e,
|
|
46
|
+
panels: e === r ? [...e.panels, ...t] : [...e.panels],
|
|
47
|
+
active: e === r ? n ?? e.active : e.active
|
|
48
|
+
})) : {
|
|
49
|
+
type: "group",
|
|
50
|
+
panels: [...t],
|
|
51
|
+
active: n ?? t[0] ?? ""
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function c(e, t) {
|
|
55
|
+
return t.length === 1 || t.length === e.panels.length && t.every((t, n) => e.panels[n] === t);
|
|
56
|
+
}
|
|
57
|
+
function l(e) {
|
|
58
|
+
return e === void 0 || Number.isInteger(e) && e >= 0;
|
|
59
|
+
}
|
|
60
|
+
function u(e, t) {
|
|
61
|
+
let n = new Set(t);
|
|
62
|
+
return {
|
|
63
|
+
version: 1,
|
|
64
|
+
root: a(e.root, (e) => o(e, (e) => !n.has(e))),
|
|
65
|
+
closed: e.closed.filter((e) => !n.has(e))
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function d(e) {
|
|
69
|
+
let { layout: t, source: n, destination: r, splitWeights: i = [.5, .5] } = e;
|
|
70
|
+
if (r.region || !i.every((e) => Number.isFinite(e) && e > 0)) return;
|
|
71
|
+
let s = h(t, n, r);
|
|
72
|
+
if (!s) return;
|
|
73
|
+
let { sourceGroup: c, targetGroup: l } = s, u = n[0], d = new Set(n), g = l.panels.find((e) => !d.has(e));
|
|
74
|
+
if (!g) return t;
|
|
75
|
+
let _ = a(t.root, (e) => o(e, (e) => !d.has(e))), v = {
|
|
76
|
+
source: n,
|
|
77
|
+
destination: r,
|
|
78
|
+
sourceGroup: c,
|
|
79
|
+
targetGroup: l,
|
|
80
|
+
moving: {
|
|
81
|
+
type: "group",
|
|
82
|
+
panels: [...n],
|
|
83
|
+
active: n.includes(c.active) ? c.active : u
|
|
84
|
+
},
|
|
85
|
+
removed: d,
|
|
86
|
+
splitWeights: i
|
|
87
|
+
};
|
|
88
|
+
return m(t, a(_, (e) => e.panels.includes(g) ? r.position === "tab" ? f(e, v) : p(e, v) : {
|
|
89
|
+
...e,
|
|
90
|
+
panels: [...e.panels]
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
function f(e, { source: t, sourceGroup: n, targetGroup: r, moving: i, destination: a, removed: o }) {
|
|
94
|
+
let s = Math.min(a.index ?? r.panels.length, r.panels.length), c = s - r.panels.slice(0, s).filter((e) => o.has(e)).length, l = [...e.panels];
|
|
95
|
+
return l.splice(c, 0, ...t), {
|
|
96
|
+
type: "group",
|
|
97
|
+
panels: l,
|
|
98
|
+
active: n === r ? n.active : i.active
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function p(e, { moving: t, destination: n, splitWeights: r }) {
|
|
102
|
+
let i = n.position === "left" || n.position === "top";
|
|
103
|
+
return {
|
|
104
|
+
type: "split",
|
|
105
|
+
axis: n.position === "left" || n.position === "right" ? "horizontal" : "vertical",
|
|
106
|
+
weights: i ? [...r] : [...r].reverse(),
|
|
107
|
+
children: i ? [t, e] : [e, t]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function m(e, n) {
|
|
111
|
+
let i = {
|
|
112
|
+
version: 1,
|
|
113
|
+
root: n ? t(n) : null,
|
|
114
|
+
closed: [...e.closed]
|
|
115
|
+
}, a = {
|
|
116
|
+
...e,
|
|
117
|
+
root: e.root ? t(e.root) : null
|
|
118
|
+
};
|
|
119
|
+
return r(i, a) ? e : i;
|
|
120
|
+
}
|
|
121
|
+
function h(e, t, n) {
|
|
122
|
+
let r = t[0];
|
|
123
|
+
if (r === void 0 || new Set(t).size !== t.length) return;
|
|
124
|
+
let a = i(e.root, r), o = i(e.root, n.target);
|
|
125
|
+
if (a && o && !(n.position !== "tab" && t.includes(n.target)) && c(a, t) && l(n.index)) return {
|
|
126
|
+
sourceGroup: a,
|
|
127
|
+
targetGroup: o
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function g(e, t) {
|
|
131
|
+
if (i(e.root, t) && !e.closed.includes(t)) return {
|
|
132
|
+
...e,
|
|
133
|
+
closed: [...e.closed, t]
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function _(e, t) {
|
|
137
|
+
if (e.closed.includes(t)) return {
|
|
138
|
+
...e,
|
|
139
|
+
closed: e.closed.filter((e) => e !== t)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function v(t, n) {
|
|
143
|
+
let r = new Set(e(t.root)), i = n.filter((e) => !r.has(e) && (r.add(e), !0));
|
|
144
|
+
return i.length ? {
|
|
145
|
+
version: 1,
|
|
146
|
+
root: s(t.root, i),
|
|
147
|
+
closed: [...t.closed]
|
|
148
|
+
} : t;
|
|
149
|
+
}
|
|
150
|
+
function y(e, t) {
|
|
151
|
+
let n = new Set(t.filter((t) => !e.closed.includes(t)));
|
|
152
|
+
return {
|
|
153
|
+
version: 1,
|
|
154
|
+
root: a(e.root, (e) => o(e, (e) => n.has(e))),
|
|
155
|
+
closed: []
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function b(e, t) {
|
|
159
|
+
if (e.closed.includes(t) || !i(e.root, t)) return;
|
|
160
|
+
let n = a(e.root, (e) => e.panels.includes(t) ? {
|
|
161
|
+
...e,
|
|
162
|
+
active: t
|
|
163
|
+
} : e), o = {
|
|
164
|
+
...e,
|
|
165
|
+
root: n
|
|
166
|
+
};
|
|
167
|
+
return r(o, e) ? void 0 : o;
|
|
168
|
+
}
|
|
169
|
+
function x(e, t) {
|
|
170
|
+
let n = t ? i(e.root, t) : void 0;
|
|
171
|
+
return n ? {
|
|
172
|
+
...e,
|
|
173
|
+
root: n
|
|
174
|
+
} : void 0;
|
|
175
|
+
}
|
|
176
|
+
export { g as closePanel, u as createDetachedLayout, i as findGroup, x as getFullscreenWorkspaceLayout, l as isValidInsertionIndex, _ as openPanel, d as placePanels, y as projectLayout, v as reconcilePanels, b as selectPanel };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=operations.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.utils.js","names":["findGroup","node","id","child","group","mapGroups","mapped","visit","children","weights","weight","index","normalizeOwnedLayout","filterGroup","panels","keep","first","appendPanels","root","active","validSource","source","isValidInsertionIndex","createDetachedLayout","removed","layout","placePanels","input","destination","splitWeights","match","moveSource","target","targetGroup","stripped","context","sourceGroup","placedLayout","joinTargetGroup","splitTargetGroup","originalIndex","moving","before","result","normalizeLayout","normalized","sameSerializedWorkspaceLayout","closePanel","openPanel","panel","reconcilePanels","saved","getPanelIds","added","available","projectLayout","visible","selectPanel","next","getFullscreenWorkspaceLayout","anchor"],"sources":["../../../../src/workspace/utils/model/operations.utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getPanelIds, normalizeLayout, normalizeOwnedLayout } from './layout.utils.js';\nimport { sameSerializedWorkspaceLayout } from './value.utils.js';\n\nimport type { WorkspaceGroup, WorkspaceLayout, WorkspaceNode } from './layout.utils.js';\n\nexport interface WorkspaceDestination {\n target: string;\n /** Region path in the visible projection of the current layout. */\n region?: string;\n position: 'tab' | 'left' | 'right' | 'top' | 'bottom';\n index?: number;\n}\n\ninterface TargetGroupContext {\n source: string[];\n destination: WorkspaceDestination;\n sourceGroup: WorkspaceGroup;\n targetGroup: WorkspaceGroup;\n moving: WorkspaceGroup;\n removed: Set<string>;\n splitWeights: [number, number];\n}\n\nexport function findGroup(node: WorkspaceNode | null, id?: string): WorkspaceGroup | undefined {\n if (!node) return undefined;\n if (node.type === 'group') return id === undefined || node.panels.includes(id) ? node : undefined;\n for (const child of node.children) {\n const group = findGroup(child, id);\n if (group) return group;\n }\n return undefined;\n}\n\nfunction mapGroups(\n node: WorkspaceNode | null,\n visit: (group: WorkspaceGroup) => WorkspaceNode | null\n): WorkspaceNode | null {\n if (!node) return null;\n if (node.type === 'group') {\n const mapped = visit(node);\n if (mapped?.type !== 'group' || mapped.panels !== node.panels) return mapped;\n return { ...mapped, panels: [...mapped.panels] };\n }\n const children: WorkspaceNode[] = [];\n const weights: number[] = [];\n node.children.forEach((child, index) => {\n const mapped = mapGroups(child, visit);\n const weight = node.weights[index];\n if (mapped && weight !== undefined) {\n children.push(mapped);\n weights.push(weight);\n }\n });\n if (!children.length) return null;\n if (children.length === 1) return children[0] ?? null;\n return normalizeOwnedLayout({ type: 'split', axis: node.axis, children, weights });\n}\n\nfunction filterGroup(group: WorkspaceGroup, keep: (id: string) => boolean): WorkspaceGroup | null {\n const panels = group.panels.filter(keep);\n const first = panels[0];\n if (first === undefined) return null;\n return { type: 'group', panels, active: panels.includes(group.active) ? group.active : first };\n}\n\nfunction appendPanels(root: WorkspaceNode | null, panels: string[], active?: string): WorkspaceNode | null {\n if (!panels.length) return root;\n const first = findGroup(root);\n return first\n ? mapGroups(root, group => ({\n ...group,\n panels: group === first ? [...group.panels, ...panels] : [...group.panels],\n active: group === first ? (active ?? group.active) : group.active\n }))\n : { type: 'group', panels: [...panels], active: active ?? panels[0] ?? '' };\n}\n\nfunction validSource(group: WorkspaceGroup, source: string[]): boolean {\n return (\n source.length === 1 ||\n (source.length === group.panels.length && source.every((id, index) => group.panels[index] === id))\n );\n}\n\nexport function isValidInsertionIndex(index: number | undefined): boolean {\n return index === undefined || (Number.isInteger(index) && index >= 0);\n}\n\n/** Removes carried panels from the arrangement and closed list without changing the saved layout. */\nexport function createDetachedLayout(layout: WorkspaceLayout, source: string[]): WorkspaceLayout {\n const removed = new Set(source);\n return {\n version: 1,\n root: mapGroups(layout.root, group => filterGroup(group, id => !removed.has(id))),\n closed: layout.closed.filter(id => !removed.has(id))\n };\n}\n\nexport function placePanels(input: {\n layout: WorkspaceLayout;\n source: string[];\n destination: WorkspaceDestination;\n splitWeights?: [number, number];\n}): WorkspaceLayout | undefined {\n const { layout, source, destination, splitWeights = [0.5, 0.5] } = input;\n if (destination.region) return undefined;\n if (!splitWeights.every(weight => Number.isFinite(weight) && weight > 0)) return undefined;\n const match = moveSource(layout, source, destination);\n if (!match) return undefined;\n const { sourceGroup, targetGroup } = match;\n const first = source[0]!;\n const removed = new Set(source);\n const target = targetGroup.panels.find(id => !removed.has(id));\n if (!target) return layout;\n const stripped = mapGroups(layout.root, group => filterGroup(group, id => !removed.has(id)));\n const moving: WorkspaceGroup = {\n type: 'group',\n panels: [...source],\n active: source.includes(sourceGroup.active) ? sourceGroup.active : first\n };\n const context: TargetGroupContext = { source, destination, sourceGroup, targetGroup, moving, removed, splitWeights };\n const root = mapGroups(stripped, group => {\n if (!group.panels.includes(target)) return { ...group, panels: [...group.panels] };\n return destination.position === 'tab' ? joinTargetGroup(group, context) : splitTargetGroup(group, context);\n });\n return placedLayout(layout, root);\n}\n\nfunction joinTargetGroup(\n group: WorkspaceGroup,\n { source, sourceGroup, targetGroup, moving, destination, removed }: TargetGroupContext\n): WorkspaceGroup {\n const originalIndex = Math.min(destination.index ?? targetGroup.panels.length, targetGroup.panels.length);\n const index = originalIndex - targetGroup.panels.slice(0, originalIndex).filter(id => removed.has(id)).length;\n const panels = [...group.panels];\n panels.splice(index, 0, ...source);\n return { type: 'group', panels, active: sourceGroup === targetGroup ? sourceGroup.active : moving.active };\n}\n\nfunction splitTargetGroup(\n group: WorkspaceGroup,\n { moving, destination, splitWeights }: TargetGroupContext\n): WorkspaceNode {\n const before = destination.position === 'left' || destination.position === 'top';\n return {\n type: 'split',\n axis: destination.position === 'left' || destination.position === 'right' ? 'horizontal' : 'vertical',\n weights: before ? [...splitWeights] : [...splitWeights].reverse(),\n children: before ? [moving, group] : [group, moving]\n };\n}\n\nfunction placedLayout(layout: WorkspaceLayout, root: WorkspaceNode | null): WorkspaceLayout {\n const result: WorkspaceLayout = { version: 1, root: root ? normalizeLayout(root) : null, closed: [...layout.closed] };\n const normalized = { ...layout, root: layout.root ? normalizeLayout(layout.root) : null };\n return sameSerializedWorkspaceLayout(result, normalized) ? layout : result;\n}\n\nfunction moveSource(layout: WorkspaceLayout, source: string[], destination: WorkspaceDestination) {\n const first = source[0];\n if (first === undefined || new Set(source).size !== source.length) return undefined;\n const sourceGroup = findGroup(layout.root, first);\n const targetGroup = findGroup(layout.root, destination.target);\n if (!sourceGroup || !targetGroup) return undefined;\n if (destination.position !== 'tab' && source.includes(destination.target)) return undefined;\n if (!validSource(sourceGroup, source) || !isValidInsertionIndex(destination.index)) return undefined;\n return { sourceGroup, targetGroup };\n}\n\n/** Retains panel placement and active preference when closing. */\nexport function closePanel(layout: WorkspaceLayout, id: string): WorkspaceLayout | undefined {\n if (!findGroup(layout.root, id) || layout.closed.includes(id)) return undefined;\n return { ...layout, closed: [...layout.closed, id] };\n}\n\nexport function openPanel(layout: WorkspaceLayout, id: string): WorkspaceLayout | undefined {\n if (!layout.closed.includes(id)) return undefined;\n return { ...layout, closed: layout.closed.filter(panel => panel !== id) };\n}\n\n/** Retains saved panel positions when supplied panels change. */\nexport function reconcilePanels(layout: WorkspaceLayout, available: string[]): WorkspaceLayout {\n const saved = new Set(getPanelIds(layout.root));\n const added = available.filter(id => {\n if (saved.has(id)) return false;\n saved.add(id);\n return true;\n });\n return added.length ? { version: 1, root: appendPanels(layout.root, added), closed: [...layout.closed] } : layout;\n}\n\n/** Creates the visible arrangement while retaining the saved snapshot. */\nexport function projectLayout(layout: WorkspaceLayout, available: string[]): WorkspaceLayout {\n const visible = new Set(available.filter(id => !layout.closed.includes(id)));\n return {\n version: 1,\n root: mapGroups(layout.root, group => filterGroup(group, id => visible.has(id))),\n closed: []\n };\n}\n\nexport function selectPanel(layout: WorkspaceLayout, id: string): WorkspaceLayout | undefined {\n if (layout.closed.includes(id) || !findGroup(layout.root, id)) return undefined;\n const root = mapGroups(layout.root, group => (group.panels.includes(id) ? { ...group, active: id } : group));\n const next = { ...layout, root };\n return sameSerializedWorkspaceLayout(next, layout) ? undefined : next;\n}\n\nexport function getFullscreenWorkspaceLayout(layout: WorkspaceLayout, anchor: string | undefined) {\n const group = anchor ? findGroup(layout.root, anchor) : undefined;\n return group ? { ...layout, root: group } : undefined;\n}\n"],"mappings":";;;AA0BA,SAAgBA,EAAU,GAA4B,GAAyC;CAC7F,IAAKC,GACL;MAAIA,EAAK,S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WorkspaceNode, WorkspaceSplit } from './layout.utils.js';
|
|
2
|
+
export type WorkspaceLayoutProjector = (layout: WorkspaceLayout, available: string[]) => WorkspaceLayout;
|
|
3
|
+
export declare function createWorkspaceLayoutProjector(): WorkspaceLayoutProjector;
|
|
4
|
+
export declare function getProjectionSignature(node: WorkspaceNode | null): string;
|
|
5
|
+
export declare function findDeepestProjectionCarrier(node: WorkspaceNode | null, expected: string, project: (node: WorkspaceNode) => WorkspaceNode | null): WorkspaceNode | undefined;
|
|
6
|
+
/** Saves visible split proportions while preserving the shares of missing panels. */
|
|
7
|
+
export declare function rebaseProjectedSplit(layout: WorkspaceLayout, renderedBranch: WorkspaceSplit, sizes: number[], available: string[], projectLayoutForCandidate?: WorkspaceLayoutProjector): WorkspaceLayout | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { getPanelIds as e } from "./layout.utils.js";
|
|
2
|
+
import { projectLayout as t } from "./operations.utils.js";
|
|
3
|
+
// src/workspace/utils/model/projection.utils.ts
|
|
4
|
+
function n() {
|
|
5
|
+
let e = [];
|
|
6
|
+
return (n, r) => {
|
|
7
|
+
let i = e.find((e) => o(e.available, r) && o(e.closed, n.closed));
|
|
8
|
+
i || (i = {
|
|
9
|
+
available: r,
|
|
10
|
+
closed: n.closed,
|
|
11
|
+
roots: /* @__PURE__ */ new Map()
|
|
12
|
+
}, e.push(i));
|
|
13
|
+
let a = i.roots.get(n.root);
|
|
14
|
+
return a || (a = t(n, r), i.roots.set(n.root, a)), a;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function r(e) {
|
|
18
|
+
return e ? e.type === "group" ? JSON.stringify(e.panels) : JSON.stringify([e.axis, e.children.map(r)]) : "null";
|
|
19
|
+
}
|
|
20
|
+
function i(e, t, n) {
|
|
21
|
+
if (e) {
|
|
22
|
+
if (e.type === "split") for (let r of e.children) {
|
|
23
|
+
let e = i(r, t, n);
|
|
24
|
+
if (e) return e;
|
|
25
|
+
}
|
|
26
|
+
return r(n(e)) === t ? e : void 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function a(n, i, a, o, u) {
|
|
30
|
+
if (!n.root || !c(i, a)) return;
|
|
31
|
+
let d = o.filter((e) => !n.closed.includes(e)), f = /* @__PURE__ */ new Map(), p = (e) => (f.has(e) || f.set(e, (u ?? t)({
|
|
32
|
+
version: 1,
|
|
33
|
+
root: e,
|
|
34
|
+
closed: []
|
|
35
|
+
}, d).root), f.get(e) ?? null), m = r(i), h = new Set(i.children.map(r)), g = /* @__PURE__ */ new Map();
|
|
36
|
+
i.children.forEach((t, n) => {
|
|
37
|
+
e(t).forEach((e) => g.set(e, n));
|
|
38
|
+
});
|
|
39
|
+
let _ = (t) => [...new Set(e(p(t)).flatMap((e) => {
|
|
40
|
+
let t = g.get(e);
|
|
41
|
+
return t === void 0 ? [] : [t];
|
|
42
|
+
}))].reduce((e, t) => e + (a[t] ?? 0), 0), v = (e) => {
|
|
43
|
+
if (e.type === "group" || h.has(r(p(e)))) return e;
|
|
44
|
+
let t = e.children.map((e) => v(e)), n = l(e, _, i.axis);
|
|
45
|
+
return n === e.weights && t.every((t, n) => t === e.children[n]) ? e : {
|
|
46
|
+
...e,
|
|
47
|
+
weights: n,
|
|
48
|
+
children: t
|
|
49
|
+
};
|
|
50
|
+
}, y = s(n.root, (e) => r(p(e)) === m, v);
|
|
51
|
+
return y === n.root ? void 0 : {
|
|
52
|
+
version: 1,
|
|
53
|
+
root: y,
|
|
54
|
+
closed: [...n.closed]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function o(e, t) {
|
|
58
|
+
return e === t || e.length === t.length && e.every((e, n) => e === t[n]);
|
|
59
|
+
}
|
|
60
|
+
function s(e, t, n) {
|
|
61
|
+
if (t(e)) return n(e);
|
|
62
|
+
if (e.type === "group") return e;
|
|
63
|
+
let r = e.children.map((e) => s(e, t, n));
|
|
64
|
+
return r.some((t, n) => t !== e.children[n]) ? {
|
|
65
|
+
...e,
|
|
66
|
+
children: r
|
|
67
|
+
} : e;
|
|
68
|
+
}
|
|
69
|
+
function c(e, t) {
|
|
70
|
+
return t.length === e.children.length && t.every((e) => Number.isFinite(e) && e > 0) && Number.isFinite(t.reduce((e, t) => e + t, 0));
|
|
71
|
+
}
|
|
72
|
+
function l(e, t, n) {
|
|
73
|
+
if (e.axis !== n) return e.weights;
|
|
74
|
+
let r = e.children.map(t), i = r.reduce((e, t) => e + t, 0);
|
|
75
|
+
if (!i) return e.weights;
|
|
76
|
+
let a = e.weights.reduce((e, t, n) => e + ((r[n] ?? 0) > 0 ? t : 0), 0), o = e.weights.map((e, t) => {
|
|
77
|
+
let n = r[t] ?? 0;
|
|
78
|
+
return n > 0 ? n / i * a : e;
|
|
79
|
+
});
|
|
80
|
+
return o.every((t, n) => {
|
|
81
|
+
let r = e.weights[n] ?? 0;
|
|
82
|
+
return Math.abs(t - r) <= 1e-12 * Math.max(t, r);
|
|
83
|
+
}) ? e.weights : o;
|
|
84
|
+
}
|
|
85
|
+
export { n as createWorkspaceLayoutProjector, i as findDeepestProjectionCarrier, r as getProjectionSignature, a as rebaseProjectedSplit };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=projection.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.utils.js","names":["createWorkspaceLayoutProjector","domains","domain","sameIds","entry","available","layout","projectedLayout","projectLayout","getProjectionSignature","node","findDeepestProjectionCarrier","child","found","expected","project","rebaseProjectedSplit","validSplitSizes","renderedBranch","sizes","visible","id","projections","projectLayoutForCandidate","renderedSignature","childSignatures","allocations","index","mass","getPanelIds","group","sum","rebase","children","weights","rebaseWeights","root","replaceBranch","left","right","matches","branch","size","axis","masses","totalMass","value","visibleShare","weight","childMass","previous"],"sources":["../../../../src/workspace/utils/model/projection.utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getPanelIds } from './layout.utils.js';\nimport { projectLayout } from './operations.utils.js';\n\nimport type { WorkspaceLayout, WorkspaceNode, WorkspaceSplit } from './layout.utils.js';\nexport type WorkspaceLayoutProjector = (layout: WorkspaceLayout, available: string[]) => WorkspaceLayout;\n\nexport function createWorkspaceLayoutProjector(): WorkspaceLayoutProjector {\n const domains: {\n available: string[];\n closed: string[];\n roots: Map<WorkspaceNode | null, WorkspaceLayout>;\n }[] = [];\n return (layout, available) => {\n let domain = domains.find(entry => sameIds(entry.available, available) && sameIds(entry.closed, layout.closed));\n if (!domain) {\n domain = { available, closed: layout.closed, roots: new Map() };\n domains.push(domain);\n }\n let projectedLayout = domain.roots.get(layout.root);\n if (!projectedLayout) {\n projectedLayout = projectLayout(layout, available);\n domain.roots.set(layout.root, projectedLayout);\n }\n return projectedLayout;\n };\n}\n\nexport function getProjectionSignature(node: WorkspaceNode | null): string {\n if (!node) return 'null';\n return node.type === 'group'\n ? JSON.stringify(node.panels)\n : JSON.stringify([node.axis, node.children.map(getProjectionSignature)]);\n}\n\nexport function findDeepestProjectionCarrier(\n node: WorkspaceNode | null,\n expected: string,\n project: (node: WorkspaceNode) => WorkspaceNode | null\n): WorkspaceNode | undefined {\n if (!node) return undefined;\n if (node.type === 'split') {\n for (const child of node.children) {\n const found = findDeepestProjectionCarrier(child, expected, project);\n if (found) return found;\n }\n }\n return getProjectionSignature(project(node)) === expected ? node : undefined;\n}\n\n/** Saves visible split proportions while preserving the shares of missing panels. */\n// eslint-disable-next-line max-params -- The operation accepts saved and rendered arrangements with scoped projection.\nexport function rebaseProjectedSplit(\n layout: WorkspaceLayout,\n renderedBranch: WorkspaceSplit,\n sizes: number[],\n available: string[],\n projectLayoutForCandidate?: WorkspaceLayoutProjector\n): WorkspaceLayout | undefined {\n if (!layout.root || !validSplitSizes(renderedBranch, sizes)) return undefined;\n\n const visible = available.filter(id => !layout.closed.includes(id));\n const projections = new Map<WorkspaceNode, WorkspaceNode | null>();\n const project = (node: WorkspaceNode): WorkspaceNode | null => {\n if (!projections.has(node)) {\n projections.set(\n node,\n (projectLayoutForCandidate ?? projectLayout)({ version: 1, root: node, closed: [] }, visible).root\n );\n }\n return projections.get(node) ?? null;\n };\n const renderedSignature = getProjectionSignature(renderedBranch);\n const childSignatures = new Set(renderedBranch.children.map(getProjectionSignature));\n const allocations = new Map<string, number>();\n renderedBranch.children.forEach((child, index) => {\n getPanelIds(child).forEach(id => allocations.set(id, index));\n });\n const mass = (node: WorkspaceNode): number => {\n const groups = new Set(\n getPanelIds(project(node)).flatMap(id => {\n const group = allocations.get(id);\n return group === undefined ? [] : [group];\n })\n );\n return [...groups].reduce((sum, group) => sum + (sizes[group] ?? 0), 0);\n };\n const rebase = (node: WorkspaceNode): WorkspaceNode => {\n if (node.type === 'group' || childSignatures.has(getProjectionSignature(project(node)))) return node;\n const children = node.children.map(child => rebase(child));\n const weights = rebaseWeights(node, mass, renderedBranch.axis);\n if (weights === node.weights && children.every((child, index) => child === node.children[index])) return node;\n return { ...node, weights, children };\n };\n const root = replaceBranch(layout.root, node => getProjectionSignature(project(node)) === renderedSignature, rebase);\n return root === layout.root ? undefined : { version: 1, root, closed: [...layout.closed] };\n}\n\nfunction sameIds(left: string[], right: string[]) {\n return left === right || (left.length === right.length && left.every((id, index) => id === right[index]));\n}\n\nfunction replaceBranch(\n node: WorkspaceNode,\n matches: (node: WorkspaceNode) => boolean,\n rebase: (node: WorkspaceNode) => WorkspaceNode\n): WorkspaceNode {\n if (matches(node)) return rebase(node);\n if (node.type === 'group') return node;\n const children = node.children.map(child => replaceBranch(child, matches, rebase));\n return children.some((child, index) => child !== node.children[index]) ? { ...node, children } : node;\n}\n\nfunction validSplitSizes(branch: WorkspaceSplit, sizes: number[]) {\n return (\n sizes.length === branch.children.length &&\n sizes.every(size => Number.isFinite(size) && size > 0) &&\n Number.isFinite(sizes.reduce((sum, size) => sum + size, 0))\n );\n}\n\nfunction rebaseWeights(\n node: WorkspaceSplit,\n mass: (node: WorkspaceNode) => number,\n axis: WorkspaceSplit['axis']\n): number[] {\n if (node.axis !== axis) return node.weights;\n const masses = node.children.map(mass);\n const totalMass = masses.reduce((sum, value) => sum + value, 0);\n if (!totalMass) return node.weights;\n const visibleShare = node.weights.reduce((sum, weight, index) => sum + ((masses[index] ?? 0) > 0 ? weight : 0), 0);\n const weights = node.weights.map((weight, index) => {\n const childMass = masses[index] ?? 0;\n return childMass > 0 ? visibleShare * (childMass / totalMass) : weight;\n });\n return weights.every((weight, index) => {\n const previous = node.weights[index] ?? 0;\n return Math.abs(weight - previous) <= 1e-12 * Math.max(weight, previous);\n })\n ? node.weights\n : weights;\n}\n"],"mappings":";;;AASA,SAAgBA,IAA2D;CACzE,IAAMC,IAIA,CAAC;CACP,QAAQ,GAAQ,MAAc;EAC5B,IAAIC,IAASD,EAAQ,MAAK,MAASE,EAAQC,EAAM,WAAWC,CAAS,KAAKF,EAAQC,EAAM,QAAQE,EAAO,MAAM,CAAC;EAC9G,AAAKJ,MACH,IAAS;GAAE;GAAW,QAAQI,EAAO;GAAQ,uBAAO,IAAI,IAAI;EAAE,GAC9DL,EAAQ,KAAKC,CAAM;EAErB,IAAIK,IAAkBL,EAAO,MAAM,IAAII,EAAO,IAAI;EAKlD,OAJKC,MACH,IAAkBC,EAAcF,GAAQD,CAAS,GACjDH,EAAO,MAAM,IAAII,EAAO,MAAMC,CAAe,IAExCA;CACT;AACF;AAEA,SAAgBE,EAAuB,GAAoC;CAEzE,OADKC,IACEA,EAAK,SAAS,UACjB,KAAK,UAAUA,EAAK,MAAM,IAC1B,KAAK,UAAU,CAACA,EAAK,MAAMA,EAAK,SAAS,IAAID,CAAsB,CAAC,CAAC,IAHvD;AAIpB;AAEA,SAAgBE,EACd,GACA,GACA,GAC2B;CAC3B,IAAKD,GACL;MAAIA,EAAK,SAAS,SAChB,KAAK,IAAME,KAASF,EAAK,UAAU;GACjC,IAAMG,IAAQF,EAA6BC,GAAOE,GAAUC,CAAO;GACnE,IAAIF,GAAO,O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AYD,EAAO,QAAQ,GAAK,MAAUb,IAAMe,GAAO,CAAC;CAC9D,IAAI,CAACD,GAAW,OAAOnC,EAAK;CAC5B,IAAMqC,IAAerC,EAAK,QAAQ,QAAQ,GAAK,GAAQ,MAAUqB,MAAQa,EAAOjB,MAAU,KAAK,IAAIqB,IAAS,IAAI,CAAC,GAC3Gd,IAAUxB,EAAK,QAAQ,KAAK,GAAQ,MAAU;EAClD,IAAMuC,IAAYL,EAAOjB,MAAU;EACnC,OAAOsB,IAAY,IAAoBA,IAAYJ,IAA5BE,IAAyCC;CAClE,CAAC;CACD,OAAOd,EAAQ,OAAO,GAAQ,MAAU;EACtC,IAAMgB,IAAWxC,EAAK,QAAQiB,MAAU;EACxC,OAAO,KAAK,IAAIqB,IAASE,CAAQ,KAAK,QAAQ,KAAK,IAAIF,GAAQE,CAAQ;CACzE,CAAC,IACGxC,EAAK,UACLwB;AACN"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkspaceLayout } from './layout.utils.js';
|
|
2
|
+
export declare function parseWorkspaceValue(value: string): WorkspaceLayout | undefined;
|
|
3
|
+
export declare function serializeWorkspaceValue(layout: WorkspaceLayout | undefined): string;
|
|
4
|
+
/** Compares serialized layout representations, including property order and supplied group fields. */
|
|
5
|
+
export declare function sameSerializedWorkspaceLayout(left: WorkspaceLayout | undefined, right: WorkspaceLayout | undefined): boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { normalizeLayout as e } from "./layout.utils.js";
|
|
2
|
+
// src/workspace/utils/model/value.utils.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"version",
|
|
5
|
+
"root",
|
|
6
|
+
"closed"
|
|
7
|
+
], n = [
|
|
8
|
+
"type",
|
|
9
|
+
"panels",
|
|
10
|
+
"active"
|
|
11
|
+
], r = [
|
|
12
|
+
"type",
|
|
13
|
+
"axis",
|
|
14
|
+
"children",
|
|
15
|
+
"weights"
|
|
16
|
+
];
|
|
17
|
+
function i(t) {
|
|
18
|
+
if (!t) return;
|
|
19
|
+
let n = JSON.parse(t), r = /* @__PURE__ */ new Set(), i = (e) => typeof e == "object" && !!e, a = (e) => i(e) ? e.type === "group" ? !Array.isArray(e.panels) || !e.panels.length || typeof e.active != "string" || !e.panels.includes(e.active) ? !1 : e.panels.every((e) => typeof e != "string" || !e || r.has(e) ? !1 : (r.add(e), !0)) : s(e) ? e.children.every((e) => a(e)) : !1 : !1;
|
|
20
|
+
if (!i(n) || n.version !== 1 || !(n.root === null || a(n.root)) || !Array.isArray(n.closed) || !n.closed.every((e) => typeof e == "string" && r.has(e)) || new Set(n.closed).size !== n.closed.length) throw TypeError("Invalid workspace arrangement");
|
|
21
|
+
return {
|
|
22
|
+
version: 1,
|
|
23
|
+
root: n.root === null ? null : e(n.root),
|
|
24
|
+
closed: [...n.closed]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function a(e) {
|
|
28
|
+
return e ? JSON.stringify(e) : "";
|
|
29
|
+
}
|
|
30
|
+
function o(e, n) {
|
|
31
|
+
return e === n ? !0 : !e || !n ? !1 : !p(e, t) || !p(n, t) ? a(e) === a(n) : e.version === n.version && f(e.closed, n.closed) && c(e.root, n.root);
|
|
32
|
+
}
|
|
33
|
+
function s(e) {
|
|
34
|
+
return e.type !== "split" || !["horizontal", "vertical"].includes(String(e.axis)) || !Array.isArray(e.children) || e.children.length < 2 || !Array.isArray(e.weights) || e.weights.length !== e.children.length || !e.weights.every((e) => typeof e == "number" && Number.isFinite(e) && e > 0) ? !1 : Number.isFinite(e.weights.reduce((e, t) => e + t, 0));
|
|
35
|
+
}
|
|
36
|
+
function c(e, t) {
|
|
37
|
+
if (e === t) return !0;
|
|
38
|
+
if (!e || !t || e.type !== t.type) return !1;
|
|
39
|
+
let i = e.type === "group" ? n : r;
|
|
40
|
+
return !p(e, i) || !p(t, i) ? JSON.stringify(e) === JSON.stringify(t) : e.type === "group" ? l(e, t) : u(e, t);
|
|
41
|
+
}
|
|
42
|
+
function l(e, t) {
|
|
43
|
+
return t.type === "group" && e.active === t.active && f(e.panels, t.panels);
|
|
44
|
+
}
|
|
45
|
+
function u(e, t) {
|
|
46
|
+
return t.type === "split" && e.axis === t.axis && f(e.weights, t.weights) && d(e.children, t.children);
|
|
47
|
+
}
|
|
48
|
+
function d(e, t) {
|
|
49
|
+
if (e === t) return !0;
|
|
50
|
+
if (e.length !== t.length) return !1;
|
|
51
|
+
for (let n = 0; n < e.length; n++) if (!c(e[n], t[n])) return !1;
|
|
52
|
+
return !0;
|
|
53
|
+
}
|
|
54
|
+
function f(e, t) {
|
|
55
|
+
if (e === t) return !0;
|
|
56
|
+
if (e.length !== t.length) return !1;
|
|
57
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
58
|
+
return !0;
|
|
59
|
+
}
|
|
60
|
+
function p(e, t) {
|
|
61
|
+
if ("toJSON" in e) return !1;
|
|
62
|
+
let n = 0;
|
|
63
|
+
for (let r in e) if (Object.hasOwn(e, r) && r !== t[n++]) return !1;
|
|
64
|
+
return n === t.length;
|
|
65
|
+
}
|
|
66
|
+
export { i as parseWorkspaceValue, o as sameSerializedWorkspaceLayout, a as serializeWorkspaceValue };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=value.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.utils.js","names":["layoutKeys","groupKeys","splitKeys","parseWorkspaceValue","value","data","ids","record","item","node","id","splitShape","child","normalizeLayout","serializeWorkspaceValue","layout","sameSerializedWorkspaceLayout","left","right","hasOrderedKeys","sameValues","sameNode","weight","sum","keys","sameGroup","sameSplit","sameChildren","index","key","expected"],"sources":["../../../../src/workspace/utils/model/value.utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { normalizeLayout } from './layout.utils.js';\n\nimport type { WorkspaceGroup, WorkspaceLayout, WorkspaceNode, WorkspaceSplit } from './layout.utils.js';\n\nconst layoutKeys = ['version', 'root', 'closed'];\nconst groupKeys = ['type', 'panels', 'active'];\nconst splitKeys = ['type', 'axis', 'children', 'weights'];\n\nexport function parseWorkspaceValue(value: string): WorkspaceLayout | undefined {\n if (!value) return undefined;\n\n const data: unknown = JSON.parse(value);\n const ids = new Set<string>();\n const record = (item: unknown): item is Record<string, unknown> => typeof item === 'object' && item !== null;\n const node = (item: unknown): item is WorkspaceNode => {\n if (!record(item)) return false;\n if (item.type === 'group') {\n if (\n !Array.isArray(item.panels) ||\n !item.panels.length ||\n typeof item.active !== 'string' ||\n !item.panels.includes(item.active)\n ) {\n return false;\n }\n return item.panels.every(id => {\n if (typeof id !== 'string' || !id || ids.has(id)) return false;\n ids.add(id);\n return true;\n });\n }\n if (!splitShape(item)) return false;\n return item.children.every(child => node(child));\n };\n if (\n !record(data) ||\n data.version !== 1 ||\n !(data.root === null || node(data.root)) ||\n !Array.isArray(data.closed) ||\n !data.closed.every(id => typeof id === 'string' && ids.has(id)) ||\n new Set(data.closed).size !== data.closed.length\n ) {\n throw new TypeError('Invalid workspace arrangement');\n }\n return { version: 1, root: data.root === null ? null : normalizeLayout(data.root), closed: [...data.closed] };\n}\n\nexport function serializeWorkspaceValue(layout: WorkspaceLayout | undefined): string {\n return layout ? JSON.stringify(layout) : '';\n}\n\n/** Compares serialized layout representations, including property order and supplied group fields. */\nexport function sameSerializedWorkspaceLayout(\n left: WorkspaceLayout | undefined,\n right: WorkspaceLayout | undefined\n): boolean {\n if (left === right) {\n return true;\n }\n if (!left || !right) {\n return false;\n }\n if (!hasOrderedKeys(left, layoutKeys) || !hasOrderedKeys(right, layoutKeys)) {\n return serializeWorkspaceValue(left) === serializeWorkspaceValue(right);\n }\n return left.version === right.version && sameValues(left.closed, right.closed) && sameNode(left.root, right.root);\n}\n\nfunction splitShape(item: Record<string, unknown>): item is Record<string, unknown> & WorkspaceSplit {\n if (item.type !== 'split' || !['horizontal', 'vertical'].includes(String(item.axis))) return false;\n if (!Array.isArray(item.children) || item.children.length < 2) return false;\n if (!Array.isArray(item.weights) || item.weights.length !== item.children.length) return false;\n if (!item.weights.every(weight => typeof weight === 'number' && Number.isFinite(weight) && weight > 0)) return false;\n return Number.isFinite(item.weights.reduce((sum: number, weight: number) => sum + weight, 0));\n}\n\nfunction sameNode(left: WorkspaceNode | null, right: WorkspaceNode | null): boolean {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.type !== right.type) {\n return false;\n }\n const keys = left.type === 'group' ? groupKeys : splitKeys;\n if (!hasOrderedKeys(left, keys) || !hasOrderedKeys(right, keys)) {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n return left.type === 'group' ? sameGroup(left, right) : sameSplit(left, right);\n}\n\nfunction sameGroup(left: WorkspaceGroup, right: WorkspaceNode) {\n return right.type === 'group' && left.active === right.active && sameValues(left.panels, right.panels);\n}\n\nfunction sameSplit(left: WorkspaceSplit, right: WorkspaceNode) {\n return (\n right.type === 'split' &&\n left.axis === right.axis &&\n sameValues(left.weights, right.weights) &&\n sameChildren(left.children, right.children)\n );\n}\n\nfunction sameChildren(left: WorkspaceNode[], right: WorkspaceNode[]) {\n if (left === right) {\n return true;\n }\n if (left.length !== right.length) {\n return false;\n }\n for (let index = 0; index < left.length; index++) {\n if (!sameNode(left[index]!, right[index]!)) {\n return false;\n }\n }\n return true;\n}\n\nfunction sameValues<T>(left: T[], right: T[]) {\n if (left === right) {\n return true;\n }\n if (left.length !== right.length) {\n return false;\n }\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n return true;\n}\n\nfunction hasOrderedKeys(value: object, expected: string[]) {\n if ('toJSON' in value) {\n return false;\n }\n let index = 0;\n for (const key in value) {\n if (!Object.hasOwn(value, key)) {\n continue;\n }\n if (key !== expected[index++]) {\n return false;\n }\n }\n return index === expected.length;\n}\n"],"mappings":";;AAOA,IAAMA,IAAa;CAAC;CAAW;CAAQ;AAAQ,GACzCC,I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GAAsB,GAAsB;CAC7D,OACER,EAAM,SAAS,WACfD,EAAK,SAASC,EAAM,QACpBE,EAAWH,EAAK,SAASC,EAAM,OAAO,KACtCS,EAAaV,EAAK,UAAUC,EAAM,QAAQ;AAE9C;AAEA,SAASS,EAAa,GAAuB,GAAwB;CACnE,IAAIV,MAASC,GACX,OAAO;CAET,IAAID,EAAK,WAAWC,EAAM,QACxB,OAAO;CAET,KAAK,IAAIU,IAAQ,GAAGA,IAAQX,EAAK,QAAQ,KACvC,IAAI,CAACI,EAASJ,EAAKW,IAASV,EAAMU,EAAO,GACvC,OAAO;CAGX,OAAO;AACT;AAEA,SAASR,EAAc,GAAW,GAAY;CAC5C,IAAIH,MAASC,GACX,OAAO;CAET,IAAID,EAAK,WAAWC,EAAM,QACxB,OAAO;CAET,KAAK,IAAIU,IAAQ,GAAGA,IAAQX,EAAK,QAAQ,KACvC,IAAIA,EAAKW,OAAWV,EAAMU,IACxB,OAAO;CAGX,OAAO;AACT;AAEA,SAAST,EAAe,GAAe,GAAoB;CACzD,IAAI,YAAYf,GACd,OAAO;CAET,IAAIwB,IAAQ;CACZ,KAAK,IAAMC,KAAOzB,GAChB,IAAK,OAAO,OAAOA,GAAOyB,CAAG,KAGzBA,MAAQC,EAAS,MACnB,OAAO;CAGX,OAAOF,MAAUE,EAAS;AAC5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Point, Rect } from '@nvidia-elements/core/internal';
|
|
2
|
+
import type { WorkspacePlacedRegion } from '../geometry/allocation.utils.js';
|
|
3
|
+
import type { WorkspaceRequirements } from '../geometry/sizing.utils.js';
|
|
4
|
+
import type { WorkspaceDragPreview, WorkspaceDropIntent } from '../interaction/drag-preview.utils.js';
|
|
5
|
+
import type { WorkspaceLayout } from '../model/layout.utils.js';
|
|
6
|
+
import type { WorkspacePlacementPlan } from './planner.utils.js';
|
|
7
|
+
interface AcquisitionInput {
|
|
8
|
+
plan: WorkspacePlacementPlan;
|
|
9
|
+
previous: WorkspaceLayout;
|
|
10
|
+
source: string[];
|
|
11
|
+
available: string[];
|
|
12
|
+
current: WorkspacePlacedRegion[];
|
|
13
|
+
rect: Rect;
|
|
14
|
+
acquisition: {
|
|
15
|
+
rect: Rect;
|
|
16
|
+
point: Point;
|
|
17
|
+
};
|
|
18
|
+
requirements: WorkspaceRequirements;
|
|
19
|
+
}
|
|
20
|
+
/** Fits a cross-scope interior reservation to its acquired allocation without retaining a hidden target. */
|
|
21
|
+
export declare function fitAcquiredPlacement(input: AcquisitionInput): WorkspacePlacementPlan | undefined;
|
|
22
|
+
/** Reuses the actual selected reservation before considering a different spatial offer. */
|
|
23
|
+
export declare function resolveSelectedPlacementPlan(input: Omit<AcquisitionInput, 'previous' | 'acquisition'> & {
|
|
24
|
+
previous?: WorkspaceDragPreview;
|
|
25
|
+
acquisition?: {
|
|
26
|
+
rect: Rect;
|
|
27
|
+
point: Point;
|
|
28
|
+
};
|
|
29
|
+
clientOrigin: Rect;
|
|
30
|
+
intent: WorkspaceDropIntent;
|
|
31
|
+
}): WorkspacePlacementPlan | undefined;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { getPanelIds as e } from "../model/layout.utils.js";
|
|
2
|
+
import { projectLayout as t } from "../model/operations.utils.js";
|
|
3
|
+
import { matchesPlacementIntent as n } from "../interaction/drag-preview.utils.js";
|
|
4
|
+
import { getAllocatedContextRect as r, getContextKey as i } from "./context.utils.js";
|
|
5
|
+
import { rebaseProjectedSplit as a } from "../model/projection.utils.js";
|
|
6
|
+
import { describePlacementSlot as o } from "./group-insertion.utils.js";
|
|
7
|
+
import { getMinimumWorkspaceDimensions as s } from "../geometry/sizing.utils.js";
|
|
8
|
+
import { fitSizes as c } from "../geometry/partition.utils.js";
|
|
9
|
+
import { allocateWorkspace as l } from "../geometry/allocation.utils.js";
|
|
10
|
+
// src/workspace/utils/placement/acquisition-sizing.utils.ts
|
|
11
|
+
function u(e) {
|
|
12
|
+
let t = o(e);
|
|
13
|
+
if (!d(t, o({
|
|
14
|
+
...e,
|
|
15
|
+
plan: { layout: e.previous }
|
|
16
|
+
}))) return e.plan;
|
|
17
|
+
let n = p(e, t.axis), r = n.allocate(e.plan.layout).groups.find((t) => t.group.panels.every((t) => e.source.includes(t)));
|
|
18
|
+
if (!r) return;
|
|
19
|
+
if (f(n, r.rect)) return e.plan;
|
|
20
|
+
let i = h(n, r.key), a = i && _(n, i, r.key), s = a && n.allocate(a).groups.find((e) => e.key === r.key);
|
|
21
|
+
return a && f(n, s?.rect) ? {
|
|
22
|
+
...e.plan,
|
|
23
|
+
layout: a
|
|
24
|
+
} : void 0;
|
|
25
|
+
}
|
|
26
|
+
function d(e, t) {
|
|
27
|
+
return !!e?.previous && !!e.next && !!t && (e.axis !== t.axis || i(e.members) !== i(t.members));
|
|
28
|
+
}
|
|
29
|
+
function f(e, t) {
|
|
30
|
+
return !!t && e.covers(t, "x") && e.covers(t, "y");
|
|
31
|
+
}
|
|
32
|
+
function p(e, n) {
|
|
33
|
+
let r = n === "horizontal" ? "x" : "y", i = r === "x" ? "width" : "height", a = (t) => t === r ? {
|
|
34
|
+
start: e.acquisition.rect[r],
|
|
35
|
+
end: e.acquisition.rect[r] + e.acquisition.rect[i]
|
|
36
|
+
} : {
|
|
37
|
+
start: e.acquisition.point[t],
|
|
38
|
+
end: e.acquisition.point[t]
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
input: e,
|
|
42
|
+
axis: r,
|
|
43
|
+
extent: i,
|
|
44
|
+
range: a,
|
|
45
|
+
covers: (e, t) => m(e, t, a(t)),
|
|
46
|
+
allocate: (n) => l({
|
|
47
|
+
root: t(n, e.available).root,
|
|
48
|
+
rect: e.rect,
|
|
49
|
+
minimum: (t) => s(t, e.requirements),
|
|
50
|
+
policy: "stop",
|
|
51
|
+
gap: e.requirements.gap
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function m(e, t, n) {
|
|
56
|
+
let r = e[t] + e[t === "x" ? "width" : "height"];
|
|
57
|
+
return n.start === n.end ? e[t] <= n.start && n.start < r : e[t] <= n.start + 1e-7 && r >= n.end - 1e-7;
|
|
58
|
+
}
|
|
59
|
+
function h(e, t) {
|
|
60
|
+
let n = t.split("."), r = e.input.plan.layout;
|
|
61
|
+
for (let t = 1; t < n.length - 1; t++) {
|
|
62
|
+
if (!r) return;
|
|
63
|
+
let i = n.slice(0, t).join("."), a = e.allocate(r).regions, o = a.find((e) => e.key === i), s = a.find((e) => e.key === `${i}.${n[t]}`);
|
|
64
|
+
if (o.node.type !== "split") return;
|
|
65
|
+
let c = o.node.axis === "horizontal" ? "x" : "y";
|
|
66
|
+
e.covers(s.rect, c) || (r = g({
|
|
67
|
+
fit: e,
|
|
68
|
+
layout: r,
|
|
69
|
+
parent: o,
|
|
70
|
+
index: Number(n[t])
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
function g({ fit: t, layout: n, parent: i, index: o }) {
|
|
76
|
+
if (i.node.type !== "split") return;
|
|
77
|
+
let l = i.node.axis === "horizontal" ? "width" : "height", u = i.node.children.map((e) => s(e, t.input.requirements)[l]), d = i.rect[l] - t.input.requirements.gap * (u.length - 1), f = i.node.children.map((n, i) => i === o ? 0 : r({
|
|
78
|
+
members: e(n),
|
|
79
|
+
allocation: t.input.current,
|
|
80
|
+
source: t.input.source
|
|
81
|
+
})?.[l]);
|
|
82
|
+
if (f.some((e) => e === void 0) || y(u) > d) return;
|
|
83
|
+
let p = f.map((e) => e);
|
|
84
|
+
return p[o] = Math.max(u[o], d - y(p)), a(n, i.node, c(p, u, d), t.input.available) ?? n;
|
|
85
|
+
}
|
|
86
|
+
function _(e, t, n) {
|
|
87
|
+
let r = e.allocate(t), i = r.regions.find((e) => e.key === n.split(".").slice(0, -1).join("."));
|
|
88
|
+
if (i.node.type !== "split") return;
|
|
89
|
+
let o = r.groups.find((e) => e.key === n), s = Number(n.split(".").at(-1)), c = v({
|
|
90
|
+
fit: e,
|
|
91
|
+
owner: {
|
|
92
|
+
...i,
|
|
93
|
+
node: i.node
|
|
94
|
+
},
|
|
95
|
+
incoming: o.rect,
|
|
96
|
+
index: s
|
|
97
|
+
});
|
|
98
|
+
if (c) return a(t, i.node, c, e.input.available) ?? t;
|
|
99
|
+
}
|
|
100
|
+
function v(e) {
|
|
101
|
+
let { fit: t, owner: n, incoming: r, index: i } = e, { axis: a, extent: o } = t, l = n.node.children.map((e) => s(e, t.input.requirements)[o]), u = l.slice(0, i), d = l.slice(i + 1), f = Math.max(n.rect[a] + y(u) + t.input.requirements.gap * i, t.range(a).end - r[o]), p = Math.min(n.rect[a] + n.rect[o] - y(d) - t.input.requirements.gap * d.length - r[o], t.range(a).start);
|
|
102
|
+
if (f > p) return;
|
|
103
|
+
let m = Math.max(f, Math.min(r[a], p));
|
|
104
|
+
return [
|
|
105
|
+
...c(n.node.weights.slice(0, i), u, m - n.rect[a] - t.input.requirements.gap * i),
|
|
106
|
+
r[o],
|
|
107
|
+
...c(n.node.weights.slice(i + 1), d, n.rect[a] + n.rect[o] - m - r[o] - t.input.requirements.gap * d.length)
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
var y = (e) => e.reduce((e, t) => e + t, 0);
|
|
111
|
+
function b(e) {
|
|
112
|
+
let t = e.previous;
|
|
113
|
+
if (C(t, e.intent) && !e.acquisition) return;
|
|
114
|
+
if (!S(t, e.source) || !x(t, e.plan)) return e.plan;
|
|
115
|
+
let n = o({
|
|
116
|
+
...e,
|
|
117
|
+
plan: t
|
|
118
|
+
}), r = o(e);
|
|
119
|
+
if (n && n.key === r?.key) return {
|
|
120
|
+
...e.plan,
|
|
121
|
+
layout: t.layout
|
|
122
|
+
};
|
|
123
|
+
if (!e.acquisition) return e.plan;
|
|
124
|
+
let { rect: i, point: a } = e.acquisition;
|
|
125
|
+
return u({
|
|
126
|
+
...e,
|
|
127
|
+
previous: t.layout,
|
|
128
|
+
acquisition: {
|
|
129
|
+
rect: {
|
|
130
|
+
...i,
|
|
131
|
+
x: i.x - e.clientOrigin.x,
|
|
132
|
+
y: i.y - e.clientOrigin.y
|
|
133
|
+
},
|
|
134
|
+
point: {
|
|
135
|
+
x: a.x - e.clientOrigin.x,
|
|
136
|
+
y: a.y - e.clientOrigin.y
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function x(e, t) {
|
|
142
|
+
return ["order", "insert"].includes(e.intent.kind) && ["insert", "reorder"].includes(t.kind);
|
|
143
|
+
}
|
|
144
|
+
function S(e, t) {
|
|
145
|
+
return e?.phase === "detached" && !e.blocked && e.allocation === "reserved" && i(e.source) === i(t);
|
|
146
|
+
}
|
|
147
|
+
function C(e, t) {
|
|
148
|
+
return e?.phase === "detached" && e.blocked && n(e.intent, t);
|
|
149
|
+
}
|
|
150
|
+
export { u as fitAcquiredPlacement, b as resolveSelectedPlacementPlan };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=acquisition-sizing.utils.js.map
|