vue-devui 1.0.0-rc.11 → 1.0.0-rc.14

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.
Files changed (115) hide show
  1. package/README.md +160 -149
  2. package/auto-complete/index.es.js +182 -10
  3. package/auto-complete/index.umd.js +18 -18
  4. package/auto-complete/style.css +1 -1
  5. package/badge/index.es.js +3 -1
  6. package/badge/index.umd.js +1 -1
  7. package/button/index.es.js +5 -3
  8. package/button/index.umd.js +6 -6
  9. package/button/style.css +1 -1
  10. package/checkbox/index.es.js +1 -1
  11. package/checkbox/index.umd.js +4 -4
  12. package/checkbox/style.css +1 -1
  13. package/collapse/index.es.js +20 -186
  14. package/collapse/index.umd.js +1 -1
  15. package/collapse/style.css +1 -1
  16. package/countdown/index.es.js +56 -13
  17. package/countdown/index.umd.js +1 -1
  18. package/{date-picker → date-picker-pro}/index.d.ts +0 -0
  19. package/date-picker-pro/index.es.js +12016 -0
  20. package/date-picker-pro/index.umd.js +27 -0
  21. package/date-picker-pro/package.json +7 -0
  22. package/date-picker-pro/style.css +1 -0
  23. package/dropdown/index.es.js +9 -2
  24. package/dropdown/index.umd.js +1 -1
  25. package/editable-select/index.es.js +248 -56
  26. package/editable-select/index.umd.js +1 -1
  27. package/editable-select/style.css +1 -1
  28. package/form/index.es.js +1 -1
  29. package/form/index.umd.js +4 -4
  30. package/icon/index.es.js +5 -3
  31. package/icon/index.umd.js +1 -1
  32. package/icon/style.css +1 -1
  33. package/image-preview/style.css +1 -1
  34. package/input/index.es.js +193 -15
  35. package/input/index.umd.js +14 -14
  36. package/input/style.css +1 -1
  37. package/input-number/index.es.js +1 -4
  38. package/input-number/index.umd.js +1 -1
  39. package/layout/index.es.js +1 -1
  40. package/layout/index.umd.js +1 -1
  41. package/modal/index.es.js +5 -3
  42. package/modal/index.umd.js +1 -1
  43. package/modal/style.css +1 -1
  44. package/notification/index.es.js +32 -34
  45. package/notification/index.umd.js +1 -1
  46. package/notification/style.css +1 -1
  47. package/nuxt/components/DRangeDatePickerPro.js +3 -0
  48. package/nuxt/components/DatePickerPro.js +3 -0
  49. package/nuxt/components/OptionGroup.js +3 -0
  50. package/nuxt/components/Step.js +3 -0
  51. package/nuxt/components/Steps.js +3 -0
  52. package/nuxt/components/TimePicker.js +3 -0
  53. package/nuxt/components/datePickerProCommonProps.js +3 -0
  54. package/nuxt/components/datePickerProPanelProps.js +3 -0
  55. package/nuxt/components/datePickerProProps.js +3 -0
  56. package/nuxt/components/stepProps.js +3 -0
  57. package/nuxt/components/stepsProps.js +3 -0
  58. package/nuxt/components/timerPickerPanelProps.js +3 -0
  59. package/package.json +1 -1
  60. package/pagination/index.es.js +175 -7
  61. package/pagination/index.umd.js +1 -1
  62. package/radio/index.es.js +1 -1
  63. package/radio/index.umd.js +4 -4
  64. package/result/index.es.js +5 -3
  65. package/result/index.umd.js +1 -1
  66. package/result/style.css +1 -1
  67. package/search/index.es.js +198 -18
  68. package/search/index.umd.js +13 -13
  69. package/search/style.css +1 -1
  70. package/select/index.es.js +382 -258
  71. package/select/index.umd.js +15 -15
  72. package/select/style.css +1 -1
  73. package/splitter/index.es.js +182 -12
  74. package/splitter/index.umd.js +13 -13
  75. package/steps/index.d.ts +7 -0
  76. package/steps/index.es.js +386 -0
  77. package/steps/index.umd.js +1 -0
  78. package/{date-picker → steps}/package.json +1 -1
  79. package/steps/style.css +1 -0
  80. package/style.css +1 -1
  81. package/switch/index.es.js +1 -1
  82. package/switch/index.umd.js +4 -4
  83. package/table/index.es.js +851 -294
  84. package/table/index.umd.js +16 -16
  85. package/table/style.css +1 -1
  86. package/tabs/index.es.js +22 -12
  87. package/tabs/index.umd.js +1 -1
  88. package/tabs/style.css +1 -1
  89. package/textarea/index.es.js +3 -2
  90. package/textarea/index.umd.js +6 -6
  91. package/time-picker/index.d.ts +7 -0
  92. package/{date-picker → time-picker}/index.es.js +1537 -1040
  93. package/time-picker/index.umd.js +27 -0
  94. package/time-picker/package.json +7 -0
  95. package/time-picker/style.css +1 -0
  96. package/time-select/index.es.js +383 -258
  97. package/time-select/index.umd.js +16 -16
  98. package/time-select/style.css +1 -1
  99. package/timeline/index.es.js +5 -3
  100. package/timeline/index.umd.js +1 -1
  101. package/timeline/style.css +1 -1
  102. package/tooltip/index.es.js +1 -1
  103. package/tooltip/index.umd.js +1 -1
  104. package/tree/index.es.js +551 -88
  105. package/tree/index.umd.js +15 -15
  106. package/tree/style.css +1 -1
  107. package/upload/index.es.js +230 -57
  108. package/upload/index.umd.js +1 -1
  109. package/upload/style.css +1 -1
  110. package/vue-devui.es.js +14310 -11217
  111. package/vue-devui.umd.js +23 -23
  112. package/date-picker/index.umd.js +0 -27
  113. package/date-picker/style.css +0 -1
  114. package/nuxt/components/DatePicker.js +0 -3
  115. package/nuxt/components/StickSlider.js +0 -3
package/tree/index.es.js CHANGED
@@ -29,9 +29,10 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { createVNode, defineComponent, toRefs, inject, watch, provide, reactive, onUnmounted, Transition, mergeProps, ref, unref, nextTick, Comment, Text, h, Fragment, withDirectives, cloneVNode, computed, onMounted, Teleport, createTextVNode, onBeforeUnmount, toRef, renderSlot, useSlots, isVNode, getCurrentInstance, onUpdated, shallowRef, toRaw, watchEffect } from "vue";
32
+ import { createVNode, defineComponent, toRefs, inject, ref, reactive, getCurrentInstance, watch, provide, onUnmounted, Transition, mergeProps, unref, nextTick, Comment, Text, h, Fragment, withDirectives, cloneVNode, computed, onMounted, Teleport, createTextVNode, onBeforeUnmount, toRef, renderSlot, useSlots, resolveComponent, isVNode, onUpdated, shallowRef, toRaw, watchEffect } from "vue";
33
33
  import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
34
34
  const USE_TREE_TOKEN = "use-tree-token";
35
+ const TREE_INSTANCE = "tree-instance";
35
36
  const NODE_HEIGHT = 30;
36
37
  const NODE_INDENT = 24;
37
38
  const IconClose = () => createVNode("svg", {
@@ -141,6 +142,187 @@ var DTreeNodeToggle = defineComponent({
141
142
  };
142
143
  }
143
144
  });
145
+ function deepAssign(...objects) {
146
+ const isObject2 = (obj) => obj && typeof obj === "object";
147
+ return objects.reduce((prev, from) => {
148
+ Object.keys(from).forEach((key) => {
149
+ const pVal = prev[key];
150
+ const oVal = from[key];
151
+ if (Array.isArray(pVal) && Array.isArray(oVal)) {
152
+ prev[key] = Array.from(/* @__PURE__ */ new Set([...oVal, ...pVal]));
153
+ } else if (isObject2(pVal) && isObject2(oVal)) {
154
+ prev[key] = deepAssign(pVal, oVal);
155
+ } else {
156
+ prev[key] = oVal;
157
+ }
158
+ });
159
+ return prev;
160
+ }, {});
161
+ }
162
+ var zhCN = {
163
+ pagination: {
164
+ totalItemText: "\u6240\u6709\u6761\u76EE",
165
+ goToText: "\u8DF3\u81F3"
166
+ },
167
+ accordion: {
168
+ loading: "\u52A0\u8F7D\u4E2D",
169
+ noData: "\u6CA1\u6709\u6570\u636E"
170
+ },
171
+ autoCompleteDropdown: {
172
+ latestInput: "\u6700\u8FD1\u8F93\u5165"
173
+ },
174
+ cascaderList: {
175
+ noData: "\u6CA1\u6709\u6570\u636E"
176
+ },
177
+ colorPicker: {
178
+ foundationPanel: "\u57FA\u7840\u9762\u677F",
179
+ advancedPanel: "\u9AD8\u7EA7\u9762\u677F"
180
+ },
181
+ datePickerPro: {
182
+ ok: "\u786E\u5B9A",
183
+ placeholder: "\u8BF7\u9009\u62E9\u65E5\u671F",
184
+ month1: "1\u6708",
185
+ month2: "2\u6708",
186
+ month3: "3\u6708",
187
+ month4: "4\u6708",
188
+ month5: "5\u6708",
189
+ month6: "6\u6708",
190
+ month7: "7\u6708",
191
+ month8: "8\u6708",
192
+ month9: "9\u6708",
193
+ month10: "10\u6708",
194
+ month11: "11\u6708",
195
+ month12: "12\u6708",
196
+ year: "\u5E74",
197
+ startPlaceholder: "\u8BF7\u9009\u62E9\u5F00\u59CB\u65E5\u671F",
198
+ endPlaceholder: "\u8BF7\u9009\u62E9\u7ED3\u675F\u65E5\u671F",
199
+ getWeekDays() {
200
+ return ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"];
201
+ },
202
+ getTimeArr() {
203
+ return ["\u65F6", "\u5206", "\u79D2"];
204
+ },
205
+ getYearMonthStr(year, month) {
206
+ return `${year}\u5E74${month}\u6708`;
207
+ }
208
+ },
209
+ editableSelect: {
210
+ noRelatedRecords: "\u627E\u4E0D\u5230\u76F8\u5173\u8BB0\u5F55",
211
+ noData: "\u6CA1\u6709\u6570\u636E"
212
+ },
213
+ input: {
214
+ placeholder: "\u8BF7\u8F93\u5165"
215
+ },
216
+ splitterBar: {
217
+ collapse: "\u6536\u8D77",
218
+ expand: "\u5C55\u5F00"
219
+ },
220
+ stepsGuide: {
221
+ previous: "\u4E0A\u4E00\u6B65",
222
+ continue: "\u6211\u77E5\u9053\u5566\uFF0C\u7EE7\u7EED",
223
+ ok: "\u6211\u77E5\u9053\u5566"
224
+ },
225
+ table: {
226
+ selectAll: "\u5168\u9009",
227
+ ok: "\u786E\u5B9A"
228
+ },
229
+ timePopup: {
230
+ ok: "\u786E\u5B9A"
231
+ },
232
+ transfer: {
233
+ unit: "\u9879",
234
+ panelUnit: "\u9879",
235
+ headerUnit: "\u9879",
236
+ noData: "\u6682\u65E0\u6570\u636E",
237
+ placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22"
238
+ },
239
+ tree: {
240
+ loading: "\u52A0\u8F7D\u4E2D",
241
+ newNode: "\u65B0\u8282\u70B9",
242
+ selectPlaceholder: "\u8BF7\u9009\u62E9"
243
+ },
244
+ upload: {
245
+ placeholder: "\u9009\u62E9\u6587\u4EF6",
246
+ getExistSameNameFilesMsg(sameNames) {
247
+ return `\u60A8\u4E0A\u4F20\u7684 "${sameNames}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
248
+ },
249
+ getAllFilesBeyondMaximalFileSizeMsg(maximalSize) {
250
+ return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
251
+ },
252
+ getBeyondMaximalFileSizeMsg(filename, maximalSize) {
253
+ return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
254
+ },
255
+ getNotAllowedFileTypeMsg(filename, scope) {
256
+ return `\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${scope}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
257
+ }
258
+ },
259
+ search: {
260
+ placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u5B57"
261
+ },
262
+ select: {
263
+ placeholder: "\u8BF7\u9009\u62E9",
264
+ noDataText: "\u65E0\u6570\u636E",
265
+ noMatchText: "\u627E\u4E0D\u5230\u76F8\u5173\u8BB0\u5F55",
266
+ loadingText: "\u52A0\u8F7D\u4E2D..."
267
+ },
268
+ tagInput: {
269
+ maxTagsText: "\u5DF2\u8FBE\u5230\u6700\u5927\u4E2A\u6570\uFF1A"
270
+ },
271
+ timeSelect: {
272
+ placeholder: "\u8BF7\u9009\u62E9\u65F6\u95F4"
273
+ }
274
+ };
275
+ const lang = ref("zh-CN");
276
+ let langMessages = reactive({
277
+ [lang.value]: zhCN
278
+ });
279
+ const Locale = {
280
+ messages() {
281
+ return langMessages[lang.value];
282
+ },
283
+ lang() {
284
+ return lang.value;
285
+ },
286
+ use(newLang, newMessages2) {
287
+ lang.value = newLang;
288
+ this.add({ [newLang]: newMessages2 });
289
+ },
290
+ add(newMessages2 = {}) {
291
+ langMessages = deepAssign(langMessages, newMessages2);
292
+ }
293
+ };
294
+ const camelize = (name) => name.substring(1).replace(/^\S/, (s) => s.toLocaleLowerCase());
295
+ function get(object4, path) {
296
+ const keys = path.split(".");
297
+ let result = object4;
298
+ keys.forEach((key) => {
299
+ var _a;
300
+ result = (_a = result[key]) != null ? _a : "";
301
+ });
302
+ return result;
303
+ }
304
+ function createI18nTranslate(name, app, newPrefix) {
305
+ const prefix = newPrefix || camelize(name) + ".";
306
+ return (path) => {
307
+ var _a;
308
+ const messages2 = ((_a = app == null ? void 0 : app.appContext.config.globalProperties.langMessages) == null ? void 0 : _a.value) || Locale.messages();
309
+ const message = get(messages2, prefix + path) || get(messages2, path);
310
+ return message;
311
+ };
312
+ }
313
+ var DTreeNodeLoading = defineComponent({
314
+ name: "DTreeNodeLoading",
315
+ setup() {
316
+ const app = getCurrentInstance();
317
+ const t = createI18nTranslate("DTree", app);
318
+ const ns2 = useNamespace("loading-children ");
319
+ return () => {
320
+ return createVNode("span", {
321
+ "class": ns2.b()
322
+ }, [`${t("loading") || "Loading"}...`]);
323
+ };
324
+ }
325
+ });
144
326
  const commonProps = {
145
327
  name: {
146
328
  type: String,
@@ -1025,10 +1207,10 @@ var lodash = { exports: {} };
1025
1207
  }();
1026
1208
  var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
1027
1209
  var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
1028
- var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set = getNative(context, "Set"), WeakMap2 = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1210
+ var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap2 = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
1029
1211
  var metaMap = WeakMap2 && new WeakMap2();
1030
1212
  var realNames = {};
1031
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap2);
1213
+ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2);
1032
1214
  var symbolProto = Symbol2 ? Symbol2.prototype : undefined$1, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1, symbolToString = symbolProto ? symbolProto.toString : undefined$1;
1033
1215
  function lodash2(value) {
1034
1216
  if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
@@ -1384,7 +1566,7 @@ var lodash = { exports: {} };
1384
1566
  function baseAt(object4, paths) {
1385
1567
  var index2 = -1, length = paths.length, result2 = Array2(length), skip = object4 == null;
1386
1568
  while (++index2 < length) {
1387
- result2[index2] = skip ? undefined$1 : get(object4, paths[index2]);
1569
+ result2[index2] = skip ? undefined$1 : get2(object4, paths[index2]);
1388
1570
  }
1389
1571
  return result2;
1390
1572
  }
@@ -1829,7 +2011,7 @@ var lodash = { exports: {} };
1829
2011
  return matchesStrictComparable(toKey(path), srcValue);
1830
2012
  }
1831
2013
  return function(object4) {
1832
- var objValue = get(object4, path);
2014
+ var objValue = get2(object4, path);
1833
2015
  return objValue === undefined$1 && objValue === srcValue ? hasIn(object4, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1834
2016
  };
1835
2017
  }
@@ -2720,8 +2902,8 @@ var lodash = { exports: {} };
2720
2902
  return func(number4);
2721
2903
  };
2722
2904
  }
2723
- var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function(values2) {
2724
- return new Set(values2);
2905
+ var createSet = !(Set2 && 1 / setToArray(new Set2([, -0]))[1] == INFINITY) ? noop : function(values2) {
2906
+ return new Set2(values2);
2725
2907
  };
2726
2908
  function createToPairs(keysFunc) {
2727
2909
  return function(object4) {
@@ -3020,7 +3202,7 @@ var lodash = { exports: {} };
3020
3202
  return result2;
3021
3203
  };
3022
3204
  var getTag = baseGetTag;
3023
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) {
3205
+ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) {
3024
3206
  getTag = function(value) {
3025
3207
  var result2 = baseGetTag(value), Ctor = result2 == objectTag ? value.constructor : undefined$1, ctorString = Ctor ? toSource(Ctor) : "";
3026
3208
  if (ctorString) {
@@ -4562,7 +4744,7 @@ var lodash = { exports: {} };
4562
4744
  function functionsIn(object4) {
4563
4745
  return object4 == null ? [] : baseFunctions(object4, keysIn(object4));
4564
4746
  }
4565
- function get(object4, path, defaultValue) {
4747
+ function get2(object4, path, defaultValue) {
4566
4748
  var result2 = object4 == null ? undefined$1 : baseGet(object4, path);
4567
4749
  return result2 === undefined$1 ? defaultValue : result2;
4568
4750
  }
@@ -5417,7 +5599,7 @@ var lodash = { exports: {} };
5417
5599
  lodash2.forInRight = forInRight;
5418
5600
  lodash2.forOwn = forOwn;
5419
5601
  lodash2.forOwnRight = forOwnRight;
5420
- lodash2.get = get;
5602
+ lodash2.get = get2;
5421
5603
  lodash2.gt = gt;
5422
5604
  lodash2.gte = gte;
5423
5605
  lodash2.has = has;
@@ -7742,7 +7924,7 @@ function useFormItemValidate(props, _rules) {
7742
7924
  return rule.trigger === triggerVal;
7743
7925
  }
7744
7926
  }).map((_a) => {
7745
- var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
7927
+ var rule = __objRest(_a, []);
7746
7928
  return rule;
7747
7929
  });
7748
7930
  };
@@ -8282,9 +8464,9 @@ function useTreeNode(data) {
8282
8464
  if (!data.value || data.value.level === 1) {
8283
8465
  return [];
8284
8466
  }
8285
- const { currentIndex = 0, parentChildNode = 0, level, expanded, isLeaf } = data.value;
8467
+ const { currentIndex = 0, parentChildNodeCount = 0, level, expanded, isLeaf } = data.value;
8286
8468
  return Array.from({ length: data.value.level - 1 }).map((_, index2) => ({
8287
- height: `${currentIndex + 1 === parentChildNode && index2 === 0 ? isLeaf || !expanded ? NODE_HEIGHT / 2 : NODE_HEIGHT : NODE_HEIGHT}px`,
8469
+ height: `${currentIndex + 1 === parentChildNodeCount && index2 === 0 ? isLeaf || !expanded ? NODE_HEIGHT / 2 : NODE_HEIGHT : NODE_HEIGHT}px`,
8288
8470
  left: `${NODE_INDENT * (level - index2 - 2) + 9}px`,
8289
8471
  top: `0px`
8290
8472
  }));
@@ -8301,6 +8483,16 @@ function useTreeNode(data) {
8301
8483
  var _a;
8302
8484
  return [ns.e("node-title"), ((_a = data.value) == null ? void 0 : _a.disableSelect) && "select-disabled"];
8303
8485
  });
8486
+ const nodeOperationAreaClass = computed(() => ns.e("node-operation-area"));
8487
+ const matchedContents = computed(() => {
8488
+ var _a, _b;
8489
+ const matchItem = ((_a = data.value) == null ? void 0 : _a.matchedText) || "";
8490
+ const label = ((_b = data.value) == null ? void 0 : _b.label) || "";
8491
+ const reg = (str) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
8492
+ const regExp = new RegExp("(" + reg(matchItem) + ")", "gi");
8493
+ return label.split(regExp);
8494
+ });
8495
+ const highlightCls = ns.e("match-highlight");
8304
8496
  return {
8305
8497
  nodeClass,
8306
8498
  nodeStyle,
@@ -8308,7 +8500,10 @@ function useTreeNode(data) {
8308
8500
  nodeTitleClass,
8309
8501
  nodeVLineClass,
8310
8502
  nodeVLineStyles,
8311
- nodeHLineClass
8503
+ nodeHLineClass,
8504
+ nodeOperationAreaClass,
8505
+ matchedContents,
8506
+ highlightCls
8312
8507
  };
8313
8508
  }
8314
8509
  var DTreeNodeContent = defineComponent({
@@ -8324,16 +8519,23 @@ var DTreeNodeContent = defineComponent({
8324
8519
  data
8325
8520
  } = toRefs(props);
8326
8521
  const {
8327
- nodeTitleClass
8522
+ nodeTitleClass,
8523
+ matchedContents,
8524
+ highlightCls
8328
8525
  } = useTreeNode(data);
8329
8526
  return () => {
8330
- var _a;
8527
+ var _a, _b, _c;
8331
8528
  return createVNode("span", {
8332
8529
  "class": nodeTitleClass.value
8333
- }, [(_a = data.value) == null ? void 0 : _a.label]);
8530
+ }, [!((_a = data.value) == null ? void 0 : _a.matchedText) && ((_b = data.value) == null ? void 0 : _b.label), ((_c = data.value) == null ? void 0 : _c.matchedText) && matchedContents.value.map((item, index2) => index2 % 2 === 0 ? item : createVNode("span", {
8531
+ "class": highlightCls
8532
+ }, [item]))]);
8334
8533
  };
8335
8534
  }
8336
8535
  });
8536
+ const formatCheckStatus = (check) => {
8537
+ return typeof check === "boolean" ? check ? "both" : "none" : check;
8538
+ };
8337
8539
  var DTreeNode = defineComponent({
8338
8540
  name: "DTreeNode",
8339
8541
  props: {
@@ -8342,23 +8544,34 @@ var DTreeNode = defineComponent({
8342
8544
  default: () => ({})
8343
8545
  },
8344
8546
  check: {
8345
- type: Boolean,
8547
+ type: [Boolean, String],
8548
+ default: false
8549
+ },
8550
+ operate: {
8551
+ type: [Boolean, String, Array],
8346
8552
  default: false
8347
8553
  }
8348
8554
  },
8349
8555
  setup(props, {
8350
8556
  slots
8351
8557
  }) {
8558
+ const app = getCurrentInstance();
8559
+ const t = createI18nTranslate("DTree", app);
8352
8560
  const {
8353
8561
  data,
8354
- check
8562
+ check,
8563
+ operate
8355
8564
  } = toRefs(props);
8356
8565
  const {
8357
8566
  toggleSelectNode,
8358
8567
  toggleCheckNode,
8359
8568
  toggleNode,
8360
- getChildren
8569
+ getChildren,
8570
+ insertBefore,
8571
+ removeNode,
8572
+ getNode
8361
8573
  } = inject(USE_TREE_TOKEN);
8574
+ const treeInstance = inject(TREE_INSTANCE);
8362
8575
  const ns2 = useNamespace("tree");
8363
8576
  const {
8364
8577
  nodeClass,
@@ -8366,23 +8579,29 @@ var DTreeNode = defineComponent({
8366
8579
  nodeContentClass,
8367
8580
  nodeVLineClass,
8368
8581
  nodeVLineStyles,
8369
- nodeHLineClass
8582
+ nodeHLineClass,
8583
+ nodeOperationAreaClass
8370
8584
  } = useTreeNode(data);
8371
8585
  const halfChecked = computed(() => {
8372
- const children = getChildren == null ? void 0 : getChildren(data.value);
8373
- const checkedChildren = children == null ? void 0 : children.filter((item) => item.checked);
8374
- if (["upward", "both"].includes(check.value)) {
8586
+ var _a;
8587
+ if (!((_a = data.value) == null ? void 0 : _a.checked)) {
8588
+ return false;
8589
+ }
8590
+ const checkFormat = formatCheckStatus(check.value);
8591
+ if (["upward", "both"].includes(checkFormat)) {
8592
+ const children = (getChildren == null ? void 0 : getChildren(data.value)) || [];
8593
+ const checkedChildren = children == null ? void 0 : children.filter((item) => item.checked);
8375
8594
  return checkedChildren.length > 0 && checkedChildren.length < children.length;
8376
8595
  } else {
8377
8596
  return false;
8378
8597
  }
8379
8598
  });
8380
- return () => {
8599
+ const checkboxProps2 = computed(() => {
8381
8600
  var _a, _b, _c;
8382
- const checkboxProps2 = {
8601
+ return {
8383
8602
  key: (_a = data.value) == null ? void 0 : _a.id,
8384
8603
  disabled: (_b = data.value) == null ? void 0 : _b.disableCheck,
8385
- halfchecked: halfChecked.value,
8604
+ halfChecked: halfChecked.value,
8386
8605
  modelValue: (_c = data.value) == null ? void 0 : _c.checked,
8387
8606
  "onUpdate:modelValue": () => {
8388
8607
  toggleCheckNode == null ? void 0 : toggleCheckNode(data.value);
@@ -8391,9 +8610,21 @@ var DTreeNode = defineComponent({
8391
8610
  event.stopPropagation();
8392
8611
  }
8393
8612
  };
8613
+ });
8614
+ const isShowOperationArea = ref(false);
8615
+ const showOperationArea = () => {
8616
+ isShowOperationArea.value = true;
8617
+ };
8618
+ const hideOperationArea = () => {
8619
+ isShowOperationArea.value = false;
8620
+ };
8621
+ return () => {
8622
+ var _a;
8394
8623
  return createVNode("div", {
8395
8624
  "class": nodeClass.value,
8396
- "style": nodeStyle.value
8625
+ "style": nodeStyle.value,
8626
+ "onMouseenter": showOperationArea,
8627
+ "onMouseleave": hideOperationArea
8397
8628
  }, [nodeVLineStyles.value.map((item) => createVNode("span", {
8398
8629
  "class": nodeVLineClass.value,
8399
8630
  "style": item
@@ -8401,6 +8632,7 @@ var DTreeNode = defineComponent({
8401
8632
  "class": nodeContentClass.value,
8402
8633
  "onClick": () => {
8403
8634
  toggleSelectNode == null ? void 0 : toggleSelectNode(data.value);
8635
+ treeInstance.emit("node-click", data.value);
8404
8636
  }
8405
8637
  }, [createVNode("span", {
8406
8638
  "class": nodeHLineClass.value
@@ -8414,10 +8646,24 @@ var DTreeNode = defineComponent({
8414
8646
  "style": {
8415
8647
  height: `${NODE_HEIGHT}px`
8416
8648
  }
8417
- }, [check.value && createVNode(Checkbox, checkboxProps2, null), slots.default ? renderSlot(useSlots(), "default", {
8649
+ }, [check.value && createVNode(Checkbox, checkboxProps2.value, null), slots.default ? renderSlot(useSlots(), "default", {
8418
8650
  nodeData: data
8419
8651
  }) : createVNode(DTreeNodeContent, {
8420
8652
  "data": data.value
8653
+ }, null), ((_a = getNode == null ? void 0 : getNode(data.value)) == null ? void 0 : _a.loading) ? slots.loading ? renderSlot(useSlots(), "loading") : createVNode(DTreeNodeLoading, null, null) : ""]), operate.value && isShowOperationArea.value && createVNode("div", {
8654
+ "class": nodeOperationAreaClass.value
8655
+ }, [createVNode(resolveComponent("d-icon"), {
8656
+ "name": "add",
8657
+ "onClick": () => {
8658
+ insertBefore(data.value, {
8659
+ label: t("newNode") || "New node"
8660
+ });
8661
+ }
8662
+ }, null), createVNode(resolveComponent("d-icon"), {
8663
+ "name": "delete",
8664
+ "onClick": () => {
8665
+ removeNode(data.value);
8666
+ }
8421
8667
  }, null)])])]);
8422
8668
  };
8423
8669
  }
@@ -8845,6 +9091,8 @@ var ResizeObserverContainer = defineComponent({
8845
9091
  top: 0
8846
9092
  });
8847
9093
  }
9094
+ }, {
9095
+ immediate: true
8848
9096
  });
8849
9097
  return () => createVNode("div", {
8850
9098
  "style": outerStyle.value
@@ -9104,6 +9352,7 @@ const ScrollStyle = {
9104
9352
  overflowY: "auto",
9105
9353
  overflowAnchor: "none"
9106
9354
  };
9355
+ const DEFAULT_HEIGHT = 20;
9107
9356
  var VirtualList = defineComponent({
9108
9357
  name: "DVirtualList",
9109
9358
  props: virtualListProps,
@@ -9212,7 +9461,7 @@ var VirtualList = defineComponent({
9212
9461
  cacheHeight = heights.get(key);
9213
9462
  }
9214
9463
  if (cacheHeight === void 0) {
9215
- cacheHeight = props.itemHeight || 20;
9464
+ cacheHeight = props.itemHeight || DEFAULT_HEIGHT;
9216
9465
  }
9217
9466
  const currentItemBottom = itemTop + cacheHeight;
9218
9467
  if (startIndex === void 0 && currentItemBottom >= scrollTop) {
@@ -9346,6 +9595,11 @@ var VirtualList = defineComponent({
9346
9595
  }, {
9347
9596
  flush: "post"
9348
9597
  });
9598
+ ctx.expose({
9599
+ scrollTo(index2) {
9600
+ syncScrollTop(index2 * (props.itemHeight || DEFAULT_HEIGHT));
9601
+ }
9602
+ });
9349
9603
  return () => {
9350
9604
  const Component = props.component;
9351
9605
  return createVNode("div", {
@@ -9385,29 +9639,33 @@ var VirtualList = defineComponent({
9385
9639
  }
9386
9640
  });
9387
9641
  function useToggle() {
9388
- return function useToggle2(data, core) {
9642
+ return function useToggle2(data, core, context, lazyLode) {
9389
9643
  const { getNode, setNodeValue } = core;
9644
+ const { lazyLoadNodes } = lazyLode;
9390
9645
  const expandNode = (node) => {
9391
- if (node.disableToggle) {
9646
+ if (node.disableToggle || node.loading) {
9392
9647
  return;
9393
9648
  }
9394
9649
  setNodeValue(node, "expanded", true);
9650
+ context.emit("toggle-change", node);
9395
9651
  };
9396
9652
  const collapseNode = (node) => {
9397
- if (node.disableToggle) {
9653
+ if (node.disableToggle || node.loading) {
9398
9654
  return;
9399
9655
  }
9400
9656
  setNodeValue(node, "expanded", false);
9657
+ context.emit("toggle-change", node);
9401
9658
  };
9402
9659
  const toggleNode = (node) => {
9403
- if (node.disableToggle) {
9660
+ if (node.disableToggle || node.loading) {
9404
9661
  return;
9405
9662
  }
9406
9663
  if (getNode(node).expanded) {
9407
- setNodeValue(node, "expanded", false);
9664
+ collapseNode(node);
9408
9665
  } else {
9409
- setNodeValue(node, "expanded", true);
9666
+ expandNode(node);
9410
9667
  }
9668
+ lazyLoadNodes(node);
9411
9669
  };
9412
9670
  const expandAllNodes = () => {
9413
9671
  data.value.forEach((node) => {
@@ -9436,17 +9694,18 @@ function omit(obj, ...keys) {
9436
9694
  function generateInnerTree(tree2, key = "children", level = 0, path = []) {
9437
9695
  level++;
9438
9696
  return tree2.reduce((acc, item, currentIndex) => {
9439
- var _a, _b;
9697
+ var _a, _b, _c;
9440
9698
  const newItem = Object.assign({}, item);
9441
9699
  if (newItem.id === void 0) {
9442
9700
  newItem.id = randomId();
9443
9701
  newItem.idType = "random";
9444
9702
  }
9445
9703
  newItem.level = level;
9446
- newItem.parentChildNode = tree2.length;
9704
+ newItem.parentChildNodeCount = tree2.length;
9447
9705
  newItem.currentIndex = currentIndex;
9448
- if (path.length > 0 && ((_a = path[path.length - 1]) == null ? void 0 : _a.level) >= level) {
9449
- while (((_b = path[path.length - 1]) == null ? void 0 : _b.level) >= level) {
9706
+ newItem.childNodeCount = ((_a = newItem.children) == null ? void 0 : _a.length) || 0;
9707
+ if (path.length > 0 && ((_b = path[path.length - 1]) == null ? void 0 : _b.level) >= level) {
9708
+ while (((_c = path[path.length - 1]) == null ? void 0 : _c.level) >= level) {
9450
9709
  path.pop();
9451
9710
  }
9452
9711
  }
@@ -9456,7 +9715,7 @@ function generateInnerTree(tree2, key = "children", level = 0, path = []) {
9456
9715
  newItem.parentId = parentNode.id;
9457
9716
  }
9458
9717
  if (!newItem[key]) {
9459
- return acc.concat(__spreadProps(__spreadValues({}, newItem), { isLeaf: true }));
9718
+ return acc.concat(__spreadProps(__spreadValues({}, newItem), { isLeaf: newItem.isLeaf === false ? false : true }));
9460
9719
  } else {
9461
9720
  return acc.concat(omit(newItem, "children"), generateInnerTree(newItem[key], key, level, path));
9462
9721
  }
@@ -9466,11 +9725,12 @@ const DEFAULT_CONFIG = {
9466
9725
  expanded: false,
9467
9726
  recursive: true
9468
9727
  };
9728
+ const nodeMap = /* @__PURE__ */ new Map();
9469
9729
  function useCore() {
9470
- const nodeMap = /* @__PURE__ */ new Map();
9471
9730
  return function useCore2(data) {
9472
9731
  const getLevel = (node) => {
9473
- return data.value.find((item) => item.id === node.id).level;
9732
+ var _a;
9733
+ return (_a = data.value.find((item) => item.id === node.id)) == null ? void 0 : _a.level;
9474
9734
  };
9475
9735
  const getChildren = (node, userConfig = DEFAULT_CONFIG) => {
9476
9736
  if (node.isLeaf) {
@@ -9504,9 +9764,9 @@ function useCore() {
9504
9764
  const treeData = config.expanded ? getInnerExpendedTree() : data;
9505
9765
  const startIndex = treeData.value.findIndex((item) => item.id === node.id);
9506
9766
  for (let i = startIndex + 1; i < treeData.value.length && getLevel(node) < treeData.value[i].level; i++) {
9507
- if (config.recursive) {
9767
+ if (config.recursive && !treeData.value[i].isHide) {
9508
9768
  result.push(treeData.value[i]);
9509
- } else if (getLevel(node) === treeData.value[i].level - 1) {
9769
+ } else if (getLevel(node) === treeData.value[i].level - 1 && !treeData.value[i].isHide) {
9510
9770
  result.push(treeData.value[i]);
9511
9771
  }
9512
9772
  }
@@ -9515,6 +9775,9 @@ function useCore() {
9515
9775
  }
9516
9776
  return result;
9517
9777
  };
9778
+ const clearNodeMap = () => {
9779
+ nodeMap.clear();
9780
+ };
9518
9781
  const getParent = (node) => {
9519
9782
  return data.value.find((item) => item.id === node.parentId);
9520
9783
  };
@@ -9524,7 +9787,7 @@ function useCore() {
9524
9787
  const result = [];
9525
9788
  for (let i = 0, len = data == null ? void 0 : data.value.length; i < len; i++) {
9526
9789
  const item = data == null ? void 0 : data.value[i];
9527
- if (excludeNodes.map((node) => node.id).includes(item.id)) {
9790
+ if (excludeNodes.map((node) => node.id).includes(item.id) || item.isHide) {
9528
9791
  continue;
9529
9792
  }
9530
9793
  if (item.expanded !== true) {
@@ -9536,100 +9799,163 @@ function useCore() {
9536
9799
  });
9537
9800
  };
9538
9801
  const getIndex = (node) => {
9802
+ if (!node) {
9803
+ return -1;
9804
+ }
9539
9805
  return data.value.findIndex((item) => item.id === node.id);
9540
9806
  };
9541
9807
  const getNode = (node) => {
9542
9808
  return data.value.find((item) => item.id === node.id);
9543
9809
  };
9544
9810
  const setNodeValue = (node, key, value) => {
9545
- nodeMap.clear();
9546
- data.value[getIndex(node)][key] = value;
9811
+ clearNodeMap();
9812
+ if (getIndex(node) !== -1) {
9813
+ data.value[getIndex(node)][key] = value;
9814
+ }
9547
9815
  };
9548
9816
  const setTree = (newTree) => {
9549
- nodeMap.clear();
9817
+ clearNodeMap();
9550
9818
  data.value = generateInnerTree(newTree);
9551
9819
  };
9820
+ const getTree = () => {
9821
+ return data.value;
9822
+ };
9552
9823
  onUnmounted(() => {
9553
- nodeMap.clear();
9824
+ clearNodeMap();
9554
9825
  });
9555
9826
  return {
9556
9827
  getLevel,
9557
9828
  getChildren,
9829
+ clearNodeMap,
9558
9830
  getParent,
9559
9831
  getExpendedTree,
9560
9832
  getIndex,
9561
9833
  getNode,
9562
9834
  setNodeValue,
9563
- setTree
9835
+ setTree,
9836
+ getTree
9837
+ };
9838
+ };
9839
+ }
9840
+ function useLazyLoad() {
9841
+ return function useLazyLoad2(data, core, context) {
9842
+ const { getNode, setNodeValue, getIndex, getChildren } = core;
9843
+ const setCommonParent = (node, nodes) => {
9844
+ nodes.value.forEach((item) => {
9845
+ if (item.level - 1 === node.level && !item.parentId) {
9846
+ item.parentId = node.id;
9847
+ }
9848
+ });
9849
+ };
9850
+ const insertChildrenNodes = (parent, nodes) => {
9851
+ const parentIndex = getIndex(parent);
9852
+ if (parentIndex !== -1) {
9853
+ data.value.splice(parentIndex + 1, 0, ...nodes.value);
9854
+ }
9855
+ };
9856
+ const dealChildNodes = (result) => {
9857
+ const node = getNode(result.node);
9858
+ setNodeValue(node, "loading", false);
9859
+ const childNodes = ref(generateInnerTree(result.treeItems, "children", node.level));
9860
+ setCommonParent(node, childNodes);
9861
+ insertChildrenNodes(node, childNodes);
9862
+ const childrenNodes = getChildren(node);
9863
+ setNodeValue(node, "childNodeCount", childrenNodes.length);
9864
+ };
9865
+ const lazyLoadNodes = (node) => {
9866
+ const innerNode = getNode(node);
9867
+ if (!innerNode.isLeaf && !innerNode.childNodeCount) {
9868
+ setNodeValue(node, "loading", true);
9869
+ context.emit("lazy-load", node, dealChildNodes);
9870
+ }
9871
+ };
9872
+ return {
9873
+ lazyLoadNodes
9564
9874
  };
9565
9875
  };
9566
9876
  }
9567
9877
  const DEFAULT_TREE_PLUGINS = [useCore(), useToggle()];
9568
- function useTree(tree2, plugins = []) {
9878
+ function useTree(tree2, plugins = [], context) {
9569
9879
  const treeData = ref(generateInnerTree(tree2));
9570
9880
  const core = useCore()(treeData);
9881
+ const lazyLode = useLazyLoad()(treeData, core, context);
9571
9882
  const pluginMethods = DEFAULT_TREE_PLUGINS.concat(plugins).reduce((acc, plugin) => {
9572
- return __spreadValues(__spreadValues({}, acc), plugin(treeData, core));
9883
+ return __spreadValues(__spreadValues({}, acc), plugin(treeData, core, context, lazyLode));
9573
9884
  }, {});
9574
9885
  return __spreadValues({
9575
9886
  treeData
9576
9887
  }, pluginMethods);
9577
9888
  }
9578
9889
  function useCheck(options = ref({ checkStrategy: "both" })) {
9579
- return function useCheck2(data, core) {
9890
+ return function useCheck2(data, core, context) {
9580
9891
  const { setNodeValue, getNode, getChildren, getParent } = core;
9581
9892
  const checkNode = (node) => {
9582
9893
  setNodeValue(node, "checked", true);
9894
+ context.emit("check-change", node);
9583
9895
  };
9584
9896
  const uncheckNode = (node) => {
9585
9897
  setNodeValue(node, "checked", false);
9898
+ context.emit("check-change", node);
9586
9899
  };
9587
- const controlParentNodeChecked = (node) => {
9900
+ const controlParentNodeChecked = (node, checked) => {
9901
+ if (!node.parentId) {
9902
+ return;
9903
+ }
9588
9904
  const parentNode = getParent(node);
9589
9905
  if (!parentNode) {
9590
9906
  return;
9591
9907
  }
9592
- const siblingNodes = getChildren(parentNode, { recursive: false });
9593
- const checkedSiblingNodes = siblingNodes.filter((item) => item.checked);
9594
- const toggleParentChecked = () => {
9908
+ let childChecked = checked;
9909
+ if (checked) {
9910
+ if (!parentNode.checked) {
9911
+ setNodeValue(parentNode, "checked", true);
9912
+ }
9913
+ } else {
9914
+ const siblingNodes = getChildren(parentNode);
9915
+ const checkedSiblingNodes = siblingNodes.filter((item) => item.checked && item.id !== node.id);
9595
9916
  if (checkedSiblingNodes.length === 0) {
9596
9917
  setNodeValue(parentNode, "checked", false);
9597
- } else if (checkedSiblingNodes.length === siblingNodes.length) {
9918
+ } else {
9598
9919
  setNodeValue(parentNode, "checked", true);
9920
+ childChecked = true;
9599
9921
  }
9600
- };
9922
+ }
9601
9923
  if (parentNode.parentId) {
9602
- toggleParentChecked();
9603
- controlParentNodeChecked(parentNode);
9604
- } else {
9605
- toggleParentChecked();
9924
+ controlParentNodeChecked(parentNode, childChecked);
9606
9925
  }
9607
9926
  };
9608
9927
  const toggleCheckNode = (node) => {
9609
- if (getNode(node).checked) {
9928
+ const checked = getNode(node).checked;
9929
+ if (checked) {
9610
9930
  setNodeValue(node, "checked", false);
9931
+ context.emit("check-change", node);
9611
9932
  if (["downward", "both"].includes(options.value.checkStrategy)) {
9612
9933
  getChildren(node).forEach((item) => setNodeValue(item, "checked", false));
9613
9934
  }
9614
9935
  } else {
9615
9936
  setNodeValue(node, "checked", true);
9937
+ context.emit("check-change", node);
9616
9938
  if (["downward", "both"].includes(options.value.checkStrategy)) {
9617
9939
  getChildren(node).forEach((item) => setNodeValue(item, "checked", true));
9618
9940
  }
9619
9941
  }
9620
9942
  if (["upward", "both"].includes(options.value.checkStrategy)) {
9621
- controlParentNodeChecked(node);
9943
+ controlParentNodeChecked(node, !checked);
9622
9944
  }
9623
9945
  };
9946
+ const getCheckedNodes = () => {
9947
+ return data.value.filter((node) => node.checked);
9948
+ };
9624
9949
  return {
9625
9950
  checkNode,
9626
9951
  uncheckNode,
9627
- toggleCheckNode
9952
+ toggleCheckNode,
9953
+ getCheckedNodes
9628
9954
  };
9629
9955
  };
9630
9956
  }
9631
9957
  function useSelect() {
9632
- return function useSelect2(data, core) {
9958
+ return function useSelect2(data, core, context) {
9633
9959
  const { setNodeValue } = core;
9634
9960
  let prevActiveNode;
9635
9961
  const selectNode = (node) => {
@@ -9641,10 +9967,12 @@ function useSelect() {
9641
9967
  setNodeValue(data.value[prevActiveNodeIndex], "selected", false);
9642
9968
  }
9643
9969
  setNodeValue(node, "selected", true);
9970
+ context.emit("select-change", node);
9644
9971
  prevActiveNode = node;
9645
9972
  };
9646
9973
  const deselectNode = (node) => {
9647
9974
  setNodeValue(node, "selected", false);
9975
+ context.emit("select-change", node);
9648
9976
  };
9649
9977
  const toggleSelectNode = (node) => {
9650
9978
  if (node.selected) {
@@ -9653,10 +9981,14 @@ function useSelect() {
9653
9981
  selectNode(node);
9654
9982
  }
9655
9983
  };
9984
+ const getSelectedNode = () => {
9985
+ return data.value.find((node) => node.selected);
9986
+ };
9656
9987
  return {
9657
9988
  selectNode,
9658
9989
  deselectNode,
9659
- toggleSelectNode
9990
+ toggleSelectNode,
9991
+ getSelectedNode
9660
9992
  };
9661
9993
  };
9662
9994
  }
@@ -9664,7 +9996,9 @@ function useOperate() {
9664
9996
  return function useOperate2(data, core) {
9665
9997
  const { setNodeValue, getChildren, getIndex, getLevel } = core;
9666
9998
  const insertBefore = (parentNode, node, referenceNode) => {
9667
- const children = getChildren(parentNode);
9999
+ const children = getChildren(parentNode, {
10000
+ recursive: false
10001
+ });
9668
10002
  const lastChild = children[children.length - 1];
9669
10003
  let insertedIndex = getIndex(parentNode) + 1;
9670
10004
  if (referenceNode) {
@@ -9674,12 +10008,20 @@ function useOperate() {
9674
10008
  }
9675
10009
  setNodeValue(parentNode, "expanded", true);
9676
10010
  setNodeValue(parentNode, "isLeaf", false);
9677
- const currentNode = __spreadProps(__spreadValues({}, node), {
10011
+ if (lastChild) {
10012
+ setNodeValue(lastChild, "parentChildNodeCount", children.length + 1);
10013
+ }
10014
+ const currentNode = ref(__spreadProps(__spreadValues({}, node), {
9678
10015
  level: getLevel(parentNode) + 1,
9679
10016
  parentId: parentNode.id,
9680
- isLeaf: true
9681
- });
9682
- data.value = data.value.slice(0, insertedIndex).concat(currentNode, data.value.slice(insertedIndex, data.value.length));
10017
+ isLeaf: true,
10018
+ parentChildNodeCount: children.length + 1,
10019
+ currentIndex: (lastChild == null ? void 0 : lastChild.currentIndex) + 1
10020
+ }));
10021
+ if (currentNode.value.id === void 0) {
10022
+ currentNode.value.id = randomId();
10023
+ }
10024
+ data.value = data.value.slice(0, insertedIndex).concat(currentNode.value, data.value.slice(insertedIndex, data.value.length));
9683
10025
  };
9684
10026
  const removeNode = (node, config = { recursive: true }) => {
9685
10027
  if (!config.recursive) {
@@ -9740,6 +10082,111 @@ function useMergeNodes() {
9740
10082
  };
9741
10083
  };
9742
10084
  }
10085
+ function useSearchFilter() {
10086
+ return function useSearchFilter2(data, core) {
10087
+ const { clearNodeMap, getExpendedTree } = core;
10088
+ const virtualListRef = ref();
10089
+ const resetNodeSearchProperty = () => {
10090
+ data.value.forEach((item) => {
10091
+ item.childrenMatched = false;
10092
+ item.isHide = false;
10093
+ item.isMatched = false;
10094
+ item.matchedText = "";
10095
+ });
10096
+ if (virtualListRef.value) {
10097
+ virtualListRef.value.scrollTo(0);
10098
+ }
10099
+ };
10100
+ const hasDealParentNode = (pre, cur, parentIdSet) => {
10101
+ return data.value[pre].parentId === data.value[cur].parentId && data.value[pre].isMatched || parentIdSet.has(data.value[pre].id) && data.value[pre].childrenMatched;
10102
+ };
10103
+ const dealMatchedData = (target, matchKey, pattern4) => {
10104
+ const trimmedTarget = lodash.exports.trim(target).toLocaleLowerCase();
10105
+ for (let i = 0; i < data.value.length; i++) {
10106
+ const key = matchKey ? data.value[i][matchKey] : data.value[i].label;
10107
+ const selfMatched = pattern4 ? pattern4.test(key) : key.toLocaleLowerCase().includes(trimmedTarget);
10108
+ data.value[i].isMatched = selfMatched;
10109
+ if (selfMatched) {
10110
+ data.value[i].matchedText = matchKey ? data.value[i].label : trimmedTarget;
10111
+ if (!data.value[i].parentId) {
10112
+ continue;
10113
+ }
10114
+ let L = i - 1;
10115
+ const set = /* @__PURE__ */ new Set();
10116
+ set.add(data.value[i].parentId);
10117
+ while (L >= 0 && data.value[L].parentId && !hasDealParentNode(L, i, set)) {
10118
+ if (set.has(data.value[L].id)) {
10119
+ data.value[L].childrenMatched = true;
10120
+ data.value[L].expanded = true;
10121
+ set.add(data.value[L].parentId);
10122
+ }
10123
+ L--;
10124
+ }
10125
+ if (L >= 0 && !data.value[L].parentId && set.has(data.value[L].id)) {
10126
+ data.value[L].childrenMatched = true;
10127
+ data.value[L].expanded = true;
10128
+ }
10129
+ }
10130
+ }
10131
+ };
10132
+ const hasParentNodeMatched = (pre, cur, parentIdSet) => {
10133
+ return parentIdSet.has(data.value[pre].id) && data.value[pre].isMatched;
10134
+ };
10135
+ const dealNodeHideProperty = () => {
10136
+ data.value.forEach((item, index2) => {
10137
+ if (item.isMatched || item.childrenMatched) {
10138
+ item.isHide = false;
10139
+ } else {
10140
+ if (!item.parentId) {
10141
+ item.isHide = true;
10142
+ return;
10143
+ }
10144
+ let L = index2 - 1;
10145
+ const set = /* @__PURE__ */ new Set();
10146
+ set.add(data.value[index2].parentId);
10147
+ while (L >= 0 && data.value[L].parentId && !hasParentNodeMatched(L, index2, set)) {
10148
+ if (set.has(data.value[L].id)) {
10149
+ set.add(data.value[L].parentId);
10150
+ }
10151
+ L--;
10152
+ }
10153
+ if (!data.value[L].parentId && !data.value[L].isMatched) {
10154
+ item.isHide = true;
10155
+ } else {
10156
+ item.isHide = false;
10157
+ }
10158
+ }
10159
+ });
10160
+ };
10161
+ const getFirstMatchIndex = () => {
10162
+ let index2 = 0;
10163
+ const showTreeData = getExpendedTree().value;
10164
+ while (index2 <= showTreeData.length - 1 && !showTreeData[index2].isMatched) {
10165
+ index2++;
10166
+ }
10167
+ return index2 >= showTreeData.length ? 0 : index2;
10168
+ };
10169
+ const searchTree = (target, option) => {
10170
+ clearNodeMap();
10171
+ resetNodeSearchProperty();
10172
+ if (!target) {
10173
+ return;
10174
+ }
10175
+ dealMatchedData(target, option.matchKey, option.pattern);
10176
+ if (option.isFilter) {
10177
+ dealNodeHideProperty();
10178
+ }
10179
+ if (virtualListRef.value) {
10180
+ const scrollIndex = getFirstMatchIndex();
10181
+ virtualListRef.value.scrollTo(scrollIndex);
10182
+ }
10183
+ };
10184
+ return {
10185
+ virtualListRef,
10186
+ searchTree
10187
+ };
10188
+ };
10189
+ }
9743
10190
  const treeProps = {
9744
10191
  data: {
9745
10192
  type: Object,
@@ -9749,6 +10196,10 @@ const treeProps = {
9749
10196
  type: [Boolean, String],
9750
10197
  default: false
9751
10198
  },
10199
+ operate: {
10200
+ type: [Boolean, String, Array],
10201
+ default: false
10202
+ },
9752
10203
  height: {
9753
10204
  type: [Number, String]
9754
10205
  }
@@ -9757,33 +10208,40 @@ var tree = "";
9757
10208
  var Tree = defineComponent({
9758
10209
  name: "DTree",
9759
10210
  props: treeProps,
9760
- setup(props, {
9761
- slots,
9762
- expose
9763
- }) {
10211
+ emits: ["toggle-change", "check-change", "select-change", "node-click", "lazy-load"],
10212
+ setup(props, context) {
10213
+ const {
10214
+ slots,
10215
+ expose
10216
+ } = context;
10217
+ const treeInstance = getCurrentInstance();
9764
10218
  const {
9765
10219
  data,
9766
- check
10220
+ check,
10221
+ operate
9767
10222
  } = toRefs(props);
9768
10223
  const ns2 = useNamespace("tree");
9769
- const userPlugins = [useSelect(), useOperate(), useMergeNodes()];
10224
+ const normalRef = ref();
10225
+ const userPlugins = [useSelect(), useOperate(), useMergeNodes(), useSearchFilter()];
9770
10226
  const checkOptions = ref({
9771
- checkStrategy: check.value || "both"
10227
+ checkStrategy: formatCheckStatus(check.value)
9772
10228
  });
9773
10229
  watch(check, (newVal) => {
9774
- checkOptions.value.checkStrategy = newVal;
10230
+ checkOptions.value.checkStrategy = formatCheckStatus(newVal);
9775
10231
  });
9776
10232
  if (check.value) {
9777
10233
  userPlugins.push(useCheck(checkOptions));
9778
10234
  }
9779
- const treeFactory = useTree(data.value, userPlugins);
10235
+ const treeFactory = useTree(data.value, userPlugins, context);
9780
10236
  const {
9781
10237
  setTree,
9782
10238
  getExpendedTree,
9783
- toggleNode
10239
+ toggleNode,
10240
+ virtualListRef
9784
10241
  } = treeFactory;
9785
10242
  watch(data, setTree);
9786
10243
  provide(USE_TREE_TOKEN, treeFactory);
10244
+ provide(TREE_INSTANCE, treeInstance);
9787
10245
  expose({
9788
10246
  treeFactory
9789
10247
  });
@@ -9792,7 +10250,8 @@ var Tree = defineComponent({
9792
10250
  nodeData: treeNode
9793
10251
  }) : createVNode(DTreeNode, {
9794
10252
  "data": treeNode,
9795
- "check": check.value
10253
+ "check": check.value,
10254
+ "operate": operate.value
9796
10255
  }, {
9797
10256
  default: () => slots.content ? renderSlot(useSlots(), "content", {
9798
10257
  nodeData: treeNode
@@ -9804,13 +10263,16 @@ var Tree = defineComponent({
9804
10263
  toggleNode
9805
10264
  }) : createVNode(DTreeNodeToggle, {
9806
10265
  "data": treeNode
9807
- }, null)
10266
+ }, null),
10267
+ loading: () => slots.loading ? renderSlot(useSlots(), "loading", {
10268
+ nodeData: treeNode
10269
+ }) : createVNode(DTreeNodeLoading, null, null)
9808
10270
  });
9809
10271
  return () => {
9810
10272
  const Component = props.height ? VirtualList : "div";
9811
10273
  const treeData = getExpendedTree == null ? void 0 : getExpendedTree().value;
9812
10274
  const vSlotsProps = {
9813
- default: props.height || (() => treeData == null ? void 0 : treeData.map(renderDTreeNode)),
10275
+ default: () => treeData == null ? void 0 : treeData.map(renderDTreeNode),
9814
10276
  item: props.height && ((treeNode) => renderDTreeNode(treeNode))
9815
10277
  };
9816
10278
  let virtualListProps2 = {};
@@ -9822,6 +10284,7 @@ var Tree = defineComponent({
9822
10284
  };
9823
10285
  }
9824
10286
  return createVNode(Component, mergeProps({
10287
+ "ref": props.height ? virtualListRef : normalRef,
9825
10288
  "class": ns2.b()
9826
10289
  }, virtualListProps2), vSlotsProps);
9827
10290
  };
@@ -9830,7 +10293,7 @@ var Tree = defineComponent({
9830
10293
  var index = {
9831
10294
  title: "Tree \u6811",
9832
10295
  category: "\u6570\u636E\u5C55\u793A",
9833
- status: "20%",
10296
+ status: "50%",
9834
10297
  install(app) {
9835
10298
  app.component(Tree.name, Tree);
9836
10299
  }