@septkit/ui 0.0.91 → 0.0.93
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/explorer/explorer-search.js +2 -1
- package/dist/explorer/explorer.js +1 -1
- package/dist/explorer/explorer.vue_vue_type_script_setup_true_lang.js +123 -112
- package/dist/index.d.ts +23 -12
- package/dist/tree/collect-expandable-node-ids.js +8 -10
- package/dist/tree/flatten-tree.js +25 -24
- package/dist/tree/has-children.js +6 -0
- package/dist/tree/tree-index.js +21 -23
- package/dist/tree/tree.js +1 -1
- package/dist/tree/tree.vue_vue_type_script_setup_true_lang.js +37 -38
- package/dist/tree/use-tree-virtualization.js +54 -34
- package/dist/ui.css +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@ import { flattenTree as s } from "./flatten-tree.js";
|
|
|
9
9
|
import { useTreeVirtualization as c } from "./use-tree-virtualization.js";
|
|
10
10
|
import { Fragment as l, computed as u, createBlock as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createVNode as h, defineComponent as g, mergeProps as _, normalizeClass as v, normalizeStyle as y, openBlock as b, ref as x, renderList as S, renderSlot as C, toDisplayString as w, unref as T, withCtx as E, withModifiers as D } from "vue";
|
|
11
11
|
//#region lib/tree/tree.vue?vue&type=script&setup=true&lang.ts
|
|
12
|
-
var O = ["onClick", "onContextmenu"],
|
|
12
|
+
var O = ["aria-expanded"], k = ["onClick", "onContextmenu"], A = { class: "flex flex-1 items-center min-w-0" }, j = { class: "pl-2 truncate" }, M = { class: "shrink-0 ml-auto pl-2" }, N = /*@__PURE__*/ g({
|
|
13
13
|
__name: "tree",
|
|
14
14
|
props: {
|
|
15
15
|
items: {},
|
|
@@ -28,75 +28,75 @@ var O = ["onClick", "onContextmenu"], k = { class: "flex flex-1 items-center min
|
|
|
28
28
|
"row-click",
|
|
29
29
|
"update:expanded"
|
|
30
30
|
],
|
|
31
|
-
setup(g, { emit:
|
|
32
|
-
let
|
|
33
|
-
root:
|
|
34
|
-
rows:
|
|
35
|
-
rowHeight: u(() =>
|
|
36
|
-
selected: () =>
|
|
31
|
+
setup(g, { emit: N }) {
|
|
32
|
+
let P = g, F = N, I = x(), L = u(() => i(P.items)), R = u(() => a(P.expanded, L.value)), z = u(() => s(P.items, new Set(R.value))), B = u(() => P.selected === void 0 ? void 0 : { id: P.selected }), { spacers: V, windowOf: H, focusRow: U } = c({
|
|
33
|
+
root: I,
|
|
34
|
+
rows: z,
|
|
35
|
+
rowHeight: u(() => P.rowHeight),
|
|
36
|
+
selected: () => P.selected
|
|
37
37
|
});
|
|
38
|
-
function U(e) {
|
|
39
|
-
P("update:expanded", o(L.value, e.id));
|
|
40
|
-
}
|
|
41
38
|
function W(e) {
|
|
42
|
-
R.value
|
|
39
|
+
F("update:expanded", o(R.value, e.id));
|
|
40
|
+
}
|
|
41
|
+
function G(e) {
|
|
42
|
+
z.value[e.index + 1]?.depth === e.depth + 1 && U(e.index + 1);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function K(e, t) {
|
|
45
45
|
if (e.key === "ArrowRight") {
|
|
46
46
|
if (!t.hasChildren) return;
|
|
47
|
-
t.expanded ?
|
|
48
|
-
} else if (e.key === "ArrowLeft") if (t.hasChildren && t.expanded)
|
|
49
|
-
else if (t.parentIndex !== void 0)
|
|
47
|
+
t.expanded ? G(t) : W(t);
|
|
48
|
+
} else if (e.key === "ArrowLeft") if (t.hasChildren && t.expanded) W(t);
|
|
49
|
+
else if (t.parentIndex !== void 0) U(t.parentIndex);
|
|
50
50
|
else return;
|
|
51
51
|
else return;
|
|
52
52
|
e.stopImmediatePropagation();
|
|
53
53
|
}
|
|
54
54
|
return (i, a) => (b(), d(T(e), {
|
|
55
55
|
ref_key: "root",
|
|
56
|
-
ref:
|
|
56
|
+
ref: I,
|
|
57
57
|
class: "explorer-tree list-none select-none w-full text-stone-700 text-sm font-medium",
|
|
58
|
-
items:
|
|
58
|
+
items: z.value,
|
|
59
59
|
"get-key": (e) => e.id,
|
|
60
60
|
"get-children": (e) => e.hasChildren ? [] : void 0,
|
|
61
61
|
expanded: [],
|
|
62
|
-
"model-value":
|
|
63
|
-
"aria-label":
|
|
62
|
+
"model-value": B.value,
|
|
63
|
+
"aria-label": P.ariaLabel
|
|
64
64
|
}, {
|
|
65
65
|
default: E(({ flattenItems: e }) => [
|
|
66
|
-
T(
|
|
66
|
+
T(V).before > 0 ? (b(), p("li", {
|
|
67
67
|
key: 0,
|
|
68
68
|
role: "presentation",
|
|
69
|
-
style: y({ height: `${T(
|
|
69
|
+
style: y({ height: `${T(V).before}px` })
|
|
70
70
|
}, null, 4)) : f("", !0),
|
|
71
|
-
(b(!0), p(l, null, S(T(
|
|
71
|
+
(b(!0), p(l, null, S(T(H)(e), (e) => (b(), d(T(t), _({
|
|
72
72
|
key: e.value.id,
|
|
73
73
|
"data-index": e.value.index
|
|
74
74
|
}, { ref_for: !0 }, e.bind, {
|
|
75
|
+
"as-child": "",
|
|
75
76
|
level: e.value.depth,
|
|
76
77
|
"aria-setsize": e.value.setSize,
|
|
77
78
|
"aria-posinset": e.value.posInSet,
|
|
78
|
-
"aria-
|
|
79
|
-
"aria-label": N.rowLabel?.(e.value.node),
|
|
79
|
+
"aria-label": P.rowLabel?.(e.value.node),
|
|
80
80
|
class: ["explorer-tree__item flex items-center px-2 rounded outline-none", e.value.node.selectable === !1 ? "" : "explorer-tree__item--selectable"],
|
|
81
81
|
style: {
|
|
82
|
-
height: `${
|
|
82
|
+
height: `${P.rowHeight}px`,
|
|
83
83
|
boxSizing: "border-box"
|
|
84
84
|
},
|
|
85
|
-
onKeydownCapture: (t) =>
|
|
85
|
+
onKeydownCapture: (t) => K(t, e.value),
|
|
86
86
|
onSelect: (t) => {
|
|
87
|
-
t.detail.originalEvent.type === "click" || e.value.node.selectable === !1 ? t.preventDefault() :
|
|
87
|
+
t.detail.originalEvent.type === "click" || e.value.node.selectable === !1 ? t.preventDefault() : F("select", e.value.node);
|
|
88
88
|
},
|
|
89
89
|
onToggle: a[0] ||= (e) => {
|
|
90
90
|
e.detail.originalEvent.type === "click" && e.preventDefault();
|
|
91
91
|
}
|
|
92
92
|
}), {
|
|
93
|
-
default: E(({ handleSelect: t }) => [m("div", {
|
|
93
|
+
default: E(({ handleSelect: t }) => [m("li", { "aria-expanded": e.value.hasChildren ? e.value.expanded : void 0 }, [m("div", {
|
|
94
94
|
class: v(["flex w-full items-center", e.value.node.selectable === !1 ? "cursor-default" : "cursor-pointer"]),
|
|
95
95
|
style: y({ "padding-left": e.value.depth === 1 ? "0rem" : `${e.value.depth - 1.5}rem` }),
|
|
96
96
|
onClick: () => {
|
|
97
|
-
e.value.node.selectable !== !1 && (t(),
|
|
97
|
+
e.value.node.selectable !== !1 && (t(), F("select", e.value.node)), F("row-click", e.value.node);
|
|
98
98
|
},
|
|
99
|
-
onContextmenu: D((t) =>
|
|
99
|
+
onContextmenu: D((t) => F("contextmenu", {
|
|
100
100
|
node: e.value.node,
|
|
101
101
|
event: t
|
|
102
102
|
}), ["prevent"])
|
|
@@ -110,33 +110,32 @@ var O = ["onClick", "onContextmenu"], k = { class: "flex flex-1 items-center min
|
|
|
110
110
|
class: "shrink-0 invisible",
|
|
111
111
|
size: 16
|
|
112
112
|
})], !0),
|
|
113
|
-
m("div",
|
|
113
|
+
m("div", A, [
|
|
114
114
|
C(i.$slots, "node-prefix", { node: e.value.node }, void 0, !0),
|
|
115
115
|
e.value.node.tag ? (b(), d(T(r), {
|
|
116
116
|
key: 0,
|
|
117
117
|
"tag-name": e.value.node.tag
|
|
118
118
|
}, null, 8, ["tag-name"])) : f("", !0),
|
|
119
|
-
C(i.$slots, "node-label", { node: e.value.node }, () => [m("span",
|
|
119
|
+
C(i.$slots, "node-label", { node: e.value.node }, () => [m("span", j, w(e.value.node.name), 1)], !0)
|
|
120
120
|
]),
|
|
121
|
-
m("div",
|
|
122
|
-
], 46, O)]),
|
|
121
|
+
m("div", M, [C(i.$slots, "node-suffix", { node: e.value.node }, void 0, !0)])
|
|
122
|
+
], 46, k)], 8, O)]),
|
|
123
123
|
_: 2
|
|
124
124
|
}, 1040, [
|
|
125
125
|
"data-index",
|
|
126
126
|
"level",
|
|
127
127
|
"aria-setsize",
|
|
128
128
|
"aria-posinset",
|
|
129
|
-
"aria-expanded",
|
|
130
129
|
"aria-label",
|
|
131
130
|
"class",
|
|
132
131
|
"style",
|
|
133
132
|
"onKeydownCapture",
|
|
134
133
|
"onSelect"
|
|
135
134
|
]))), 128)),
|
|
136
|
-
T(
|
|
135
|
+
T(V).after > 0 ? (b(), p("li", {
|
|
137
136
|
key: 1,
|
|
138
137
|
role: "presentation",
|
|
139
|
-
style: y({ height: `${T(
|
|
138
|
+
style: y({ height: `${T(V).after}px` })
|
|
140
139
|
}, null, 4)) : f("", !0)
|
|
141
140
|
]),
|
|
142
141
|
_: 3
|
|
@@ -150,4 +149,4 @@ var O = ["onClick", "onContextmenu"], k = { class: "flex flex-1 items-center min
|
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
//#endregion
|
|
153
|
-
export {
|
|
152
|
+
export { N as default };
|
|
@@ -1,54 +1,74 @@
|
|
|
1
1
|
import { useVirtualScroller as e } from "../virtual/use-virtual-scroller.js";
|
|
2
2
|
import "../virtual/index.js";
|
|
3
|
-
import { computed as t, nextTick as n,
|
|
3
|
+
import { computed as t, nextTick as n, onBeforeUnmount as r, onMounted as i, ref as a, watch as o } from "vue";
|
|
4
4
|
//#region lib/tree/use-tree-virtualization.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var s = 10, c = 800;
|
|
6
|
+
function l(e) {
|
|
7
7
|
for (let t = e?.parentElement; t; t = t.parentElement) if (/auto|scroll|overlay/.test(getComputedStyle(t).overflowY)) return t;
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
return e === void 0 ? -1 : u.value.findIndex((t) => t.id === e);
|
|
14
|
-
}), _ = e({
|
|
15
|
-
scrollElement: p,
|
|
10
|
+
function u({ root: u, rows: d, rowHeight: f, selected: p }) {
|
|
11
|
+
let m = a(null), h = a(0), g = p() !== void 0, _ = a(), v = !1, y = t(() => S(p())), b = t(() => S(_.value)), x = e({
|
|
12
|
+
scrollElement: m,
|
|
16
13
|
rows: {
|
|
17
|
-
count: () =>
|
|
18
|
-
size:
|
|
19
|
-
overscan:
|
|
20
|
-
paddingStart: () =>
|
|
21
|
-
getKey: (e) =>
|
|
22
|
-
keep: () =>
|
|
14
|
+
count: () => d.value.length,
|
|
15
|
+
size: f,
|
|
16
|
+
overscan: s,
|
|
17
|
+
paddingStart: () => h.value,
|
|
18
|
+
getKey: (e) => d.value[e]?.id ?? e,
|
|
19
|
+
keep: () => [y.value, b.value].filter((e) => e >= 0)
|
|
23
20
|
},
|
|
24
21
|
initialRect: {
|
|
25
22
|
width: 0,
|
|
26
|
-
height:
|
|
23
|
+
height: c
|
|
27
24
|
}
|
|
28
25
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
i(() => {
|
|
27
|
+
m.value = l(u.value?.$el ?? null), E(), u.value?.$el.addEventListener("focusin", C), u.value?.$el.addEventListener("focusout", w), n(D);
|
|
28
|
+
}), r(() => {
|
|
29
|
+
u.value?.$el.removeEventListener("focusin", C), u.value?.$el.removeEventListener("focusout", w);
|
|
30
|
+
}), o(d, () => {
|
|
31
|
+
v = !0, n(() => {
|
|
32
|
+
v = !1, E(), T();
|
|
33
|
+
});
|
|
34
|
+
}), o(p, () => {
|
|
35
|
+
g = !0, n(D);
|
|
36
|
+
}), o(y, () => void n(D));
|
|
37
|
+
function S(e) {
|
|
38
|
+
return e === void 0 ? -1 : d.value.findIndex((t) => t.id === e);
|
|
37
39
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
+
function C(e) {
|
|
41
|
+
let t = e.target.closest("[data-index]")?.dataset.index;
|
|
42
|
+
_.value = t === void 0 ? void 0 : d.value[Number(t)]?.id;
|
|
40
43
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
44
|
+
function w(e) {
|
|
45
|
+
let t = e.relatedTarget;
|
|
46
|
+
(t ? !u.value?.$el.contains(t) : !v) && (_.value = void 0);
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
function T() {
|
|
49
|
+
let e = u.value?.$el;
|
|
50
|
+
if (!e || b.value < 0) return;
|
|
51
|
+
let t = globalThis.document.activeElement;
|
|
52
|
+
t && t !== globalThis.document.body || e.querySelector(`[data-index="${b.value}"]`)?.focus();
|
|
53
|
+
}
|
|
54
|
+
function E() {
|
|
55
|
+
let e = u.value?.$el, t = m.value;
|
|
56
|
+
!e || !t || (h.value = e.getBoundingClientRect().top - t.getBoundingClientRect().top + t.scrollTop);
|
|
57
|
+
}
|
|
58
|
+
function D() {
|
|
59
|
+
!g || y.value < 0 || (g = !1, x.scrollToIndex({ index: y.value }));
|
|
60
|
+
}
|
|
61
|
+
function O(e) {
|
|
62
|
+
return x.rows.value.flatMap((t) => e[t.index] ?? []);
|
|
63
|
+
}
|
|
64
|
+
async function k(e) {
|
|
65
|
+
_.value = d.value[e]?.id, x.scrollToIndex({ index: e }), await n(), u.value?.$el.querySelector(`[data-index="${e}"]`)?.focus();
|
|
46
66
|
}
|
|
47
67
|
return {
|
|
48
|
-
spacers:
|
|
49
|
-
windowOf:
|
|
50
|
-
focusRow:
|
|
68
|
+
spacers: x.spacers,
|
|
69
|
+
windowOf: O,
|
|
70
|
+
focusRow: k
|
|
51
71
|
};
|
|
52
72
|
}
|
|
53
73
|
//#endregion
|
|
54
|
-
export {
|
|
74
|
+
export { u as useTreeVirtualization };
|