@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/tree/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
- import { defineComponent as te, useSlots as se, computed as W, onMounted as le, onBeforeUnmount as oe, ref as i, shallowRef as ne, nextTick as $, 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 S } from "../event-bus/index.es.js";
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(([K, s]) => {
8
- const C = s.checked && !s.partialChecked, O = c || K != "-1";
9
- return C && O;
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: K }) {
66
- const s = r, C = se(), { defaultProps: O } = pe("Tree"), G = W(() => fe(s, O)), p = K;
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
- S.on("tree:update-tree-nodes", x), E(s.filter), k();
68
+ k.on("tree:update-tree-nodes", A), M(s.filter), b();
69
69
  }), oe(() => {
70
- S.off("tree:update-tree-nodes", x);
70
+ k.off("tree:update-tree-nodes", A);
71
71
  });
72
- const g = i(!0), F = i((/* @__PURE__ */ new Date()).getTime().toString()), H = i(), y = i([]), h = i([]), v = i({}), b = i(!1), d = i({ "-1": !0 }), w = i(!1), m = W({
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 N;
82
- const f = JSON.stringify(n.key), a = !!(e != null && e.includes(Number(n.key)));
83
- u.value[f] = { checked: a }, (N = n.children) != null && N.length && t(n.children, f), o && z(o);
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(y.value);
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 == "number"), z = (e) => {
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 = v.value[e]) == null ? void 0 : t.every((l) => {
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 = v.value[e]) == null ? void 0 : t.some((l) => {
108
- var n, f;
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) || ((f = u.value[o]) == null ? void 0 : f.partialChecked);
110
+ return ((n = u.value[o]) == null ? void 0 : n.checked) || ((h = u.value[o]) == null ? void 0 : h.partialChecked);
111
111
  });
112
- }, A = (e) => e.map((t) => {
112
+ }, w = (e) => e.map((t) => {
113
113
  var l;
114
- return t.key = t.key ?? t._id, (l = t.children) != null && l.length && (v.value = {
115
- ...v.value,
116
- [t.key.toString()]: t.children.map((o) => Number(o.key))
117
- }, t.children = A(t.children)), s.disableNodeWhen && (t.selectable = !s.disableNodeWhen(t)), t;
118
- }), x = () => {
119
- (async () => (p("update:selectedKeys", {}), await k(!1), M()))();
120
- }, k = async (e = !0) => {
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
- g.value = !0;
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 = A(t);
129
- h.value = j(l), y.value = l, sessionStorage.setItem(`${s.type}Tree`, JSON.stringify(l)), sessionStorage.setItem(
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(h.value)
133
+ JSON.stringify(y.value)
132
134
  );
133
135
  }
134
- s.selectLastNode && s.selectionMode === "single" && await $(Y), s.autoSelectAll && s.selectionMode === "checkbox" && await $(q);
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), m.value = u.value), e || S.emit("tree:tree-updated"), g.value = !1;
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 N, D;
141
+ var I, D;
140
142
  const e = sessionStorage.getItem(
141
143
  `${s.type.toLowerCase()}Node`
142
- ), t = (N = y.value) == null ? void 0 : N[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, f = s.disableNodeAll ? l : t, a = n && s.disableNodeAll ? (
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 ?? f;
147
+ ) : o ?? h;
146
148
  if ((a == null ? void 0 : a.key) != null && Z(a == null ? void 0 : a.key)) {
147
- m.value = { [a == null ? void 0 : a.key]: !0 };
148
- const J = sessionStorage.getItem(
149
+ g.value = { [a == null ? void 0 : a.key]: !0 };
150
+ const W = sessionStorage.getItem(
149
151
  `${s.type.toLowerCase()}NodeExpandedKeys`
150
152
  );
151
- J && (d.value = JSON.parse(J)), B(a);
153
+ W && (d.value = JSON.parse(W)), x(a);
152
154
  }
153
- }, Z = (e) => h.value.some((t) => t.key === e), B = (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
- h.value.forEach((t) => {
165
+ y.value.forEach((t) => {
164
166
  e[t.key] = {
165
167
  checked: !0,
166
168
  partialChecked: !1
167
169
  };
168
- }), m.value = e;
169
- }, T = () => {
170
- b.value = !0;
171
- for (const e of y.value)
172
- L(e);
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
- }, L = (e) => {
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
- L(l);
181
+ T(l);
180
182
  }
181
183
  }, _ = () => {
182
- d.value = { "-1": !0 }, b.value = !1;
183
- }, M = () => {
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
- ).map(Number), t = h.value.filter(
188
- (l) => e.includes(l.key)
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
- ), S.emit("tree:selection-changed", {
195
+ ), k.emit("tree:selection-changed", {
194
196
  keys: JSON.stringify(e)
195
197
  })), p("update:selectedTreeNodes", t);
196
198
  }
197
- }, E = (e) => {
198
- e != null && e.length ? T() : I();
199
+ }, M = (e) => {
200
+ e != null && e.length ? B() : E();
199
201
  }, ee = (e) => {
200
- s.readonly || B(e);
201
- }, I = () => {
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
- E(e);
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 k()), M();
214
+ e[1] !== t[1] && (p("update:selectedKeys", {}), await b()), L();
213
215
  }
214
216
  ), c({
215
- treeNodes: y,
216
- flatNodes: h,
217
- isLoading: g,
218
- showDisposableGroups: w,
219
- isExpandedAll: b,
217
+ treeNodes: f,
218
+ flatNodes: y,
219
+ isLoading: v,
220
+ showDisposableGroups: O,
221
+ isExpandedAll: N,
220
222
  collapseAll: _,
221
- expandAll: T,
222
- expandNodeAll: I,
223
- fetchTreeList: k
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": m.value,
232
- "onUpdate:selectionKeys": t[1] || (t[1] = (l) => m.value = 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: g.value,
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": w.value,
247
+ "show-disposable-groups": O.value,
246
248
  "tree-node-menus": e.treeNodeMenus,
247
249
  "use-option": e.useOption,
248
- value: y.value,
249
- onNodeCollapse: t[2] || (t[2] = (l) => b.value = !1),
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
- C.default ? {
257
+ K.default ? {
256
258
  name: "default",
257
259
  fn: ce(({ node: l, checked: o, disabled: n }) => [
258
260
  ue(e.$slots, "default", {