villianjs-pro 1.0.0 → 1.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/dist/{ProTable3 → Beyond}/index.d.ts +1 -1
- package/dist/Beyond/index.js +1 -0
- package/dist/Beyond/list.d.ts +5 -0
- package/dist/Beyond/list.js +1 -0
- package/dist/Beyond/styles/index.d.ts +8 -0
- package/dist/Beyond/styles/index.js +1 -0
- package/dist/Beyond/types.d.ts +26 -0
- package/dist/Button/types.d.ts +1 -1
- package/dist/ButtonGroup/styles.js +1 -1
- package/dist/Exports/exports.d.ts +3 -0
- package/dist/Exports/exports.js +1 -0
- package/dist/Exports/index.d.ts +2 -0
- package/dist/Exports/index.js +1 -0
- package/dist/Exports/types.d.ts +61 -0
- package/dist/List/index.d.ts +8 -0
- package/dist/List/index.js +1 -0
- package/dist/List/list-container.d.ts +37 -0
- package/dist/List/list-container.js +1 -0
- package/dist/ProTable/components/Container.d.ts +27 -0
- package/dist/ProTable/components/Container.js +1 -0
- package/dist/ProTable/components/form-content.d.ts +34 -0
- package/dist/ProTable/{update/update.js → components/form-content.js} +1 -1
- package/dist/ProTable/components/form-footer.d.ts +32 -0
- package/dist/ProTable/components/form-footer.js +1 -0
- package/dist/ProTable/components/grid-card.d.ts +27 -0
- package/dist/ProTable/components/grid-card.js +1 -0
- package/dist/ProTable/components/grid-view.d.ts +52 -0
- package/dist/ProTable/components/grid-view.js +1 -0
- package/dist/ProTable/components/header-buttons-wrapper.d.ts +10 -0
- package/dist/ProTable/components/header-buttons-wrapper.js +1 -0
- package/dist/ProTable/components/list/index.d.ts +19 -0
- package/dist/ProTable/components/list/index.js +1 -0
- package/dist/ProTable/components/operation-container.d.ts +39 -0
- package/dist/ProTable/components/operation-container.js +1 -0
- package/dist/ProTable/components/operation-content-router.d.ts +37 -0
- package/dist/ProTable/components/operation-content-router.js +1 -0
- package/dist/ProTable/components/operation-content.d.ts +35 -0
- package/dist/ProTable/components/operation-content.js +1 -0
- package/dist/ProTable/components/row-actions-router.d.ts +8 -0
- package/dist/{ProTable3/hooks/utils.js → ProTable/components/row-actions-router.js} +1 -1
- package/dist/ProTable/components/row-actions.d.ts +59 -0
- package/dist/ProTable/components/row-actions.js +1 -0
- package/dist/ProTable/components/search.d.ts +3 -0
- package/dist/{ProTable2 → ProTable}/components/search.js +1 -1
- package/dist/ProTable/context.d.ts +20 -58
- package/dist/ProTable/context.js +1 -1
- package/dist/ProTable/hooks/usePagination.js +1 -0
- package/dist/ProTable/hooks/useRouterNavigation.d.ts +10 -0
- package/dist/ProTable/hooks/useRouterNavigation.js +1 -0
- package/dist/ProTable/index.d.ts +3 -2
- package/dist/ProTable/index.js +1 -1
- package/dist/ProTable/styles.d.ts +1 -0
- package/dist/ProTable/styles.js +1 -1
- package/dist/ProTable/table.d.ts +2 -3
- package/dist/ProTable/table.js +1 -1
- package/dist/ProTable/types.d.ts +389 -90
- package/dist/ProTable/utils.d.ts +83 -0
- package/dist/ProTable/utils.js +1 -0
- package/dist/TabSelector/TabSelector.d.ts +3 -0
- package/dist/TabSelector/TabSelector.js +1 -0
- package/dist/TabSelector/index.d.ts +2 -0
- package/dist/TabSelector/index.js +1 -0
- package/dist/TabSelector/modal.d.ts +16 -0
- package/dist/TabSelector/modal.js +1 -0
- package/dist/TabSelector/selected-items-display.d.ts +11 -0
- package/dist/TabSelector/selected-items-display.js +1 -0
- package/dist/TabSelector/styles.d.ts +2 -0
- package/dist/TabSelector/styles.js +1 -0
- package/dist/TabSelector/types.d.ts +24 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/locale/langs/zh-cn/index.js +1 -1
- package/package.json +30 -17
- package/dist/ProTable/form-footer.d.ts +0 -26
- package/dist/ProTable/form-footer.js +0 -1
- package/dist/ProTable/list.d.ts +0 -5
- package/dist/ProTable/list.js +0 -1
- package/dist/ProTable/update/index.d.ts +0 -1
- package/dist/ProTable/update/index.js +0 -1
- package/dist/ProTable/update/update.d.ts +0 -3
- package/dist/ProTable2/components/search.d.ts +0 -2
- package/dist/ProTable2/index.d.ts +0 -2
- package/dist/ProTable2/index.js +0 -1
- package/dist/ProTable2/styles.d.ts +0 -7
- package/dist/ProTable2/styles.js +0 -1
- package/dist/ProTable2/table.d.ts +0 -2
- package/dist/ProTable2/table.js +0 -1
- package/dist/ProTable2/types.d.ts +0 -23
- package/dist/ProTable3/components/index.d.ts +0 -2
- package/dist/ProTable3/components/index.js +0 -1
- package/dist/ProTable3/components/list/index.d.ts +0 -19
- package/dist/ProTable3/components/list/index.js +0 -1
- package/dist/ProTable3/components/search/index.d.ts +0 -2
- package/dist/ProTable3/components/search/index.js +0 -1
- package/dist/ProTable3/container.d.ts +0 -3
- package/dist/ProTable3/container.js +0 -1
- package/dist/ProTable3/context.d.ts +0 -13
- package/dist/ProTable3/context.js +0 -1
- package/dist/ProTable3/hooks/types.d.ts +0 -72
- package/dist/ProTable3/hooks/useBatchRemoveButton.d.ts +0 -38
- package/dist/ProTable3/hooks/useBatchRemoveButton.js +0 -1
- package/dist/ProTable3/hooks/useCreateButton.d.ts +0 -34
- package/dist/ProTable3/hooks/useCreateButton.js +0 -1
- package/dist/ProTable3/hooks/useExtraButtons.d.ts +0 -26
- package/dist/ProTable3/hooks/useExtraButtons.js +0 -1
- package/dist/ProTable3/hooks/useOptionRender.d.ts +0 -30
- package/dist/ProTable3/hooks/useOptionRender.js +0 -1
- package/dist/ProTable3/hooks/usePagination.js +0 -1
- package/dist/ProTable3/hooks/utils.d.ts +0 -12
- package/dist/ProTable3/index.js +0 -1
- package/dist/ProTable3/styles.d.ts +0 -7
- package/dist/ProTable3/styles.js +0 -1
- package/dist/ProTable3/table.d.ts +0 -2
- package/dist/ProTable3/table.js +0 -1
- package/dist/ProTable3/types.d.ts +0 -106
- /package/dist/{ProTable2 → Beyond}/types.js +0 -0
- /package/dist/{ProTable3/hooks → Exports}/types.js +0 -0
- /package/dist/{ProTable3 → ProTable}/hooks/usePagination.d.ts +0 -0
- /package/dist/{ProTable3 → TabSelector}/types.js +0 -0
package/dist/ProTable/types.d.ts
CHANGED
|
@@ -1,121 +1,420 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from 'react';
|
|
1
|
+
import * as React from "react";
|
|
3
2
|
import type { SizeType } from "antd/es/config-provider/SizeContext";
|
|
4
|
-
import type
|
|
3
|
+
import { type ProTableProps as AntdProTableProps, type ProColumns } from "@ant-design/pro-components";
|
|
4
|
+
import type { Key } from "react";
|
|
5
5
|
import type { ButtonGroupItem } from "../ButtonGroup";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type VlianTableColumn<T, ValueType = 'text'> = ProColumns<T, ValueType> & {
|
|
14
|
-
textType?: 'input' | 'select';
|
|
15
|
-
};
|
|
6
|
+
import type { DrawerProps } from "antd";
|
|
7
|
+
import type { FormSchema } from "@ant-design/pro-form/es/components/SchemaForm/typing";
|
|
8
|
+
import type { ProFormColumnsType } from "../Form/types";
|
|
9
|
+
import type { ModalProps } from "../Modal/components/antd";
|
|
10
|
+
/**
|
|
11
|
+
* 表格操作模式
|
|
12
|
+
*/
|
|
16
13
|
export type VlianTableMode = "modal" | "drawer" | "router";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 获取详情
|
|
43
|
-
* @param record
|
|
44
|
-
* @param index
|
|
45
|
-
*/
|
|
46
|
-
detail?: <T>(record: T, index: number) => Promise<any>;
|
|
47
|
-
maxOptionCount?: number;
|
|
48
|
-
};
|
|
49
|
-
export type BooleanCallback = Promise<boolean> | boolean;
|
|
50
|
-
export type Obj = Record<string, any>;
|
|
51
|
-
export interface TablePermissionMap {
|
|
52
|
-
create?: string;
|
|
53
|
-
batchRemove?: string;
|
|
54
|
-
view?: string;
|
|
55
|
-
update?: string;
|
|
56
|
-
remove?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 操作类型
|
|
16
|
+
*/
|
|
17
|
+
export type OperationType = "list" | "create" | "update" | "view";
|
|
18
|
+
/**
|
|
19
|
+
* 视图显示模式
|
|
20
|
+
*/
|
|
21
|
+
export type ViewMode = "table" | "grid";
|
|
22
|
+
/**
|
|
23
|
+
* 网格卡片渲染函数的参数
|
|
24
|
+
*/
|
|
25
|
+
export interface GridCardRenderParams<T = any> {
|
|
26
|
+
/** 当前记录数据 */
|
|
27
|
+
record: T;
|
|
28
|
+
/** 记录索引 */
|
|
29
|
+
index: number;
|
|
30
|
+
/** 当前记录是否被选中 */
|
|
31
|
+
isSelected?: boolean;
|
|
32
|
+
/** 当前记录的 key */
|
|
33
|
+
rowKey?: React.Key;
|
|
34
|
+
/** 切换选中状态的方法 */
|
|
35
|
+
onSelect?: (selected: boolean) => void;
|
|
36
|
+
/** 是否显示选择框 */
|
|
37
|
+
showSelection?: boolean;
|
|
57
38
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
/**
|
|
40
|
+
* 网格卡片渲染函数
|
|
41
|
+
*/
|
|
42
|
+
export type GridCardRender<T = any> = (params: GridCardRenderParams<T>) => React.ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* 提取 FormSchema 的 submitter 类型
|
|
45
|
+
*/
|
|
46
|
+
type FormSchemaSubmitter<T, ValueType extends string = 'text'> = FormSchema<T, ValueType>['submitter'];
|
|
47
|
+
/**
|
|
48
|
+
* 搜索表单类型
|
|
49
|
+
*/
|
|
50
|
+
export type SearchType = Extract<FormSchema["layoutType"], "QueryFilter" | "Form">;
|
|
51
|
+
/**
|
|
52
|
+
* ProTableSearch 组件属性
|
|
53
|
+
* 继承 FormSchema 的所有属性,并扩展自定义属性
|
|
54
|
+
*/
|
|
55
|
+
export type ProTableSearchProps<T = Record<string, any>, ValueType extends string = 'text'> = Omit<FormSchema<T, ValueType>, 'layoutType' | 'submitter' | 'columns'> & {
|
|
56
|
+
/**
|
|
57
|
+
* @description 布局类型
|
|
58
|
+
* @default Form
|
|
59
|
+
*/
|
|
60
|
+
layoutType?: SearchType;
|
|
61
|
+
/**
|
|
62
|
+
* @description 表单列配置(支持 ProColumns 和 ProFormColumnsType)
|
|
63
|
+
* @default []
|
|
64
|
+
*/
|
|
65
|
+
columns?: ProColumns<T, ValueType>[] | ProFormColumnsType<T, ValueType>[];
|
|
66
|
+
/**
|
|
67
|
+
* @description 标签宽度
|
|
68
|
+
* @default auto
|
|
69
|
+
*/
|
|
70
|
+
labelWidth?: string | number;
|
|
71
|
+
/**
|
|
72
|
+
* @description 标签布局属性
|
|
73
|
+
*/
|
|
74
|
+
labelCol?: React.CSSProperties;
|
|
75
|
+
/**
|
|
76
|
+
* @description 提交按钮配置,设置为 false 时隐藏提交按钮
|
|
77
|
+
*/
|
|
78
|
+
submitter?: FormSchemaSubmitter<T, ValueType> | {
|
|
79
|
+
/**
|
|
80
|
+
* @description 自定义渲染提交按钮
|
|
81
|
+
*/
|
|
82
|
+
render?: false | ((props: any, doms: React.ReactNode[]) => React.ReactNode);
|
|
83
|
+
/**
|
|
84
|
+
* @description 搜索配置
|
|
85
|
+
*/
|
|
86
|
+
searchConfig?: {
|
|
87
|
+
/**
|
|
88
|
+
* @description 提交按钮文本
|
|
89
|
+
*/
|
|
90
|
+
submitText?: string;
|
|
91
|
+
/**
|
|
92
|
+
* @description 重置按钮文本
|
|
93
|
+
*/
|
|
94
|
+
resetText?: string;
|
|
95
|
+
};
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
};
|
|
67
98
|
};
|
|
68
|
-
|
|
99
|
+
/**
|
|
100
|
+
* 搜索配置
|
|
101
|
+
*/
|
|
102
|
+
export type SearchConfig<T = Record<string, any>, ValueType = "text"> = {
|
|
69
103
|
/**
|
|
70
|
-
*
|
|
104
|
+
* @description 布局类型
|
|
105
|
+
* @default Form
|
|
71
106
|
*/
|
|
72
|
-
|
|
107
|
+
layoutType?: SearchType;
|
|
73
108
|
/**
|
|
74
|
-
*
|
|
109
|
+
* @description 表单布局
|
|
110
|
+
* @default inline
|
|
75
111
|
*/
|
|
76
|
-
|
|
112
|
+
layout?: "horizontal" | "vertical" | "inline";
|
|
77
113
|
/**
|
|
78
|
-
*
|
|
114
|
+
* @description 搜索表单其他属性(排除 columns,因为 columns 由表格 columns 自动生成)
|
|
79
115
|
*/
|
|
80
|
-
|
|
116
|
+
searchProps?: Omit<ProTableSearchProps<T, ValueType extends string ? ValueType : "text">, "columns" | "layoutType" | "layout">;
|
|
81
117
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
/**
|
|
119
|
+
* 操作按钮配置
|
|
120
|
+
*/
|
|
121
|
+
export interface HeaderButtonItem extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'disabled'> {
|
|
122
|
+
/**
|
|
123
|
+
* @description 按钮 key
|
|
124
|
+
*/
|
|
125
|
+
key?: string;
|
|
126
|
+
/**
|
|
127
|
+
* @description 按钮是否可见(支持函数形式,根据 selectedRowKeys 动态判断)
|
|
128
|
+
*/
|
|
129
|
+
visible?: boolean | ((selectKeys: Key[]) => boolean);
|
|
130
|
+
/**
|
|
131
|
+
* @description 按钮是否禁用(支持函数形式,根据 selectedRowKeys 动态判断)
|
|
132
|
+
*/
|
|
133
|
+
disabled?: boolean | ((selectKeys: Key[]) => boolean);
|
|
134
|
+
/**
|
|
135
|
+
* @description 点击回调
|
|
136
|
+
*/
|
|
137
|
+
onClick?: (selectKeys: Key[]) => void | Promise<void>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 操作行按钮配置
|
|
141
|
+
*/
|
|
142
|
+
export interface RowButtonItem<T = any> extends Omit<ButtonGroupItem, 'key' | 'onClick' | 'disabled'> {
|
|
143
|
+
/**
|
|
144
|
+
* @description 按钮 key
|
|
145
|
+
*/
|
|
146
|
+
key?: string;
|
|
147
|
+
/**
|
|
148
|
+
* @description 按钮是否可见
|
|
149
|
+
*/
|
|
150
|
+
visible?: boolean | ((record: T, index: number) => boolean);
|
|
151
|
+
/**
|
|
152
|
+
* @description 按钮是否禁用
|
|
153
|
+
*/
|
|
154
|
+
disabled?: boolean | ((record: T, index: number) => boolean);
|
|
155
|
+
/**
|
|
156
|
+
* @description 点击回调
|
|
157
|
+
*/
|
|
158
|
+
onClick?: (record: T, index: number) => void | Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 操作内容渲染函数
|
|
162
|
+
*/
|
|
163
|
+
export type OperationContentRender<T = any> = (params: {
|
|
164
|
+
type: OperationType;
|
|
165
|
+
record?: T;
|
|
166
|
+
onClose: () => void;
|
|
167
|
+
onSuccess?: () => void;
|
|
168
|
+
}) => React.ReactNode;
|
|
169
|
+
/**
|
|
170
|
+
* 表单底部渲染函数
|
|
171
|
+
*/
|
|
172
|
+
export type FormFooterRender<T = any> = (params: {
|
|
173
|
+
/**
|
|
174
|
+
* @description 操作类型
|
|
175
|
+
*/
|
|
176
|
+
type: OperationType;
|
|
177
|
+
/**
|
|
178
|
+
* @description 当前记录
|
|
179
|
+
*/
|
|
180
|
+
record?: T;
|
|
181
|
+
/**
|
|
182
|
+
* @description 表单实例
|
|
183
|
+
*/
|
|
184
|
+
form: any;
|
|
185
|
+
/**
|
|
186
|
+
* @description 提交处理
|
|
187
|
+
*/
|
|
188
|
+
onSubmit: () => void;
|
|
189
|
+
/**
|
|
190
|
+
* @description 取消处理
|
|
191
|
+
*/
|
|
192
|
+
onCancel: () => void;
|
|
193
|
+
/**
|
|
194
|
+
* @description 提交中状态
|
|
195
|
+
*/
|
|
196
|
+
loading?: boolean;
|
|
197
|
+
}) => React.ReactNode;
|
|
198
|
+
/**
|
|
199
|
+
* 表单提交回调
|
|
200
|
+
* @returns 返回 false 时不关闭弹窗和刷新数据;返回 void 或 true 时正常关闭和刷新
|
|
201
|
+
*/
|
|
202
|
+
export type FormSubmitCallback<T = any> = (values: T, type: OperationType, record?: T) => Promise<void | false> | void | false;
|
|
203
|
+
/**
|
|
204
|
+
* 内置表单配置
|
|
205
|
+
*/
|
|
206
|
+
export interface FormConfig<T = any, ValueType extends string = 'text'> {
|
|
207
|
+
/**
|
|
208
|
+
* @description 是否启用内置表单(设置为 false 时使用 operationContent 自定义)
|
|
209
|
+
* @default true
|
|
210
|
+
*/
|
|
211
|
+
enabled?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* @description 表单列配置(不传则从表格 columns 自动生成)
|
|
214
|
+
*/
|
|
215
|
+
columns?: ProFormColumnsType<T, ValueType>[];
|
|
216
|
+
/**
|
|
217
|
+
* @description 表单属性(透传给 Form 组件)
|
|
218
|
+
*/
|
|
219
|
+
formProps?: Omit<FormSchema<T, ValueType>, 'columns' | 'onFinish' | 'submitter'>;
|
|
220
|
+
/**
|
|
221
|
+
* @description 自定义表单底部渲染(返回 false 则隐藏底部)
|
|
222
|
+
*/
|
|
223
|
+
footerRender?: false | FormFooterRender<T>;
|
|
224
|
+
/**
|
|
225
|
+
* @description 表单提交回调
|
|
226
|
+
*/
|
|
227
|
+
onSubmit?: FormSubmitCallback<T>;
|
|
228
|
+
/**
|
|
229
|
+
* @description 新增时的提交按钮文本
|
|
230
|
+
*/
|
|
231
|
+
createSubmitText?: string;
|
|
232
|
+
/**
|
|
233
|
+
* @description 编辑时的提交按钮文本
|
|
234
|
+
*/
|
|
235
|
+
updateSubmitText?: string;
|
|
236
|
+
/**
|
|
237
|
+
* @description 取消按钮文本
|
|
238
|
+
*/
|
|
239
|
+
cancelText?: string;
|
|
240
|
+
/**
|
|
241
|
+
* @description 表单布局
|
|
242
|
+
* @default horizontal
|
|
243
|
+
*/
|
|
244
|
+
layout?: "horizontal" | "vertical" | "inline";
|
|
245
|
+
/**
|
|
246
|
+
* @description 标签宽度
|
|
247
|
+
*/
|
|
248
|
+
labelCol?: any;
|
|
249
|
+
/**
|
|
250
|
+
* @description 控件宽度
|
|
251
|
+
*/
|
|
252
|
+
wrapperCol?: any;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 公共属性
|
|
256
|
+
*/
|
|
257
|
+
export type ProTableProps<DataSource = Record<string, any>, ParamsType = Record<string, any>, ValueType = "text"> = AntdProTableProps<DataSource, ParamsType, ValueType> & {
|
|
87
258
|
prefixCls?: string;
|
|
88
259
|
className?: string;
|
|
89
260
|
style?: React.CSSProperties;
|
|
90
261
|
size?: SizeType;
|
|
91
|
-
|
|
92
|
-
|
|
262
|
+
tableKey?: string;
|
|
263
|
+
/**
|
|
264
|
+
* @description Table action 的引用,便于自定义触发
|
|
265
|
+
*/
|
|
266
|
+
actionRef?: AntdProTableProps<DataSource, ParamsType, ValueType>['actionRef'];
|
|
267
|
+
/**
|
|
268
|
+
* @description 搜索表单类型(已废弃,请使用 search.layoutType)
|
|
269
|
+
* @default QueryFilter
|
|
270
|
+
* @deprecated 请使用 search.layoutType
|
|
271
|
+
*/
|
|
272
|
+
searchType?: SearchType;
|
|
273
|
+
/**
|
|
274
|
+
* @description 搜索表单配置
|
|
275
|
+
*/
|
|
276
|
+
search?: false | SearchConfig<DataSource, ValueType>;
|
|
277
|
+
/**
|
|
278
|
+
* @description 是否显示新增按钮
|
|
279
|
+
* @default true
|
|
280
|
+
*/
|
|
281
|
+
showCreateBtn?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* @description 新增按钮配置,设置为 false 时不显示
|
|
284
|
+
*/
|
|
285
|
+
createBtnProps?: HeaderButtonItem | false;
|
|
286
|
+
/**
|
|
287
|
+
* @description 新增按钮点击回调
|
|
288
|
+
*/
|
|
289
|
+
onCreate?: (selectKeys: Key[]) => void | Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* @description 是否显示批量删除按钮
|
|
292
|
+
* @default true
|
|
293
|
+
*/
|
|
294
|
+
showBatchRemoveBtn?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* @description 批量删除按钮配置,设置为 false 时不显示
|
|
297
|
+
*/
|
|
298
|
+
batchRemoveBtnProps?: HeaderButtonItem | false;
|
|
299
|
+
/**
|
|
300
|
+
* @description 批量删除点击回调
|
|
301
|
+
* @returns 返回 false 时不刷新数据;返回 void 或 true 时正常刷新
|
|
302
|
+
*/
|
|
303
|
+
onBatchRemove?: (selectKeys: Key[]) => void | false | Promise<void | false>;
|
|
304
|
+
/**
|
|
305
|
+
* @description 自定义操作按钮列表
|
|
306
|
+
*/
|
|
307
|
+
headerButtonItems?: HeaderButtonItem[];
|
|
308
|
+
/**
|
|
309
|
+
* @description ButtonGroup 最大显示按钮数量
|
|
310
|
+
* @default 3
|
|
311
|
+
*/
|
|
312
|
+
headerButtonMaxCount?: number;
|
|
313
|
+
/**
|
|
314
|
+
* @description 是否开启页面大小缓存
|
|
315
|
+
* @default false
|
|
316
|
+
*/
|
|
317
|
+
openPageSizeCache?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* @description 默认页面大小
|
|
320
|
+
* @default 10
|
|
321
|
+
*/
|
|
322
|
+
defaultPageSize?: number;
|
|
323
|
+
/**
|
|
324
|
+
* @description 操作模式
|
|
325
|
+
* @default modal
|
|
326
|
+
*/
|
|
327
|
+
mode?: VlianTableMode;
|
|
328
|
+
/**
|
|
329
|
+
* @description 是否显示查看按钮
|
|
330
|
+
* @default true
|
|
331
|
+
*/
|
|
332
|
+
showViewBtn?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* @description 查看按钮配置
|
|
335
|
+
*/
|
|
336
|
+
viewBtnProps?: RowButtonItem<DataSource> | false;
|
|
337
|
+
/**
|
|
338
|
+
* @description 是否显示编辑按钮
|
|
339
|
+
* @default true
|
|
340
|
+
*/
|
|
341
|
+
showUpdateBtn?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* @description 编辑按钮配置
|
|
344
|
+
*/
|
|
345
|
+
updateBtnProps?: RowButtonItem<DataSource> | false;
|
|
346
|
+
/**
|
|
347
|
+
* @description 是否显示删除按钮
|
|
348
|
+
* @default true
|
|
349
|
+
*/
|
|
350
|
+
showRemoveBtn?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* @description 删除按钮配置
|
|
353
|
+
*/
|
|
354
|
+
removeBtnProps?: RowButtonItem<DataSource> | false;
|
|
355
|
+
/**
|
|
356
|
+
* @description 自定义行操作按钮列表
|
|
357
|
+
*/
|
|
358
|
+
rowButtonItems?: RowButtonItem<DataSource>[];
|
|
359
|
+
/**
|
|
360
|
+
* @description 行操作按钮最大显示数量
|
|
361
|
+
* @default 3
|
|
362
|
+
*/
|
|
363
|
+
rowButtonMaxCount?: number;
|
|
364
|
+
/**
|
|
365
|
+
* @description Modal 配置
|
|
366
|
+
*/
|
|
367
|
+
modalProps?: Omit<ModalProps, 'open' | 'onCancel' | 'children'>;
|
|
368
|
+
/**
|
|
369
|
+
* @description Drawer 配置
|
|
370
|
+
*/
|
|
371
|
+
drawerProps?: Omit<DrawerProps, 'open' | 'onClose' | 'children'>;
|
|
372
|
+
/**
|
|
373
|
+
* @description 路由基础路径(router 模式下使用)
|
|
374
|
+
*/
|
|
375
|
+
routerBasePath?: string;
|
|
376
|
+
/**
|
|
377
|
+
* @description 操作内容渲染函数
|
|
378
|
+
*/
|
|
379
|
+
operationContent?: OperationContentRender<DataSource>;
|
|
93
380
|
/**
|
|
94
|
-
*
|
|
381
|
+
* @description 获取详情数据(用于编辑和查看)
|
|
95
382
|
*/
|
|
96
|
-
|
|
383
|
+
onGetDetail?: (record: DataSource, index: number) => Promise<DataSource>;
|
|
97
384
|
/**
|
|
98
|
-
* @description
|
|
385
|
+
* @description 删除回调
|
|
386
|
+
* @returns 返回 false 时不刷新数据;返回 void 或 true 时正常刷新
|
|
99
387
|
*/
|
|
100
|
-
|
|
388
|
+
onRemove?: (record: DataSource, index: number) => void | false | Promise<void | false>;
|
|
101
389
|
/**
|
|
102
|
-
* @description
|
|
390
|
+
* @description 内置表单配置
|
|
103
391
|
*/
|
|
104
|
-
|
|
392
|
+
formConfig?: FormConfig<DataSource, ValueType extends string ? ValueType : 'text'>;
|
|
105
393
|
/**
|
|
106
|
-
*
|
|
394
|
+
* @description 默认视图模式
|
|
395
|
+
* @default table
|
|
107
396
|
*/
|
|
108
|
-
|
|
397
|
+
defaultViewMode?: ViewMode;
|
|
109
398
|
/**
|
|
110
|
-
*
|
|
399
|
+
* @description 网格卡片渲染函数(网格模式下必需)
|
|
111
400
|
*/
|
|
112
|
-
|
|
401
|
+
gridCardRender?: GridCardRender<DataSource>;
|
|
113
402
|
/**
|
|
114
|
-
*
|
|
403
|
+
* @description 网格列数配置
|
|
404
|
+
* @default { xs: 1, sm: 2, md: 3, lg: 4, xl: 4, xxl: 6 }
|
|
115
405
|
*/
|
|
116
|
-
|
|
406
|
+
gridColumns?: {
|
|
407
|
+
xs?: number;
|
|
408
|
+
sm?: number;
|
|
409
|
+
md?: number;
|
|
410
|
+
lg?: number;
|
|
411
|
+
xl?: number;
|
|
412
|
+
xxl?: number;
|
|
413
|
+
};
|
|
117
414
|
/**
|
|
118
|
-
*
|
|
415
|
+
* @description 网格卡片中每行显示的字段数量
|
|
416
|
+
* @default 3
|
|
119
417
|
*/
|
|
120
|
-
|
|
418
|
+
gridCardFieldsPerRow?: number;
|
|
121
419
|
};
|
|
420
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProTable 工具函数
|
|
3
|
+
*/
|
|
4
|
+
import type { Key } from "react";
|
|
5
|
+
import type { ButtonGroupItem } from "../ButtonGroup";
|
|
6
|
+
import type { HeaderButtonItem, RowButtonItem } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* LocalStorage 工具类
|
|
9
|
+
*/
|
|
10
|
+
export declare class StorageHelper {
|
|
11
|
+
/**
|
|
12
|
+
* 安全读取 localStorage
|
|
13
|
+
*/
|
|
14
|
+
static getItem(key: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* 安全写入 localStorage
|
|
17
|
+
*/
|
|
18
|
+
static setItem(key: string, value: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 读取 JSON 数据
|
|
21
|
+
*/
|
|
22
|
+
static getJSON<T = any>(key: string, defaultValue: T): T;
|
|
23
|
+
/**
|
|
24
|
+
* 写入 JSON 数据
|
|
25
|
+
*/
|
|
26
|
+
static setJSON(key: string, value: any): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 读取数字
|
|
29
|
+
*/
|
|
30
|
+
static getNumber(key: string, defaultValue: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* 写入数字
|
|
33
|
+
*/
|
|
34
|
+
static setNumber(key: string, value: number): boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 按钮配置转换器(用于 Header 按钮)
|
|
38
|
+
*/
|
|
39
|
+
export declare function convertHeaderButtonToGroupItem(config: HeaderButtonItem | false | undefined, defaultKey: string, selectedRowKeys: Key[], defaultHandler?: () => void | Promise<void>): ButtonGroupItem | null;
|
|
40
|
+
/**
|
|
41
|
+
* 按钮配置转换器(用于行操作按钮)
|
|
42
|
+
*/
|
|
43
|
+
export declare function convertRowButtonToGroupItem<T = any>(config: RowButtonItem<T> | false | undefined, defaultKey: string, record: T, index: number, defaultHandler?: (record: T, index: number) => void | Promise<void>): ButtonGroupItem | null;
|
|
44
|
+
/**
|
|
45
|
+
* 列过滤工具
|
|
46
|
+
*/
|
|
47
|
+
export declare class ColumnHelper {
|
|
48
|
+
/**
|
|
49
|
+
* 过滤显示列(排除操作列)
|
|
50
|
+
*/
|
|
51
|
+
static filterDisplayColumns(columns: any[]): any[];
|
|
52
|
+
/**
|
|
53
|
+
* 查找操作列
|
|
54
|
+
*/
|
|
55
|
+
static findActionColumn(columns: any[]): any | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* 检查是否存在操作列
|
|
58
|
+
*/
|
|
59
|
+
static hasActionColumn(columns: any[]): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* 为列添加默认配置
|
|
62
|
+
*/
|
|
63
|
+
static addDefaultConfig(columns: any[]): any[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 操作类型工厂函数
|
|
67
|
+
* 创建统一的操作处理函数
|
|
68
|
+
*/
|
|
69
|
+
export declare function createOperationHandler<T = any>(operationType: 'view' | 'update', setOperationType: (type: any) => void, setCurrentIndex: (index: number) => void, setCurrentRecord: (record: T | null) => void, setOperationVisible: (visible: boolean) => void, onGetDetail?: (record: T, index: number) => Promise<T>, mode?: string): (record: T, index: number) => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* 获取响应式 span 配置
|
|
72
|
+
*/
|
|
73
|
+
export declare function getResponsiveSpan(gridSpan?: 'half' | 'full'): {
|
|
74
|
+
xs: number;
|
|
75
|
+
sm: number;
|
|
76
|
+
md: number;
|
|
77
|
+
lg: number;
|
|
78
|
+
xl: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* 格式化显示值
|
|
82
|
+
*/
|
|
83
|
+
export declare function formatDisplayValue(value: any, defaultValue?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _object_without_properties_loose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}export var StorageHelper=/*#__PURE__*/function(){"use strict";function StorageHelper(){_class_call_check(this,StorageHelper)}_create_class(StorageHelper,null,[{key:"getItem",value:function getItem(key){try{return window.localStorage.getItem(key)}catch(error){console.error("Failed to read from localStorage (key: ".concat(key,"):"),error);return null}}},{key:"setItem",value:function setItem(key,value){try{window.localStorage.setItem(key,value);return true}catch(error){console.error("Failed to write to localStorage (key: ".concat(key,"):"),error);return false}}},{key:"getJSON",value:function getJSON(key,defaultValue){var value=this.getItem(key);if(!value)return defaultValue;try{return JSON.parse(value)}catch(error){console.error("Failed to parse JSON from localStorage (key: ".concat(key,"):"),error);return defaultValue}}},{key:"setJSON",value:function setJSON(key,value){try{var jsonString=JSON.stringify(value);return this.setItem(key,jsonString)}catch(error){console.error("Failed to stringify JSON for localStorage (key: ".concat(key,"):"),error);return false}}},{key:"getNumber",value:function getNumber(key,defaultValue){var value=this.getItem(key);if(!value)return defaultValue;var parsed=Number(value);return isNaN(parsed)||parsed<=0?defaultValue:parsed}},{key:"setNumber",value:function setNumber(key,value){return this.setItem(key,String(value))}}]);return StorageHelper}();export function convertHeaderButtonToGroupItem(config,defaultKey,selectedRowKeys,defaultHandler){if(config===false){return null}var visible=typeof(config===null||config===void 0?void 0:config.visible)==="function"?config.visible(selectedRowKeys):(config===null||config===void 0?void 0:config.visible)!==false;if(!visible){return null}var disabled=typeof(config===null||config===void 0?void 0:config.disabled)==="function"?config.disabled(selectedRowKeys):(config===null||config===void 0?void 0:config.disabled)||false;var _ref=config||{},_=_ref.visible,__=_ref.disabled,onClick=_ref.onClick,label=_ref.label,restProps=_object_without_properties(_ref,["visible","disabled","onClick","label"]);return _object_spread_props(_object_spread({},restProps),{key:(config===null||config===void 0?void 0:config.key)||defaultKey,label:label||"",disabled:disabled,onClick:function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onClick)return[3,2];return[4,onClick(selectedRowKeys)];case 1:_state.sent();return[3,4];case 2:if(!defaultHandler)return[3,4];return[4,defaultHandler()];case 3:_state.sent();_state.label=4;case 4:return[2]}})})()}})}export function convertRowButtonToGroupItem(config,defaultKey,record,index,defaultHandler){if(config===false){return null}var visible=typeof(config===null||config===void 0?void 0:config.visible)==="function"?config.visible(record,index):(config===null||config===void 0?void 0:config.visible)!==false;if(!visible){return null}var disabled=typeof(config===null||config===void 0?void 0:config.disabled)==="function"?config.disabled(record,index):(config===null||config===void 0?void 0:config.disabled)||false;var _ref=config||{},_=_ref.visible,__=_ref.disabled,onClick=_ref.onClick,label=_ref.label,restProps=_object_without_properties(_ref,["visible","disabled","onClick","label"]);return _object_spread_props(_object_spread({},restProps),{key:(config===null||config===void 0?void 0:config.key)||defaultKey,label:label||"",disabled:disabled,onClick:function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onClick)return[3,2];return[4,onClick(record,index)];case 1:_state.sent();return[3,4];case 2:if(!defaultHandler)return[3,4];return[4,defaultHandler(record,index)];case 3:_state.sent();_state.label=4;case 4:return[2]}})})()}})}export var ColumnHelper=/*#__PURE__*/function(){"use strict";function ColumnHelper(){_class_call_check(this,ColumnHelper)}_create_class(ColumnHelper,null,[{key:"filterDisplayColumns",value:function filterDisplayColumns(columns){return columns.filter(function(col){return!col.hideInTable&&col.dataIndex&&col.valueType!=="option"&&col.key!=="actions"&&col.dataIndex!=="actions"})}},{key:"findActionColumn",value:function findActionColumn(columns){return columns.find(function(col){return col.valueType==="option"||col.key==="actions"||col.dataIndex==="actions"})}},{key:"hasActionColumn",value:function hasActionColumn(columns){return columns.some(function(col){return col.key==="actions"||col.dataIndex==="actions"||col.valueType==="option"})}},{key:"addDefaultConfig",value:function addDefaultConfig(columns){return columns.map(function(col){var _col_ellipsis;var result=_object_spread_props(_object_spread({},col),{ellipsis:(_col_ellipsis=col.ellipsis)!==null&&_col_ellipsis!==void 0?_col_ellipsis:{showTitle:true}});if(!col.width&&!col.maxWidth&&!col.minWidth){result.width=200}return result})}}]);return ColumnHelper}();export function createOperationHandler(operationType,setOperationType,setCurrentIndex,setCurrentRecord,setOperationVisible,onGetDetail,mode){return function(record,index){return _async_to_generator(function(){var detail;return _ts_generator(this,function(_state){switch(_state.label){case 0:setOperationType(operationType);setCurrentIndex(index);if(!onGetDetail)return[3,2];return[4,onGetDetail(record,index)];case 1:detail=_state.sent();setCurrentRecord(detail);return[3,3];case 2:setCurrentRecord(record);_state.label=3;case 3:if(mode!=="router"){setOperationVisible(true)}return[2]}})})()}}export function getResponsiveSpan(gridSpan){if(gridSpan==="full"){return{xs:24,sm:24,md:24,lg:24,xl:24}}return{xs:24,sm:12,md:12,lg:12,xl:12}}export function formatDisplayValue(value){var defaultValue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"-";if(value===null||value===undefined||value===""){return defaultValue}if(typeof value==="string"||typeof value==="number"){return String(value)}return defaultValue}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}import{useState}from"react";import*as React from"react";import{theme}from"antd";import classNames from"classnames";import{Typography}from"../Text";import{useStyles}from"./styles";import{SelectedItemsDisplay}from"./selected-items-display";import{SelectorModal}from"./modal";export var TabSelector=function(param){var tabs=param.tabs,_param_value=param.value,value=_param_value===void 0?{}:_param_value,onChange=param.onChange,_param_placeholder=param.placeholder,placeholder=_param_placeholder===void 0?"点击选择项目...":_param_placeholder,_param_disabled=param.disabled,disabled=_param_disabled===void 0?false:_param_disabled,_param_readonly=param.readonly,readonly=_param_readonly===void 0?false:_param_readonly,columns=param.columns;var hashId=theme.useToken().hashId;var modalRef=React.useRef(null);var _useState=_sliced_to_array(useState(value),2),selectedData=_useState[0],setSelectedData=_useState[1];useStyles();var handleClick=function(){var _modalRef_current;if(disabled||readonly){return}if(!tabs||tabs&&tabs.length===0){console.error("未配置tabs");return}console.info("a");(_modalRef_current=modalRef.current)===null||_modalRef_current===void 0?void 0:_modalRef_current.open()};var handleConfirm=function(data){setSelectedData(data);onChange===null||onChange===void 0?void 0:onChange(data)};var handleRemoveItem=function(item){var newData=_object_spread({},selectedData);var _iteratorNormalCompletion=true,_didIteratorError=false,_iteratorError=undefined;try{for(var _iterator=Object.keys(newData)[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var tabKey=_step.value;var tabItems=newData[tabKey]||[];var itemIndex=tabItems.findIndex(function(selected){return selected.id===item.id});if(itemIndex!==-1){newData[tabKey]=tabItems.filter(function(selected){return selected.id!==item.id});break}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator.return!=null){_iterator.return()}}finally{if(_didIteratorError){throw _iteratorError}}}setSelectedData(newData);onChange===null||onChange===void 0?void 0:onChange(newData)};var getAllSelectedItems=function(){return Object.values(selectedData).flat()};var getTotalCount=function(){return getAllSelectedItems().length};return React.createElement("div",{className:classNames(hashId,"vlian-tab-modal"),onClick:handleClick},getTotalCount()>0?React.createElement(SelectedItemsDisplay,{items:getAllSelectedItems(),onRemove:handleRemoveItem,compact:true}):React.createElement(Typography.Text,{type:"secondary"},placeholder),React.createElement(SelectorModal,{tabs:tabs,ref:modalRef,onConfirm:handleConfirm,initialValue:selectedData,columns:columns}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./types";export*from"./TabSelector";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TabConfig, TableItem } from "./types";
|
|
3
|
+
import type { ProColumns } from '@ant-design/pro-components';
|
|
4
|
+
export type ModalProps = {
|
|
5
|
+
tabs: TabConfig[];
|
|
6
|
+
initialValue: Record<string, TableItem[]>;
|
|
7
|
+
onConfirm: (value: Record<string, TableItem[]>) => void;
|
|
8
|
+
columns?: ProColumns<Record<string, any>>[];
|
|
9
|
+
rowKey?: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ModalInst = {
|
|
13
|
+
open: () => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const SelectorModal: (props: ModalProps & React.RefAttributes<ModalInst>) => React.ReactElement | null;
|