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.
- package/README.md +57 -57
- package/dist/DemoCom/SyhDemo.d.ts +3 -0
- package/dist/DemoCom/SyhDemo.js +257 -0
- package/dist/DemoCom/TableDemo.js +8 -4
- package/dist/TableDemo/BasicTable.js +2 -1
- package/dist/TableDemo/EditableTable.js +83 -67
- package/dist/TableDemo/ProEditableTable.d.ts +21 -0
- package/dist/TableDemo/ProEditableTable.js +482 -0
- package/dist/TableDemo/data.d.ts +15 -0
- package/dist/TableDemo/data.js +33 -1
- package/dist/TableDemo/index.js +6 -5
- package/dist/components/DatePicker/data-picker.d.ts +7 -8
- package/dist/components/Menu/menu.d.ts +3 -3
- package/dist/components/PrintContainer/utils.js +3 -3
- package/dist/components/ProTable/hooks.d.ts +28 -0
- package/dist/components/ProTable/hooks.js +279 -0
- package/dist/components/ProTable/index.d.ts +8 -0
- package/dist/components/ProTable/index.js +77 -0
- package/dist/components/ProTable/interface.d.ts +51 -0
- package/dist/components/ProTable/interface.js +1 -0
- package/dist/components/Table/components/FillDown.d.ts +8 -0
- package/dist/components/Table/components/FillDown.js +10 -0
- package/dist/components/Table/components/FilterDropdown.d.ts +14 -0
- package/dist/components/Table/components/FilterDropdown.js +69 -0
- package/dist/components/Table/constants.d.ts +2 -0
- package/dist/components/Table/constants.js +2 -0
- package/dist/components/Table/hooks/useColumns.d.ts +20 -8
- package/dist/components/Table/hooks/useColumns.js +484 -182
- package/dist/components/Table/hooks/useDropRef.js +2 -1
- package/dist/components/Table/hooks/useInnerPagination.js +1 -0
- package/dist/components/Table/hooks/useSelectSubtotal.d.ts +4 -0
- package/dist/components/Table/hooks/useSelectSubtotal.js +178 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/Table/table-adddel-column.d.ts +8 -5
- package/dist/components/Table/table-adddel-column.js +15 -5
- package/dist/components/Table/table-dynamic.js +63 -5
- package/dist/components/Table/table-enhance-cell.d.ts +6 -3
- package/dist/components/Table/table-enhance-cell.js +196 -109
- package/dist/components/Table/table-enhance-row.d.ts +4 -4
- package/dist/components/Table/table-enhance-row.js +10 -11
- package/dist/components/Table/table-headTooltip.d.ts +6 -0
- package/dist/components/Table/table-headTooltip.js +13 -0
- package/dist/components/Table/table-resizable-title.d.ts +4 -5
- package/dist/components/Table/table-resizable-title.js +32 -6
- package/dist/components/Table/table-sort.d.ts +11 -0
- package/dist/components/Table/table-sort.js +65 -0
- package/dist/components/Table/table.d.ts +20 -4
- package/dist/components/Table/table.js +478 -176
- package/dist/components/Table/utils/dom.d.ts +26 -0
- package/dist/components/Table/utils/dom.js +122 -0
- package/dist/components/Table/utils/filterHandle.d.ts +1 -0
- package/dist/components/Table/utils/filterHandle.js +51 -0
- package/dist/components/Table/utils/getSummaryData.d.ts +1 -0
- package/dist/components/Table/utils/getSummaryData.js +3 -1
- package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
- package/dist/components/Table/utils/shallowEqual.js +34 -0
- package/dist/components/Table/utils/validate.d.ts +1 -1
- package/dist/components/Table/utils/validate.js +5 -5
- package/dist/components/TimePicker/time-picker.d.ts +0 -1
- package/dist/components/ZtIcon/index.d.ts +1 -1
- package/dist/components/business/Common/UserForgetPassword/index.js +17 -6
- package/dist/components/business/Common/UserInfo/index.js +3 -1
- package/dist/components/business/Common/UserPassword/index.d.ts +1 -0
- package/dist/components/business/Common/UserPassword/index.js +42 -14
- package/dist/components/business/Common/validatePassword.d.ts +8 -0
- package/dist/components/business/Common/validatePassword.js +168 -0
- package/dist/components/utils/index.d.ts +1 -0
- package/dist/components/utils/index.js +20 -0
- package/dist/components/utils/useLastest.d.ts +2 -0
- package/dist/components/utils/useLastest.js +6 -0
- package/dist/index.css +96 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/package.json +4 -3
|
@@ -56,12 +56,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
56
|
}
|
|
57
57
|
return t;
|
|
58
58
|
};
|
|
59
|
-
import React, {
|
|
60
|
-
import { EditableContext } from './table-enhance-row';
|
|
61
|
-
import {
|
|
59
|
+
import React, { useEffect, memo, useRef, useCallback, useMemo, useState, } from 'react';
|
|
60
|
+
// import { EditableContext } from './table-enhance-row';
|
|
61
|
+
import { InputNumber, Select, message } from '../../index';
|
|
62
|
+
import { Input } from 'antd';
|
|
62
63
|
import { ERROR_TD_CLASSNAME } from './index';
|
|
63
64
|
import { getInnerIndex } from './hooks/useInnerPagination';
|
|
64
65
|
import { exactRound } from 'ztxkutils/dist/tools';
|
|
66
|
+
import { INNER_PARENT_ROW_KEY_NO, INNER_PARENT_ROW_KEY } from './constants';
|
|
65
67
|
/**
|
|
66
68
|
* 数据转换 将粘贴过来的数据格式化处理
|
|
67
69
|
*/
|
|
@@ -85,74 +87,109 @@ function transformData(data, config) {
|
|
|
85
87
|
}
|
|
86
88
|
return newData;
|
|
87
89
|
}
|
|
88
|
-
var TableEnhanceCell =
|
|
89
|
-
var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "onTableChange", "columns", "currentpage"]);
|
|
90
|
-
var form = useContext(EditableContext);
|
|
90
|
+
var TableEnhanceCell = function (_a) {
|
|
91
|
+
var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, dataSource = _a.dataSource, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, rowKey = _a.rowKey, expandableChildrenColumnName = _a.expandableChildrenColumnName, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "dataSource", "onTableChange", "columns", "currentpage", "onMouseEnter", "onMouseLeave", "rowKey", "expandableChildrenColumnName"]);
|
|
91
92
|
var tdRef = useRef();
|
|
93
|
+
var valueRef = useRef({});
|
|
94
|
+
var _b = useState(), val = _b[0], setVal = _b[1];
|
|
92
95
|
useEffect(function () {
|
|
93
|
-
var _a;
|
|
94
96
|
if (dataIndex) {
|
|
95
|
-
|
|
97
|
+
// form?.setFieldsValue({ [dataIndex]: record[dataIndex] });
|
|
98
|
+
// form?.setFieldValue(dataIndex, record[dataIndex]);
|
|
99
|
+
setVal(record[dataIndex]);
|
|
100
|
+
valueRef.current[dataIndex] = record[dataIndex];
|
|
96
101
|
}
|
|
97
|
-
}, [dataIndex,
|
|
102
|
+
}, [dataIndex, record]);
|
|
98
103
|
/**
|
|
99
104
|
* @description 保存事件
|
|
100
105
|
*/
|
|
101
|
-
var save = function (info) { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
-
var innerIndex, values, result, currentInputNumberValue, result, currentInputNumberValue
|
|
103
|
-
var _a, _b;
|
|
104
|
-
return __generator(this, function (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
var save = useCallback(function (info) { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var innerIndex, newDataSource, newRecord, parentId_1, currentParentItem, parentIndex, currentParentItemChildren, childrenRecord, values, result, currentInputNumberValue, result, currentInputNumberValue;
|
|
108
|
+
var _a, _b, _c;
|
|
109
|
+
return __generator(this, function (_d) {
|
|
110
|
+
innerIndex = getInnerIndex(currentpage, index);
|
|
111
|
+
newDataSource = dataSource ? dataSource() : undefined;
|
|
112
|
+
newRecord = record;
|
|
113
|
+
// 代表当前修改的是子项,需要通过rowKey找到父项中对应的子项,取到最新值
|
|
114
|
+
if (newRecord && newRecord[INNER_PARENT_ROW_KEY]) {
|
|
115
|
+
try {
|
|
116
|
+
innerIndex = typeof index === 'number' ? index : innerIndex;
|
|
117
|
+
parentId_1 = newRecord[INNER_PARENT_ROW_KEY];
|
|
118
|
+
currentParentItem = null;
|
|
119
|
+
// 代表没有配置rowKey,那需要找到父级index
|
|
120
|
+
if (parentId_1.startsWith(INNER_PARENT_ROW_KEY_NO)) {
|
|
121
|
+
parentIndex = parentId_1.slice(INNER_PARENT_ROW_KEY_NO.length) - 0;
|
|
122
|
+
currentParentItem = newDataSource[parentIndex];
|
|
116
123
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
currentInputNumberValue = values[dataIndex];
|
|
120
|
-
if (currentInputNumberValue > (result === null || result === void 0 ? void 0 : result.number)) {
|
|
121
|
-
message.warning((result.tableName ? "\u60A8\u4FEE\u6539" + result.tableName + "\u8868\u683C\u7684" : '表格') + " \u7B2C" + (typeof index === 'number' ? index + 1 : index) + "\u884C \u7684" + title + "\u5B57\u6BB5\uFF0C\u8F93\u5165\u7684\u6570\u503C\uFF0C\u5DF2\u8D85\u8FC7\u6700\u5927\u503C\uFF0C\u5DF2\u5E2E\u60A8\u4FEE\u6539\u4E3A\u6700\u5927\u503C!");
|
|
122
|
-
handleSave(__assign(__assign(__assign({}, record), values), (_a = {}, _a[dataIndex] = result === null || result === void 0 ? void 0 : result.number, _a)),
|
|
123
|
-
// index,
|
|
124
|
-
innerIndex, dataIndex);
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
}
|
|
124
|
+
else {
|
|
125
|
+
currentParentItem = newDataSource.find(function (item) { return item[rowKey] === parentId_1; });
|
|
127
126
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
currentParentItemChildren = currentParentItem[expandableChildrenColumnName];
|
|
128
|
+
childrenRecord = typeof index === 'number'
|
|
129
|
+
? __assign({}, currentParentItemChildren[index]) : record;
|
|
130
|
+
Reflect.deleteProperty(childrenRecord, INNER_PARENT_ROW_KEY);
|
|
131
|
+
newRecord = typeof index === 'number' ? childrenRecord : record;
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
console.log(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// 直接取父级元素即可
|
|
139
|
+
newRecord =
|
|
140
|
+
Array.isArray(newDataSource) && typeof innerIndex === 'number'
|
|
141
|
+
? newDataSource[innerIndex]
|
|
142
|
+
: record;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
values = valueRef.current;
|
|
146
|
+
if (!handleSave) {
|
|
147
|
+
console.error('Table props onEditableSave is not a function');
|
|
148
|
+
}
|
|
149
|
+
if (info && info.maxResult) {
|
|
150
|
+
result = info.maxResult;
|
|
151
|
+
currentInputNumberValue = values[dataIndex];
|
|
152
|
+
if (currentInputNumberValue > (result === null || result === void 0 ? void 0 : result.number)) {
|
|
153
|
+
message.warning((result.tableName ? "\u60A8\u4FEE\u6539" + result.tableName + "\u8868\u683C\u7684" : '表格') + " \u7B2C" + (typeof index === 'number' ? index + 1 : index) + "\u884C \u7684" + title + "\u5B57\u6BB5\uFF0C\u8F93\u5165\u7684\u6570\u503C\uFF0C\u5DF2\u8D85\u8FC7\u6700\u5927\u503C\uFF0C\u5DF2\u5E2E\u60A8\u4FEE\u6539\u4E3A\u6700\u5927\u503C!");
|
|
154
|
+
handleSave(__assign(__assign({}, newRecord), (_a = {}, _a[dataIndex] = result === null || result === void 0 ? void 0 : result.number, _a)), innerIndex, dataIndex, { isInner: true });
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (info && info.minResult) {
|
|
159
|
+
result = info.minResult;
|
|
160
|
+
currentInputNumberValue = values[dataIndex];
|
|
161
|
+
if (currentInputNumberValue < (result === null || result === void 0 ? void 0 : result.number)) {
|
|
162
|
+
message.warning((result.tableName ? "\u60A8\u4FEE\u6539" + result.tableName + "\u8868\u683C\u7684" : '表格') + " \u7B2C" + (index ? index + 1 : index) + "\u884C \u7684" + title + "\u5B57\u6BB5\uFF0C\u8F93\u5165\u7684\u6570\u503C\uFF0C\u5DF2\u4F4E\u4E8E\u6700\u5C0F\u503C\uFF0C\u5DF2\u5E2E\u60A8\u4FEE\u6539\u4E3A\u6700\u5C0F\u503C!");
|
|
163
|
+
handleSave(__assign(__assign({}, newRecord), (_b = {}, _b[dataIndex] = result === null || result === void 0 ? void 0 : result.number, _b)), innerIndex, dataIndex, { isInner: true });
|
|
164
|
+
return [2 /*return*/];
|
|
138
165
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return [3 /*break*/, 4];
|
|
142
|
-
case 3:
|
|
143
|
-
err_1 = _c.sent();
|
|
144
|
-
console.error('Save failed:', err_1);
|
|
145
|
-
return [3 /*break*/, 4];
|
|
146
|
-
case 4: return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
handleSave(__assign(__assign({}, newRecord), (_c = {}, _c[dataIndex] = values[dataIndex], _c)), innerIndex, dataIndex, { isInner: true });
|
|
147
168
|
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
console.error('Save failed:', err);
|
|
171
|
+
}
|
|
172
|
+
return [2 /*return*/];
|
|
148
173
|
});
|
|
149
|
-
}); }
|
|
150
|
-
|
|
151
|
-
|
|
174
|
+
}); }, [
|
|
175
|
+
currentpage,
|
|
176
|
+
dataIndex,
|
|
177
|
+
handleSave,
|
|
178
|
+
index,
|
|
179
|
+
record,
|
|
180
|
+
title,
|
|
181
|
+
dataSource,
|
|
182
|
+
expandableChildrenColumnName,
|
|
183
|
+
rowKey,
|
|
184
|
+
]);
|
|
185
|
+
var removeErrorClass = useCallback(function () {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
if (tdRef.current &&
|
|
188
|
+
((_b = (_a = tdRef.current.classList).contains) === null || _b === void 0 ? void 0 : _b.call(_a, ERROR_TD_CLASSNAME))) {
|
|
152
189
|
tdRef.current.classList.remove(ERROR_TD_CLASSNAME);
|
|
153
190
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
191
|
+
}, []);
|
|
192
|
+
var onPasteHandle = useCallback(function (e) {
|
|
156
193
|
if (!onTableChange) {
|
|
157
194
|
return;
|
|
158
195
|
}
|
|
@@ -211,22 +248,38 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
211
248
|
return result;
|
|
212
249
|
});
|
|
213
250
|
// onTableChange && onTableChange(resultTextList, index, record);
|
|
251
|
+
setVal(resultTextList[0][dataIndex]);
|
|
252
|
+
valueRef.current[dataIndex] = resultTextList[0][dataIndex];
|
|
214
253
|
onTableChange && onTableChange(resultTextList, innerIndex, record);
|
|
215
254
|
}
|
|
216
255
|
}
|
|
217
|
-
}
|
|
256
|
+
}, [columns, currentpage, dataIndex, index, onTableChange, record]);
|
|
218
257
|
/**
|
|
219
258
|
* @description 生成编辑框
|
|
220
259
|
*/
|
|
221
|
-
var createEditableDom = function (
|
|
260
|
+
var createEditableDom = useMemo(function () {
|
|
261
|
+
// 执行优化,减少生成无意义的组件rerender次数
|
|
262
|
+
if (!editable) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
222
265
|
if (!editableConfig) {
|
|
223
|
-
return (React.createElement(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
266
|
+
return (React.createElement(Input, { autoComplete: "new-password", maxLength: 50, onPressEnter: save, onBlur: save, allowClear: true, onPaste: onPasteHandle, value: val, onMouseUp: function (e) {
|
|
267
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
268
|
+
},
|
|
269
|
+
// draggable
|
|
270
|
+
// onDragStart={(e) => {
|
|
271
|
+
// e?.stopPropagation?.();
|
|
272
|
+
// e?.preventDefault?.();
|
|
273
|
+
// e?.nativeEvent?.stopImmediatePropagation?.();
|
|
274
|
+
// }}
|
|
275
|
+
onChange: function (e) {
|
|
276
|
+
setVal(e.target.value);
|
|
277
|
+
removeErrorClass();
|
|
278
|
+
valueRef.current[dataIndex] = e.target.value;
|
|
279
|
+
if (!e.target.value) {
|
|
280
|
+
e.target.focus();
|
|
281
|
+
}
|
|
282
|
+
} }));
|
|
230
283
|
}
|
|
231
284
|
var type = editableConfig.type, data = editableConfig.data, keyValue = editableConfig.keyValue, maxHandle = editableConfig.maxHandle, minHandle = editableConfig.minHandle, overMaxTip = editableConfig.overMaxTip, lowMinTip = editableConfig.lowMinTip, disabledHandle = editableConfig.disabledHandle, editableProps = __rest(editableConfig, ["type", "data", "keyValue", "maxHandle", "minHandle", "overMaxTip", "lowMinTip", "disabledHandle"]);
|
|
232
285
|
var selectData = data; // 下拉框使用到得数据
|
|
@@ -278,53 +331,87 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
278
331
|
}
|
|
279
332
|
// 处理各种类型
|
|
280
333
|
if (type === 'select') {
|
|
281
|
-
return (React.createElement(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
334
|
+
return (React.createElement(Select, __assign({ allowClear: true }, editableProps, { disabled: disabledResult, value: val, onChange: function (value, option) {
|
|
335
|
+
removeErrorClass();
|
|
336
|
+
save(value);
|
|
337
|
+
valueRef.current[dataIndex] = value;
|
|
338
|
+
} }), Array.isArray(selectData) &&
|
|
339
|
+
selectData.map(function (item) { return (React.createElement(Select.Option, { key: item[selectKeyValue.key] + '', value: item[selectKeyValue === null || selectKeyValue === void 0 ? void 0 : selectKeyValue.key] }, item[selectKeyValue === null || selectKeyValue === void 0 ? void 0 : selectKeyValue.label])); })));
|
|
287
340
|
}
|
|
288
341
|
else if (type === 'inputNumber') {
|
|
289
|
-
return (React.createElement(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
342
|
+
return (React.createElement(InputNumber, __assign({ autoComplete: "new-password", maxLength: 50 }, inputNumMaxMin, editableProps, inputNumberRangeTip, { disabled: disabledResult,
|
|
343
|
+
// draggable
|
|
344
|
+
// onDragStart={(e) => {
|
|
345
|
+
// e?.stopPropagation?.();
|
|
346
|
+
// e?.preventDefault?.();
|
|
347
|
+
// e?.nativeEvent?.stopImmediatePropagation?.();
|
|
348
|
+
// }}
|
|
349
|
+
onPressEnter: function (e) {
|
|
350
|
+
var _a;
|
|
351
|
+
editableProps.onPressEnter && ((_a = editableProps.onPressEnter) === null || _a === void 0 ? void 0 : _a.call(editableProps, e));
|
|
352
|
+
save({ maxResult: maxResult, minResult: minResult });
|
|
353
|
+
}, onBlur: function (e) {
|
|
354
|
+
var _a;
|
|
355
|
+
editableProps.onBlur && ((_a = editableProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(editableProps, e));
|
|
356
|
+
save({ maxResult: maxResult, minResult: minResult });
|
|
357
|
+
}, onFocus: function (e) {
|
|
358
|
+
var _a;
|
|
359
|
+
editableProps.onFocus && ((_a = editableProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(editableProps, e));
|
|
360
|
+
}, onPaste: onPasteHandle, value: val, onChange: function (value) {
|
|
361
|
+
setVal(value);
|
|
362
|
+
valueRef.current[dataIndex] = value;
|
|
363
|
+
removeErrorClass();
|
|
364
|
+
} })));
|
|
304
365
|
}
|
|
305
366
|
else if (type === 'textArea') {
|
|
306
|
-
return (React.createElement(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
367
|
+
return (React.createElement(Input.TextArea, __assign({ autoComplete: "new-password", maxLength: 200, autoSize: { maxRows: 3 } }, editableProps, { disabled: disabledResult, onPressEnter: save, onBlur: save, onPaste: onPasteHandle, value: val, onMouseUp: function (e) {
|
|
368
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
369
|
+
},
|
|
370
|
+
// draggable
|
|
371
|
+
// onDragStart={(e) => {
|
|
372
|
+
// e?.stopPropagation?.();
|
|
373
|
+
// e?.preventDefault?.();
|
|
374
|
+
// e?.nativeEvent?.stopImmediatePropagation?.();
|
|
375
|
+
// }}
|
|
376
|
+
onChange: function (e) {
|
|
377
|
+
setVal(e.target.value);
|
|
378
|
+
valueRef.current[dataIndex] = e.target.value;
|
|
379
|
+
removeErrorClass();
|
|
380
|
+
if (!e.target.value) {
|
|
381
|
+
e.target.focus();
|
|
382
|
+
}
|
|
383
|
+
}, allowClear: true })));
|
|
313
384
|
}
|
|
314
385
|
else {
|
|
315
|
-
return (React.createElement(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
386
|
+
return (React.createElement(Input, __assign({ autoComplete: "new-password", maxLength: 50 }, editableProps, { disabled: disabledResult, onPressEnter: save, onBlur: save, allowClear: true, onPaste: onPasteHandle, value: val, onMouseUp: function (e) {
|
|
387
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
388
|
+
},
|
|
389
|
+
// draggable
|
|
390
|
+
// onDragStart={(e) => {
|
|
391
|
+
// e?.stopPropagation?.();
|
|
392
|
+
// e?.preventDefault?.();
|
|
393
|
+
// e?.nativeEvent?.stopImmediatePropagation?.();
|
|
394
|
+
// }}
|
|
395
|
+
onChange: function (e) {
|
|
396
|
+
setVal(e.target.value);
|
|
397
|
+
valueRef.current[dataIndex] = e.target.value;
|
|
398
|
+
removeErrorClass();
|
|
399
|
+
if (!e.target.value) {
|
|
400
|
+
e.target.focus();
|
|
401
|
+
}
|
|
402
|
+
} })));
|
|
322
403
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
404
|
+
}, [
|
|
405
|
+
val,
|
|
406
|
+
editable,
|
|
407
|
+
editableConfig,
|
|
408
|
+
dataIndex,
|
|
409
|
+
index,
|
|
410
|
+
onPasteHandle,
|
|
411
|
+
record,
|
|
412
|
+
removeErrorClass,
|
|
413
|
+
save,
|
|
414
|
+
]);
|
|
415
|
+
return (React.createElement("td", __assign({ ref: tdRef }, restProps), editable ? (React.createElement("div", { className: "zt-table__enhance-cell" }, createEditableDom)) : (children)));
|
|
416
|
+
};
|
|
417
|
+
export default memo(TableEnhanceCell);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IMoveRow as _IMoveRow } from './hooks/useDropRef';
|
|
3
|
-
import { FormInstance } from 'antd/lib/form';
|
|
4
3
|
export declare type IMoveRow = _IMoveRow;
|
|
5
4
|
interface IProps {
|
|
6
5
|
index: number;
|
|
7
6
|
moverow: IMoveRow;
|
|
8
7
|
className?: string;
|
|
9
8
|
style?: any;
|
|
9
|
+
vRow?: any;
|
|
10
|
+
[prop: string]: any;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default TableEnhanceRow;
|
|
12
|
+
declare const _default: React.NamedExoticComponent<IProps>;
|
|
13
|
+
export default _default;
|
|
@@ -20,16 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, { memo } from 'react';
|
|
23
|
+
import React, { memo, useMemo } from 'react';
|
|
24
24
|
import useDropRef from './hooks/useDropRef';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var TableEnhanceRow = memo(function (props) {
|
|
28
|
-
var index = props.index, moverow = props.moverow, className = props.className, style = props.style, restProps = __rest(props, ["index", "moverow", "className", "style"]);
|
|
25
|
+
var TableEnhanceRow = function (props) {
|
|
26
|
+
var index = props.index, moverow = props.moverow, className = props.className, style = props.style, vRow = props.vRow, restProps = __rest(props, ["index", "moverow", "className", "style", "vRow"]);
|
|
29
27
|
var _a = useDropRef(index, moverow), ref = _a.ref, isOver = _a.isOver, dropClassName = _a.dropClassName;
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
|
|
28
|
+
var memoStyle = useMemo(function () { return (__assign({ cursor: !moverow ? 'default' : 'move' }, style)); }, [moverow, style]);
|
|
29
|
+
var tempProps = useMemo(function () {
|
|
30
|
+
return __assign({ ref: ref, className: "" + className + (isOver ? dropClassName : ''), style: memoStyle }, restProps);
|
|
31
|
+
}, [className, dropClassName, restProps, memoStyle, isOver, ref]);
|
|
32
|
+
return vRow ? (vRow(tempProps, ref)) : (React.createElement("tr", __assign({ ref: ref, className: "" + className + (isOver ? dropClassName : ''), style: memoStyle }, restProps)));
|
|
33
|
+
};
|
|
34
|
+
export default memo(TableEnhanceRow);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
3
|
+
import { Tooltip } from '../../index';
|
|
4
|
+
var TableHeadTooltip = function (_a) {
|
|
5
|
+
var children = _a.children, headTooltip = _a.headTooltip;
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
children,
|
|
8
|
+
React.createElement(Tooltip, { title: headTooltip },
|
|
9
|
+
React.createElement(QuestionCircleOutlined, { style: {
|
|
10
|
+
marginLeft: '5px',
|
|
11
|
+
} }))));
|
|
12
|
+
};
|
|
13
|
+
export default TableHeadTooltip;
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* @description
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
onResize: (e: React.SyntheticEvent<Element>, data: any) => void;
|
|
6
|
+
declare const _default: React.MemoExoticComponent<(props: React.HTMLAttributes<any> & {
|
|
7
|
+
onResize: (e: React.SyntheticEvent<Element, Event>, data: any) => void;
|
|
9
8
|
width: number;
|
|
10
|
-
}) => JSX.Element
|
|
11
|
-
export default
|
|
9
|
+
}) => JSX.Element>;
|
|
10
|
+
export default _default;
|
|
@@ -24,16 +24,42 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
* @author 陈亚雄
|
|
25
25
|
* @description
|
|
26
26
|
*/
|
|
27
|
-
import React from 'react';
|
|
27
|
+
import React, { useState } from 'react';
|
|
28
28
|
import { Resizable } from 'react-resizable';
|
|
29
|
+
import classnames from 'classnames';
|
|
29
30
|
var TableResizableTitle = function (props) {
|
|
30
|
-
var onResize = props.onResize, width = props.width, restProps = __rest(props, ["onResize", "width"]);
|
|
31
|
+
var onResize = props.onResize, width = props.width, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, restProps = __rest(props, ["onResize", "width", "onMouseEnter", "onMouseLeave"]);
|
|
32
|
+
// 添加偏移量
|
|
33
|
+
var _a = useState(0), offset = _a[0], setOffset = _a[1];
|
|
31
34
|
if (!width) {
|
|
32
35
|
return React.createElement("th", __assign({}, restProps));
|
|
33
36
|
}
|
|
34
|
-
return (React.createElement(Resizable, { width: width, height: 0, handle: React.createElement("span", {
|
|
37
|
+
return (React.createElement(Resizable, { width: Number(width) + Number(offset), height: 0, handle: React.createElement("span", {
|
|
38
|
+
// 有偏移量显示竖线
|
|
39
|
+
// className="react-resizable-handle"
|
|
40
|
+
className: classnames(['react-resizable-handle', offset && 'active']),
|
|
41
|
+
// 拖拽层偏移
|
|
42
|
+
style: { transform: "translateX(" + offset + "px)" }, onClick: function (e) {
|
|
35
43
|
e.stopPropagation();
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
} }), onResize: function (e, _a) {
|
|
46
|
+
var size = _a.size;
|
|
47
|
+
// 这里只更新偏移量,数据列表其实并没有伸缩
|
|
48
|
+
setOffset(size.width - width);
|
|
49
|
+
}, onResizeStop: function (e, data) {
|
|
50
|
+
// 拖拽结束以后偏移量归零
|
|
51
|
+
setOffset(0);
|
|
52
|
+
// 这里是props传进来的事件,在外部是列数据中的onHeaderCell方法提供的事件,请自行研究官方提供的案例
|
|
53
|
+
onResize(e, data);
|
|
54
|
+
}, draggableOpts: { enableUserSelectHack: false } },
|
|
55
|
+
React.createElement("th", __assign({}, restProps, { style: __assign({ overflow: 'visible' }, restProps.style) }),
|
|
56
|
+
React.createElement("div", { style: {
|
|
57
|
+
width: '100%',
|
|
58
|
+
overflow: 'hidden',
|
|
59
|
+
whiteSpace: 'pre-wrap',
|
|
60
|
+
// whiteSpace: 'nowrap',
|
|
61
|
+
// textOverflow: 'ellipsis',
|
|
62
|
+
// 此处样式是在th中增加div块,为了解决拖拉时偏移虚线在右侧不出现问题
|
|
63
|
+
} }, restProps.children))));
|
|
38
64
|
};
|
|
39
|
-
export default TableResizableTitle;
|
|
65
|
+
export default React.memo(TableResizableTitle);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import CaretDownOutlined from '@ant-design/icons/CaretDownOutlined';
|
|
4
|
+
import CaretUpOutlined from '@ant-design/icons/CaretUpOutlined';
|
|
5
|
+
var ASCEND = 'ascend';
|
|
6
|
+
var DESCEND = 'descend';
|
|
7
|
+
export default function TableSortTitle(props) {
|
|
8
|
+
var title = props.title, field = props.field, onChange = props.onChange, customOrder = props.customOrder, setCustomOrder = props.setCustomOrder, align = props.align;
|
|
9
|
+
// const [order, setOrder] = useState<any>();
|
|
10
|
+
var order = !customOrder
|
|
11
|
+
? null
|
|
12
|
+
: customOrder.field === field
|
|
13
|
+
? customOrder.order
|
|
14
|
+
: null;
|
|
15
|
+
var handleSortClick = function (e) {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
var currentOrd;
|
|
18
|
+
if (order === ASCEND) {
|
|
19
|
+
currentOrd = DESCEND;
|
|
20
|
+
setCustomOrder({
|
|
21
|
+
field: field,
|
|
22
|
+
order: currentOrd,
|
|
23
|
+
});
|
|
24
|
+
// setOrder(DESCEND);
|
|
25
|
+
}
|
|
26
|
+
else if (order === DESCEND) {
|
|
27
|
+
currentOrd = null;
|
|
28
|
+
setCustomOrder({
|
|
29
|
+
field: field,
|
|
30
|
+
order: currentOrd,
|
|
31
|
+
});
|
|
32
|
+
// setOrder(null);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
currentOrd = ASCEND;
|
|
36
|
+
setCustomOrder({
|
|
37
|
+
field: field,
|
|
38
|
+
order: currentOrd,
|
|
39
|
+
});
|
|
40
|
+
// setOrder(ASCEND);
|
|
41
|
+
}
|
|
42
|
+
onChange && onChange({ field: field, order: currentOrd });
|
|
43
|
+
};
|
|
44
|
+
var currentTitle = useMemo(function () {
|
|
45
|
+
if (order === ASCEND) {
|
|
46
|
+
return '点击降序';
|
|
47
|
+
}
|
|
48
|
+
else if (order === DESCEND) {
|
|
49
|
+
return '取消排序';
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return '点击升序';
|
|
53
|
+
}
|
|
54
|
+
}, [order]);
|
|
55
|
+
return (React.createElement("div", { className: "zt-table_sorter" },
|
|
56
|
+
align === 'center' ? React.createElement("div", null) : null,
|
|
57
|
+
React.createElement("div", { className: "sorter_title" }, typeof title === 'function' ? title() : title),
|
|
58
|
+
React.createElement("div", { className: "sorter_icon", onClick: handleSortClick, title: currentTitle },
|
|
59
|
+
React.createElement(CaretUpOutlined, { className: classNames("ant-table-column-sorter-up", {
|
|
60
|
+
active: order === ASCEND,
|
|
61
|
+
}) }),
|
|
62
|
+
React.createElement(CaretDownOutlined, { className: classNames("ant-table-column-sorter-down", {
|
|
63
|
+
active: order === DESCEND,
|
|
64
|
+
}) }))));
|
|
65
|
+
}
|
|
@@ -7,13 +7,15 @@ export interface IProps<RecordType> extends Omit<TableProps<RecordType>, 'column
|
|
|
7
7
|
/**新增行删除行方法 */
|
|
8
8
|
onAddAndDelHandle?: (type: 'add' | 'del', index: number) => void;
|
|
9
9
|
/**隐藏新增icon */
|
|
10
|
-
hideAddIcon?: boolean;
|
|
10
|
+
hideAddIcon?: boolean | ((record: any, index: number) => boolean);
|
|
11
11
|
/**新增icon提示文字 */
|
|
12
|
-
addIconText?: string;
|
|
12
|
+
addIconText?: string | ((record: any, index: number) => string);
|
|
13
13
|
/**隐藏删除icon */
|
|
14
|
-
hideDelIcon?: boolean;
|
|
14
|
+
hideDelIcon?: boolean | ((record: any, index: number) => boolean);
|
|
15
15
|
/**删除icon提示文字 */
|
|
16
|
-
delIconText?: string;
|
|
16
|
+
delIconText?: string | ((record: any, index: number) => string);
|
|
17
|
+
/** 是否隐藏图标 */
|
|
18
|
+
hiddenColumnDynamicIcon?: boolean;
|
|
17
19
|
/**是否显示动态表头配置 */
|
|
18
20
|
showColumnDynamic?: boolean;
|
|
19
21
|
/**动态表头配置,是否缓存,动态列配置如果要缓存得话,必须得使用一个全局唯一得key来标识 */
|
|
@@ -57,6 +59,19 @@ export interface IProps<RecordType> extends Omit<TableProps<RecordType>, 'column
|
|
|
57
59
|
/** 是否显示删除全部按钮 */
|
|
58
60
|
showDelAllBtn?: boolean;
|
|
59
61
|
delAllChange?: () => void;
|
|
62
|
+
/** 开启虚拟滚动 */
|
|
63
|
+
virtualTableKey?: string;
|
|
64
|
+
/** 是否需要排序 内部会有一个排序功能。自定义的 这个在某些条件下不会开启。但是还需要别的条件也不开启 */
|
|
65
|
+
isSort?: boolean;
|
|
66
|
+
/** 排序方法 ascend 升序 descend 降序 */
|
|
67
|
+
onSortChange?: (info: {
|
|
68
|
+
order: 'ascend' | 'descend' | null;
|
|
69
|
+
field: string;
|
|
70
|
+
}) => void;
|
|
71
|
+
/** 填充方法 */
|
|
72
|
+
onFillDownChange?: (info: {
|
|
73
|
+
field: string;
|
|
74
|
+
}) => void;
|
|
60
75
|
}
|
|
61
76
|
/**
|
|
62
77
|
* TodoList
|
|
@@ -68,6 +83,7 @@ export interface IProps<RecordType> extends Omit<TableProps<RecordType>, 'column
|
|
|
68
83
|
* 实现可拖拽行 completed
|
|
69
84
|
* 实现可编辑功能
|
|
70
85
|
*/
|
|
86
|
+
export declare function usePrevious(value: any): undefined;
|
|
71
87
|
declare function Table<RecordType extends object = any>(props: IProps<RecordType>): JSX.Element;
|
|
72
88
|
declare const _default: React.MemoExoticComponent<typeof Table>;
|
|
73
89
|
export default _default;
|