@zat-design/sisyphus-react 3.4.10 → 3.4.11-beta.2
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/index.esm.css +64 -50
- package/dist/less.esm.css +64 -50
- package/es/ProEditTable/components/DndWrapper/index.d.ts +1 -0
- package/es/ProEditTable/components/DndWrapper/index.js +4 -3
- package/es/ProEditTable/components/RenderField/index.js +6 -10
- package/es/ProEditTable/index.js +49 -56
- package/es/ProEditTable/propsType.d.ts +5 -0
- package/es/ProEditTable/style/index.less +10 -0
- package/es/ProForm/components/base/DatePicker/useDateLimit.d.ts +9 -0
- package/es/ProForm/components/base/DatePicker/useDateLimit.js +15 -0
- package/es/ProForm/components/base/InputNumber/index.js +42 -28
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +35 -29
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +28 -20
- package/es/ProForm/components/combination/FormList/propsType.d.ts +4 -4
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +3 -0
- package/es/ProForm/components/combination/Group/index.js +2 -2
- package/es/ProForm/components/combination/Group/style/index.less +1 -1
- package/es/ProForm/components/combination/Group/utils.d.ts +1 -1
- package/es/ProForm/components/combination/Group/utils.js +40 -5
- package/es/ProForm/components/combination/ProCascader/utils/index.js +5 -3
- package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.js +4 -3
- package/es/ProForm/index.js +3 -2
- package/es/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
- package/es/ProForm/utils/useDeepCompareMemo.js +2 -1
- package/es/ProForm/utils/useForm.js +11 -2
- package/es/ProForm/utils/useShouldUpdate.js +8 -2
- package/es/ProIcon/index.d.ts +1 -0
- package/es/ProIcon/index.js +2 -3
- package/es/ProIcon/symbolIcon.js +43 -0
- package/es/ProTree/components/ProTree.js +18 -10
- package/es/ProTree/components/ProTreeSelect/index.js +2 -2
- package/es/ProTree/components/Tree.js +11 -6
- package/es/ProTree/index.js +2 -1
- package/es/ProUpload/components/ButtonRender.d.ts +1 -0
- package/es/ProUpload/components/ButtonRender.js +3 -1
- package/es/ProUpload/components/FileItem.d.ts +1 -0
- package/es/ProUpload/components/FileItem.js +21 -3
- package/es/ProUpload/index.js +4 -2
- package/es/ProUpload/propsType.d.ts +5 -0
- package/es/ProUpload/style/index.less +101 -111
- package/lib/ProEditTable/components/DndWrapper/index.d.ts +1 -0
- package/lib/ProEditTable/components/DndWrapper/index.js +4 -3
- package/lib/ProEditTable/components/RenderField/index.js +6 -10
- package/lib/ProEditTable/index.js +48 -55
- package/lib/ProEditTable/propsType.d.ts +5 -0
- package/lib/ProEditTable/style/index.less +10 -0
- package/lib/ProForm/components/base/DatePicker/useDateLimit.d.ts +9 -0
- package/lib/ProForm/components/base/DatePicker/useDateLimit.js +22 -0
- package/lib/ProForm/components/base/InputNumber/index.js +41 -27
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +35 -29
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +28 -20
- package/lib/ProForm/components/combination/FormList/propsType.d.ts +4 -4
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +3 -0
- package/lib/ProForm/components/combination/Group/index.js +1 -1
- package/lib/ProForm/components/combination/Group/style/index.less +1 -1
- package/lib/ProForm/components/combination/Group/utils.d.ts +1 -1
- package/lib/ProForm/components/combination/Group/utils.js +40 -5
- package/lib/ProForm/components/combination/ProCascader/utils/index.js +5 -3
- package/lib/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProRangeLimit/index.js +4 -3
- package/lib/ProForm/index.js +3 -2
- package/lib/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
- package/lib/ProForm/utils/useDeepCompareMemo.js +2 -1
- package/lib/ProForm/utils/useForm.js +11 -2
- package/lib/ProForm/utils/useShouldUpdate.js +8 -2
- package/lib/ProIcon/index.d.ts +1 -0
- package/lib/ProIcon/index.js +1 -2
- package/lib/ProIcon/symbolIcon.js +45 -0
- package/lib/ProTree/components/ProTree.js +17 -9
- package/lib/ProTree/components/ProTreeSelect/index.js +2 -2
- package/lib/ProTree/components/Tree.js +11 -6
- package/lib/ProTree/index.js +2 -1
- package/lib/ProUpload/components/ButtonRender.d.ts +1 -0
- package/lib/ProUpload/components/ButtonRender.js +3 -1
- package/lib/ProUpload/components/FileItem.d.ts +1 -0
- package/lib/ProUpload/components/FileItem.js +19 -3
- package/lib/ProUpload/index.js +4 -2
- package/lib/ProUpload/propsType.d.ts +5 -0
- package/lib/ProUpload/style/index.less +101 -111
- package/package.json +1 -1
|
@@ -160,11 +160,6 @@ var RenderField = function RenderField(_ref) {
|
|
|
160
160
|
_formItemProps.valuePropName = 'checked';
|
|
161
161
|
valueType = 'switch';
|
|
162
162
|
}
|
|
163
|
-
// 针对Percentage特殊处理
|
|
164
|
-
if (type === 'Percentage') {
|
|
165
|
-
type = 'InputNumber';
|
|
166
|
-
valueType = 'percentage';
|
|
167
|
-
}
|
|
168
163
|
/**
|
|
169
164
|
* 针对一些特殊类型,基于formItem的normalize与getValueProps进行默认值类型转换
|
|
170
165
|
* @returns {}
|
|
@@ -292,7 +287,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
292
287
|
return nextArgs;
|
|
293
288
|
};
|
|
294
289
|
// 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
|
|
295
|
-
var
|
|
290
|
+
var _onChange = debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
296
291
|
var _len2,
|
|
297
292
|
args,
|
|
298
293
|
_key2,
|
|
@@ -319,7 +314,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
319
314
|
}
|
|
320
315
|
_args = [].concat(args);
|
|
321
316
|
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
322
|
-
row = form.getFieldValue(rowPath, true);
|
|
317
|
+
row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
|
|
323
318
|
orgRow = cloneDeep(row);
|
|
324
319
|
if (!onFieldChange) {
|
|
325
320
|
_context.next = 18;
|
|
@@ -372,7 +367,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
372
367
|
});
|
|
373
368
|
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
374
369
|
setTimeout(function () {
|
|
375
|
-
form.validateFields(validateFieldKeys);
|
|
370
|
+
form.validateFields([name].concat(_toConsumableArray(validateFieldKeys)));
|
|
376
371
|
}, 100);
|
|
377
372
|
}
|
|
378
373
|
}
|
|
@@ -410,7 +405,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
410
405
|
}
|
|
411
406
|
_args = formatArgs([].concat(args));
|
|
412
407
|
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
413
|
-
row = form.getFieldValue(rowPath, true);
|
|
408
|
+
row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
|
|
414
409
|
orgRow = cloneDeep(row);
|
|
415
410
|
_args[1] = row;
|
|
416
411
|
_context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
|
|
@@ -488,12 +483,13 @@ var RenderField = function RenderField(_ref) {
|
|
|
488
483
|
}, _fieldProps), (_TargetComponent4 = TargetComponent) === null || _TargetComponent4 === void 0 ? void 0 : _TargetComponent4.props), {}, {
|
|
489
484
|
namePath: [].concat(_toConsumableArray(namePath), [index]),
|
|
490
485
|
disabled: _disabled,
|
|
491
|
-
onChange:
|
|
486
|
+
onChange: _onChange,
|
|
492
487
|
onBlur: _onblur,
|
|
493
488
|
index: index,
|
|
494
489
|
otherProps: {
|
|
495
490
|
form: form,
|
|
496
491
|
names: names,
|
|
492
|
+
namePath: [].concat(_toConsumableArray(namePath), [index]),
|
|
497
493
|
name: cellName,
|
|
498
494
|
listName: cellName,
|
|
499
495
|
viewEmpty: viewEmpty,
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import "antd/es/table/style";
|
|
2
2
|
import _Table from "antd/es/table";
|
|
3
3
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
5
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
6
|
import "antd/es/config-provider/style";
|
|
@@ -11,11 +9,11 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
11
9
|
import "antd/es/form/style";
|
|
12
10
|
import _Form from "antd/es/form";
|
|
13
11
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["value", "onChange", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled"];
|
|
12
|
+
var _excluded = ["value", "onChange", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "footerRender"];
|
|
15
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
14
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
17
15
|
import { get, isArray } from 'lodash';
|
|
18
|
-
import {
|
|
16
|
+
import { useLocalStorageState, useSetState } from 'ahooks';
|
|
19
17
|
import classnames from 'classnames';
|
|
20
18
|
import { transformColumns } from './utils';
|
|
21
19
|
import { getRandom, getNamePath } from './utils/tools';
|
|
@@ -52,6 +50,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
52
50
|
originalDiffTip = _ref.originalDiffTip,
|
|
53
51
|
rowKey = _ref.rowKey,
|
|
54
52
|
rowDisabled = _ref.rowDisabled,
|
|
53
|
+
footerRender = _ref.footerRender,
|
|
55
54
|
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
56
55
|
// 上下文form
|
|
57
56
|
var contentForm = _Form.useFormInstance();
|
|
@@ -95,8 +94,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
95
94
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
96
95
|
state = _useSetState2[0],
|
|
97
96
|
setState = _useSetState2[1];
|
|
98
|
-
var
|
|
99
|
-
cellNamePath = state.cellNamePath,
|
|
97
|
+
var cellNamePath = state.cellNamePath,
|
|
100
98
|
forceUpdate = state.forceUpdate,
|
|
101
99
|
editingKeys = state.editingKeys,
|
|
102
100
|
virtualKey = state.virtualKey,
|
|
@@ -173,6 +171,25 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
173
171
|
}
|
|
174
172
|
return className;
|
|
175
173
|
};
|
|
174
|
+
// 判断是否禁止添加、批量删除
|
|
175
|
+
var isForbiddenBtn = useCallback(function (type) {
|
|
176
|
+
// 当工具栏不渲染时,都不渲染
|
|
177
|
+
if (toolbarProps === false) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
// 通过配置项配置show 为 false 开启关闭添加与批量删除
|
|
181
|
+
if (Array.isArray(toolbarProps)) {
|
|
182
|
+
var addBtnConfig = toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.find(function (item) {
|
|
183
|
+
return item.type === type;
|
|
184
|
+
});
|
|
185
|
+
if (typeof (addBtnConfig === null || addBtnConfig === void 0 ? void 0 : addBtnConfig.show) === 'function') {
|
|
186
|
+
addBtnConfig.show = addBtnConfig.show();
|
|
187
|
+
}
|
|
188
|
+
return (addBtnConfig === null || addBtnConfig === void 0 ? void 0 : addBtnConfig.show) === false;
|
|
189
|
+
}
|
|
190
|
+
}, [toolbarProps]);
|
|
191
|
+
// 是否隐藏勾选框
|
|
192
|
+
var isHideCheckBox = isForbiddenBtn('mulDelete');
|
|
176
193
|
// 复选框
|
|
177
194
|
var _rowSelection = _objectSpread({
|
|
178
195
|
fixed: true,
|
|
@@ -191,25 +208,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
191
208
|
};
|
|
192
209
|
}
|
|
193
210
|
return {};
|
|
194
|
-
}
|
|
211
|
+
},
|
|
212
|
+
hideSelectAll: isHideCheckBox
|
|
195
213
|
}, rowSelection);
|
|
196
|
-
// 判断是否禁止添加、批量删除
|
|
197
|
-
var isForbiddenBtn = useCallback(function (type) {
|
|
198
|
-
// 当工具栏不渲染时,都不渲染
|
|
199
|
-
if (toolbarProps === false) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
// 通过配置项配置show 为 false 开启关闭添加与批量删除
|
|
203
|
-
if (Array.isArray(toolbarProps)) {
|
|
204
|
-
var addBtnConfig = toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.find(function (item) {
|
|
205
|
-
return item.type === type;
|
|
206
|
-
});
|
|
207
|
-
if (typeof (addBtnConfig === null || addBtnConfig === void 0 ? void 0 : addBtnConfig.show) === 'function') {
|
|
208
|
-
addBtnConfig.show = addBtnConfig.show();
|
|
209
|
-
}
|
|
210
|
-
return (addBtnConfig === null || addBtnConfig === void 0 ? void 0 : addBtnConfig.show) === false;
|
|
211
|
-
}
|
|
212
|
-
}, [toolbarProps]);
|
|
213
214
|
// 分页变更
|
|
214
215
|
var handlePageChange = useCallback(function (current, pageSize) {
|
|
215
216
|
setState({
|
|
@@ -245,41 +246,29 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
245
246
|
* @returns rowSelection
|
|
246
247
|
*/
|
|
247
248
|
var renderRowSelection = function renderRowSelection() {
|
|
248
|
-
if (disabled || isView) {
|
|
249
|
+
if (disabled || isView || isHideCheckBox) {
|
|
249
250
|
return null;
|
|
250
251
|
}
|
|
251
|
-
return
|
|
252
|
+
return _rowSelection;
|
|
252
253
|
};
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}));
|
|
272
|
-
return function setColumns() {
|
|
273
|
-
return _ref4.apply(this, arguments);
|
|
274
|
-
};
|
|
275
|
-
}();
|
|
276
|
-
useDebounceEffect(function () {
|
|
277
|
-
setColumns();
|
|
278
|
-
}, [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page],
|
|
279
|
-
// columns更新修复外部表单无法控制内部表单的问题
|
|
280
|
-
{
|
|
281
|
-
wait: 60
|
|
282
|
-
});
|
|
254
|
+
var _columns = useMemo(function () {
|
|
255
|
+
return transformColumns(columns, config);
|
|
256
|
+
}, [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page, config.name]);
|
|
257
|
+
// const setColumns = async () => {
|
|
258
|
+
// const nextColumns = transformColumns(columns, config);
|
|
259
|
+
// setState({
|
|
260
|
+
// _columns: nextColumns,
|
|
261
|
+
// });
|
|
262
|
+
// };
|
|
263
|
+
// useDebounceEffect(
|
|
264
|
+
// () => {
|
|
265
|
+
// setColumns();
|
|
266
|
+
// },
|
|
267
|
+
// [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page], // columns更新修复外部表单无法控制内部表单的问题
|
|
268
|
+
// {
|
|
269
|
+
// wait: 60,
|
|
270
|
+
// },
|
|
271
|
+
// );
|
|
283
272
|
useEffect(function () {
|
|
284
273
|
var _value$;
|
|
285
274
|
// 初始化默认生成row-key
|
|
@@ -341,6 +330,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
341
330
|
onRow: function onRow() {
|
|
342
331
|
return {
|
|
343
332
|
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
333
|
+
isHideCheckBox: isHideCheckBox,
|
|
344
334
|
onClick: function onClick() {}
|
|
345
335
|
};
|
|
346
336
|
}
|
|
@@ -366,6 +356,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
366
356
|
}), !isView && (value === null || value === void 0 ? void 0 : value.length) ? _jsx("div", {
|
|
367
357
|
className: "pro-edit-table-toolbar".concat(pagination ? ' pro-edit-table-toolbar-fixed' : ''),
|
|
368
358
|
children: _jsx(RenderToolbar, _objectSpread({}, config))
|
|
359
|
+
}) : null, footerRender ? _jsx("div", {
|
|
360
|
+
className: "pro-edit-table-footer",
|
|
361
|
+
children: footerRender
|
|
369
362
|
}) : null]
|
|
370
363
|
}), _jsx(Validator, {
|
|
371
364
|
name: name,
|
|
@@ -217,6 +217,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
217
217
|
* @default -
|
|
218
218
|
*/
|
|
219
219
|
actionProps?: BaseActionProps<T>[] | boolean;
|
|
220
|
+
/**
|
|
221
|
+
* @description 自定义 table footer 左侧渲染, 配置后toolbarProps会失效
|
|
222
|
+
* @default -
|
|
223
|
+
*/
|
|
224
|
+
footerRender?: ReactNode;
|
|
220
225
|
/**
|
|
221
226
|
* @description 自定义底部操作栏 默认为添加、删除(批量)
|
|
222
227
|
* @default -
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
td[rowspan]{
|
|
6
6
|
vertical-align: middle !important;
|
|
7
7
|
}
|
|
8
|
+
|
|
8
9
|
.pro-edit-table-tooltip {
|
|
9
10
|
display : inline-flex;
|
|
10
11
|
align-items: center;
|
|
@@ -71,6 +72,11 @@
|
|
|
71
72
|
cursor: pointer;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
.drag-wrapper.no-check {
|
|
76
|
+
.anticon {
|
|
77
|
+
margin-right: 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
74
80
|
|
|
75
81
|
&.pro-table-no-stripe {
|
|
76
82
|
.@{ant-prefix}-table-tbody tr:nth-child(n)>td {
|
|
@@ -282,6 +288,10 @@
|
|
|
282
288
|
}
|
|
283
289
|
}
|
|
284
290
|
|
|
291
|
+
.pro-edit-table-footer{
|
|
292
|
+
margin-top: 12px;
|
|
293
|
+
}
|
|
294
|
+
|
|
285
295
|
.pro-edit-table-header {
|
|
286
296
|
margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1));
|
|
287
297
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DurationInputArg1, DurationInputArg2, Moment } from 'moment';
|
|
2
|
+
interface Props {
|
|
3
|
+
range?: [Moment?, Moment?];
|
|
4
|
+
limit?: [DurationInputArg1, DurationInputArg2];
|
|
5
|
+
}
|
|
6
|
+
export declare const useDateLimit: (props: Props) => {
|
|
7
|
+
onCalendarChange: (val: any) => void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
export var useDateLimit = function useDateLimit(props) {
|
|
4
|
+
var range = props.range,
|
|
5
|
+
limit = props.limit;
|
|
6
|
+
var _useState = useState(),
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
dates = _useState2[0],
|
|
9
|
+
setDates = _useState2[1];
|
|
10
|
+
return {
|
|
11
|
+
onCalendarChange: function onCalendarChange(val) {
|
|
12
|
+
return setDates(val);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -6,9 +6,9 @@ import _Space from "antd/es/space";
|
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
7
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
9
|
-
var _excluded = ["placeholder", "className", "otherProps", "range", "min", "max", "onBlur"];
|
|
9
|
+
var _excluded = ["placeholder", "className", "otherProps", "range", "min", "max", "onBlur", "onFocus"];
|
|
10
10
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { useMemo } from 'react';
|
|
11
|
+
import { useMemo, useRef } from 'react';
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
import Big from 'big.js';
|
|
14
14
|
import { tools } from '@zat-design/utils';
|
|
@@ -42,6 +42,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
42
42
|
min = props.min,
|
|
43
43
|
max = props.max,
|
|
44
44
|
onBlur = props.onBlur,
|
|
45
|
+
onFocus = props.onFocus,
|
|
45
46
|
rest = _objectWithoutProperties(props, _excluded);
|
|
46
47
|
var _ref2 = ProForm.useFieldProps() || {},
|
|
47
48
|
isViewCon = _ref2.isView,
|
|
@@ -49,34 +50,45 @@ var InputNumber = function InputNumber(props) {
|
|
|
49
50
|
valueType = _ref2.valueType,
|
|
50
51
|
viewType = _ref2.viewType,
|
|
51
52
|
label = _ref2.label;
|
|
53
|
+
var initialConfig = useProConfig('InputNumber');
|
|
54
|
+
var activateRef = useRef(false);
|
|
52
55
|
var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
|
|
53
56
|
var valueProps = {};
|
|
57
|
+
var formatter = function formatter(value) {
|
|
58
|
+
if (value === '') return '';
|
|
59
|
+
var num = Number(value);
|
|
60
|
+
if (Number.isNaN(num)) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
var val = num.toLocaleString('en-US', {
|
|
64
|
+
maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision) || 2
|
|
65
|
+
});
|
|
66
|
+
if (!activateRef.current) {
|
|
67
|
+
var _val$split = val.split('.'),
|
|
68
|
+
_val$split2 = _slicedToArray(_val$split, 2),
|
|
69
|
+
int = _val$split2[0],
|
|
70
|
+
_val$split2$ = _val$split2[1],
|
|
71
|
+
float = _val$split2$ === void 0 ? '' : _val$split2$;
|
|
72
|
+
return "".concat(int, ".").concat(float.padEnd((props === null || props === void 0 ? void 0 : props.precision) || 2, '0'));
|
|
73
|
+
}
|
|
74
|
+
return val;
|
|
75
|
+
};
|
|
76
|
+
var _parser = function parser(value, precision) {
|
|
77
|
+
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
78
|
+
if (value === '') return value;
|
|
79
|
+
return Number.isNaN(num) || !precision ? value : num.toFixed(precision);
|
|
80
|
+
};
|
|
54
81
|
if (valueType) {
|
|
55
82
|
switch (valueType) {
|
|
56
|
-
//
|
|
83
|
+
// 千分位
|
|
57
84
|
case 'thousandth':
|
|
58
85
|
case 'thousandthCNY':
|
|
59
86
|
case 'money':
|
|
60
87
|
case 'amount':
|
|
61
88
|
valueProps = {
|
|
62
|
-
formatter:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
var num = Number(value);
|
|
67
|
-
if (Number.isNaN(num)) {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
return num.toLocaleString('en-US', {
|
|
71
|
-
maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision) || 2
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
parser: function parser(value) {
|
|
75
|
-
var num = Number(value.replace(/[\s,]+/g, ''));
|
|
76
|
-
if (value === '') {
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
return Number.isNaN(num) ? value : num.toFixed((props === null || props === void 0 ? void 0 : props.precision) || 2);
|
|
89
|
+
formatter: formatter,
|
|
90
|
+
parser: function parser(val) {
|
|
91
|
+
return _parser(val, (props === null || props === void 0 ? void 0 : props.precision) || 2);
|
|
80
92
|
}
|
|
81
93
|
};
|
|
82
94
|
break;
|
|
@@ -144,7 +156,6 @@ var InputNumber = function InputNumber(props) {
|
|
|
144
156
|
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
145
157
|
_min = _useMemo2[0],
|
|
146
158
|
_max = _useMemo2[1];
|
|
147
|
-
var initialConfig = useProConfig('InputNumber');
|
|
148
159
|
var _className = classNames(_defineProperty({
|
|
149
160
|
'full-form-item': true
|
|
150
161
|
}, className, !!className));
|
|
@@ -222,15 +233,12 @@ var InputNumber = function InputNumber(props) {
|
|
|
222
233
|
// 失去焦点时处理数字,
|
|
223
234
|
var handleBlur = function handleBlur(e) {
|
|
224
235
|
var _e$target, _e$target2;
|
|
225
|
-
|
|
236
|
+
activateRef.current = false;
|
|
237
|
+
var value = _parser(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value, props.precision);
|
|
226
238
|
var limit = {
|
|
227
239
|
min: Number(_min),
|
|
228
240
|
max: Number(_max)
|
|
229
241
|
};
|
|
230
|
-
// 截取数字指定精度
|
|
231
|
-
if (props.precision !== undefined) {
|
|
232
|
-
value = Number(value.toFixed(props.precision));
|
|
233
|
-
}
|
|
234
242
|
switch (valueType || viewType) {
|
|
235
243
|
// 百分比
|
|
236
244
|
case 'percent':
|
|
@@ -245,7 +253,12 @@ var InputNumber = function InputNumber(props) {
|
|
|
245
253
|
value = limitNumber(value, limit);
|
|
246
254
|
break;
|
|
247
255
|
}
|
|
248
|
-
onBlur(value, Number(e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value));
|
|
256
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(value, Number(e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value));
|
|
257
|
+
};
|
|
258
|
+
// 获得焦点
|
|
259
|
+
var handleFocus = function handleFocus(e) {
|
|
260
|
+
activateRef.current = true;
|
|
261
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
249
262
|
};
|
|
250
263
|
return _jsx(_InputNumber, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
251
264
|
autoComplete: "off",
|
|
@@ -253,6 +266,7 @@ var InputNumber = function InputNumber(props) {
|
|
|
253
266
|
className: _className
|
|
254
267
|
}, valueProps), initialConfig), rest), {}, {
|
|
255
268
|
onBlur: handleBlur,
|
|
269
|
+
onFocus: handleFocus,
|
|
256
270
|
min: _min,
|
|
257
271
|
max: _max
|
|
258
272
|
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "antd/es/button/style";
|
|
2
2
|
import _Button from "antd/es/button";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import "antd/es/popconfirm/style";
|
|
5
4
|
import _Popconfirm from "antd/es/popconfirm";
|
|
6
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
@@ -9,7 +8,8 @@ import _Space from "antd/es/space";
|
|
|
9
8
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
10
9
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
11
10
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
12
|
-
|
|
11
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
12
|
+
var _excluded = ["label", "onClick", "onHandle", "type", "needConfirm", "confirmProps", "title"],
|
|
13
13
|
_excluded2 = ["onClick", "label"];
|
|
14
14
|
import { createElement as _createElement } from "react";
|
|
15
15
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -28,7 +28,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
28
28
|
var add = operation.add;
|
|
29
29
|
add(undefined, index + 1);
|
|
30
30
|
},
|
|
31
|
-
type: 'text',
|
|
32
31
|
label: "".concat(locale.ProForm.formListActions[0]),
|
|
33
32
|
icon: _jsx(PlusSquareOutlined, {})
|
|
34
33
|
},
|
|
@@ -40,7 +39,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
40
39
|
var remove = operation.remove;
|
|
41
40
|
remove(index);
|
|
42
41
|
},
|
|
43
|
-
type: 'text',
|
|
44
42
|
label: "".concat(locale.ProForm.formListActions[1]),
|
|
45
43
|
icon: mode === 'less' ? _jsx(ProIcon, {
|
|
46
44
|
type: "solid-close",
|
|
@@ -57,7 +55,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
57
55
|
var add = operation.add;
|
|
58
56
|
add(record, index + 1);
|
|
59
57
|
},
|
|
60
|
-
type: 'text',
|
|
61
58
|
label: "".concat(locale.ProForm.formListActions[2]),
|
|
62
59
|
icon: _jsx(CopyOutlined, {})
|
|
63
60
|
},
|
|
@@ -69,7 +66,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
69
66
|
var move = operation.move;
|
|
70
67
|
move(index, index - 1);
|
|
71
68
|
},
|
|
72
|
-
type: 'text',
|
|
73
69
|
label: "".concat(locale.ProForm.formListActions[3]),
|
|
74
70
|
icon: _jsx(UpSquareOutlined, {})
|
|
75
71
|
},
|
|
@@ -81,7 +77,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
81
77
|
var move = operation.move;
|
|
82
78
|
move(index, index + 1);
|
|
83
79
|
},
|
|
84
|
-
type: 'text',
|
|
85
80
|
label: "".concat(locale.ProForm.formListActions[4]),
|
|
86
81
|
icon: _jsx(DownSquareOutlined, {})
|
|
87
82
|
}
|
|
@@ -105,7 +100,7 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
105
100
|
return originActions;
|
|
106
101
|
};
|
|
107
102
|
var defaultActionProps = [{
|
|
108
|
-
|
|
103
|
+
type: 'delete'
|
|
109
104
|
}];
|
|
110
105
|
var ActionButton = function ActionButton(props) {
|
|
111
106
|
var namePath = props.namePath,
|
|
@@ -123,12 +118,19 @@ var ActionButton = function ActionButton(props) {
|
|
|
123
118
|
// 默认显示一个delete
|
|
124
119
|
var actionProps = useMemo(function () {
|
|
125
120
|
var _props$actionProps;
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
// 兼容 actionType 和 type
|
|
122
|
+
var _actionProps = (_props$actionProps = props.actionProps) === null || _props$actionProps === void 0 ? void 0 : _props$actionProps.map(function (item) {
|
|
123
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
type: item.actionType
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
if (!(_actionProps === null || _actionProps === void 0 ? void 0 : _actionProps.find(function (item) {
|
|
129
|
+
return item.type === 'delete';
|
|
128
130
|
}))) {
|
|
129
|
-
return
|
|
131
|
+
return _actionProps ? [].concat(_toConsumableArray(_actionProps), defaultActionProps) : defaultActionProps;
|
|
130
132
|
}
|
|
131
|
-
return
|
|
133
|
+
return _actionProps;
|
|
132
134
|
}, [props.actionProps]);
|
|
133
135
|
var handleClick = /*#__PURE__*/function () {
|
|
134
136
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(defaultCallback, callback, index, item) {
|
|
@@ -158,7 +160,7 @@ var ActionButton = function ActionButton(props) {
|
|
|
158
160
|
});
|
|
159
161
|
return _context.abrupt("return");
|
|
160
162
|
case 7:
|
|
161
|
-
if ((item === null || item === void 0 ? void 0 : item.
|
|
163
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'add') {
|
|
162
164
|
operation.add(data, index !== undefined ? index + 1 : undefined);
|
|
163
165
|
}
|
|
164
166
|
case 8:
|
|
@@ -187,18 +189,18 @@ var ActionButton = function ActionButton(props) {
|
|
|
187
189
|
align: "start",
|
|
188
190
|
className: "pro-form-list-action",
|
|
189
191
|
children: actionProps === null || actionProps === void 0 ? void 0 : actionProps.map(function (item) {
|
|
190
|
-
if (item.show === false) return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.
|
|
192
|
+
if (item.show === false) return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
191
193
|
if (isFunction(item.show) && !item.show(form.getFieldValue(namePath), {
|
|
192
194
|
namePath: namePath,
|
|
193
195
|
index: index,
|
|
194
196
|
form: form
|
|
195
197
|
})) {
|
|
196
|
-
return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.
|
|
198
|
+
return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
197
199
|
}
|
|
198
200
|
var label = item.label,
|
|
199
201
|
onClick = item.onClick,
|
|
200
202
|
onHandle = item.onHandle,
|
|
201
|
-
|
|
203
|
+
type = item.type,
|
|
202
204
|
needConfirm = item.needConfirm,
|
|
203
205
|
confirmProps = item.confirmProps,
|
|
204
206
|
title = item.title,
|
|
@@ -206,27 +208,27 @@ var ActionButton = function ActionButton(props) {
|
|
|
206
208
|
var _needConfirm = needConfirm || confirmProps;
|
|
207
209
|
var _confirmProps = !confirmProps || confirmProps === true ? {} : confirmProps;
|
|
208
210
|
var _onClick = onClick || onHandle;
|
|
209
|
-
if (['add', 'delete', 'copy', 'moveUp', 'moveDown'].includes(
|
|
211
|
+
if (['add', 'delete', 'copy', 'moveUp', 'moveDown'].includes(type)) {
|
|
210
212
|
// 禁用状态默认隐藏内置操作按钮
|
|
211
213
|
if (disabled || isView) return _jsx(_Fragment, {});
|
|
212
|
-
var _defaultActions$
|
|
213
|
-
internalOnClick = _defaultActions$
|
|
214
|
-
defaultLabel = _defaultActions$
|
|
215
|
-
defaultRest = _objectWithoutProperties(_defaultActions$
|
|
214
|
+
var _defaultActions$type = defaultActions[type],
|
|
215
|
+
internalOnClick = _defaultActions$type.onClick,
|
|
216
|
+
defaultLabel = _defaultActions$type.label,
|
|
217
|
+
defaultRest = _objectWithoutProperties(_defaultActions$type, _excluded2);
|
|
216
218
|
// 小于min不可删除
|
|
217
|
-
if (min && min >= fields.length && ['delete'].includes(
|
|
219
|
+
if (min && min >= fields.length && ['delete'].includes(type)) {
|
|
218
220
|
return false;
|
|
219
221
|
}
|
|
220
222
|
// 大于等于max不可新增和复制
|
|
221
|
-
if (max && max <= fields.length && ['add', 'copy'].includes(
|
|
223
|
+
if (max && max <= fields.length && ['add', 'copy'].includes(type)) {
|
|
222
224
|
return false;
|
|
223
225
|
}
|
|
224
226
|
// 下标为零 不可向上移动
|
|
225
|
-
if (index === 0 && ['moveUp'].includes(
|
|
227
|
+
if (index === 0 && ['moveUp'].includes(type)) {
|
|
226
228
|
return false;
|
|
227
229
|
}
|
|
228
230
|
// 下标最大 不可向下移动
|
|
229
|
-
if (index + 1 === fields.length &&
|
|
231
|
+
if (index + 1 === fields.length && type === 'moveDown') {
|
|
230
232
|
return false;
|
|
231
233
|
}
|
|
232
234
|
return _needConfirm ? _jsx(_Popconfirm, _objectSpread(_objectSpread({
|
|
@@ -239,18 +241,20 @@ var ActionButton = function ActionButton(props) {
|
|
|
239
241
|
}
|
|
240
242
|
}, _confirmProps), {}, {
|
|
241
243
|
children: _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, defaultRest), rest), {}, {
|
|
244
|
+
type: "text",
|
|
242
245
|
onClick: function onClick(e) {
|
|
243
246
|
return e.stopPropagation();
|
|
244
247
|
},
|
|
245
248
|
children: label || defaultLabel
|
|
246
249
|
}))
|
|
247
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
250
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index)) : _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, defaultRest), rest), {}, {
|
|
251
|
+
type: "text",
|
|
248
252
|
onClick: function onClick(e) {
|
|
249
253
|
e.stopPropagation();
|
|
250
254
|
handleClick(internalOnClick, _onClick, index, item);
|
|
251
255
|
},
|
|
252
256
|
children: label || defaultLabel
|
|
253
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
257
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
254
258
|
}
|
|
255
259
|
return needConfirm ? _jsx(_Popconfirm, _objectSpread(_objectSpread({
|
|
256
260
|
title: title !== null && title !== void 0 ? title : "".concat(locale.ProForm.formListConfirmMessage),
|
|
@@ -262,13 +266,15 @@ var ActionButton = function ActionButton(props) {
|
|
|
262
266
|
}
|
|
263
267
|
}, _confirmProps), {}, {
|
|
264
268
|
children: _jsx(_Button, _objectSpread(_objectSpread({}, rest), {}, {
|
|
269
|
+
type: "text",
|
|
265
270
|
onClick: function onClick(e) {
|
|
266
271
|
return e.stopPropagation();
|
|
267
272
|
},
|
|
268
273
|
children: label
|
|
269
274
|
}))
|
|
270
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
271
|
-
key: "".concat(item === null || item === void 0 ? void 0 : item.
|
|
275
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index)) : ( /*#__PURE__*/_createElement(_Button, _objectSpread(_objectSpread({}, rest), {}, {
|
|
276
|
+
key: "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index),
|
|
277
|
+
type: "text",
|
|
272
278
|
onClick: function onClick(e) {
|
|
273
279
|
e.stopPropagation();
|
|
274
280
|
customClick(_onClick, index);
|