@antdv-vue/pro-table 0.0.0-stage → 2.0.3
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 +255 -0
- package/README.md +106 -2
- package/dist/InternalTable.d.ts +360 -0
- package/dist/InternalTable.js +444 -0
- package/dist/RenderTypings.d.ts +33 -0
- package/dist/RenderTypings.js +1 -0
- package/dist/ResizableTableTitle.d.ts +24 -0
- package/dist/ResizableTableTitle.js +89 -0
- package/dist/Store/Provide.d.ts +68 -0
- package/dist/Store/Provide.js +132 -0
- package/dist/Table.d.ts +363 -0
- package/dist/Table.js +151 -0
- package/dist/TableRender.d.ts +54 -0
- package/dist/TableRender.js +295 -0
- package/dist/components/Alert/index.d.ts +45 -0
- package/dist/components/Alert/index.js +94 -0
- package/dist/components/Alert/style/index.d.ts +8 -0
- package/dist/components/Alert/style/index.js +11 -0
- package/dist/components/ColumnSetting/CheckboxList.d.ts +24 -0
- package/dist/components/ColumnSetting/CheckboxList.js +138 -0
- package/dist/components/ColumnSetting/CheckboxListItem.d.ts +17 -0
- package/dist/components/ColumnSetting/CheckboxListItem.js +84 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.d.ts +22 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.js +82 -0
- package/dist/components/ColumnSetting/ToolTipIcon.d.ts +12 -0
- package/dist/components/ColumnSetting/ToolTipIcon.js +47 -0
- package/dist/components/ColumnSetting/index.d.ts +26 -0
- package/dist/components/ColumnSetting/index.js +117 -0
- package/dist/components/ColumnSetting/style/index.d.ts +8 -0
- package/dist/components/ColumnSetting/style/index.js +73 -0
- package/dist/components/DragSortTable/index.d.ts +375 -0
- package/dist/components/DragSortTable/index.js +166 -0
- package/dist/components/DragSortTable/style/index.d.ts +8 -0
- package/dist/components/DragSortTable/style/index.js +25 -0
- package/dist/components/Dropdown/Button.d.ts +20 -0
- package/dist/components/Dropdown/Button.js +155 -0
- package/dist/components/Dropdown/index.d.ts +27 -0
- package/dist/components/Dropdown/index.js +149 -0
- package/dist/components/EditableTable/CellEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/CellEditorTable.js +167 -0
- package/dist/components/EditableTable/EditableTable.d.ts +67 -0
- package/dist/components/EditableTable/EditableTable.js +141 -0
- package/dist/components/EditableTable/InternalEditableTable.d.ts +189 -0
- package/dist/components/EditableTable/InternalEditableTable.js +508 -0
- package/dist/components/EditableTable/RowEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/RowEditorTable.js +147 -0
- package/dist/components/EditableTable/context.d.ts +9 -0
- package/dist/components/EditableTable/context.js +11 -0
- package/dist/components/EditableTable/index.d.ts +5 -0
- package/dist/components/EditableTable/index.js +5 -0
- package/dist/components/Form/FormRender.d.ts +77 -0
- package/dist/components/Form/FormRender.js +198 -0
- package/dist/components/Form/index.d.ts +33 -0
- package/dist/components/Form/index.js +91 -0
- package/dist/components/ToolBar/DensityIcon.d.ts +22 -0
- package/dist/components/ToolBar/DensityIcon.js +71 -0
- package/dist/components/ToolBar/FullScreenIcon.d.ts +6 -0
- package/dist/components/ToolBar/FullScreenIcon.js +30 -0
- package/dist/components/ToolBar/HeaderMenu.d.ts +22 -0
- package/dist/components/ToolBar/HeaderMenu.js +84 -0
- package/dist/components/ToolBar/index.d.ts +102 -0
- package/dist/components/ToolBar/index.js +322 -0
- package/dist/components/ToolBar/style/index.d.ts +8 -0
- package/dist/components/ToolBar/style/index.js +116 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/pro-table.esm.js +3274 -0
- package/dist/style/index.d.ts +11 -0
- package/dist/style/index.js +162 -0
- package/dist/typing.d.ts +409 -0
- package/dist/typing.js +1 -0
- package/dist/useFetchData.d.ts +10 -0
- package/dist/useFetchData.js +243 -0
- package/dist/utils/cellRenderToFromItem.d.ts +52 -0
- package/dist/utils/cellRenderToFromItem.js +163 -0
- package/dist/utils/columnRender.d.ts +54 -0
- package/dist/utils/columnRender.js +148 -0
- package/dist/utils/columnSort.d.ts +7 -0
- package/dist/utils/columnSort.js +17 -0
- package/dist/utils/genProColumnsToColumns.d.ts +69 -0
- package/dist/utils/genProColumnsToColumns.js +197 -0
- package/dist/utils/index.d.ts +122 -0
- package/dist/utils/index.js +227 -0
- package/dist/utils/useDragSort.d.ts +182 -0
- package/dist/utils/useDragSort.js +162 -0
- package/package.json +67 -3
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import TableAlert from "./components/Alert/index.js";
|
|
2
|
+
import { genProColumnsToColumns } from "./utils/genProColumnsToColumns.js";
|
|
3
|
+
import { flattenColumns, genColumnKey, mergePagination, parseServerDefaultColumnConfig, useActionType } from "./utils/index.js";
|
|
4
|
+
import FormSearch from "./components/Form/index.js";
|
|
5
|
+
import { useTableContextInject } from "./Store/Provide.js";
|
|
6
|
+
import Toolbar from "./components/ToolBar/index.js";
|
|
7
|
+
import style_default from "./style/index.js";
|
|
8
|
+
import TableRender from "./TableRender.js";
|
|
9
|
+
import useFetchData from "./useFetchData.js";
|
|
10
|
+
import { columnSort } from "./utils/columnSort.js";
|
|
11
|
+
import { cloneVNode, computed, createVNode, defineComponent, mergeProps, shallowRef, toRef, watchEffect } from "vue";
|
|
12
|
+
import { useProFormInstanceExpose } from "@antdv-vue/pro-form";
|
|
13
|
+
import { proTheme, useIntl } from "@antdv-vue/pro-provider";
|
|
14
|
+
import { stringify, useEditableArray, useEffect, useMountMergeState } from "@antdv-vue/pro-utils";
|
|
15
|
+
import { classNames } from "@v-c/util";
|
|
16
|
+
import isEqual from "@v-c/util/dist/isEqual";
|
|
17
|
+
import { useConfig } from "antdv-next/config-provider/context";
|
|
18
|
+
//#region src/InternalTable.tsx
|
|
19
|
+
function useRowKey(props) {
|
|
20
|
+
return computed(() => {
|
|
21
|
+
if (typeof props.rowKey === "function") return props.rowKey;
|
|
22
|
+
const rowKey = (record, index) => {
|
|
23
|
+
if (index === -1) return record[props.rowKey];
|
|
24
|
+
if (props.name) return index?.toString();
|
|
25
|
+
return record[props.rowKey] ?? index?.toString();
|
|
26
|
+
};
|
|
27
|
+
return rowKey;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function useMergedPagination({ pagination, action, intl, request, type }) {
|
|
31
|
+
return computed(() => {
|
|
32
|
+
const newPropsPagination = pagination === false ? false : { ...pagination || {} };
|
|
33
|
+
const pageConfig = {
|
|
34
|
+
...action.pageInfo.value,
|
|
35
|
+
setPageInfo: ({ pageSize, current }) => {
|
|
36
|
+
const { pageInfo } = action;
|
|
37
|
+
if (pageSize === pageInfo.value.pageSize || pageInfo.value.current === 1) {
|
|
38
|
+
action.setPageInfo({
|
|
39
|
+
pageSize,
|
|
40
|
+
current
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (request) action.setDataSource([]);
|
|
45
|
+
action.setPageInfo({
|
|
46
|
+
pageSize,
|
|
47
|
+
current: type === "listy" ? current : 1
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (request && newPropsPagination) {
|
|
52
|
+
delete newPropsPagination.onChange;
|
|
53
|
+
delete newPropsPagination.onShowSizeChange;
|
|
54
|
+
}
|
|
55
|
+
return mergePagination(newPropsPagination, pageConfig, intl.value);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const InternalProTable = /* @__PURE__ */ defineComponent((props, { slots, expose }) => {
|
|
59
|
+
const config = useConfig();
|
|
60
|
+
const formRef = shallowRef();
|
|
61
|
+
const prefixCls = computed(() => props.prefixCls ?? config.value.getPrefixCls("pro"));
|
|
62
|
+
const baseClassName = computed(() => `${prefixCls.value}-table`);
|
|
63
|
+
const intl = useIntl();
|
|
64
|
+
const { token } = proTheme?.useToken();
|
|
65
|
+
/** 通用的来操作子节点的工具类 */
|
|
66
|
+
const actionRef = shallowRef();
|
|
67
|
+
const counter = useTableContextInject();
|
|
68
|
+
const [hashId, cssVarCls] = style_default(baseClassName);
|
|
69
|
+
/** 单选多选的相关逻辑 */
|
|
70
|
+
const [selectedRowKeys, setSelectedRowKeys] = useMountMergeState(props.rowSelection ? props.rowSelection?.defaultSelectedRowKeys || [] : void 0, { value: computed(() => props.rowSelection ? props.rowSelection.selectedRowKeys : void 0) });
|
|
71
|
+
const [formSearch, setFormSearch] = useMountMergeState(() => {
|
|
72
|
+
if (props.manualRequest || props.search !== false) return;
|
|
73
|
+
return {};
|
|
74
|
+
});
|
|
75
|
+
const [proFilter, setProFilter] = useMountMergeState({});
|
|
76
|
+
const [proSort, setProSort] = useMountMergeState({});
|
|
77
|
+
const defaultProTableParams = computed(() => {
|
|
78
|
+
const { sort, filter } = parseServerDefaultColumnConfig(flattenColumns(props.columns));
|
|
79
|
+
return {
|
|
80
|
+
defaultProFilter: filter,
|
|
81
|
+
defaultProSort: sort
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
/** 设置默认排序和筛选值 */
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setProFilter(defaultProTableParams.value.defaultProFilter);
|
|
87
|
+
setProSort(defaultProTableParams.value.defaultProSort);
|
|
88
|
+
}, [() => defaultProTableParams.value.defaultProFilter, () => defaultProTableParams.value.defaultProSort]);
|
|
89
|
+
/** 需要初始化 不然默认可能报错 这里取了 defaultCurrent 和 current 为了保证不会重复刷新 */
|
|
90
|
+
const fetchPagination = computed(() => typeof props.pagination === "object" ? props.pagination : {
|
|
91
|
+
defaultCurrent: 1,
|
|
92
|
+
defaultPageSize: 20,
|
|
93
|
+
pageSize: 20,
|
|
94
|
+
current: 1
|
|
95
|
+
});
|
|
96
|
+
const fetchData = computed(() => {
|
|
97
|
+
if (!props.request) return void 0;
|
|
98
|
+
return async (pageParams) => {
|
|
99
|
+
const actionParams = {
|
|
100
|
+
...pageParams || {},
|
|
101
|
+
...formSearch.value,
|
|
102
|
+
...props.params
|
|
103
|
+
};
|
|
104
|
+
delete actionParams._timestamp;
|
|
105
|
+
return await props.request?.(actionParams, proSort.value, proFilter.value);
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
const action = useFetchData(fetchData, props.defaultData, {
|
|
109
|
+
pageInfo: computed(() => props.pagination === false ? false : fetchPagination.value),
|
|
110
|
+
loading: toRef(() => props.loading),
|
|
111
|
+
dataSource: toRef(() => props.dataSource),
|
|
112
|
+
onDataSourceChange: props.onDataSourceChange,
|
|
113
|
+
onLoad: props.onLoad,
|
|
114
|
+
onLoadingChange: props.onLoadingChange,
|
|
115
|
+
onRequestError: props.onRequestError,
|
|
116
|
+
postData: props.postData,
|
|
117
|
+
revalidateOnFocus: toRef(() => props.revalidateOnFocus || false),
|
|
118
|
+
manual: computed(() => formSearch.value === void 0),
|
|
119
|
+
polling: toRef(() => props.polling),
|
|
120
|
+
effects: [
|
|
121
|
+
() => stringify(props.params),
|
|
122
|
+
() => stringify(formSearch.value),
|
|
123
|
+
() => stringify(proFilter.value),
|
|
124
|
+
() => stringify(proSort.value)
|
|
125
|
+
],
|
|
126
|
+
debounceTime: toRef(() => props.debounceTime),
|
|
127
|
+
onPageInfoChange: (pageInfo) => {
|
|
128
|
+
if (!props.pagination || !fetchData.value) return;
|
|
129
|
+
props.pagination?.onChange?.(pageInfo.current, pageInfo.pageSize);
|
|
130
|
+
props.pagination?.onShowSizeChange?.(pageInfo.current, pageInfo.pageSize);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
/** 聚焦的时候重新请求数据,这样可以保证数据都是最新的。 */
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (props.manualRequest || !props.request || !props.revalidateOnFocus || props.form?.ignoreRules) return;
|
|
136
|
+
const visibilitychange = async () => {
|
|
137
|
+
if (document.visibilityState === "visible") await action.reload();
|
|
138
|
+
};
|
|
139
|
+
document.addEventListener("visibilitychange", visibilitychange);
|
|
140
|
+
return () => document.removeEventListener("visibilitychange", visibilitychange);
|
|
141
|
+
}, []);
|
|
142
|
+
/** SelectedRowKeys受控处理selectRows */
|
|
143
|
+
const preserveRecords = shallowRef(/* @__PURE__ */ new Map());
|
|
144
|
+
const getRowKey = useRowKey(props);
|
|
145
|
+
watchEffect(() => {
|
|
146
|
+
if (action.dataSource.value?.length) action.dataSource.value.forEach((data) => {
|
|
147
|
+
const dataRowKey = getRowKey.value(data, -1);
|
|
148
|
+
preserveRecords.value.set(dataRowKey, data);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
/** 清空所有的选中项 */
|
|
152
|
+
const onCleanSelected = () => {
|
|
153
|
+
if (props.rowSelection && props.rowSelection.onChange) props.rowSelection.onChange([], [], { type: "all" });
|
|
154
|
+
setSelectedRowKeys([]);
|
|
155
|
+
};
|
|
156
|
+
if (counter.propsRef) counter.propsRef.value = props;
|
|
157
|
+
if (counter.setPrefixName) counter.setPrefixName(props.name);
|
|
158
|
+
/** 可编辑行的相关配置 */
|
|
159
|
+
const editableUtils = useEditableArray({
|
|
160
|
+
...props.editable,
|
|
161
|
+
type: computed(() => props.editable?.type),
|
|
162
|
+
editableKeys: computed(() => props.editable?.editableKeys),
|
|
163
|
+
tableName: computed(() => props.name),
|
|
164
|
+
getRowKey,
|
|
165
|
+
childrenColumnName: computed(() => props.expandable?.childrenColumnName || "children"),
|
|
166
|
+
dataSource: computed(() => action?.dataSource.value || []),
|
|
167
|
+
setDataSource: (data) => {
|
|
168
|
+
props.editable?.onValuesChange?.(void 0, data);
|
|
169
|
+
action?.setDataSource(data);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
/** 绑定 action */
|
|
173
|
+
actionRef.value = useActionType(action, {
|
|
174
|
+
nativeElement: computed(() => counter.rootDomRef?.value),
|
|
175
|
+
focus: () => {
|
|
176
|
+
counter.rootDomRef?.value?.focus();
|
|
177
|
+
},
|
|
178
|
+
fullScreen: async () => {
|
|
179
|
+
if (!counter.rootDomRef?.value || !document.fullscreenEnabled) return;
|
|
180
|
+
if (document.fullscreenElement) await document.exitFullscreen();
|
|
181
|
+
else await counter.rootDomRef?.value.requestFullscreen();
|
|
182
|
+
},
|
|
183
|
+
onCleanSelected: async () => {
|
|
184
|
+
onCleanSelected();
|
|
185
|
+
},
|
|
186
|
+
resetAll: async () => {
|
|
187
|
+
onCleanSelected();
|
|
188
|
+
counter.setKeyWords?.(void 0);
|
|
189
|
+
action.setPageInfo({ current: 1 });
|
|
190
|
+
setProFilter(defaultProTableParams.value.defaultProFilter);
|
|
191
|
+
setProSort(defaultProTableParams.value.defaultProSort);
|
|
192
|
+
formRef.value?.resetFields();
|
|
193
|
+
setFormSearch({});
|
|
194
|
+
},
|
|
195
|
+
editableUtils
|
|
196
|
+
});
|
|
197
|
+
/** 同步 action */
|
|
198
|
+
counter.setAction?.(actionRef.value);
|
|
199
|
+
const tableColumns = computed(() => genProColumnsToColumns({
|
|
200
|
+
columns: props.columns,
|
|
201
|
+
counter,
|
|
202
|
+
columnEmptyText: props.columnEmptyText || "-",
|
|
203
|
+
type: props.type,
|
|
204
|
+
editableUtils,
|
|
205
|
+
marginSM: token.value.marginSM,
|
|
206
|
+
rowKey: props.rowKey || "id",
|
|
207
|
+
childrenColumnName: props.expandable?.childrenColumnName ?? "children",
|
|
208
|
+
proFilter: proFilter.value,
|
|
209
|
+
proSort: proSort.value
|
|
210
|
+
})?.sort(columnSort(counter.columnsMap?.value)));
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (tableColumns.value && tableColumns.value.length > 0) {
|
|
213
|
+
const columnKeys = tableColumns.value.map((item) => genColumnKey(item.key, item.index));
|
|
214
|
+
counter.setSortKeyColumns?.(columnKeys);
|
|
215
|
+
}
|
|
216
|
+
}, [() => tableColumns.value]);
|
|
217
|
+
const selectedRows = computed(() => selectedRowKeys.value?.map((key) => preserveRecords.value?.get(key)));
|
|
218
|
+
/** 页面编辑的计算 */
|
|
219
|
+
const pagination = useMergedPagination({
|
|
220
|
+
pagination: props.pagination,
|
|
221
|
+
action,
|
|
222
|
+
intl,
|
|
223
|
+
request: props.request,
|
|
224
|
+
type: props.type || "table"
|
|
225
|
+
});
|
|
226
|
+
const onFormSearchSubmit = async (values) => {
|
|
227
|
+
if (props.options && props.options.search) {
|
|
228
|
+
const { name = "keyword" } = props.options.search === true ? {} : props.options.search;
|
|
229
|
+
/** 如果传入的 onSearch 返回值为 false,则不要把options.search.name对应的值set到formSearch */
|
|
230
|
+
if (typeof props.options.search !== "boolean") {
|
|
231
|
+
if (await props.options.search?.onSearch?.(counter.keyWords?.value)) {
|
|
232
|
+
setFormSearch({
|
|
233
|
+
...values,
|
|
234
|
+
[name]: counter.keyWords?.value
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
setFormSearch(values);
|
|
241
|
+
};
|
|
242
|
+
const loading = computed(() => {
|
|
243
|
+
if (typeof action.loading.value === "object") return action.loading.value.spinning || false;
|
|
244
|
+
return action.loading.value;
|
|
245
|
+
});
|
|
246
|
+
/** 是不是 LightFilter, LightFilter 有一些特殊的处理 */
|
|
247
|
+
const isLightFilter = computed(() => props.search !== false && props.search?.filterType === "light");
|
|
248
|
+
const hideToolbar = computed(() => props.options === false && !props.headerTitle && !props.toolBarRender && !props.toolbar && !isLightFilter.value);
|
|
249
|
+
expose({
|
|
250
|
+
...actionRef.value,
|
|
251
|
+
get nativeElement() {
|
|
252
|
+
return actionRef.value?.nativeElement;
|
|
253
|
+
},
|
|
254
|
+
get pageInfo() {
|
|
255
|
+
return actionRef.value?.pageInfo;
|
|
256
|
+
},
|
|
257
|
+
formRef: useProFormInstanceExpose(formRef)
|
|
258
|
+
});
|
|
259
|
+
return () => {
|
|
260
|
+
const { name: isEditorTable, tableAlertRender, tableAlertOptionRender, rowSelection: propsRowSelection = false, toolBarRender, headerTitle, toolbar, ghost, search, columns, form, type = "table", manualRequest, onReset, onSubmit, searchFormRender, optionsRender, dateFormatter, beforeSearchSubmit, cardBordered, options, tooltip } = props;
|
|
261
|
+
/** 行选择相关的问题 */
|
|
262
|
+
const rowSelection = {
|
|
263
|
+
selectedRowKeys: selectedRowKeys.value,
|
|
264
|
+
...props.rowSelection,
|
|
265
|
+
onChange: (keys, rows) => {
|
|
266
|
+
if (props.rowSelection && props.rowSelection.onChange) props.rowSelection.onChange(keys, rows, { type: "all" });
|
|
267
|
+
setSelectedRowKeys(keys);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
const defaultSearchNode = search === false && type !== "form" ? null : createVNode(FormSearch, {
|
|
271
|
+
"pagination": pagination.value,
|
|
272
|
+
"beforeSearchSubmit": beforeSearchSubmit,
|
|
273
|
+
"action": actionRef.value,
|
|
274
|
+
"columns": columns,
|
|
275
|
+
"onFormSearchSubmit": onFormSearchSubmit,
|
|
276
|
+
"ghost": ghost,
|
|
277
|
+
"onReset": onReset,
|
|
278
|
+
"onSubmit": onSubmit,
|
|
279
|
+
"loading": !!loading.value,
|
|
280
|
+
"manualRequest": manualRequest,
|
|
281
|
+
"search": search,
|
|
282
|
+
"form": form,
|
|
283
|
+
"type": type,
|
|
284
|
+
"cardBordered": typeof cardBordered === "string" ? true : cardBordered,
|
|
285
|
+
"dateFormatter": dateFormatter
|
|
286
|
+
}, null);
|
|
287
|
+
const searchNode = searchFormRender && defaultSearchNode ? searchFormRender(props, defaultSearchNode) : defaultSearchNode;
|
|
288
|
+
/** 内置的工具栏 */
|
|
289
|
+
const toolbarDom = toolBarRender === false ? null : createVNode(Toolbar, {
|
|
290
|
+
"headerTitle": headerTitle,
|
|
291
|
+
"hideToolbar": hideToolbar.value,
|
|
292
|
+
"selectedRows": selectedRows.value,
|
|
293
|
+
"loading": loading.value,
|
|
294
|
+
"selectedRowKeys": selectedRowKeys.value,
|
|
295
|
+
"columns": tableColumns.value,
|
|
296
|
+
"tooltip": tooltip,
|
|
297
|
+
"toolbar": toolbar,
|
|
298
|
+
"onFormSearchSubmit": (newValues) => setFormSearch({
|
|
299
|
+
...formSearch.value,
|
|
300
|
+
...newValues
|
|
301
|
+
}),
|
|
302
|
+
"searchNode": isLightFilter.value && searchNode !== null ? cloneVNode(searchNode, { ref: formRef }) : null,
|
|
303
|
+
"options": options,
|
|
304
|
+
"optionsRender": optionsRender,
|
|
305
|
+
"action": actionRef.value,
|
|
306
|
+
"toolBarRender": toolBarRender
|
|
307
|
+
}, null);
|
|
308
|
+
/** 内置的多选操作栏 */
|
|
309
|
+
const alertDom = propsRowSelection ? createVNode(TableAlert, {
|
|
310
|
+
"selectedRowKeys": selectedRowKeys.value,
|
|
311
|
+
"selectedRows": selectedRows.value,
|
|
312
|
+
"onCleanSelected": onCleanSelected,
|
|
313
|
+
"alertOptionRender": tableAlertOptionRender,
|
|
314
|
+
"alertInfoRender": tableAlertRender,
|
|
315
|
+
"alwaysShowAlert": propsRowSelection?.alwaysShowAlert
|
|
316
|
+
}, null) : null;
|
|
317
|
+
return createVNode(TableRender, mergeProps(props, {
|
|
318
|
+
"class": classNames(baseClassName.value, hashId.value, cssVarCls.value),
|
|
319
|
+
"name": isEditorTable,
|
|
320
|
+
"prefixCls": baseClassName.value,
|
|
321
|
+
"size": counter.tableSize?.value,
|
|
322
|
+
"onSizeChange": counter.setTableSize,
|
|
323
|
+
"pagination": pagination.value,
|
|
324
|
+
"searchNode": searchNode !== null ? cloneVNode(searchNode, { ref: formRef }) : null,
|
|
325
|
+
"rowSelection": propsRowSelection ? rowSelection : void 0,
|
|
326
|
+
"tableColums": tableColumns.value,
|
|
327
|
+
"isLightFilter": isLightFilter.value,
|
|
328
|
+
"action": action,
|
|
329
|
+
"alertDom": alertDom,
|
|
330
|
+
"toolbarDom": toolbarDom,
|
|
331
|
+
"hideToolbar": hideToolbar.value,
|
|
332
|
+
"onSortChange": (sortConfig) => {
|
|
333
|
+
if (isEqual(proSort.value, sortConfig)) return;
|
|
334
|
+
setProSort(sortConfig ?? {});
|
|
335
|
+
},
|
|
336
|
+
"onFilterChange": (filterConfig) => {
|
|
337
|
+
if (isEqual(filterConfig, proFilter.value)) return;
|
|
338
|
+
setProFilter(filterConfig ?? {});
|
|
339
|
+
},
|
|
340
|
+
"editableUtils": editableUtils,
|
|
341
|
+
"getRowKey": getRowKey.value
|
|
342
|
+
}), slots);
|
|
343
|
+
};
|
|
344
|
+
}, {
|
|
345
|
+
name: "InternalProTable",
|
|
346
|
+
props: [
|
|
347
|
+
"beforeSearchSubmit",
|
|
348
|
+
"bodyCell",
|
|
349
|
+
"bordered",
|
|
350
|
+
"caption",
|
|
351
|
+
"cardBordered",
|
|
352
|
+
"cardProps",
|
|
353
|
+
"childrenColumnName",
|
|
354
|
+
"classes",
|
|
355
|
+
"columnEmptyText",
|
|
356
|
+
"columns",
|
|
357
|
+
"columnsState",
|
|
358
|
+
"components",
|
|
359
|
+
"dataSource",
|
|
360
|
+
"dateFormatter",
|
|
361
|
+
"debounceTime",
|
|
362
|
+
"defaultData",
|
|
363
|
+
"defaultExpandAllRows",
|
|
364
|
+
"defaultExpandedRowKeys",
|
|
365
|
+
"defaultSize",
|
|
366
|
+
"direction",
|
|
367
|
+
"dropdownPrefixCls",
|
|
368
|
+
"editable",
|
|
369
|
+
"errorBoundaryRender",
|
|
370
|
+
"expandIcon",
|
|
371
|
+
"expandIconColumnIndex",
|
|
372
|
+
"expandRowByClick",
|
|
373
|
+
"expandable",
|
|
374
|
+
"expandedRowClassName",
|
|
375
|
+
"expandedRowKeys",
|
|
376
|
+
"expandedRowRender",
|
|
377
|
+
"footer",
|
|
378
|
+
"form",
|
|
379
|
+
"getContainerWidth",
|
|
380
|
+
"getPopupContainer",
|
|
381
|
+
"ghost",
|
|
382
|
+
"headerCell",
|
|
383
|
+
"headerTitle",
|
|
384
|
+
"id",
|
|
385
|
+
"indentSize",
|
|
386
|
+
"loading",
|
|
387
|
+
"locale",
|
|
388
|
+
"manualRequest",
|
|
389
|
+
"measureRowRender",
|
|
390
|
+
"name",
|
|
391
|
+
"onDataSourceChange",
|
|
392
|
+
"onExpand",
|
|
393
|
+
"onExpandedRowsChange",
|
|
394
|
+
"onHeaderRow",
|
|
395
|
+
"onLoad",
|
|
396
|
+
"onLoadingChange",
|
|
397
|
+
"onRequestError",
|
|
398
|
+
"onReset",
|
|
399
|
+
"onRow",
|
|
400
|
+
"onSizeChange",
|
|
401
|
+
"onSubmit",
|
|
402
|
+
"options",
|
|
403
|
+
"optionsRender",
|
|
404
|
+
"pagination",
|
|
405
|
+
"params",
|
|
406
|
+
"polling",
|
|
407
|
+
"postData",
|
|
408
|
+
"prefixCls",
|
|
409
|
+
"request",
|
|
410
|
+
"revalidateOnFocus",
|
|
411
|
+
"rootClass",
|
|
412
|
+
"rowClassName",
|
|
413
|
+
"rowHoverable",
|
|
414
|
+
"rowKey",
|
|
415
|
+
"rowSelection",
|
|
416
|
+
"scroll",
|
|
417
|
+
"search",
|
|
418
|
+
"searchFormRender",
|
|
419
|
+
"showHeader",
|
|
420
|
+
"showSorterTooltip",
|
|
421
|
+
"size",
|
|
422
|
+
"sortDirections",
|
|
423
|
+
"sticky",
|
|
424
|
+
"styles",
|
|
425
|
+
"summary",
|
|
426
|
+
"tableAlertOptionRender",
|
|
427
|
+
"tableAlertRender",
|
|
428
|
+
"tableClass",
|
|
429
|
+
"tableExtraRender",
|
|
430
|
+
"tableLayout",
|
|
431
|
+
"tableRender",
|
|
432
|
+
"tableStyle",
|
|
433
|
+
"tableViewRender",
|
|
434
|
+
"tailor",
|
|
435
|
+
"title",
|
|
436
|
+
"toolBarRender",
|
|
437
|
+
"toolbar",
|
|
438
|
+
"tooltip",
|
|
439
|
+
"type",
|
|
440
|
+
"virtual"
|
|
441
|
+
]
|
|
442
|
+
});
|
|
443
|
+
//#endregion
|
|
444
|
+
export { InternalProTable as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ToolBarProps } from "./components/ToolBar/index.js";
|
|
2
|
+
import { ActionType, ProTableProps } from "./typing.js";
|
|
3
|
+
import { IntlType } from "@antdv-vue/pro-provider";
|
|
4
|
+
import { Key, WithFalse } from "@antdv-vue/pro-utils";
|
|
5
|
+
import { VueNode as VueNode$1 } from "@v-c/util";
|
|
6
|
+
|
|
7
|
+
//#region src/RenderTypings.d.ts
|
|
8
|
+
type ErrorBoundaryRender = WithFalse<(options: {
|
|
9
|
+
error: Error;
|
|
10
|
+
info: string;
|
|
11
|
+
}) => VueNode$1>;
|
|
12
|
+
type TableAlertRender<T> = WithFalse<(props: {
|
|
13
|
+
intl: IntlType;
|
|
14
|
+
selectedRowKeys: (number | string | Key)[];
|
|
15
|
+
selectedRows: T[];
|
|
16
|
+
onCleanSelected: () => void;
|
|
17
|
+
}) => VueNode$1>;
|
|
18
|
+
type TableRender<T, U, K> = WithFalse<(props: ProTableProps<T, U, K>, defaultDom: VueNode$1, /** 各个区域的 dom */
|
|
19
|
+
|
|
20
|
+
domList: {
|
|
21
|
+
toolbar?: VueNode$1;
|
|
22
|
+
alert?: VueNode$1;
|
|
23
|
+
table?: VueNode$1;
|
|
24
|
+
}) => VueNode$1>;
|
|
25
|
+
type SearchFormRender<T, U, K> = (props: ProTableProps<T, U, K>, defaultDom: VueNode$1) => VueNode$1;
|
|
26
|
+
type OptionsRender<T, U> = (props: ToolBarProps<T, U>, defaultDom: VueNode$1[]) => VueNode$1[];
|
|
27
|
+
type TableExtraRender<T, U, K> = (props: ProTableProps<T, U, K>, dataSource: any[]) => VueNode$1;
|
|
28
|
+
type ToolBarRender<T> = (action: ActionType<any, T> | undefined, rows: {
|
|
29
|
+
selectedRowKeys?: Key[];
|
|
30
|
+
selectedRows: (T | undefined)[];
|
|
31
|
+
}) => VueNode$1[];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ErrorBoundaryRender, OptionsRender, SearchFormRender, TableAlertRender, TableExtraRender, TableRender, ToolBarRender };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { SlotsType } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/ResizableTableTitle.d.ts
|
|
5
|
+
interface ResizableTableTitleProps {
|
|
6
|
+
resizable?: boolean;
|
|
7
|
+
width?: number | string;
|
|
8
|
+
}
|
|
9
|
+
interface ResizableTableTitleEmits {
|
|
10
|
+
resize: (event: MouseEvent, info: {
|
|
11
|
+
size: {
|
|
12
|
+
width: number;
|
|
13
|
+
};
|
|
14
|
+
}) => void;
|
|
15
|
+
[key: string]: (...args: any[]) => void;
|
|
16
|
+
}
|
|
17
|
+
interface ResizableTableTitleSlots {
|
|
18
|
+
default?: () => any;
|
|
19
|
+
}
|
|
20
|
+
declare const ResizableTableTitle: _$vue.DefineSetupFnComponent<ResizableTableTitleProps, ResizableTableTitleEmits, SlotsType<ResizableTableTitleSlots>, ResizableTableTitleProps & {
|
|
21
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
22
|
+
}, _$vue.PublicProps>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ResizableTableTitleEmits, ResizableTableTitleProps, ResizableTableTitleSlots, ResizableTableTitle as default };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { computed, createVNode, defineComponent, mergeProps, onBeforeUnmount, shallowRef } from "vue";
|
|
2
|
+
import { classNames } from "@v-c/util";
|
|
3
|
+
//#region src/ResizableTableTitle.tsx
|
|
4
|
+
function getWidthNumber(width, element) {
|
|
5
|
+
if (typeof width === "number") return width;
|
|
6
|
+
if (typeof width === "string") {
|
|
7
|
+
const parsedWidth = Number.parseFloat(width);
|
|
8
|
+
if (Number.isFinite(parsedWidth)) return parsedWidth;
|
|
9
|
+
}
|
|
10
|
+
return element?.offsetWidth ?? 0;
|
|
11
|
+
}
|
|
12
|
+
const ResizableTableTitle = /* @__PURE__ */ defineComponent((props, { attrs, slots, emit }) => {
|
|
13
|
+
const cellRef = shallowRef();
|
|
14
|
+
let startX = 0;
|
|
15
|
+
let startWidth = 0;
|
|
16
|
+
let previousUserSelect = "";
|
|
17
|
+
let resizeFrame;
|
|
18
|
+
let latestResize;
|
|
19
|
+
const resizeable = computed(() => !!props.resizable);
|
|
20
|
+
function clearDocumentEvents() {
|
|
21
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
22
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
23
|
+
document.body.style.userSelect = previousUserSelect;
|
|
24
|
+
if (resizeFrame !== void 0) {
|
|
25
|
+
cancelAnimationFrame(resizeFrame);
|
|
26
|
+
resizeFrame = void 0;
|
|
27
|
+
}
|
|
28
|
+
latestResize = void 0;
|
|
29
|
+
}
|
|
30
|
+
function flushResize() {
|
|
31
|
+
resizeFrame = void 0;
|
|
32
|
+
if (!latestResize) return;
|
|
33
|
+
const { event, width } = latestResize;
|
|
34
|
+
latestResize = void 0;
|
|
35
|
+
emit("resize", event, { size: { width } });
|
|
36
|
+
}
|
|
37
|
+
function scheduleResize(event, width) {
|
|
38
|
+
latestResize = {
|
|
39
|
+
event,
|
|
40
|
+
width
|
|
41
|
+
};
|
|
42
|
+
if (resizeFrame !== void 0) return;
|
|
43
|
+
resizeFrame = requestAnimationFrame(flushResize);
|
|
44
|
+
}
|
|
45
|
+
function onMouseMove(event) {
|
|
46
|
+
scheduleResize(event, Math.max(startWidth + event.clientX - startX, 40));
|
|
47
|
+
}
|
|
48
|
+
function onMouseUp() {
|
|
49
|
+
if (resizeFrame !== void 0) {
|
|
50
|
+
cancelAnimationFrame(resizeFrame);
|
|
51
|
+
flushResize();
|
|
52
|
+
}
|
|
53
|
+
clearDocumentEvents();
|
|
54
|
+
}
|
|
55
|
+
function onMouseDown(event) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
startX = event.clientX;
|
|
59
|
+
startWidth = getWidthNumber(props.width, cellRef.value);
|
|
60
|
+
previousUserSelect = document.body.style.userSelect;
|
|
61
|
+
document.body.style.userSelect = "none";
|
|
62
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
63
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
64
|
+
}
|
|
65
|
+
onBeforeUnmount(clearDocumentEvents);
|
|
66
|
+
return () => {
|
|
67
|
+
const { class: className, className: legacyClassName, style, ...restAttrs } = attrs;
|
|
68
|
+
const widthStyle = props.width == null ? void 0 : { width: typeof props.width === "number" ? `${props.width}px` : props.width };
|
|
69
|
+
return createVNode("th", mergeProps(restAttrs, {
|
|
70
|
+
"ref": cellRef,
|
|
71
|
+
"class": classNames(className, legacyClassName, { "ant-table-cell-resizable": resizeable.value }),
|
|
72
|
+
"style": {
|
|
73
|
+
...style,
|
|
74
|
+
...widthStyle,
|
|
75
|
+
position: resizeable.value ? "relative" : style?.position
|
|
76
|
+
}
|
|
77
|
+
}), [slots.default?.(), resizeable.value && createVNode("span", {
|
|
78
|
+
"class": "ant-table-cell-resizable-handle",
|
|
79
|
+
"onMousedown": onMouseDown
|
|
80
|
+
}, null)]);
|
|
81
|
+
};
|
|
82
|
+
}, {
|
|
83
|
+
name: "ResizableTableTitle",
|
|
84
|
+
inheritAttrs: false,
|
|
85
|
+
props: ["resizable", "width"],
|
|
86
|
+
emits: ["resize"]
|
|
87
|
+
});
|
|
88
|
+
//#endregion
|
|
89
|
+
export { ResizableTableTitle as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DensitySize } from "../components/ToolBar/DensityIcon.js";
|
|
2
|
+
import { ActionType, ProColumns, ProTableProps } from "../typing.js";
|
|
3
|
+
import { ComputedRef, Ref, ShallowRef } from "vue";
|
|
4
|
+
import { ParamsType } from "@antdv-vue/pro-provider";
|
|
5
|
+
import { TableColumnType } from "antdv-next";
|
|
6
|
+
import { NamePath } from "antdv-next/dist/form/types";
|
|
7
|
+
|
|
8
|
+
//#region src/Store/Provide.d.ts
|
|
9
|
+
interface ColumnsState {
|
|
10
|
+
show?: boolean;
|
|
11
|
+
fixed?: boolean | 'start' | 'end';
|
|
12
|
+
order?: number;
|
|
13
|
+
disable?: boolean | {
|
|
14
|
+
checkbox: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
type ProTableColumn<T> = ColumnsState & TableColumnType<T>;
|
|
18
|
+
interface UseContainerProps<T, U, ValueType> {
|
|
19
|
+
onColumnsStateChange?: (map: Record<string, ColumnsState> | undefined) => void;
|
|
20
|
+
size?: DensitySize;
|
|
21
|
+
defaultSize?: DensitySize;
|
|
22
|
+
onSizeChange?: (size: DensitySize) => void;
|
|
23
|
+
columns?: ProTableColumn<T>[] | ProColumns<T, ValueType>[];
|
|
24
|
+
columnsState?: ProTableProps<T, U, ValueType>['columnsState'];
|
|
25
|
+
}
|
|
26
|
+
declare function useContainer<T = Record<string, any>, U = ParamsType, ValueType = 'text'>(props?: UseContainerProps<T, U, ValueType>): {
|
|
27
|
+
action: ShallowRef<any, any>;
|
|
28
|
+
setAction: (newAction?: ActionType<any, T>) => void;
|
|
29
|
+
sortKeyColumns: ShallowRef<string[], string[]>;
|
|
30
|
+
setSortKeyColumns: (keys: string[]) => void;
|
|
31
|
+
propsRef: ShallowRef<ProTableProps<T, U, ValueType> | undefined, ProTableProps<T, U, ValueType> | undefined>;
|
|
32
|
+
tableSize: Ref<DensitySize, DensitySize>;
|
|
33
|
+
setTableSize: (val: DensitySize) => void;
|
|
34
|
+
prefixName: ShallowRef<(string | number | boolean | (string | number | boolean)[]) | undefined, (string | number | boolean | (string | number | boolean)[]) | undefined>;
|
|
35
|
+
setPrefixName: (name?: NamePath<string | number | boolean>) => void;
|
|
36
|
+
columnsMap: Ref<Record<string, ColumnsState>, Record<string, ColumnsState>>;
|
|
37
|
+
setColumnsMap: (val: Record<string, ColumnsState>) => void;
|
|
38
|
+
keyWords: Ref<string | undefined, string | undefined>;
|
|
39
|
+
setKeyWords: (val: string | undefined) => void;
|
|
40
|
+
columns: ProTableColumn<T>[] | ProColumns<T, ValueType>[] | undefined;
|
|
41
|
+
clearPersistenceStorage: () => void;
|
|
42
|
+
defaultColumnKeyMap: ComputedRef<Record<string, ColumnsState>>;
|
|
43
|
+
rootDomRef: ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
44
|
+
};
|
|
45
|
+
interface ContainerReturnType<T, U, ValueType> {
|
|
46
|
+
action?: ShallowRef<ActionType<any, T> | undefined>;
|
|
47
|
+
setAction?: (newAction?: ActionType<any, T>) => void;
|
|
48
|
+
sortKeyColumns?: ShallowRef<string[]>;
|
|
49
|
+
setSortKeyColumns?: (keys: string[]) => void;
|
|
50
|
+
propsRef?: ShallowRef<ProTableProps<T, U, ValueType> | undefined>;
|
|
51
|
+
tableSize?: Ref<DensitySize>;
|
|
52
|
+
setTableSize?: (val: DensitySize) => void;
|
|
53
|
+
prefixName: ShallowRef<NamePath<string | number | boolean> | undefined>;
|
|
54
|
+
setPrefixName?: (name?: NamePath<string | number | boolean>) => void;
|
|
55
|
+
columnsMap?: Ref<Record<string, ColumnsState>>;
|
|
56
|
+
setColumnsMap?: (val: Record<string, ColumnsState>) => void;
|
|
57
|
+
keyWords?: Ref<string | undefined>;
|
|
58
|
+
setKeyWords?: (val: string | undefined) => void;
|
|
59
|
+
columns?: ProTableColumn<T>[] | ProColumns<T, ValueType>[];
|
|
60
|
+
clearPersistenceStorage?: () => void;
|
|
61
|
+
defaultColumnKeyMap?: ComputedRef<Record<string, ColumnsState>>;
|
|
62
|
+
rootDomRef?: ShallowRef<HTMLDivElement | null>;
|
|
63
|
+
}
|
|
64
|
+
declare const tableContextKey: unique symbol;
|
|
65
|
+
declare function useTableContextProvider<T, U, S>(props: ContainerReturnType<T, U, S>): void;
|
|
66
|
+
declare const useTableContextInject: <T, U, S>() => ContainerReturnType<T, U, S>;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ColumnsState, ContainerReturnType, ProTableColumn, UseContainerProps, tableContextKey, useContainer, useTableContextInject, useTableContextProvider };
|