kui-vue 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{readme.md → README.md} +4 -10
- package/components/button/demo/group.md +1 -1
- package/components/card/card.jsx +1 -1
- package/components/checkbox/checkboxGroup.jsx +4 -4
- package/components/checkbox/demo/group.md +17 -6
- package/components/checkbox/styles/index.less +4 -11
- package/components/colorPicker/colorpicker.jsx +5 -6
- package/components/colorPicker/demo/customTrigger.md +2 -2
- package/components/colorPicker/demo/mode.md +1 -4
- package/components/datePicker/datepicker.jsx +19 -11
- package/components/datePicker/demo/basic.md +15 -6
- package/components/datePicker/demo/lang.md +2 -2
- package/components/drawer/drawer.jsx +2 -2
- package/components/dropdown/dropdown.jsx +9 -40
- package/components/form/demo/valid.md +1 -0
- package/components/image/image.jsx +1 -0
- package/components/input/index.md +1 -1
- package/components/inputNumber/demo/basic.md +12 -5
- package/components/inputNumber/demo/format.md +0 -5
- package/components/inputNumber/index.md +1 -1
- package/components/inputNumber/inputNumber.jsx +3 -5
- package/components/inputNumber/styles/index.less +64 -64
- package/components/menu/submenu.jsx +5 -5
- package/components/page/page.jsx +0 -1
- package/components/popconfirm/popconfirm.jsx +4 -4
- package/components/poptip/poptip.jsx +4 -4
- package/components/radio/demo/group.md +16 -6
- package/components/radio/demo/radioButton.md +3 -8
- package/components/radio/radioGroup.jsx +8 -11
- package/components/radio/styles/index.less +10 -21
- package/components/select/demo/basic.md +16 -7
- package/components/select/demo/filterable.md +4 -2
- package/components/select/index.md +23 -22
- package/components/select/option.jsx +7 -3
- package/components/select/select.jsx +43 -36
- package/components/select/styles/index.less +1 -0
- package/components/slider/demo/basic.md +2 -1
- package/components/slider/demo/withNumber.md +3 -3
- package/components/slider/slider.jsx +0 -25
- package/components/space/styles/index.less +3 -1
- package/components/styles/sys.less +3 -0
- package/components/switch/switch.jsx +15 -5
- package/components/table/styles/index.less +10 -5
- package/components/table/table.jsx +98 -69
- package/components/tooltip/tooltip.jsx +3 -3
- package/components/treeselect/demo/size.md +2 -2
- package/components/treeselect/treeselect.jsx +15 -20
- package/components/utils/placement.js +137 -126
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +118 -115
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/zh-CN.js +1 -1
- package/dist/locale/zh-TW.js +1 -1
- package/package.json +5 -5
- package/test/i18n@8.x.html +6 -2
- package/types/image/KImage.d.ts +1 -0
- package/types/index.d.ts +10 -10
- package/types/switch/Switch.d.ts +2 -0
- package/components/steps/index.js +0 -4
- package/components/steps/step.vue +0 -82
- package/components/steps/steps.vue +0 -68
- package/components/steps/styles/index.less +0 -198
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
watch,
|
|
16
16
|
nextTick,
|
|
17
17
|
inject,
|
|
18
|
-
toRefs,
|
|
19
18
|
// Transition,
|
|
20
19
|
onBeforeMount,
|
|
21
20
|
onMounted,
|
|
22
21
|
computed,
|
|
22
|
+
onBeforeUpdate,
|
|
23
23
|
// cloneVNode,
|
|
24
24
|
} from "vue";
|
|
25
25
|
|
|
@@ -77,7 +77,7 @@ const Select = defineComponent({
|
|
|
77
77
|
: injectedLocale;
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
const labelText = ref([]);
|
|
80
|
+
// const labelText = ref([]);
|
|
81
81
|
const visible = ref(false);
|
|
82
82
|
const rendered = ref(false);
|
|
83
83
|
const currentValue = ref(
|
|
@@ -92,47 +92,50 @@ const Select = defineComponent({
|
|
|
92
92
|
const hasSearchEvent = "search" in listeners;
|
|
93
93
|
const refPopper = ref();
|
|
94
94
|
const transOrigin = ref("bottom");
|
|
95
|
-
const
|
|
95
|
+
const refSelection = ref();
|
|
96
96
|
const left = ref(0);
|
|
97
97
|
const top = ref(0);
|
|
98
98
|
const currentPlacement = ref(ps.placement);
|
|
99
99
|
const queryInputEventTimer = ref();
|
|
100
|
-
|
|
101
100
|
const activeIndex = ref(-1);
|
|
102
101
|
|
|
103
102
|
const reallySize = ref(0);
|
|
104
103
|
const ctxFocused = ref(false);
|
|
104
|
+
const updateTrigger = ref(0);
|
|
105
|
+
|
|
106
|
+
onBeforeUpdate(() => {
|
|
107
|
+
updateTrigger.value++;
|
|
108
|
+
});
|
|
109
|
+
|
|
105
110
|
watch(
|
|
106
111
|
() => ps.placement,
|
|
107
112
|
(v) => {
|
|
108
113
|
currentPlacement.value = v;
|
|
109
|
-
|
|
114
|
+
if (visible.value) {
|
|
115
|
+
updatePosition();
|
|
116
|
+
}
|
|
110
117
|
}
|
|
111
118
|
);
|
|
112
119
|
watch(
|
|
113
120
|
() => ps.options,
|
|
114
121
|
(v) => {
|
|
115
|
-
updateLabel();
|
|
116
|
-
// 如果下拉框是打开状态,重新计算位置(防止数据变多导致高度变化)
|
|
117
122
|
if (visible.value) {
|
|
118
123
|
updatePosition();
|
|
119
124
|
}
|
|
120
125
|
},
|
|
121
126
|
{ deep: true }
|
|
122
127
|
);
|
|
128
|
+
|
|
123
129
|
watch(
|
|
124
130
|
() => ps.value,
|
|
125
131
|
(v) => {
|
|
126
132
|
currentValue.value = ps.multiple ? v || [] : isEmpty(v) ? [] : [v];
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
if (visible.value) {
|
|
134
|
+
updatePosition();
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
);
|
|
131
|
-
|
|
132
|
-
// // 影响外层 scroll
|
|
133
|
-
// const item = refPopper.value.children[0].children[activeIndex.value];
|
|
134
|
-
// item.scrollIntoView({ block: "center" });
|
|
135
|
-
// };
|
|
138
|
+
|
|
136
139
|
const scrollOptionIntoView = () => {
|
|
137
140
|
const containerEl = refPopper.value;
|
|
138
141
|
const optionEl = refPopper.value.children[0].children[activeIndex.value];
|
|
@@ -198,11 +201,17 @@ const Select = defineComponent({
|
|
|
198
201
|
document.removeEventListener("click", outsideClick);
|
|
199
202
|
});
|
|
200
203
|
|
|
204
|
+
const labelText = computed(() => {
|
|
205
|
+
return optionsData.value
|
|
206
|
+
.filter((item) => currentValue.value.includes(item.value))
|
|
207
|
+
.map((item) => item.label);
|
|
208
|
+
});
|
|
209
|
+
|
|
201
210
|
const updatePosition = () => {
|
|
202
211
|
nextTick(() => {
|
|
203
|
-
minWidth.value =
|
|
212
|
+
minWidth.value = refSelection.value?.offsetWidth;
|
|
204
213
|
setPlacement({
|
|
205
|
-
|
|
214
|
+
refSelection,
|
|
206
215
|
refPopper,
|
|
207
216
|
currentPlacement,
|
|
208
217
|
transOrigin,
|
|
@@ -214,14 +223,13 @@ const Select = defineComponent({
|
|
|
214
223
|
|
|
215
224
|
onMounted(() => {
|
|
216
225
|
nextTick(() => {
|
|
217
|
-
minWidth.value =
|
|
218
|
-
updateLabel();
|
|
226
|
+
minWidth.value = refSelection.value?.offsetWidth;
|
|
219
227
|
});
|
|
220
228
|
document.addEventListener("keydown", onKeydown);
|
|
221
229
|
});
|
|
222
230
|
|
|
223
231
|
const outsideClick = (e) => {
|
|
224
|
-
const ctx =
|
|
232
|
+
const ctx = refSelection.value?.$el || refSelection.value;
|
|
225
233
|
if (
|
|
226
234
|
refPopper.value &&
|
|
227
235
|
!refPopper.value.contains(e.target) &&
|
|
@@ -266,7 +274,6 @@ const Select = defineComponent({
|
|
|
266
274
|
if (currentValue.value?.indexOf(value) >= 0) {
|
|
267
275
|
selected = false;
|
|
268
276
|
currentValue.value = currentValue.value.filter((v) => v !== value);
|
|
269
|
-
labelText.value = labelText.value.filter((v) => v !== label);
|
|
270
277
|
} else {
|
|
271
278
|
currentValue.value.push(value);
|
|
272
279
|
labelText.value.push(label);
|
|
@@ -279,9 +286,8 @@ const Select = defineComponent({
|
|
|
279
286
|
}
|
|
280
287
|
} else {
|
|
281
288
|
currentValue.value = [value];
|
|
282
|
-
labelText.value = [label];
|
|
283
|
-
// toggle();
|
|
284
289
|
visible.value = false;
|
|
290
|
+
emit("openChange", false);
|
|
285
291
|
clearQuery();
|
|
286
292
|
activeIndex.value = -1;
|
|
287
293
|
}
|
|
@@ -290,7 +296,7 @@ const Select = defineComponent({
|
|
|
290
296
|
emit("input", result);
|
|
291
297
|
|
|
292
298
|
emit("change", result);
|
|
293
|
-
emit("select", value, label, selected);
|
|
299
|
+
emit("select", { value, label, selected });
|
|
294
300
|
};
|
|
295
301
|
const searchInput = (e) => {
|
|
296
302
|
queryKey.value = e.target.value;
|
|
@@ -307,10 +313,12 @@ const Select = defineComponent({
|
|
|
307
313
|
document.addEventListener("click", outsideClick);
|
|
308
314
|
nextTick(() => {
|
|
309
315
|
visible.value = true;
|
|
316
|
+
emit("openChange", true);
|
|
310
317
|
updatePosition();
|
|
311
318
|
});
|
|
312
319
|
} else {
|
|
313
320
|
visible.value = true;
|
|
321
|
+
emit("openChange", true);
|
|
314
322
|
updatePosition();
|
|
315
323
|
}
|
|
316
324
|
emit("search", e);
|
|
@@ -330,13 +338,11 @@ const Select = defineComponent({
|
|
|
330
338
|
const removeTag = (e, index) => {
|
|
331
339
|
if (ps.disabled) return;
|
|
332
340
|
currentValue.value.splice(index, 1);
|
|
333
|
-
labelText.value.splice(index, 1);
|
|
334
341
|
e.stopPropagation();
|
|
335
342
|
updatePosition();
|
|
336
343
|
};
|
|
337
344
|
const onClear = (e) => {
|
|
338
345
|
currentValue.value = [];
|
|
339
|
-
labelText.value = [];
|
|
340
346
|
emit("input", ps.multiple ? [] : "");
|
|
341
347
|
emit("change", ps.multiple ? [] : "");
|
|
342
348
|
clearQuery();
|
|
@@ -365,11 +371,13 @@ const Select = defineComponent({
|
|
|
365
371
|
document.addEventListener("click", outsideClick);
|
|
366
372
|
nextTick(() => {
|
|
367
373
|
visible.value = true;
|
|
374
|
+
emit("openChange", true);
|
|
368
375
|
updatePosition();
|
|
369
376
|
showQuery();
|
|
370
377
|
});
|
|
371
378
|
} else {
|
|
372
379
|
visible.value = show || !visible.value;
|
|
380
|
+
emit("openChange", visible.value);
|
|
373
381
|
if (visible.value) {
|
|
374
382
|
updatePosition();
|
|
375
383
|
showQuery();
|
|
@@ -379,12 +387,8 @@ const Select = defineComponent({
|
|
|
379
387
|
}
|
|
380
388
|
};
|
|
381
389
|
|
|
382
|
-
const updateLabel = () => {
|
|
383
|
-
labelText.value = optionsData.value
|
|
384
|
-
.filter((item) => currentValue.value.includes(item.value))
|
|
385
|
-
.map((item) => item.label);
|
|
386
|
-
};
|
|
387
390
|
const optionsData = computed(() => {
|
|
391
|
+
updateTrigger.value;
|
|
388
392
|
let { options, loading } = ps;
|
|
389
393
|
if (loading) return [];
|
|
390
394
|
if (!options) {
|
|
@@ -405,7 +409,7 @@ const Select = defineComponent({
|
|
|
405
409
|
});
|
|
406
410
|
const filterOptions = () => {
|
|
407
411
|
const key = queryKey.value;
|
|
408
|
-
const filter = ps.filterable &&
|
|
412
|
+
const filter = ps.filterable && key.trim() !== "";
|
|
409
413
|
return filter
|
|
410
414
|
? optionsData.value.filter((item) =>
|
|
411
415
|
item.label.toLowerCase().includes(key.toLowerCase())
|
|
@@ -444,7 +448,6 @@ const Select = defineComponent({
|
|
|
444
448
|
ps.multiple &&
|
|
445
449
|
currentValue.value.length > 0
|
|
446
450
|
) {
|
|
447
|
-
labelText.value = labelText.value.slice(0, -1);
|
|
448
451
|
currentValue.value = currentValue.value.slice(0, -1);
|
|
449
452
|
emit("input", currentValue.value);
|
|
450
453
|
// emit("update:value", currentValue.value);
|
|
@@ -457,13 +460,17 @@ const Select = defineComponent({
|
|
|
457
460
|
}
|
|
458
461
|
};
|
|
459
462
|
const showClear = computed(() => {
|
|
460
|
-
return
|
|
463
|
+
return (
|
|
464
|
+
ps.clearable &&
|
|
465
|
+
!ps.disabled &&
|
|
466
|
+
!isEmpty(currentValue.value) &&
|
|
467
|
+
!isEmpty(labelText.value)
|
|
468
|
+
);
|
|
461
469
|
});
|
|
462
470
|
const renderOverlay = () => {
|
|
463
|
-
const optionNodes = renderOptions();
|
|
464
|
-
|
|
465
471
|
let overlay = null;
|
|
466
472
|
if (rendered.value) {
|
|
473
|
+
const optionNodes = renderOptions();
|
|
467
474
|
const preCls = "k-select";
|
|
468
475
|
const props = {
|
|
469
476
|
ref: refPopper,
|
|
@@ -642,7 +649,7 @@ const Select = defineComponent({
|
|
|
642
649
|
onClick={toggle}
|
|
643
650
|
onFocus={() => (ctxFocused.value = true)}
|
|
644
651
|
onBlur={() => (ctxFocused.value = false)}
|
|
645
|
-
ref={
|
|
652
|
+
ref={refSelection}
|
|
646
653
|
>
|
|
647
654
|
{icon ? <Icon type={icon} class="k-select-icon" /> : null}
|
|
648
655
|
<div class="k-select-selection">{childNode}</div>
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<Space style="max-width:520px;" vertical block>
|
|
9
|
-
<code>value: {{ v1 }}</code>
|
|
10
9
|
<code>Disabled: <k-switch v-model="disabled" /></code>
|
|
10
|
+
<code>v-model: {{ v1 }}</code>
|
|
11
11
|
<Slider v-model="v1" :step="10" :disabled="disabled" :min="20" />
|
|
12
|
+
<code>v-model: {{ v2 }}</code>
|
|
12
13
|
<Slider v-model="v2" range :disabled="disabled" :min="10" :max="80" />
|
|
13
14
|
<Slider
|
|
14
15
|
:marks="{ 0: '0°C', 25: '25°C', 36: '36°C', 100: '100°C' }"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<div>
|
|
9
9
|
<Row>
|
|
10
10
|
<Col :span="12">
|
|
11
|
-
<Slider v-model="n1" :min="1" :max="20" />
|
|
11
|
+
<Slider v-model:value="n1" :min="1" :max="20" />
|
|
12
12
|
</Col>
|
|
13
13
|
<Col :span="4">
|
|
14
14
|
<InputNumber
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
</Row>
|
|
22
22
|
<Row>
|
|
23
23
|
<Col :span="12">
|
|
24
|
-
<Slider v-model="n2" :min="0" :max="1" :step="0.01" />
|
|
24
|
+
<Slider v-model:value="n2" :min="0" :max="1" :step="0.01" />
|
|
25
25
|
</Col>
|
|
26
26
|
<Col :span="4">
|
|
27
27
|
<InputNumber
|
|
28
|
-
v-model="n2"
|
|
28
|
+
v-model:value="n2"
|
|
29
29
|
:min="0"
|
|
30
30
|
:max="1"
|
|
31
31
|
:step="0.01"
|
|
@@ -128,37 +128,12 @@ const Slider = defineComponent({
|
|
|
128
128
|
const v = ps.range ? [...defaultValue.value] : defaultValue.value;
|
|
129
129
|
let newValue = null;
|
|
130
130
|
if (ps.range) {
|
|
131
|
-
// todo:
|
|
132
|
-
// v = type === "right" ? [v[0], x] : [x, v[1]];
|
|
133
|
-
// 可以交叉
|
|
134
131
|
let [a, b] = [...v];
|
|
135
|
-
// let x1 = Math.min(a, b, x);
|
|
136
|
-
// let y1 = Math.max(a, b, x);
|
|
137
132
|
if (type == "right") {
|
|
138
|
-
// if (x > a) {
|
|
139
|
-
// newValue = [a, x];
|
|
140
|
-
// } else if (x < a) {
|
|
141
|
-
// newValue = [x, b ];
|
|
142
|
-
// } else {
|
|
143
|
-
// console.log(a, b, x);
|
|
144
133
|
newValue = [a, x];
|
|
145
|
-
// }
|
|
146
134
|
} else {
|
|
147
135
|
newValue = [x, b];
|
|
148
136
|
}
|
|
149
|
-
|
|
150
|
-
// let [x1, y1] = [...newValue];
|
|
151
|
-
// if (x1 > y1) {
|
|
152
|
-
// newValue = [y1, x1];
|
|
153
|
-
// }
|
|
154
|
-
// console.log(x1,y1);
|
|
155
|
-
|
|
156
|
-
// 不能交叉
|
|
157
|
-
// if (type === "right") {
|
|
158
|
-
// v = [v[0], Math.max(v[0], x)]; // 右边不能小于左边
|
|
159
|
-
// } else {
|
|
160
|
-
// v = [Math.min(x, v[1]), v[1]]; // 左边不能大于右边
|
|
161
|
-
// }
|
|
162
137
|
} else {
|
|
163
138
|
newValue = x;
|
|
164
139
|
}
|
|
@@ -24,12 +24,15 @@ textarea::placeholder {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
&::-webkit-scrollbar-track {
|
|
27
|
+
background-color: transparent;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
&::-webkit-scrollbar-thumb {
|
|
30
31
|
border-radius: 8px;
|
|
31
32
|
width: 6px;
|
|
32
33
|
height: 6px;
|
|
34
|
+
min-height: 55px;
|
|
35
|
+
min-width: 55px;
|
|
33
36
|
background-color: var(--kui-color-border);
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import Icon from "../icon";
|
|
2
2
|
import { Loading } from "kui-icons";
|
|
3
3
|
import { defineComponent, ref, watch } from "vue";
|
|
4
|
-
import { withInstall } from
|
|
4
|
+
import { withInstall } from "../utils/vue";
|
|
5
5
|
const Switch = defineComponent({
|
|
6
6
|
name: "KSwitch",
|
|
7
|
+
model: {
|
|
8
|
+
prop: "checked",
|
|
9
|
+
event: "input",
|
|
10
|
+
},
|
|
7
11
|
props: {
|
|
12
|
+
checked: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
8
16
|
// checked: [Boolean, Number], //for 3
|
|
9
|
-
value: [Boolean, Number], //for
|
|
17
|
+
value: [Boolean, Number], //for 2
|
|
10
18
|
type: String,
|
|
11
19
|
disabled: Boolean,
|
|
12
20
|
loading: Boolean,
|
|
@@ -20,9 +28,10 @@ const Switch = defineComponent({
|
|
|
20
28
|
falseText: String,
|
|
21
29
|
},
|
|
22
30
|
setup(ps, { slots, emit }) {
|
|
23
|
-
const isChecked = ref(ps.
|
|
31
|
+
const isChecked = ref(ps.checked);
|
|
24
32
|
watch(
|
|
25
|
-
() => ps.
|
|
33
|
+
() => ps.checked,
|
|
34
|
+
// () => ps.value,
|
|
26
35
|
(nv, no) => {
|
|
27
36
|
isChecked.value = nv;
|
|
28
37
|
}
|
|
@@ -69,7 +78,8 @@ const Switch = defineComponent({
|
|
|
69
78
|
class={classes}
|
|
70
79
|
onClick={change}
|
|
71
80
|
disabled={disabled || loading}
|
|
72
|
-
type="button"
|
|
81
|
+
type="button"
|
|
82
|
+
>
|
|
73
83
|
{textNode}
|
|
74
84
|
{loadNode}
|
|
75
85
|
</button>
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
z-index: 3;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.k-table-cell-fix-left
|
|
20
|
-
position: sticky;
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
.k-table-cell-fix-left,
|
|
23
20
|
.k-table-cell-fix-right {
|
|
24
21
|
position: sticky;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
backface-visibility: hidden;
|
|
24
|
+
-webkit-backface-visibility: hidden;
|
|
25
|
+
will-change: transform;
|
|
26
|
+
contain: layout;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
.k-spin {
|
|
@@ -328,7 +330,10 @@
|
|
|
328
330
|
padding: 20px 16px;
|
|
329
331
|
}
|
|
330
332
|
}
|
|
331
|
-
|
|
333
|
+
.k-table-body {
|
|
334
|
+
-webkit-overflow-scrolling: touch;
|
|
335
|
+
will-change: scroll-position;
|
|
336
|
+
}
|
|
332
337
|
.k-table-header + .k-table-body {
|
|
333
338
|
table tr th:first-child {
|
|
334
339
|
border-radius: 0;
|
|
@@ -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 = {
|
|
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
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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={{
|
|
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 (
|
|
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`
|