@fewangsit/wangsvue-fats 1.0.1-alpha.63 → 1.0.1-alpha.65
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/buttonselecttree/index.d.ts +1 -1
- package/dialogselecttree/index.d.ts +6 -0
- package/dialogselecttree/index.es.js +8 -8
- package/image/index.d.ts +11 -0
- package/image/index.es.js +86 -73
- package/package.json +1 -1
- package/stats.html +1 -1
- package/tree/index.es.js +76 -74
- package/wangsvue-fats.esm.browser.js +475 -460
- package/wangsvue-fats.system.js +13 -13
package/tree/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as te, useSlots as se, computed as
|
|
2
|
-
import { e as
|
|
1
|
+
import { defineComponent as te, useSlots as se, computed as $, onMounted as le, onBeforeUnmount as oe, ref as i, shallowRef as ne, nextTick as J, watch as U, createBlock as ae, openBlock as de, mergeProps as ie, createSlots as re, withCtx as ce, renderSlot as ue } from "vue";
|
|
2
|
+
import { e as k } from "../event-bus/index.es.js";
|
|
3
3
|
import { u as pe } from "../plugins/WangsVue.es.js";
|
|
4
4
|
import { m as fe } from "../utils/mergePropsWithDefaults.util.es.js";
|
|
5
5
|
import { _ as ye } from "../basetree/index.es.js";
|
|
6
6
|
const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => Object.fromEntries(
|
|
7
|
-
Object.entries(r).filter(([
|
|
8
|
-
const
|
|
9
|
-
return
|
|
7
|
+
Object.entries(r).filter(([S, s]) => {
|
|
8
|
+
const K = s.checked && !s.partialChecked, C = c || S != "-1";
|
|
9
|
+
return K && C;
|
|
10
10
|
})
|
|
11
11
|
), j = (r) => r ? r.flatMap((c) => [
|
|
12
12
|
{ ...c },
|
|
@@ -62,14 +62,14 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
62
62
|
nodeSelectedWhen: {}
|
|
63
63
|
},
|
|
64
64
|
emits: ["update:selectedKeys", "update:selectedTreeNodes", "nodeSelect", "nodeUnselect", "toggleMenu"],
|
|
65
|
-
setup(r, { expose: c, emit:
|
|
66
|
-
const s = r,
|
|
65
|
+
setup(r, { expose: c, emit: S }) {
|
|
66
|
+
const s = r, K = se(), { defaultProps: C } = pe("Tree"), G = $(() => fe(s, C)), p = S;
|
|
67
67
|
le(() => {
|
|
68
|
-
|
|
68
|
+
k.on("tree:update-tree-nodes", A), M(s.filter), b();
|
|
69
69
|
}), oe(() => {
|
|
70
|
-
|
|
70
|
+
k.off("tree:update-tree-nodes", A);
|
|
71
71
|
});
|
|
72
|
-
const
|
|
72
|
+
const v = i(!0), F = i((/* @__PURE__ */ new Date()).getTime().toString()), H = i(), f = i([]), y = i([]), m = i({}), N = i(!1), d = i({ "-1": !0 }), O = i(!1), g = $({
|
|
73
73
|
get: () => s.selectedKeys ?? {},
|
|
74
74
|
set: (e) => {
|
|
75
75
|
p("update:selectedKeys", e);
|
|
@@ -78,17 +78,17 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
78
78
|
if (s.selectionMode === "checkbox") {
|
|
79
79
|
const t = (l, o) => {
|
|
80
80
|
l.forEach((n) => {
|
|
81
|
-
var
|
|
82
|
-
const
|
|
83
|
-
u.value[
|
|
81
|
+
var a;
|
|
82
|
+
const h = !!(e != null && e.includes(n.key));
|
|
83
|
+
u.value[n.key] = { checked: h }, (a = n.children) != null && a.length && t(n.children, n.key), o && z(o);
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
t(
|
|
86
|
+
t(f.value);
|
|
87
87
|
} else {
|
|
88
88
|
const t = e == null ? void 0 : e[0];
|
|
89
89
|
t && (u.value = { [t]: !0 });
|
|
90
90
|
}
|
|
91
|
-
}, V = (e) => Array.isArray(e) && e.every((t) => typeof t == "
|
|
91
|
+
}, V = (e) => Array.isArray(e) && e.every((t) => typeof t == "string"), z = (e) => {
|
|
92
92
|
const t = Q(e), l = u.value[e].checked || t, o = !t && X(e);
|
|
93
93
|
u.value[e] = {
|
|
94
94
|
// It should be checked when not partial checked, when it partially checked, the checked value should be false
|
|
@@ -97,60 +97,62 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
97
97
|
};
|
|
98
98
|
}, Q = (e) => {
|
|
99
99
|
var t;
|
|
100
|
-
return (t =
|
|
100
|
+
return (t = m.value[e]) == null ? void 0 : t.every((l) => {
|
|
101
101
|
var n;
|
|
102
102
|
const o = JSON.stringify(l);
|
|
103
103
|
return (n = u.value[o]) == null ? void 0 : n.checked;
|
|
104
104
|
});
|
|
105
105
|
}, X = (e) => {
|
|
106
106
|
var t;
|
|
107
|
-
return (t =
|
|
108
|
-
var n,
|
|
107
|
+
return (t = m.value[e]) == null ? void 0 : t.some((l) => {
|
|
108
|
+
var n, h;
|
|
109
109
|
const o = JSON.stringify(l);
|
|
110
|
-
return ((n = u.value[o]) == null ? void 0 : n.checked) || ((
|
|
110
|
+
return ((n = u.value[o]) == null ? void 0 : n.checked) || ((h = u.value[o]) == null ? void 0 : h.partialChecked);
|
|
111
111
|
});
|
|
112
|
-
},
|
|
112
|
+
}, w = (e) => e.map((t) => {
|
|
113
113
|
var l;
|
|
114
|
-
return t.key = t.key ?? t._id, (l = t.children) != null && l.length && (
|
|
115
|
-
...
|
|
116
|
-
[t.key.toString()]: t.children.map(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
114
|
+
return t.key = t.key ?? t._id, (l = t.children) != null && l.length && (m.value = {
|
|
115
|
+
...m.value,
|
|
116
|
+
[t.key.toString()]: t.children.map(
|
|
117
|
+
(o) => o.key
|
|
118
|
+
)
|
|
119
|
+
}, t.children = w(t.children)), s.disableNodeWhen && (t.selectable = !s.disableNodeWhen(t)), t;
|
|
120
|
+
}), A = () => {
|
|
121
|
+
(async () => (p("update:selectedKeys", {}), await b(!1), L()))();
|
|
122
|
+
}, b = async (e = !0) => {
|
|
121
123
|
try {
|
|
122
|
-
|
|
124
|
+
v.value = !0;
|
|
123
125
|
const { data: t } = await G.value.fetchTree(
|
|
124
126
|
s.type,
|
|
125
127
|
s.params
|
|
126
128
|
) ?? { data: [] };
|
|
127
129
|
if (t) {
|
|
128
|
-
const l =
|
|
129
|
-
|
|
130
|
+
const l = w(t);
|
|
131
|
+
y.value = j(l), f.value = l, sessionStorage.setItem(`${s.type}Tree`, JSON.stringify(l)), sessionStorage.setItem(
|
|
130
132
|
`flatten${s.type}nodes`,
|
|
131
|
-
JSON.stringify(
|
|
133
|
+
JSON.stringify(y.value)
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
|
-
s.selectLastNode && s.selectionMode === "single" && await
|
|
136
|
+
s.selectLastNode && s.selectionMode === "single" && await J(Y), s.autoSelectAll && s.selectionMode === "checkbox" && await J(q);
|
|
135
137
|
} finally {
|
|
136
|
-
V(s.selectedKeys) && (R(s.selectedKeys),
|
|
138
|
+
V(s.selectedKeys) && (R(s.selectedKeys), g.value = u.value), e || k.emit("tree:tree-updated"), v.value = !1;
|
|
137
139
|
}
|
|
138
140
|
}, Y = async () => {
|
|
139
|
-
var
|
|
141
|
+
var I, D;
|
|
140
142
|
const e = sessionStorage.getItem(
|
|
141
143
|
`${s.type.toLowerCase()}Node`
|
|
142
|
-
), t = (
|
|
144
|
+
), t = (I = f.value) == null ? void 0 : I[0], l = (D = t == null ? void 0 : t.children) == null ? void 0 : D[0], o = e ? JSON.parse(e) : null, n = (o == null ? void 0 : o.key) == -1, h = s.disableNodeAll ? l : t, a = n && s.disableNodeAll ? (
|
|
143
145
|
// When last node is All, and disableNodeExist, it should select the firstChild of all
|
|
144
146
|
l
|
|
145
|
-
) : o ??
|
|
147
|
+
) : o ?? h;
|
|
146
148
|
if ((a == null ? void 0 : a.key) != null && Z(a == null ? void 0 : a.key)) {
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
+
g.value = { [a == null ? void 0 : a.key]: !0 };
|
|
150
|
+
const W = sessionStorage.getItem(
|
|
149
151
|
`${s.type.toLowerCase()}NodeExpandedKeys`
|
|
150
152
|
);
|
|
151
|
-
|
|
153
|
+
W && (d.value = JSON.parse(W)), x(a);
|
|
152
154
|
}
|
|
153
|
-
}, Z = (e) =>
|
|
155
|
+
}, Z = (e) => y.value.some((t) => t.key === e), x = (e) => {
|
|
154
156
|
p("nodeSelect", e), s.shouldEmitEventOnChange && (sessionStorage.setItem(
|
|
155
157
|
`${s.type.toLowerCase()}Node`,
|
|
156
158
|
JSON.stringify(e)
|
|
@@ -160,67 +162,67 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
160
162
|
));
|
|
161
163
|
}, q = () => {
|
|
162
164
|
const e = {};
|
|
163
|
-
|
|
165
|
+
y.value.forEach((t) => {
|
|
164
166
|
e[t.key] = {
|
|
165
167
|
checked: !0,
|
|
166
168
|
partialChecked: !1
|
|
167
169
|
};
|
|
168
|
-
}),
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
for (const e of
|
|
172
|
-
|
|
170
|
+
}), g.value = e;
|
|
171
|
+
}, B = () => {
|
|
172
|
+
N.value = !0;
|
|
173
|
+
for (const e of f.value)
|
|
174
|
+
T(e);
|
|
173
175
|
d.value = { ...d.value };
|
|
174
|
-
},
|
|
176
|
+
}, T = (e) => {
|
|
175
177
|
var t;
|
|
176
178
|
if ((t = e.children) != null && t.length) {
|
|
177
179
|
d.value[e.key ?? ""] = !0;
|
|
178
180
|
for (const l of e.children)
|
|
179
|
-
|
|
181
|
+
T(l);
|
|
180
182
|
}
|
|
181
183
|
}, _ = () => {
|
|
182
|
-
d.value = { "-1": !0 },
|
|
183
|
-
},
|
|
184
|
+
d.value = { "-1": !0 }, N.value = !1;
|
|
185
|
+
}, L = () => {
|
|
184
186
|
if (s.selectedKeys) {
|
|
185
187
|
const e = Array.isArray(s.selectedKeys) ? s.selectedKeys : Object.keys(
|
|
186
188
|
P(s.selectedKeys, s.includeNodeAllKey)
|
|
187
|
-
)
|
|
188
|
-
(l) => e.includes(l.
|
|
189
|
+
), t = y.value.filter(
|
|
190
|
+
(l) => e.includes(l._id)
|
|
189
191
|
);
|
|
190
192
|
s.shouldEmitEventOnChange && (sessionStorage.setItem(
|
|
191
193
|
`${s.type.toLowerCase()}Keys`,
|
|
192
194
|
JSON.stringify(e)
|
|
193
|
-
),
|
|
195
|
+
), k.emit("tree:selection-changed", {
|
|
194
196
|
keys: JSON.stringify(e)
|
|
195
197
|
})), p("update:selectedTreeNodes", t);
|
|
196
198
|
}
|
|
197
|
-
},
|
|
198
|
-
e != null && e.length ?
|
|
199
|
+
}, M = (e) => {
|
|
200
|
+
e != null && e.length ? B() : E();
|
|
199
201
|
}, ee = (e) => {
|
|
200
|
-
s.readonly ||
|
|
201
|
-
},
|
|
202
|
+
s.readonly || x(e);
|
|
203
|
+
}, E = () => {
|
|
202
204
|
d.value = { "-1": !0 };
|
|
203
205
|
};
|
|
204
206
|
return U(
|
|
205
207
|
() => s.filter,
|
|
206
208
|
(e) => {
|
|
207
|
-
|
|
209
|
+
M(e);
|
|
208
210
|
}
|
|
209
211
|
), U(
|
|
210
212
|
() => [s.selectedKeys, s.type],
|
|
211
213
|
async (e, t) => {
|
|
212
|
-
e[1] !== t[1] && (p("update:selectedKeys", {}), await
|
|
214
|
+
e[1] !== t[1] && (p("update:selectedKeys", {}), await b()), L();
|
|
213
215
|
}
|
|
214
216
|
), c({
|
|
215
|
-
treeNodes:
|
|
216
|
-
flatNodes:
|
|
217
|
-
isLoading:
|
|
218
|
-
showDisposableGroups:
|
|
219
|
-
isExpandedAll:
|
|
217
|
+
treeNodes: f,
|
|
218
|
+
flatNodes: y,
|
|
219
|
+
isLoading: v,
|
|
220
|
+
showDisposableGroups: O,
|
|
221
|
+
isExpandedAll: N,
|
|
220
222
|
collapseAll: _,
|
|
221
|
-
expandAll:
|
|
222
|
-
expandNodeAll:
|
|
223
|
-
fetchTreeList:
|
|
223
|
+
expandAll: B,
|
|
224
|
+
expandNodeAll: E,
|
|
225
|
+
fetchTreeList: b
|
|
224
226
|
}), (e, t) => (de(), ae(ye, ie({
|
|
225
227
|
id: F.value,
|
|
226
228
|
ref_key: "tree",
|
|
@@ -228,8 +230,8 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
228
230
|
}, e.$attrs, {
|
|
229
231
|
"expanded-keys": d.value,
|
|
230
232
|
"onUpdate:expandedKeys": t[0] || (t[0] = (l) => d.value = l),
|
|
231
|
-
"selection-keys":
|
|
232
|
-
"onUpdate:selectionKeys": t[1] || (t[1] = (l) =>
|
|
233
|
+
"selection-keys": g.value,
|
|
234
|
+
"onUpdate:selectionKeys": t[1] || (t[1] = (l) => g.value = l),
|
|
233
235
|
class: { readonly: s.readonly },
|
|
234
236
|
"disable-keys": e.disableKeys,
|
|
235
237
|
"disable-node-all": s.disableNodeAll,
|
|
@@ -238,21 +240,21 @@ const be = (r, c = !1) => Object.keys(P(r, c)).map(Number), P = (r, c = !1) => O
|
|
|
238
240
|
"exact-disable-node-when": e.exactDisableNodeWhen,
|
|
239
241
|
"filter-text": e.filter,
|
|
240
242
|
"list-labels-no-option": e.listLabelsNoOption,
|
|
241
|
-
loading:
|
|
243
|
+
loading: v.value,
|
|
242
244
|
"node-selected-when": e.nodeSelectedWhen,
|
|
243
245
|
"propagate-selection": e.propagateSelection,
|
|
244
246
|
"selection-mode": s.selectionMode,
|
|
245
|
-
"show-disposable-groups":
|
|
247
|
+
"show-disposable-groups": O.value,
|
|
246
248
|
"tree-node-menus": e.treeNodeMenus,
|
|
247
249
|
"use-option": e.useOption,
|
|
248
|
-
value:
|
|
249
|
-
onNodeCollapse: t[2] || (t[2] = (l) =>
|
|
250
|
+
value: f.value,
|
|
251
|
+
onNodeCollapse: t[2] || (t[2] = (l) => N.value = !1),
|
|
250
252
|
onNodeSelect: ee,
|
|
251
253
|
onNodeUnselect: t[3] || (t[3] = (l) => p("nodeUnselect", l)),
|
|
252
254
|
onToggleMenu: t[4] || (t[4] = (l) => p("toggleMenu", l)),
|
|
253
255
|
"filter-by": "name"
|
|
254
256
|
}), re({ _: 2 }, [
|
|
255
|
-
|
|
257
|
+
K.default ? {
|
|
256
258
|
name: "default",
|
|
257
259
|
fn: ce(({ node: l, checked: o, disabled: n }) => [
|
|
258
260
|
ue(e.$slots, "default", {
|