@deot/vc 1.0.69 → 1.0.70
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/index.d.ts +52 -2
- package/dist/index.iife.js +191 -22
- package/dist/index.umd.cjs +191 -22
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1011,6 +1011,7 @@ export declare const Components: {
|
|
|
1011
1011
|
};
|
|
1012
1012
|
renderOption: Render;
|
|
1013
1013
|
renderOptionGroup: Render;
|
|
1014
|
+
renderLabel: Render;
|
|
1014
1015
|
searchPlaceholder: {
|
|
1015
1016
|
type: StringConstructor;
|
|
1016
1017
|
default: string;
|
|
@@ -1097,6 +1098,7 @@ export declare const Components: {
|
|
|
1097
1098
|
};
|
|
1098
1099
|
renderOption: Render;
|
|
1099
1100
|
renderOptionGroup: Render;
|
|
1101
|
+
renderLabel: Render;
|
|
1100
1102
|
searchPlaceholder: {
|
|
1101
1103
|
type: StringConstructor;
|
|
1102
1104
|
default: string;
|
|
@@ -1209,6 +1211,7 @@ export declare const Components: {
|
|
|
1209
1211
|
};
|
|
1210
1212
|
renderOption: Render;
|
|
1211
1213
|
renderOptionGroup: Render;
|
|
1214
|
+
renderLabel: Render;
|
|
1212
1215
|
searchPlaceholder: {
|
|
1213
1216
|
type: StringConstructor;
|
|
1214
1217
|
default: string;
|
|
@@ -1295,6 +1298,7 @@ export declare const Components: {
|
|
|
1295
1298
|
};
|
|
1296
1299
|
renderOption: Render;
|
|
1297
1300
|
renderOptionGroup: Render;
|
|
1301
|
+
renderLabel: Render;
|
|
1298
1302
|
searchPlaceholder: {
|
|
1299
1303
|
type: StringConstructor;
|
|
1300
1304
|
default: string;
|
|
@@ -9813,6 +9817,7 @@ export declare const Components: {
|
|
|
9813
9817
|
Select: DefineComponent<ExtractPropTypes< {
|
|
9814
9818
|
renderOption: Render;
|
|
9815
9819
|
renderOptionGroup: Render;
|
|
9820
|
+
renderLabel: Render;
|
|
9816
9821
|
data: {
|
|
9817
9822
|
type: ArrayConstructor;
|
|
9818
9823
|
default: () => never[];
|
|
@@ -9891,6 +9896,7 @@ export declare const Components: {
|
|
|
9891
9896
|
}>, () => JSX.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("clear" | "change" | "close" | "ready" | "update:modelValue" | "visible-change")[], "clear" | "change" | "close" | "ready" | "update:modelValue" | "visible-change", PublicProps, Readonly<ExtractPropTypes< {
|
|
9892
9897
|
renderOption: Render;
|
|
9893
9898
|
renderOptionGroup: Render;
|
|
9899
|
+
renderLabel: Render;
|
|
9894
9900
|
data: {
|
|
9895
9901
|
type: ArrayConstructor;
|
|
9896
9902
|
default: () => never[];
|
|
@@ -9994,6 +10000,7 @@ export declare const Components: {
|
|
|
9994
10000
|
MSelect: DefineComponent<ExtractPropTypes< {
|
|
9995
10001
|
renderOption: Render;
|
|
9996
10002
|
renderOptionGroup: Render;
|
|
10003
|
+
renderLabel: Render;
|
|
9997
10004
|
data: {
|
|
9998
10005
|
type: ArrayConstructor;
|
|
9999
10006
|
default: () => never[];
|
|
@@ -10072,6 +10079,7 @@ export declare const Components: {
|
|
|
10072
10079
|
}>, () => JSX.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("clear" | "change" | "close" | "ready" | "update:modelValue" | "visible-change")[], "clear" | "change" | "close" | "ready" | "update:modelValue" | "visible-change", PublicProps, Readonly<ExtractPropTypes< {
|
|
10073
10080
|
renderOption: Render;
|
|
10074
10081
|
renderOptionGroup: Render;
|
|
10082
|
+
renderLabel: Render;
|
|
10075
10083
|
data: {
|
|
10076
10084
|
type: ArrayConstructor;
|
|
10077
10085
|
default: () => never[];
|
|
@@ -10596,7 +10604,15 @@ export declare const Components: {
|
|
|
10596
10604
|
type: BooleanConstructor;
|
|
10597
10605
|
default: undefined;
|
|
10598
10606
|
};
|
|
10599
|
-
|
|
10607
|
+
affix: {
|
|
10608
|
+
type: (ObjectConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
10609
|
+
default: boolean;
|
|
10610
|
+
};
|
|
10611
|
+
columns: {
|
|
10612
|
+
type: ArrayConstructor;
|
|
10613
|
+
default: () => never[];
|
|
10614
|
+
};
|
|
10615
|
+
}>, () => JSX.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("select" | "select-all" | "selection-change" | "expand-change" | "current-change" | "update:columns" | "cell-mouse-enter" | "cell-mouse-leave" | "header-click" | "header-contextmenu" | "update:sort" | "sort-change" | "header-dragend" | "cell-click" | "cell-dblclick" | "row-click" | "row-contextmenu" | "row-dblclick")[], "select" | "select-all" | "selection-change" | "expand-change" | "current-change" | "update:columns" | "cell-mouse-enter" | "cell-mouse-leave" | "header-click" | "header-contextmenu" | "update:sort" | "sort-change" | "header-dragend" | "cell-click" | "cell-dblclick" | "row-click" | "row-contextmenu" | "row-dblclick", PublicProps, Readonly<ExtractPropTypes< {
|
|
10600
10616
|
data: {
|
|
10601
10617
|
type: ArrayConstructor;
|
|
10602
10618
|
default: () => never[];
|
|
@@ -10672,12 +10688,21 @@ export declare const Components: {
|
|
|
10672
10688
|
type: BooleanConstructor;
|
|
10673
10689
|
default: undefined;
|
|
10674
10690
|
};
|
|
10691
|
+
affix: {
|
|
10692
|
+
type: (ObjectConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
10693
|
+
default: boolean;
|
|
10694
|
+
};
|
|
10695
|
+
columns: {
|
|
10696
|
+
type: ArrayConstructor;
|
|
10697
|
+
default: () => never[];
|
|
10698
|
+
};
|
|
10675
10699
|
}>> & Readonly<{
|
|
10676
10700
|
onSelect?: ((...args: any[]) => any) | undefined;
|
|
10677
10701
|
"onSelect-all"?: ((...args: any[]) => any) | undefined;
|
|
10678
10702
|
"onSelection-change"?: ((...args: any[]) => any) | undefined;
|
|
10679
10703
|
"onExpand-change"?: ((...args: any[]) => any) | undefined;
|
|
10680
10704
|
"onCurrent-change"?: ((...args: any[]) => any) | undefined;
|
|
10705
|
+
"onUpdate:columns"?: ((...args: any[]) => any) | undefined;
|
|
10681
10706
|
"onCell-mouse-enter"?: ((...args: any[]) => any) | undefined;
|
|
10682
10707
|
"onCell-mouse-leave"?: ((...args: any[]) => any) | undefined;
|
|
10683
10708
|
"onHeader-click"?: ((...args: any[]) => any) | undefined;
|
|
@@ -10695,6 +10720,7 @@ export declare const Components: {
|
|
|
10695
10720
|
resizable: boolean;
|
|
10696
10721
|
data: unknown[];
|
|
10697
10722
|
border: boolean;
|
|
10723
|
+
columns: unknown[];
|
|
10698
10724
|
lazy: boolean;
|
|
10699
10725
|
highlight: boolean;
|
|
10700
10726
|
placeholder: string | Function;
|
|
@@ -10709,6 +10735,7 @@ export declare const Components: {
|
|
|
10709
10735
|
divider: boolean;
|
|
10710
10736
|
showSummary: boolean;
|
|
10711
10737
|
treeMap: Record<string, any>;
|
|
10738
|
+
affix: boolean | unknown[] | Record<string, any>;
|
|
10712
10739
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
10713
10740
|
MTable: DefineComponent<ExtractPropTypes< {
|
|
10714
10741
|
data: {
|
|
@@ -10786,7 +10813,15 @@ export declare const Components: {
|
|
|
10786
10813
|
type: BooleanConstructor;
|
|
10787
10814
|
default: undefined;
|
|
10788
10815
|
};
|
|
10789
|
-
|
|
10816
|
+
affix: {
|
|
10817
|
+
type: (ObjectConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
10818
|
+
default: boolean;
|
|
10819
|
+
};
|
|
10820
|
+
columns: {
|
|
10821
|
+
type: ArrayConstructor;
|
|
10822
|
+
default: () => never[];
|
|
10823
|
+
};
|
|
10824
|
+
}>, () => JSX.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("select" | "select-all" | "selection-change" | "expand-change" | "current-change" | "update:columns" | "cell-mouse-enter" | "cell-mouse-leave" | "header-click" | "header-contextmenu" | "update:sort" | "sort-change" | "header-dragend" | "cell-click" | "cell-dblclick" | "row-click" | "row-contextmenu" | "row-dblclick")[], "select" | "select-all" | "selection-change" | "expand-change" | "current-change" | "update:columns" | "cell-mouse-enter" | "cell-mouse-leave" | "header-click" | "header-contextmenu" | "update:sort" | "sort-change" | "header-dragend" | "cell-click" | "cell-dblclick" | "row-click" | "row-contextmenu" | "row-dblclick", PublicProps, Readonly<ExtractPropTypes< {
|
|
10790
10825
|
data: {
|
|
10791
10826
|
type: ArrayConstructor;
|
|
10792
10827
|
default: () => never[];
|
|
@@ -10862,12 +10897,21 @@ export declare const Components: {
|
|
|
10862
10897
|
type: BooleanConstructor;
|
|
10863
10898
|
default: undefined;
|
|
10864
10899
|
};
|
|
10900
|
+
affix: {
|
|
10901
|
+
type: (ObjectConstructor | BooleanConstructor | ArrayConstructor)[];
|
|
10902
|
+
default: boolean;
|
|
10903
|
+
};
|
|
10904
|
+
columns: {
|
|
10905
|
+
type: ArrayConstructor;
|
|
10906
|
+
default: () => never[];
|
|
10907
|
+
};
|
|
10865
10908
|
}>> & Readonly<{
|
|
10866
10909
|
onSelect?: ((...args: any[]) => any) | undefined;
|
|
10867
10910
|
"onSelect-all"?: ((...args: any[]) => any) | undefined;
|
|
10868
10911
|
"onSelection-change"?: ((...args: any[]) => any) | undefined;
|
|
10869
10912
|
"onExpand-change"?: ((...args: any[]) => any) | undefined;
|
|
10870
10913
|
"onCurrent-change"?: ((...args: any[]) => any) | undefined;
|
|
10914
|
+
"onUpdate:columns"?: ((...args: any[]) => any) | undefined;
|
|
10871
10915
|
"onCell-mouse-enter"?: ((...args: any[]) => any) | undefined;
|
|
10872
10916
|
"onCell-mouse-leave"?: ((...args: any[]) => any) | undefined;
|
|
10873
10917
|
"onHeader-click"?: ((...args: any[]) => any) | undefined;
|
|
@@ -10885,6 +10929,7 @@ export declare const Components: {
|
|
|
10885
10929
|
resizable: boolean;
|
|
10886
10930
|
data: unknown[];
|
|
10887
10931
|
border: boolean;
|
|
10932
|
+
columns: unknown[];
|
|
10888
10933
|
lazy: boolean;
|
|
10889
10934
|
highlight: boolean;
|
|
10890
10935
|
placeholder: string | Function;
|
|
@@ -10899,6 +10944,7 @@ export declare const Components: {
|
|
|
10899
10944
|
divider: boolean;
|
|
10900
10945
|
showSummary: boolean;
|
|
10901
10946
|
treeMap: Record<string, any>;
|
|
10947
|
+
affix: boolean | unknown[] | Record<string, any>;
|
|
10902
10948
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
10903
10949
|
TableColumn: DefineComponent<ExtractPropTypes< {
|
|
10904
10950
|
type: {
|
|
@@ -13725,6 +13771,7 @@ export declare const Components: {
|
|
|
13725
13771
|
renderNodeLabel: Render;
|
|
13726
13772
|
renderOption: Render;
|
|
13727
13773
|
renderOptionGroup: Render;
|
|
13774
|
+
renderLabel: Render;
|
|
13728
13775
|
searchPlaceholder: {
|
|
13729
13776
|
type: StringConstructor;
|
|
13730
13777
|
default: string;
|
|
@@ -13812,6 +13859,7 @@ export declare const Components: {
|
|
|
13812
13859
|
renderNodeLabel: Render;
|
|
13813
13860
|
renderOption: Render;
|
|
13814
13861
|
renderOptionGroup: Render;
|
|
13862
|
+
renderLabel: Render;
|
|
13815
13863
|
searchPlaceholder: {
|
|
13816
13864
|
type: StringConstructor;
|
|
13817
13865
|
default: string;
|
|
@@ -13926,6 +13974,7 @@ export declare const Components: {
|
|
|
13926
13974
|
renderNodeLabel: Render;
|
|
13927
13975
|
renderOption: Render;
|
|
13928
13976
|
renderOptionGroup: Render;
|
|
13977
|
+
renderLabel: Render;
|
|
13929
13978
|
searchPlaceholder: {
|
|
13930
13979
|
type: StringConstructor;
|
|
13931
13980
|
default: string;
|
|
@@ -14013,6 +14062,7 @@ export declare const Components: {
|
|
|
14013
14062
|
renderNodeLabel: Render;
|
|
14014
14063
|
renderOption: Render;
|
|
14015
14064
|
renderOptionGroup: Render;
|
|
14065
|
+
renderLabel: Render;
|
|
14016
14066
|
searchPlaceholder: {
|
|
14017
14067
|
type: StringConstructor;
|
|
14018
14068
|
default: string;
|
package/dist/index.iife.js
CHANGED
|
@@ -111429,6 +111429,7 @@ ${p}
|
|
|
111429
111429
|
...pick(props$81, inputKeys$2),
|
|
111430
111430
|
renderOption: [Function],
|
|
111431
111431
|
renderOptionGroup: [Function],
|
|
111432
|
+
renderLabel: [Function],
|
|
111432
111433
|
data: {
|
|
111433
111434
|
type: Array,
|
|
111434
111435
|
default: () => []
|
|
@@ -119075,10 +119076,11 @@ ${p}
|
|
|
119075
119076
|
const onLoaded = (ctx) => {
|
|
119076
119077
|
ctx?.destroy?.();
|
|
119077
119078
|
};
|
|
119078
|
-
const toDataURL = async () => {
|
|
119079
|
+
const toDataURL = async (type = "svg") => {
|
|
119079
119080
|
const loadContext = onLoad();
|
|
119080
119081
|
try {
|
|
119081
119082
|
await refresh();
|
|
119083
|
+
if (type === "png") return (await snapshot.value.toPng()).src;
|
|
119082
119084
|
return snapshot.value.toRaw();
|
|
119083
119085
|
} finally {
|
|
119084
119086
|
onLoaded(loadContext);
|
|
@@ -119104,7 +119106,7 @@ ${p}
|
|
|
119104
119106
|
skip$ = typeof v === "undefined" ? true : !!v;
|
|
119105
119107
|
return v;
|
|
119106
119108
|
}).finally(() => done(skip$));
|
|
119107
|
-
return;
|
|
119109
|
+
return skip;
|
|
119108
119110
|
}
|
|
119109
119111
|
done(skip);
|
|
119110
119112
|
};
|
|
@@ -120723,6 +120725,7 @@ ${p}
|
|
|
120723
120725
|
default: true
|
|
120724
120726
|
},
|
|
120725
120727
|
render: [Function],
|
|
120728
|
+
renderLabel: [Function],
|
|
120726
120729
|
row: Object
|
|
120727
120730
|
},
|
|
120728
120731
|
setup(props, { slots, expose }) {
|
|
@@ -120782,7 +120785,7 @@ ${p}
|
|
|
120782
120785
|
}, "vc-select-option"],
|
|
120783
120786
|
"onClick": (0, vue.withModifiers)(handleClick, ["stop"]),
|
|
120784
120787
|
"onMousedown": handlePrevent
|
|
120785
|
-
}, [formatterLabel.value, isChecked.value && (0, vue.createVNode)(Icon, { "type": "correct" }, null)]);
|
|
120788
|
+
}, [typeof props.renderLabel === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.renderLabel }, customOptions.value), null) : slots.label ? slots.label(customOptions.value) : formatterLabel.value, isChecked.value && (0, vue.createVNode)(Icon, { "type": "correct" }, null)]);
|
|
120786
120789
|
};
|
|
120787
120790
|
}
|
|
120788
120791
|
});
|
|
@@ -120795,17 +120798,21 @@ ${p}
|
|
|
120795
120798
|
},
|
|
120796
120799
|
label: { type: [String, Number] },
|
|
120797
120800
|
row: Object,
|
|
120798
|
-
render: [Function]
|
|
120801
|
+
render: [Function],
|
|
120802
|
+
renderLabel: [Function]
|
|
120799
120803
|
},
|
|
120800
120804
|
setup(props, { slots }) {
|
|
120801
120805
|
const formatterLabel = (0, vue.computed)(() => {
|
|
120802
120806
|
return String(props.label || props.value).trim();
|
|
120803
120807
|
});
|
|
120804
120808
|
const customOptions = (0, vue.computed)(() => {
|
|
120805
|
-
return {
|
|
120809
|
+
return {
|
|
120810
|
+
row: props.row,
|
|
120811
|
+
store: { group: true }
|
|
120812
|
+
};
|
|
120806
120813
|
});
|
|
120807
120814
|
return () => {
|
|
120808
|
-
return (0, vue.createVNode)("div", { "class": "vc-select-option-group" }, [typeof props.render === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.render }, customOptions.value), null) : slots.
|
|
120815
|
+
return (0, vue.createVNode)("div", { "class": "vc-select-option-group" }, [typeof props.render === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.render }, customOptions.value), null) : slots.optionGroup ? slots.optionGroup(customOptions.value) : (0, vue.createVNode)("div", { "class": "vc-select-option-group__title" }, [typeof props.renderLabel === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.renderLabel }, customOptions.value), null) : slots.label ? slots.label(customOptions.value) : formatterLabel.value]), (0, vue.createVNode)("div", null, [slots?.default?.()])]);
|
|
120809
120816
|
};
|
|
120810
120817
|
}
|
|
120811
120818
|
});
|
|
@@ -121074,7 +121081,8 @@ ${p}
|
|
|
121074
121081
|
"key": item.value,
|
|
121075
121082
|
"render": props.renderOptionGroup
|
|
121076
121083
|
}, {
|
|
121077
|
-
|
|
121084
|
+
optionGroup: slots?.optionGroup,
|
|
121085
|
+
label: slots?.label,
|
|
121078
121086
|
default: () => {
|
|
121079
121087
|
return item.children.map(($item) => {
|
|
121080
121088
|
return (0, vue.createVNode)(Option$1, {
|
|
@@ -121085,8 +121093,12 @@ ${p}
|
|
|
121085
121093
|
"label": $item.label,
|
|
121086
121094
|
"disabled": $item.disabled,
|
|
121087
121095
|
"filterable": $item.filterable,
|
|
121088
|
-
"render": props.renderOption
|
|
121089
|
-
|
|
121096
|
+
"render": props.renderOption,
|
|
121097
|
+
"renderLabel": props.renderLabel
|
|
121098
|
+
}, {
|
|
121099
|
+
default: slots?.option,
|
|
121100
|
+
label: slots?.label
|
|
121101
|
+
});
|
|
121090
121102
|
});
|
|
121091
121103
|
}
|
|
121092
121104
|
}) : (0, vue.createVNode)(Option$1, {
|
|
@@ -121097,8 +121109,12 @@ ${p}
|
|
|
121097
121109
|
"label": item.label,
|
|
121098
121110
|
"disabled": item.disabled,
|
|
121099
121111
|
"filterable": item.filterable,
|
|
121100
|
-
"render": props.renderOption
|
|
121101
|
-
|
|
121112
|
+
"render": props.renderOption,
|
|
121113
|
+
"renderLabel": props.renderLabel
|
|
121114
|
+
}, {
|
|
121115
|
+
default: slots?.option,
|
|
121116
|
+
label: slots?.label
|
|
121117
|
+
});
|
|
121102
121118
|
})]) : slots?.default?.()] })
|
|
121103
121119
|
]);
|
|
121104
121120
|
}
|
|
@@ -123926,6 +123942,10 @@ ${p}
|
|
|
123926
123942
|
expand;
|
|
123927
123943
|
tree;
|
|
123928
123944
|
layout;
|
|
123945
|
+
_columnsSync = {
|
|
123946
|
+
snapshot: [],
|
|
123947
|
+
suppressWatch: false
|
|
123948
|
+
};
|
|
123929
123949
|
flatData = (0, vue.computed)(() => {
|
|
123930
123950
|
if (this.table.props.expandSelectable) return concat(flattenData(this.states.data, {
|
|
123931
123951
|
parent: true,
|
|
@@ -124062,13 +124082,13 @@ ${p}
|
|
|
124062
124082
|
updateColumns() {
|
|
124063
124083
|
const { states } = this;
|
|
124064
124084
|
const _columns = states._columns || [];
|
|
124065
|
-
|
|
124066
|
-
|
|
124067
|
-
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
124068
|
-
_columns[0].fixed = true;
|
|
124069
|
-
leftFixedColumns.unshift(_columns[0]);
|
|
124085
|
+
if (_columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
124086
|
+
if (_columns.some((column) => column.fixed === true || column.fixed === "left")) _columns[0].fixed = true;
|
|
124070
124087
|
}
|
|
124071
|
-
const
|
|
124088
|
+
const visibleColumns = this.cloneVisibleTree(_columns);
|
|
124089
|
+
const leftFixedColumns = visibleColumns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
124090
|
+
const rightFixedColumns = visibleColumns.filter((column) => column.fixed === "right");
|
|
124091
|
+
const notFixedColumns = visibleColumns.filter((column) => !column.fixed);
|
|
124072
124092
|
const originColumns = concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
124073
124093
|
const headerRows = columnsToRowsEffect(originColumns);
|
|
124074
124094
|
states.leftFixedColumns = leftFixedColumns;
|
|
@@ -124076,6 +124096,100 @@ ${p}
|
|
|
124076
124096
|
states.rightFixedColumns = rightFixedColumns;
|
|
124077
124097
|
states.originColumns = originColumns;
|
|
124078
124098
|
states.headerRows = headerRows;
|
|
124099
|
+
this.syncColumnsToParent();
|
|
124100
|
+
}
|
|
124101
|
+
/**
|
|
124102
|
+
* 基于 _columns 生成"可见树":剔除 hidden 列。
|
|
124103
|
+
* 仅克隆含 children 的父节点(避免 columnsToRowsEffect 把 colspan/level/rowspan
|
|
124104
|
+
* 写回原列对象造成残留);leaf 列保持原引用,以便 Layout 写回 realWidth/stickyStyle/stickyClass。
|
|
124105
|
+
* @param arr 列集合
|
|
124106
|
+
* @returns 可见列集合
|
|
124107
|
+
*/
|
|
124108
|
+
cloneVisibleTree(arr) {
|
|
124109
|
+
const walk = (list) => {
|
|
124110
|
+
const out = [];
|
|
124111
|
+
for (const column of list) {
|
|
124112
|
+
if (column.hidden) continue;
|
|
124113
|
+
if (column.children && column.children.length) {
|
|
124114
|
+
const children = walk(column.children);
|
|
124115
|
+
if (children.length === 0) continue;
|
|
124116
|
+
out.push({
|
|
124117
|
+
...column,
|
|
124118
|
+
children
|
|
124119
|
+
});
|
|
124120
|
+
} else out.push(column);
|
|
124121
|
+
}
|
|
124122
|
+
return out;
|
|
124123
|
+
};
|
|
124124
|
+
return walk(arr);
|
|
124125
|
+
}
|
|
124126
|
+
/**
|
|
124127
|
+
* 向外部 emit update:columns。
|
|
124128
|
+
* 暴露全部收集到的 leaf 列(含被隐藏的,带 hidden 标记),不做可见性过滤。
|
|
124129
|
+
* 指纹同时纳入 id 顺序与各列 hidden 状态:
|
|
124130
|
+
* - 外部写回(顺序/hidden)后内部应用,指纹不变 -> 不重复 emit,避免回环;
|
|
124131
|
+
* - 内部列增删导致变化 -> 指纹变化 -> emit 通知外部。
|
|
124132
|
+
*/
|
|
124133
|
+
syncColumnsToParent() {
|
|
124134
|
+
const keys = [
|
|
124135
|
+
"id",
|
|
124136
|
+
"hidden",
|
|
124137
|
+
"label",
|
|
124138
|
+
"prop",
|
|
124139
|
+
"type"
|
|
124140
|
+
];
|
|
124141
|
+
const columns = flattenData(this.states._columns).map((column) => pick(column, keys));
|
|
124142
|
+
if (isEqualWith(columns.map((i) => pick(i, keys)), this._columnsSync.snapshot.map((i) => pick(i, keys)))) return;
|
|
124143
|
+
this._columnsSync.snapshot = columns;
|
|
124144
|
+
this._columnsSync.suppressWatch = true;
|
|
124145
|
+
this.table.emit("update:columns", columns);
|
|
124146
|
+
}
|
|
124147
|
+
/**
|
|
124148
|
+
* 处理外部对 v-model:columns 的写回:
|
|
124149
|
+
* 1) 按 id 把 hidden 回写到内部列对象(递归含 children,覆盖多级表头);
|
|
124150
|
+
* 2) 按 id 对齐顺序重排顶层 _columns(缺失项按原相对顺序补在末尾,避免误丢列)。
|
|
124151
|
+
* @param v 外部写回的列数组
|
|
124152
|
+
*/
|
|
124153
|
+
applyExternalColumns(v) {
|
|
124154
|
+
if (this._columnsSync.suppressWatch) {
|
|
124155
|
+
this._columnsSync.suppressWatch = false;
|
|
124156
|
+
return;
|
|
124157
|
+
}
|
|
124158
|
+
const _columns = this.states._columns;
|
|
124159
|
+
if (!Array.isArray(v) || !v.length) return;
|
|
124160
|
+
const hiddenById = v.reduce((pre, e) => (e && e.id != null && pre.set(e.id, !!e.hidden), pre), /* @__PURE__ */ new Map());
|
|
124161
|
+
let hiddenChanged = false;
|
|
124162
|
+
const applyHidden = (list) => {
|
|
124163
|
+
for (const column of list) {
|
|
124164
|
+
if (hiddenById.has(column.id)) {
|
|
124165
|
+
const v1 = hiddenById.get(column.id);
|
|
124166
|
+
if (!!column.hidden !== v1) {
|
|
124167
|
+
column.hidden = v1;
|
|
124168
|
+
hiddenChanged = true;
|
|
124169
|
+
}
|
|
124170
|
+
}
|
|
124171
|
+
if (column.children && column.children.length) applyHidden(column.children);
|
|
124172
|
+
}
|
|
124173
|
+
};
|
|
124174
|
+
applyHidden(_columns);
|
|
124175
|
+
const order = v.map((e) => e?.id).filter(Boolean);
|
|
124176
|
+
const idToCol = _columns.reduce((pre, column) => (pre.set(column.id, column), pre), /* @__PURE__ */ new Map());
|
|
124177
|
+
const used = /* @__PURE__ */ new Set();
|
|
124178
|
+
const reordered = [];
|
|
124179
|
+
for (const id of order) {
|
|
124180
|
+
const column = idToCol.get(id);
|
|
124181
|
+
if (column && !used.has(column)) {
|
|
124182
|
+
reordered.push(column);
|
|
124183
|
+
used.add(column);
|
|
124184
|
+
}
|
|
124185
|
+
}
|
|
124186
|
+
for (const column of _columns) if (!used.has(column)) reordered.push(column);
|
|
124187
|
+
const orderChanged = !(reordered.length === _columns.length && reordered.every((column, i) => column === _columns[i]));
|
|
124188
|
+
orderChanged && (this.states._columns = reordered);
|
|
124189
|
+
if (orderChanged || hiddenChanged) {
|
|
124190
|
+
this.updateColumns();
|
|
124191
|
+
this.scheduleLayout();
|
|
124192
|
+
}
|
|
124079
124193
|
}
|
|
124080
124194
|
isSelected(row) {
|
|
124081
124195
|
const { selection = [] } = this.states;
|
|
@@ -125043,6 +125157,29 @@ ${p}
|
|
|
125043
125157
|
resizable: {
|
|
125044
125158
|
type: Boolean,
|
|
125045
125159
|
default: void 0
|
|
125160
|
+
},
|
|
125161
|
+
/**
|
|
125162
|
+
* 流式高度下(未设置 height/max-height)表头吸顶、合计行吸底
|
|
125163
|
+
* boolean 时同时作用于表头与合计行;
|
|
125164
|
+
* array 为 [top, bottom],每项可为 boolean 或 affix 配置对象;
|
|
125165
|
+
* object 时同时作用于两端
|
|
125166
|
+
*/
|
|
125167
|
+
affix: {
|
|
125168
|
+
type: [
|
|
125169
|
+
Boolean,
|
|
125170
|
+
Array,
|
|
125171
|
+
Object
|
|
125172
|
+
],
|
|
125173
|
+
default: false
|
|
125174
|
+
},
|
|
125175
|
+
/**
|
|
125176
|
+
* v-model:columns
|
|
125177
|
+
* 暴露内部收集到的全部 leaf 列;外部可按 id 反向重排,
|
|
125178
|
+
* 并通过每项的 hidden 字段控制该列是否渲染(不影响收集)。
|
|
125179
|
+
*/
|
|
125180
|
+
columns: {
|
|
125181
|
+
type: Array,
|
|
125182
|
+
default: () => []
|
|
125046
125183
|
}
|
|
125047
125184
|
},
|
|
125048
125185
|
emits: [
|
|
@@ -125062,7 +125199,8 @@ ${p}
|
|
|
125062
125199
|
"header-dragend",
|
|
125063
125200
|
"expand-change",
|
|
125064
125201
|
"sort-change",
|
|
125065
|
-
"update:sort"
|
|
125202
|
+
"update:sort",
|
|
125203
|
+
"update:columns"
|
|
125066
125204
|
],
|
|
125067
125205
|
setup(props, { slots, expose, emit }) {
|
|
125068
125206
|
const instance = (0, vue.getCurrentInstance)();
|
|
@@ -125080,6 +125218,8 @@ ${p}
|
|
|
125080
125218
|
const body = (0, vue.ref)();
|
|
125081
125219
|
const appendWrapper = (0, vue.ref)(null);
|
|
125082
125220
|
const footerWrapper = (0, vue.ref)(null);
|
|
125221
|
+
const affixHeader = (0, vue.ref)(null);
|
|
125222
|
+
const affixFooter = (0, vue.ref)(null);
|
|
125083
125223
|
const resizeProxy = (0, vue.ref)(null);
|
|
125084
125224
|
const scrollPosition = (0, vue.ref)("left");
|
|
125085
125225
|
const hoverState = (0, vue.ref)(null);
|
|
@@ -125129,6 +125269,20 @@ ${p}
|
|
|
125129
125269
|
}
|
|
125130
125270
|
return {};
|
|
125131
125271
|
});
|
|
125272
|
+
const affixOptions = (0, vue.computed)(() => {
|
|
125273
|
+
const fluidHeight = !props.height && !props.maxHeight;
|
|
125274
|
+
const source = Array.isArray(props.affix) ? props.affix : [props.affix, props.affix];
|
|
125275
|
+
return ["top", "bottom"].map((placement, index) => {
|
|
125276
|
+
const item = source[index];
|
|
125277
|
+
const isObject = !!item && typeof item === "object";
|
|
125278
|
+
return {
|
|
125279
|
+
placement,
|
|
125280
|
+
fixed: true,
|
|
125281
|
+
...isObject ? item : {},
|
|
125282
|
+
disabled: !fluidHeight || !item || isObject && item.disabled
|
|
125283
|
+
};
|
|
125284
|
+
});
|
|
125285
|
+
});
|
|
125132
125286
|
let isUnMount = false;
|
|
125133
125287
|
const updateScrollY = () => {
|
|
125134
125288
|
if (isUnMount) return;
|
|
@@ -125139,11 +125293,18 @@ ${p}
|
|
|
125139
125293
|
* 对 Table 进行重新布局。
|
|
125140
125294
|
* 当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法
|
|
125141
125295
|
*/
|
|
125296
|
+
const refreshAffix = () => {
|
|
125297
|
+
(0, vue.nextTick)(() => {
|
|
125298
|
+
affixHeader.value?.refresh?.();
|
|
125299
|
+
affixFooter.value?.refresh?.();
|
|
125300
|
+
});
|
|
125301
|
+
};
|
|
125142
125302
|
const refreshLayout = () => {
|
|
125143
125303
|
if (isUnMount) return;
|
|
125144
125304
|
layout.updateColumnsWidth();
|
|
125145
125305
|
if (shouldUpdateHeight.value) layout.updateElsHeight();
|
|
125146
125306
|
scroller.value?.refresh?.();
|
|
125307
|
+
refreshAffix();
|
|
125147
125308
|
};
|
|
125148
125309
|
const toggleAllSelection = () => {
|
|
125149
125310
|
store.toggleAllSelection();
|
|
@@ -125247,6 +125408,13 @@ ${p}
|
|
|
125247
125408
|
(0, vue.watch)(() => props.expandRowValue, (v) => {
|
|
125248
125409
|
if (v) store.setExpandRowValueAdapter(v);
|
|
125249
125410
|
}, { immediate: true });
|
|
125411
|
+
(0, vue.watch)(() => props.columns, (v) => {
|
|
125412
|
+
if (!Array.isArray(v) || v.length === 0) return;
|
|
125413
|
+
store.applyExternalColumns(v);
|
|
125414
|
+
}, {
|
|
125415
|
+
deep: true,
|
|
125416
|
+
flush: "post"
|
|
125417
|
+
});
|
|
125250
125418
|
(0, vue.watch)(() => [scrollPosition.value, props.data?.length], ([v]) => {
|
|
125251
125419
|
raf(() => {
|
|
125252
125420
|
const el = tableWrapper.value;
|
|
@@ -125285,6 +125453,7 @@ ${p}
|
|
|
125285
125453
|
layout,
|
|
125286
125454
|
updateScrollY,
|
|
125287
125455
|
refreshLayout,
|
|
125456
|
+
refreshAffix,
|
|
125288
125457
|
toggleAllSelection,
|
|
125289
125458
|
setCurrentRow,
|
|
125290
125459
|
toggleRowSelection,
|
|
@@ -125322,7 +125491,7 @@ ${p}
|
|
|
125322
125491
|
"ref": hiddenColumns,
|
|
125323
125492
|
"class": "vc-table__hidden"
|
|
125324
125493
|
}, [slots.default?.()]),
|
|
125325
|
-
props.showHeader && (0, vue.createVNode)("div", {
|
|
125494
|
+
props.showHeader && (0, vue.createVNode)(Affix, (0, vue.mergeProps)({ "ref": affixHeader }, affixOptions.value[0]), { default: () => [(0, vue.createVNode)("div", {
|
|
125326
125495
|
"ref": headerWrapper,
|
|
125327
125496
|
"class": "vc-table__header-wrapper"
|
|
125328
125497
|
}, [(0, vue.createVNode)(TableHeader, {
|
|
@@ -125330,7 +125499,7 @@ ${p}
|
|
|
125330
125499
|
"resizable": props.resizable,
|
|
125331
125500
|
"sort": props.sort,
|
|
125332
125501
|
"style": bodyWidthStyle.value
|
|
125333
|
-
}, null)]),
|
|
125502
|
+
}, null)])] }),
|
|
125334
125503
|
states.columns.length > 0 && (0, vue.createVNode)(TableBody, {
|
|
125335
125504
|
"ref": body,
|
|
125336
125505
|
"height-style": [bodyHeightStyle.value],
|
|
@@ -125342,7 +125511,7 @@ ${p}
|
|
|
125342
125511
|
"ref": appendWrapper,
|
|
125343
125512
|
"class": "vc-table__append-wrapper"
|
|
125344
125513
|
}, [slots.append()])] }),
|
|
125345
|
-
props.showSummary && (0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125514
|
+
props.showSummary && (0, vue.createVNode)(Affix, (0, vue.mergeProps)({ "ref": affixFooter }, affixOptions.value[1]), { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125346
125515
|
"ref": footerWrapper,
|
|
125347
125516
|
"class": "vc-table__footer-wrapper"
|
|
125348
125517
|
}, [(0, vue.createVNode)(TableFooter, {
|
|
@@ -125350,7 +125519,7 @@ ${p}
|
|
|
125350
125519
|
"sum-text": props.sumText || "合计",
|
|
125351
125520
|
"get-summary": props.getSummary,
|
|
125352
125521
|
"style": bodyWidthStyle.value
|
|
125353
|
-
}, null)]), [[vue.vShow, props.data && props.data.length > 0]]),
|
|
125522
|
+
}, null)]), [[vue.vShow, props.data && props.data.length > 0]])] }),
|
|
125354
125523
|
props.data.length === 0 && (0, vue.createVNode)("div", { "class": [{ "has-height": !!props.height }, "vc-table__empty-wrapper"] }, [slots.empty ? slots.empty() : (0, vue.createVNode)("span", { "class": "vc-table__empty-text" }, [props.emptyText || "暂无数据"])]),
|
|
125355
125524
|
(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125356
125525
|
"ref": resizeProxy,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -111431,6 +111431,7 @@ ${p}
|
|
|
111431
111431
|
...pick(props$81, inputKeys$2),
|
|
111432
111432
|
renderOption: [Function],
|
|
111433
111433
|
renderOptionGroup: [Function],
|
|
111434
|
+
renderLabel: [Function],
|
|
111434
111435
|
data: {
|
|
111435
111436
|
type: Array,
|
|
111436
111437
|
default: () => []
|
|
@@ -119077,10 +119078,11 @@ ${p}
|
|
|
119077
119078
|
const onLoaded = (ctx) => {
|
|
119078
119079
|
ctx?.destroy?.();
|
|
119079
119080
|
};
|
|
119080
|
-
const toDataURL = async () => {
|
|
119081
|
+
const toDataURL = async (type = "svg") => {
|
|
119081
119082
|
const loadContext = onLoad();
|
|
119082
119083
|
try {
|
|
119083
119084
|
await refresh();
|
|
119085
|
+
if (type === "png") return (await snapshot.value.toPng()).src;
|
|
119084
119086
|
return snapshot.value.toRaw();
|
|
119085
119087
|
} finally {
|
|
119086
119088
|
onLoaded(loadContext);
|
|
@@ -119106,7 +119108,7 @@ ${p}
|
|
|
119106
119108
|
skip$ = typeof v === "undefined" ? true : !!v;
|
|
119107
119109
|
return v;
|
|
119108
119110
|
}).finally(() => done(skip$));
|
|
119109
|
-
return;
|
|
119111
|
+
return skip;
|
|
119110
119112
|
}
|
|
119111
119113
|
done(skip);
|
|
119112
119114
|
};
|
|
@@ -120725,6 +120727,7 @@ ${p}
|
|
|
120725
120727
|
default: true
|
|
120726
120728
|
},
|
|
120727
120729
|
render: [Function],
|
|
120730
|
+
renderLabel: [Function],
|
|
120728
120731
|
row: Object
|
|
120729
120732
|
},
|
|
120730
120733
|
setup(props, { slots, expose }) {
|
|
@@ -120784,7 +120787,7 @@ ${p}
|
|
|
120784
120787
|
}, "vc-select-option"],
|
|
120785
120788
|
"onClick": (0, vue.withModifiers)(handleClick, ["stop"]),
|
|
120786
120789
|
"onMousedown": handlePrevent
|
|
120787
|
-
}, [formatterLabel.value, isChecked.value && (0, vue.createVNode)(Icon, { "type": "correct" }, null)]);
|
|
120790
|
+
}, [typeof props.renderLabel === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.renderLabel }, customOptions.value), null) : slots.label ? slots.label(customOptions.value) : formatterLabel.value, isChecked.value && (0, vue.createVNode)(Icon, { "type": "correct" }, null)]);
|
|
120788
120791
|
};
|
|
120789
120792
|
}
|
|
120790
120793
|
});
|
|
@@ -120797,17 +120800,21 @@ ${p}
|
|
|
120797
120800
|
},
|
|
120798
120801
|
label: { type: [String, Number] },
|
|
120799
120802
|
row: Object,
|
|
120800
|
-
render: [Function]
|
|
120803
|
+
render: [Function],
|
|
120804
|
+
renderLabel: [Function]
|
|
120801
120805
|
},
|
|
120802
120806
|
setup(props, { slots }) {
|
|
120803
120807
|
const formatterLabel = (0, vue.computed)(() => {
|
|
120804
120808
|
return String(props.label || props.value).trim();
|
|
120805
120809
|
});
|
|
120806
120810
|
const customOptions = (0, vue.computed)(() => {
|
|
120807
|
-
return {
|
|
120811
|
+
return {
|
|
120812
|
+
row: props.row,
|
|
120813
|
+
store: { group: true }
|
|
120814
|
+
};
|
|
120808
120815
|
});
|
|
120809
120816
|
return () => {
|
|
120810
|
-
return (0, vue.createVNode)("div", { "class": "vc-select-option-group" }, [typeof props.render === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.render }, customOptions.value), null) : slots.
|
|
120817
|
+
return (0, vue.createVNode)("div", { "class": "vc-select-option-group" }, [typeof props.render === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.render }, customOptions.value), null) : slots.optionGroup ? slots.optionGroup(customOptions.value) : (0, vue.createVNode)("div", { "class": "vc-select-option-group__title" }, [typeof props.renderLabel === "function" ? (0, vue.createVNode)(Customer, (0, vue.mergeProps)({ "render": props.renderLabel }, customOptions.value), null) : slots.label ? slots.label(customOptions.value) : formatterLabel.value]), (0, vue.createVNode)("div", null, [slots?.default?.()])]);
|
|
120811
120818
|
};
|
|
120812
120819
|
}
|
|
120813
120820
|
});
|
|
@@ -121076,7 +121083,8 @@ ${p}
|
|
|
121076
121083
|
"key": item.value,
|
|
121077
121084
|
"render": props.renderOptionGroup
|
|
121078
121085
|
}, {
|
|
121079
|
-
|
|
121086
|
+
optionGroup: slots?.optionGroup,
|
|
121087
|
+
label: slots?.label,
|
|
121080
121088
|
default: () => {
|
|
121081
121089
|
return item.children.map(($item) => {
|
|
121082
121090
|
return (0, vue.createVNode)(Option$1, {
|
|
@@ -121087,8 +121095,12 @@ ${p}
|
|
|
121087
121095
|
"label": $item.label,
|
|
121088
121096
|
"disabled": $item.disabled,
|
|
121089
121097
|
"filterable": $item.filterable,
|
|
121090
|
-
"render": props.renderOption
|
|
121091
|
-
|
|
121098
|
+
"render": props.renderOption,
|
|
121099
|
+
"renderLabel": props.renderLabel
|
|
121100
|
+
}, {
|
|
121101
|
+
default: slots?.option,
|
|
121102
|
+
label: slots?.label
|
|
121103
|
+
});
|
|
121092
121104
|
});
|
|
121093
121105
|
}
|
|
121094
121106
|
}) : (0, vue.createVNode)(Option$1, {
|
|
@@ -121099,8 +121111,12 @@ ${p}
|
|
|
121099
121111
|
"label": item.label,
|
|
121100
121112
|
"disabled": item.disabled,
|
|
121101
121113
|
"filterable": item.filterable,
|
|
121102
|
-
"render": props.renderOption
|
|
121103
|
-
|
|
121114
|
+
"render": props.renderOption,
|
|
121115
|
+
"renderLabel": props.renderLabel
|
|
121116
|
+
}, {
|
|
121117
|
+
default: slots?.option,
|
|
121118
|
+
label: slots?.label
|
|
121119
|
+
});
|
|
121104
121120
|
})]) : slots?.default?.()] })
|
|
121105
121121
|
]);
|
|
121106
121122
|
}
|
|
@@ -123928,6 +123944,10 @@ ${p}
|
|
|
123928
123944
|
expand;
|
|
123929
123945
|
tree;
|
|
123930
123946
|
layout;
|
|
123947
|
+
_columnsSync = {
|
|
123948
|
+
snapshot: [],
|
|
123949
|
+
suppressWatch: false
|
|
123950
|
+
};
|
|
123931
123951
|
flatData = (0, vue.computed)(() => {
|
|
123932
123952
|
if (this.table.props.expandSelectable) return concat(flattenData(this.states.data, {
|
|
123933
123953
|
parent: true,
|
|
@@ -124064,13 +124084,13 @@ ${p}
|
|
|
124064
124084
|
updateColumns() {
|
|
124065
124085
|
const { states } = this;
|
|
124066
124086
|
const _columns = states._columns || [];
|
|
124067
|
-
|
|
124068
|
-
|
|
124069
|
-
if (leftFixedColumns.length > 0 && _columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
124070
|
-
_columns[0].fixed = true;
|
|
124071
|
-
leftFixedColumns.unshift(_columns[0]);
|
|
124087
|
+
if (_columns[0] && _columns[0].type === "selection" && !_columns[0].fixed) {
|
|
124088
|
+
if (_columns.some((column) => column.fixed === true || column.fixed === "left")) _columns[0].fixed = true;
|
|
124072
124089
|
}
|
|
124073
|
-
const
|
|
124090
|
+
const visibleColumns = this.cloneVisibleTree(_columns);
|
|
124091
|
+
const leftFixedColumns = visibleColumns.filter((column) => column.fixed === true || column.fixed === "left");
|
|
124092
|
+
const rightFixedColumns = visibleColumns.filter((column) => column.fixed === "right");
|
|
124093
|
+
const notFixedColumns = visibleColumns.filter((column) => !column.fixed);
|
|
124074
124094
|
const originColumns = concat(leftFixedColumns, notFixedColumns, rightFixedColumns);
|
|
124075
124095
|
const headerRows = columnsToRowsEffect(originColumns);
|
|
124076
124096
|
states.leftFixedColumns = leftFixedColumns;
|
|
@@ -124078,6 +124098,100 @@ ${p}
|
|
|
124078
124098
|
states.rightFixedColumns = rightFixedColumns;
|
|
124079
124099
|
states.originColumns = originColumns;
|
|
124080
124100
|
states.headerRows = headerRows;
|
|
124101
|
+
this.syncColumnsToParent();
|
|
124102
|
+
}
|
|
124103
|
+
/**
|
|
124104
|
+
* 基于 _columns 生成"可见树":剔除 hidden 列。
|
|
124105
|
+
* 仅克隆含 children 的父节点(避免 columnsToRowsEffect 把 colspan/level/rowspan
|
|
124106
|
+
* 写回原列对象造成残留);leaf 列保持原引用,以便 Layout 写回 realWidth/stickyStyle/stickyClass。
|
|
124107
|
+
* @param arr 列集合
|
|
124108
|
+
* @returns 可见列集合
|
|
124109
|
+
*/
|
|
124110
|
+
cloneVisibleTree(arr) {
|
|
124111
|
+
const walk = (list) => {
|
|
124112
|
+
const out = [];
|
|
124113
|
+
for (const column of list) {
|
|
124114
|
+
if (column.hidden) continue;
|
|
124115
|
+
if (column.children && column.children.length) {
|
|
124116
|
+
const children = walk(column.children);
|
|
124117
|
+
if (children.length === 0) continue;
|
|
124118
|
+
out.push({
|
|
124119
|
+
...column,
|
|
124120
|
+
children
|
|
124121
|
+
});
|
|
124122
|
+
} else out.push(column);
|
|
124123
|
+
}
|
|
124124
|
+
return out;
|
|
124125
|
+
};
|
|
124126
|
+
return walk(arr);
|
|
124127
|
+
}
|
|
124128
|
+
/**
|
|
124129
|
+
* 向外部 emit update:columns。
|
|
124130
|
+
* 暴露全部收集到的 leaf 列(含被隐藏的,带 hidden 标记),不做可见性过滤。
|
|
124131
|
+
* 指纹同时纳入 id 顺序与各列 hidden 状态:
|
|
124132
|
+
* - 外部写回(顺序/hidden)后内部应用,指纹不变 -> 不重复 emit,避免回环;
|
|
124133
|
+
* - 内部列增删导致变化 -> 指纹变化 -> emit 通知外部。
|
|
124134
|
+
*/
|
|
124135
|
+
syncColumnsToParent() {
|
|
124136
|
+
const keys = [
|
|
124137
|
+
"id",
|
|
124138
|
+
"hidden",
|
|
124139
|
+
"label",
|
|
124140
|
+
"prop",
|
|
124141
|
+
"type"
|
|
124142
|
+
];
|
|
124143
|
+
const columns = flattenData(this.states._columns).map((column) => pick(column, keys));
|
|
124144
|
+
if (isEqualWith(columns.map((i) => pick(i, keys)), this._columnsSync.snapshot.map((i) => pick(i, keys)))) return;
|
|
124145
|
+
this._columnsSync.snapshot = columns;
|
|
124146
|
+
this._columnsSync.suppressWatch = true;
|
|
124147
|
+
this.table.emit("update:columns", columns);
|
|
124148
|
+
}
|
|
124149
|
+
/**
|
|
124150
|
+
* 处理外部对 v-model:columns 的写回:
|
|
124151
|
+
* 1) 按 id 把 hidden 回写到内部列对象(递归含 children,覆盖多级表头);
|
|
124152
|
+
* 2) 按 id 对齐顺序重排顶层 _columns(缺失项按原相对顺序补在末尾,避免误丢列)。
|
|
124153
|
+
* @param v 外部写回的列数组
|
|
124154
|
+
*/
|
|
124155
|
+
applyExternalColumns(v) {
|
|
124156
|
+
if (this._columnsSync.suppressWatch) {
|
|
124157
|
+
this._columnsSync.suppressWatch = false;
|
|
124158
|
+
return;
|
|
124159
|
+
}
|
|
124160
|
+
const _columns = this.states._columns;
|
|
124161
|
+
if (!Array.isArray(v) || !v.length) return;
|
|
124162
|
+
const hiddenById = v.reduce((pre, e) => (e && e.id != null && pre.set(e.id, !!e.hidden), pre), /* @__PURE__ */ new Map());
|
|
124163
|
+
let hiddenChanged = false;
|
|
124164
|
+
const applyHidden = (list) => {
|
|
124165
|
+
for (const column of list) {
|
|
124166
|
+
if (hiddenById.has(column.id)) {
|
|
124167
|
+
const v1 = hiddenById.get(column.id);
|
|
124168
|
+
if (!!column.hidden !== v1) {
|
|
124169
|
+
column.hidden = v1;
|
|
124170
|
+
hiddenChanged = true;
|
|
124171
|
+
}
|
|
124172
|
+
}
|
|
124173
|
+
if (column.children && column.children.length) applyHidden(column.children);
|
|
124174
|
+
}
|
|
124175
|
+
};
|
|
124176
|
+
applyHidden(_columns);
|
|
124177
|
+
const order = v.map((e) => e?.id).filter(Boolean);
|
|
124178
|
+
const idToCol = _columns.reduce((pre, column) => (pre.set(column.id, column), pre), /* @__PURE__ */ new Map());
|
|
124179
|
+
const used = /* @__PURE__ */ new Set();
|
|
124180
|
+
const reordered = [];
|
|
124181
|
+
for (const id of order) {
|
|
124182
|
+
const column = idToCol.get(id);
|
|
124183
|
+
if (column && !used.has(column)) {
|
|
124184
|
+
reordered.push(column);
|
|
124185
|
+
used.add(column);
|
|
124186
|
+
}
|
|
124187
|
+
}
|
|
124188
|
+
for (const column of _columns) if (!used.has(column)) reordered.push(column);
|
|
124189
|
+
const orderChanged = !(reordered.length === _columns.length && reordered.every((column, i) => column === _columns[i]));
|
|
124190
|
+
orderChanged && (this.states._columns = reordered);
|
|
124191
|
+
if (orderChanged || hiddenChanged) {
|
|
124192
|
+
this.updateColumns();
|
|
124193
|
+
this.scheduleLayout();
|
|
124194
|
+
}
|
|
124081
124195
|
}
|
|
124082
124196
|
isSelected(row) {
|
|
124083
124197
|
const { selection = [] } = this.states;
|
|
@@ -125045,6 +125159,29 @@ ${p}
|
|
|
125045
125159
|
resizable: {
|
|
125046
125160
|
type: Boolean,
|
|
125047
125161
|
default: void 0
|
|
125162
|
+
},
|
|
125163
|
+
/**
|
|
125164
|
+
* 流式高度下(未设置 height/max-height)表头吸顶、合计行吸底
|
|
125165
|
+
* boolean 时同时作用于表头与合计行;
|
|
125166
|
+
* array 为 [top, bottom],每项可为 boolean 或 affix 配置对象;
|
|
125167
|
+
* object 时同时作用于两端
|
|
125168
|
+
*/
|
|
125169
|
+
affix: {
|
|
125170
|
+
type: [
|
|
125171
|
+
Boolean,
|
|
125172
|
+
Array,
|
|
125173
|
+
Object
|
|
125174
|
+
],
|
|
125175
|
+
default: false
|
|
125176
|
+
},
|
|
125177
|
+
/**
|
|
125178
|
+
* v-model:columns
|
|
125179
|
+
* 暴露内部收集到的全部 leaf 列;外部可按 id 反向重排,
|
|
125180
|
+
* 并通过每项的 hidden 字段控制该列是否渲染(不影响收集)。
|
|
125181
|
+
*/
|
|
125182
|
+
columns: {
|
|
125183
|
+
type: Array,
|
|
125184
|
+
default: () => []
|
|
125048
125185
|
}
|
|
125049
125186
|
},
|
|
125050
125187
|
emits: [
|
|
@@ -125064,7 +125201,8 @@ ${p}
|
|
|
125064
125201
|
"header-dragend",
|
|
125065
125202
|
"expand-change",
|
|
125066
125203
|
"sort-change",
|
|
125067
|
-
"update:sort"
|
|
125204
|
+
"update:sort",
|
|
125205
|
+
"update:columns"
|
|
125068
125206
|
],
|
|
125069
125207
|
setup(props, { slots, expose, emit }) {
|
|
125070
125208
|
const instance = (0, vue.getCurrentInstance)();
|
|
@@ -125082,6 +125220,8 @@ ${p}
|
|
|
125082
125220
|
const body = (0, vue.ref)();
|
|
125083
125221
|
const appendWrapper = (0, vue.ref)(null);
|
|
125084
125222
|
const footerWrapper = (0, vue.ref)(null);
|
|
125223
|
+
const affixHeader = (0, vue.ref)(null);
|
|
125224
|
+
const affixFooter = (0, vue.ref)(null);
|
|
125085
125225
|
const resizeProxy = (0, vue.ref)(null);
|
|
125086
125226
|
const scrollPosition = (0, vue.ref)("left");
|
|
125087
125227
|
const hoverState = (0, vue.ref)(null);
|
|
@@ -125131,6 +125271,20 @@ ${p}
|
|
|
125131
125271
|
}
|
|
125132
125272
|
return {};
|
|
125133
125273
|
});
|
|
125274
|
+
const affixOptions = (0, vue.computed)(() => {
|
|
125275
|
+
const fluidHeight = !props.height && !props.maxHeight;
|
|
125276
|
+
const source = Array.isArray(props.affix) ? props.affix : [props.affix, props.affix];
|
|
125277
|
+
return ["top", "bottom"].map((placement, index) => {
|
|
125278
|
+
const item = source[index];
|
|
125279
|
+
const isObject = !!item && typeof item === "object";
|
|
125280
|
+
return {
|
|
125281
|
+
placement,
|
|
125282
|
+
fixed: true,
|
|
125283
|
+
...isObject ? item : {},
|
|
125284
|
+
disabled: !fluidHeight || !item || isObject && item.disabled
|
|
125285
|
+
};
|
|
125286
|
+
});
|
|
125287
|
+
});
|
|
125134
125288
|
let isUnMount = false;
|
|
125135
125289
|
const updateScrollY = () => {
|
|
125136
125290
|
if (isUnMount) return;
|
|
@@ -125141,11 +125295,18 @@ ${p}
|
|
|
125141
125295
|
* 对 Table 进行重新布局。
|
|
125142
125296
|
* 当 Table 或其祖先元素由隐藏切换为显示时,可能需要调用此方法
|
|
125143
125297
|
*/
|
|
125298
|
+
const refreshAffix = () => {
|
|
125299
|
+
(0, vue.nextTick)(() => {
|
|
125300
|
+
affixHeader.value?.refresh?.();
|
|
125301
|
+
affixFooter.value?.refresh?.();
|
|
125302
|
+
});
|
|
125303
|
+
};
|
|
125144
125304
|
const refreshLayout = () => {
|
|
125145
125305
|
if (isUnMount) return;
|
|
125146
125306
|
layout.updateColumnsWidth();
|
|
125147
125307
|
if (shouldUpdateHeight.value) layout.updateElsHeight();
|
|
125148
125308
|
scroller.value?.refresh?.();
|
|
125309
|
+
refreshAffix();
|
|
125149
125310
|
};
|
|
125150
125311
|
const toggleAllSelection = () => {
|
|
125151
125312
|
store.toggleAllSelection();
|
|
@@ -125249,6 +125410,13 @@ ${p}
|
|
|
125249
125410
|
(0, vue.watch)(() => props.expandRowValue, (v) => {
|
|
125250
125411
|
if (v) store.setExpandRowValueAdapter(v);
|
|
125251
125412
|
}, { immediate: true });
|
|
125413
|
+
(0, vue.watch)(() => props.columns, (v) => {
|
|
125414
|
+
if (!Array.isArray(v) || v.length === 0) return;
|
|
125415
|
+
store.applyExternalColumns(v);
|
|
125416
|
+
}, {
|
|
125417
|
+
deep: true,
|
|
125418
|
+
flush: "post"
|
|
125419
|
+
});
|
|
125252
125420
|
(0, vue.watch)(() => [scrollPosition.value, props.data?.length], ([v]) => {
|
|
125253
125421
|
raf(() => {
|
|
125254
125422
|
const el = tableWrapper.value;
|
|
@@ -125287,6 +125455,7 @@ ${p}
|
|
|
125287
125455
|
layout,
|
|
125288
125456
|
updateScrollY,
|
|
125289
125457
|
refreshLayout,
|
|
125458
|
+
refreshAffix,
|
|
125290
125459
|
toggleAllSelection,
|
|
125291
125460
|
setCurrentRow,
|
|
125292
125461
|
toggleRowSelection,
|
|
@@ -125324,7 +125493,7 @@ ${p}
|
|
|
125324
125493
|
"ref": hiddenColumns,
|
|
125325
125494
|
"class": "vc-table__hidden"
|
|
125326
125495
|
}, [slots.default?.()]),
|
|
125327
|
-
props.showHeader && (0, vue.createVNode)("div", {
|
|
125496
|
+
props.showHeader && (0, vue.createVNode)(Affix, (0, vue.mergeProps)({ "ref": affixHeader }, affixOptions.value[0]), { default: () => [(0, vue.createVNode)("div", {
|
|
125328
125497
|
"ref": headerWrapper,
|
|
125329
125498
|
"class": "vc-table__header-wrapper"
|
|
125330
125499
|
}, [(0, vue.createVNode)(TableHeader, {
|
|
@@ -125332,7 +125501,7 @@ ${p}
|
|
|
125332
125501
|
"resizable": props.resizable,
|
|
125333
125502
|
"sort": props.sort,
|
|
125334
125503
|
"style": bodyWidthStyle.value
|
|
125335
|
-
}, null)]),
|
|
125504
|
+
}, null)])] }),
|
|
125336
125505
|
states.columns.length > 0 && (0, vue.createVNode)(TableBody, {
|
|
125337
125506
|
"ref": body,
|
|
125338
125507
|
"height-style": [bodyHeightStyle.value],
|
|
@@ -125344,7 +125513,7 @@ ${p}
|
|
|
125344
125513
|
"ref": appendWrapper,
|
|
125345
125514
|
"class": "vc-table__append-wrapper"
|
|
125346
125515
|
}, [slots.append()])] }),
|
|
125347
|
-
props.showSummary && (0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125516
|
+
props.showSummary && (0, vue.createVNode)(Affix, (0, vue.mergeProps)({ "ref": affixFooter }, affixOptions.value[1]), { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125348
125517
|
"ref": footerWrapper,
|
|
125349
125518
|
"class": "vc-table__footer-wrapper"
|
|
125350
125519
|
}, [(0, vue.createVNode)(TableFooter, {
|
|
@@ -125352,7 +125521,7 @@ ${p}
|
|
|
125352
125521
|
"sum-text": props.sumText || "合计",
|
|
125353
125522
|
"get-summary": props.getSummary,
|
|
125354
125523
|
"style": bodyWidthStyle.value
|
|
125355
|
-
}, null)]), [[vue.vShow, props.data && props.data.length > 0]]),
|
|
125524
|
+
}, null)]), [[vue.vShow, props.data && props.data.length > 0]])] }),
|
|
125356
125525
|
props.data.length === 0 && (0, vue.createVNode)("div", { "class": [{ "has-height": !!props.height }, "vc-table__empty-wrapper"] }, [slots.empty ? slots.empty() : (0, vue.createVNode)("span", { "class": "vc-table__empty-text" }, [props.emptyText || "暂无数据"])]),
|
|
125357
125526
|
(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
125358
125527
|
"ref": resizeProxy,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/vc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.70",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@deot/vc-components": "^1.0.
|
|
23
|
-
"@deot/vc-hooks": "^1.0.
|
|
24
|
-
"@deot/vc-shared": "^1.0.
|
|
22
|
+
"@deot/vc-components": "^1.0.70",
|
|
23
|
+
"@deot/vc-hooks": "^1.0.70",
|
|
24
|
+
"@deot/vc-shared": "^1.0.70"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vue": "*"
|