This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,223 @@
import type { ComponentInternalInstance, PropType, Ref, VNode } from 'vue';
import type { DefaultRow, Table, TableSortOrder } from '../table/defaults';
import type { TableOverflowTooltipFormatter, TableOverflowTooltipOptions } from '../util';
import type { Store } from '../store';
type CI<T extends DefaultRow> = {
column: TableColumnCtx<T>;
$index: number;
store: Store<T>;
_self: any;
};
type Filters = {
text: string;
value: string;
}[];
type FilterMethods<T extends DefaultRow> = (value: string, row: T, column: TableColumnCtx<T>) => void;
type ValueOf<T> = T[keyof T];
type TableColumnCtx<T extends DefaultRow = DefaultRow> = {
id: string;
realWidth: number | null;
type: string;
label: string;
className: string;
labelClassName: string;
property: string;
prop: string;
width?: string | number;
minWidth: string | number;
renderHeader: (data: CI<T>) => VNode;
sortable: boolean | string;
sortMethod: (a: T, b: T) => number;
sortBy: string | ((row: T, index: number, array?: T[]) => string) | string[];
resizable: boolean;
columnKey: string;
rawColumnKey: string;
align: string;
headerAlign: string;
showOverflowTooltip?: boolean | TableOverflowTooltipOptions;
tooltipFormatter?: TableOverflowTooltipFormatter<T>;
fixed: boolean | string;
formatter: (row: T, column: TableColumnCtx<T>, cellValue: any, index: number) => VNode | string;
selectable: (row: T, index: number) => boolean;
reserveSelection: boolean;
filterMethod: FilterMethods<T>;
filteredValue: string[];
filters: Filters;
filterPlacement: string;
filterMultiple: boolean;
filterClassName: string;
index: number | ((index: number) => number);
sortOrders: (TableSortOrder | null)[];
renderCell: (data: any) => VNode | VNode[];
colSpan: number;
rowSpan: number;
children?: TableColumnCtx<T>[];
level: number;
filterable: boolean | FilterMethods<T> | Filters;
order: TableSortOrder | null;
isColumnGroup: boolean;
isSubColumn: boolean;
columns: TableColumnCtx<T>[];
getColumnIndex: () => number;
no: number;
filterOpened?: boolean;
renderFilterIcon?: (scope: any) => VNode;
renderExpand?: (scope: any) => VNode;
};
interface TableColumn<T extends DefaultRow> extends ComponentInternalInstance {
vnode: {
vParent: TableColumn<T> | Table<T>;
} & VNode;
vParent: TableColumn<T> | Table<T>;
columnId: string;
columnConfig: Ref<Partial<TableColumnCtx<T>>>;
}
export type { Filters, FilterMethods, TableColumnCtx, TableColumn, ValueOf };
declare const _default: {
/**
* @description type of the column. If set to `selection`, the column will display checkbox. If set to `index`, the column will display index of the row (staring from 1). If set to `expand`, the column will display expand icon
*/
type: {
type: StringConstructor;
default: string;
};
/**
* @description column label
*/
label: StringConstructor;
/**
* @description class name of cells in the column
*/
className: StringConstructor;
/**
* @description class name of the label of this column
*/
labelClassName: StringConstructor;
/**
* @description
*/
property: StringConstructor;
/**
* @description field name. You can also use its alias: `property`
*/
prop: StringConstructor;
/**
* @description column width
*/
width: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
/**
* @description column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion
*/
minWidth: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
/**
* @description render function for table header of this column
*/
renderHeader: PropType<TableColumnCtx<any>["renderHeader"]>;
/**
* @description whether column can be sorted. Remote sorting can be done by setting this attribute to 'custom' and listening to the `sort-change` event of Table
*/
sortable: {
type: (BooleanConstructor | StringConstructor)[];
default: boolean;
};
/**
* @description sorting method, works when `sortable` is `true`. Should return a number, just like Array.sort
*/
sortMethod: PropType<TableColumnCtx<any>["sortMethod"]>;
/**
* @description specify which property to sort by, works when `sortable` is `true` and `sort-method` is `undefined`. If set to an Array, the column will sequentially sort by the next property if the previous one is equal
*/
sortBy: PropType<TableColumnCtx<any>["sortBy"]>;
/**
* @description whether column width can be resized, works when `border` of `el-table` is `true`
*/
resizable: {
type: BooleanConstructor;
default: boolean;
};
/**
* @description column's key. If you need to use the filter-change event, you need this attribute to identify which column is being filtered
*/
columnKey: StringConstructor;
/**
* @description alignment, the value should be 'left' \/ 'center' \/ 'right'
*/
align: StringConstructor;
/**
* @description alignment of the table header. If omitted, the value of the above `align` attribute will be applied, the value should be 'left' \/ 'center' \/ 'right'
*/
headerAlign: StringConstructor;
/**
* @description whether to hide extra content and show them in a tooltip when hovering on the cell
*/
showOverflowTooltip: {
type: PropType<TableColumnCtx<any>["showOverflowTooltip"]>;
default: undefined;
};
/**
* @description function that formats cell tooltip content, works when `show-overflow-tooltip` is `true`
*/
tooltipFormatter: PropType<TableColumnCtx<any>["tooltipFormatter"]>;
/**
* @description whether column is fixed at left / right. Will be fixed at left if `true`
*/
fixed: (BooleanConstructor | StringConstructor)[];
/**
* @description function that formats cell content
*/
formatter: PropType<TableColumnCtx<any>["formatter"]>;
/**
* @description function that determines if a certain row can be selected, works when `type` is 'selection'
*/
selectable: PropType<TableColumnCtx<any>["selectable"]>;
/**
* @description whether to reserve selection after data refreshing, works when `type` is 'selection'. Note that `row-key` is required for this to work
*/
reserveSelection: BooleanConstructor;
/**
* @description data filtering method. If `filter-multiple` is on, this method will be called multiple times for each row, and a row will display if one of the calls returns `true`
*/
filterMethod: PropType<TableColumnCtx<any>["filterMethod"]>;
/**
* @description filter value for selected data, might be useful when table header is rendered with `render-header`
*/
filteredValue: PropType<TableColumnCtx<any>["filteredValue"]>;
/**
* @description an array of data filtering options. For each element in this array, `text` and `value` are required
*/
filters: PropType<TableColumnCtx<any>["filters"]>;
/**
* @description placement for the filter dropdown
*/
filterPlacement: StringConstructor;
/**
* @description whether data filtering supports multiple options
*/
filterMultiple: {
type: BooleanConstructor;
default: boolean;
};
/**
* @description className for the filter dropdown
*/
filterClassName: StringConstructor;
/**
* @description customize indices for each row, works on columns with `type=index`
*/
index: PropType<TableColumnCtx<any>["index"]>;
/**
* @description the order of the sorting strategies used when sorting the data, works when `sortable` is `true`. Accepts an array, as the user clicks on the header, the column is sorted in order of the elements in the array
*/
sortOrders: {
type: PropType<TableColumnCtx<any>["sortOrders"]>;
default: () => (string | null)[];
validator: (val: TableColumnCtx<any>["sortOrders"]) => boolean;
};
};
export default _default;

View File

@@ -0,0 +1,68 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var defaultProps = {
type: {
type: String,
default: "default"
},
label: String,
className: String,
labelClassName: String,
property: String,
prop: String,
width: {
type: [String, Number],
default: ""
},
minWidth: {
type: [String, Number],
default: ""
},
renderHeader: Function,
sortable: {
type: [Boolean, String],
default: false
},
sortMethod: Function,
sortBy: [String, Function, Array],
resizable: {
type: Boolean,
default: true
},
columnKey: String,
align: String,
headerAlign: String,
showOverflowTooltip: {
type: [Boolean, Object],
default: void 0
},
tooltipFormatter: Function,
fixed: [Boolean, String],
formatter: Function,
selectable: Function,
reserveSelection: Boolean,
filterMethod: Function,
filteredValue: Array,
filters: Array,
filterPlacement: String,
filterMultiple: {
type: Boolean,
default: true
},
filterClassName: String,
index: [Number, Function],
sortOrders: {
type: Array,
default: () => {
return ["ascending", "descending", null];
},
validator: (val) => {
return val.every((order) => ["ascending", "descending", null].includes(order));
}
}
};
exports["default"] = defaultProps;
//# sourceMappingURL=defaults.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,125 @@
import type { TableColumnCtx } from './defaults';
declare const _default: import("vue").DefineComponent<{
type: {
type: StringConstructor;
default: string;
};
label: StringConstructor;
className: StringConstructor;
labelClassName: StringConstructor;
property: StringConstructor;
prop: StringConstructor;
width: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
minWidth: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
renderHeader: import("vue").PropType<TableColumnCtx<any>["renderHeader"]>;
sortable: {
type: (BooleanConstructor | StringConstructor)[];
default: boolean;
};
sortMethod: import("vue").PropType<TableColumnCtx<any>["sortMethod"]>;
sortBy: import("vue").PropType<TableColumnCtx<any>["sortBy"]>;
resizable: {
type: BooleanConstructor;
default: boolean;
};
columnKey: StringConstructor;
align: StringConstructor;
headerAlign: StringConstructor;
showOverflowTooltip: {
type: import("vue").PropType<TableColumnCtx<any>["showOverflowTooltip"]>;
default: undefined;
};
tooltipFormatter: import("vue").PropType<TableColumnCtx<any>["tooltipFormatter"]>;
fixed: (BooleanConstructor | StringConstructor)[];
formatter: import("vue").PropType<TableColumnCtx<any>["formatter"]>;
selectable: import("vue").PropType<TableColumnCtx<any>["selectable"]>;
reserveSelection: BooleanConstructor;
filterMethod: import("vue").PropType<TableColumnCtx<any>["filterMethod"]>;
filteredValue: import("vue").PropType<TableColumnCtx<any>["filteredValue"]>;
filters: import("vue").PropType<TableColumnCtx<any>["filters"]>;
filterPlacement: StringConstructor;
filterMultiple: {
type: BooleanConstructor;
default: boolean;
};
filterClassName: StringConstructor;
index: import("vue").PropType<TableColumnCtx<any>["index"]>;
sortOrders: {
type: import("vue").PropType<TableColumnCtx<any>["sortOrders"]>;
default: () => (string | null)[];
validator: (val: TableColumnCtx<any>["sortOrders"]) => boolean;
};
}, void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
type: {
type: StringConstructor;
default: string;
};
label: StringConstructor;
className: StringConstructor;
labelClassName: StringConstructor;
property: StringConstructor;
prop: StringConstructor;
width: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
minWidth: {
type: (NumberConstructor | StringConstructor)[];
default: string;
};
renderHeader: import("vue").PropType<TableColumnCtx<any>["renderHeader"]>;
sortable: {
type: (BooleanConstructor | StringConstructor)[];
default: boolean;
};
sortMethod: import("vue").PropType<TableColumnCtx<any>["sortMethod"]>;
sortBy: import("vue").PropType<TableColumnCtx<any>["sortBy"]>;
resizable: {
type: BooleanConstructor;
default: boolean;
};
columnKey: StringConstructor;
align: StringConstructor;
headerAlign: StringConstructor;
showOverflowTooltip: {
type: import("vue").PropType<TableColumnCtx<any>["showOverflowTooltip"]>;
default: undefined;
};
tooltipFormatter: import("vue").PropType<TableColumnCtx<any>["tooltipFormatter"]>;
fixed: (BooleanConstructor | StringConstructor)[];
formatter: import("vue").PropType<TableColumnCtx<any>["formatter"]>;
selectable: import("vue").PropType<TableColumnCtx<any>["selectable"]>;
reserveSelection: BooleanConstructor;
filterMethod: import("vue").PropType<TableColumnCtx<any>["filterMethod"]>;
filteredValue: import("vue").PropType<TableColumnCtx<any>["filteredValue"]>;
filters: import("vue").PropType<TableColumnCtx<any>["filters"]>;
filterPlacement: StringConstructor;
filterMultiple: {
type: BooleanConstructor;
default: boolean;
};
filterClassName: StringConstructor;
index: import("vue").PropType<TableColumnCtx<any>["index"]>;
sortOrders: {
type: import("vue").PropType<TableColumnCtx<any>["sortOrders"]>;
default: () => (string | null)[];
validator: (val: TableColumnCtx<any>["sortOrders"]) => boolean;
};
}>>, {
width: string | number;
minWidth: string | number;
type: string;
resizable: boolean;
showOverflowTooltip: boolean | Partial<Pick<import("element-plus").ElTooltipProps, "offset" | "transition" | "placement" | "effect" | "showAfter" | "hideAfter" | "popperOptions" | "enterable" | "popperClass" | "appendTo" | "showArrow">> | undefined;
sortOrders: (import("../table/defaults").TableSortOrder | null)[];
sortable: string | boolean;
reserveSelection: boolean;
filterMultiple: boolean;
}>;
export default _default;

View File

@@ -0,0 +1,153 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index = require('../../../checkbox/index.js');
var config = require('../config.js');
var util = require('../util.js');
var watcherHelper = require('./watcher-helper.js');
var renderHelper = require('./render-helper.js');
var defaults = require('./defaults.js');
var types = require('../../../../utils/types.js');
var shared = require('@vue/shared');
let columnIdSeed = 1;
var ElTableColumn = vue.defineComponent({
name: "ElTableColumn",
components: {
ElCheckbox: index.ElCheckbox
},
props: defaults["default"],
setup(props, { slots }) {
const instance = vue.getCurrentInstance();
const columnConfig = vue.ref({});
const owner = vue.computed(() => {
let parent2 = instance.parent;
while (parent2 && !parent2.tableId) {
parent2 = parent2.parent;
}
return parent2;
});
const { registerNormalWatchers, registerComplexWatchers } = watcherHelper["default"](owner, props);
const {
columnId,
isSubColumn,
realHeaderAlign,
columnOrTableParent,
setColumnWidth,
setColumnForcedProps,
setColumnRenders,
getPropsData,
getColumnElIndex,
realAlign,
updateColumnOrder
} = renderHelper["default"](props, slots, owner);
const parent = columnOrTableParent.value;
columnId.value = `${"tableId" in parent && parent.tableId || "columnId" in parent && parent.columnId}_column_${columnIdSeed++}`;
vue.onBeforeMount(() => {
isSubColumn.value = owner.value !== parent;
const type = props.type || "default";
const sortable = props.sortable === "" ? true : props.sortable;
const showOverflowTooltip = type === "selection" ? false : types.isUndefined(props.showOverflowTooltip) ? parent.props.showOverflowTooltip : props.showOverflowTooltip;
const tooltipFormatter = types.isUndefined(props.tooltipFormatter) ? parent.props.tooltipFormatter : props.tooltipFormatter;
const defaults = {
...config.cellStarts[type],
id: columnId.value,
type,
property: props.prop || props.property,
align: realAlign,
headerAlign: realHeaderAlign,
showOverflowTooltip,
tooltipFormatter,
filterable: props.filters || props.filterMethod,
filteredValue: [],
filterPlacement: "",
filterClassName: "",
isColumnGroup: false,
isSubColumn: false,
filterOpened: false,
sortable,
index: props.index,
rawColumnKey: instance.vnode.key
};
const basicProps = [
"columnKey",
"label",
"className",
"labelClassName",
"type",
"renderHeader",
"formatter",
"fixed",
"resizable"
];
const sortProps = ["sortMethod", "sortBy", "sortOrders"];
const selectProps = ["selectable", "reserveSelection"];
const filterProps = [
"filterMethod",
"filters",
"filterMultiple",
"filterOpened",
"filteredValue",
"filterPlacement",
"filterClassName"
];
let column = getPropsData(basicProps, sortProps, selectProps, filterProps);
column = util.mergeOptions(defaults, column);
const chains = util.compose(setColumnRenders, setColumnWidth, setColumnForcedProps);
column = chains(column);
columnConfig.value = column;
registerNormalWatchers();
registerComplexWatchers();
});
vue.onMounted(() => {
var _a, _b;
const parent2 = columnOrTableParent.value;
const children = isSubColumn.value ? (_a = parent2.vnode.el) == null ? void 0 : _a.children : (_b = parent2.refs.hiddenColumns) == null ? void 0 : _b.children;
const getColumnIndex = () => getColumnElIndex(children || [], instance.vnode.el);
columnConfig.value.getColumnIndex = getColumnIndex;
const columnIndex = getColumnIndex();
columnIndex > -1 && owner.value.store.commit("insertColumn", columnConfig.value, isSubColumn.value ? "columnConfig" in parent2 && parent2.columnConfig.value : null, updateColumnOrder);
});
vue.onBeforeUnmount(() => {
const getColumnIndex = columnConfig.value.getColumnIndex;
const columnIndex = getColumnIndex ? getColumnIndex() : -1;
columnIndex > -1 && owner.value.store.commit("removeColumn", columnConfig.value, isSubColumn.value ? "columnConfig" in parent && parent.columnConfig.value : null, updateColumnOrder);
});
instance.columnId = columnId.value;
instance.columnConfig = columnConfig;
return;
},
render() {
var _a, _b, _c;
try {
const renderDefault = (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, {
row: {},
column: {},
$index: -1
});
const children = [];
if (shared.isArray(renderDefault)) {
for (const childNode of renderDefault) {
if (((_c = childNode.type) == null ? void 0 : _c.name) === "ElTableColumn" || childNode.shapeFlag & 2) {
children.push(childNode);
} else if (childNode.type === vue.Fragment && shared.isArray(childNode.children)) {
childNode.children.forEach((vnode2) => {
if ((vnode2 == null ? void 0 : vnode2.patchFlag) !== 1024 && !shared.isString(vnode2 == null ? void 0 : vnode2.children)) {
children.push(vnode2);
}
});
}
}
}
const vnode = vue.h("div", children);
return vnode;
} catch (e) {
return vue.h("div", []);
}
}
});
exports["default"] = ElTableColumn;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
import type { ComputedRef, RendererNode, Slots } from 'vue';
import type { TableColumn, TableColumnCtx } from './defaults';
import type { DefaultRow, Table } from '../table/defaults';
declare function useRender<T extends DefaultRow>(props: TableColumnCtx<T>, slots: Slots, owner: ComputedRef<Table<T>>): {
columnId: import("vue").Ref<string>;
realAlign: import("vue").Ref<string | null | undefined>;
isSubColumn: import("vue").Ref<boolean>;
realHeaderAlign: import("vue").Ref<string | null | undefined>;
columnOrTableParent: ComputedRef<Table<T> | TableColumn<T>>;
setColumnWidth: (column: TableColumnCtx<T>) => TableColumnCtx<T>;
setColumnForcedProps: (column: TableColumnCtx<T>) => TableColumnCtx<T>;
setColumnRenders: (column: TableColumnCtx<T>) => TableColumnCtx<T>;
getPropsData: (...propsKey: string[][]) => Record<string, any>;
getColumnElIndex: (children: T[], child: RendererNode | null) => number;
updateColumnOrder: () => void;
};
export default useRender;

View File

@@ -0,0 +1,175 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var config = require('../config.js');
var util = require('../util.js');
var index = require('../../../../hooks/use-namespace/index.js');
var types = require('../../../../utils/types.js');
var shared = require('@vue/shared');
function useRender(props, slots, owner) {
const instance = vue.getCurrentInstance();
const columnId = vue.ref("");
const isSubColumn = vue.ref(false);
const realAlign = vue.ref();
const realHeaderAlign = vue.ref();
const ns = index.useNamespace("table");
vue.watchEffect(() => {
realAlign.value = props.align ? `is-${props.align}` : null;
realAlign.value;
});
vue.watchEffect(() => {
realHeaderAlign.value = props.headerAlign ? `is-${props.headerAlign}` : realAlign.value;
realHeaderAlign.value;
});
const columnOrTableParent = vue.computed(() => {
let parent = instance.vnode.vParent || instance.parent;
while (parent && !parent.tableId && !parent.columnId) {
parent = parent.vnode.vParent || parent.parent;
}
return parent;
});
const hasTreeColumn = vue.computed(() => {
const { store } = instance.parent;
if (!store)
return false;
const { treeData } = store.states;
const treeDataValue = treeData.value;
return treeDataValue && Object.keys(treeDataValue).length > 0;
});
const realWidth = vue.ref(util.parseWidth(props.width));
const realMinWidth = vue.ref(util.parseMinWidth(props.minWidth));
const setColumnWidth = (column) => {
if (realWidth.value)
column.width = realWidth.value;
if (realMinWidth.value) {
column.minWidth = realMinWidth.value;
}
if (!realWidth.value && realMinWidth.value) {
column.width = void 0;
}
if (!column.minWidth) {
column.minWidth = 80;
}
column.realWidth = Number(types.isUndefined(column.width) ? column.minWidth : column.width);
return column;
};
const setColumnForcedProps = (column) => {
const type = column.type;
const source = config.cellForced[type] || {};
Object.keys(source).forEach((prop) => {
const value = source[prop];
if (prop !== "className" && !types.isUndefined(value)) {
column[prop] = value;
}
});
const className = config.getDefaultClassName(type);
if (className) {
const forceClass = `${vue.unref(ns.namespace)}-${className}`;
column.className = column.className ? `${column.className} ${forceClass}` : forceClass;
}
return column;
};
const checkSubColumn = (children) => {
if (shared.isArray(children)) {
children.forEach((child) => check(child));
} else {
check(children);
}
function check(item) {
var _a;
if (((_a = item == null ? void 0 : item.type) == null ? void 0 : _a.name) === "ElTableColumn") {
item.vParent = instance;
}
}
};
const setColumnRenders = (column) => {
if (props.renderHeader) ; else if (column.type !== "selection") {
column.renderHeader = (scope) => {
instance.columnConfig.value["label"];
return vue.renderSlot(slots, "header", scope, () => [column.label]);
};
}
if (slots["filter-icon"]) {
column.renderFilterIcon = (scope) => {
return vue.renderSlot(slots, "filter-icon", scope);
};
}
if (slots.expand) {
column.renderExpand = (scope) => {
return vue.renderSlot(slots, "expand", scope);
};
}
let originRenderCell = column.renderCell;
if (column.type === "expand") {
column.renderCell = (data) => vue.h("div", {
class: "cell"
}, [originRenderCell(data)]);
owner.value.renderExpanded = (row) => {
return slots.default ? slots.default(row) : slots.default;
};
} else {
originRenderCell = originRenderCell || config.defaultRenderCell;
column.renderCell = (data) => {
let children = null;
if (slots.default) {
const vnodes = slots.default(data);
children = vnodes.some((v) => v.type !== vue.Comment) ? vnodes : originRenderCell(data);
} else {
children = originRenderCell(data);
}
const { columns } = owner.value.store.states;
const firstUserColumnIndex = columns.value.findIndex((item) => item.type === "default");
const shouldCreatePlaceholder = hasTreeColumn.value && data.cellIndex === firstUserColumnIndex;
const prefix = config.treeCellPrefix(data, shouldCreatePlaceholder);
const props2 = {
class: "cell",
style: {}
};
if (column.showOverflowTooltip) {
props2.class = `${props2.class} ${vue.unref(ns.namespace)}-tooltip`;
props2.style = {
width: `${(data.column.realWidth || Number(data.column.width)) - 1}px`
};
}
checkSubColumn(children);
return vue.h("div", props2, [prefix, children]);
};
}
return column;
};
const getPropsData = (...propsKey) => {
return propsKey.reduce((prev, cur) => {
if (shared.isArray(cur)) {
cur.forEach((key) => {
prev[key] = props[key];
});
}
return prev;
}, {});
};
const getColumnElIndex = (children, child) => {
return Array.prototype.indexOf.call(children, child);
};
const updateColumnOrder = () => {
owner.value.store.commit("updateColumnOrder", instance.columnConfig.value);
};
return {
columnId,
realAlign,
isSubColumn,
realHeaderAlign,
columnOrTableParent,
setColumnWidth,
setColumnForcedProps,
setColumnRenders,
getPropsData,
getColumnElIndex,
updateColumnOrder
};
}
exports["default"] = useRender;
//# sourceMappingURL=render-helper.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
import type { ComputedRef } from 'vue';
import type { DefaultRow } from '../table/defaults';
import type { TableColumnCtx } from './defaults';
declare function useWatcher<T extends DefaultRow>(owner: ComputedRef<any>, props_: Partial<TableColumnCtx<T>>): {
registerComplexWatchers: () => void;
registerNormalWatchers: () => void;
};
export default useWatcher;

View File

@@ -0,0 +1,88 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var util = require('../util.js');
var shared = require('@vue/shared');
function getAllAliases(props, aliases) {
return props.reduce((prev, cur) => {
prev[cur] = cur;
return prev;
}, aliases);
}
function useWatcher(owner, props_) {
const instance = vue.getCurrentInstance();
const registerComplexWatchers = () => {
const props = ["fixed"];
const aliases = {
realWidth: "width",
realMinWidth: "minWidth"
};
const allAliases = getAllAliases(props, aliases);
Object.keys(allAliases).forEach((key) => {
const columnKey = aliases[key];
if (shared.hasOwn(props_, columnKey)) {
vue.watch(() => props_[columnKey], (newVal) => {
let value = newVal;
if (columnKey === "width" && key === "realWidth") {
value = util.parseWidth(newVal);
}
if (columnKey === "minWidth" && key === "realMinWidth") {
value = util.parseMinWidth(newVal);
}
instance.columnConfig.value[columnKey] = value;
instance.columnConfig.value[key] = value;
const updateColumns = columnKey === "fixed";
owner.value.store.scheduleLayout(updateColumns);
});
}
});
};
const registerNormalWatchers = () => {
const props = [
"label",
"filters",
"filterMultiple",
"filteredValue",
"sortable",
"index",
"formatter",
"className",
"labelClassName",
"filterClassName",
"showOverflowTooltip",
"tooltipFormatter"
];
const parentProps = ["showOverflowTooltip"];
const aliases = {
property: "prop",
align: "realAlign",
headerAlign: "realHeaderAlign"
};
const allAliases = getAllAliases(props, aliases);
Object.keys(allAliases).forEach((key) => {
const columnKey = aliases[key];
if (shared.hasOwn(props_, columnKey)) {
vue.watch(() => props_[columnKey], (newVal) => {
instance.columnConfig.value[key] = newVal;
});
}
});
parentProps.forEach((key) => {
if (shared.hasOwn(owner.value.props, key)) {
vue.watch(() => owner.value.props[key], (newVal) => {
instance.columnConfig.value[key] = newVal;
});
}
});
};
return {
registerComplexWatchers,
registerNormalWatchers
};
}
exports["default"] = useWatcher;
//# sourceMappingURL=watcher-helper.js.map

File diff suppressed because one or more lines are too long