@septkit/ui 0.0.59 → 0.0.61
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/diagram-layout/diagram-node-card.js +7 -0
- package/dist/diagram-layout/diagram-node-card.vue_vue_type_script_setup_true_lang.js +147 -0
- package/dist/diagram-layout/diagram-node-group.js +7 -0
- package/dist/diagram-layout/diagram-node-group.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/diagram-layout/group-geometry.js +7 -0
- package/dist/diagram-layout/group-stack.js +13 -0
- package/dist/diagram-layout/grouping.js +33 -0
- package/dist/diagram-layout/index.js +9 -2
- package/dist/diagram-layout/use-diagram-layout.js +319 -0
- package/dist/diagram-layout/visibility-model.js +56 -0
- package/dist/external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/info.js +20 -0
- package/dist/index.d.ts +354 -0
- package/dist/index.js +9 -2
- package/dist/ui.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import t from "./diagram-node-card.vue_vue_type_script_setup_true_lang.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region lib/diagram-layout/diagram-node-card.vue
|
|
5
|
+
var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-b6238586"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { n as default };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import e from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/info.js";
|
|
2
|
+
import { ELEMENT_TO_COLOR as t } from "../icons/element-color-map.generated.js";
|
|
3
|
+
import { ELEMENT_TO_ICON as n } from "../icons/element-icon-mapper.js";
|
|
4
|
+
import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, normalizeClass as d, normalizeStyle as f, openBlock as p, ref as m, renderList as h, resolveDynamicComponent as g, toDisplayString as _, unref as v, withModifiers as y } from "vue";
|
|
5
|
+
//#region lib/diagram-layout/diagram-node-card.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var b = [
|
|
7
|
+
"data-testid",
|
|
8
|
+
"data-testid-node",
|
|
9
|
+
"data-node-id",
|
|
10
|
+
"tabindex",
|
|
11
|
+
"role",
|
|
12
|
+
"aria-expanded",
|
|
13
|
+
"aria-label",
|
|
14
|
+
"aria-level",
|
|
15
|
+
"aria-setsize",
|
|
16
|
+
"aria-posinset",
|
|
17
|
+
"aria-selected"
|
|
18
|
+
], x = ["data-tip"], S = ["title"], C = ["data-testid"], w = {
|
|
19
|
+
key: 1,
|
|
20
|
+
class: "node-footer"
|
|
21
|
+
}, T = {
|
|
22
|
+
"data-testid": "capsules",
|
|
23
|
+
class: "node-capsules"
|
|
24
|
+
}, E = ["data-tip"], D = {
|
|
25
|
+
key: 1,
|
|
26
|
+
class: "capsule-tag"
|
|
27
|
+
}, O = { class: "capsule-value" }, k = /*@__PURE__*/ u({
|
|
28
|
+
__name: "diagram-node-card",
|
|
29
|
+
props: {
|
|
30
|
+
nodeId: {},
|
|
31
|
+
tagName: {},
|
|
32
|
+
label: {},
|
|
33
|
+
hasChildren: { type: Boolean },
|
|
34
|
+
isExpanded: { type: Boolean },
|
|
35
|
+
width: {},
|
|
36
|
+
height: { default: void 0 },
|
|
37
|
+
compact: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: !1
|
|
40
|
+
},
|
|
41
|
+
selected: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: !1
|
|
44
|
+
},
|
|
45
|
+
childCounts: { default: () => [] },
|
|
46
|
+
testId: { default: "diagram-node-card" },
|
|
47
|
+
detailsTestId: { default: "diagram-node-card-show-details" },
|
|
48
|
+
tabbable: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: !1
|
|
51
|
+
},
|
|
52
|
+
treeMeta: { default: void 0 }
|
|
53
|
+
},
|
|
54
|
+
emits: [
|
|
55
|
+
"select",
|
|
56
|
+
"toggle-expand",
|
|
57
|
+
"show-details",
|
|
58
|
+
"keydown"
|
|
59
|
+
],
|
|
60
|
+
setup(u, { expose: k, emit: A }) {
|
|
61
|
+
let j = u, M = A, N = m(null);
|
|
62
|
+
k({ focus: () => N.value?.focus() });
|
|
63
|
+
let P = i(() => ({
|
|
64
|
+
width: `${j.width}px`,
|
|
65
|
+
...j.height ? { height: `${j.height}px` } : {}
|
|
66
|
+
})), F = i(() => `${j.tagName}: ${j.label}`), I = i(() => n[j.tagName]), L = i(() => t[j.tagName]), R = i(() => {
|
|
67
|
+
let e = j.childCounts.reduce((e, t) => e + t.count, 0), t = e > 0 ? `, ${e} child element${e === 1 ? "" : "s"}` : "";
|
|
68
|
+
return `${j.tagName}: ${j.label}${t}`;
|
|
69
|
+
}), z = i(() => j.treeMeta ? "treeitem" : void 0);
|
|
70
|
+
function B() {
|
|
71
|
+
M("select", j.nodeId), j.hasChildren && M("toggle-expand", j.nodeId);
|
|
72
|
+
}
|
|
73
|
+
function V(e) {
|
|
74
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
75
|
+
e.preventDefault(), B();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
M("keydown", e);
|
|
79
|
+
}
|
|
80
|
+
return (i, u) => (p(), s("div", {
|
|
81
|
+
ref_key: "rootEl",
|
|
82
|
+
ref: N,
|
|
83
|
+
class: d(["node-root", { selected: j.selected }]),
|
|
84
|
+
"data-testid": j.testId,
|
|
85
|
+
"data-testid-node": j.tagName,
|
|
86
|
+
"data-node-id": j.nodeId,
|
|
87
|
+
style: f(P.value),
|
|
88
|
+
tabindex: j.tabbable ? 0 : -1,
|
|
89
|
+
role: z.value,
|
|
90
|
+
"aria-expanded": j.hasChildren ? j.isExpanded : void 0,
|
|
91
|
+
"aria-label": R.value,
|
|
92
|
+
"aria-level": j.treeMeta?.level,
|
|
93
|
+
"aria-setsize": j.treeMeta?.setsize,
|
|
94
|
+
"aria-posinset": j.treeMeta?.posinset,
|
|
95
|
+
"aria-selected": j.selected,
|
|
96
|
+
onClick: y(B, ["stop"]),
|
|
97
|
+
onKeydown: V
|
|
98
|
+
}, [c("div", {
|
|
99
|
+
"data-testid": "node-body",
|
|
100
|
+
class: d(["node-body", { compact: j.compact }])
|
|
101
|
+
}, [
|
|
102
|
+
j.compact ? o("", !0) : (p(), s("div", {
|
|
103
|
+
key: 0,
|
|
104
|
+
"data-testid": "type-label",
|
|
105
|
+
class: d(["node-type-label", [L.value?.background, L.value?.text]])
|
|
106
|
+
}, _(j.tagName), 3)),
|
|
107
|
+
c("div", {
|
|
108
|
+
"data-testid": "header",
|
|
109
|
+
class: d(["header", {
|
|
110
|
+
collapsed: !j.isExpanded,
|
|
111
|
+
expanded: j.isExpanded
|
|
112
|
+
}])
|
|
113
|
+
}, [
|
|
114
|
+
I.value ? (p(), s("div", {
|
|
115
|
+
key: 0,
|
|
116
|
+
"data-testid": "icon-circle",
|
|
117
|
+
class: d(["node-icon-circle tooltip", [L.value?.background, L.value?.text]]),
|
|
118
|
+
"data-tip": j.tagName
|
|
119
|
+
}, [(p(), a(g(I.value)))], 10, x)) : o("", !0),
|
|
120
|
+
c("div", {
|
|
121
|
+
"data-testid": "node-label",
|
|
122
|
+
class: "node-label",
|
|
123
|
+
title: F.value
|
|
124
|
+
}, _(j.label), 9, S),
|
|
125
|
+
c("button", {
|
|
126
|
+
type: "button",
|
|
127
|
+
class: "details-button tooltip",
|
|
128
|
+
"data-testid": j.detailsTestId,
|
|
129
|
+
"data-tip": "Show details",
|
|
130
|
+
"aria-label": "Show details",
|
|
131
|
+
onClick: u[0] ||= y((e) => M("show-details", j.nodeId), ["stop"])
|
|
132
|
+
}, [l(v(e), { size: 16 })], 8, C)
|
|
133
|
+
], 2),
|
|
134
|
+
j.childCounts.length > 0 ? (p(), s("div", w, [c("div", T, [(p(!0), s(r, null, h(j.childCounts, (e) => (p(), s("div", {
|
|
135
|
+
key: e.tagName,
|
|
136
|
+
"data-testid": "capsule",
|
|
137
|
+
class: d(["capsule tooltip", [v(t)[e.tagName]?.text]]),
|
|
138
|
+
"data-tip": `${e.count} × ${e.tagName}`
|
|
139
|
+
}, [v(n)[e.tagName] ? (p(), a(g(v(n)[e.tagName]), {
|
|
140
|
+
key: 0,
|
|
141
|
+
class: "capsule-icon"
|
|
142
|
+
})) : (p(), s("span", D, _(e.tagName), 1)), c("span", O, _(e.label ?? e.count), 1)], 10, E))), 128))])])) : o("", !0)
|
|
143
|
+
], 2)], 46, b));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
//#endregion
|
|
147
|
+
export { k as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import t from "./diagram-node-group.vue_vue_type_script_setup_true_lang.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region lib/diagram-layout/diagram-node-group.vue
|
|
5
|
+
var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-636fa72f"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { n as default };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import e from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/chevron-down.js";
|
|
2
|
+
import t from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/chevron-right.js";
|
|
3
|
+
import { ELEMENT_TO_COLOR as n } from "../icons/element-color-map.generated.js";
|
|
4
|
+
import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, defineComponent as l, normalizeClass as u, normalizeStyle as d, openBlock as f, ref as p, renderList as m, renderSlot as h, toDisplayString as g, unref as _ } from "vue";
|
|
5
|
+
//#region lib/diagram-layout/diagram-node-group.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var v = ["data-testid"], y = [
|
|
7
|
+
"data-testid",
|
|
8
|
+
"role",
|
|
9
|
+
"tabindex",
|
|
10
|
+
"aria-expanded",
|
|
11
|
+
"aria-label",
|
|
12
|
+
"aria-level",
|
|
13
|
+
"aria-setsize",
|
|
14
|
+
"aria-posinset"
|
|
15
|
+
], b = ["title"], x = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "group-toggle"
|
|
18
|
+
}, S = ["role"], C = /*@__PURE__*/ l({
|
|
19
|
+
__name: "diagram-node-group",
|
|
20
|
+
props: {
|
|
21
|
+
groupId: {},
|
|
22
|
+
tagName: {},
|
|
23
|
+
label: {},
|
|
24
|
+
count: {},
|
|
25
|
+
width: {},
|
|
26
|
+
collapsedMembersHeight: {},
|
|
27
|
+
members: { default: () => [] },
|
|
28
|
+
expanded: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !1
|
|
31
|
+
},
|
|
32
|
+
expandable: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
35
|
+
},
|
|
36
|
+
testId: { default: "diagram-node-group" },
|
|
37
|
+
toggleTestId: { default: "diagram-node-group-toggle" },
|
|
38
|
+
tabbable: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
treeMeta: { default: void 0 }
|
|
43
|
+
},
|
|
44
|
+
emits: ["toggle", "keydown"],
|
|
45
|
+
setup(l, { expose: C, emit: w }) {
|
|
46
|
+
let T = l, E = w, D = p(null);
|
|
47
|
+
C({ focus: () => D.value?.focus() });
|
|
48
|
+
let O = i(() => n[T.tagName]), k = i(() => ({ width: `${T.width}px` })), A = i(() => T.expanded ? {} : {
|
|
49
|
+
height: `${T.collapsedMembersHeight}px`,
|
|
50
|
+
overflowY: "auto",
|
|
51
|
+
overflowX: "hidden"
|
|
52
|
+
}), j = i(() => `${T.tagName} group, ${T.count} item${T.count === 1 ? "" : "s"}`), M = i(() => {
|
|
53
|
+
if (T.tabbable !== void 0) return T.tabbable ? 0 : -1;
|
|
54
|
+
}), N = i(() => T.treeMeta ? "treeitem" : void 0), P = i(() => T.treeMeta ? "group" : void 0);
|
|
55
|
+
function F() {
|
|
56
|
+
T.expandable && E("toggle", T.groupId);
|
|
57
|
+
}
|
|
58
|
+
function I(e) {
|
|
59
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
60
|
+
e.preventDefault(), F();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
E("keydown", e);
|
|
64
|
+
}
|
|
65
|
+
return (n, i) => (f(), s("div", {
|
|
66
|
+
class: u(["group-root", O.value?.text]),
|
|
67
|
+
style: d(k.value),
|
|
68
|
+
"data-testid": T.testId
|
|
69
|
+
}, [c("div", {
|
|
70
|
+
ref_key: "headerEl",
|
|
71
|
+
ref: D,
|
|
72
|
+
class: u(["group-header", [
|
|
73
|
+
O.value?.background,
|
|
74
|
+
O.value?.text,
|
|
75
|
+
{ "is-expandable": T.expandable }
|
|
76
|
+
]]),
|
|
77
|
+
"data-testid": T.toggleTestId,
|
|
78
|
+
role: N.value,
|
|
79
|
+
tabindex: M.value,
|
|
80
|
+
"aria-expanded": T.expandable ? T.expanded : void 0,
|
|
81
|
+
"aria-label": j.value,
|
|
82
|
+
"aria-level": T.treeMeta?.level,
|
|
83
|
+
"aria-setsize": T.treeMeta?.setsize,
|
|
84
|
+
"aria-posinset": T.treeMeta?.posinset,
|
|
85
|
+
onClick: F,
|
|
86
|
+
onKeydown: I
|
|
87
|
+
}, [c("div", {
|
|
88
|
+
class: "group-label",
|
|
89
|
+
title: `${T.tagName} group (${T.count})`
|
|
90
|
+
}, g(T.label), 9, b), T.expandable ? (f(), s("div", x, [T.expanded ? (f(), a(_(e), {
|
|
91
|
+
key: 0,
|
|
92
|
+
size: 24
|
|
93
|
+
})) : (f(), a(_(t), {
|
|
94
|
+
key: 1,
|
|
95
|
+
size: 24
|
|
96
|
+
}))])) : o("", !0)], 42, y), c("div", {
|
|
97
|
+
class: "group-members",
|
|
98
|
+
role: P.value,
|
|
99
|
+
style: d(A.value)
|
|
100
|
+
}, [(f(!0), s(r, null, m(T.members, (e) => h(n.$slots, "member", {
|
|
101
|
+
key: e.id,
|
|
102
|
+
member: e
|
|
103
|
+
}, void 0, !0)), 128))], 12, S)], 14, v));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
//#endregion
|
|
107
|
+
export { C as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region lib/diagram-layout/group-geometry.ts
|
|
2
|
+
var e = 34, t = 72, n = 48, r = 12, i = 156;
|
|
3
|
+
function a(e) {
|
|
4
|
+
return e ? 72 : 48;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { i as GROUP_COLLAPSED_MEMBERS_HEIGHT, e as GROUP_HEADER_HEIGHT, r as GROUP_MEMBER_GAP, t as GROUP_MEMBER_HEIGHT, n as GROUP_MEMBER_HEIGHT_COMPACT, a as memberCardHeight };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region lib/diagram-layout/group-stack.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
let { memberHeights: n, gap: r, collapsedHeight: i } = e, a = n.reduce((e, t) => e + t, 0) + Math.max(0, n.length - 1) * r, o = Math.min(a, i), s = a > i;
|
|
4
|
+
return {
|
|
5
|
+
contentHeight: a,
|
|
6
|
+
collapsedShownHeight: o,
|
|
7
|
+
expandable: s,
|
|
8
|
+
scrolls: !t && s,
|
|
9
|
+
shownHeight: t ? a : o
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as groupStackMetrics };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region lib/diagram-layout/grouping.ts
|
|
2
|
+
var e = "__group__";
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
return `${e}${t}_${n}`;
|
|
5
|
+
}
|
|
6
|
+
function n(t) {
|
|
7
|
+
return t.startsWith(e);
|
|
8
|
+
}
|
|
9
|
+
function r(e, n) {
|
|
10
|
+
let r = new Set(e), i = [];
|
|
11
|
+
for (let a of e) {
|
|
12
|
+
let e = n[a];
|
|
13
|
+
if (!e) continue;
|
|
14
|
+
let o = e.childrenCache.map((e) => e.record.id).filter((e) => r.has(e)), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
15
|
+
for (let e of o) {
|
|
16
|
+
let t = n[e];
|
|
17
|
+
if (!t) continue;
|
|
18
|
+
let r = t.record.tagName;
|
|
19
|
+
if (c.set(r, (c.get(r) ?? 0) + 1), t.visibleChildIds.size > 0) continue;
|
|
20
|
+
let i = s.get(r);
|
|
21
|
+
i ? i.push(e) : s.set(r, [e]);
|
|
22
|
+
}
|
|
23
|
+
for (let [e, n] of s) (c.get(e) ?? 0) >= 2 && n.length >= 1 && i.push({
|
|
24
|
+
id: t(a, e),
|
|
25
|
+
parentId: a,
|
|
26
|
+
tagName: e,
|
|
27
|
+
memberIds: n
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return i;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { r as computeGroups, n as isGroupId, t as makeGroupId };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { applyInitialVisibility as e, buildRecordCache as t, collectVisibleIds as n, hideDescendants as r } from "./visibility-model.js";
|
|
2
|
+
import { groupStackMetrics as i } from "./group-stack.js";
|
|
3
|
+
import { GROUP_COLLAPSED_MEMBERS_HEIGHT as a, GROUP_HEADER_HEIGHT as o, GROUP_MEMBER_GAP as s, GROUP_MEMBER_HEIGHT as c, GROUP_MEMBER_HEIGHT_COMPACT as l, memberCardHeight as u } from "./group-geometry.js";
|
|
4
|
+
import { computeGroups as d, isGroupId as f, makeGroupId as p } from "./grouping.js";
|
|
5
|
+
import { createElkLayoutEngine as m } from "./elk-layout-engine.js";
|
|
6
|
+
import { useDiagramLayout as h } from "./use-diagram-layout.js";
|
|
7
|
+
import g from "./diagram-node-card.js";
|
|
8
|
+
import _ from "./diagram-node-group.js";
|
|
9
|
+
export { g as DiagramNodeCard, _ as DiagramNodeGroup, a as GROUP_COLLAPSED_MEMBERS_HEIGHT, o as GROUP_HEADER_HEIGHT, s as GROUP_MEMBER_GAP, c as GROUP_MEMBER_HEIGHT, l as GROUP_MEMBER_HEIGHT_COMPACT, e as applyInitialVisibility, t as buildRecordCache, n as collectVisibleIds, d as computeGroups, m as createElkLayoutEngine, i as groupStackMetrics, r as hideDescendants, f as isGroupId, p as makeGroupId, u as memberCardHeight, h as useDiagramLayout };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { applyInitialVisibility as e, buildRecordCache as t, collectVisibleIds as n, hideDescendants as r } from "./visibility-model.js";
|
|
2
|
+
import { computeGroups as i, isGroupId as a } from "./grouping.js";
|
|
3
|
+
import { createElkLayoutEngine as o } from "./elk-layout-engine.js";
|
|
4
|
+
import { shallowRef as s, triggerRef as c } from "vue";
|
|
5
|
+
//#region lib/diagram-layout/use-diagram-layout.ts
|
|
6
|
+
var l = "__virtual_root__", u = 100;
|
|
7
|
+
function d(d) {
|
|
8
|
+
let f = d.engine ?? o(), p = d.measuredHeightFeedback ?? !0, m = [], h = {}, g = [], _ = [], v = 0, y = null, b = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), S = s(/* @__PURE__ */ new Set()), C = s([]), w = s([]), T = s([]), E = s(/* @__PURE__ */ new Map()), D = s([]);
|
|
9
|
+
function O(e) {
|
|
10
|
+
m = e;
|
|
11
|
+
}
|
|
12
|
+
function k() {
|
|
13
|
+
S.value = /* @__PURE__ */ new Set(), x.clear(), b.clear(), v = 0, y = null, D.value = [];
|
|
14
|
+
}
|
|
15
|
+
function A(e) {
|
|
16
|
+
_ = e;
|
|
17
|
+
}
|
|
18
|
+
async function j(n) {
|
|
19
|
+
let r = t(m, d.isRoot);
|
|
20
|
+
h = r.recordMap, g = r.rootIds, D.value = r.orphanIds, e(h, g, n), await U();
|
|
21
|
+
}
|
|
22
|
+
async function M() {
|
|
23
|
+
await U();
|
|
24
|
+
}
|
|
25
|
+
async function N(e) {
|
|
26
|
+
if (!p) return !1;
|
|
27
|
+
let t = !1;
|
|
28
|
+
for (let n in e) {
|
|
29
|
+
let r = e[n];
|
|
30
|
+
r > 0 && b.get(n) !== r && (b.set(n, r), t = !0);
|
|
31
|
+
}
|
|
32
|
+
return t && m.length > 0 ? (await M(), !0) : !1;
|
|
33
|
+
}
|
|
34
|
+
async function P(e) {
|
|
35
|
+
let t = h[e];
|
|
36
|
+
if (t) {
|
|
37
|
+
x.set(e, ++v);
|
|
38
|
+
for (let e of t.childrenCache) t.visibleChildIds.add(e.record.id);
|
|
39
|
+
await M();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function F(e) {
|
|
43
|
+
let t = h[e];
|
|
44
|
+
t && (r(t), await M());
|
|
45
|
+
}
|
|
46
|
+
async function I(e) {
|
|
47
|
+
let t = h[e];
|
|
48
|
+
t && (t.visibleChildIds.size > 0 ? await F(e) : await P(e));
|
|
49
|
+
}
|
|
50
|
+
async function L(e) {
|
|
51
|
+
let t = q(e, E.value.get(e) ?? []);
|
|
52
|
+
t && K(t, S.value.has(e)).expandable && (S.value.has(e) ? S.value.delete(e) : S.value.add(e), c(S), await M());
|
|
53
|
+
}
|
|
54
|
+
function R(e) {
|
|
55
|
+
return !!h[e]?.childrenCache.length;
|
|
56
|
+
}
|
|
57
|
+
function z(e, t) {
|
|
58
|
+
let n = h[e];
|
|
59
|
+
if (n) {
|
|
60
|
+
m.push(...t);
|
|
61
|
+
for (let e of t) {
|
|
62
|
+
let t = {
|
|
63
|
+
record: e,
|
|
64
|
+
childrenCache: [],
|
|
65
|
+
visibleChildIds: /* @__PURE__ */ new Set()
|
|
66
|
+
};
|
|
67
|
+
h[e.id] = t, n.childrenCache.push(t), n.visibleChildIds.add(e.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function B(e) {
|
|
72
|
+
return h[e];
|
|
73
|
+
}
|
|
74
|
+
function V(e, t) {
|
|
75
|
+
let n = h[e];
|
|
76
|
+
if (!n) return;
|
|
77
|
+
let r = {
|
|
78
|
+
...n.record,
|
|
79
|
+
...t
|
|
80
|
+
};
|
|
81
|
+
n.record = r, m = m.map((t) => t.id === e ? r : t), H();
|
|
82
|
+
}
|
|
83
|
+
function H() {
|
|
84
|
+
if (!y) return;
|
|
85
|
+
let { emitSequence: e, positions: t, groupLayouts: n } = y, r = [], i = [];
|
|
86
|
+
for (let a of e) {
|
|
87
|
+
let e = t[a.kind === "group" ? a.group.id : a.id] ?? {
|
|
88
|
+
x: 0,
|
|
89
|
+
y: 0
|
|
90
|
+
};
|
|
91
|
+
if (a.kind === "node") {
|
|
92
|
+
r.push(d.toNode({
|
|
93
|
+
entry: h[a.id],
|
|
94
|
+
position: e
|
|
95
|
+
}));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
let o = n.get(a.group.id);
|
|
99
|
+
i.push(d.toGroupNode({
|
|
100
|
+
group: a.group,
|
|
101
|
+
members: G(a.group.memberIds),
|
|
102
|
+
position: e,
|
|
103
|
+
size: o,
|
|
104
|
+
expanded: S.value.has(a.group.id),
|
|
105
|
+
expandable: o.expandable
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
C.value = [...r, ...i];
|
|
109
|
+
}
|
|
110
|
+
async function U() {
|
|
111
|
+
let e = n(g, h), t = new Set(e), r = i(e, h), a = new Set(r.flatMap((e) => e.memberIds)), o = new Map(r.map((e) => [`${e.parentId}::${e.tagName}`, e])), s = J(e), c = (e) => (s.get(e) ?? 0) >= 2, p = Y(e, a, c), m = Z(e, o, p, c), _ = Q(m, t, a, o, p, c), v = Math.max(0, ...e.map((e) => W(e).width)) + u, b = /* @__PURE__ */ new Map(), x = [{
|
|
112
|
+
id: l,
|
|
113
|
+
width: 0,
|
|
114
|
+
height: 0,
|
|
115
|
+
orderHint: -v
|
|
116
|
+
}, ...m.map((e) => {
|
|
117
|
+
if (e.kind === "group") {
|
|
118
|
+
let t = K(e.group, S.value.has(e.group.id));
|
|
119
|
+
return b.set(e.group.id, t), {
|
|
120
|
+
id: e.group.id,
|
|
121
|
+
width: t.width,
|
|
122
|
+
height: t.height,
|
|
123
|
+
orderHint: (_.get(e.group.id) ?? 0) * v
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
let t = W(e.id);
|
|
127
|
+
return {
|
|
128
|
+
id: e.id,
|
|
129
|
+
width: t.width,
|
|
130
|
+
height: t.height,
|
|
131
|
+
orderHint: (_.get(e.id) ?? 0) * v
|
|
132
|
+
};
|
|
133
|
+
})], C = X(m, t, a), D = {
|
|
134
|
+
nodes: x,
|
|
135
|
+
edges: C
|
|
136
|
+
}, O = await f.layout(D, d.layoutOptions);
|
|
137
|
+
y = {
|
|
138
|
+
emitSequence: m,
|
|
139
|
+
positions: O.positions,
|
|
140
|
+
groupLayouts: b
|
|
141
|
+
}, H();
|
|
142
|
+
let k = new Set(m.map((e) => e.kind === "group" ? e.group.id : e.id));
|
|
143
|
+
T.value = m.map((e) => {
|
|
144
|
+
let t = e.kind === "group" ? e.group.id : e.id, n = e.kind === "group" ? e.group.parentId : h[e.id]?.record.parent?.id, r = O.positions[t] ?? {
|
|
145
|
+
x: 0,
|
|
146
|
+
y: 0
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
id: t,
|
|
150
|
+
x: r.x,
|
|
151
|
+
y: r.y,
|
|
152
|
+
parentId: n && k.has(n) ? n : null
|
|
153
|
+
};
|
|
154
|
+
}), E.value = new Map(r.map((e) => [e.id, e.memberIds]));
|
|
155
|
+
let A = C.filter((e) => e.sources[0] !== l).filter((e) => !a.has(e.targets[0])), j = /* @__PURE__ */ new Map();
|
|
156
|
+
for (let e of A) {
|
|
157
|
+
let t = e.sources[0];
|
|
158
|
+
j.set(t, (j.get(t) ?? 0) + 1);
|
|
159
|
+
}
|
|
160
|
+
w.value = A.map((e) => {
|
|
161
|
+
let t = j.get(e.sources[0]) === 1;
|
|
162
|
+
return d.toEdge({
|
|
163
|
+
edge: e,
|
|
164
|
+
route: t ? [] : O.edgeRoutes[e.id] ?? [],
|
|
165
|
+
singleChild: t
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function W(e) {
|
|
170
|
+
let t = h[e];
|
|
171
|
+
return d.nodeSize(t.record, b.get(e));
|
|
172
|
+
}
|
|
173
|
+
function G(e) {
|
|
174
|
+
return e.map((e) => h[e]).filter(Boolean);
|
|
175
|
+
}
|
|
176
|
+
function K(e, t) {
|
|
177
|
+
return d.groupLayout(e, G(e.memberIds), t);
|
|
178
|
+
}
|
|
179
|
+
function q(e, t) {
|
|
180
|
+
if (!a(e) || t.length === 0) return;
|
|
181
|
+
let n = h[t[0]]?.record;
|
|
182
|
+
if (n?.parent?.id) return {
|
|
183
|
+
id: e,
|
|
184
|
+
parentId: n.parent.id,
|
|
185
|
+
tagName: n.tagName,
|
|
186
|
+
memberIds: t
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function J(e) {
|
|
190
|
+
let t = /* @__PURE__ */ new Map();
|
|
191
|
+
for (let n of e) {
|
|
192
|
+
let e = h[n]?.record;
|
|
193
|
+
if (!e?.parent?.id) continue;
|
|
194
|
+
let r = `${e.parent.id}::${e.tagName}`;
|
|
195
|
+
t.set(r, (t.get(r) ?? 0) + 1);
|
|
196
|
+
}
|
|
197
|
+
return t;
|
|
198
|
+
}
|
|
199
|
+
function Y(e, t, n) {
|
|
200
|
+
let r = /* @__PURE__ */ new Map();
|
|
201
|
+
for (let i of e) {
|
|
202
|
+
if (t.has(i)) continue;
|
|
203
|
+
let e = h[i]?.record;
|
|
204
|
+
if (!e?.parent?.id) continue;
|
|
205
|
+
let a = `${e.parent.id}::${e.tagName}`;
|
|
206
|
+
if (!n(a)) continue;
|
|
207
|
+
let o = r.get(a);
|
|
208
|
+
o ? o.push(i) : r.set(a, [i]);
|
|
209
|
+
}
|
|
210
|
+
for (let e of r.values()) e.sort((e, t) => (x.get(e) ?? 0) - (x.get(t) ?? 0));
|
|
211
|
+
return r;
|
|
212
|
+
}
|
|
213
|
+
function X(e, t, n) {
|
|
214
|
+
let r = [];
|
|
215
|
+
for (let i of e) {
|
|
216
|
+
let e = i.kind === "group" ? i.group.id : i.id, a = i.kind === "group" ? i.group.parentId : h[i.id]?.record.parent?.id, o = a && t.has(a) && !n.has(a) ? a : l;
|
|
217
|
+
r.push({
|
|
218
|
+
id: `${o}->${e}`,
|
|
219
|
+
sources: [o],
|
|
220
|
+
targets: [e]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
for (let e of _) t.has(e.source) && t.has(e.target) && r.push({
|
|
224
|
+
id: e.id,
|
|
225
|
+
sources: [e.source],
|
|
226
|
+
targets: [e.target]
|
|
227
|
+
});
|
|
228
|
+
return r;
|
|
229
|
+
}
|
|
230
|
+
function Z(e, t, n, r) {
|
|
231
|
+
let i = [], a = /* @__PURE__ */ new Set();
|
|
232
|
+
for (let o of e) {
|
|
233
|
+
let e = h[o]?.record, s = e?.parent?.id ? `${e.parent.id}::${e.tagName}` : void 0;
|
|
234
|
+
if (s && r(s)) {
|
|
235
|
+
if (!a.has(s)) {
|
|
236
|
+
a.add(s);
|
|
237
|
+
for (let e of n.get(s) ?? []) i.push({
|
|
238
|
+
kind: "node",
|
|
239
|
+
id: e
|
|
240
|
+
});
|
|
241
|
+
let e = t.get(s);
|
|
242
|
+
e && i.push({
|
|
243
|
+
kind: "group",
|
|
244
|
+
group: e
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
i.push({
|
|
250
|
+
kind: "node",
|
|
251
|
+
id: o
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return i;
|
|
255
|
+
}
|
|
256
|
+
function Q(e, t, n, r, i, a) {
|
|
257
|
+
let o = /* @__PURE__ */ new Map(), s = 0, c = (e) => {
|
|
258
|
+
let n = h[e];
|
|
259
|
+
if (!n) return [];
|
|
260
|
+
let o = [], s = /* @__PURE__ */ new Set();
|
|
261
|
+
for (let c of n.childrenCache) {
|
|
262
|
+
let n = c.record.id;
|
|
263
|
+
if (!t.has(n)) continue;
|
|
264
|
+
let l = `${e}::${c.record.tagName}`;
|
|
265
|
+
if (a(l)) {
|
|
266
|
+
if (!s.has(l)) {
|
|
267
|
+
s.add(l);
|
|
268
|
+
for (let e of i.get(l) ?? []) o.push({
|
|
269
|
+
kind: "node",
|
|
270
|
+
id: e
|
|
271
|
+
});
|
|
272
|
+
let e = r.get(l);
|
|
273
|
+
e && o.push({
|
|
274
|
+
kind: "group",
|
|
275
|
+
group: e
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
o.push({
|
|
281
|
+
kind: "node",
|
|
282
|
+
id: n
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return o;
|
|
286
|
+
}, l = (e) => {
|
|
287
|
+
for (let t of e) t.kind === "group" ? o.set(t.group.id, s++) : (o.set(t.id, s++), l(c(t.id)));
|
|
288
|
+
};
|
|
289
|
+
return l(e.filter((e) => {
|
|
290
|
+
if (e.kind === "group") return !(t.has(e.group.parentId) && !n.has(e.group.parentId));
|
|
291
|
+
let r = h[e.id]?.record.parent?.id;
|
|
292
|
+
return !(r && t.has(r) && !n.has(r));
|
|
293
|
+
})), o;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
flowNodes: C,
|
|
297
|
+
flowEdges: w,
|
|
298
|
+
navNodes: T,
|
|
299
|
+
groupMembersById: E,
|
|
300
|
+
expandedGroupIds: S,
|
|
301
|
+
orphanIds: D,
|
|
302
|
+
setRecords: O,
|
|
303
|
+
setConnections: A,
|
|
304
|
+
reset: k,
|
|
305
|
+
calcLayout: j,
|
|
306
|
+
reCalcLayout: M,
|
|
307
|
+
applyMeasuredHeights: N,
|
|
308
|
+
expandNode: P,
|
|
309
|
+
collapseNode: F,
|
|
310
|
+
toggleNode: I,
|
|
311
|
+
toggleGroup: L,
|
|
312
|
+
hasNodeLoadedChildren: R,
|
|
313
|
+
addChildren: z,
|
|
314
|
+
getRecordEntry: B,
|
|
315
|
+
updateRecord: V
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
export { d as useDiagramLayout };
|