@vitorfba/vue-treeselect 1.0.1 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- import { createVNode as r, mergeProps as Pe, openBlock as V, createElementBlock as j, createElementVNode as $, normalizeClass as se, renderSlot as je, createTextVNode as Q, resolveComponent as H, defineComponent as Ue, createBlock as Qe, Teleport as Ke } from "vue";
1
+ import { createVNode as r, mergeProps as Pe, createElementBlock as U, openBlock as V, createElementVNode as $, normalizeClass as se, renderSlot as je, resolveComponent as P, createTextVNode as K, defineComponent as Ue, createBlock as Qe, Teleport as Ke } from "vue";
2
2
  var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
3
  function C(e) {
4
4
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -102,7 +102,7 @@ function Qt(e) {
102
102
  var n = Pt.test(e);
103
103
  return n || jt.test(e) ? Ut(e.slice(2), n ? 2 : 8) : Ht.test(e) ? fe : +e;
104
104
  }
105
- var Ie = Qt, Kt = Ce, K = ct, pe = Ie, qt = "Expected a function", Yt = Math.max, Xt = Math.min;
105
+ var Ie = Qt, Kt = Ce, q = ct, pe = Ie, qt = "Expected a function", Yt = Math.max, Xt = Math.min;
106
106
  function Gt(e, t, n) {
107
107
  var s, i, o, a, c, d, f = 0, m = !1, p = !1, v = !0;
108
108
  if (typeof e != "function")
@@ -124,7 +124,7 @@ function Gt(e, t, n) {
124
124
  return d === void 0 || O >= t || O < 0 || p && D >= o;
125
125
  }
126
126
  function L() {
127
- var u = K();
127
+ var u = q();
128
128
  if (z(u))
129
129
  return M(u);
130
130
  c = setTimeout(L, k(u));
@@ -132,14 +132,14 @@ function Gt(e, t, n) {
132
132
  function M(u) {
133
133
  return c = void 0, v && s ? N(u) : (s = i = void 0, a);
134
134
  }
135
- function U() {
135
+ function Q() {
136
136
  c !== void 0 && clearTimeout(c), f = 0, s = d = i = c = void 0;
137
137
  }
138
138
  function l() {
139
- return c === void 0 ? a : M(K());
139
+ return c === void 0 ? a : M(q());
140
140
  }
141
141
  function h() {
142
- var u = K(), O = z(u);
142
+ var u = q(), O = z(u);
143
143
  if (s = arguments, i = this, d = u, O) {
144
144
  if (c === void 0)
145
145
  return I(d);
@@ -148,7 +148,7 @@ function Gt(e, t, n) {
148
148
  }
149
149
  return c === void 0 && (c = setTimeout(L, t)), a;
150
150
  }
151
- return h.cancel = U, h.flush = l, h;
151
+ return h.cancel = Q, h.flush = l, h;
152
152
  }
153
153
  var Jt = Gt;
154
154
  const Zt = /* @__PURE__ */ C(Jt);
@@ -172,10 +172,10 @@ function De(e, t) {
172
172
  n !== -1 && e.splice(n, 1);
173
173
  }
174
174
  let ie;
175
- const P = [], tn = 100;
175
+ const j = [], tn = 100;
176
176
  function nn() {
177
177
  ie = setInterval(() => {
178
- P.forEach(xe);
178
+ j.forEach(xe);
179
179
  }, tn);
180
180
  }
181
181
  function sn() {
@@ -192,9 +192,9 @@ function rn(e, t) {
192
192
  lastWidth: null,
193
193
  lastHeight: null
194
194
  }, s = () => {
195
- De(P, n), P.length || sn();
195
+ De(j, n), j.length || sn();
196
196
  };
197
- return P.push(n), xe(n), nn(), s;
197
+ return j.push(n), xe(n), nn(), s;
198
198
  }
199
199
  function ge(e, t) {
200
200
  const n = document.documentMode === 9;
@@ -298,13 +298,13 @@ function Dn(e, t, n) {
298
298
  for (let s = 0, i = e.length; s < i; s++)
299
299
  if (t.call(n, e[s], s, e)) return e[s];
300
300
  }
301
- function q(e, t) {
301
+ function Y(e, t) {
302
302
  if (e.length !== t.length) return !0;
303
303
  for (let n = 0; n < e.length; n++)
304
304
  if (e[n] !== t[n]) return !0;
305
305
  return !1;
306
306
  }
307
- const E = null, oe = 0, $e = 1, Ve = 2, T = "ALL_CHILDREN", R = "ALL_DESCENDANTS", A = "LEAF_CHILDREN", B = "LEAF_DESCENDANTS", xn = "LOAD_ROOT_OPTIONS", Rn = "LOAD_CHILDREN_OPTIONS", An = "ASYNC_SEARCH", Y = "ALL", W = "BRANCH_PRIORITY", X = "LEAF_PRIORITY", G = "ALL_WITH_INDETERMINATE", Oe = "ORDER_SELECTED", ye = "LEVEL", _e = "INDEX", g = {
307
+ const E = null, oe = 0, $e = 1, Ve = 2, T = "ALL_CHILDREN", R = "ALL_DESCENDANTS", A = "LEAF_CHILDREN", B = "LEAF_DESCENDANTS", xn = "LOAD_ROOT_OPTIONS", Rn = "LOAD_CHILDREN_OPTIONS", An = "ASYNC_SEARCH", X = "ALL", W = "BRANCH_PRIORITY", G = "LEAF_PRIORITY", J = "ALL_WITH_INDETERMINATE", Oe = "ORDER_SELECTED", ye = "LEVEL", _e = "INDEX", g = {
308
308
  BACKSPACE: 8,
309
309
  ENTER: 13,
310
310
  ESCAPE: 27,
@@ -334,7 +334,7 @@ function ke(e, t) {
334
334
  function $n(e, t) {
335
335
  return e.level === t.level ? ke(e, t) : e.level - t.level;
336
336
  }
337
- function J() {
337
+ function Z() {
338
338
  return {
339
339
  isLoaded: !1,
340
340
  isLoading: !1,
@@ -347,7 +347,7 @@ function Vn(e) {
347
347
  function we(e, t, n) {
348
348
  return e ? Xe(t, n) : _(n, t);
349
349
  }
350
- function Z(e) {
350
+ function H(e) {
351
351
  return e.message || /* istanbul ignore next */
352
352
  String(e);
353
353
  }
@@ -842,7 +842,7 @@ const zn = {
842
842
  type: String,
843
843
  default: W,
844
844
  validator(e) {
845
- return _([Y, W, X, G], e);
845
+ return _([X, W, G, J], e);
846
846
  }
847
847
  },
848
848
  /**
@@ -896,7 +896,7 @@ const zn = {
896
896
  selectedNodeMap: S()
897
897
  },
898
898
  // States of root options.
899
- rootOptionsStates: J(),
899
+ rootOptionsStates: Z(),
900
900
  localSearch: {
901
901
  // Has user entered any query to search local options?
902
902
  active: !1,
@@ -924,19 +924,19 @@ const zn = {
924
924
  */
925
925
  internalValue() {
926
926
  let e;
927
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === Y)
927
+ if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === X)
928
928
  e = this.forest.selectedNodeIds.slice();
929
929
  else if (this.valueConsistsOf === W)
930
930
  e = this.forest.selectedNodeIds.filter((t) => {
931
931
  const n = this.getNode(t);
932
932
  return n.isRootNode ? !0 : !this.isSelected(n.parentNode);
933
933
  });
934
- else if (this.valueConsistsOf === X)
934
+ else if (this.valueConsistsOf === G)
935
935
  e = this.forest.selectedNodeIds.filter((t) => {
936
936
  const n = this.getNode(t);
937
937
  return n.isLeaf ? !0 : n.children.length === 0;
938
938
  });
939
- else if (this.valueConsistsOf === G) {
939
+ else if (this.valueConsistsOf === J) {
940
940
  const t = [];
941
941
  e = this.forest.selectedNodeIds.slice(), this.selectedNodes.forEach((n) => {
942
942
  n.ancestors.forEach((s) => {
@@ -1015,7 +1015,7 @@ const zn = {
1015
1015
  this.initialize();
1016
1016
  },
1017
1017
  internalValue(e, t) {
1018
- q(e, t) && (this.$emit("update:modelValue", this.getValue(), this.getInstanceId()), this.$emit("input", this.getValue(), this.getInstanceId()), this.$emit("updated", this.getValue(), this.getInstanceId()));
1018
+ Y(e, t) && (this.$emit("update:modelValue", this.getValue(), this.getInstanceId()), this.$emit("input", this.getValue(), this.getInstanceId()), this.$emit("updated", this.getValue(), this.getInstanceId()));
1019
1019
  },
1020
1020
  matchKeys() {
1021
1021
  this.initialize();
@@ -1035,7 +1035,7 @@ const zn = {
1035
1035
  },
1036
1036
  value() {
1037
1037
  const e = this.extractCheckedNodeIdsFromValue();
1038
- q(e, this.internalValue) && this.fixSelectedNodeIds(e);
1038
+ Y(e, this.internalValue) && this.fixSelectedNodeIds(e);
1039
1039
  }
1040
1040
  },
1041
1041
  methods: {
@@ -1121,7 +1121,7 @@ const zn = {
1121
1121
  },
1122
1122
  fixSelectedNodeIds(e) {
1123
1123
  let t = [];
1124
- if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === Y)
1124
+ if (this.single || this.flat || this.disableBranchNodes || this.valueConsistsOf === X)
1125
1125
  t = e;
1126
1126
  else if (this.valueConsistsOf === W)
1127
1127
  e.forEach((s) => {
@@ -1131,13 +1131,13 @@ const zn = {
1131
1131
  t.push(o.id);
1132
1132
  });
1133
1133
  });
1134
- else if (this.valueConsistsOf === X) {
1134
+ else if (this.valueConsistsOf === G) {
1135
1135
  const s = S(), i = e.slice();
1136
1136
  for (; i.length; ) {
1137
1137
  const o = i.shift(), a = this.getNode(o);
1138
1138
  t.push(o), !a.isRootNode && (a.parentNode.id in s || (s[a.parentNode.id] = a.parentNode.children.length), --s[a.parentNode.id] === 0 && i.push(a.parentNode.id));
1139
1139
  }
1140
- } else if (this.valueConsistsOf === G) {
1140
+ } else if (this.valueConsistsOf === J) {
1141
1141
  const s = S(), i = e.filter((o) => {
1142
1142
  const a = this.getNode(o);
1143
1143
  return a.isLeaf || a.children.length === 0;
@@ -1147,7 +1147,7 @@ const zn = {
1147
1147
  t.push(o), !a.isRootNode && (a.parentNode.id in s || (s[a.parentNode.id] = a.parentNode.children.length), --s[a.parentNode.id] === 0 && i.push(a.parentNode.id));
1148
1148
  }
1149
1149
  }
1150
- q(this.forest.selectedNodeIds, t) && (this.forest.selectedNodeIds = t), this.buildForestState();
1150
+ Y(this.forest.selectedNodeIds, t) && (this.forest.selectedNodeIds = t), this.buildForestState();
1151
1151
  },
1152
1152
  keepDataOfSelectedNodes(e) {
1153
1153
  this.forest.selectedNodeIds.forEach((t) => {
@@ -1244,22 +1244,22 @@ const zn = {
1244
1244
  return t.isLoading;
1245
1245
  },
1246
1246
  start: () => {
1247
- t.isLoading = !0, t.isLoaded = !1, t.loadingError = "";
1247
+ t.isLoading = !0, t.isLoaded = !1, t.loadingError = "", this.rootOptionsStates.isLoading = !0, this.rootOptionsStates.isLoaded = !1, this.rootOptionsStates.loadingError = "";
1248
1248
  },
1249
1249
  succeed: (s) => {
1250
- t.isLoaded = !0, t.options = s, this.trigger.searchQuery === e && n();
1250
+ t.isLoaded = !0, t.options = Array.isArray(s) ? s : s || [], this.rootOptionsStates.isLoaded = !0, this.trigger.searchQuery === e && n();
1251
1251
  },
1252
1252
  fail: (s) => {
1253
- t.loadingError = Z(s);
1253
+ t.loadingError = H(s), this.rootOptionsStates.loadingError = H(s);
1254
1254
  },
1255
1255
  end: () => {
1256
- t.isLoading = !1;
1256
+ t.isLoading = !1, this.rootOptionsStates.isLoading = !1;
1257
1257
  }
1258
1258
  });
1259
1259
  },
1260
1260
  getRemoteSearchEntry() {
1261
1261
  const { searchQuery: e } = this.trigger, t = this.remoteSearch[e] || {
1262
- ...J(),
1262
+ ...Z(),
1263
1263
  options: []
1264
1264
  };
1265
1265
  if (this.$watch(
@@ -1372,12 +1372,12 @@ const zn = {
1372
1372
  const { id: c, label: d, children: f, isDefaultExpanded: m } = i, p = e === E, v = p ? 0 : e.level + 1, N = Array.isArray(f) || f === null, I = !N, k = !!i.isDisabled || !this.flat && !p && e.isDisabled, z = !!i.isUnselectable, L = !!i.isNew, M = this.matchKeys.reduce((h, u) => ({
1373
1373
  ...h,
1374
1374
  [u]: Vn(i[u]).toLocaleLowerCase()
1375
- }), {}), U = p ? M.label : e.nestedSearchLabel + " " + M.label;
1375
+ }), {}), Q = p ? M.label : e.nestedSearchLabel + " " + M.label;
1376
1376
  this.forest.nodeMap[c] = S();
1377
1377
  const l = this.forest.nodeMap[c];
1378
- if (l.id = c, l.label = d, l.level = v, l.ancestors = p ? [] : [e].concat(e.ancestors), l.index = (p ? [] : e.index).concat(a), l.parentNode = e, l.lowerCased = M, l.nestedSearchLabel = U, l.isDisabled = k, l.isUnselectable = z, l.isNew = L, l.isMatched = !1, l.isHighlighted = !1, l.isBranch = N, l.isLeaf = I, l.isRootNode = p, l.raw = o, N) {
1378
+ if (l.id = c, l.label = d, l.level = v, l.ancestors = p ? [] : [e].concat(e.ancestors), l.index = (p ? [] : e.index).concat(a), l.parentNode = e, l.lowerCased = M, l.nestedSearchLabel = Q, l.isDisabled = k, l.isUnselectable = z, l.isNew = L, l.isMatched = !1, l.isHighlighted = !1, l.isBranch = N, l.isLeaf = I, l.isRootNode = p, l.raw = o, N) {
1379
1379
  const h = Array.isArray(f);
1380
- l.childrenStates = { ...J(), isLoaded: h }, l.isExpanded = typeof m == "boolean" ? m : v < this.defaultExpandLevel, l.hasMatchedDescendants = !1, l.hasDisabledDescendants = !1, l.isExpandedOnSearch = !1, l.showAllChildrenOnSearch = !1, l.count = {
1380
+ l.childrenStates = { ...Z(), isLoaded: h }, l.isExpanded = typeof m == "boolean" ? m : v < this.defaultExpandLevel, l.hasMatchedDescendants = !1, l.hasDisabledDescendants = !1, l.isExpandedOnSearch = !1, l.showAllChildrenOnSearch = !1, l.count = {
1381
1381
  [T]: 0,
1382
1382
  [R]: 0,
1383
1383
  [A]: 0,
@@ -1414,7 +1414,7 @@ const zn = {
1414
1414
  });
1415
1415
  },
1416
1416
  fail: (e) => {
1417
- this.rootOptionsStates.loadingError = Z(e);
1417
+ this.rootOptionsStates.loadingError = H(e);
1418
1418
  },
1419
1419
  end: () => {
1420
1420
  this.rootOptionsStates.isLoading = !1;
@@ -1440,7 +1440,7 @@ const zn = {
1440
1440
  this.getNode(t).childrenStates.isLoaded = !0;
1441
1441
  },
1442
1442
  fail: (s) => {
1443
- this.getNode(t).childrenStates.loadingError = Z(s);
1443
+ this.getNode(t).childrenStates.loadingError = H(s);
1444
1444
  },
1445
1445
  end: () => {
1446
1446
  this.getNode(t).childrenStates.isLoading = !1;
@@ -1836,7 +1836,7 @@ const Wn = {
1836
1836
  viewBox: "0 0 348.333 348.333"
1837
1837
  };
1838
1838
  function Qn(e, t, n, s, i, o) {
1839
- return V(), j("svg", Un, t[0] || (t[0] = [
1839
+ return V(), U("svg", Un, t[0] || (t[0] = [
1840
1840
  $("path", { d: "M336.559 68.611L231.016 174.165l105.543 105.549c15.699 15.705 15.699 41.145 0 56.85-7.844 7.844-18.128 11.769-28.407 11.769-10.296 0-20.581-3.919-28.419-11.769L174.167 231.003 68.609 336.563c-7.843 7.844-18.128 11.769-28.416 11.769-10.285 0-20.563-3.919-28.413-11.769-15.699-15.698-15.699-41.139 0-56.85l105.54-105.549L11.774 68.611c-15.699-15.699-15.699-41.145 0-56.844 15.696-15.687 41.127-15.687 56.829 0l105.563 105.554L279.721 11.767c15.705-15.687 41.139-15.687 56.832 0 15.705 15.699 15.705 41.145.006 56.844z" }, null, -1)
1841
1841
  ]));
1842
1842
  }
@@ -1926,7 +1926,7 @@ const We = /* @__PURE__ */ ae(jn, [["render", Qn]]), Kn = {
1926
1926
  viewBox: "0 0 292.362 292.362"
1927
1927
  };
1928
1928
  function Gn(e, t, n, s, i, o) {
1929
- return V(), j("svg", Xn, t[0] || (t[0] = [
1929
+ return V(), U("svg", Xn, t[0] || (t[0] = [
1930
1930
  $("path", { d: "M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z" }, null, -1)
1931
1931
  ]));
1932
1932
  }
@@ -2043,7 +2043,7 @@ const He = /* @__PURE__ */ ae(Yn, [["render", Gn]]), Jn = {
2043
2043
  }
2044
2044
  },
2045
2045
  setup(e) {
2046
- return (t, n) => (V(), j("div", {
2046
+ return (t, n) => (V(), U("div", {
2047
2047
  class: se(`vue-treeselect__tip vue-treeselect__${e.type}-tip`)
2048
2048
  }, [
2049
2049
  $("div", Zn, [
@@ -2132,7 +2132,7 @@ const ts = {
2132
2132
  /*node.isLeaf && */
2133
2133
  e.hasBranchNodes ? (ee || (ee = r("div", {
2134
2134
  class: "vue-treeselect__option-arrow-placeholder"
2135
- }, [Q(" ")])), ee) : null
2135
+ }, [K(" ")])), ee) : null
2136
2136
  );
2137
2137
  },
2138
2138
  renderLabelContainer(e) {
@@ -2185,13 +2185,13 @@ const ts = {
2185
2185
  class: i
2186
2186
  }, [t.label, n && r("span", {
2187
2187
  class: o
2188
- }, [Q("("), s, Q(")")])]);
2188
+ }, [K("("), s, K(")")])]);
2189
2189
  },
2190
2190
  renderSubOptions() {
2191
2191
  const {
2192
2192
  node: e
2193
2193
  } = this;
2194
- return e.childrenStates.isLoaded ? e.children.map((t) => r(H("vue-treeselect--option"), {
2194
+ return e.childrenStates.isLoaded ? e.children.map((t) => r(P("vue-treeselect--option"), {
2195
2195
  node: t,
2196
2196
  key: t.id
2197
2197
  }, null)) : null;
@@ -2375,7 +2375,7 @@ const ts = {
2375
2375
  const {
2376
2376
  instance: e
2377
2377
  } = this, t = e.getRemoteSearchEntry(), n = e.trigger.searchQuery === "" && !e.defaultOptions, s = n ? !1 : t.isLoaded && t.options.length === 0;
2378
- return n ? this.renderSearchPromptTip() : t.isLoading ? this.renderLoadingOptionsTip() : t.loadingError ? this.renderAsyncSearchLoadingErrorTip() : s ? this.renderNoResultsTip() : this.renderOptionList();
2378
+ return n ? this.renderSearchPromptTip() : e.rootOptionsStates.isLoading ? this.renderLoadingOptionsTip() : e.rootOptionsStates.loadingError ? this.renderAsyncSearchLoadingErrorTip() : s ? this.renderNoResultsTip() : this.renderOptionList();
2379
2379
  },
2380
2380
  renderOptionList() {
2381
2381
  const {
@@ -2582,8 +2582,8 @@ const ts = {
2582
2582
  }
2583
2583
  });
2584
2584
  function rs(e, t, n, s, i, o) {
2585
- const a = H("HiddenFields"), c = H("Control"), d = H("Menu");
2586
- return V(), j("div", {
2585
+ const a = P("HiddenFields"), c = P("Control"), d = P("Menu");
2586
+ return V(), U("div", {
2587
2587
  ref: "wrapper",
2588
2588
  class: se(e.wrapperClass)
2589
2589
  }, [
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vitorfba/vue-treeselect",
3
3
  "author": "vitorfba",
4
4
  "license": "MIT",
5
- "version": "1.0.1",
5
+ "version": "1.0.3",
6
6
  "description": "Tree select hierarchical component for vue 3 (compat).",
7
7
  "type": "module",
8
8
  "exports": {