kui-vue 3.6.0 → 3.6.2

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 (141) hide show
  1. package/{readme.md → README.md} +4 -10
  2. package/components/button/demo/group.md +1 -1
  3. package/components/button/demo/size.md +1 -1
  4. package/components/card/card.jsx +1 -1
  5. package/components/checkbox/checkbox.jsx +17 -16
  6. package/components/checkbox/checkboxGroup.jsx +5 -5
  7. package/components/checkbox/demo/group.md +17 -6
  8. package/components/checkbox/styles/index.less +4 -11
  9. package/components/collapse/collapse.jsx +9 -10
  10. package/components/collapse/demo/accordion.md +2 -2
  11. package/components/collapse/demo/basic.md +2 -2
  12. package/components/collapse/demo/extra.md +2 -2
  13. package/components/collapse/demo/nesting.md +4 -4
  14. package/components/collapse/demo/sample.md +2 -2
  15. package/components/collapse/index.md +6 -6
  16. package/components/colorPicker/colorpicker.jsx +5 -6
  17. package/components/colorPicker/demo/basic.md +14 -2
  18. package/components/colorPicker/demo/customTrigger.md +2 -2
  19. package/components/colorPicker/demo/index.jsx +0 -8
  20. package/components/colorPicker/demo/size.md +24 -10
  21. package/components/datePicker/datepicker.jsx +19 -11
  22. package/components/datePicker/demo/basic.md +15 -6
  23. package/components/datePicker/demo/lang.md +2 -2
  24. package/components/datePicker/demo/size.md +1 -1
  25. package/components/drawer/drawer.jsx +2 -2
  26. package/components/dropdown/dropdown.jsx +9 -40
  27. package/components/dropdown/dropdownButton.jsx +18 -7
  28. package/components/empty/demo/basic.md +1 -3
  29. package/components/empty/demo/nodesc.md +1 -3
  30. package/components/empty/demo/used.md +4 -6
  31. package/components/empty/empty.jsx +19 -17
  32. package/components/empty/styles/index.less +18 -5
  33. package/components/form/demo/align.md +10 -10
  34. package/components/form/demo/valid.md +3 -2
  35. package/components/form/form.jsx +1 -1
  36. package/components/form/formitem.jsx +1 -1
  37. package/components/image/image.jsx +1 -0
  38. package/components/image/preview.jsx +1 -1
  39. package/components/input/demo/basic.md +1 -1
  40. package/components/input/demo/group.md +1 -1
  41. package/components/input/index.md +1 -1
  42. package/components/input/input.jsx +7 -5
  43. package/components/input/inputBox.jsx +2 -2
  44. package/components/inputNumber/demo/basic.md +12 -5
  45. package/components/inputNumber/demo/format.md +0 -5
  46. package/components/inputNumber/index.md +1 -1
  47. package/components/inputNumber/inputNumber.jsx +3 -5
  48. package/components/inputNumber/styles/index.less +64 -64
  49. package/components/menu/submenu.jsx +5 -5
  50. package/components/message/demo/close.md +1 -1
  51. package/components/message/group.jsx +2 -2
  52. package/components/message/index.md +1 -1
  53. package/components/message/inner.jsx +26 -7
  54. package/components/notice/demo/close.md +1 -1
  55. package/components/notice/index.md +1 -1
  56. package/components/page/page.jsx +0 -1
  57. package/components/page/styles/index.less +7 -1
  58. package/components/popconfirm/popconfirm.jsx +18 -20
  59. package/components/poptip/poptip.jsx +4 -4
  60. package/components/progress/progress.jsx +1 -1
  61. package/components/radio/demo/group.md +16 -6
  62. package/components/radio/demo/radioButton.md +3 -8
  63. package/components/radio/radio.jsx +14 -11
  64. package/components/radio/radioButton.jsx +1 -1
  65. package/components/radio/radioGroup.jsx +9 -12
  66. package/components/radio/styles/index.less +10 -21
  67. package/components/rate/demo/basic.md +12 -2
  68. package/components/rate/demo/character.md +16 -2
  69. package/components/rate/demo/index.jsx +0 -8
  70. package/components/rate/demo/tips.md +15 -5
  71. package/components/rate/rate.jsx +24 -5
  72. package/components/select/demo/basic.md +16 -7
  73. package/components/select/demo/filterable.md +4 -2
  74. package/components/select/demo/size.md +1 -1
  75. package/components/select/index.md +23 -22
  76. package/components/select/option.jsx +7 -3
  77. package/components/select/select.jsx +43 -37
  78. package/components/select/styles/index.less +1 -0
  79. package/components/slider/demo/basic.md +2 -1
  80. package/components/slider/demo/withNumber.md +3 -3
  81. package/components/slider/slider.jsx +0 -25
  82. package/components/space/styles/index.less +5 -1
  83. package/components/spin/index.md +6 -5
  84. package/components/styles/sys.less +3 -0
  85. package/components/switch/switch.jsx +13 -5
  86. package/components/table/demo/size.md +1 -1
  87. package/components/table/styles/index.less +10 -5
  88. package/components/table/table.jsx +98 -69
  89. package/components/tabs/tabs.jsx +1 -1
  90. package/components/tooltip/tooltip.jsx +16 -11
  91. package/components/treeselect/demo/basic.md +11 -8
  92. package/components/treeselect/demo/size.md +6 -5
  93. package/components/treeselect/demo/theme.md +0 -1
  94. package/components/treeselect/treeselect.jsx +15 -20
  95. package/components/upload/upload.jsx +0 -1
  96. package/components/utils/placement.js +162 -124
  97. package/dist/k-ui.cjs.js +2 -2
  98. package/dist/k-ui.css +2 -2
  99. package/dist/k-ui.d.ts +131 -127
  100. package/dist/k-ui.esm.js +2 -2
  101. package/dist/k-ui.umd.js +2 -2
  102. package/dist/locale/de.js +1 -1
  103. package/dist/locale/el.js +1 -1
  104. package/dist/locale/en.js +1 -1
  105. package/dist/locale/fr.js +1 -1
  106. package/dist/locale/it.js +1 -1
  107. package/dist/locale/ja.js +1 -1
  108. package/dist/locale/ko.js +1 -1
  109. package/dist/locale/ru.js +1 -1
  110. package/dist/locale/th.js +1 -1
  111. package/dist/locale/ua.js +2 -2
  112. package/dist/locale/uk.js +1 -1
  113. package/dist/locale/vi.js +1 -1
  114. package/dist/locale/zh-CN.js +1 -1
  115. package/dist/locale/zh-TW.js +1 -1
  116. package/package.json +5 -5
  117. package/test/i18n@8.x.html +6 -2
  118. package/types/checkbox/Checkbox.d.ts +1 -1
  119. package/types/collapse/Collapse.d.ts +1 -1
  120. package/types/image/KImage.d.ts +1 -0
  121. package/types/index.d.ts +12 -12
  122. package/types/popconfirm/Popconfirm.d.ts +1 -0
  123. package/types/radio/Radio.d.ts +1 -1
  124. package/types/radio/RadioButton.d.ts +1 -1
  125. package/types/switch/Switch.d.ts +2 -1
  126. package/types/tooltip/Tooltip.d.ts +1 -0
  127. package/components/base/collapse.jsx +0 -15
  128. package/components/base/input.jsx +0 -210
  129. package/components/colorPicker/demo/disabled.md +0 -16
  130. package/components/colorPicker/demo/disabledAlpha.md +0 -13
  131. package/components/colorPicker/demo/mode.md +0 -24
  132. package/components/colorPicker/demo/presets.md +0 -17
  133. package/components/rate/demo/clear.md +0 -13
  134. package/components/rate/demo/custom.md +0 -23
  135. package/components/rate/demo/disabled.md +0 -12
  136. package/components/rate/demo/half.md +0 -12
  137. package/components/steps/index.js +0 -4
  138. package/components/steps/step.vue +0 -82
  139. package/components/steps/steps.vue +0 -68
  140. package/components/steps/styles/index.less +0 -198
  141. package/components/utils/element.js +0 -122
@@ -13,7 +13,7 @@ import { CaretUp, CaretDown } from "kui-icons";
13
13
  import Empty from "../empty";
14
14
  import Spin from "../spin";
15
15
  import { withInstall } from "../utils/vue";
16
-
16
+ import Icon from "../icon";
17
17
  const Table = defineComponent({
18
18
  name: "Table",
19
19
  props: {
@@ -136,7 +136,11 @@ const Table = defineComponent({
136
136
  // 使用 flattedColumns
137
137
  flattedColumns.value.forEach((col) => {
138
138
  if (col.fixed === "left") {
139
- const style = { position: "sticky", left: `${leftOffset}px` };
139
+ const style = {
140
+ position: "sticky",
141
+ transform: "translateZ(0)",
142
+ left: `${leftOffset}px`,
143
+ };
140
144
  headerStyles[col.key] = style;
141
145
  bodyStyles[col.key] = style;
142
146
  leftOffset += col.width || 100;
@@ -150,6 +154,7 @@ const Table = defineComponent({
150
154
  bodyStyles[col.key] = {
151
155
  position: "sticky",
152
156
  right: `${rightOffset}px`,
157
+ transform: "translateZ(0)",
153
158
  };
154
159
 
155
160
  const headerRight = isSplit.value
@@ -159,6 +164,7 @@ const Table = defineComponent({
159
164
  headerStyles[col.key] = {
160
165
  position: "sticky",
161
166
  right: `${headerRight}px`,
167
+ transform: "translateZ(0)",
162
168
  };
163
169
 
164
170
  rightOffset += col.width || 100;
@@ -183,13 +189,25 @@ const Table = defineComponent({
183
189
  return cls;
184
190
  };
185
191
 
192
+ let scrollRafId = 0;
186
193
  const handleBodyScroll = (e) => {
187
- const { scrollLeft, scrollWidth, clientWidth } = e.target;
188
- if (isSplit.value && headerWrapperRef.value) {
189
- headerWrapperRef.value.scrollLeft = scrollLeft;
190
- }
191
- pingLeft.value = scrollLeft > 0;
192
- pingRight.value = scrollLeft < scrollWidth - clientWidth - 1;
194
+ const target = e?.target;
195
+ if (!target) return;
196
+ if (scrollRafId) cancelAnimationFrame(scrollRafId);
197
+ scrollRafId = requestAnimationFrame(() => {
198
+ const { scrollLeft, scrollWidth, clientWidth } = target;
199
+ if (isSplit.value && headerWrapperRef.value) {
200
+ headerWrapperRef.value.scrollLeft = scrollLeft;
201
+ }
202
+
203
+ // 优化边界检测,避免亚像素抖动
204
+ const maxScrollLeft = Math.max(0, scrollWidth - clientWidth);
205
+ const nextPingLeft = scrollLeft > 0.5;
206
+ const nextPingRight = scrollLeft < maxScrollLeft - 0.5;
207
+
208
+ if (pingLeft.value !== nextPingLeft) pingLeft.value = nextPingLeft;
209
+ if (pingRight.value !== nextPingRight) pingRight.value = nextPingRight;
210
+ });
193
211
  };
194
212
 
195
213
  const measureScrollbar = () => {
@@ -273,15 +291,16 @@ const Table = defineComponent({
273
291
  emit("update:selectedKeys", Array.from(newSet));
274
292
  };
275
293
 
276
- // --- Render Functions ---
277
-
278
294
  const renderColGroup = (isHeader = false) => (
279
295
  <colgroup>
280
296
  {props.checkable && <col style={{ width: "50px" }} />}
281
297
  {flattedColumns.value.map((col) => (
282
298
  <col
283
299
  key={col.key}
284
- style={{ width: col.width ? `${col.width}px` : "100px" }}
300
+ style={{
301
+ width: col.width ? `${col.width}px` : "auto",
302
+ minWidth: col.width ? `${col.width}px` : "150px",
303
+ }}
285
304
  />
286
305
  ))}
287
306
  {isHeader && isSplit.value && (
@@ -381,6 +400,68 @@ const Table = defineComponent({
381
400
  );
382
401
  };
383
402
 
403
+ const mergeMatrix = computed(() => {
404
+ const data = processedData.value;
405
+ const cols = flattedColumns.value;
406
+
407
+ // 结构: matrix[rowIndex][colIndex] = { rowSpan: 1, colSpan: 1, show: true }
408
+ const matrix = [];
409
+
410
+ if (!data.length) return matrix;
411
+
412
+ for (let i = 0; i < data.length; i++) {
413
+ matrix[i] = [];
414
+ for (let j = 0; j < cols.length; j++) {
415
+ matrix[i][j] = { rowSpan: 1, colSpan: 1, show: true };
416
+ }
417
+ }
418
+
419
+ for (let i = 0; i < data.length; i++) {
420
+ for (let j = 0; j < cols.length; j++) {
421
+ if (!matrix[i][j].show) continue;
422
+
423
+ const record = data[i];
424
+ const col = cols[j];
425
+
426
+ let rowspan = 1;
427
+ let colspan = 1;
428
+
429
+ if (col.rowSpan) {
430
+ rowspan =
431
+ typeof col.rowSpan === "function"
432
+ ? col.rowSpan(record, i)
433
+ : col.rowSpan;
434
+ }
435
+ if (col.colSpan) {
436
+ colspan =
437
+ typeof col.colSpan === "function"
438
+ ? col.colSpan(record, i)
439
+ : col.colSpan;
440
+ }
441
+
442
+ if (rowspan === 1 && colspan === 1) continue;
443
+
444
+ matrix[i][j].rowSpan = rowspan;
445
+ matrix[i][j].colSpan = colspan;
446
+
447
+ for (let r = 0; r < rowspan; r++) {
448
+ for (let c = 0; c < colspan; c++) {
449
+ if (r === 0 && c === 0) continue; // 跳过自己
450
+
451
+ const targetRow = i + r;
452
+ const targetCol = j + c;
453
+
454
+ if (matrix[targetRow] && matrix[targetRow][targetCol]) {
455
+ matrix[targetRow][targetCol].show = false;
456
+ }
457
+ }
458
+ }
459
+ }
460
+ }
461
+
462
+ return matrix;
463
+ });
464
+
384
465
  const renderTbody = () => (
385
466
  <tbody>
386
467
  {processedData.value.map((record, rowIndex) => {
@@ -409,65 +490,13 @@ const Table = defineComponent({
409
490
  </td>
410
491
  )}
411
492
  {flattedColumns.value.map((col, colIndex) => {
412
- // 检查当前单元格是否应该渲染(未被其他单元格合并)
413
- const shouldRenderCell = () => {
414
- // 检查水平方向是否被前面的单元格合并
415
- for (let i = 0; i < colIndex; i++) {
416
- const prevCol = flattedColumns.value[i];
417
- const prevColSpan =
418
- typeof prevCol.colSpan === "function"
419
- ? prevCol.colSpan(record, rowIndex) // 这里应该是 rowIndex
420
- : prevCol.colSpan;
421
-
422
- // 如果前面的单元格跨越了当前单元格的位置,则当前单元格不应该渲染
423
- if (prevColSpan && i + prevColSpan > colIndex) {
424
- return false;
425
- }
426
- }
427
-
428
- // 检查垂直方向是否被上面的单元格合并
429
- for (let i = 0; i < rowIndex; i++) {
430
- const prevRecord = processedData.value[i];
431
- const prevRowSpan =
432
- typeof col.rowSpan === "function"
433
- ? col.rowSpan(prevRecord, i) // 这里应该是 i
434
- : col.rowSpan;
435
-
436
- if (prevRowSpan && i + prevRowSpan > rowIndex) {
437
- return false;
438
- }
439
- }
440
-
441
- return true;
442
- };
443
-
444
- // 如果不应该渲染,则返回null
445
- if (!shouldRenderCell()) {
446
- return null;
447
- }
448
-
449
- // 计算当前单元格的跨行列属性
450
- let attrs = {};
451
-
452
- const colSpanValue =
453
- typeof col.colSpan === "function"
454
- ? col.colSpan(record, rowIndex) // 这里可能需要根据具体情况调整参数顺序
455
- : col.colSpan;
456
-
457
- const rowSpanValue =
458
- typeof col.rowSpan === "function"
459
- ? col.rowSpan(record, rowIndex)
460
- : col.rowSpan;
461
-
462
- // 只有当跨行列数大于1时才添加对应属性
463
- if (colSpanValue > 1) {
464
- attrs.colspan = colSpanValue;
465
- }
493
+ const cellState = mergeMatrix.value[rowIndex]?.[colIndex];
466
494
 
467
- if (rowSpanValue > 1) {
468
- attrs.rowspan = rowSpanValue;
469
- }
495
+ if (!cellState || !cellState.show) return null;
470
496
 
497
+ const attrs = {};
498
+ if (cellState.rowSpan > 1) attrs.rowspan = cellState.rowSpan;
499
+ if (cellState.colSpan > 1) attrs.colspan = cellState.colSpan;
471
500
  return (
472
501
  <td
473
502
  key={col.key}
@@ -547,7 +576,7 @@ const Table = defineComponent({
547
576
  ref={bodyWrapperRef}
548
577
  style={{
549
578
  overflowY: props.scroll.y ? "scroll" : "auto",
550
- overflowX: "auto",
579
+ overflowX: props.data?.length ? "auto" : "hidden",
551
580
  maxHeight: props.scroll.y
552
581
  ? typeof props.scroll.y === "number"
553
582
  ? `${props.scroll.y}px`
@@ -1,5 +1,5 @@
1
1
  import Icon from "../icon";
2
- import { getChildren } from "../utils/element";
2
+ import { getChildren } from "../utils/vnode";
3
3
  import { Close, ChevronBack, ChevronForward } from "kui-icons";
4
4
  import {
5
5
  defineComponent,
@@ -17,6 +17,7 @@ const Tooltip = defineComponent({
17
17
  transfer,
18
18
  },
19
19
  props: {
20
+ show: Boolean,
20
21
  dark: Boolean,
21
22
  title: [String, Number, Object, Array],
22
23
  color: String,
@@ -31,21 +32,25 @@ const Tooltip = defineComponent({
31
32
  },
32
33
  show: Boolean,
33
34
  },
34
- setup(ps, { slots, attrs }) {
35
+ setup(ps, { slots, attrs, emit }) {
35
36
  const rendered = ref(ps.show);
36
37
  const visible = ref(ps.show);
37
38
  const refPopper = ref();
38
- const refCtx = ref();
39
+ const refSelection = ref();
39
40
  const left = ref(0);
40
41
  const top = ref(0);
41
42
  const currentPlacement = ref(ps.placement);
42
43
  const transOrigin = ref("bottom");
43
44
  const hideTimer = ref();
44
45
  const showTimer = ref();
46
+ const updateShow = (value) => {
47
+ visible.value = value;
48
+ emit("update:show", value);
49
+ };
45
50
  const updatePosition = () => {
46
51
  nextTick(() => {
47
52
  setPlacement({
48
- refCtx,
53
+ refSelection,
49
54
  refPopper,
50
55
  currentPlacement,
51
56
  transOrigin,
@@ -79,19 +84,19 @@ const Tooltip = defineComponent({
79
84
  if (!rendered.value) {
80
85
  rendered.value = true;
81
86
  nextTick(() => {
82
- visible.value = true;
87
+ updateShow(true);
83
88
  updatePosition();
84
89
  });
85
90
  } else {
86
91
  clearTimeout(showTimer.value);
87
- visible.value = true;
92
+ updateShow(true);
88
93
  updatePosition();
89
94
  }
90
95
  };
91
96
  const hide = () => {
92
97
  hideTimer.value = setTimeout(() => {
93
98
  if (!ps.show) {
94
- visible.value = false;
99
+ updateShow(false);
95
100
  }
96
101
  }, 300);
97
102
  };
@@ -109,7 +114,7 @@ const Tooltip = defineComponent({
109
114
  },
110
115
  ];
111
116
  const wpProps = {
112
- ref: refCtx,
117
+ ref: refSelection,
113
118
  on: {
114
119
  touchstart: mouseEnter,
115
120
  touchmove: updatePosition,
@@ -150,24 +155,24 @@ const Tooltip = defineComponent({
150
155
  mouseenter: () => {
151
156
  clearTimeout(hideTimer.value);
152
157
  if (ps.disabled) return;
153
- visible.value = true;
158
+ updateShow(true);
154
159
  },
155
160
  mouseleave: () => {
156
161
  showTimer.value = setTimeout(() => {
157
162
  if (!ps.show) {
158
- visible.value = false;
163
+ updateShow(false);
159
164
  }
160
165
  }, 300);
161
166
  },
162
167
  },
163
168
  // onMouseenter: () => {
164
169
  // clearTimeout(hideTimer.value);
165
- // visible.value = true;
170
+ // updateShow(true)
166
171
  // },
167
172
  // onMouseleave: () => {
168
173
  // showTimer.value = setTimeout(() => {
169
174
  // if (!ps.show) {
170
- // visible.value = false;
175
+ // updateShow(false)
171
176
  // }
172
177
  // }, 300);
173
178
  // },
@@ -5,18 +5,21 @@
5
5
 
6
6
  ```vue
7
7
  <template>
8
- <TreeSelect
9
- v-model="value"
10
- :tree-data="data"
11
- tree-showLine
12
- :treeExpandedKeys="expandedKeys"
13
- block
14
- />
8
+ <Space vertical>
9
+ <code>v-model: {{ value }}</code>
10
+ <TreeSelect
11
+ v-model="value"
12
+ :tree-data="data"
13
+ tree-showLine
14
+ :treeExpandedKeys="expandedKeys"
15
+ block
16
+ />
17
+ </Space>
15
18
  </template>
16
19
  <script setup>
17
20
  import { ref } from "vue";
18
21
  const expandedKeys = ["0-1", "1-1", "1-1-2", "1-2"];
19
- const value = ref();
22
+ const value = ref("0-1");
20
23
  const data = [
21
24
  {
22
25
  title: "tree 1",
@@ -1,6 +1,6 @@
1
1
  <cn>
2
- ### 基础用法
3
- 最简单的用法。
2
+ ### 尺寸
3
+ 选择框的尺寸有:`small`、`default`、`large`。
4
4
  </cn>
5
5
 
6
6
  ```vue
@@ -17,7 +17,7 @@
17
17
  />
18
18
  <TreeSelect
19
19
  :size="size"
20
- v-model="value"
20
+ v-model="value1"
21
21
  :tree-data="data"
22
22
  tree-showLine
23
23
  :treeExpandedKeys="expandedKeys"
@@ -26,7 +26,7 @@
26
26
  />
27
27
  <TreeSelect
28
28
  :size="size"
29
- v-model="value"
29
+ v-model="value1"
30
30
  :tree-data="data"
31
31
  tree-showLine
32
32
  :treeExpandedKeys="expandedKeys"
@@ -46,7 +46,8 @@ const sizes = [
46
46
  const size = ref("default");
47
47
 
48
48
  const expandedKeys = ["0-1", "1-1", "1-1-2", "1-2"];
49
- const value = ref();
49
+ const value = ref('0-1');
50
+ const value1 = ref(['0-1']);
50
51
  const data = [
51
52
  {
52
53
  title: "tree 1",
@@ -17,7 +17,6 @@
17
17
  block
18
18
  :icon="Search"
19
19
  :treeData="data"
20
- block
21
20
  placeholder="我多了一个图标"
22
21
  />
23
22
  <TreeSelect
@@ -84,7 +84,6 @@ const TreeSelect = defineComponent({
84
84
  : injectedLocale;
85
85
  });
86
86
 
87
- const labelText = ref([]);
88
87
  const visible = ref(false);
89
88
  const rendered = ref(false);
90
89
  const currentValue = ref(
@@ -99,7 +98,7 @@ const TreeSelect = defineComponent({
99
98
  const hasSearchEvent = "search" in listeners;
100
99
  const refPopper = ref();
101
100
  const transOrigin = ref("bottom");
102
- const refCtx = ref();
101
+ const refSelection = ref();
103
102
  const left = ref(0);
104
103
  const top = ref(0);
105
104
  const currentPlacement = ref(ps.placement);
@@ -122,7 +121,6 @@ const TreeSelect = defineComponent({
122
121
  (v) => {
123
122
  currentValue.value = ps.multiple ? v || [] : isEmpty(v) ? [] : [v];
124
123
  updatePosition();
125
- updateLabel();
126
124
  }
127
125
  );
128
126
 
@@ -132,9 +130,9 @@ const TreeSelect = defineComponent({
132
130
 
133
131
  const updatePosition = () => {
134
132
  nextTick(() => {
135
- minWidth.value = refCtx.value?.offsetWidth;
133
+ minWidth.value = refSelection.value?.offsetWidth;
136
134
  setPlacement({
137
- refCtx,
135
+ refSelection,
138
136
  refPopper,
139
137
  currentPlacement,
140
138
  transOrigin,
@@ -146,13 +144,12 @@ const TreeSelect = defineComponent({
146
144
 
147
145
  onMounted(() => {
148
146
  nextTick(() => {
149
- minWidth.value = refCtx.value?.offsetWidth;
150
- updateLabel();
147
+ minWidth.value = refSelection.value?.offsetWidth;
151
148
  });
152
149
  });
153
150
 
154
151
  const outsideClick = (e) => {
155
- const ctx = refCtx.value?.$el || refCtx.value;
152
+ const ctx = refSelection.value?.$el || refSelection.value;
156
153
  if (
157
154
  refPopper.value &&
158
155
  !refPopper.value.contains(e.target) &&
@@ -214,13 +211,11 @@ const TreeSelect = defineComponent({
214
211
  const removeTag = (e, index) => {
215
212
  if (ps.disabled) return;
216
213
  currentValue.value.splice(index, 1);
217
- labelText.value.splice(index, 1);
218
214
  e.stopPropagation();
219
215
  updatePosition();
220
216
  };
221
217
  const onClear = (e) => {
222
218
  currentValue.value = [];
223
- labelText.value = [];
224
219
  emit("input", ps.multiple ? [] : "");
225
220
  emit("change", ps.multiple ? [] : "");
226
221
 
@@ -263,12 +258,12 @@ const TreeSelect = defineComponent({
263
258
  }
264
259
  }
265
260
  };
266
-
267
- const updateLabel = () => {
268
- labelText.value = optionsData.value
261
+ const labelText = computed(() => {
262
+ return optionsData.value
269
263
  .filter((item) => currentValue.value.includes(item.key))
270
264
  .map((item) => item.title);
271
- };
265
+ });
266
+
272
267
  const optionsData = computed(() => {
273
268
  const options = buildTree({
274
269
  data: ps.treeData,
@@ -317,10 +312,8 @@ const TreeSelect = defineComponent({
317
312
  if (currentValue.value?.indexOf(value) >= 0) {
318
313
  selected = false;
319
314
  currentValue.value = currentValue.value.filter((v) => v !== value);
320
- labelText.value = labelText.value.filter((v) => v !== label);
321
315
  } else {
322
316
  currentValue.value.push(value);
323
- labelText.value.push(label);
324
317
  }
325
318
 
326
319
  updatePosition();
@@ -331,7 +324,6 @@ const TreeSelect = defineComponent({
331
324
  }
332
325
  } else {
333
326
  currentValue.value = [value];
334
- labelText.value = [label];
335
327
  visible.value = false;
336
328
  clearQuery();
337
329
  }
@@ -374,7 +366,6 @@ const TreeSelect = defineComponent({
374
366
  ps.multiple &&
375
367
  currentValue.value.length > 0
376
368
  ) {
377
- labelText.value = labelText.value.slice(0, -1);
378
369
  currentValue.value = currentValue.value.slice(0, -1);
379
370
  emit("input", currentValue.value);
380
371
  // emit("update:value", currentValue.value);
@@ -558,7 +549,11 @@ const TreeSelect = defineComponent({
558
549
  },
559
550
  ];
560
551
  const clearNode = showClear.value ? (
561
- <Icon class="k-tree-select-clearable" type={CloseCircle} onClick={onClear} />
552
+ <Icon
553
+ class="k-tree-select-clearable"
554
+ type={CloseCircle}
555
+ onClick={onClear}
556
+ />
562
557
  ) : null;
563
558
 
564
559
  return (
@@ -570,7 +565,7 @@ const TreeSelect = defineComponent({
570
565
  onClick={toggle}
571
566
  onFocus={() => (ctxFocused.value = true)}
572
567
  onBlur={() => (ctxFocused.value = false)}
573
- ref={refCtx}
568
+ ref={refSelection}
574
569
  >
575
570
  {icon ? <Icon type={icon} class="k-tree-select-icon" /> : null}
576
571
  <div class="k-tree-select-selection">{childNode}</div>
@@ -65,7 +65,6 @@ const Upload = defineComponent({
65
65
  });
66
66
  }
67
67
  } else {
68
- console.log(file)
69
68
  toUpload(item, file);
70
69
  }
71
70
  };