@gx-design-vue/pro-table 0.2.0-alpha.8 → 0.2.0-alpha.9

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.
Files changed (133) hide show
  1. package/dist/ProTable.d.ts +14 -492
  2. package/dist/ProTable.js +818 -518
  3. package/dist/components/ScrollBar/Bar.d.ts +81 -0
  4. package/dist/components/ScrollBar/Bar.js +84 -0
  5. package/dist/components/ScrollBar/Thumb.d.ts +52 -0
  6. package/dist/components/ScrollBar/{Thumb/index.js → Thumb.js} +67 -55
  7. package/dist/components/ScrollBar/context.d.ts +3 -4
  8. package/dist/components/ScrollBar/context.js +3 -3
  9. package/dist/components/ScrollBar/util.d.ts +6 -5
  10. package/dist/components/ScrollBar/util.js +1 -12
  11. package/dist/components/SearchForm/CollapseToggle.d.ts +55 -0
  12. package/dist/components/SearchForm/CollapseToggle.js +47 -0
  13. package/dist/components/SearchForm/FormItemContainer.d.ts +75 -0
  14. package/dist/components/SearchForm/FormItemContainer.js +225 -0
  15. package/dist/components/SearchForm/FormItemWrapper.d.ts +82 -0
  16. package/dist/components/SearchForm/FormItemWrapper.js +62 -0
  17. package/dist/components/SearchForm/SearchForm.d.ts +130 -0
  18. package/dist/components/SearchForm/SearchForm.js +319 -0
  19. package/dist/components/SearchForm/index.d.ts +2 -0
  20. package/dist/components/SearchForm/index.js +2 -0
  21. package/dist/components/Toolbar/FullscreenIcon.d.ts +26 -0
  22. package/dist/components/Toolbar/FullscreenIcon.js +22 -0
  23. package/dist/components/Toolbar/ListToolBar.d.ts +111 -0
  24. package/dist/components/Toolbar/ListToolBar.js +101 -0
  25. package/dist/components/Toolbar/index.d.ts +103 -0
  26. package/dist/components/Toolbar/index.js +101 -0
  27. package/dist/components/Toolbar/style.d.ts +8 -0
  28. package/dist/components/{ListToolBar → Toolbar}/style.js +32 -27
  29. package/dist/context/TableContext.d.ts +15 -27
  30. package/dist/context/TableContext.js +3 -3
  31. package/dist/hooks/index.d.ts +16 -0
  32. package/dist/hooks/index.js +16 -0
  33. package/dist/hooks/useBreakpoints.d.ts +13 -0
  34. package/dist/hooks/useBreakpoints.js +57 -0
  35. package/dist/hooks/useCellRender.d.ts +13 -0
  36. package/dist/hooks/useCellRender.js +28 -0
  37. package/dist/hooks/useColumnResize.d.ts +30 -0
  38. package/dist/hooks/useColumnResize.js +110 -0
  39. package/dist/hooks/useColumns.d.ts +35 -24
  40. package/dist/hooks/useColumns.js +89 -56
  41. package/dist/hooks/useFetchData.d.ts +40 -65
  42. package/dist/hooks/useFetchData.js +157 -172
  43. package/dist/hooks/useFitPage.d.ts +19 -0
  44. package/dist/hooks/useFitPage.js +90 -0
  45. package/dist/hooks/useKeepAliveReload.d.ts +21 -0
  46. package/dist/hooks/useKeepAliveReload.js +24 -0
  47. package/dist/hooks/useLoading.d.ts +18 -7
  48. package/dist/hooks/useLoading.js +26 -8
  49. package/dist/hooks/usePagination.d.ts +10 -7
  50. package/dist/hooks/usePagination.js +37 -26
  51. package/dist/hooks/useRequestOptions.d.ts +18 -0
  52. package/dist/hooks/useRequestOptions.js +39 -0
  53. package/dist/hooks/useRowSelection.d.ts +27 -15
  54. package/dist/hooks/useRowSelection.js +92 -77
  55. package/dist/hooks/useTable.d.ts +19 -77
  56. package/dist/hooks/useTable.js +66 -54
  57. package/dist/hooks/useTableForm.d.ts +15 -83
  58. package/dist/hooks/useTableForm.js +93 -57
  59. package/dist/hooks/useTableScroll.d.ts +33 -31
  60. package/dist/hooks/useTableScroll.js +71 -26
  61. package/dist/hooks/useTableSize.d.ts +17 -7
  62. package/dist/hooks/useTableSize.js +20 -6
  63. package/dist/index.d.ts +10 -7
  64. package/dist/index.js +9 -3
  65. package/dist/interface.d.ts +492 -0
  66. package/dist/pro-table.esm.js +3512 -3965
  67. package/dist/pro-table.js +1 -1
  68. package/dist/style/fit-page.d.ts +4 -2
  69. package/dist/style/fit-page.js +9 -3
  70. package/dist/style/index.d.ts +4 -6
  71. package/dist/style/index.js +24 -74
  72. package/dist/style/list.d.ts +4 -2
  73. package/dist/style/list.js +1 -10
  74. package/dist/style/resizable.d.ts +8 -0
  75. package/dist/style/resizable.js +18 -0
  76. package/dist/style/scroll.d.ts +4 -2
  77. package/dist/style/scroll.js +8 -6
  78. package/dist/style/search.d.ts +8 -0
  79. package/dist/{components/Form/style.js → style/search.js} +22 -8
  80. package/dist/theme/augment.d.ts +8 -0
  81. package/dist/theme/interface/components.d.ts +8 -0
  82. package/dist/utils/dateFormat.d.ts +9 -0
  83. package/dist/utils/dateFormat.js +29 -0
  84. package/dist/utils/formConstants.d.ts +9 -0
  85. package/dist/utils/formConstants.js +29 -0
  86. package/dist/utils/valueFormat.d.ts +9 -0
  87. package/dist/utils/valueFormat.js +27 -0
  88. package/package.json +10 -9
  89. package/dist/components/Form/components/RequestSelect.d.ts +0 -50
  90. package/dist/components/Form/components/RequestSelect.js +0 -56
  91. package/dist/components/Form/hooks/useForm.d.ts +0 -11
  92. package/dist/components/Form/hooks/useForm.js +0 -30
  93. package/dist/components/Form/index.d.ts +0 -32
  94. package/dist/components/Form/index.js +0 -504
  95. package/dist/components/Form/style.d.ts +0 -6
  96. package/dist/components/Form/utils/config.d.ts +0 -9
  97. package/dist/components/Form/utils/config.js +0 -29
  98. package/dist/components/Form/utils/dateFormat.d.ts +0 -22
  99. package/dist/components/Form/utils/dateFormat.js +0 -43
  100. package/dist/components/ListToolBar/index.d.ts +0 -59
  101. package/dist/components/ListToolBar/index.js +0 -123
  102. package/dist/components/ListToolBar/style.d.ts +0 -6
  103. package/dist/components/ScrollBar/Bar/index.d.ts +0 -49
  104. package/dist/components/ScrollBar/Bar/index.js +0 -68
  105. package/dist/components/ScrollBar/Bar/props.d.ts +0 -25
  106. package/dist/components/ScrollBar/Bar/props.js +0 -17
  107. package/dist/components/ScrollBar/Thumb/index.d.ts +0 -40
  108. package/dist/components/ScrollBar/Thumb/props.d.ts +0 -20
  109. package/dist/components/ScrollBar/Thumb/props.js +0 -17
  110. package/dist/components/TableCell/index.d.ts +0 -37
  111. package/dist/components/TableCell/index.js +0 -69
  112. package/dist/components/ToolBar/FullscreenIcon.d.ts +0 -7
  113. package/dist/components/ToolBar/FullscreenIcon.js +0 -11
  114. package/dist/components/ToolBar/index.d.ts +0 -34
  115. package/dist/components/ToolBar/index.js +0 -97
  116. package/dist/hooks/tryOnActivated.d.ts +0 -6
  117. package/dist/hooks/tryOnActivated.js +0 -12
  118. package/dist/hooks/useDebounceFn.d.ts +0 -8
  119. package/dist/hooks/useDebounceFn.js +0 -31
  120. package/dist/hooks/useScrollArea.d.ts +0 -24
  121. package/dist/hooks/useScrollArea.js +0 -102
  122. package/dist/props.d.ts +0 -340
  123. package/dist/props.js +0 -247
  124. package/dist/types/ColumnTypings.d.ts +0 -130
  125. package/dist/types/SlotsTypings.d.ts +0 -63
  126. package/dist/types/SlotsTypings.js +0 -12
  127. package/dist/types/TableTypings.d.ts +0 -359
  128. package/dist/types/index.d.ts +0 -9
  129. package/dist/utils/utils.d.ts +0 -10
  130. package/dist/utils/utils.js +0 -89
  131. /package/dist/{types/ColumnTypings.js → interface.js} +0 -0
  132. /package/dist/{types/TableTypings.js → theme/augment.js} +0 -0
  133. /package/dist/{types/index.js → theme/interface/components.js} +0 -0
@@ -1,359 +0,0 @@
1
- import { ProColumnType, ProColumnsType, ProSearchMap } from "./ColumnTypings.js";
2
- import { TableSorterRecord } from "./index.js";
3
- import { CustomDataRender, DefaultRender, PageItemRender } from "./SlotsTypings.js";
4
- import { CSSProperties, ComputedRef, Ref } from "vue";
5
- import { Breakpoint, CustomRender, Fn, RecordType, SemanticClassNames, SemanticStyles, SizeType, WithFalse } from "@gx-design-vue/pro-utils";
6
- import { TableProps } from "ant-design-vue/es/table";
7
- import { FilterValue, SelectionSelectFn, SorterResult, TableCurrentDataSource, TablePaginationConfig, TableRowSelection } from "ant-design-vue/es/table/interface";
8
-
9
- //#region src/types/TableTypings.d.ts
10
- interface ProTableFetchParams<R = RecordType> {
11
- params?: R;
12
- filters?: Record<string, FilterValue | null>;
13
- sorter?: SorterResult | SorterResult[];
14
- pagination?: ProTablePagination;
15
- removeKeys?: (string | number)[];
16
- immediate?: boolean;
17
- isPolling?: boolean;
18
- showLoading?: boolean;
19
- extra?: TableCurrentDataSource;
20
- }
21
- type TableActionPlacement = 'left' | 'right';
22
- type TablePaginationPosition = 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
23
- interface TableScroll {
24
- x?: number | string;
25
- y?: number | string;
26
- }
27
- type TableSemanticName = 'root' | 'content' | 'search' | 'searchItem' | 'searchControl' | 'searchContent' | 'searchText' | 'searchButtons' | 'card' | 'toolbar' | 'toolbarAfter' | 'toolbarLeft' | 'toolbarRight' | 'toolbarTitle' | 'list' | 'listContent' | 'pagination' | 'table';
28
- type TableStylesType = SemanticStyles<TableSemanticName>;
29
- type TableClassNamesType = SemanticClassNames<TableSemanticName>;
30
- type ProFieldEmptyText<T = any> = string | ((record: T) => void);
31
- type ProTableRowSelection<T = any> = Omit<TableRowSelection<T>, 'selectedRowKeys'> & {
32
- selectedRows?: T[];
33
- selectedRowKeys?: (string | number)[];
34
- };
35
- interface ProTablePaginationConfig extends Omit<TablePaginationConfig, 'position'> {
36
- total?: number;
37
- position?: TablePaginationPosition[];
38
- }
39
- type ProTablePagination = ProTablePaginationConfig | false;
40
- interface PageState {
41
- current: number;
42
- pageSize: number;
43
- total?: number;
44
- }
45
- interface RequestData<T = any> {
46
- data: T[] | undefined;
47
- success?: boolean;
48
- total?: number;
49
- }
50
- interface RequestConfig<T> {
51
- params: T extends undefined ? PageState : PageState & Partial<T>;
52
- sorter: TableSorterRecord[];
53
- filter: Record<string, FilterValue | null>;
54
- extra?: TableCurrentDataSource;
55
- }
56
- type RequestFunction<T = any, D = undefined> = (props: RequestConfig<D>) => Promise<Partial<RequestData<T>> | undefined>;
57
- type ColConfig = Partial<Record<Breakpoint, number>>;
58
- interface FormConfig {
59
- className?: string;
60
- /**
61
- * actions 表单动作的配置参数
62
- */
63
- actions?: {
64
- /**
65
- * reset 是否展示重置按钮
66
- */
67
- reset?: boolean;
68
- /**
69
- * resetReload 是否展示重置按钮
70
- */
71
- resetReload?: boolean;
72
- /**
73
- * searchText 搜索按钮文案
74
- */
75
- searchText?: string;
76
- /**
77
- * resetText 重置按钮文案
78
- */
79
- resetText?: string;
80
- };
81
- /**
82
- * collapsed 收起状态
83
- */
84
- collapsed?: boolean;
85
- /**
86
- * defaultCollapsed 默认收起状态
87
- */
88
- defaultCollapsed?: boolean;
89
- /**
90
- * autoRequest 表单搜索条件变化后自动请求request
91
- */
92
- autoRequest?: boolean;
93
- /**
94
- * collapseRender 展开收起自定义渲染
95
- */
96
- collapseRender?: WithFalse<(collapsed?: boolean) => CustomRender>;
97
- /**
98
- * span 支持断点('xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs')一行展示几个 demo { xl: 4, lg: 3 }
99
- */
100
- span?: ColConfig;
101
- /**
102
- * breakpoint 断点配置支持写入具体宽度 一行展示几个(这里是指大于宽度生效),优先级比span要高 demo { 1440: 4 }
103
- */
104
- breakpoint?: Record<number, number>;
105
- /**
106
- * gap 每项表单间的间隔
107
- */
108
- gap?: number | string;
109
- /**
110
- * label 搜索表单的label配置参数
111
- */
112
- label?: {
113
- /**
114
- * label label与表单项之间的间隔:仅支持数字
115
- */
116
- gap?: number;
117
- /**
118
- * colon label与表单项之间的间否使用冒号间隔
119
- */
120
- colon?: boolean;
121
- /**
122
- * width label的宽度:支持数字和字符
123
- */
124
- width?: number | string;
125
- /**
126
- * align label在宽度内的对齐方式:'center' | 'left' | 'right'
127
- */
128
- align?: 'center' | 'left' | 'right';
129
- };
130
- }
131
- interface OptionConfig {
132
- reload?: ((onClick?: Fn) => CustomRender) | boolean;
133
- fullScreen?: ((onClick?: Fn) => CustomRender) | boolean | (() => Promise<void>);
134
- }
135
- /** action表格实例 */
136
- interface ProCoreActionType<T = RecordType, R = RecordType> {
137
- /**
138
- * loading 状态,可以直接进行修改
139
- */
140
- loading: Ref<boolean>;
141
- /**
142
- * dataSource 只读表格数据,不能修改
143
- */
144
- dataSource: ComputedRef<T[]>;
145
- /**
146
- * getLoadingStatus 主动获取表格loading状态
147
- */
148
- getLoadingStatus: () => boolean;
149
- /**
150
- * pagination 表格翻页参数
151
- */
152
- pagination: R | boolean;
153
- /**
154
- * pageInfo 表格的翻页参数(只有current、pageSize、total)
155
- */
156
- pageInfo: PageState;
157
- /**
158
- * selectedKeys 表格列选择keys,只读
159
- */
160
- selectedKeys: ComputedRef<(string | number)[]>;
161
- /**
162
- * selectedItems 表格列选择rows,只读
163
- */
164
- selectedItems: ComputedRef<T[]>;
165
- /**
166
- * rowsSelection 表格列选项操作
167
- */
168
- rowsSelection?: {
169
- /**
170
- * clear 清楚全部选项
171
- */
172
- clear: () => void;
173
- /**
174
- * sync 表格数据变化后,主动同步选择项
175
- */
176
- sync: (data: T[]) => void;
177
- /**
178
- * remove 删除选择项
179
- */
180
- remove: (keys: (string | number)[]) => void;
181
- /**
182
- * select 选中选择项
183
- */
184
- select: SelectionSelectFn<T>;
185
- /**
186
- * selectAll 当前表格数据全部选择
187
- */
188
- selectAll: TableRowSelection<T>['onSelectAll'];
189
- };
190
- /**
191
- * reload 主动刷新,按照当前的参数在当前页重新请求下
192
- */
193
- reload: (info?: ProTableFetchParams<R>) => void;
194
- /**
195
- * reloadAndReset 刷新并清空表单,重置为第一页
196
- */
197
- reloadAndReset: (options?: {
198
- callBack?: () => void;
199
- wait?: boolean;
200
- }) => void;
201
- /**
202
- * setPagination 设置翻页参数
203
- */
204
- setPagination: (pagination: ProTablePaginationConfig) => void;
205
- /**
206
- * setPageInfo 设置翻页、排序、筛选、并且刷新(reload)
207
- */
208
- setPageInfo: (pagination: ProTablePaginationConfig, filters?: Record<string, FilterValue | null>, sorter?: SorterResult | SorterResult[], extra?: TableCurrentDataSource) => void;
209
- /**
210
- * setTableDataList 更新表格数据,直接替换,谨慎操作
211
- */
212
- setTableDataList: (data: T[]) => void;
213
- /**
214
- * operateTableDataRow 更新TableData属性值
215
- */
216
- operateTableDataRow: ({
217
- key,
218
- type,
219
- row,
220
- value
221
- }: {
222
- /**
223
- * row 更新、添加(后、前)操作需要传入的参数
224
- */
225
- row?: Partial<T>;
226
- /**
227
- * key 这里是表格数据的唯一字段,确保字段值为唯一
228
- */
229
- key?: keyof T;
230
- /**
231
- * value 更新、删除操作时,要把要操作的row的唯一字段的值传入,用作判断
232
- */
233
- value?: any;
234
- /**
235
- * type 操作类型:更新、后新增、删除、前新增
236
- */
237
- type?: 'update' | 'push' | 'delete' | 'unshift';
238
- }) => void;
239
- /**
240
- * 改变loading状态
241
- */
242
- setLoading: (loading: boolean) => void;
243
- }
244
- /** form查询表单实例 */
245
- interface ProCoreFormType<R = RecordType> {
246
- /**
247
- * getFormSearch 获取表格-表单请求参数
248
- */
249
- getFormSearch?: () => R;
250
- /**
251
- * getFormInnerState 获取表格-内部表单参数
252
- */
253
- getFormInnerState?: () => R;
254
- /**
255
- * restFormState 重置内部表单组件参数
256
- */
257
- restFormState?: (callBack?: () => void) => void;
258
- }
259
- interface ProTableRef<T = RecordType, R = RecordType> {
260
- formRef: () => ProCoreFormType<R>;
261
- actionRef: () => ProCoreActionType<T, R>;
262
- }
263
- type ProTableProps<DataRecord extends object = RecordType, ParamsType extends object = RecordType> = Omit<TableProps<DataRecord>, 'columns' | 'dataSource' | 'rowKey' | 'id' | 'pagination' | 'onExpand' | 'expandedRowKeys' | 'onExpandedRowsChange' | 'onResizeColumn' | 'customHeaderRow' | 'footer' | 'title' | 'expandIcon' | 'customRow' | 'expandedRowRender' | 'defaultExpandedRowKeys' | 'rowClassName' | 'rowExpandable' | 'transformCellText' | 'onChange'> & Partial<{
264
- /**
265
- * fitPage 适配页面高度,使其表格占据一屏
266
- */
267
- fitPage: boolean;
268
- class: string;
269
- style: CSSProperties;
270
- id: string;
271
- classNames: TableClassNamesType;
272
- styles: TableStylesType;
273
- dataSource: DataRecord[];
274
- actionProps: {
275
- placement?: TableActionPlacement;
276
- actions?: DefaultRender[];
277
- };
278
- title: (data: DataRecord[]) => any;
279
- footer: (data: DataRecord[]) => any;
280
- rowExpandable: (record: DataRecord) => boolean;
281
- transformCellText: (opt: {
282
- text: any;
283
- column: ProColumnType;
284
- record: any;
285
- index: number;
286
- }) => any;
287
- expandIcon: (props: {
288
- prefixCls: string;
289
- expanded: boolean;
290
- record: DataRecord;
291
- expandable: boolean;
292
- onExpand: (record: DataRecord, event: MouseEvent) => void;
293
- }) => any;
294
- rowClassName: string | ((record: DataRecord, index: number, indent: number) => string);
295
- customRow: (data: DataRecord, index?: number, column?: ProColumnType) => any;
296
- customHeaderRow: (data: DataRecord, index?: number, column?: ProColumnType) => any;
297
- expandedRowRender: (opt: {
298
- record: DataRecord;
299
- index: number;
300
- indent: number;
301
- expanded: boolean;
302
- }) => any;
303
- expandedRowKeys: any[];
304
- defaultExpandedRowKeys: any[];
305
- rowKey: keyof DataRecord;
306
- titleTipText: string;
307
- autoScroll: boolean;
308
- showSearch: boolean;
309
- keepAliveReload: boolean;
310
- emptyTextProps: {
311
- class?: string;
312
- style?: CSSProperties;
313
- extraProps?: RecordType;
314
- };
315
- columnEmptyText: ProFieldEmptyText<DataRecord>;
316
- showLoading: boolean;
317
- neverScroll: boolean;
318
- modalScroll: boolean;
319
- scrollBreakpoint: Breakpoint | number;
320
- draggable: boolean;
321
- bordered: boolean;
322
- showIndex: boolean;
323
- cardBordered: boolean;
324
- virtualScroll: boolean;
325
- size: SizeType;
326
- align: ProColumnType['align'];
327
- options: OptionConfig | boolean;
328
- rowSelection: ProTableRowSelection;
329
- columns: ProColumnsType<DataRecord, ParamsType>;
330
- waitRequest: boolean;
331
- polling: number;
332
- debounceTime: number;
333
- request: RequestFunction<DataRecord, ParamsType>;
334
- autoRequest: boolean;
335
- params: ParamsType;
336
- postData: (data: DataRecord[]) => DataRecord[];
337
- pagination: ProTablePagination;
338
- form: FormConfig | false;
339
- searchMap: ProSearchMap<undefined, keyof ParamsType | keyof DataRecord>[];
340
- onChange: (pagination: ProTablePaginationConfig, filters?: Record<string, FilterValue | null>, sorter?: SorterResult | SorterResult[], extra?: TableCurrentDataSource) => void;
341
- onExpand: (expanded: boolean, record: DataRecord) => void;
342
- onExpandedRowsChange: (expandedKeys: any[]) => void;
343
- onResizeColumn: (w: number, col: ProColumnType) => void;
344
- onReset: (params?: Partial<ParamsType>) => void;
345
- onReload: (params?: Partial<ParamsType>) => void;
346
- onSubmit: (params?: Partial<ParamsType>) => void;
347
- onSizeChange: (size: string) => any;
348
- onLoadingChange: (loading: boolean) => any;
349
- onRequestError: (e: Error) => void;
350
- onBeforeSearchSubmit: RequestFunction<DataRecord, ParamsType>;
351
- emptyText: DefaultRender;
352
- headerTitle: DefaultRender;
353
- headerTitleTip: DefaultRender;
354
- listToolAfter: DefaultRender;
355
- customRender: CustomDataRender;
356
- pageItemRender: PageItemRender;
357
- }>;
358
- //#endregion
359
- export { ColConfig, FormConfig, OptionConfig, PageState, ProCoreActionType, ProCoreFormType, ProFieldEmptyText, ProTableFetchParams, ProTablePagination, ProTablePaginationConfig, ProTableProps, ProTableRef, ProTableRowSelection, RequestConfig, RequestData, RequestFunction, TableActionPlacement, TableClassNamesType, TablePaginationPosition, TableScroll, TableSemanticName, TableStylesType };
@@ -1,9 +0,0 @@
1
- import { RecordType } from "@gx-design-vue/pro-utils";
2
- import { FilterValue, SorterResult } from "ant-design-vue/es/table/interface";
3
-
4
- //#region src/types/index.d.ts
5
- type TableFilters = Record<string, FilterValue | null>;
6
- type TableSorterRecord = SorterResult<RecordType>;
7
- type TableSorter = TableSorterRecord | TableSorterRecord[];
8
- //#endregion
9
- export { TableFilters, TableSorter, TableSorterRecord };
@@ -1,10 +0,0 @@
1
- import { ProColumnsValueType } from "../types/ColumnTypings.js";
2
- import { ProTablePagination } from "../types/TableTypings.js";
3
-
4
- //#region src/utils/utils.d.ts
5
- declare function valueFormat(value: any, format: ProColumnsValueType | undefined, className: string, hashId: string): any;
6
- declare function getCurrentData(data: any[], pageInfo: ProTablePagination): any[];
7
- declare function handleCopy(codeStr: string): void;
8
- declare function watchElementHeightByClass(root: string | (() => (HTMLElement | undefined | null)), onChange: (el: HTMLElement | undefined) => void): () => void;
9
- //#endregion
10
- export { getCurrentData, handleCopy, valueFormat, watchElementHeightByClass };
@@ -1,89 +0,0 @@
1
- import { createVNode, isVNode, mergeProps } from "vue";
2
- import { isNil, isObject } from "@gx-design-vue/pro-utils";
3
- import dayjs from "dayjs";
4
- //#region src/utils/utils.tsx
5
- function _isSlot(s) {
6
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
7
- }
8
- function valueFormat(value, format, className, hashId) {
9
- if (isNil(value)) return "";
10
- if (!format) return value;
11
- let newValue = value;
12
- if (isObject(format)) return createVNode(format.node === "a" ? "span" : format.node, mergeProps(format?.attr || {}, {
13
- "class": format.class,
14
- "onClick": format.click
15
- }), _isSlot(value) ? value : { default: () => [value] });
16
- switch (format) {
17
- case "link":
18
- newValue = createVNode("span", { "class": [`${className}-a`, hashId] }, [value]);
19
- break;
20
- case "time":
21
- newValue = dayjs(value).format("HH:mm:ss");
22
- break;
23
- case "dateMonth":
24
- newValue = `${dayjs(value).month() + 1}月`;
25
- break;
26
- case "date":
27
- newValue = dayjs(value).format("YYYY-MM-DD");
28
- break;
29
- case "dateTime":
30
- newValue = dayjs(value).format("YYYY-MM-DD HH:mm:ss");
31
- break;
32
- default: break;
33
- }
34
- return newValue;
35
- }
36
- function getCurrentData(data, pageInfo) {
37
- const current = pageInfo ? pageInfo.current || 1 : 1;
38
- const pageSize = pageInfo ? pageInfo.pageSize || 10 : 10;
39
- return data.filter((_, index) => index < current * pageSize && index >= pageSize * (current - 1));
40
- }
41
- function handleCopy(codeStr) {
42
- const textArea = document.createElement("textarea");
43
- textArea.style.position = "absolute";
44
- textArea.style.opacity = "0";
45
- textArea.value = codeStr;
46
- document.body.appendChild(textArea);
47
- textArea.select();
48
- document.execCommand("copy");
49
- document.body.removeChild(textArea);
50
- }
51
- function watchElementHeightByClass(root, onChange) {
52
- let resizeObserver = null;
53
- let mutationObserver = null;
54
- function cleanup() {
55
- resizeObserver && resizeObserver.disconnect();
56
- mutationObserver && mutationObserver.disconnect();
57
- }
58
- function setupResize(el) {
59
- if (!el) return;
60
- resizeObserver = new ResizeObserver(() => {
61
- onChange(el);
62
- });
63
- resizeObserver.observe(el);
64
- onChange(el);
65
- }
66
- function findTarget() {
67
- if (typeof root === "string") return document.querySelector(root);
68
- return root();
69
- }
70
- const initial = findTarget();
71
- if (initial) {
72
- setupResize(initial);
73
- return cleanup;
74
- }
75
- mutationObserver = new MutationObserver(() => {
76
- const el = findTarget();
77
- if (el) {
78
- mutationObserver.disconnect();
79
- setupResize(el);
80
- }
81
- });
82
- mutationObserver.observe(document.body, {
83
- childList: true,
84
- subtree: true
85
- });
86
- return cleanup;
87
- }
88
- //#endregion
89
- export { getCurrentData, handleCopy, valueFormat, watchElementHeightByClass };
File without changes