ztxkui 4.2.18-2 → 4.2.18-21

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 (75) hide show
  1. package/README.md +57 -57
  2. package/dist/DemoCom/SyhDemo.d.ts +3 -0
  3. package/dist/DemoCom/SyhDemo.js +257 -0
  4. package/dist/DemoCom/TableDemo.js +8 -4
  5. package/dist/TableDemo/BasicTable.js +2 -1
  6. package/dist/TableDemo/EditableTable.js +83 -67
  7. package/dist/TableDemo/ProEditableTable.d.ts +21 -0
  8. package/dist/TableDemo/ProEditableTable.js +482 -0
  9. package/dist/TableDemo/data.d.ts +15 -0
  10. package/dist/TableDemo/data.js +33 -1
  11. package/dist/TableDemo/index.js +6 -5
  12. package/dist/components/DatePicker/data-picker.d.ts +7 -8
  13. package/dist/components/Menu/menu.d.ts +3 -3
  14. package/dist/components/PrintContainer/utils.js +3 -3
  15. package/dist/components/ProTable/hooks.d.ts +28 -0
  16. package/dist/components/ProTable/hooks.js +279 -0
  17. package/dist/components/ProTable/index.d.ts +8 -0
  18. package/dist/components/ProTable/index.js +77 -0
  19. package/dist/components/ProTable/interface.d.ts +51 -0
  20. package/dist/components/ProTable/interface.js +1 -0
  21. package/dist/components/Table/components/FillDown.d.ts +8 -0
  22. package/dist/components/Table/components/FillDown.js +10 -0
  23. package/dist/components/Table/components/FilterDropdown.d.ts +14 -0
  24. package/dist/components/Table/components/FilterDropdown.js +69 -0
  25. package/dist/components/Table/constants.d.ts +2 -0
  26. package/dist/components/Table/constants.js +2 -0
  27. package/dist/components/Table/hooks/useColumns.d.ts +20 -8
  28. package/dist/components/Table/hooks/useColumns.js +484 -182
  29. package/dist/components/Table/hooks/useDropRef.js +2 -1
  30. package/dist/components/Table/hooks/useInnerPagination.js +1 -0
  31. package/dist/components/Table/hooks/useSelectSubtotal.d.ts +4 -0
  32. package/dist/components/Table/hooks/useSelectSubtotal.js +178 -0
  33. package/dist/components/Table/index.d.ts +7 -0
  34. package/dist/components/Table/table-adddel-column.d.ts +8 -5
  35. package/dist/components/Table/table-adddel-column.js +15 -5
  36. package/dist/components/Table/table-dynamic.js +63 -5
  37. package/dist/components/Table/table-enhance-cell.d.ts +6 -3
  38. package/dist/components/Table/table-enhance-cell.js +196 -109
  39. package/dist/components/Table/table-enhance-row.d.ts +4 -4
  40. package/dist/components/Table/table-enhance-row.js +10 -11
  41. package/dist/components/Table/table-headTooltip.d.ts +6 -0
  42. package/dist/components/Table/table-headTooltip.js +13 -0
  43. package/dist/components/Table/table-resizable-title.d.ts +4 -5
  44. package/dist/components/Table/table-resizable-title.js +32 -6
  45. package/dist/components/Table/table-sort.d.ts +11 -0
  46. package/dist/components/Table/table-sort.js +65 -0
  47. package/dist/components/Table/table.d.ts +20 -4
  48. package/dist/components/Table/table.js +478 -176
  49. package/dist/components/Table/utils/dom.d.ts +26 -0
  50. package/dist/components/Table/utils/dom.js +122 -0
  51. package/dist/components/Table/utils/filterHandle.d.ts +1 -0
  52. package/dist/components/Table/utils/filterHandle.js +51 -0
  53. package/dist/components/Table/utils/getSummaryData.d.ts +1 -0
  54. package/dist/components/Table/utils/getSummaryData.js +3 -1
  55. package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
  56. package/dist/components/Table/utils/shallowEqual.js +34 -0
  57. package/dist/components/Table/utils/validate.d.ts +1 -1
  58. package/dist/components/Table/utils/validate.js +5 -5
  59. package/dist/components/TimePicker/time-picker.d.ts +0 -1
  60. package/dist/components/ZtIcon/index.d.ts +1 -1
  61. package/dist/components/business/Common/UserForgetPassword/index.js +17 -6
  62. package/dist/components/business/Common/UserInfo/index.js +3 -1
  63. package/dist/components/business/Common/UserPassword/index.d.ts +1 -0
  64. package/dist/components/business/Common/UserPassword/index.js +42 -14
  65. package/dist/components/business/Common/validatePassword.d.ts +8 -0
  66. package/dist/components/business/Common/validatePassword.js +168 -0
  67. package/dist/components/utils/index.d.ts +1 -0
  68. package/dist/components/utils/index.js +20 -0
  69. package/dist/components/utils/useLastest.d.ts +2 -0
  70. package/dist/components/utils/useLastest.js +6 -0
  71. package/dist/index.css +96 -7
  72. package/dist/index.css.map +1 -1
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.js +5 -0
  75. package/package.json +4 -3
@@ -0,0 +1,279 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
13
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
14
+ to[j] = from[i];
15
+ return to;
16
+ };
17
+ import { useRef, useEffect, useMemo, useCallback } from 'react';
18
+ import update from 'immutability-helper';
19
+ // 设置数据源临时Ref对象
20
+ export function useDataSourceRef(dataSource) {
21
+ var dataSourceRef = useRef(dataSource);
22
+ useEffect(function () {
23
+ dataSourceRef.current = dataSource;
24
+ }, [dataSource]);
25
+ return dataSourceRef;
26
+ }
27
+ // 加减行相关
28
+ export function useAddAndDelRow(showAddIcon, showDelIcon, dataSourceRef, addDataMode, addDataReturnRecord, onChange, rowKey, refreshScuCell) {
29
+ var needAddAndDel = useMemo(function () {
30
+ return showAddIcon || showDelIcon;
31
+ }, [showAddIcon, showDelIcon]);
32
+ // 增减行回调
33
+ var onAddAndDelHandle = useCallback(function (type, index) {
34
+ var _a, _b;
35
+ if (typeof addDataMode === 'function') {
36
+ var newDataSource_1 = addDataMode(index, dataSourceRef.current, type);
37
+ refreshScuCell();
38
+ onChange &&
39
+ onChange(newDataSource_1, {
40
+ currentIndex: index,
41
+ type: type,
42
+ preDataSource: dataSourceRef.current,
43
+ currentRecord: dataSourceRef.current[index],
44
+ });
45
+ return;
46
+ }
47
+ var newDataSource = __spreadArray([], dataSourceRef.current);
48
+ var newRecord = {};
49
+ if (type === 'add') {
50
+ var currentRecord = newDataSource[index];
51
+ var outsideRecord = addDataReturnRecord
52
+ ? addDataReturnRecord(currentRecord)
53
+ : {};
54
+ if (addDataMode === 'blank') {
55
+ // 生成一条空白数据
56
+ newRecord = __assign((_a = {}, _a[rowKey] = Date.now() + "-" + index, _a.__INNER__ADD__DATA = true, _a), outsideRecord);
57
+ }
58
+ else {
59
+ // 复制当前这条数据
60
+ newRecord = __assign(__assign(__assign({}, currentRecord), (_b = {}, _b[rowKey] = Date.now() + "-" + index, _b.__INNER__ADD__DATA = true, _b)), outsideRecord);
61
+ }
62
+ newDataSource.splice(index + 1, 0, newRecord);
63
+ }
64
+ else {
65
+ newDataSource.splice(index, 1);
66
+ }
67
+ refreshScuCell();
68
+ onChange &&
69
+ onChange(newDataSource, {
70
+ currentIndex: index,
71
+ type: type,
72
+ preDataSource: dataSourceRef.current,
73
+ currentRecord: dataSourceRef.current[index],
74
+ });
75
+ }, [
76
+ addDataMode,
77
+ onChange,
78
+ dataSourceRef,
79
+ rowKey,
80
+ refreshScuCell,
81
+ addDataReturnRecord,
82
+ ]);
83
+ return {
84
+ needAddAndDel: needAddAndDel,
85
+ onAddAndDelHandle: onAddAndDelHandle,
86
+ };
87
+ }
88
+ // 拖拽行相关
89
+ export function useMoveRow(onChange, dataSourceRef, refreshScuCell) {
90
+ var onMoveRowHandle = useCallback(function (dragIndex, hoverIndex) {
91
+ var copyDataSource = __spreadArray([], dataSourceRef.current);
92
+ var dragRow = copyDataSource[dragIndex];
93
+ var newDataSource = update(copyDataSource, {
94
+ $splice: [
95
+ [dragIndex, 1],
96
+ [hoverIndex, 0, dragRow],
97
+ ],
98
+ });
99
+ refreshScuCell();
100
+ onChange &&
101
+ onChange(newDataSource, {
102
+ currentIndex: dragIndex,
103
+ targetIndex: hoverIndex,
104
+ type: 'move',
105
+ preDataSource: dataSourceRef.current,
106
+ });
107
+ }, [onChange, dataSourceRef, refreshScuCell]);
108
+ return onMoveRowHandle;
109
+ }
110
+ // 编辑行相关
111
+ function objIsEqual(newObj, oldObj) {
112
+ try {
113
+ var keys = Object.keys(newObj);
114
+ var oldKeys = Object.keys(oldObj);
115
+ if (keys.length !== oldKeys.length) {
116
+ return false;
117
+ }
118
+ for (var i = 0; i < keys.length; i++) {
119
+ var key = keys[i];
120
+ if (oldObj[key] !== newObj[key]) {
121
+ return false;
122
+ }
123
+ }
124
+ return true;
125
+ }
126
+ catch (err) {
127
+ return false;
128
+ }
129
+ }
130
+ export function useEditRow(onChange, dataSourceRef, innerTableHandleRef, _a) {
131
+ var onBatchPastePre = _a.onBatchPastePre, onBatchPastePost = _a.onBatchPastePost;
132
+ var onEditableSaveHandle = useCallback(function (record, index, _dataIndex, otherConfig) {
133
+ var _a;
134
+ var _b, _c, _d, _e;
135
+ if (_dataIndex === void 0) { _dataIndex = ''; }
136
+ if (typeof index === 'number') {
137
+ // TODO:帮助找到真实的index,如果开启内部分页 需要这么做
138
+ var realyIndex = otherConfig && otherConfig.isInner
139
+ ? index
140
+ : (_c = (_b = innerTableHandleRef.current) === null || _b === void 0 ? void 0 : _b.getRealyIndex) === null || _c === void 0 ? void 0 : _c.call(_b, index);
141
+ var newDataSource = __spreadArray([], dataSourceRef.current);
142
+ var oldRecord = newDataSource[realyIndex];
143
+ // 如果新的record里面的值 老的Record里面有 那么不需要触发onChange
144
+ // 这里主要是为了优化物料组件带来的多次rerender导致的一些问题
145
+ if (objIsEqual(record, oldRecord)) {
146
+ return;
147
+ }
148
+ // TODO:清楚错误样式
149
+ if (!otherConfig || (otherConfig && !otherConfig.isInner)) {
150
+ (_e = (_d = innerTableHandleRef === null || innerTableHandleRef === void 0 ? void 0 : innerTableHandleRef.current) === null || _d === void 0 ? void 0 : _d.clearErrorClass) === null || _e === void 0 ? void 0 : _e.call(_d, index);
151
+ }
152
+ var newRecord = _dataIndex
153
+ ? __assign(__assign(__assign({}, record), oldRecord), (_a = {}, _a[_dataIndex] = record[_dataIndex], _a)) : __assign(__assign({}, oldRecord), record);
154
+ newDataSource.splice(realyIndex, 1, newRecord);
155
+ onChange &&
156
+ onChange(newDataSource, {
157
+ currentIndex: realyIndex,
158
+ type: 'edit',
159
+ preDataSource: dataSourceRef.current,
160
+ });
161
+ }
162
+ }, [dataSourceRef, onChange, innerTableHandleRef]);
163
+ var onBatchPasteHandle = useCallback(function (records, startIndex) {
164
+ if (!Array.isArray(records)) {
165
+ return;
166
+ }
167
+ // 前置处理
168
+ var pasteRecords = onBatchPastePre
169
+ ? onBatchPastePre(records, {
170
+ currentIndex: startIndex,
171
+ })
172
+ : records;
173
+ // 计算结束位置
174
+ var endIndex = startIndex + pasteRecords.length - 1;
175
+ var currentRecords = Array.isArray(dataSourceRef.current)
176
+ ? dataSourceRef.current.slice()
177
+ : [];
178
+ if (endIndex > currentRecords.length - 1) {
179
+ endIndex = currentRecords.length - 1;
180
+ }
181
+ // 从开始位置开始,替换对应的值
182
+ var currentIndex = 0;
183
+ var dataSource = currentRecords.map(function (record, index) {
184
+ if (index >= startIndex && index <= endIndex) {
185
+ var obj = __assign(__assign({}, record), pasteRecords[currentIndex]);
186
+ currentIndex++;
187
+ return obj;
188
+ }
189
+ return record;
190
+ });
191
+ // 后置处理
192
+ var newDataSource = onBatchPastePost
193
+ ? onBatchPastePost(dataSource, {
194
+ currentIndex: startIndex,
195
+ endIndex: endIndex,
196
+ })
197
+ : dataSource;
198
+ // 触发onChange事件
199
+ onChange &&
200
+ onChange(newDataSource, {
201
+ currentIndex: startIndex,
202
+ endIndex: endIndex,
203
+ type: 'paste',
204
+ preDataSource: dataSourceRef.current,
205
+ });
206
+ }, [dataSourceRef, onChange, onBatchPastePre, onBatchPastePost]);
207
+ return {
208
+ onEditableSaveHandle: onEditableSaveHandle,
209
+ onBatchPasteHandle: onBatchPasteHandle,
210
+ };
211
+ }
212
+ // SCU刷新逻辑
213
+ // 这么写的原因是 如果拖拽行 增减行后,并不能触发column的scu
214
+ // 之前的写法是,通过useState刷新。但是 setState会触发整个组件的刷新
215
+ // 设置数据后,本身会触发setState。导致执行两次rerender。每个单元格都会执行rerender
216
+ // 通过Ref并不会触发 setState 通过setTimeout也不会导致每一个单元格的刷新出现问题
217
+ export function useScuRfresh() {
218
+ var timeOutRef = useRef(null);
219
+ var tableSCURefreshRef = useRef();
220
+ var refreshScuCell = useCallback(function () {
221
+ tableSCURefreshRef.current = true;
222
+ }, []);
223
+ var getRefreshScuCell = useCallback(function () {
224
+ if (tableSCURefreshRef.current) {
225
+ if (timeOutRef.current) {
226
+ clearTimeout(timeOutRef.current);
227
+ timeOutRef.current = null;
228
+ }
229
+ timeOutRef.current = setTimeout(function () {
230
+ tableSCURefreshRef.current = false;
231
+ });
232
+ return true;
233
+ }
234
+ return false;
235
+ }, []);
236
+ return {
237
+ refreshScuCell: refreshScuCell,
238
+ getRefreshScuCell: getRefreshScuCell,
239
+ };
240
+ }
241
+ // 选择相关控制
242
+ export function useChoice(choiceMode, filterOptions, selectedRowOptions) {
243
+ if (choiceMode === void 0) { choiceMode = 'checkbox'; }
244
+ var isChoiceFilter = filterOptions.isChoiceFilter, choiceFilterHandle = filterOptions.choiceFilterHandle;
245
+ var selectedRowKeys = selectedRowOptions.selectedRowKeys, selectedRows = selectedRowOptions.selectedRows, onSelectedRowChange = selectedRowOptions.onSelectedRowChange, onSelect = selectedRowOptions.onSelect;
246
+ var rowSelection = useMemo(function () {
247
+ return {
248
+ type: choiceMode,
249
+ selectedRowKeys: selectedRowKeys,
250
+ onChange: function (selectedRowKeys, selectedRows) {
251
+ onSelectedRowChange &&
252
+ onSelectedRowChange(selectedRowKeys, selectedRows);
253
+ },
254
+ onSelect: function (record, selected, selectedRows) {
255
+ onSelect && onSelect(record, selected, selectedRows);
256
+ },
257
+ // 过滤规则设置
258
+ getCheckboxProps: function (record) {
259
+ // 如果不开启过滤 那么全都可以选
260
+ if (!isChoiceFilter) {
261
+ return {};
262
+ }
263
+ // 如果传入了过滤函数,那么如何过滤用户自定义
264
+ if (choiceFilterHandle) {
265
+ return choiceFilterHandle(record, selectedRowKeys, selectedRows);
266
+ }
267
+ },
268
+ };
269
+ }, [
270
+ choiceMode,
271
+ isChoiceFilter,
272
+ choiceFilterHandle,
273
+ selectedRowKeys,
274
+ selectedRows,
275
+ onSelectedRowChange,
276
+ onSelect,
277
+ ]);
278
+ return { rowSelection: rowSelection };
279
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 业务封装可编辑表格组件
3
+ */
4
+ import React from 'react';
5
+ import { IProps } from './interface';
6
+ declare function ProEditTable(props: IProps<any>): JSX.Element;
7
+ declare const _default: React.MemoExoticComponent<typeof ProEditTable>;
8
+ export default _default;
@@ -0,0 +1,77 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /**
24
+ * 业务封装可编辑表格组件
25
+ */
26
+ import React, { memo, useRef, useImperativeHandle } from 'react';
27
+ import { Table } from '../../index';
28
+ import { useDataSourceRef, useAddAndDelRow, useScuRfresh, useMoveRow, useEditRow, useChoice, } from './hooks';
29
+ function ProEditTable(props) {
30
+ var rowKey = props.rowKey, dataSource = props.dataSource, columns = props.columns, onChange = props.onChange, showAddIcon = props.showAddIcon, showDelIcon = props.showDelIcon, _a = props.addDataMode, addDataMode = _a === void 0 ? 'blank' : _a, addDataReturnRecord = props.addDataReturnRecord, isMove = props.isMove, isEdit = props.isEdit, isPaste = props.isPaste, tableHandleRef = props.tableHandleRef, onBatchPastePre = props.onBatchPastePre, onBatchPastePost = props.onBatchPastePost, isChoice = props.isChoice, choiceMode = props.choiceMode, isChoiceFilter = props.isChoiceFilter, choiceFilterHandle = props.choiceFilterHandle, selectedRowKeys = props.selectedRowKeys, selectedRows = props.selectedRows, onSelectedRowChange = props.onSelectedRowChange, onSelect = props.onSelect, restProps = __rest(props, ["rowKey", "dataSource", "columns", "onChange", "showAddIcon", "showDelIcon", "addDataMode", "addDataReturnRecord", "isMove", "isEdit", "isPaste", "tableHandleRef", "onBatchPastePre", "onBatchPastePost", "isChoice", "choiceMode", "isChoiceFilter", "choiceFilterHandle", "selectedRowKeys", "selectedRows", "onSelectedRowChange", "onSelect"]);
31
+ var innerTableHandleRef = useRef();
32
+ var tableColumns = columns.map(function (item) {
33
+ if (item.shouldCellUpdate) {
34
+ var fn_1 = item.shouldCellUpdate;
35
+ item.shouldCellUpdate = function (record, preRecord) {
36
+ if (getRefreshScuCell()) {
37
+ return true;
38
+ }
39
+ return fn_1(record, preRecord);
40
+ };
41
+ }
42
+ return item;
43
+ });
44
+ // 保存dataSource值存为Ref
45
+ var dataSourceRef = useDataSourceRef(dataSource);
46
+ // SCU逻辑
47
+ var _b = useScuRfresh(), refreshScuCell = _b.refreshScuCell, getRefreshScuCell = _b.getRefreshScuCell;
48
+ // 增减行相关hook
49
+ var _c = useAddAndDelRow(showAddIcon, showDelIcon, dataSourceRef, addDataMode, addDataReturnRecord, onChange, rowKey, refreshScuCell), needAddAndDel = _c.needAddAndDel, onAddAndDelHandle = _c.onAddAndDelHandle;
50
+ // 拖拽行相关hook
51
+ var onMoveRowHandle = useMoveRow(onChange, dataSourceRef, refreshScuCell);
52
+ // 修改行相关hook
53
+ var _d = useEditRow(onChange, dataSourceRef, innerTableHandleRef, {
54
+ onBatchPastePre: onBatchPastePre,
55
+ onBatchPastePost: onBatchPastePost,
56
+ }), onEditableSaveHandle = _d.onEditableSaveHandle, onBatchPasteHandle = _d.onBatchPasteHandle;
57
+ // 选择行相关hook
58
+ var rowSelection = useChoice(choiceMode, {
59
+ isChoiceFilter: isChoiceFilter,
60
+ choiceFilterHandle: choiceFilterHandle,
61
+ }, {
62
+ selectedRowKeys: selectedRowKeys,
63
+ selectedRows: selectedRows,
64
+ onSelectedRowChange: onSelectedRowChange,
65
+ onSelect: onSelect,
66
+ }).rowSelection;
67
+ useImperativeHandle(tableHandleRef, function () { return ({
68
+ validate: innerTableHandleRef.current.validate,
69
+ clearErrorClass: innerTableHandleRef.current.clearErrorClass,
70
+ getCurrentPage: innerTableHandleRef.current.getCurrentPage,
71
+ getRealyIndex: innerTableHandleRef.current.getRealyIndex,
72
+ onEditableSaveHandle: onEditableSaveHandle,
73
+ scrollTo: innerTableHandleRef.current.scrollTo,
74
+ }); });
75
+ return (React.createElement(Table, __assign({ rowKey: rowKey, dataSource: dataSource, columns: tableColumns, hideAddIcon: !showAddIcon, hideDelIcon: !showDelIcon, onAddAndDelHandle: needAddAndDel ? onAddAndDelHandle : undefined, onMoveRow: isMove ? onMoveRowHandle : undefined, onEditableSave: isEdit ? onEditableSaveHandle : undefined, tableHandleRef: innerTableHandleRef, onTableChange: isPaste ? onBatchPasteHandle : undefined, rowSelection: isChoice ? rowSelection : undefined }, restProps)));
76
+ }
77
+ export default memo(ProEditTable);
@@ -0,0 +1,51 @@
1
+ /// <reference types="react" />
2
+ import { ColumnsType } from '../../components/Table';
3
+ import { IProps as TableIProps } from '../../components/Table/table';
4
+ export interface IProps<RecordType> extends Omit<TableIProps<RecordType>, 'columns' | 'onChange' | 'onEditableSave'> {
5
+ dataSource: any[];
6
+ columns: ColumnsType<any>;
7
+ rowKey: string;
8
+ onChange?: (dataSource: any[], info?: {
9
+ currentIndex: number;
10
+ endIndex?: number;
11
+ targetIndex?: number;
12
+ type?: string;
13
+ }) => void;
14
+ showAddIcon?: boolean;
15
+ showDelIcon?: boolean;
16
+ /**
17
+ * 增加数据的模式 blank add空白数据; copy add复制数据; 自定义增加
18
+ */
19
+ addDataMode?: 'blank' | 'copy' | ((index: number, dataSource: any[], type: string) => any[]);
20
+ addDataReturnRecord?: (record: any) => any;
21
+ isMove?: boolean;
22
+ isEdit?: boolean;
23
+ isPaste?: boolean;
24
+ onBatchPastePre?: (data: any[], info?: {
25
+ currentIndex: number;
26
+ endIndex?: number;
27
+ }) => any[];
28
+ onBatchPastePost?: (data: any[], info?: {
29
+ currentIndex: number;
30
+ endIndex?: number;
31
+ }) => any[];
32
+ isChoice?: boolean;
33
+ choiceMode?: 'radio' | 'checkbox';
34
+ isChoiceFilter?: boolean;
35
+ choiceFilterHandle?: (record: any, selectedRowKeys: React.Key[], selectedRows: any[]) => any;
36
+ selectedRowKeys?: React.Key[];
37
+ selectedRows?: any[];
38
+ onSelectedRowChange?: (selectedRowKeys: React.Key[], selectedRows: any[]) => void;
39
+ onSelect?: (record: any, selected: boolean, selectedRows: any) => void;
40
+ tableHandleRef?: React.Ref<{
41
+ validate: () => Promise<any>;
42
+ clearErrorClass: (index: number) => void;
43
+ getCurrentPage: () => {
44
+ page: number;
45
+ pageSize: number;
46
+ } | null;
47
+ getRealyIndex: (index: number) => number;
48
+ onEditableSaveHandle: (record: any, index: number | undefined, _dataIndex: string) => void;
49
+ [prop: string]: any;
50
+ }>;
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ title?: any;
4
+ field: any;
5
+ onClick?: any;
6
+ }
7
+ declare const FillDown: React.FC<IProps>;
8
+ export default FillDown;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { VerticalAlignBottomOutlined } from '@ant-design/icons';
3
+ var FillDown = function (_a) {
4
+ var title = _a.title, field = _a.field, onClick = _a.onClick;
5
+ return (React.createElement("div", { className: "zt-table_fillDown" },
6
+ React.createElement("div", { className: "fillDown_title" }, typeof title === 'function' ? title() : title),
7
+ React.createElement("div", { className: "fillDown_icon", title: "\u5F80\u4E0B\u586B\u5145", onClick: function (e) { return (onClick === null || onClick === void 0 ? void 0 : onClick.current) && onClick.current({ field: field }); } },
8
+ React.createElement(VerticalAlignBottomOutlined, null))));
9
+ };
10
+ export default FillDown;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ searchInputRef?: any;
4
+ setSelectedKeys?: any;
5
+ selectedKeys?: any;
6
+ confirm?: any;
7
+ clearFilters?: any;
8
+ dataIndex?: any;
9
+ handleSearch?: any;
10
+ handleReset?: any;
11
+ dataSourceRef?: any;
12
+ }
13
+ declare const FilterDropdown: React.FC<IProps>;
14
+ export default FilterDropdown;
@@ -0,0 +1,69 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
2
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
3
+ to[j] = from[i];
4
+ return to;
5
+ };
6
+ import React, { useState, useMemo } from 'react';
7
+ import { Input } from 'antd';
8
+ import { Button, Tooltip, Checkbox } from '../../../index';
9
+ import { QuestionCircleOutlined } from '@ant-design/icons';
10
+ var FilterDropdown = function (_a) {
11
+ var searchInputRef = _a.searchInputRef, setSelectedKeys = _a.setSelectedKeys, selectedKeys = _a.selectedKeys, confirm = _a.confirm, clearFilters = _a.clearFilters, dataIndex = _a.dataIndex, handleSearch = _a.handleSearch, handleReset = _a.handleReset, dataSourceRef = _a.dataSourceRef;
12
+ var _b = useState(''), v = _b[0], setV = _b[1];
13
+ var _c = useState([]), cV = _c[0], setCV = _c[1];
14
+ var currentData = useMemo(function () {
15
+ if (!Array.isArray(dataSourceRef.current)) {
16
+ return [];
17
+ }
18
+ if (typeof dataIndex !== 'string') {
19
+ return [];
20
+ }
21
+ var newArr = dataSourceRef.current.map(function (item) {
22
+ var _a;
23
+ return (_a = item[dataIndex]) !== null && _a !== void 0 ? _a : '';
24
+ });
25
+ // 记录出现次数
26
+ var resultArr = [];
27
+ newArr
28
+ .filter(function (item) { return item !== ''; })
29
+ .forEach(function (item) {
30
+ var index = resultArr.findIndex(function (i) { return i.value === item; });
31
+ if (index === -1) {
32
+ resultArr.push({
33
+ value: item,
34
+ count: 1,
35
+ });
36
+ }
37
+ else {
38
+ resultArr[index].count++;
39
+ }
40
+ });
41
+ return resultArr;
42
+ }, [dataIndex, dataSourceRef]);
43
+ return (React.createElement("div", { style: { padding: 6 }, onKeyDown: function (e) { return e.stopPropagation(); } },
44
+ React.createElement(Input, { ref: searchInputRef, value: v, onChange: function (e) {
45
+ setV(e.target.value);
46
+ setSelectedKeys(e.target.value ? __spreadArray([e.target.value], cV) : __spreadArray([], cV));
47
+ }, onPressEnter: function () {
48
+ return handleSearch(selectedKeys, confirm, dataIndex);
49
+ }, style: { marginBottom: 8 } }),
50
+ React.createElement(Checkbox.Group, { className: "table-checkbox", value: cV, onChange: function (checkValue) {
51
+ setCV(checkValue);
52
+ setSelectedKeys(v ? __spreadArray(__spreadArray([], checkValue), [v]) : checkValue);
53
+ } }, currentData.map(function (item) {
54
+ return (React.createElement(Checkbox, { key: item.value, value: item.value }, item.value));
55
+ })),
56
+ React.createElement("div", null,
57
+ React.createElement(Button, { type: "primary", onClick: function () {
58
+ return handleSearch(selectedKeys, confirm, dataIndex);
59
+ } },
60
+ "\u641C\u7D22",
61
+ React.createElement(Tooltip, { placement: "bottomLeft", title: "\u5BF9\u4E8E\u6570\u5B57\u5217\u53EF\u4EE5\u5C1D\u8BD5\u8F93\u5165\u4E00\u4E9B\u8868\u8FBE\u5F0F: $0 + 1 > 2\u3001 >= 10\u3001 $0 + 1 == 2" },
62
+ React.createElement(QuestionCircleOutlined, null))),
63
+ React.createElement(Button, { onClick: function () {
64
+ setV('');
65
+ setCV([]);
66
+ clearFilters && handleReset(clearFilters);
67
+ }, style: { marginLeft: 10 } }, "\u91CD\u7F6E"))));
68
+ };
69
+ export default FilterDropdown;
@@ -3,3 +3,5 @@
3
3
  */
4
4
  export declare const dynamicColumnDragType: unique symbol;
5
5
  export declare const tableDragRowType: unique symbol;
6
+ export declare const INNER_PARENT_ROW_KEY = "__inner__parent__row__key_cyx";
7
+ export declare const INNER_PARENT_ROW_KEY_NO = "__inner__parent__row__key_cyx_no";
@@ -3,3 +3,5 @@
3
3
  */
4
4
  export var dynamicColumnDragType = Symbol('dynamic-column-drag');
5
5
  export var tableDragRowType = Symbol('table-drag-row');
6
+ export var INNER_PARENT_ROW_KEY = '__inner__parent__row__key_cyx';
7
+ export var INNER_PARENT_ROW_KEY_NO = '__inner__parent__row__key_cyx_no';
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { ColumnsType } from '../';
2
+ import { IProps as ITableProps } from '../table';
3
3
  export interface IConfigInfo {
4
4
  [props: string]: {
5
5
  isChangeable?: any;
@@ -9,20 +9,21 @@ export interface IConfigInfo {
9
9
  }
10
10
  interface IProps<RecordType> {
11
11
  columns: ColumnsType<RecordType> | undefined;
12
+ hiddenColumnDynamicIcon?: boolean;
12
13
  showColumnDynamic?: boolean;
13
14
  showColumnDynamicKey?: string;
14
15
  /**新增行删除行方法 */
15
16
  onAddAndDelHandle?: (type: 'add' | 'del', index: number) => void;
16
17
  /**隐藏新增icon */
17
- hideAddIcon?: boolean;
18
+ hideAddIcon?: ITableProps<any>['hideAddIcon'];
18
19
  /**新增icon提示文字 */
19
- addIconText?: string;
20
+ addIconText?: ITableProps<any>['addIconText'];
20
21
  /**隐藏删除icon */
21
- hideDelIcon?: boolean;
22
+ hideDelIcon?: ITableProps<any>['hideDelIcon'];
22
23
  showDelAllBtn?: boolean;
23
24
  delAllChange?: any;
24
25
  /**删除icon提示文字 */
25
- delIconText?: string;
26
+ delIconText?: ITableProps<any>['delIconText'];
26
27
  showDynamicHandle?: () => void;
27
28
  /**表格列编辑事件 */
28
29
  onEditableSave?: (record: RecordType, index: number | undefined, dataIndex: string) => void;
@@ -32,15 +33,26 @@ interface IProps<RecordType> {
32
33
  onTableChange?: any;
33
34
  /** 当前页 */
34
35
  currentPage?: any;
36
+ currentDataSource?: any;
37
+ preDataSource?: any;
38
+ rowKey?: any;
39
+ dataSourceRef?: any;
40
+ expandableChildrenColumnName?: string;
41
+ customSortHandle?: any;
42
+ customOrder?: any;
43
+ setCustomOrder?: any;
44
+ isSort?: boolean;
45
+ onFillDownChangeRef?: any;
35
46
  }
36
47
  export declare const getTableLayoutFullData: (columns: any, tableLayout: any) => any;
37
48
  export declare const LOCALSTORAGE_KEY = "ztui_dynamic_table_key";
38
49
  export declare const LOCALSTORAGE_LRU_KEY = "ztui_dynamic_table_lru_key";
39
50
  export declare const LOCALSTORAGE_LRU_MAX_SIZE = 500;
51
+ export declare function getStorage(key: any): any;
40
52
  export declare function setDynamicKey(dynamicStorageKey: string, value: any): void;
41
53
  declare function useColumns<RecordType>(props: IProps<RecordType>): {
42
- newColumns: any;
43
- dynamicColumns: any;
44
- setNewColumns: React.Dispatch<any>;
54
+ newColumns: ColumnsType<RecordType>;
55
+ dynamicColumns: ColumnsType<RecordType>;
56
+ refreshColumnsHandle: (columns?: any) => void;
45
57
  };
46
58
  export default useColumns;