@aimerthyr/virtual-table 1.0.0
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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +105 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +349 -0
- package/dist/index.js +4484 -0
- package/dist/index.js.map +1 -0
- package/dist/virtual-table.css +1 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { AllowedComponentProps } from 'vue';
|
|
2
|
+
import { ColumnDef } from '@tanstack/vue-table';
|
|
3
|
+
import { ColumnFiltersState } from '@tanstack/vue-table';
|
|
4
|
+
import { ColumnPinningState } from '@tanstack/vue-table';
|
|
5
|
+
import { ColumnSizingState } from '@tanstack/vue-table';
|
|
6
|
+
import { ComponentCustomProps } from 'vue';
|
|
7
|
+
import { CSSProperties } from 'vue';
|
|
8
|
+
import { ExpandedState } from '@tanstack/vue-table';
|
|
9
|
+
import { HTMLAttributes } from 'vue';
|
|
10
|
+
import { PaginationState } from '@tanstack/vue-table';
|
|
11
|
+
import { PublicProps } from 'vue';
|
|
12
|
+
import { RowSelectionState } from '@tanstack/vue-table';
|
|
13
|
+
import { ShallowUnwrapRef } from 'vue';
|
|
14
|
+
import { SortingState } from '@tanstack/vue-table';
|
|
15
|
+
import { Table } from '@tanstack/vue-table';
|
|
16
|
+
import { TdHTMLAttributes } from 'vue';
|
|
17
|
+
import { ThHTMLAttributes } from 'vue';
|
|
18
|
+
import { VNode as VNode_2 } from 'vue';
|
|
19
|
+
import { VNodeProps } from 'vue';
|
|
20
|
+
|
|
21
|
+
declare type __VLS_PrettifyLocal<T> = {
|
|
22
|
+
[K in keyof T]: T[K];
|
|
23
|
+
} & {};
|
|
24
|
+
|
|
25
|
+
/** checkbox 选择列 */
|
|
26
|
+
export declare const CHECKBOX_COLUMN_KEY = "CHECKBOX_COLUMN_KEY";
|
|
27
|
+
|
|
28
|
+
declare const _default: <TData extends VTableData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
29
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
30
|
+
readonly "onUpdate:defaultFilter"?: ((value: ColumnFiltersState) => any) | undefined;
|
|
31
|
+
readonly "onUpdate:defaultSort"?: ((value: SortingState) => any) | undefined;
|
|
32
|
+
readonly "onUpdate:defaultPagination"?: ((value: PaginationState) => any) | undefined;
|
|
33
|
+
readonly "onUpdate:defaultExpanded"?: ((value: ExpandedState) => any) | undefined;
|
|
34
|
+
readonly "onUpdate:defaultSelection"?: ((value: RowSelectionState) => any) | undefined;
|
|
35
|
+
readonly "onUpdate:defaultColumnPinning"?: ((value: ColumnPinningState) => any) | undefined;
|
|
36
|
+
readonly "onUpdate:defaultColumnSizing"?: ((value: ColumnSizingState) => any) | undefined;
|
|
37
|
+
} & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>, "onUpdate:defaultFilter" | "onUpdate:defaultSort" | "onUpdate:defaultPagination" | "onUpdate:defaultExpanded" | "onUpdate:defaultSelection" | "onUpdate:defaultColumnPinning" | "onUpdate:defaultColumnSizing"> & ({
|
|
38
|
+
defaultFilter?: ColumnFiltersState;
|
|
39
|
+
defaultSort?: SortingState;
|
|
40
|
+
defaultPagination?: PaginationState;
|
|
41
|
+
defaultExpanded?: ExpandedState;
|
|
42
|
+
defaultSelection?: RowSelectionState;
|
|
43
|
+
defaultColumnPinning?: ColumnPinningState;
|
|
44
|
+
defaultColumnSizing?: ColumnSizingState;
|
|
45
|
+
} & VTableProps<TData>) & Partial<{}>> & PublicProps;
|
|
46
|
+
expose(exposed: ShallowUnwrapRef<VTableInstance>): void;
|
|
47
|
+
attrs: any;
|
|
48
|
+
slots: any;
|
|
49
|
+
emit: ((evt: "update:defaultFilter", value: ColumnFiltersState) => void) & ((evt: "update:defaultSort", value: SortingState) => void) & ((evt: "update:defaultPagination", value: PaginationState) => void) & ((evt: "update:defaultExpanded", value: ExpandedState) => void) & ((evt: "update:defaultSelection", value: RowSelectionState) => void) & ((evt: "update:defaultColumnPinning", value: ColumnPinningState) => void) & ((evt: "update:defaultColumnSizing", value: ColumnSizingState) => void);
|
|
50
|
+
}>) => VNode_2 & {
|
|
51
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
52
|
+
};
|
|
53
|
+
export { _default as VTable }
|
|
54
|
+
export default _default;
|
|
55
|
+
|
|
56
|
+
/** 展开列 */
|
|
57
|
+
export declare const EXPAND_COLUMN_KEY = "EXPAND_COLUMN_KEY";
|
|
58
|
+
|
|
59
|
+
/** data 中 展开子行的数据属性 */
|
|
60
|
+
export declare const EXPAND_ROW_DATA_INDEX = "_expandChildren";
|
|
61
|
+
|
|
62
|
+
/** 是否是展开行 */
|
|
63
|
+
export declare const EXPAND_ROW_KEY = "_isExpandRow";
|
|
64
|
+
|
|
65
|
+
/** 表格默认样式 */
|
|
66
|
+
export declare const TABLE_DEFAULT_STYLE: CSSProperties;
|
|
67
|
+
|
|
68
|
+
export declare type VTableBorderConfig = {
|
|
69
|
+
/** 是否显示边框 */
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
/** 边框样式 */
|
|
72
|
+
borderStyle?: 'solid' | 'dashed';
|
|
73
|
+
/** 边框颜色 */
|
|
74
|
+
borderColor?: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** 表格状态(分页,排序,筛选) */
|
|
78
|
+
export declare type VTableChangeState = {
|
|
79
|
+
pagination: VTablePaginationState;
|
|
80
|
+
sortList: VTableSortingState;
|
|
81
|
+
filterList: VTableColumnFiltersState;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Checkbox 自定义组件接口定义
|
|
86
|
+
*/
|
|
87
|
+
export declare interface VTableCheckboxProps {
|
|
88
|
+
/** 是否选中 */
|
|
89
|
+
checked: boolean;
|
|
90
|
+
/** 是否禁用 */
|
|
91
|
+
disabled: boolean;
|
|
92
|
+
/** 是否半选状态 */
|
|
93
|
+
indeterminate: boolean;
|
|
94
|
+
/** 选中状态变化回调(需要直接拿到事件对象) */
|
|
95
|
+
onCheckedChange: (e: Event) => void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** 列配置 */
|
|
99
|
+
export declare interface VTableColumn<TData = any> {
|
|
100
|
+
/** 列的 key (同时也对应于每一列数据的 key) */
|
|
101
|
+
columnKey: string;
|
|
102
|
+
/** 列标题 */
|
|
103
|
+
columnHeader?: ColumnDef<TData>['header'];
|
|
104
|
+
/** 列对齐方式 */
|
|
105
|
+
columnAlign?: 'left' | 'center' | 'right';
|
|
106
|
+
/** 列的宽度(支持数字或百分比字符串,如 200 或 '20%') */
|
|
107
|
+
columnWidth?: number | string;
|
|
108
|
+
/** 是否开启排序 */
|
|
109
|
+
columnEnableSort?: boolean;
|
|
110
|
+
/** 是否开启筛选 */
|
|
111
|
+
columnEnableFilter?: boolean;
|
|
112
|
+
/** 单元格内容 */
|
|
113
|
+
columnCell?: ColumnDef<TData>['cell'];
|
|
114
|
+
/** 当前列宽是否可以调整 */
|
|
115
|
+
columnEnableResize?: boolean;
|
|
116
|
+
/** 列宽最大值 */
|
|
117
|
+
columnMaxWidth?: number;
|
|
118
|
+
/** 列宽最小值 (默认 50px) */
|
|
119
|
+
columnMinWidth?: number;
|
|
120
|
+
/** 可自行拓展字段 */
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export declare type VTableColumnFiltersState = ColumnFiltersState;
|
|
125
|
+
|
|
126
|
+
export declare type VTableColumnPinningState = ColumnPinningState;
|
|
127
|
+
|
|
128
|
+
export declare type VTableData<T = Record<string, any>> = T & {
|
|
129
|
+
/** 当前行是否展开 */
|
|
130
|
+
[EXPAND_ROW_KEY]?: boolean;
|
|
131
|
+
/** 子行数据列表(HACK: 为了实现自定义展开行的逻辑,这里只会有一项) */
|
|
132
|
+
[EXPAND_ROW_DATA_INDEX]?: Array<VTableData<T>>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** 表格默认 props */
|
|
136
|
+
export declare const vTableDefaultProps: {
|
|
137
|
+
data?: ((props: VTableProps<any>) => any[]) | undefined;
|
|
138
|
+
columns?: ((props: VTableProps<any>) => VTableColumn<any>[]) | undefined;
|
|
139
|
+
rowHeight?: number | ((props: VTableProps<any>) => number) | undefined;
|
|
140
|
+
rowKey?: VTableRowKey<any> | ((props: VTableProps<any>) => string | number | ((row: any) => string | number)) | undefined;
|
|
141
|
+
loading?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
142
|
+
fixedHeader?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
143
|
+
enableSortingRemoval?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
144
|
+
borderConfig?: ((props: VTableProps<any>) => VTableBorderConfig) | undefined;
|
|
145
|
+
rowSelectionConfig?: ((props: VTableProps<any>) => VTableRowSelectionConfig<any>) | undefined;
|
|
146
|
+
loadMoreConfig?: ((props: VTableProps<any>) => VTableLoadMoreConfig) | undefined;
|
|
147
|
+
paginationConfig?: ((props: VTableProps<any>) => VTablePaginationConfig) | undefined;
|
|
148
|
+
treeConfig?: ((props: VTableProps<any>) => VTableTreeConfig) | undefined;
|
|
149
|
+
enableExpandRow?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
150
|
+
enableRowHover?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
151
|
+
adaptiveColumnWidth?: number | ((props: VTableProps<any>) => number) | undefined;
|
|
152
|
+
defaultExpandAllRows?: boolean | ((props: VTableProps<any>) => boolean) | undefined;
|
|
153
|
+
columnResizeMode?: "onChange" | "onEnd" | ((props: VTableProps<any>) => "onChange" | "onEnd") | undefined;
|
|
154
|
+
customRow?: ((row: any, rowIndex: number) => HTMLAttributes) | ((props: VTableProps<any>) => (row: any, rowIndex: number) => HTMLAttributes) | undefined;
|
|
155
|
+
customHeaderCell?: ((column: VTableColumn, colIndex: number) => ThHTMLAttributes) | ((props: VTableProps<any>) => (column: VTableColumn, colIndex: number) => ThHTMLAttributes) | undefined;
|
|
156
|
+
customCell?: ((column: VTableColumn, colIndex: number) => TdHTMLAttributes) | ((props: VTableProps<any>) => (column: VTableColumn, colIndex: number) => TdHTMLAttributes) | undefined;
|
|
157
|
+
onTableChange?: ((data: VTableChangeState) => void) | ((props: VTableProps<any>) => (data: VTableChangeState) => void) | undefined;
|
|
158
|
+
onScrollToBottom?: (() => void) | ((props: VTableProps<any>) => () => void) | undefined;
|
|
159
|
+
onExpandedRowsChange?: ((expandState: VTableExpandedState) => void) | ((props: VTableProps<any>) => (expandState: VTableExpandedState) => void) | undefined;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export declare type VTableExpandedState = ExpandedState;
|
|
163
|
+
|
|
164
|
+
/** VTable 实例类型定义 */
|
|
165
|
+
export declare interface VTableInstance {
|
|
166
|
+
/** 滚动到指定行 */
|
|
167
|
+
scrollToIndex: (index: number) => void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export declare type VTableLoadMoreConfig = {
|
|
171
|
+
/** 是否显示"没有更多了"提示 */
|
|
172
|
+
showNoMore?: boolean;
|
|
173
|
+
/** 自定义"没有更多了"文本 */
|
|
174
|
+
noMoreText?: string;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export declare type VTablePaginationConfig = {
|
|
178
|
+
/** 总数(必须要传) */
|
|
179
|
+
total: number;
|
|
180
|
+
/** 是否开启分页 */
|
|
181
|
+
enabled?: boolean;
|
|
182
|
+
/** 分页器位置 */
|
|
183
|
+
placement?: 'left' | 'center' | 'right';
|
|
184
|
+
/** 服务端分页还是前端分页 */
|
|
185
|
+
mode?: 'client' | 'server';
|
|
186
|
+
/** 分页器额外属性(如果你自己定义了分页器组件,则用于回传给你自己定义的组件) */
|
|
187
|
+
paginationExtraProps?: Record<string, any>;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Pagination 自定义组件接口定义
|
|
192
|
+
*/
|
|
193
|
+
export declare interface VTablePaginationProps {
|
|
194
|
+
/** 每页条数 */
|
|
195
|
+
pageSize: number;
|
|
196
|
+
/** 当前页码 */
|
|
197
|
+
pageIndex: number;
|
|
198
|
+
/** 总条数 */
|
|
199
|
+
total: number;
|
|
200
|
+
/** 页码变化回调 */
|
|
201
|
+
onPageChange: (pageIndex: number, pageSize: number) => void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export declare type VTablePaginationState = PaginationState;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Popover 自定义组件接口定义
|
|
208
|
+
*/
|
|
209
|
+
export declare interface VTablePopoverProps {
|
|
210
|
+
/** 是否显示 */
|
|
211
|
+
open: boolean;
|
|
212
|
+
/** 显示状态变化回调 */
|
|
213
|
+
onOpenChange: (value: boolean) => void;
|
|
214
|
+
/** 触发区域 */
|
|
215
|
+
trigger: () => VNode_2;
|
|
216
|
+
/** 下拉内容 */
|
|
217
|
+
content: () => VNode_2;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** props 类型定义 */
|
|
221
|
+
export declare interface VTableProps<TData = any> {
|
|
222
|
+
/** 表格数据 */
|
|
223
|
+
data: TData[];
|
|
224
|
+
/** 表格列 */
|
|
225
|
+
columns: VTableColumn[];
|
|
226
|
+
/** 表格行高 (⭐️建议设置,优化滚动性能,防止出现不可控的滚动异常行为) */
|
|
227
|
+
rowHeight?: number;
|
|
228
|
+
/** 行唯一标识字段 */
|
|
229
|
+
rowKey?: VTableRowKey<TData>;
|
|
230
|
+
/** 是否正在加载中(⭐️如果需要滚动加载的话,建议设置,用于防止滚动触底多次) */
|
|
231
|
+
loading?: boolean;
|
|
232
|
+
/** 是否固定表头(表头不随着滚动) */
|
|
233
|
+
fixedHeader?: boolean;
|
|
234
|
+
/** 是否允许取消排序 */
|
|
235
|
+
enableSortingRemoval?: boolean;
|
|
236
|
+
/** 边框样式配置 */
|
|
237
|
+
borderConfig?: VTableBorderConfig;
|
|
238
|
+
/** 选择行功能配置 */
|
|
239
|
+
rowSelectionConfig?: VTableRowSelectionConfig<TData>;
|
|
240
|
+
/** 加载更多配置 */
|
|
241
|
+
loadMoreConfig?: VTableLoadMoreConfig;
|
|
242
|
+
/** 分页器配置 */
|
|
243
|
+
paginationConfig?: VTablePaginationConfig;
|
|
244
|
+
/** 树形结构配置 */
|
|
245
|
+
treeConfig?: VTableTreeConfig;
|
|
246
|
+
/** 是否启用展开行功能 */
|
|
247
|
+
enableExpandRow?: boolean;
|
|
248
|
+
/** 是否启用 行 hover 高亮 */
|
|
249
|
+
enableRowHover?: boolean;
|
|
250
|
+
/** 自适应列宽(当列数很多时,会出现横向滚动条,那么就需要设置自适应列的最小列宽) */
|
|
251
|
+
adaptiveColumnWidth?: number;
|
|
252
|
+
/** 默认展开所有行(仅初始化生效) */
|
|
253
|
+
defaultExpandAllRows?: boolean;
|
|
254
|
+
/** 列宽调整模式 */
|
|
255
|
+
columnResizeMode?: 'onChange' | 'onEnd';
|
|
256
|
+
/** 自定义数据行属性 */
|
|
257
|
+
customRow?: (row: TData, rowIndex: number) => HTMLAttributes;
|
|
258
|
+
/** 自定义表头单元格属性 */
|
|
259
|
+
customHeaderCell?: (column: VTableColumn, colIndex: number) => ThHTMLAttributes;
|
|
260
|
+
/** 自定义表体单元格属性 */
|
|
261
|
+
customCell?: (column: VTableColumn, colIndex: number) => TdHTMLAttributes;
|
|
262
|
+
/** 表格状态变化(筛选,排序,分页) */
|
|
263
|
+
onTableChange?: (data: VTableChangeState) => void;
|
|
264
|
+
/** 滚动到表格底部 */
|
|
265
|
+
onScrollToBottom?: () => void;
|
|
266
|
+
/** 展开行变化回调 */
|
|
267
|
+
onExpandedRowsChange?: (expandState: VTableExpandedState) => void;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare type VTableRowKey<TData> = string | number | ((row: TData) => string | number);
|
|
271
|
+
|
|
272
|
+
export declare type VTableRowSelectionConfig<TData> = {
|
|
273
|
+
/** 是否开启 checkbox 列 */
|
|
274
|
+
enabled?: boolean;
|
|
275
|
+
/** 判断该行是否禁用选择 */
|
|
276
|
+
getRowCheckDisabled?: (row: TData) => boolean;
|
|
277
|
+
/** 选择行变化回调 */
|
|
278
|
+
onChange?: (selectedRows: TData[]) => void;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export declare type VTableSelectionState = RowSelectionState;
|
|
282
|
+
|
|
283
|
+
/** slots 类型定义 */
|
|
284
|
+
export declare interface VTableSlots<TData = any> {
|
|
285
|
+
/** 自定义头部渲染 */
|
|
286
|
+
customHeader?: (data: {
|
|
287
|
+
columns: VTableColumn[];
|
|
288
|
+
table: Table<TData>;
|
|
289
|
+
}) => VNode_2;
|
|
290
|
+
/** 自定义单元格 */
|
|
291
|
+
bodyCell?: (data: {
|
|
292
|
+
columnKey: string;
|
|
293
|
+
column: VTableColumn;
|
|
294
|
+
row: TData;
|
|
295
|
+
rowIndex: number;
|
|
296
|
+
}) => VNode_2;
|
|
297
|
+
/** 自定义列头 */
|
|
298
|
+
headerCell?: (data: {
|
|
299
|
+
columnKey: string;
|
|
300
|
+
column: VTableColumn;
|
|
301
|
+
}) => VNode_2;
|
|
302
|
+
/** 自定义筛选图标 */
|
|
303
|
+
customFilterIcon?: (data: {
|
|
304
|
+
columnKey: string;
|
|
305
|
+
filtered: boolean;
|
|
306
|
+
column: VTableColumn;
|
|
307
|
+
}) => VNode_2;
|
|
308
|
+
/** 自定义筛选下拉 */
|
|
309
|
+
customFilterDropdown?: (data: {
|
|
310
|
+
confirm: () => void;
|
|
311
|
+
reset: () => void;
|
|
312
|
+
setFilterValue: (value: any) => void;
|
|
313
|
+
column: VTableColumn;
|
|
314
|
+
filterModelValue: any;
|
|
315
|
+
}) => VNode_2;
|
|
316
|
+
/** 自定义展开行 */
|
|
317
|
+
expandedRowRender?: (data: {
|
|
318
|
+
row: TData;
|
|
319
|
+
}) => VNode_2;
|
|
320
|
+
/** 自定义 Popover */
|
|
321
|
+
customPopover?: (props: {
|
|
322
|
+
open: boolean;
|
|
323
|
+
onOpenChange: (value: boolean) => void;
|
|
324
|
+
trigger: () => VNode_2;
|
|
325
|
+
content: () => VNode_2;
|
|
326
|
+
}) => VNode_2;
|
|
327
|
+
/** 自定义分页器 */
|
|
328
|
+
customPagination?: (props: VTablePaginationProps) => VNode_2;
|
|
329
|
+
/** 自定义 checkbox */
|
|
330
|
+
customCheckbox?: (props: VTableCheckboxProps) => VNode_2;
|
|
331
|
+
/** 自定义空状态 */
|
|
332
|
+
customEmpty?: () => VNode_2;
|
|
333
|
+
/** 自定义 loading 图标 */
|
|
334
|
+
customLoadingIcon?: () => VNode_2;
|
|
335
|
+
[key: string]: ((...args: any[]) => VNode_2) | undefined;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export declare type VTableSortingState = SortingState;
|
|
339
|
+
|
|
340
|
+
export declare type VTableTreeConfig = {
|
|
341
|
+
/** 是否启用树形结构 */
|
|
342
|
+
enabled?: boolean;
|
|
343
|
+
/** 子节点字段名,默认为 'children' */
|
|
344
|
+
childrenKey?: string;
|
|
345
|
+
/** 缩进距离 */
|
|
346
|
+
indentSize?: number;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export { }
|