bkui-vue 0.0.1-beta.63 → 0.0.1-beta.66

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 (40) hide show
  1. package/dist/index.cjs.js +28 -28
  2. package/dist/index.esm.js +625 -421
  3. package/dist/index.umd.js +28 -28
  4. package/dist/style.css +1 -1
  5. package/lib/alert/alert.css +2 -0
  6. package/lib/alert/alert.less +2 -0
  7. package/lib/alert/alert.variable.css +2 -0
  8. package/lib/alert/index.js +1 -1
  9. package/lib/button/button.less +1 -1
  10. package/lib/code-diff/index.js +2 -1
  11. package/lib/code-diff/index.js.LICENSE.txt +37 -0
  12. package/lib/select/select.css +3 -0
  13. package/lib/select/select.less +4 -0
  14. package/lib/select/select.variable.css +3 -0
  15. package/lib/tab/index.d.ts +10 -13
  16. package/lib/tab/index.js +1 -1
  17. package/lib/tab/props.d.ts +3 -0
  18. package/lib/tab/tab-nav.d.ts +11 -7
  19. package/lib/tab/tab.css +19 -0
  20. package/lib/tab/tab.d.ts +3 -4
  21. package/lib/tab/tab.less +25 -19
  22. package/lib/tab/tab.variable.css +19 -0
  23. package/lib/tag-input/tag-input.css +1 -0
  24. package/lib/tag-input/tag-input.less +1 -0
  25. package/lib/tag-input/tag-input.variable.css +1 -0
  26. package/lib/tree/constant.d.ts +9 -7
  27. package/lib/tree/index.d.ts +85 -1
  28. package/lib/tree/index.js +1 -1
  29. package/lib/tree/props.d.ts +27 -0
  30. package/lib/tree/tree.css +1 -1
  31. package/lib/tree/tree.d.ts +40 -0
  32. package/lib/tree/tree.less +1 -1
  33. package/lib/tree/tree.variable.css +1 -1
  34. package/lib/tree/use-node-action.d.ts +4 -1
  35. package/lib/tree/{use-async.d.ts → use-node-async.d.ts} +0 -0
  36. package/lib/tree/use-node-attribute.d.ts +9 -2
  37. package/lib/tree/use-node-drag.d.ts +3 -0
  38. package/lib/tree/use-tree-init.d.ts +12 -0
  39. package/lib/tree/util.d.ts +2 -6
  40. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -2674,18 +2674,18 @@ folder.inheritAttrs = false;
2674
2674
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M860.8 128H163.2a32 32 0 0 0-27.36 52l295.2 336 0.96 0V896l160-82.72V516.8l0.96 0 295.2-336A32 32 0 0 0 860.8 128Z"}}]}');
2675
2675
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 64C264 64 64 264 64 512c0 57.6 11.2 113.6 32 166.4V896c0 17.6 14.4 32 32 32h217.6C576 1019.2 836.8 908.8 928 678.4S908.8 187.2 678.4 96C625.6 75.2 569.6 64 512 64zM500.8 721.6c-27.2 0-48-20.8-48-48s20.8-48 48-48c27.2 0 48 20.8 48 48S528 721.6 500.8 721.6zM587.2 507.2c-36.8 20.8-48 35.2-48 62.4v14.4H464v-16c-3.2-44.8 11.2-70.4 51.2-92.8 36.8-22.4 48-35.2 48-60.8s-20.8-44.8-52.8-44.8c-28.8-1.6-52.8 19.2-56 48 0 1.6 0 1.6 0 3.2h-76.8c1.6-70.4 49.6-118.4 136-118.4 80 0 132.8 44.8 132.8 110.4C648 454.4 627.2 484.8 587.2 507.2z"}}]}');
2676
2676
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 64C264 64 64 264 64 512s200 448 448 448 448-200 448-448S760 64 512 64zM500.8 721.6c-27.2 0-48-20.8-48-48s20.8-48 48-48c27.2 0 48 20.8 48 48S528 721.6 500.8 721.6zM587.2 507.2c-36.8 20.8-48 35.2-48 62.4v14.4H464v-16c-3.2-44.8 11.2-70.4 51.2-92.8 36.8-22.4 48-35.2 48-60.8s-20.8-44.8-52.8-44.8c-28.8-1.6-52.8 19.2-56 48 0 1.6 0 1.6 0 3.2h-76.8c1.6-70.4 49.6-118.4 136-118.4 80 0 132.8 44.8 132.8 110.4C648 454.4 627.2 484.8 587.2 507.2z"}}]}');
2677
- const data$c = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 128c212.8 0 384 171.2 384 384S724.8 896 512 896 128 724.8 128 512 299.2 128 512 128M512 64C264 64 64 264 64 512s200 448 448 448 448-200 448-448S760 64 512 64z"}},{"type":"element","name":"path","attributes":{"d":"M548.8 673.6A48 48 0 0 1 500.8 721.6 48 48 0 0 1 452.8 673.6 48 48 0 0 1 548.8 673.6z"}},{"type":"element","name":"path","attributes":{"d":"M513.6 302.4c80 0 132.8 44.8 132.8 110.4 0 41.6-20.8 72-60.8 96-40 24-48 35.2-48 62.4v14.4H464v-16c-3.2-44.8 11.2-70.4 51.2-92.8 36.8-22.4 48-35.2 48-60.8s-20.8-44.8-52.8-44.8c-28.8-1.6-52.8 19.2-56 48 0 1.6 0 1.6 0 3.2h-76.8C377.6 352 427.2 302.4 513.6 302.4z"}}]}');
2678
- const help = (props, context) => {
2677
+ JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 128c212.8 0 384 171.2 384 384S724.8 896 512 896 128 724.8 128 512 299.2 128 512 128M512 64C264 64 64 264 64 512s200 448 448 448 448-200 448-448S760 64 512 64z"}},{"type":"element","name":"path","attributes":{"d":"M548.8 673.6A48 48 0 0 1 500.8 721.6 48 48 0 0 1 452.8 673.6 48 48 0 0 1 548.8 673.6z"}},{"type":"element","name":"path","attributes":{"d":"M513.6 302.4c80 0 132.8 44.8 132.8 110.4 0 41.6-20.8 72-60.8 96-40 24-48 35.2-48 62.4v14.4H464v-16c-3.2-44.8 11.2-70.4 51.2-92.8 36.8-22.4 48-35.2 48-60.8s-20.8-44.8-52.8-44.8c-28.8-1.6-52.8 19.2-56 48 0 1.6 0 1.6 0 3.2h-76.8C377.6 352 427.2 302.4 513.6 302.4z"}}]}');
2678
+ JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1303.273","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M664.4363636363637 0C676.8000000000001 0 688.5818181818182 4.945454545454545 697.3090909090909 13.672727272727274L697.3090909090909 13.672727272727274 1010.3272727272728 326.6909090909091C1019.0545454545455 335.41818181818184 1024 347.3454545454546 1024 359.70909090909095L1024 359.70909090909095 1024 1256.7272727272727C1024 1282.4727272727273 1003.2 1303.2727272727273 977.4545454545455 1303.2727272727273L977.4545454545455 1303.2727272727273 46.54545454545455 1303.2727272727273C20.8 1303.2727272727273 0 1282.4727272727273 0 1256.7272727272727L0 1256.7272727272727 0 46.54545454545455C0 20.8 20.8 0 46.54545454545455 0L46.54545454545455 0ZM637.6727272727272 744.7272727272727L474.76363636363635 954.1818181818182 358.40000000000003 814.5454545454546 195.4909090909091 1024 847.1272727272727 1024 637.6727272727272 744.7272727272727ZM465.4545454545455 558.5454545454545C414.041856 558.5454545454545 372.3636363636364 600.2236741818182 372.3636363636364 651.6363636363636 372.3636363636364 703.0490530909091 414.041856 744.7272727272727 465.4545454545455 744.7272727272727 516.8672349090909 744.7272727272727 558.5454545454545 703.0490530909091 558.5454545454545 651.6363636363636 558.5454545454545 600.2236741818182 516.8672349090909 558.5454545454545 465.4545454545455 558.5454545454545ZM642.9090909090909 107.34545454545454L642.9090909090909 381.0909090909091 916.6545454545455 381.0909090909091 642.9090909090909 107.34545454545454Z"}}]}');
2679
+ const data$c = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 64C264 64 64 264 64 512s200 448 448 448 448-200 448-448S760 64 512 64zM512 896C299.2 896 128 724.8 128 512S299.2 128 512 128s384 171.2 384 384S724.8 896 512 896z"}},{"type":"element","name":"path","attributes":{"d":"M494.4 403.2c-28.8 6.4-56 20.8-76.8 41.6-24 22.4 1.6 44.8 16 27.2 9.6-12.8 24-22.4 40-28.8 11.2-1.6 17.6 1.6 19.2 9.6 1.6 14.4 0 27.2-4.8 41.6-4.8 19.2-14.4 51.2-25.6 94.4-22.4 76.8-33.6 124.8-30.4 140.8 3.2 17.6 12.8 32 28.8 41.6 17.6 8 38.4 9.6 57.6 4.8 30.4-6.4 57.6-22.4 80-44.8 25.6-25.6-3.2-43.2-17.6-28.8-9.6 12.8-24 22.4-40 25.6-14.4 3.2-22.4-3.2-25.6-16-1.6-14.4 1.6-28.8 6.4-41.6 40-136 57.6-212.8 52.8-232-3.2-14.4-12.8-27.2-25.6-33.6C532.8 398.4 512 398.4 494.4 403.2z"}},{"type":"element","name":"path","attributes":{"d":"M608 304A48 48 0 0 1 560 352 48 48 0 0 1 512 304 48 48 0 0 1 608 304z"}}]}');
2680
+ const infoLine = (props, context) => {
2679
2681
  const p2 = __spreadValues(__spreadValues({}, props), context.attrs);
2680
2682
  return createVNode(bkIcon, mergeProps(p2, {
2681
2683
  "data": data$c,
2682
- "name": "help"
2684
+ "name": "infoLine"
2683
2685
  }), null);
2684
2686
  };
2685
- help.displayName = "help";
2686
- help.inheritAttrs = false;
2687
- JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1303.273","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M664.4363636363637 0C676.8000000000001 0 688.5818181818182 4.945454545454545 697.3090909090909 13.672727272727274L697.3090909090909 13.672727272727274 1010.3272727272728 326.6909090909091C1019.0545454545455 335.41818181818184 1024 347.3454545454546 1024 359.70909090909095L1024 359.70909090909095 1024 1256.7272727272727C1024 1282.4727272727273 1003.2 1303.2727272727273 977.4545454545455 1303.2727272727273L977.4545454545455 1303.2727272727273 46.54545454545455 1303.2727272727273C20.8 1303.2727272727273 0 1282.4727272727273 0 1256.7272727272727L0 1256.7272727272727 0 46.54545454545455C0 20.8 20.8 0 46.54545454545455 0L46.54545454545455 0ZM637.6727272727272 744.7272727272727L474.76363636363635 954.1818181818182 358.40000000000003 814.5454545454546 195.4909090909091 1024 847.1272727272727 1024 637.6727272727272 744.7272727272727ZM465.4545454545455 558.5454545454545C414.041856 558.5454545454545 372.3636363636364 600.2236741818182 372.3636363636364 651.6363636363636 372.3636363636364 703.0490530909091 414.041856 744.7272727272727 465.4545454545455 744.7272727272727 516.8672349090909 744.7272727272727 558.5454545454545 703.0490530909091 558.5454545454545 651.6363636363636 558.5454545454545 600.2236741818182 516.8672349090909 558.5454545454545 465.4545454545455 558.5454545454545ZM642.9090909090909 107.34545454545454L642.9090909090909 381.0909090909091 916.6545454545455 381.0909090909091 642.9090909090909 107.34545454545454Z"}}]}');
2688
- JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 64C264 64 64 264 64 512s200 448 448 448 448-200 448-448S760 64 512 64zM512 896C299.2 896 128 724.8 128 512S299.2 128 512 128s384 171.2 384 384S724.8 896 512 896z"}},{"type":"element","name":"path","attributes":{"d":"M494.4 403.2c-28.8 6.4-56 20.8-76.8 41.6-24 22.4 1.6 44.8 16 27.2 9.6-12.8 24-22.4 40-28.8 11.2-1.6 17.6 1.6 19.2 9.6 1.6 14.4 0 27.2-4.8 41.6-4.8 19.2-14.4 51.2-25.6 94.4-22.4 76.8-33.6 124.8-30.4 140.8 3.2 17.6 12.8 32 28.8 41.6 17.6 8 38.4 9.6 57.6 4.8 30.4-6.4 57.6-22.4 80-44.8 25.6-25.6-3.2-43.2-17.6-28.8-9.6 12.8-24 22.4-40 25.6-14.4 3.2-22.4-3.2-25.6-16-1.6-14.4 1.6-28.8 6.4-41.6 40-136 57.6-212.8 52.8-232-3.2-14.4-12.8-27.2-25.6-33.6C532.8 398.4 512 398.4 494.4 403.2z"}},{"type":"element","name":"path","attributes":{"d":"M608 304A48 48 0 0 1 560 352 48 48 0 0 1 512 304 48 48 0 0 1 608 304z"}}]}');
2687
+ infoLine.displayName = "infoLine";
2688
+ infoLine.inheritAttrs = false;
2689
2689
  const data$b = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","class":"bk-icon","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;","overflow":"hidden","viewBox":"0 0 1024 1024"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 64A448 448 0 1 1 64 512 448 448 0 0 1 512 64ZM493.92 402.56a156 156 0 0 0-77.12 42.24c-24.32 22.88 1.44 44 16 27.52a82.56 82.56 0 0 1 40.48-28.16c11.04-2.24 17.6 1.28 19.36 10.4A118.88 118.88 0 0 1 488.16 496q-7.2 29.76-26.4 93.92-34.72 116.32-30.08 140.8a54.72 54.72 0 0 0 28.8 40.96 88 88 0 0 0 58.4 5.12 161.76 161.76 0 0 0 80-45.44c25.76-24.96-3.52-43.04-17.28-28a76.32 76.32 0 0 1-39.36 26.08c-14.24 2.88-22.72-2.4-25.28-16A104.96 104.96 0 0 1 522.88 672Q582.24 469.12 576 439.84a46.24 46.24 0 0 0-25.6-33.6A89.6 89.6 0 0 0 493.92 402.56Zm67.84-39.84A49.92 49.92 0 1 0 512 312.96 49.76 49.76 0 0 0 561.76 362.72Z"}}]}');
2690
2690
  const info = (props, context) => {
2691
2691
  const p2 = __spreadValues(__spreadValues({}, props), context.attrs);
@@ -2858,7 +2858,7 @@ var Component$A = defineComponent({
2858
2858
  "class": typeClass
2859
2859
  }, [createVNode("div", {
2860
2860
  "class": "bk-alert-wraper"
2861
- }, [this.showIcon && createVNode(help, {
2861
+ }, [this.showIcon && createVNode(infoLine, {
2862
2862
  "class": "bk-alert-icon-info"
2863
2863
  }, null), createVNode("div", {
2864
2864
  "class": "bk-alert-content"
@@ -15450,6 +15450,7 @@ const tabNavProps = __spreadValues({
15450
15450
  type: Array,
15451
15451
  default: () => []
15452
15452
  },
15453
+ tabPosition: PropTypes.commonType(["left", "right", "top"], "position").def("top"),
15453
15454
  closable: Boolean,
15454
15455
  addable: Boolean,
15455
15456
  sortable: Boolean,
@@ -15531,51 +15532,49 @@ var TabNav = defineComponent({
15531
15532
  const dragenterIndex = ref(-1);
15532
15533
  const dragStartIndex = ref(-1);
15533
15534
  const draggingEle = ref("");
15534
- return {
15535
+ const distinctRoots = (el1, el2) => el1 === el2;
15536
+ const methods = {
15537
+ handleTabAdd(e) {
15538
+ props.tabAdd(e);
15539
+ },
15540
+ dragstart(index, $event) {
15541
+ dragStartIndex.value = index;
15542
+ draggingEle.value = props.guid;
15543
+ Object.assign($event.dataTransfer, {
15544
+ effectAllowed: "move"
15545
+ });
15546
+ props.tabDrag(index, $event);
15547
+ },
15548
+ dragenter(index) {
15549
+ if (distinctRoots(draggingEle.value, props.guid)) {
15550
+ dragenterIndex.value = index;
15551
+ }
15552
+ },
15553
+ dragend() {
15554
+ dragenterIndex.value = -1;
15555
+ dragStartIndex.value = -1;
15556
+ draggingEle.value = null;
15557
+ },
15558
+ drop(index, sortType) {
15559
+ if (!distinctRoots(draggingEle.value, props.guid)) {
15560
+ return false;
15561
+ }
15562
+ props.tabSort(dragStartIndex.value, index, sortType);
15563
+ },
15564
+ handleTabChange(name2) {
15565
+ props.tabChange(name2);
15566
+ },
15567
+ handleTabRemove(index, panel) {
15568
+ props.tabRemove(index, panel);
15569
+ }
15570
+ };
15571
+ return __spreadProps(__spreadValues({}, methods), {
15535
15572
  navs,
15536
15573
  dragenterIndex,
15537
15574
  dragStartIndex,
15538
15575
  draggingEle,
15539
15576
  guid: Math.random().toString(16).substr(4) + Math.random().toString(16).substr(4)
15540
- };
15541
- },
15542
- methods: {
15543
- distinctRoots(el1, el2) {
15544
- return el1 === el2;
15545
- },
15546
- handleTabAdd(e) {
15547
- this.tabAdd(e);
15548
- },
15549
- dragstart(index, $event) {
15550
- this.dragStartIndex = index;
15551
- this.draggingEle = this.guid;
15552
- Object.assign($event.dataTransfer, {
15553
- effectAllowed: "move"
15554
- });
15555
- this.tabDrag(index, $event);
15556
- },
15557
- dragenter(index) {
15558
- if (this.distinctRoots(this.draggingEle, this.guid)) {
15559
- this.dragenterIndex = index;
15560
- }
15561
- },
15562
- dragend() {
15563
- this.dragenterIndex = -1;
15564
- this.dragStartIndex = -1;
15565
- this.draggingEle = null;
15566
- },
15567
- drop(index, sortType) {
15568
- if (!this.distinctRoots(this.draggingEle, this.guid)) {
15569
- return false;
15570
- }
15571
- this.tabSort(this.dragStartIndex, index, sortType);
15572
- },
15573
- handleTabChange(name2) {
15574
- this.tabChange(name2);
15575
- },
15576
- handleTabRemove(index, panel) {
15577
- this.tabRemove(index, panel);
15578
- }
15577
+ });
15579
15578
  },
15580
15579
  render() {
15581
15580
  const {
@@ -15695,17 +15694,12 @@ var Tab = defineComponent({
15695
15694
  "drag"
15696
15695
  ],
15697
15696
  setup(_props, {
15698
- slots
15697
+ slots,
15698
+ emit
15699
15699
  }) {
15700
15700
  const isMounted = ref(false);
15701
15701
  const panels = ref([]);
15702
15702
  const instance = getCurrentInstance();
15703
- if (typeof slots.panel === "function") {
15704
- panels.value = slots.panel();
15705
- }
15706
- if (typeof slots.default === "function") {
15707
- panels.value = slots.default();
15708
- }
15709
15703
  const getPaneInstanceFromSlot = (vnode, panelInstanceList = []) => {
15710
15704
  const {
15711
15705
  children
@@ -15732,7 +15726,7 @@ var Tab = defineComponent({
15732
15726
  return;
15733
15727
  const content = children[0];
15734
15728
  const panelInstanceList = getPaneInstanceFromSlot(content);
15735
- const isChanged = !(panelInstanceList.length === panels.value.length && panelInstanceList.every((panel, index) => panel.uid === panels.value[index].uid));
15729
+ const isChanged = panelInstanceList.length !== panels.value.length;
15736
15730
  if (isChanged) {
15737
15731
  panels.value = panelInstanceList;
15738
15732
  }
@@ -15745,52 +15739,54 @@ var Tab = defineComponent({
15745
15739
  onUpdated(() => {
15746
15740
  setPanelInstances();
15747
15741
  });
15748
- return {
15749
- isMounted,
15750
- panels
15751
- };
15752
- },
15753
- methods: {
15754
- tabAdd(e) {
15755
- this.$emit("add", {
15756
- e
15757
- });
15758
- this.$emit("add-panel", {
15759
- e
15760
- });
15761
- },
15762
- tabChange(name2) {
15763
- this.$emit("change", name2);
15764
- this.$emit("tab-change", name2);
15765
- this.$emit("update:active", name2);
15766
- },
15767
- tabRemove(index, panel) {
15768
- this.$emit("remove", index, panel);
15769
- this.$emit("remove-panel", index, panel);
15770
- },
15771
- tabSort(dragTabIndex, dropTabIndex, sortType) {
15772
- if (sortType === "insert") {
15773
- if (dragTabIndex < dropTabIndex) {
15774
- this.panels.splice(dropTabIndex + 1, 0, this.panels[dragTabIndex]);
15775
- this.panels.splice(dragTabIndex, 1);
15776
- } else if (dragTabIndex > dropTabIndex) {
15777
- this.panels.splice(dropTabIndex, 0, this.panels[dragTabIndex]);
15778
- this.panels.splice(dragTabIndex + 1, 1);
15742
+ const methods = {
15743
+ tabAdd(e) {
15744
+ emit("add", {
15745
+ e
15746
+ });
15747
+ emit("add-panel", {
15748
+ e
15749
+ });
15750
+ },
15751
+ tabChange(name2) {
15752
+ emit("change", name2);
15753
+ emit("tab-change", name2);
15754
+ emit("update:active", name2);
15755
+ },
15756
+ tabRemove(index, panel) {
15757
+ emit("remove", index, panel);
15758
+ emit("remove-panel", index, panel);
15759
+ },
15760
+ tabSort(dragTabIndex, dropTabIndex, sortType) {
15761
+ const list = panels.value;
15762
+ if (sortType === "insert") {
15763
+ if (dragTabIndex < dropTabIndex) {
15764
+ list.splice(dropTabIndex + 1, 0, panels[dragTabIndex]);
15765
+ list.splice(dragTabIndex, 1);
15766
+ } else if (dragTabIndex > dropTabIndex) {
15767
+ list.splice(dropTabIndex, 0, panels[dragTabIndex]);
15768
+ list.splice(dragTabIndex + 1, 1);
15769
+ } else {
15770
+ return false;
15771
+ }
15779
15772
  } else {
15780
- return false;
15773
+ const swap = list[dropTabIndex];
15774
+ list[dropTabIndex] = list[dragTabIndex];
15775
+ list[dragTabIndex] = swap;
15781
15776
  }
15782
- } else {
15783
- const swap = this.panels[dropTabIndex];
15784
- this.panels[dropTabIndex] = this.panels[dragTabIndex];
15785
- this.panels[dragTabIndex] = swap;
15777
+ panels.value = [...list];
15778
+ emit("sort", dragTabIndex, dropTabIndex, sortType);
15779
+ emit("sort-change", dragTabIndex, dropTabIndex, sortType);
15780
+ },
15781
+ tabDrag(dragTabIndex, dragEvent) {
15782
+ emit("drag", dragTabIndex, dragEvent);
15783
+ emit("on-drag-tab", dragTabIndex, dragEvent);
15786
15784
  }
15787
- this.$emit("sort", dragTabIndex, dropTabIndex, sortType);
15788
- this.$emit("sort-change", dragTabIndex, dropTabIndex, sortType);
15789
- },
15790
- tabDrag(dragTabIndex, dragEvent) {
15791
- this.$emit("drag", dragTabIndex, dragEvent);
15792
- this.$emit("on-drag-tab", dragTabIndex, dragEvent);
15793
- }
15785
+ };
15786
+ return __spreadProps(__spreadValues({}, methods), {
15787
+ isMounted,
15788
+ panels
15789
+ });
15794
15790
  },
15795
15791
  render() {
15796
15792
  var _a, _b;
@@ -15814,6 +15810,7 @@ var Tab = defineComponent({
15814
15810
  validateActive,
15815
15811
  changeOnHover,
15816
15812
  changeOnHoverDelay,
15813
+ tabPosition,
15817
15814
  tabAdd,
15818
15815
  tabChange,
15819
15816
  tabRemove,
@@ -15833,6 +15830,7 @@ var Tab = defineComponent({
15833
15830
  validateActive,
15834
15831
  changeOnHover,
15835
15832
  changeOnHoverDelay,
15833
+ tabPosition,
15836
15834
  tabAdd,
15837
15835
  tabChange,
15838
15836
  tabRemove,
@@ -20989,15 +20987,17 @@ var NODE_ATTRIBUTES = /* @__PURE__ */ ((NODE_ATTRIBUTES2) => {
20989
20987
  NODE_ATTRIBUTES2["DEPTH"] = "__depth";
20990
20988
  NODE_ATTRIBUTES2["INDEX"] = "__index";
20991
20989
  NODE_ATTRIBUTES2["UUID"] = "__uuid";
20992
- NODE_ATTRIBUTES2["PARENT_ID"] = "__parentId";
20993
- NODE_ATTRIBUTES2["HAS_CHILD"] = "__hasChild";
20990
+ NODE_ATTRIBUTES2["PARENT_ID"] = "__parent_id";
20991
+ NODE_ATTRIBUTES2["HAS_CHILD"] = "__has_child";
20994
20992
  NODE_ATTRIBUTES2["PATH"] = "__path";
20995
- NODE_ATTRIBUTES2["IS_ROOT"] = "__isRoot";
20993
+ NODE_ATTRIBUTES2["IS_ROOT"] = "__is_root";
20996
20994
  NODE_ATTRIBUTES2["ORDER"] = "__order";
20997
- NODE_ATTRIBUTES2["IS_OPEN"] = "__isOpen";
20998
- NODE_ATTRIBUTES2["CHECKED"] = "__checked";
20999
- NODE_ATTRIBUTES2["IS_ASYNC_INIT"] = "__isAsyncInit";
21000
- NODE_ATTRIBUTES2["IS_MATCH"] = "__isMatch";
20995
+ NODE_ATTRIBUTES2["IS_OPENED"] = "__is_open";
20996
+ NODE_ATTRIBUTES2["IS_CHECKED"] = "__is_checked";
20997
+ NODE_ATTRIBUTES2["IS_SELECTED"] = "__is_selected";
20998
+ NODE_ATTRIBUTES2["IS_ASYNC_INIT"] = "__is_async_init";
20999
+ NODE_ATTRIBUTES2["IS_MATCH"] = "__is_match";
21000
+ NODE_ATTRIBUTES2["IS_NULL"] = "__IS_NULL";
21001
21001
  return NODE_ATTRIBUTES2;
21002
21002
  })(NODE_ATTRIBUTES || {});
21003
21003
  const treeProps = {
@@ -21042,7 +21042,11 @@ const treeProps = {
21042
21042
  PropTypes.number,
21043
21043
  PropTypes.bool
21044
21044
  ]).def(void 0),
21045
- emptyText: PropTypes.string.def("\u6CA1\u6709\u6570\u636E")
21045
+ emptyText: PropTypes.string.def("\u6CA1\u6709\u6570\u636E"),
21046
+ draggable: PropTypes.bool.def(false),
21047
+ dragSort: PropTypes.bool.def(false),
21048
+ selectable: PropTypes.bool.def(true),
21049
+ selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.any]).def(null)
21046
21050
  };
21047
21051
  var useEmpty = (props, {
21048
21052
  slots
@@ -21057,8 +21061,7 @@ var useEmpty = (props, {
21057
21061
  }
21058
21062
  })
21059
21063
  });
21060
- var useNodeAttribute = (flatData) => {
21061
- const schemaValues = computed(() => Array.from(flatData.schema.values()));
21064
+ var useNodeAttribute = (flatData, props) => {
21062
21065
  const getSchemaVal2 = (key) => flatData.schema.get(key);
21063
21066
  const getNodeAttr2 = (node, attr) => {
21064
21067
  var _a;
@@ -21068,26 +21071,55 @@ var useNodeAttribute = (flatData) => {
21068
21071
  [attr]: val
21069
21072
  }));
21070
21073
  const getNodePath = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PATH);
21074
+ const getNodeId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.UUID);
21071
21075
  const isRootNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_ROOT);
21072
- const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPEN);
21076
+ const isNodeOpened = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_OPENED);
21073
21077
  const hasChildNode = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.HAS_CHILD);
21074
21078
  const isNodeMatched = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_MATCH);
21075
- const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.CHECKED);
21079
+ const isNodeChecked = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.IS_CHECKED);
21080
+ const getNodeParentId = (node) => getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID);
21081
+ const getNodeParentIdById = (id) => getNodeAttr2({
21082
+ [NODE_ATTRIBUTES.UUID]: id
21083
+ }, NODE_ATTRIBUTES.PARENT_ID);
21084
+ const deleteNodeSchema = (id) => flatData.schema.delete(id);
21076
21085
  const isItemOpen = (item) => {
21077
21086
  var _a;
21078
21087
  if (typeof item === "object") {
21079
21088
  return isNodeOpened(item);
21080
21089
  }
21081
21090
  if (typeof item === "string") {
21082
- return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPEN];
21091
+ return (_a = getSchemaVal2(item)) == null ? void 0 : _a[NODE_ATTRIBUTES.IS_OPENED];
21083
21092
  }
21084
21093
  return false;
21085
21094
  };
21086
21095
  const checkNodeIsOpen = (node) => isRootNode(node) || isItemOpen(node) || isItemOpen(getNodeAttr2(node, NODE_ATTRIBUTES.PARENT_ID));
21096
+ const getSourceNodeByPath = (path) => {
21097
+ const paths = path.split("-");
21098
+ return paths.reduce((pre, nodeIndex) => {
21099
+ const index = Number(nodeIndex);
21100
+ return Array.isArray(pre) ? pre[index] : pre[props.children][index];
21101
+ }, props.data);
21102
+ };
21103
+ const getSourceNodeByUID = (uid) => getSourceNodeByPath(getNodePath({
21104
+ [NODE_ATTRIBUTES.UUID]: uid
21105
+ }));
21106
+ const getParentNodeData = (uid) => {
21107
+ if (isRootNode({
21108
+ [NODE_ATTRIBUTES.UUID]: uid
21109
+ })) {
21110
+ return {
21111
+ [props.children]: props.data
21112
+ };
21113
+ }
21114
+ return getSourceNodeByUID(getNodeParentIdById(uid));
21115
+ };
21087
21116
  return {
21088
- schemaValues,
21089
21117
  getSchemaVal: getSchemaVal2,
21090
21118
  getNodeAttr: getNodeAttr2,
21119
+ getNodeId,
21120
+ getNodeParentId,
21121
+ getNodeParentIdById,
21122
+ getParentNodeData,
21091
21123
  setNodeAttr,
21092
21124
  getNodePath,
21093
21125
  isRootNode,
@@ -21096,223 +21128,13 @@ var useNodeAttribute = (flatData) => {
21096
21128
  isItemOpen,
21097
21129
  isNodeChecked,
21098
21130
  isNodeMatched,
21099
- checkNodeIsOpen
21131
+ checkNodeIsOpen,
21132
+ getSourceNodeByPath,
21133
+ getSourceNodeByUID,
21134
+ deleteNodeSchema
21100
21135
  };
21101
21136
  };
21102
- var rngBrowser = { exports: {} };
21103
- var getRandomValues = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != "undefined" && typeof window.msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto);
21104
- if (getRandomValues) {
21105
- var rnds8 = new Uint8Array(16);
21106
- rngBrowser.exports = function whatwgRNG() {
21107
- getRandomValues(rnds8);
21108
- return rnds8;
21109
- };
21110
- } else {
21111
- var rnds = new Array(16);
21112
- rngBrowser.exports = function mathRNG() {
21113
- for (var i = 0, r2; i < 16; i++) {
21114
- if ((i & 3) === 0)
21115
- r2 = Math.random() * 4294967296;
21116
- rnds[i] = r2 >>> ((i & 3) << 3) & 255;
21117
- }
21118
- return rnds;
21119
- };
21120
- }
21121
- var byteToHex = [];
21122
- for (var i = 0; i < 256; ++i) {
21123
- byteToHex[i] = (i + 256).toString(16).substr(1);
21124
- }
21125
- function bytesToUuid$2(buf, offset2) {
21126
- var i = offset2 || 0;
21127
- var bth = byteToHex;
21128
- return [
21129
- bth[buf[i++]],
21130
- bth[buf[i++]],
21131
- bth[buf[i++]],
21132
- bth[buf[i++]],
21133
- "-",
21134
- bth[buf[i++]],
21135
- bth[buf[i++]],
21136
- "-",
21137
- bth[buf[i++]],
21138
- bth[buf[i++]],
21139
- "-",
21140
- bth[buf[i++]],
21141
- bth[buf[i++]],
21142
- "-",
21143
- bth[buf[i++]],
21144
- bth[buf[i++]],
21145
- bth[buf[i++]],
21146
- bth[buf[i++]],
21147
- bth[buf[i++]],
21148
- bth[buf[i++]]
21149
- ].join("");
21150
- }
21151
- var bytesToUuid_1 = bytesToUuid$2;
21152
- var rng$1 = rngBrowser.exports;
21153
- var bytesToUuid$1 = bytesToUuid_1;
21154
- var _nodeId;
21155
- var _clockseq;
21156
- var _lastMSecs = 0;
21157
- var _lastNSecs = 0;
21158
- function v1$1(options, buf, offset2) {
21159
- var i = buf && offset2 || 0;
21160
- var b2 = buf || [];
21161
- options = options || {};
21162
- var node = options.node || _nodeId;
21163
- var clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
21164
- if (node == null || clockseq == null) {
21165
- var seedBytes = rng$1();
21166
- if (node == null) {
21167
- node = _nodeId = [
21168
- seedBytes[0] | 1,
21169
- seedBytes[1],
21170
- seedBytes[2],
21171
- seedBytes[3],
21172
- seedBytes[4],
21173
- seedBytes[5]
21174
- ];
21175
- }
21176
- if (clockseq == null) {
21177
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
21178
- }
21179
- }
21180
- var msecs = options.msecs !== void 0 ? options.msecs : new Date().getTime();
21181
- var nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
21182
- var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
21183
- if (dt < 0 && options.clockseq === void 0) {
21184
- clockseq = clockseq + 1 & 16383;
21185
- }
21186
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) {
21187
- nsecs = 0;
21188
- }
21189
- if (nsecs >= 1e4) {
21190
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
21191
- }
21192
- _lastMSecs = msecs;
21193
- _lastNSecs = nsecs;
21194
- _clockseq = clockseq;
21195
- msecs += 122192928e5;
21196
- var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
21197
- b2[i++] = tl >>> 24 & 255;
21198
- b2[i++] = tl >>> 16 & 255;
21199
- b2[i++] = tl >>> 8 & 255;
21200
- b2[i++] = tl & 255;
21201
- var tmh = msecs / 4294967296 * 1e4 & 268435455;
21202
- b2[i++] = tmh >>> 8 & 255;
21203
- b2[i++] = tmh & 255;
21204
- b2[i++] = tmh >>> 24 & 15 | 16;
21205
- b2[i++] = tmh >>> 16 & 255;
21206
- b2[i++] = clockseq >>> 8 | 128;
21207
- b2[i++] = clockseq & 255;
21208
- for (var n2 = 0; n2 < 6; ++n2) {
21209
- b2[i + n2] = node[n2];
21210
- }
21211
- return buf ? buf : bytesToUuid$1(b2);
21212
- }
21213
- var v1_1 = v1$1;
21214
- var rng = rngBrowser.exports;
21215
- var bytesToUuid = bytesToUuid_1;
21216
- function v4$1(options, buf, offset2) {
21217
- var i = buf && offset2 || 0;
21218
- if (typeof options == "string") {
21219
- buf = options === "binary" ? new Array(16) : null;
21220
- options = null;
21221
- }
21222
- options = options || {};
21223
- var rnds = options.random || (options.rng || rng)();
21224
- rnds[6] = rnds[6] & 15 | 64;
21225
- rnds[8] = rnds[8] & 63 | 128;
21226
- if (buf) {
21227
- for (var ii = 0; ii < 16; ++ii) {
21228
- buf[i + ii] = rnds[ii];
21229
- }
21230
- }
21231
- return buf || bytesToUuid(rnds);
21232
- }
21233
- var v4_1 = v4$1;
21234
- var v1 = v1_1;
21235
- var v4 = v4_1;
21236
- var uuid = v4;
21237
- uuid.v1 = v1;
21238
- uuid.v4 = v4;
21239
- var uuid_1 = uuid;
21240
21137
  const DEFAULT_LEVLE_LINE = "1px dashed #c3cdd7";
21241
- const getFlatdata = (props, treeData = void 0, cachedSchema = []) => {
21242
- const { data: data2, children } = props;
21243
- const outputData = [];
21244
- let order2 = 0;
21245
- const schema = /* @__PURE__ */ new Map();
21246
- function getUid(item) {
21247
- let uid = null;
21248
- if (typeof props.nodeKey === "string") {
21249
- uid = item[props.nodeKey];
21250
- }
21251
- return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
21252
- }
21253
- function getCachedTreeNodeAttr(uuid2, node, attr, cachedAttr, defaultValue = void 0) {
21254
- const cached = (cachedSchema || []).find((item) => item[NODE_ATTRIBUTES.UUID] === uuid2);
21255
- let result = void 0;
21256
- if (cached) {
21257
- result = cached[cachedAttr];
21258
- } else {
21259
- result = node[attr];
21260
- }
21261
- if (result === void 0) {
21262
- result = defaultValue;
21263
- }
21264
- return result;
21265
- }
21266
- function isCachedTreeNodeOpened(uuid2, node) {
21267
- return getCachedTreeNodeAttr(uuid2, node, "isOpen", NODE_ATTRIBUTES.IS_OPEN, false);
21268
- }
21269
- function isCachedTreeNodeChecked(uuid2, node) {
21270
- return getCachedTreeNodeAttr(uuid2, node, "checked", NODE_ATTRIBUTES.CHECKED, false);
21271
- }
21272
- function isCachedTreeNodeMatch(uuid2, node) {
21273
- return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
21274
- }
21275
- function flatten(array, depth = 0, parent = null, path = null) {
21276
- const arrLength = array.length;
21277
- for (let i = 0; i < arrLength; i++) {
21278
- const item = array[i];
21279
- if (Array.isArray(item)) {
21280
- flatten(item, depth, parent, path);
21281
- } else {
21282
- if (typeof item === "object" && item !== null) {
21283
- const uuid2 = getUid(item);
21284
- const currentPath = path !== null ? `${path}-${i}` : `${i}`;
21285
- const hasChildren = !!(item[children] || []).length;
21286
- const attrs = {
21287
- [NODE_ATTRIBUTES.DEPTH]: depth,
21288
- [NODE_ATTRIBUTES.INDEX]: i,
21289
- [NODE_ATTRIBUTES.UUID]: uuid2,
21290
- [NODE_ATTRIBUTES.PARENT_ID]: parent,
21291
- [NODE_ATTRIBUTES.HAS_CHILD]: hasChildren,
21292
- [NODE_ATTRIBUTES.PATH]: currentPath,
21293
- [NODE_ATTRIBUTES.IS_ROOT]: parent === null,
21294
- [NODE_ATTRIBUTES.ORDER]: order2,
21295
- [NODE_ATTRIBUTES.IS_MATCH]: isCachedTreeNodeMatch(uuid2, item),
21296
- [NODE_ATTRIBUTES.IS_OPEN]: isCachedTreeNodeOpened(uuid2, item),
21297
- [NODE_ATTRIBUTES.CHECKED]: isCachedTreeNodeChecked(uuid2, item),
21298
- [children]: null
21299
- };
21300
- Object.assign(item, { [NODE_ATTRIBUTES.UUID]: uuid2 });
21301
- schema.set(uuid2, attrs);
21302
- order2 += 1;
21303
- outputData.push(__spreadProps(__spreadValues({}, item), {
21304
- [children]: null
21305
- }));
21306
- if (Object.prototype.hasOwnProperty.call(item, children)) {
21307
- flatten(item[children] || [], depth + 1, uuid2, currentPath);
21308
- }
21309
- }
21310
- }
21311
- }
21312
- }
21313
- flatten(treeData ? treeData : data2);
21314
- return [outputData, schema];
21315
- };
21316
21138
  const getPropsOneOfBoolValueWithDefault = (props, key, item = null, defaultTrueValue = null, defaultFalseValue = null, args = []) => {
21317
21139
  const prop = props[key];
21318
21140
  if (typeof prop === "boolean") {
@@ -21368,19 +21190,20 @@ const getNodeItemStyle = (item, props, flatData = {}) => {
21368
21190
  } : {});
21369
21191
  };
21370
21192
  const getNodeItemClass = (item, schema, props) => {
21371
- const { __isRoot, __isOpen } = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {};
21193
+ const { __is_root, __is_open } = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {};
21372
21194
  return {
21373
- "is-root": __isRoot,
21195
+ "is-root": __is_root,
21374
21196
  "bk-tree-node": true,
21375
- "is-open": __isOpen,
21197
+ "is-open": __is_open,
21376
21198
  "is-virtual-render": props.virtualRender,
21377
21199
  "level-line": props.levelLine
21378
21200
  };
21379
21201
  };
21380
21202
  const getNodeRowClass = (item, schema) => {
21381
- const { __checked } = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {};
21203
+ const { __is_checked, __is_selected } = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {};
21382
21204
  return {
21383
- "is-checked": __checked,
21205
+ "is-checked": __is_checked,
21206
+ "is-selected": __is_selected,
21384
21207
  [resolveClassName("node-row")]: true
21385
21208
  };
21386
21209
  };
@@ -21395,7 +21218,20 @@ const assignTreeNode = (path, treeData, childKey, assignVal) => {
21395
21218
  }, treeData);
21396
21219
  Object.assign(targetNode, assignVal || {});
21397
21220
  };
21398
- var useAsync = (props, flatData) => {
21221
+ const resolveNodeItem = (node) => {
21222
+ if (node === void 0 || node === null) {
21223
+ return { __IS_NULL: true };
21224
+ }
21225
+ if (typeof node === "string") {
21226
+ return { [NODE_ATTRIBUTES.UUID]: node };
21227
+ }
21228
+ if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.UUID)) {
21229
+ return node;
21230
+ }
21231
+ console.error("setNodeAction Error: node id cannot found");
21232
+ return node;
21233
+ };
21234
+ var useNodeAsync = (props, flatData) => {
21399
21235
  const {
21400
21236
  setNodeAttr,
21401
21237
  getNodePath,
@@ -21403,7 +21239,7 @@ var useAsync = (props, flatData) => {
21403
21239
  } = useNodeAttribute(flatData);
21404
21240
  const setNodeRemoteLoad = (resp, item) => {
21405
21241
  if (typeof resp === "object" && resp !== null) {
21406
- setNodeAttr(item, NODE_ATTRIBUTES.IS_OPEN, true);
21242
+ setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, true);
21407
21243
  const nodeValue = Array.isArray(resp) ? resp : [resp];
21408
21244
  updateTreeNode(getNodePath(item), props.data, props.children, props.children, nodeValue);
21409
21245
  }
@@ -21448,25 +21284,25 @@ var useAsync = (props, flatData) => {
21448
21284
  deepAutoOpen
21449
21285
  };
21450
21286
  };
21451
- var useNodeAction = (props, ctx, flatData, renderData) => {
21452
- const checkedNodes = [];
21287
+ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
21288
+ let selectedNodeId = null;
21453
21289
  const {
21454
21290
  setNodeAttr,
21455
21291
  getNodePath,
21456
21292
  getSchemaVal: getSchemaVal2,
21457
21293
  getNodeAttr: getNodeAttr2,
21294
+ getNodeId,
21458
21295
  isRootNode,
21459
21296
  hasChildNode,
21460
21297
  isItemOpen,
21461
21298
  isNodeOpened,
21462
21299
  isNodeChecked,
21463
- isNodeMatched,
21464
- schemaValues
21300
+ isNodeMatched
21465
21301
  } = useNodeAttribute(flatData);
21466
21302
  const {
21467
21303
  asyncNodeClick,
21468
21304
  deepAutoOpen
21469
- } = useAsync(props, flatData);
21305
+ } = useNodeAsync(props, flatData);
21470
21306
  const getRootIcon = (item) => isItemOpen(item) ? createVNode(folderShapeOpen, {
21471
21307
  "class": resolveClassName("tree-icon")
21472
21308
  }, null) : createVNode(folder, {
@@ -21535,7 +21371,7 @@ var useNodeAction = (props, ctx, flatData, renderData) => {
21535
21371
  };
21536
21372
  const setNodeOpened = (item, isOpen = null, e = null, fireEmit = true) => {
21537
21373
  const newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
21538
- setNodeAttr(item, NODE_ATTRIBUTES.IS_OPEN, newVal);
21374
+ setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, newVal);
21539
21375
  if (fireEmit) {
21540
21376
  const emitEvent = isItemOpen(item) ? EVENTS.NODE_EXPAND : EVENTS.NODE_COLLAPSE;
21541
21377
  ctx.emit(emitEvent, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
@@ -21543,7 +21379,33 @@ var useNodeAction = (props, ctx, flatData, renderData) => {
21543
21379
  if (newVal) {
21544
21380
  return;
21545
21381
  }
21546
- renderData.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).forEach((filterNode) => setNodeAttr(filterNode, NODE_ATTRIBUTES.IS_OPEN, newVal));
21382
+ renderData.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).forEach((filterNode) => setNodeAttr(filterNode, NODE_ATTRIBUTES.IS_OPENED, newVal));
21383
+ };
21384
+ const setNodeAction = (args, action, value) => {
21385
+ if (Array.isArray(args)) {
21386
+ args.forEach((node) => setNodeAttr(resolveNodeItem(node), action, value));
21387
+ return;
21388
+ }
21389
+ setNodeAttr(resolveNodeItem(args), action, value);
21390
+ };
21391
+ const setOpen = (item, isOpen = true, autoOpenParents = false) => {
21392
+ const resolvedItem = resolveNodeItem(item);
21393
+ if (resolvedItem[NODE_ATTRIBUTES.IS_NULL]) {
21394
+ return;
21395
+ }
21396
+ if (autoOpenParents) {
21397
+ if (isOpen) {
21398
+ setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPENED, isOpen);
21399
+ if (!isRootNode(resolvedItem)) {
21400
+ const parentId = getNodeAttr2(resolvedItem, NODE_ATTRIBUTES.PARENT_ID);
21401
+ setOpen(parentId, true, true);
21402
+ }
21403
+ } else {
21404
+ setNodeOpened(resolvedItem, false, null, false);
21405
+ }
21406
+ } else {
21407
+ setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPENED, isOpen);
21408
+ }
21547
21409
  };
21548
21410
  const hanldeTreeNodeClick = (item, e) => {
21549
21411
  asyncNodeClick(item);
@@ -21555,17 +21417,28 @@ var useNodeAction = (props, ctx, flatData, renderData) => {
21555
21417
  e.preventDefault();
21556
21418
  hanldeTreeNodeClick(node, e);
21557
21419
  };
21558
- const handleNodeContentClick = (item, e) => {
21559
- if (!checkedNodes.includes(item[NODE_ATTRIBUTES.UUID])) {
21560
- checkedNodes.forEach((__uuid) => setNodeAttr({
21561
- __uuid
21562
- }, NODE_ATTRIBUTES.CHECKED, false));
21563
- checkedNodes.length = 0;
21564
- setNodeAttr(item, NODE_ATTRIBUTES.CHECKED, true);
21565
- checkedNodes.push(item[NODE_ATTRIBUTES.UUID]);
21566
- if (!isNodeOpened(item)) {
21567
- hanldeTreeNodeClick(item, e);
21420
+ const setSelect = (uuid2, selected = true, autoOpen = true) => {
21421
+ const resolvedItem = resolveNodeItem(uuid2);
21422
+ if (resolvedItem[NODE_ATTRIBUTES.IS_NULL]) {
21423
+ return;
21424
+ }
21425
+ if (props.selectable) {
21426
+ if (selectedNodeId !== null) {
21427
+ setNodeAttr({
21428
+ [NODE_ATTRIBUTES.UUID]: selectedNodeId
21429
+ }, NODE_ATTRIBUTES.IS_SELECTED, !selected);
21568
21430
  }
21431
+ setNodeAttr(resolvedItem, NODE_ATTRIBUTES.IS_SELECTED, selected);
21432
+ selectedNodeId = getNodeId(resolvedItem);
21433
+ }
21434
+ if (autoOpen) {
21435
+ setOpen(uuid2, true, true);
21436
+ }
21437
+ };
21438
+ const handleNodeContentClick = (item, e) => {
21439
+ setSelect(item);
21440
+ if (!isNodeOpened(item)) {
21441
+ hanldeTreeNodeClick(item, e);
21569
21442
  }
21570
21443
  ctx.emit(EVENTS.NODE_CLICK, resolveScopedSlotParam(item), getSchemaVal2(item[NODE_ATTRIBUTES.UUID]), e);
21571
21444
  };
@@ -21608,6 +21481,7 @@ var useNodeAction = (props, ctx, flatData, renderData) => {
21608
21481
  const renderTreeNode = (item) => {
21609
21482
  var _a, _b, _c, _d, _e;
21610
21483
  return createVNode("div", {
21484
+ "data-tree-node": getNodeId(item),
21611
21485
  "class": getNodeRowClass(item, flatData.schema)
21612
21486
  }, [createVNode("div", {
21613
21487
  "class": getNodeItemClass(item, flatData.schema, props),
@@ -21626,8 +21500,130 @@ var useNodeAction = (props, ctx, flatData, renderData) => {
21626
21500
  renderTreeNode,
21627
21501
  hanldeTreeNodeClick,
21628
21502
  deepAutoOpen,
21629
- setNodeOpened
21503
+ setNodeAction,
21504
+ setNodeOpened,
21505
+ setSelect,
21506
+ setOpen
21507
+ };
21508
+ };
21509
+ var useNodeDrag = (props, root, flatData) => {
21510
+ const {
21511
+ getSourceNodeByUID,
21512
+ getNodeParentIdById,
21513
+ getParentNodeData,
21514
+ getNodeAttr: getNodeAttr2,
21515
+ getNodePath,
21516
+ isRootNode
21517
+ } = useNodeAttribute(flatData, props);
21518
+ const getTargetTreeNode = (e) => {
21519
+ const target = e.target;
21520
+ return target.closest("[data-tree-node]");
21521
+ };
21522
+ const handleTreeNodeMouseup = (e) => {
21523
+ const targetNode = getTargetTreeNode(e);
21524
+ targetNode.removeEventListener("mouseup", handleTreeNodeMouseup);
21525
+ };
21526
+ const handleTreeNodeMousedown = (e) => {
21527
+ const targetNode = getTargetTreeNode(e);
21528
+ targetNode.setAttribute("draggable", "true");
21529
+ targetNode.addEventListener("mouseup", handleTreeNodeMouseup);
21530
+ };
21531
+ const handleTreeNodeDragover = (e) => {
21532
+ e.preventDefault();
21533
+ const targetNode = getTargetTreeNode(e);
21534
+ const sourceNodeId = e.dataTransfer.getData("node-id");
21535
+ const targetNodeId = targetNode.getAttribute("data-tree-node");
21536
+ const transferEffect = isNodeSortable(sourceNodeId, targetNodeId) ? "move" : "none";
21537
+ e.dataTransfer.effectAllowed = transferEffect;
21538
+ e.dataTransfer.dropEffect = transferEffect;
21539
+ };
21540
+ const handleTreeNodeDragStart = (e) => {
21541
+ e.dataTransfer.effectAllowed = "move";
21542
+ e.dataTransfer.dropEffect = "move";
21543
+ const targetNode = getTargetTreeNode(e);
21544
+ e.dataTransfer.setData("text/plain", "");
21545
+ e.dataTransfer.setData("node-id", targetNode.getAttribute("data-tree-node"));
21546
+ };
21547
+ const handleTreeNodeDrop = (e) => {
21548
+ e.preventDefault();
21549
+ e.stopPropagation();
21550
+ const targetNode = getTargetTreeNode(e);
21551
+ const sourceNodeId = e.dataTransfer.getData("node-id");
21552
+ const targetNodeId = targetNode.getAttribute("data-tree-node");
21553
+ Reflect.apply(props.dragSort ? dragSortData : dragAsChildNode, globalThis, [sourceNodeId, targetNodeId]);
21554
+ };
21555
+ const isNodeSortable = (sourceId, tartgetId) => {
21556
+ const sourcePath = getNodePath({
21557
+ [NODE_ATTRIBUTES.UUID]: sourceId
21558
+ });
21559
+ const targetPath = getNodePath({
21560
+ [NODE_ATTRIBUTES.UUID]: tartgetId
21561
+ });
21562
+ const sourceParentNodeId = getNodeParentIdById(sourceId);
21563
+ const targetParentNode = getNodeParentIdById(tartgetId);
21564
+ if (sourceParentNodeId === targetParentNode) {
21565
+ return true;
21566
+ }
21567
+ return sourcePath.indexOf(targetPath) === -1 && targetPath.indexOf(sourcePath) === -1;
21568
+ };
21569
+ const dragSortData = (sourceId, tartgetId) => {
21570
+ if (!isNodeSortable(sourceId, tartgetId)) {
21571
+ return;
21572
+ }
21573
+ const sourceNodeData = JSON.parse(JSON.stringify(getSourceNodeByUID(sourceId)));
21574
+ const targetNodeData = JSON.parse(JSON.stringify(getSourceNodeByUID(tartgetId)));
21575
+ const sourceNodeParent = getParentNodeData(sourceId);
21576
+ const targetNodeParent = getParentNodeData(tartgetId);
21577
+ const sourceNodeIndex = getNodeAttr2({
21578
+ [NODE_ATTRIBUTES.UUID]: sourceId
21579
+ }, NODE_ATTRIBUTES.INDEX);
21580
+ const targetNodeIndex = getNodeAttr2({
21581
+ [NODE_ATTRIBUTES.UUID]: tartgetId
21582
+ }, NODE_ATTRIBUTES.INDEX);
21583
+ sourceNodeParent == null ? void 0 : sourceNodeParent[props.children].splice(sourceNodeIndex, 1, targetNodeData);
21584
+ targetNodeParent == null ? void 0 : targetNodeParent[props.children].splice(targetNodeIndex, 1, sourceNodeData);
21585
+ };
21586
+ const dragAsChildNode = (sourceNodeId, targetNodeId) => {
21587
+ const sourceNodeData = getSourceNodeByUID(sourceNodeId);
21588
+ const targetNodeData = getSourceNodeByUID(targetNodeId);
21589
+ let parentNode = null;
21590
+ if (isRootNode({
21591
+ [NODE_ATTRIBUTES.UUID]: sourceNodeId
21592
+ })) {
21593
+ parentNode = props.data;
21594
+ } else {
21595
+ const sourceNodeParentId = getNodeParentIdById(sourceNodeId);
21596
+ if (sourceNodeParentId !== void 0 && sourceNodeParentId !== null) {
21597
+ parentNode = getSourceNodeByUID(sourceNodeParentId);
21598
+ const sourceNodeIndex = getNodeAttr2({
21599
+ [NODE_ATTRIBUTES.UUID]: sourceNodeId
21600
+ }, NODE_ATTRIBUTES.INDEX);
21601
+ parentNode == null ? void 0 : parentNode[props.children].splice(sourceNodeIndex, 1);
21602
+ }
21603
+ }
21604
+ if (!targetNodeData[props.children]) {
21605
+ targetNodeData[props.children] = [];
21606
+ }
21607
+ targetNodeData[props.children].unshift(sourceNodeData);
21630
21608
  };
21609
+ onMounted(() => {
21610
+ if (props.draggable && root.value) {
21611
+ const rootTree = root.value.$el;
21612
+ rootTree.addEventListener("mousedown", handleTreeNodeMousedown);
21613
+ rootTree.addEventListener("dragstart", handleTreeNodeDragStart);
21614
+ rootTree.addEventListener("dragover", handleTreeNodeDragover);
21615
+ rootTree.addEventListener("drop", handleTreeNodeDrop);
21616
+ }
21617
+ });
21618
+ onUnmounted(() => {
21619
+ if (props.draggable && root.value) {
21620
+ const rootTree = root.value.$el;
21621
+ rootTree.removeEventListener("mousedown", handleTreeNodeMousedown);
21622
+ rootTree.removeEventListener("dragstart", handleTreeNodeDragStart);
21623
+ rootTree.removeEventListener("dragover", handleTreeNodeDragover);
21624
+ rootTree.removeEventListener("drop", handleTreeNodeDrop);
21625
+ }
21626
+ });
21631
21627
  };
21632
21628
  var useSearch = (props) => {
21633
21629
  var _a;
@@ -21671,20 +21667,272 @@ var useSearch = (props) => {
21671
21667
  isTreeUI
21672
21668
  };
21673
21669
  };
21670
+ var rngBrowser = { exports: {} };
21671
+ var getRandomValues = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != "undefined" && typeof window.msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto);
21672
+ if (getRandomValues) {
21673
+ var rnds8 = new Uint8Array(16);
21674
+ rngBrowser.exports = function whatwgRNG() {
21675
+ getRandomValues(rnds8);
21676
+ return rnds8;
21677
+ };
21678
+ } else {
21679
+ var rnds = new Array(16);
21680
+ rngBrowser.exports = function mathRNG() {
21681
+ for (var i = 0, r2; i < 16; i++) {
21682
+ if ((i & 3) === 0)
21683
+ r2 = Math.random() * 4294967296;
21684
+ rnds[i] = r2 >>> ((i & 3) << 3) & 255;
21685
+ }
21686
+ return rnds;
21687
+ };
21688
+ }
21689
+ var byteToHex = [];
21690
+ for (var i = 0; i < 256; ++i) {
21691
+ byteToHex[i] = (i + 256).toString(16).substr(1);
21692
+ }
21693
+ function bytesToUuid$2(buf, offset2) {
21694
+ var i = offset2 || 0;
21695
+ var bth = byteToHex;
21696
+ return [
21697
+ bth[buf[i++]],
21698
+ bth[buf[i++]],
21699
+ bth[buf[i++]],
21700
+ bth[buf[i++]],
21701
+ "-",
21702
+ bth[buf[i++]],
21703
+ bth[buf[i++]],
21704
+ "-",
21705
+ bth[buf[i++]],
21706
+ bth[buf[i++]],
21707
+ "-",
21708
+ bth[buf[i++]],
21709
+ bth[buf[i++]],
21710
+ "-",
21711
+ bth[buf[i++]],
21712
+ bth[buf[i++]],
21713
+ bth[buf[i++]],
21714
+ bth[buf[i++]],
21715
+ bth[buf[i++]],
21716
+ bth[buf[i++]]
21717
+ ].join("");
21718
+ }
21719
+ var bytesToUuid_1 = bytesToUuid$2;
21720
+ var rng$1 = rngBrowser.exports;
21721
+ var bytesToUuid$1 = bytesToUuid_1;
21722
+ var _nodeId;
21723
+ var _clockseq;
21724
+ var _lastMSecs = 0;
21725
+ var _lastNSecs = 0;
21726
+ function v1$1(options, buf, offset2) {
21727
+ var i = buf && offset2 || 0;
21728
+ var b2 = buf || [];
21729
+ options = options || {};
21730
+ var node = options.node || _nodeId;
21731
+ var clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
21732
+ if (node == null || clockseq == null) {
21733
+ var seedBytes = rng$1();
21734
+ if (node == null) {
21735
+ node = _nodeId = [
21736
+ seedBytes[0] | 1,
21737
+ seedBytes[1],
21738
+ seedBytes[2],
21739
+ seedBytes[3],
21740
+ seedBytes[4],
21741
+ seedBytes[5]
21742
+ ];
21743
+ }
21744
+ if (clockseq == null) {
21745
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
21746
+ }
21747
+ }
21748
+ var msecs = options.msecs !== void 0 ? options.msecs : new Date().getTime();
21749
+ var nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
21750
+ var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
21751
+ if (dt < 0 && options.clockseq === void 0) {
21752
+ clockseq = clockseq + 1 & 16383;
21753
+ }
21754
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) {
21755
+ nsecs = 0;
21756
+ }
21757
+ if (nsecs >= 1e4) {
21758
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
21759
+ }
21760
+ _lastMSecs = msecs;
21761
+ _lastNSecs = nsecs;
21762
+ _clockseq = clockseq;
21763
+ msecs += 122192928e5;
21764
+ var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
21765
+ b2[i++] = tl >>> 24 & 255;
21766
+ b2[i++] = tl >>> 16 & 255;
21767
+ b2[i++] = tl >>> 8 & 255;
21768
+ b2[i++] = tl & 255;
21769
+ var tmh = msecs / 4294967296 * 1e4 & 268435455;
21770
+ b2[i++] = tmh >>> 8 & 255;
21771
+ b2[i++] = tmh & 255;
21772
+ b2[i++] = tmh >>> 24 & 15 | 16;
21773
+ b2[i++] = tmh >>> 16 & 255;
21774
+ b2[i++] = clockseq >>> 8 | 128;
21775
+ b2[i++] = clockseq & 255;
21776
+ for (var n2 = 0; n2 < 6; ++n2) {
21777
+ b2[i + n2] = node[n2];
21778
+ }
21779
+ return buf ? buf : bytesToUuid$1(b2);
21780
+ }
21781
+ var v1_1 = v1$1;
21782
+ var rng = rngBrowser.exports;
21783
+ var bytesToUuid = bytesToUuid_1;
21784
+ function v4$1(options, buf, offset2) {
21785
+ var i = buf && offset2 || 0;
21786
+ if (typeof options == "string") {
21787
+ buf = options === "binary" ? new Array(16) : null;
21788
+ options = null;
21789
+ }
21790
+ options = options || {};
21791
+ var rnds = options.random || (options.rng || rng)();
21792
+ rnds[6] = rnds[6] & 15 | 64;
21793
+ rnds[8] = rnds[8] & 63 | 128;
21794
+ if (buf) {
21795
+ for (var ii = 0; ii < 16; ++ii) {
21796
+ buf[i + ii] = rnds[ii];
21797
+ }
21798
+ }
21799
+ return buf || bytesToUuid(rnds);
21800
+ }
21801
+ var v4_1 = v4$1;
21802
+ var v1 = v1_1;
21803
+ var v4 = v4_1;
21804
+ var uuid = v4;
21805
+ uuid.v1 = v1;
21806
+ uuid.v4 = v4;
21807
+ var uuid_1 = uuid;
21808
+ var useTreeInit = (props) => {
21809
+ var _a;
21810
+ const getFlatdata = (props2, treeData = void 0, cachedSchema = []) => {
21811
+ const {
21812
+ data: data2,
21813
+ children
21814
+ } = props2;
21815
+ const outputData = [];
21816
+ let order2 = 0;
21817
+ const schema = /* @__PURE__ */ new Map();
21818
+ function getUid(item) {
21819
+ let uid = null;
21820
+ if (typeof props2.nodeKey === "string") {
21821
+ uid = item[props2.nodeKey];
21822
+ }
21823
+ return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
21824
+ }
21825
+ function getCachedTreeNodeAttr(uuid2, node, attr, cachedAttr, defVal = void 0) {
21826
+ const cached = (cachedSchema || []).find((item) => item[NODE_ATTRIBUTES.UUID] === uuid2);
21827
+ let result = void 0;
21828
+ if (cached) {
21829
+ result = cached[cachedAttr];
21830
+ } else {
21831
+ result = node[attr];
21832
+ }
21833
+ if (result === void 0) {
21834
+ result = defVal;
21835
+ }
21836
+ return result;
21837
+ }
21838
+ function isCachedTreeNodeOpened(uuid2, node) {
21839
+ return getCachedTreeNodeAttr(uuid2, node, "isOpen", NODE_ATTRIBUTES.IS_OPENED, false);
21840
+ }
21841
+ function isCachedTreeNodeChecked(uuid2, node) {
21842
+ return getCachedTreeNodeAttr(uuid2, node, "checked", NODE_ATTRIBUTES.IS_CHECKED, false);
21843
+ }
21844
+ function isCachedTreeNodeMatch(uuid2, node) {
21845
+ return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
21846
+ }
21847
+ function isCachedTreeNodeSelected(uuid2, node) {
21848
+ return getCachedTreeNodeAttr(uuid2, node, "isSelected", NODE_ATTRIBUTES.IS_SELECTED, false);
21849
+ }
21850
+ function flatten(array, depth = 0, parent = null, path = null) {
21851
+ const arrLength = array.length;
21852
+ for (let i = 0; i < arrLength; i++) {
21853
+ const item = array[i];
21854
+ if (Array.isArray(item)) {
21855
+ flatten(item, depth, parent, path);
21856
+ } else {
21857
+ if (typeof item === "object" && item !== null) {
21858
+ const uuid2 = getUid(item);
21859
+ const currentPath = path !== null ? `${path}-${i}` : `${i}`;
21860
+ const hasChildren = !!(item[children] || []).length;
21861
+ const attrs = {
21862
+ [NODE_ATTRIBUTES.DEPTH]: depth,
21863
+ [NODE_ATTRIBUTES.INDEX]: i,
21864
+ [NODE_ATTRIBUTES.UUID]: uuid2,
21865
+ [NODE_ATTRIBUTES.PARENT_ID]: parent,
21866
+ [NODE_ATTRIBUTES.HAS_CHILD]: hasChildren,
21867
+ [NODE_ATTRIBUTES.PATH]: currentPath,
21868
+ [NODE_ATTRIBUTES.IS_ROOT]: parent === null,
21869
+ [NODE_ATTRIBUTES.ORDER]: order2,
21870
+ [NODE_ATTRIBUTES.IS_SELECTED]: props2.selectable ? isCachedTreeNodeSelected(uuid2, item) : false,
21871
+ [NODE_ATTRIBUTES.IS_MATCH]: isCachedTreeNodeMatch(uuid2, item),
21872
+ [NODE_ATTRIBUTES.IS_OPENED]: isCachedTreeNodeOpened(uuid2, item),
21873
+ [NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
21874
+ [children]: null
21875
+ };
21876
+ Object.assign(item, {
21877
+ [NODE_ATTRIBUTES.UUID]: uuid2
21878
+ });
21879
+ schema.set(uuid2, attrs);
21880
+ order2 += 1;
21881
+ outputData.push(__spreadProps(__spreadValues({}, item), {
21882
+ [children]: null
21883
+ }));
21884
+ if (Object.prototype.hasOwnProperty.call(item, children)) {
21885
+ flatten(item[children] || [], depth + 1, uuid2, currentPath);
21886
+ }
21887
+ }
21888
+ }
21889
+ }
21890
+ }
21891
+ flatten(treeData ? treeData : data2);
21892
+ return [outputData, schema];
21893
+ };
21894
+ const formatData = getFlatdata(props);
21895
+ const flatData = reactive({
21896
+ data: formatData[0],
21897
+ schema: formatData[1],
21898
+ levelLineSchema: {}
21899
+ });
21900
+ const schemaValues = computed(() => Array.from(flatData.schema.values()));
21901
+ const {
21902
+ asyncNodeClick,
21903
+ deepAutoOpen
21904
+ } = useNodeAsync(props, flatData);
21905
+ watch(() => [props.data], (newData) => {
21906
+ var _a2, _b;
21907
+ const formatData2 = getFlatdata(props, newData, schemaValues.value);
21908
+ flatData.data = formatData2[0];
21909
+ flatData.schema = formatData2[1];
21910
+ if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
21911
+ deepAutoOpen();
21912
+ }
21913
+ }, {
21914
+ deep: true
21915
+ });
21916
+ if ((_a = props.async) == null ? void 0 : _a.callback) {
21917
+ deepAutoOpen();
21918
+ }
21919
+ return {
21920
+ flatData,
21921
+ schemaValues,
21922
+ asyncNodeClick,
21923
+ deepAutoOpen
21924
+ };
21925
+ };
21674
21926
  var Component$1 = defineComponent({
21675
21927
  name: "Tree",
21676
21928
  props: treeProps,
21677
21929
  emits: [EVENTS.NODE_CLICK, EVENTS.NODE_COLLAPSE, EVENTS.NODE_EXPAND],
21678
21930
  setup(props, ctx) {
21679
- var _a;
21680
- const formatData = getFlatdata(props);
21681
- const flatData = reactive({
21682
- data: formatData[0],
21683
- schema: formatData[1],
21684
- levelLineSchema: {}
21685
- });
21686
21931
  const {
21687
- schemaValues,
21932
+ flatData,
21933
+ schemaValues
21934
+ } = useTreeInit(props);
21935
+ const {
21688
21936
  setNodeAttr,
21689
21937
  checkNodeIsOpen,
21690
21938
  getNodeAttr: getNodeAttr2,
@@ -21725,68 +21973,22 @@ var Component$1 = defineComponent({
21725
21973
  const {
21726
21974
  renderTreeNode,
21727
21975
  hanldeTreeNodeClick,
21728
- deepAutoOpen,
21729
- setNodeOpened
21730
- } = useNodeAction(props, ctx, flatData, renderData);
21731
- if ((_a = props.async) == null ? void 0 : _a.callback) {
21732
- deepAutoOpen();
21733
- }
21734
- watch(() => [props.data], (newData) => {
21735
- var _a2, _b;
21736
- const formatData2 = getFlatdata(props, newData, schemaValues.value);
21737
- flatData.data = formatData2[0];
21738
- flatData.schema = formatData2[1];
21739
- if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
21740
- deepAutoOpen();
21741
- }
21742
- }, {
21743
- deep: true
21744
- });
21745
- const resolveNodeItem = (node) => {
21746
- if (typeof node === "string") {
21747
- return {
21748
- [NODE_ATTRIBUTES.UUID]: node
21749
- };
21750
- }
21751
- if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.UUID)) {
21752
- return node;
21753
- }
21754
- console.error("setNodeAction Error: node id cannot found");
21755
- return node;
21756
- };
21757
- const setNodeAction = (args, action, value) => {
21758
- if (Array.isArray(args)) {
21759
- args.forEach((node) => setNodeAttr(resolveNodeItem(node), action, value));
21760
- return;
21761
- }
21762
- setNodeAttr(resolveNodeItem(args), action, value);
21763
- };
21764
- const setOpen = (item, isOpen = true, autoOpenParents = false) => {
21765
- const resolvedItem = resolveNodeItem(item);
21766
- if (autoOpenParents) {
21767
- if (isOpen) {
21768
- setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPEN, isOpen);
21769
- if (!isRootNode(resolvedItem)) {
21770
- const parentId = getNodeAttr2(resolvedItem, NODE_ATTRIBUTES.PARENT_ID);
21771
- setOpen(parentId, true, true);
21772
- }
21773
- } else {
21774
- setNodeOpened(resolvedItem, false, null, false);
21775
- }
21776
- } else {
21777
- setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPEN, isOpen);
21778
- }
21779
- };
21976
+ setNodeOpened,
21977
+ setOpen,
21978
+ setNodeAction,
21979
+ setSelect
21980
+ } = useNodeAction(props, ctx, flatData, renderData, schemaValues);
21780
21981
  const setChecked = (item, checked = true) => {
21781
- setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.CHECKED, checked);
21782
- };
21783
- const setSelect = (item, fireOther = true) => {
21784
- var _a2;
21785
- if (fireOther) {
21786
- setChecked((_a2 = schemaValues.value.filter((item2) => isNodeChecked(item2))) != null ? _a2 : [], false);
21787
- }
21788
- setChecked(item, true);
21982
+ setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
21789
21983
  };
21984
+ if (props.selectable) {
21985
+ watch(() => props.selected, (newData) => {
21986
+ setSelect(newData, true, true);
21987
+ }, {
21988
+ immediate: true
21989
+ });
21990
+ }
21991
+ const getData = () => flatData;
21790
21992
  ctx.expose({
21791
21993
  hanldeTreeNodeClick,
21792
21994
  isNodeChecked,
@@ -21798,12 +22000,14 @@ var Component$1 = defineComponent({
21798
22000
  setChecked,
21799
22001
  setNodeAction,
21800
22002
  setNodeOpened,
21801
- setSelect
22003
+ setSelect,
22004
+ getData
21802
22005
  });
21803
22006
  const root = ref();
21804
22007
  const {
21805
22008
  renderEmpty
21806
22009
  } = useEmpty(props, ctx);
22010
+ useNodeDrag(props, root, flatData);
21807
22011
  const renderTreeContent = (scopedData) => {
21808
22012
  if (scopedData.length) {
21809
22013
  return scopedData.map(renderTreeNode);