@shwfed/config 2.3.10 → 2.3.12
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/mcp.mjs +946 -544
- package/dist/module.json +1 -1
- package/dist/preview/assets/{config-CyScbxXy.js → config-B-1L3Ra-.js} +1 -1
- package/dist/preview/assets/{config-ja_GMXxV.js → config-Cf5kO84H.js} +1 -1
- package/dist/preview/assets/{config-bxqg3yuv.js → config-DTQkLHVw.js} +1 -1
- package/dist/preview/assets/{config-HdWYFZ09.js → config-DqxN0Byp.js} +1 -1
- package/dist/preview/assets/{config-2R4XkSGs.js → config-QUQ71Eo6.js} +1 -1
- package/dist/preview/assets/{config-ykJZssgx.js → config-oO93sSer.js} +1 -1
- package/dist/preview/assets/{config-KcLrpkc1.js → config-sJ5XKUJy.js} +1 -1
- package/dist/preview/assets/{config-BxzDT_57.js → config-zCMkbPQt.js} +1 -1
- package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-CWyVRSOh.js → definition.vue_vue_type_script_setup_true_lang-D-OVRv68.js} +1 -1
- package/dist/preview/assets/index-Br_eXThF.css +1 -0
- package/dist/preview/assets/index-D8QyOVfp.js +637 -0
- package/dist/preview/assets/index-b_t8yWJJ.js +1 -0
- package/dist/preview/assets/{runtime-B8aUJIpn.js → runtime-10_7L7Gz.js} +1 -1
- package/dist/preview/assets/{runtime-CxA8fvQP.js → runtime-B2EP6060.js} +1 -1
- package/dist/preview/assets/{runtime-LBdh1D75.js → runtime-BxlgShjU.js} +1 -1
- package/dist/preview/assets/{runtime-DqZhDPHl.js → runtime-Cv2doZNu.js} +1 -1
- package/dist/preview/assets/{runtime-CpSiaWMP.js → runtime-CzDUrqSa.js} +1 -1
- package/dist/preview/assets/{runtime-D2K1s33u.js → runtime-DcYhXvSk.js} +1 -1
- package/dist/preview/assets/{runtime-DAXQmtLg.js → runtime-DlDhRVII.js} +1 -1
- package/dist/preview/assets/{runtime-C9XnvD5A.js → runtime-cmkN6aik.js} +1 -1
- package/dist/preview/index.html +2 -2
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/schema.d.ts +1 -1
- package/dist/runtime/components/config/blocks/2026-05-17/com.shwfed.block.chart.xy/schema.d.ts +4 -0
- package/dist/runtime/components/config/blocks/2026-05-17/com.shwfed.block.chart.xy/schema.js +6 -17
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.d.vue.ts +18 -18
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/config.vue.d.ts +18 -18
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetime/config.d.vue.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetime/config.vue.d.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.time/config.d.vue.ts +2 -2
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.time/config.vue.d.ts +2 -2
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.d.vue.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/config.vue.d.ts +4 -4
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.d.vue.ts +12 -12
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/config.vue.d.ts +12 -12
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.switch/config.d.vue.ts +10 -10
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.switch/config.vue.d.ts +10 -10
- package/dist/runtime/components/form/fields/2026-05-12/com.shwfed.form.field.upload/config.d.vue.ts +12 -12
- package/dist/runtime/components/form/fields/2026-05-12/com.shwfed.form.field.upload/config.vue.d.ts +12 -12
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.d.vue.ts +133 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.vue +605 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.vue.d.ts +133 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/runtime.d.vue.ts +8 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/runtime.vue +324 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/runtime.vue.d.ts +8 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/schema.d.ts +99 -0
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/schema.js +129 -0
- package/dist/runtime/components/form/unit-config.vue +8 -27
- package/dist/runtime/components/form/utils/resolve.d.ts +48 -9
- package/dist/runtime/components/form/utils/resolve.js +59 -5
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.vue +305 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.vue +81 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/schema.d.ts +55 -0
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/schema.js +82 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.vue +310 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.vue +81 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/schema.d.ts +66 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/schema.js +71 -0
- package/dist/runtime/components/table/config.d.vue.ts +2 -2
- package/dist/runtime/components/table/config.vue +7 -46
- package/dist/runtime/components/table/config.vue.d.ts +2 -2
- package/dist/runtime/components/table/schema.d.ts +9 -2
- package/dist/runtime/components/table/schema.js +30 -14
- package/dist/runtime/components/table/utils/resolve.d.ts +53 -0
- package/dist/runtime/components/table/utils/resolve.js +66 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerDateTimePanel.d.vue.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerDateTimePanel.vue.d.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.d.vue.ts +1 -1
- package/dist/runtime/components/ui/date-range-picker/DateRangePickerTimeInput.vue.d.ts +1 -1
- package/dist/runtime/components/ui/tree/Tree.d.vue.ts +57 -0
- package/dist/runtime/components/ui/tree/Tree.vue +325 -0
- package/dist/runtime/components/ui/tree/Tree.vue.d.ts +57 -0
- package/dist/runtime/components/ui/tree/TreeNode.d.vue.ts +53 -0
- package/dist/runtime/components/ui/tree/TreeNode.vue +299 -0
- package/dist/runtime/components/ui/tree/TreeNode.vue.d.ts +53 -0
- package/dist/runtime/components/ui/tree/index.d.ts +3 -0
- package/dist/runtime/components/ui/tree/index.js +2 -0
- package/dist/runtime/components/ui/tree/types.d.ts +120 -0
- package/dist/runtime/components/ui/tree/types.js +0 -0
- package/dist/runtime/components/ui/tree/useTreeState.d.ts +95 -0
- package/dist/runtime/components/ui/tree/useTreeState.js +369 -0
- package/dist/runtime/shims.d.ts +2 -0
- package/package.json +1 -1
- package/dist/preview/assets/index-BPKK3hGV.css +0 -1
- package/dist/preview/assets/index-D3pf2RjG.js +0 -1
- package/dist/preview/assets/index-OUd02U3g.js +0 -1075
- package/dist/runtime/components/form/ai/fields-button.d.vue.ts +0 -13
- package/dist/runtime/components/form/ai/fields-button.vue +0 -458
- package/dist/runtime/components/form/ai/fields-button.vue.d.ts +0 -13
- package/dist/runtime/components/form/ai/fields-task.md +0 -71
- package/dist/runtime/components/table/ai/columns-button.d.vue.ts +0 -12
- package/dist/runtime/components/table/ai/columns-button.vue +0 -491
- package/dist/runtime/components/table/ai/columns-button.vue.d.ts +0 -12
- package/dist/runtime/components/table/ai/columns-task.md +0 -53
- package/dist/runtime/components/table/ai/data-source-button.d.vue.ts +0 -20
- package/dist/runtime/components/table/ai/data-source-button.vue +0 -324
- package/dist/runtime/components/table/ai/data-source-button.vue.d.ts +0 -20
- package/dist/runtime/components/table/ai/data-source-task.md +0 -17
- package/dist/runtime/utils/ai/cel-prompt.d.ts +0 -11
- package/dist/runtime/utils/ai/cel-prompt.js +0 -27
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { computed, reactive, ref, shallowRef } from "vue";
|
|
2
|
+
import { Cause, Effect, Exit } from "effect";
|
|
3
|
+
export function useTreeState(opts) {
|
|
4
|
+
const expanded = reactive(new Set(opts.initialExpanded()));
|
|
5
|
+
const selected = reactive(new Set(opts.initialSelection()));
|
|
6
|
+
const loadState = reactive(/* @__PURE__ */ new Map());
|
|
7
|
+
const requested = reactive(/* @__PURE__ */ new Set());
|
|
8
|
+
const focusedKey = ref(null);
|
|
9
|
+
const rootsView = shallowRef(opts.rootsRef.value);
|
|
10
|
+
/* @__PURE__ */ ((roots) => {
|
|
11
|
+
void roots;
|
|
12
|
+
})(opts.rootsRef);
|
|
13
|
+
function syncRoots() {
|
|
14
|
+
rootsView.value = opts.rootsRef.value;
|
|
15
|
+
}
|
|
16
|
+
function locate(key) {
|
|
17
|
+
const stack = [
|
|
18
|
+
{ siblings: rootsView.value, parent: null, depth: 0 }
|
|
19
|
+
];
|
|
20
|
+
while (stack.length) {
|
|
21
|
+
const frame = stack.pop();
|
|
22
|
+
for (let i = 0; i < frame.siblings.length; i++) {
|
|
23
|
+
const n = frame.siblings[i];
|
|
24
|
+
if (opts.getKey(n) === key) {
|
|
25
|
+
return {
|
|
26
|
+
node: n,
|
|
27
|
+
parent: frame.parent,
|
|
28
|
+
depth: frame.depth,
|
|
29
|
+
index: i,
|
|
30
|
+
siblings: frame.siblings
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const kids = resolvedChildren(n);
|
|
34
|
+
if (kids && kids.length) {
|
|
35
|
+
stack.push({ siblings: kids, parent: n, depth: frame.depth + 1 });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function resolvedChildren(node) {
|
|
42
|
+
const k = opts.getKey(node);
|
|
43
|
+
const cached = loadState.get(k);
|
|
44
|
+
if (cached?.status === "loaded") return cached.children;
|
|
45
|
+
const inline = opts.getChildren?.(node);
|
|
46
|
+
if (inline === void 0) {
|
|
47
|
+
if (opts.loadChildren) return null;
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
if (inline.length > 0) return inline;
|
|
51
|
+
if (opts.loadChildren) return null;
|
|
52
|
+
return inline;
|
|
53
|
+
}
|
|
54
|
+
function isExpandable(node) {
|
|
55
|
+
const cached = loadState.get(opts.getKey(node));
|
|
56
|
+
if (cached?.status === "loaded" && cached.children.length > 0) return true;
|
|
57
|
+
const inline = opts.getChildren?.(node);
|
|
58
|
+
if (inline === void 0) return false;
|
|
59
|
+
if (inline.length > 0) return true;
|
|
60
|
+
return Boolean(opts.loadChildren);
|
|
61
|
+
}
|
|
62
|
+
function ensureLoaded(node) {
|
|
63
|
+
const loader = opts.loadChildren;
|
|
64
|
+
if (!loader) return;
|
|
65
|
+
const inline = opts.getChildren?.(node);
|
|
66
|
+
if (!(inline !== void 0 && inline.length === 0)) return;
|
|
67
|
+
const key = opts.getKey(node);
|
|
68
|
+
if (requested.has(key)) return;
|
|
69
|
+
const prior = loadState.get(key);
|
|
70
|
+
if (prior?.status === "loaded") return;
|
|
71
|
+
requested.add(key);
|
|
72
|
+
loadState.set(key, { status: "loading" });
|
|
73
|
+
Effect.runPromiseExit(loader(node)).then((exit) => {
|
|
74
|
+
Exit.match(exit, {
|
|
75
|
+
onSuccess: (children) => {
|
|
76
|
+
loadState.set(key, { status: "loaded", children });
|
|
77
|
+
},
|
|
78
|
+
onFailure: (cause) => {
|
|
79
|
+
const failure = Cause.failureOption(cause);
|
|
80
|
+
const error = failure._tag === "Some" ? failure.value : cause;
|
|
81
|
+
loadState.set(key, { status: "error", error });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function retry(key) {
|
|
87
|
+
requested.delete(key);
|
|
88
|
+
loadState.delete(key);
|
|
89
|
+
const loc = locate(key);
|
|
90
|
+
if (loc) ensureLoaded(loc.node);
|
|
91
|
+
}
|
|
92
|
+
function invalidate(key) {
|
|
93
|
+
requested.delete(key);
|
|
94
|
+
loadState.delete(key);
|
|
95
|
+
}
|
|
96
|
+
function expand(key) {
|
|
97
|
+
const loc = locate(key);
|
|
98
|
+
if (!loc) return;
|
|
99
|
+
if (!isExpandable(loc.node)) return;
|
|
100
|
+
expanded.add(key);
|
|
101
|
+
ensureLoaded(loc.node);
|
|
102
|
+
}
|
|
103
|
+
function collapse(key) {
|
|
104
|
+
expanded.delete(key);
|
|
105
|
+
}
|
|
106
|
+
function toggleExpand(key) {
|
|
107
|
+
if (expanded.has(key)) collapse(key);
|
|
108
|
+
else expand(key);
|
|
109
|
+
}
|
|
110
|
+
function emitSelection() {
|
|
111
|
+
opts.onSelectionChange(Array.from(selected));
|
|
112
|
+
}
|
|
113
|
+
function selectSingle(key) {
|
|
114
|
+
selected.clear();
|
|
115
|
+
selected.add(key);
|
|
116
|
+
emitSelection();
|
|
117
|
+
}
|
|
118
|
+
function clearSelection() {
|
|
119
|
+
if (selected.size === 0) return;
|
|
120
|
+
selected.clear();
|
|
121
|
+
emitSelection();
|
|
122
|
+
}
|
|
123
|
+
function walkSubtree(node, visit, depth = 0) {
|
|
124
|
+
visit(node, depth);
|
|
125
|
+
const kids = resolvedChildren(node);
|
|
126
|
+
if (kids && kids.length > 0) {
|
|
127
|
+
for (const c of kids) walkSubtree(c, visit, depth + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function cascadeToggle(node, depth, on) {
|
|
131
|
+
walkSubtree(node, (n, d) => {
|
|
132
|
+
if (!opts.selectable(n, depth + d)) return;
|
|
133
|
+
const k = opts.getKey(n);
|
|
134
|
+
if (on) selected.add(k);
|
|
135
|
+
else selected.delete(k);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function toggleMulti(key) {
|
|
139
|
+
const loc = locate(key);
|
|
140
|
+
if (!loc) return;
|
|
141
|
+
if (!opts.selectable(loc.node, loc.depth)) return;
|
|
142
|
+
const mode = opts.cascade();
|
|
143
|
+
const turningOn = !selected.has(key);
|
|
144
|
+
if (mode === "independent") {
|
|
145
|
+
if (turningOn) selected.add(key);
|
|
146
|
+
else selected.delete(key);
|
|
147
|
+
} else {
|
|
148
|
+
cascadeToggle(loc.node, loc.depth, turningOn);
|
|
149
|
+
}
|
|
150
|
+
emitSelection();
|
|
151
|
+
}
|
|
152
|
+
function selectKey(key) {
|
|
153
|
+
const mode = opts.selectionMode();
|
|
154
|
+
if (mode === "none") return;
|
|
155
|
+
if (mode === "single") {
|
|
156
|
+
const loc = locate(key);
|
|
157
|
+
if (!loc || !opts.selectable(loc.node, loc.depth)) return;
|
|
158
|
+
selectSingle(key);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (selected.has(key)) return;
|
|
162
|
+
toggleMulti(key);
|
|
163
|
+
}
|
|
164
|
+
function deselectKey(key) {
|
|
165
|
+
const mode = opts.selectionMode();
|
|
166
|
+
if (mode === "none") return;
|
|
167
|
+
if (mode === "single") {
|
|
168
|
+
if (!selected.has(key)) return;
|
|
169
|
+
selected.delete(key);
|
|
170
|
+
emitSelection();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!selected.has(key)) return;
|
|
174
|
+
toggleMulti(key);
|
|
175
|
+
}
|
|
176
|
+
function descendantSelectionStats(node, depth) {
|
|
177
|
+
let total = 0;
|
|
178
|
+
let selectedCount = 0;
|
|
179
|
+
const kids = resolvedChildren(node);
|
|
180
|
+
if (!kids || kids.length === 0) return { total, selectedCount };
|
|
181
|
+
for (const c of kids) {
|
|
182
|
+
walkSubtree(c, (n, d) => {
|
|
183
|
+
if (!opts.selectable(n, depth + 1 + d)) return;
|
|
184
|
+
total++;
|
|
185
|
+
if (selected.has(opts.getKey(n))) selectedCount++;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return { selectedCount, total };
|
|
189
|
+
}
|
|
190
|
+
function isIndeterminate(node, depth) {
|
|
191
|
+
if (opts.selectionMode() !== "multi") return false;
|
|
192
|
+
if (opts.cascade() !== "cascade-both") return false;
|
|
193
|
+
const { selectedCount, total } = descendantSelectionStats(node, depth);
|
|
194
|
+
if (total === 0) return false;
|
|
195
|
+
return selectedCount > 0 && selectedCount < total;
|
|
196
|
+
}
|
|
197
|
+
function isVisuallySelected(node, depth) {
|
|
198
|
+
const k = opts.getKey(node);
|
|
199
|
+
if (selected.has(k)) return true;
|
|
200
|
+
if (opts.selectionMode() !== "multi") return false;
|
|
201
|
+
if (opts.cascade() !== "cascade-both") return false;
|
|
202
|
+
const { selectedCount, total } = descendantSelectionStats(node, depth);
|
|
203
|
+
return total > 0 && selectedCount === total;
|
|
204
|
+
}
|
|
205
|
+
function withMutation(next) {
|
|
206
|
+
opts.setRoots(next);
|
|
207
|
+
rootsView.value = next;
|
|
208
|
+
}
|
|
209
|
+
function mutateSiblings(parentKey, op) {
|
|
210
|
+
if (parentKey === null) {
|
|
211
|
+
const next = rootsView.value.slice();
|
|
212
|
+
op(next);
|
|
213
|
+
withMutation(next);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
const parentLoc = locate(parentKey);
|
|
217
|
+
if (!parentLoc) return false;
|
|
218
|
+
const inline = opts.getChildren?.(parentLoc.node);
|
|
219
|
+
if (inline !== void 0) {
|
|
220
|
+
op(inline);
|
|
221
|
+
} else {
|
|
222
|
+
const ls = loadState.get(parentKey);
|
|
223
|
+
if (ls?.status === "loaded") {
|
|
224
|
+
op(ls.children);
|
|
225
|
+
} else {
|
|
226
|
+
const arr = [];
|
|
227
|
+
op(arr);
|
|
228
|
+
loadState.set(parentKey, { status: "loaded", children: arr });
|
|
229
|
+
requested.add(parentKey);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
withMutation(rootsView.value.slice());
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
function insert(parentKey, node, index) {
|
|
236
|
+
mutateSiblings(parentKey, (siblings) => {
|
|
237
|
+
const at = index ?? siblings.length;
|
|
238
|
+
siblings.splice(Math.max(0, Math.min(at, siblings.length)), 0, node);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function remove(key) {
|
|
242
|
+
const loc = locate(key);
|
|
243
|
+
if (!loc) return;
|
|
244
|
+
loc.siblings.splice(loc.index, 1);
|
|
245
|
+
selected.delete(key);
|
|
246
|
+
expanded.delete(key);
|
|
247
|
+
loadState.delete(key);
|
|
248
|
+
requested.delete(key);
|
|
249
|
+
withMutation(rootsView.value.slice());
|
|
250
|
+
}
|
|
251
|
+
function move(key, newParentKey, index) {
|
|
252
|
+
const loc = locate(key);
|
|
253
|
+
if (!loc) return;
|
|
254
|
+
const [node] = loc.siblings.splice(loc.index, 1);
|
|
255
|
+
if (!node) return;
|
|
256
|
+
if (newParentKey === null) {
|
|
257
|
+
const next = rootsView.value.slice();
|
|
258
|
+
const at = Math.max(0, Math.min(index, next.length));
|
|
259
|
+
next.splice(at, 0, node);
|
|
260
|
+
withMutation(next);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const parentLoc = locate(newParentKey);
|
|
264
|
+
if (!parentLoc) {
|
|
265
|
+
loc.siblings.splice(loc.index, 0, node);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const inline = opts.getChildren?.(parentLoc.node);
|
|
269
|
+
if (inline !== void 0) {
|
|
270
|
+
const at = Math.max(0, Math.min(index, inline.length));
|
|
271
|
+
inline.splice(at, 0, node);
|
|
272
|
+
} else {
|
|
273
|
+
const ls = loadState.get(newParentKey);
|
|
274
|
+
if (ls?.status === "loaded") {
|
|
275
|
+
const at = Math.max(0, Math.min(index, ls.children.length));
|
|
276
|
+
ls.children.splice(at, 0, node);
|
|
277
|
+
} else {
|
|
278
|
+
const arr = [node];
|
|
279
|
+
loadState.set(newParentKey, { status: "loaded", children: arr });
|
|
280
|
+
requested.add(newParentKey);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
withMutation(rootsView.value.slice());
|
|
284
|
+
}
|
|
285
|
+
function update(key, patch) {
|
|
286
|
+
const loc = locate(key);
|
|
287
|
+
if (!loc) return;
|
|
288
|
+
Object.assign(loc.node, patch);
|
|
289
|
+
withMutation(rootsView.value.slice());
|
|
290
|
+
}
|
|
291
|
+
function flattenVisible(filter) {
|
|
292
|
+
const out = [];
|
|
293
|
+
function walk(siblings, depth) {
|
|
294
|
+
for (const n of siblings) {
|
|
295
|
+
if (!filter || filter(n)) {
|
|
296
|
+
out.push({ node: n, depth, key: opts.getKey(n) });
|
|
297
|
+
}
|
|
298
|
+
const kids = resolvedChildren(n);
|
|
299
|
+
if (kids && kids.length > 0 && expanded.has(opts.getKey(n))) {
|
|
300
|
+
walk(kids, depth + 1);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
walk(rootsView.value, 0);
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
function findPath(key) {
|
|
308
|
+
const trail = [];
|
|
309
|
+
function walk(siblings) {
|
|
310
|
+
for (const n of siblings) {
|
|
311
|
+
trail.push(n);
|
|
312
|
+
if (opts.getKey(n) === key) return true;
|
|
313
|
+
const kids = resolvedChildren(n);
|
|
314
|
+
if (kids && kids.length && walk(kids)) return true;
|
|
315
|
+
trail.pop();
|
|
316
|
+
}
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
return walk(rootsView.value) ? trail.slice() : null;
|
|
320
|
+
}
|
|
321
|
+
function snapshot() {
|
|
322
|
+
return {
|
|
323
|
+
roots: rootsView.value.slice(),
|
|
324
|
+
selected: Array.from(selected),
|
|
325
|
+
expanded: Array.from(expanded)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const selectedNodes = computed(() => {
|
|
329
|
+
const out = [];
|
|
330
|
+
for (const k of selected) {
|
|
331
|
+
const loc = locate(k);
|
|
332
|
+
if (loc) out.push(loc.node);
|
|
333
|
+
}
|
|
334
|
+
return out;
|
|
335
|
+
});
|
|
336
|
+
return {
|
|
337
|
+
// state (reactive)
|
|
338
|
+
expanded,
|
|
339
|
+
selected,
|
|
340
|
+
loadState,
|
|
341
|
+
focusedKey,
|
|
342
|
+
rootsView,
|
|
343
|
+
// queries
|
|
344
|
+
locate,
|
|
345
|
+
resolvedChildren,
|
|
346
|
+
isExpandable,
|
|
347
|
+
isIndeterminate,
|
|
348
|
+
isVisuallySelected,
|
|
349
|
+
flattenVisible,
|
|
350
|
+
selectedNodes,
|
|
351
|
+
// mutations / commands
|
|
352
|
+
syncRoots,
|
|
353
|
+
expand,
|
|
354
|
+
collapse,
|
|
355
|
+
toggleExpand,
|
|
356
|
+
selectKey,
|
|
357
|
+
deselectKey,
|
|
358
|
+
clearSelection,
|
|
359
|
+
toggleMulti,
|
|
360
|
+
insert,
|
|
361
|
+
remove,
|
|
362
|
+
move,
|
|
363
|
+
update,
|
|
364
|
+
invalidate,
|
|
365
|
+
retry,
|
|
366
|
+
findPath,
|
|
367
|
+
snapshot
|
|
368
|
+
};
|
|
369
|
+
}
|
package/dist/runtime/shims.d.ts
CHANGED