qidian-vue-ui 2.0.27 → 2.0.28
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/dist/components/service/table/edit-cell.d.ts +14 -1
- package/dist/components/service/table/edit-cell.mjs +36 -7
- package/dist/components/service/table/index.css +28 -28
- package/dist/components/service/table/index.vue.mjs +1 -1
- package/dist/components/service/table/index.vue2.mjs +116 -11
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableEditableCellPropsParams, TableRowData, TableRowValue } from 'tdesign-vue-next';
|
|
1
|
+
import type { AllValidateResult, TableEditableCellPropsParams, TableRowData, TableRowValue } from 'tdesign-vue-next';
|
|
2
2
|
import type { PropType } from 'vue';
|
|
3
3
|
import type { QdFormBeforeSubmitQueueItem } from '../../form';
|
|
4
4
|
import type { QdServiceTableFormItem } from './types';
|
|
@@ -23,6 +23,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
23
23
|
label: PropType<unknown>;
|
|
24
24
|
lazy: BooleanConstructor;
|
|
25
25
|
active: BooleanConstructor;
|
|
26
|
+
autofocus: BooleanConstructor;
|
|
27
|
+
validationErrors: PropType<AllValidateResult[]>;
|
|
26
28
|
renderCell: {
|
|
27
29
|
type: PropType<() => unknown>;
|
|
28
30
|
required: true;
|
|
@@ -31,6 +33,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
31
33
|
type: PropType<() => void>;
|
|
32
34
|
required: true;
|
|
33
35
|
};
|
|
36
|
+
consumeAutofocus: {
|
|
37
|
+
type: PropType<() => void>;
|
|
38
|
+
required: true;
|
|
39
|
+
};
|
|
34
40
|
registerBeforeSubmit: {
|
|
35
41
|
type: PropType<RegisterBeforeSubmit>;
|
|
36
42
|
required: true;
|
|
@@ -75,6 +81,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
75
81
|
label: PropType<unknown>;
|
|
76
82
|
lazy: BooleanConstructor;
|
|
77
83
|
active: BooleanConstructor;
|
|
84
|
+
autofocus: BooleanConstructor;
|
|
85
|
+
validationErrors: PropType<AllValidateResult[]>;
|
|
78
86
|
renderCell: {
|
|
79
87
|
type: PropType<() => unknown>;
|
|
80
88
|
required: true;
|
|
@@ -83,6 +91,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
83
91
|
type: PropType<() => void>;
|
|
84
92
|
required: true;
|
|
85
93
|
};
|
|
94
|
+
consumeAutofocus: {
|
|
95
|
+
type: PropType<() => void>;
|
|
96
|
+
required: true;
|
|
97
|
+
};
|
|
86
98
|
registerBeforeSubmit: {
|
|
87
99
|
type: PropType<RegisterBeforeSubmit>;
|
|
88
100
|
required: true;
|
|
@@ -109,6 +121,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
109
121
|
};
|
|
110
122
|
}>> & Readonly<{}>, {
|
|
111
123
|
lazy: boolean;
|
|
124
|
+
autofocus: boolean;
|
|
112
125
|
active: boolean;
|
|
113
126
|
sourceRow: TableRowData;
|
|
114
127
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmpty } from "qidian-shared";
|
|
2
|
-
import { defineComponent, computed,
|
|
2
|
+
import { defineComponent, computed, onBeforeUnmount, provide, h } from "vue";
|
|
3
3
|
import { useConfig } from "../../config-provider/useConfig.mjs";
|
|
4
4
|
import { qdUseComputeValue } from "../../config-renderer/compute.mjs";
|
|
5
5
|
import { resolveQdFormItemOptions } from "../../form/utils.mjs";
|
|
@@ -94,6 +94,8 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
94
94
|
label: [String, Function, Object],
|
|
95
95
|
lazy: Boolean,
|
|
96
96
|
active: Boolean,
|
|
97
|
+
autofocus: Boolean,
|
|
98
|
+
validationErrors: Array,
|
|
97
99
|
renderCell: {
|
|
98
100
|
type: Function,
|
|
99
101
|
required: true
|
|
@@ -102,6 +104,10 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
102
104
|
type: Function,
|
|
103
105
|
required: true
|
|
104
106
|
},
|
|
107
|
+
consumeAutofocus: {
|
|
108
|
+
type: Function,
|
|
109
|
+
required: true
|
|
110
|
+
},
|
|
105
111
|
registerBeforeSubmit: {
|
|
106
112
|
type: Function,
|
|
107
113
|
required: true
|
|
@@ -131,18 +137,26 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
131
137
|
attrs
|
|
132
138
|
}) {
|
|
133
139
|
const horizontalScroll = props.getHorizontalScroll();
|
|
140
|
+
const restoreHorizontalScrollOnFocus = props.autofocus;
|
|
134
141
|
let autofocusScrollRestored = false;
|
|
142
|
+
let unmounting = false;
|
|
135
143
|
const currentContext = computed(() => createRowEditContext(props.sourceRow ?? props.row, () => props.row, props.colKey, props.updateEditedCellValue, props.notifyDataChange, (value) => {
|
|
136
144
|
if (typeof attrs.onChange === "function") attrs.onChange(value);
|
|
137
145
|
}));
|
|
138
146
|
const {
|
|
139
147
|
t
|
|
140
148
|
} = useConfig("form");
|
|
149
|
+
const validationError = computed(() => props.validationErrors?.[0]);
|
|
141
150
|
const validationStatus = computed(() => {
|
|
142
|
-
const status = attrs.status;
|
|
151
|
+
const status = attrs.status ?? validationError.value?.type;
|
|
143
152
|
if (status === "error" || status === "warning" || status === "success") return status;
|
|
153
|
+
if (validationError.value) return "error";
|
|
144
154
|
return void 0;
|
|
145
155
|
});
|
|
156
|
+
const validationTips = computed(() => {
|
|
157
|
+
const tips = attrs.tips ?? validationError.value?.message;
|
|
158
|
+
return typeof tips === "string" ? tips : void 0;
|
|
159
|
+
});
|
|
146
160
|
const reIfRender = computed(() => {
|
|
147
161
|
const ifRender = props.formItem.ifRender;
|
|
148
162
|
if (isEmpty(ifRender)) return true;
|
|
@@ -164,7 +178,7 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
164
178
|
if (!resolved) return;
|
|
165
179
|
return {
|
|
166
180
|
...resolved,
|
|
167
|
-
...props.
|
|
181
|
+
...props.autofocus ? {
|
|
168
182
|
autofocus: true
|
|
169
183
|
} : {},
|
|
170
184
|
...validationStatus.value ? {
|
|
@@ -174,13 +188,27 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
174
188
|
});
|
|
175
189
|
function handleFocusin() {
|
|
176
190
|
props.activate();
|
|
177
|
-
if (!props.lazy || !props.active || autofocusScrollRestored || horizontalScroll === void 0) {
|
|
191
|
+
if (!props.lazy || !props.active || !restoreHorizontalScrollOnFocus || autofocusScrollRestored || horizontalScroll === void 0) {
|
|
178
192
|
return;
|
|
179
193
|
}
|
|
180
194
|
autofocusScrollRestored = true;
|
|
181
195
|
props.setHorizontalScroll(horizontalScroll);
|
|
182
196
|
queueMicrotask(() => props.setHorizontalScroll(horizontalScroll));
|
|
183
197
|
}
|
|
198
|
+
function handleFocusout(event) {
|
|
199
|
+
const currentTarget = event.currentTarget;
|
|
200
|
+
const nextTarget = event.relatedTarget;
|
|
201
|
+
if (nextTarget instanceof Node && currentTarget.contains(nextTarget)) return;
|
|
202
|
+
requestAnimationFrame(() => {
|
|
203
|
+
if (unmounting || !currentTarget.isConnected || currentTarget.contains(document.activeElement)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
props.consumeAutofocus();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
onBeforeUnmount(() => {
|
|
210
|
+
unmounting = true;
|
|
211
|
+
});
|
|
184
212
|
provide(PROVIDE_FORM_ADD_BEFORE_SUBMIT_QUEUE, (item) => {
|
|
185
213
|
const cleanup = props.registerBeforeSubmit(props.rowValue, item);
|
|
186
214
|
onBeforeUnmount(cleanup);
|
|
@@ -199,16 +227,17 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
|
|
|
199
227
|
return h("div", {
|
|
200
228
|
...rendererAttrs,
|
|
201
229
|
class: ["qd-service-table__cell-editor", "t-form__controls", status ? `t-is-${status}` : void 0, status === "success" ? "t-form--success-border" : void 0],
|
|
202
|
-
onFocusin: handleFocusin
|
|
230
|
+
onFocusin: handleFocusin,
|
|
231
|
+
onFocusout: handleFocusout
|
|
203
232
|
}, [h("div", {
|
|
204
233
|
class: "t-form__controls-content"
|
|
205
234
|
}, [h(_sfc_main, {
|
|
206
235
|
config: component.value,
|
|
207
236
|
context: currentContext.value,
|
|
208
237
|
crudMode: props.formItem.crudMode
|
|
209
|
-
})]),
|
|
238
|
+
})]), validationTips.value ? h("div", {
|
|
210
239
|
class: ["t-tips", status ? `t-is-${status}` : "t-is-default"]
|
|
211
|
-
},
|
|
240
|
+
}, validationTips.value) : void 0]);
|
|
212
241
|
};
|
|
213
242
|
}
|
|
214
243
|
});
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
.qd-service-table[data-v-
|
|
1
|
+
.qd-service-table[data-v-ffc43b16] {
|
|
2
2
|
height: 100%;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
}
|
|
6
|
-
.qd-service-table[data-v-
|
|
6
|
+
.qd-service-table[data-v-ffc43b16] > .t-table__content {
|
|
7
7
|
flex: 1;
|
|
8
8
|
}
|
|
9
|
-
.qd-service-table--mini[data-v-
|
|
9
|
+
.qd-service-table--mini[data-v-ffc43b16] {
|
|
10
10
|
font: var(--td-font-body-small);
|
|
11
11
|
}
|
|
12
|
-
.qd-service-table--mini[data-v-
|
|
13
|
-
.qd-service-table--mini[data-v-
|
|
12
|
+
.qd-service-table--mini[data-v-ffc43b16] th,
|
|
13
|
+
.qd-service-table--mini[data-v-ffc43b16] tr:not(.t-table__expanded-row) > td {
|
|
14
14
|
padding: var(--td-comp-paddingTB-xxs) var(--td-comp-paddingLR-xxs);
|
|
15
15
|
line-height: var(--td-line-height-body-small);
|
|
16
16
|
}
|
|
17
|
-
.qd-service-table--mini[data-v-
|
|
17
|
+
.qd-service-table--mini[data-v-ffc43b16] .t-table__row-full-element {
|
|
18
18
|
padding: var(--td-comp-paddingTB-xs) var(--td-comp-paddingLR-s);
|
|
19
19
|
}
|
|
20
|
-
.qd-service-table--hide-empty-image[data-v-
|
|
20
|
+
.qd-service-table--hide-empty-image[data-v-ffc43b16] .t-table__empty {
|
|
21
21
|
min-height: auto;
|
|
22
22
|
}
|
|
23
|
-
.qd-service-table--hide-empty-image[data-v-
|
|
23
|
+
.qd-service-table--hide-empty-image[data-v-ffc43b16] .t-table__empty .t-empty {
|
|
24
24
|
padding: 0 !important;
|
|
25
25
|
}
|
|
26
|
-
.qd-service-table--hide-empty-image[data-v-
|
|
26
|
+
.qd-service-table--hide-empty-image[data-v-ffc43b16] .t-table__empty .t-empty__image {
|
|
27
27
|
display: none;
|
|
28
28
|
}
|
|
29
|
-
.qd-service-table--hide-empty-image[data-v-
|
|
29
|
+
.qd-service-table--hide-empty-image[data-v-ffc43b16] .t-table__empty .t-empty__title {
|
|
30
30
|
margin-top: 0;
|
|
31
31
|
}
|
|
32
|
-
.qd-service-table[data-v-
|
|
32
|
+
.qd-service-table[data-v-ffc43b16] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
|
|
33
33
|
margin-left: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
|
|
34
34
|
}
|
|
35
|
-
.qd-service-table[data-v-
|
|
35
|
+
.qd-service-table[data-v-ffc43b16] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
|
|
36
36
|
width: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
|
|
37
37
|
}
|
|
38
|
-
.qd-service-table[data-v-
|
|
39
|
-
.qd-service-table[data-v-
|
|
40
|
-
transform: var(--
|
|
38
|
+
.qd-service-table[data-v-ffc43b16] .t-affix > .t-table__affixed-header-elm-wrap,
|
|
39
|
+
.qd-service-table[data-v-ffc43b16] .t-affix > .t-table__scrollbar--obvious {
|
|
40
|
+
transform: var(--v366f53ea);
|
|
41
41
|
}
|
|
42
|
-
.qd-service-table--horizontal-bar-static[data-v-
|
|
42
|
+
.qd-service-table--horizontal-bar-static[data-v-ffc43b16] .t-table__scrollbar--obvious {
|
|
43
43
|
visibility: hidden;
|
|
44
44
|
pointer-events: none;
|
|
45
45
|
}
|
|
46
|
-
.qd-service-table[data-v-
|
|
46
|
+
.qd-service-table[data-v-ffc43b16] .t-table__expanded-row .qd-service-table--horizontal-bar-static > div:has(> div > .t-table__scrollbar--obvious) {
|
|
47
47
|
display: none;
|
|
48
48
|
}
|
|
49
|
-
.qd-service-table[data-v-
|
|
49
|
+
.qd-service-table[data-v-ffc43b16] .t-table__expanded-row > td {
|
|
50
50
|
height: 0;
|
|
51
51
|
}
|
|
52
|
-
.qd-service-table[data-v-
|
|
52
|
+
.qd-service-table[data-v-ffc43b16] .t-table__affixed-header-elm-wrap {
|
|
53
53
|
height: auto !important;
|
|
54
54
|
}
|
|
55
|
-
.qd-service-table[data-v-
|
|
55
|
+
.qd-service-table[data-v-ffc43b16] .t-table__affixed-header-elm {
|
|
56
56
|
position: relative;
|
|
57
57
|
scrollbar-width: none;
|
|
58
58
|
}
|
|
59
|
-
.qd-service-table[data-v-
|
|
59
|
+
.qd-service-table[data-v-ffc43b16] .t-table__affixed-header-elm::-webkit-scrollbar {
|
|
60
60
|
display: none;
|
|
61
61
|
width: 0;
|
|
62
62
|
height: 0;
|
|
63
63
|
}
|
|
64
|
-
.qd-service-table[data-v-
|
|
64
|
+
.qd-service-table[data-v-ffc43b16] .t-table__virtual-scroll-cursor + table {
|
|
65
65
|
border-collapse: separate;
|
|
66
66
|
}
|
|
67
|
-
.qd-service-table[data-v-
|
|
67
|
+
.qd-service-table[data-v-ffc43b16] .t-table__expanded-row-inner {
|
|
68
68
|
display: block;
|
|
69
69
|
position: sticky;
|
|
70
70
|
left: 0;
|
|
71
|
-
width: var(--
|
|
71
|
+
width: var(--v12b6b140) !important;
|
|
72
72
|
}
|
|
73
|
-
.qd-service-table[data-v-
|
|
73
|
+
.qd-service-table[data-v-ffc43b16] .t-table__cell-wrap > .t-form__controls > .t-form__controls-content > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
|
|
74
74
|
width: 100%;
|
|
75
75
|
}
|
|
76
|
-
.qd-service-table[data-v-
|
|
76
|
+
.qd-service-table[data-v-ffc43b16] .qd-service-table__non-editable-col {
|
|
77
77
|
background-color: color-mix(in srgb, var(--td-bg-color-component) 50%, transparent);
|
|
78
78
|
}
|
|
79
|
-
.qd-service-table[data-v-
|
|
79
|
+
.qd-service-table[data-v-ffc43b16] .qd-service-table__non-editable-col:is(
|
|
80
80
|
.t-table__cell--fixed-left,
|
|
81
81
|
.t-table__cell--fixed-right
|
|
82
82
|
) {
|
|
83
83
|
background-color: inherit;
|
|
84
84
|
background-image: linear-gradient(color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent), color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent));
|
|
85
85
|
}
|
|
86
|
-
.qd-service-table--disable-horizontal-scroll[data-v-
|
|
86
|
+
.qd-service-table--disable-horizontal-scroll[data-v-ffc43b16] colgroup > col {
|
|
87
87
|
width: auto !important;
|
|
88
88
|
}
|
|
@@ -2,7 +2,7 @@ import './index.css'
|
|
|
2
2
|
import _sfc_main from "./index.vue2.mjs";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
|
|
5
|
-
const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
5
|
+
const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ffc43b16"]]);
|
|
6
6
|
export {
|
|
7
7
|
QdServiceTable as default
|
|
8
8
|
};
|
|
@@ -324,8 +324,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
324
324
|
emit: __emit
|
|
325
325
|
}) {
|
|
326
326
|
useCssVars((_ctx) => ({
|
|
327
|
-
"
|
|
328
|
-
"
|
|
327
|
+
"v366f53ea": affixedHeaderTransform.value,
|
|
328
|
+
"v12b6b140": expandedRowWidth.value
|
|
329
329
|
}));
|
|
330
330
|
const props = __props;
|
|
331
331
|
const emit = __emit;
|
|
@@ -379,6 +379,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
379
379
|
const treeLoadIds = ref([]);
|
|
380
380
|
const editingCells = shallowRef([]);
|
|
381
381
|
const activeEditingCell = shallowRef();
|
|
382
|
+
const autofocusEditingCell = shallowRef();
|
|
383
|
+
const editingCellValidationErrors = shallowRef(/* @__PURE__ */ new Map());
|
|
382
384
|
const expandedRowProxyMap = /* @__PURE__ */ new WeakMap();
|
|
383
385
|
let dataChangePending = false;
|
|
384
386
|
const {
|
|
@@ -577,6 +579,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
577
579
|
...scrollOptions
|
|
578
580
|
} : scroll;
|
|
579
581
|
const reTableOptions = tableOptions;
|
|
582
|
+
const onValidate = reTableOptions.onValidate;
|
|
583
|
+
const onRowValidate = reTableOptions.onRowValidate;
|
|
584
|
+
reTableOptions.onValidate = (context) => {
|
|
585
|
+
replaceTableValidationErrors(context.result);
|
|
586
|
+
onValidate?.(context);
|
|
587
|
+
};
|
|
588
|
+
reTableOptions.onRowValidate = (context) => {
|
|
589
|
+
syncCellValidationErrors(context.result);
|
|
590
|
+
onRowValidate?.(context);
|
|
591
|
+
};
|
|
580
592
|
const expandedRow = reTableOptions.expandedRow;
|
|
581
593
|
if (expandedRow) {
|
|
582
594
|
reTableOptions.expandedRow = (h2, context) => expandedRow(h2, {
|
|
@@ -1012,6 +1024,74 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1012
1024
|
function getCellKey(row, colKey) {
|
|
1013
1025
|
return `${String(getRowValue(row))}__${String(colKey)}`;
|
|
1014
1026
|
}
|
|
1027
|
+
function syncCellValidationErrors(results) {
|
|
1028
|
+
if (!results.length) return;
|
|
1029
|
+
const nextErrors = new Map(editingCellValidationErrors.value);
|
|
1030
|
+
for (const result of results) {
|
|
1031
|
+
const rowValue = getRowValue(result.row);
|
|
1032
|
+
const colKey = String(result.col.colKey);
|
|
1033
|
+
const rowErrors = new Map(nextErrors.get(rowValue));
|
|
1034
|
+
if (result.errorList.length) rowErrors.set(colKey, result.errorList);
|
|
1035
|
+
else rowErrors.delete(colKey);
|
|
1036
|
+
if (rowErrors.size) nextErrors.set(rowValue, rowErrors);
|
|
1037
|
+
else nextErrors.delete(rowValue);
|
|
1038
|
+
}
|
|
1039
|
+
editingCellValidationErrors.value = nextErrors;
|
|
1040
|
+
}
|
|
1041
|
+
function replaceTableValidationErrors(result) {
|
|
1042
|
+
const nextErrors = /* @__PURE__ */ new Map();
|
|
1043
|
+
for (const row of data.value) {
|
|
1044
|
+
const rowValue = getRowValue(row);
|
|
1045
|
+
const rowErrors = /* @__PURE__ */ new Map();
|
|
1046
|
+
for (const {
|
|
1047
|
+
column
|
|
1048
|
+
} of editableColumns.value) {
|
|
1049
|
+
const colKey = String(column.colKey);
|
|
1050
|
+
const errors = result[getCellKey(row, colKey)] ?? result[`${String(rowValue)}_${colKey}`];
|
|
1051
|
+
if (errors?.length) rowErrors.set(colKey, errors);
|
|
1052
|
+
}
|
|
1053
|
+
if (rowErrors.size) nextErrors.set(rowValue, rowErrors);
|
|
1054
|
+
}
|
|
1055
|
+
editingCellValidationErrors.value = nextErrors;
|
|
1056
|
+
}
|
|
1057
|
+
function replaceRowValidationErrors(rowValue, results) {
|
|
1058
|
+
const nextErrors = new Map(editingCellValidationErrors.value);
|
|
1059
|
+
const rowErrors = /* @__PURE__ */ new Map();
|
|
1060
|
+
for (const result of results) {
|
|
1061
|
+
if (!result.errorList.length) continue;
|
|
1062
|
+
rowErrors.set(String(result.col.colKey), result.errorList);
|
|
1063
|
+
}
|
|
1064
|
+
if (rowErrors.size) nextErrors.set(rowValue, rowErrors);
|
|
1065
|
+
else nextErrors.delete(rowValue);
|
|
1066
|
+
editingCellValidationErrors.value = nextErrors;
|
|
1067
|
+
}
|
|
1068
|
+
function pruneCellValidationErrors(rows) {
|
|
1069
|
+
const currentErrors = editingCellValidationErrors.value;
|
|
1070
|
+
if (!currentErrors.size) return;
|
|
1071
|
+
const validColKeys = new Set(editableColumns.value.map(({
|
|
1072
|
+
column
|
|
1073
|
+
}) => String(column.colKey)));
|
|
1074
|
+
const validErrorRows = /* @__PURE__ */ new Set();
|
|
1075
|
+
for (const row of rows) {
|
|
1076
|
+
const rowValue = getRowValue(row);
|
|
1077
|
+
if (!currentErrors.has(rowValue)) continue;
|
|
1078
|
+
validErrorRows.add(rowValue);
|
|
1079
|
+
if (validErrorRows.size === currentErrors.size) break;
|
|
1080
|
+
}
|
|
1081
|
+
let changed = false;
|
|
1082
|
+
const nextErrors = /* @__PURE__ */ new Map();
|
|
1083
|
+
for (const [rowValue, rowErrors] of currentErrors) {
|
|
1084
|
+
if (!validErrorRows.has(rowValue)) {
|
|
1085
|
+
changed = true;
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
const validRowErrors = new Map([...rowErrors].filter(([colKey]) => validColKeys.has(colKey)));
|
|
1089
|
+
if (validRowErrors.size !== rowErrors.size) changed = true;
|
|
1090
|
+
if (validRowErrors.size) nextErrors.set(rowValue, validRowErrors);
|
|
1091
|
+
}
|
|
1092
|
+
if (!changed) return;
|
|
1093
|
+
editingCellValidationErrors.value = nextErrors;
|
|
1094
|
+
}
|
|
1015
1095
|
function isSameEditingCell(first, second) {
|
|
1016
1096
|
return getRowValue(first.row) === getRowValue(second.row) && first.colKey === second.colKey;
|
|
1017
1097
|
}
|
|
@@ -1060,9 +1140,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1060
1140
|
}
|
|
1061
1141
|
function removeEditingCell(target) {
|
|
1062
1142
|
editingCells.value = editingCells.value.filter((item) => !isSameEditingCell(item, target));
|
|
1143
|
+
clearAutofocusEditingCell(target);
|
|
1063
1144
|
if (!activeEditingCell.value || !isSameEditingCell(activeEditingCell.value, target)) return;
|
|
1064
1145
|
activeEditingCell.value = editingCells.value.at(-1);
|
|
1065
1146
|
}
|
|
1147
|
+
function clearAutofocusEditingCell(target) {
|
|
1148
|
+
if (!autofocusEditingCell.value || !isSameEditingCell(autofocusEditingCell.value, target)) {
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
autofocusEditingCell.value = void 0;
|
|
1152
|
+
}
|
|
1066
1153
|
let suppressEnterCellKey = null;
|
|
1067
1154
|
async function exitEditingCell(target) {
|
|
1068
1155
|
const cellKey = getCellKey(target.row, target.colKey);
|
|
@@ -1081,14 +1168,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1081
1168
|
if (suppressEnterCellKey === cellKey) suppressEnterCellKey = null;
|
|
1082
1169
|
}, 0);
|
|
1083
1170
|
}
|
|
1084
|
-
function enterEditingCell(target) {
|
|
1171
|
+
function enterEditingCell(target, autofocus = true) {
|
|
1085
1172
|
const currentActiveCell = activeEditingCell.value;
|
|
1086
1173
|
if (currentActiveCell && !isSameEditingCell(currentActiveCell, target)) {
|
|
1174
|
+
clearAutofocusEditingCell(currentActiveCell);
|
|
1087
1175
|
void exitEditingCell(currentActiveCell);
|
|
1088
1176
|
}
|
|
1089
1177
|
const editingCell = findEditingCell(target.row, target.colKey);
|
|
1090
1178
|
if (!editingCell) editingCells.value = [...editingCells.value, target];
|
|
1091
1179
|
activeEditingCell.value = editingCell ?? target;
|
|
1180
|
+
if (autofocus) autofocusEditingCell.value = activeEditingCell.value;
|
|
1092
1181
|
}
|
|
1093
1182
|
async function exitAllEditingCells() {
|
|
1094
1183
|
for (const editingCell of [...editingCells.value]) {
|
|
@@ -1103,7 +1192,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1103
1192
|
const column = context.col;
|
|
1104
1193
|
if (column.formItem) {
|
|
1105
1194
|
const editingCell = findEditingCell(context.row, column.colKey);
|
|
1106
|
-
if (editingCell)
|
|
1195
|
+
if (editingCell) enterEditingCell(editingCell, false);
|
|
1107
1196
|
else exitActiveEditingCell();
|
|
1108
1197
|
return;
|
|
1109
1198
|
}
|
|
@@ -1429,9 +1518,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1429
1518
|
}
|
|
1430
1519
|
async function validateTableData(params) {
|
|
1431
1520
|
const result = isVirtualScroll.value ? await serializeOffscreen(() => validateTableViaOffscreenForm()) : (await tableRef.value?.validateTableData())?.result ?? {};
|
|
1432
|
-
if (isVirtualScroll.value)
|
|
1433
|
-
result
|
|
1434
|
-
|
|
1521
|
+
if (isVirtualScroll.value) {
|
|
1522
|
+
replaceTableValidationErrors(result);
|
|
1523
|
+
props.onValidate?.({
|
|
1524
|
+
result
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1435
1527
|
const cellResults = resolveValidationResults(result);
|
|
1436
1528
|
const context = {
|
|
1437
1529
|
result,
|
|
@@ -1444,10 +1536,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1444
1536
|
}
|
|
1445
1537
|
async function validateRowData(rowValue, params) {
|
|
1446
1538
|
const result = isVirtualScroll.value ? await serializeOffscreen(() => validateSingleRowViaOffscreenForm(rowValue)) : (await tableRef.value?.validateRowData(rowValue))?.result ?? [];
|
|
1447
|
-
if (isVirtualScroll.value)
|
|
1448
|
-
result
|
|
1449
|
-
|
|
1450
|
-
|
|
1539
|
+
if (isVirtualScroll.value) {
|
|
1540
|
+
replaceRowValidationErrors(rowValue, result);
|
|
1541
|
+
props.onRowValidate?.({
|
|
1542
|
+
result,
|
|
1543
|
+
trigger: "parent"
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1451
1546
|
const context = {
|
|
1452
1547
|
result,
|
|
1453
1548
|
trigger: "parent",
|
|
@@ -1623,6 +1718,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1623
1718
|
row,
|
|
1624
1719
|
colKey
|
|
1625
1720
|
}),
|
|
1721
|
+
autofocus: !!autofocusEditingCell.value && isSameEditingCell(autofocusEditingCell.value, {
|
|
1722
|
+
row,
|
|
1723
|
+
colKey
|
|
1724
|
+
}),
|
|
1725
|
+
validationErrors: editingCellValidationErrors.value.get(getRowValue(row))?.get(String(colKey)),
|
|
1626
1726
|
renderCell: () => renderDisplayCell(h, column, cellContext),
|
|
1627
1727
|
activate: () => {
|
|
1628
1728
|
if (suppressEnterCellKey === getCellKey(row, colKey)) return;
|
|
@@ -1631,6 +1731,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1631
1731
|
colKey
|
|
1632
1732
|
});
|
|
1633
1733
|
},
|
|
1734
|
+
consumeAutofocus: () => clearAutofocusEditingCell({
|
|
1735
|
+
row,
|
|
1736
|
+
colKey
|
|
1737
|
+
}),
|
|
1634
1738
|
registerBeforeSubmit: registerBeforeSubmitQueue
|
|
1635
1739
|
};
|
|
1636
1740
|
}
|
|
@@ -1878,6 +1982,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1878
1982
|
watch(expandedTreeNodes, adjustScrollWhenTreeExpanded, {
|
|
1879
1983
|
flush: "post"
|
|
1880
1984
|
});
|
|
1985
|
+
watch(data, pruneCellValidationErrors);
|
|
1881
1986
|
watch(tableContentVisible, (visible) => {
|
|
1882
1987
|
if (!visible) return;
|
|
1883
1988
|
watchAnimatingTransformAncestor();
|