@zat-design/sisyphus-react 3.6.5 → 3.6.6-beta.1
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/es/ProEditTable/components/RenderField/index.js +65 -45
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProForm/components/base/InputNumber/index.js +20 -11
- package/es/ProForm/index.d.ts +3 -2
- package/es/ProForm/index.js +3 -17
- package/es/ProForm/utils/useShouldUpdate.js +9 -1
- package/es/ProForm/utils/useWatch.d.ts +7 -0
- package/es/ProForm/utils/useWatch.js +77 -0
- package/es/ProTable/utils.js +1 -1
- package/es/ProTree/components/ProTreeSelect/index.js +15 -4
- package/lib/ProEditTable/components/RenderField/index.js +65 -45
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProForm/components/base/InputNumber/index.js +20 -11
- package/lib/ProForm/index.d.ts +3 -2
- package/lib/ProForm/index.js +2 -16
- package/lib/ProForm/utils/useShouldUpdate.js +9 -1
- package/lib/ProForm/utils/useWatch.d.ts +7 -0
- package/lib/ProForm/utils/useWatch.js +87 -0
- package/lib/ProTable/utils.js +1 -1
- package/lib/ProTree/components/ProTreeSelect/index.js +15 -4
- package/package.json +2 -2
| @@ -11,7 +11,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | |
| 11 11 | 
             
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         | 
| 12 12 | 
             
            import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
         | 
| 13 13 | 
             
            import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
         | 
| 14 | 
            -
            var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
         | 
| 14 | 
            +
            var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm", "validateTrigger"];
         | 
| 15 15 | 
             
            import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
         | 
| 16 16 | 
             
            /* eslint-disable prefer-destructuring */
         | 
| 17 17 | 
             
            /* eslint-disable prefer-const */
         | 
| @@ -60,6 +60,8 @@ var RenderField = function RenderField(_ref) { | |
| 60 60 | 
             
                className = column.className,
         | 
| 61 61 | 
             
                trim = column.trim,
         | 
| 62 62 | 
             
                confirm = column.confirm,
         | 
| 63 | 
            +
                _column$validateTrigg = column.validateTrigger,
         | 
| 64 | 
            +
                validateTrigger = _column$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSumbit'] : _column$validateTrigg,
         | 
| 63 65 | 
             
                resetProps = _objectWithoutProperties(column, _excluded);
         | 
| 64 66 | 
             
              // editRender弃用使用component同ProForm
         | 
| 65 67 | 
             
              var _editRender = component || editRender;
         | 
| @@ -158,7 +160,9 @@ var RenderField = function RenderField(_ref) { | |
| 158 160 | 
             
              // 分离form item参数,防止对于参数透传(如onChange,防止重复触发)并优先级高于 _fieldProps 内部参数
         | 
| 159 161 | 
             
              var formItemChildProps = _objectSpread({}, _fieldProps);
         | 
| 160 162 | 
             
              // 允许formItem的属性放在column最外层
         | 
| 161 | 
            -
              var _formItemProps = _objectSpread(_objectSpread({}, resetProps), internalRule) | 
| 163 | 
            +
              var _formItemProps = _objectSpread(_objectSpread(_objectSpread({}, resetProps), internalRule), {}, {
         | 
| 164 | 
            +
                validateTrigger: validateTrigger
         | 
| 165 | 
            +
              });
         | 
| 162 166 | 
             
              if (['Switch', 'SwitchCheckbox'].includes(type)) {
         | 
| 163 167 | 
             
                _formItemProps.valuePropName = 'checked';
         | 
| 164 168 | 
             
                valueType = 'switch';
         | 
| @@ -318,6 +322,12 @@ var RenderField = function RenderField(_ref) { | |
| 318 322 | 
             
                return _regeneratorRuntime().wrap(function _callee$(_context) {
         | 
| 319 323 | 
             
                  while (1) switch (_context.prev = _context.next) {
         | 
| 320 324 | 
             
                    case 0:
         | 
| 325 | 
            +
                      if (!(!onFieldChange && !onChange)) {
         | 
| 326 | 
            +
                        _context.next = 2;
         | 
| 327 | 
            +
                        break;
         | 
| 328 | 
            +
                      }
         | 
| 329 | 
            +
                      return _context.abrupt("return", null);
         | 
| 330 | 
            +
                    case 2:
         | 
| 321 331 | 
             
                      for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
         | 
| 322 332 | 
             
                        args[_key2] = _args2[_key2];
         | 
| 323 333 | 
             
                      }
         | 
| @@ -326,58 +336,60 @@ var RenderField = function RenderField(_ref) { | |
| 326 336 | 
             
                      row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
         | 
| 327 337 | 
             
                      orgRow = cloneDeep(row);
         | 
| 328 338 | 
             
                      if (!onFieldChange) {
         | 
| 329 | 
            -
                        _context.next =  | 
| 339 | 
            +
                        _context.next = 20;
         | 
| 330 340 | 
             
                        break;
         | 
| 331 341 | 
             
                      }
         | 
| 332 342 | 
             
                      _args = formatArgs(args);
         | 
| 333 343 | 
             
                      _args[1] = row;
         | 
| 334 344 | 
             
                      _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
         | 
| 335 345 | 
             
                      if (!_context.t0) {
         | 
| 336 | 
            -
                        _context.next =  | 
| 346 | 
            +
                        _context.next = 14;
         | 
| 337 347 | 
             
                        break;
         | 
| 338 348 | 
             
                      }
         | 
| 339 | 
            -
                      _context.next =  | 
| 349 | 
            +
                      _context.next = 14;
         | 
| 340 350 | 
             
                      return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
         | 
| 341 | 
            -
                    case  | 
| 351 | 
            +
                    case 14:
         | 
| 342 352 | 
             
                      _context.t1 = onFieldChange;
         | 
| 343 353 | 
             
                      if (!_context.t1) {
         | 
| 344 | 
            -
                        _context.next =  | 
| 354 | 
            +
                        _context.next = 18;
         | 
| 345 355 | 
             
                        break;
         | 
| 346 356 | 
             
                      }
         | 
| 347 | 
            -
                      _context.next =  | 
| 357 | 
            +
                      _context.next = 18;
         | 
| 348 358 | 
             
                      return onFieldChange.apply(void 0, _toConsumableArray(_args));
         | 
| 349 | 
            -
                    case 16:
         | 
| 350 | 
            -
                      _context.next = 27;
         | 
| 351 | 
            -
                      break;
         | 
| 352 359 | 
             
                    case 18:
         | 
| 360 | 
            +
                      _context.next = 29;
         | 
| 361 | 
            +
                      break;
         | 
| 362 | 
            +
                    case 20:
         | 
| 353 363 | 
             
                      _args = _args.concat([row, index, form]);
         | 
| 354 364 | 
             
                      _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
         | 
| 355 365 | 
             
                      if (!_context.t2) {
         | 
| 356 | 
            -
                        _context.next =  | 
| 366 | 
            +
                        _context.next = 25;
         | 
| 357 367 | 
             
                        break;
         | 
| 358 368 | 
             
                      }
         | 
| 359 | 
            -
                      _context.next =  | 
| 369 | 
            +
                      _context.next = 25;
         | 
| 360 370 | 
             
                      return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
         | 
| 361 | 
            -
                    case  | 
| 371 | 
            +
                    case 25:
         | 
| 362 372 | 
             
                      _context.t3 = onChange;
         | 
| 363 373 | 
             
                      if (!_context.t3) {
         | 
| 364 | 
            -
                        _context.next =  | 
| 374 | 
            +
                        _context.next = 29;
         | 
| 365 375 | 
             
                        break;
         | 
| 366 376 | 
             
                      }
         | 
| 367 | 
            -
                      _context.next =  | 
| 377 | 
            +
                      _context.next = 29;
         | 
| 368 378 | 
             
                      return onChange.apply(void 0, _toConsumableArray(_args));
         | 
| 369 | 
            -
                    case  | 
| 379 | 
            +
                    case 29:
         | 
| 370 380 | 
             
                      // 判断属性是否变动
         | 
| 371 381 | 
             
                      form.setFieldValue(rowPath, row);
         | 
| 372 | 
            -
                      if ( | 
| 373 | 
            -
                         | 
| 374 | 
            -
             | 
| 375 | 
            -
                           | 
| 376 | 
            -
             | 
| 377 | 
            -
             | 
| 378 | 
            -
                           | 
| 379 | 
            -
                             | 
| 380 | 
            -
             | 
| 382 | 
            +
                      if (validateTrigger && validateTrigger.includes('onChange')) {
         | 
| 383 | 
            +
                        if (!isEqual(orgRow, row)) {
         | 
| 384 | 
            +
                          diff = difference(row, orgRow) || {};
         | 
| 385 | 
            +
                          validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
         | 
| 386 | 
            +
                            return [].concat(_toConsumableArray(rowPath), [key]);
         | 
| 387 | 
            +
                          });
         | 
| 388 | 
            +
                          if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
         | 
| 389 | 
            +
                            setTimeout(function () {
         | 
| 390 | 
            +
                              form.validateFields(validateFieldKeys);
         | 
| 391 | 
            +
                            }, 100);
         | 
| 392 | 
            +
                          }
         | 
| 381 393 | 
             
                        }
         | 
| 382 394 | 
             
                      }
         | 
| 383 395 | 
             
                      setState({
         | 
| @@ -385,7 +397,7 @@ var RenderField = function RenderField(_ref) { | |
| 385 397 | 
             
                          d: Date.now()
         | 
| 386 398 | 
             
                        }
         | 
| 387 399 | 
             
                      });
         | 
| 388 | 
            -
                    case  | 
| 400 | 
            +
                    case 32:
         | 
| 389 401 | 
             
                    case "end":
         | 
| 390 402 | 
             
                      return _context.stop();
         | 
| 391 403 | 
             
                  }
         | 
| @@ -409,6 +421,12 @@ var RenderField = function RenderField(_ref) { | |
| 409 421 | 
             
                  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
         | 
| 410 422 | 
             
                    while (1) switch (_context2.prev = _context2.next) {
         | 
| 411 423 | 
             
                      case 0:
         | 
| 424 | 
            +
                        if (onBlur) {
         | 
| 425 | 
            +
                          _context2.next = 2;
         | 
| 426 | 
            +
                          break;
         | 
| 427 | 
            +
                        }
         | 
| 428 | 
            +
                        return _context2.abrupt("return", null);
         | 
| 429 | 
            +
                      case 2:
         | 
| 412 430 | 
             
                        for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
         | 
| 413 431 | 
             
                          args[_key3] = _args3[_key3];
         | 
| 414 432 | 
             
                        }
         | 
| @@ -419,49 +437,51 @@ var RenderField = function RenderField(_ref) { | |
| 419 437 | 
             
                        _args[1] = row;
         | 
| 420 438 | 
             
                        _context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
         | 
| 421 439 | 
             
                        if (!_context2.t0) {
         | 
| 422 | 
            -
                          _context2.next =  | 
| 440 | 
            +
                          _context2.next = 12;
         | 
| 423 441 | 
             
                          break;
         | 
| 424 442 | 
             
                        }
         | 
| 425 | 
            -
                        _context2.next =  | 
| 443 | 
            +
                        _context2.next = 12;
         | 
| 426 444 | 
             
                        return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, _toConsumableArray(_args));
         | 
| 427 | 
            -
                      case  | 
| 445 | 
            +
                      case 12:
         | 
| 428 446 | 
             
                        _context2.t1 = onBlur;
         | 
| 429 447 | 
             
                        if (!_context2.t1) {
         | 
| 430 | 
            -
                          _context2.next =  | 
| 448 | 
            +
                          _context2.next = 16;
         | 
| 431 449 | 
             
                          break;
         | 
| 432 450 | 
             
                        }
         | 
| 433 | 
            -
                        _context2.next =  | 
| 451 | 
            +
                        _context2.next = 16;
         | 
| 434 452 | 
             
                        return onBlur.apply(void 0, _toConsumableArray(_args));
         | 
| 435 | 
            -
                      case  | 
| 453 | 
            +
                      case 16:
         | 
| 436 454 | 
             
                        // 判断属性是否变动
         | 
| 437 455 | 
             
                        form.setFieldValue(rowPath, row);
         | 
| 438 | 
            -
                        if ( | 
| 439 | 
            -
                           | 
| 440 | 
            -
             | 
| 441 | 
            -
                             | 
| 442 | 
            -
             | 
| 443 | 
            -
             | 
| 444 | 
            -
                             | 
| 456 | 
            +
                        if (validateTrigger && validateTrigger.includes('onBlur')) {
         | 
| 457 | 
            +
                          if (!isEqual(orgRow, row)) {
         | 
| 458 | 
            +
                            diff = difference(row, orgRow) || {};
         | 
| 459 | 
            +
                            validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
         | 
| 460 | 
            +
                              return [].concat(_toConsumableArray(rowPath), [key]);
         | 
| 461 | 
            +
                            });
         | 
| 462 | 
            +
                            if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
         | 
| 463 | 
            +
                              debounceValidate(validateFieldKeys);
         | 
| 464 | 
            +
                            }
         | 
| 445 465 | 
             
                          }
         | 
| 446 466 | 
             
                        }
         | 
| 447 467 | 
             
                        if (!isCell) {
         | 
| 448 | 
            -
                          _context2.next =  | 
| 468 | 
            +
                          _context2.next = 22;
         | 
| 449 469 | 
             
                          break;
         | 
| 450 470 | 
             
                        }
         | 
| 451 | 
            -
                        _context2.next =  | 
| 471 | 
            +
                        _context2.next = 21;
         | 
| 452 472 | 
             
                        return form.validateFields([cellName]);
         | 
| 453 | 
            -
                      case  | 
| 473 | 
            +
                      case 21:
         | 
| 454 474 | 
             
                        setState({
         | 
| 455 475 | 
             
                          cellNamePath: []
         | 
| 456 476 | 
             
                        });
         | 
| 457 | 
            -
                      case  | 
| 477 | 
            +
                      case 22:
         | 
| 458 478 | 
             
                        // 单行编辑时需要 强制更新视图
         | 
| 459 479 | 
             
                        setState({
         | 
| 460 480 | 
             
                          forceUpdate: {
         | 
| 461 481 | 
             
                            d: Date.now()
         | 
| 462 482 | 
             
                          }
         | 
| 463 483 | 
             
                        });
         | 
| 464 | 
            -
                      case  | 
| 484 | 
            +
                      case 23:
         | 
| 465 485 | 
             
                      case "end":
         | 
| 466 486 | 
             
                        return _context2.stop();
         | 
| 467 487 | 
             
                    }
         | 
| @@ -100,6 +100,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro | |
| 100 100 | 
             
                hiddenNames?: NamePath[] | NamePath[][];
         | 
| 101 101 | 
             
                rules?: ProRule[] | RulesFn<T>;
         | 
| 102 102 | 
             
                confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
         | 
| 103 | 
            +
                validateTrigger?: string | string[];
         | 
| 103 104 | 
             
                [key: string]: any;
         | 
| 104 105 | 
             
            }
         | 
| 105 106 | 
             
            export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
         | 
| @@ -35,6 +35,7 @@ var limitNumber = function limitNumber(num, _ref) { | |
| 35 35 | 
             
              return num;
         | 
| 36 36 | 
             
            };
         | 
| 37 37 | 
             
            var InputNumber = function InputNumber(props) {
         | 
| 38 | 
            +
              var _props$precision4;
         | 
| 38 39 | 
             
              var placeholder = props.placeholder,
         | 
| 39 40 | 
             
                className = props.className,
         | 
| 40 41 | 
             
                otherProps = props.otherProps,
         | 
| @@ -55,28 +56,33 @@ var InputNumber = function InputNumber(props) { | |
| 55 56 | 
             
              var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
         | 
| 56 57 | 
             
              var valueProps = {};
         | 
| 57 58 | 
             
              var formatter = function formatter(value) {
         | 
| 59 | 
            +
                var _props$precision;
         | 
| 58 60 | 
             
                if (value === '') return '';
         | 
| 59 61 | 
             
                var num = Number(value);
         | 
| 60 62 | 
             
                if (Number.isNaN(num)) {
         | 
| 61 63 | 
             
                  return value;
         | 
| 62 64 | 
             
                }
         | 
| 63 65 | 
             
                var val = num.toLocaleString('en-US', {
         | 
| 64 | 
            -
                  maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision)  | 
| 66 | 
            +
                  maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
         | 
| 65 67 | 
             
                });
         | 
| 66 68 | 
             
                if (!activateRef.current) {
         | 
| 69 | 
            +
                  var _props$precision2;
         | 
| 67 70 | 
             
                  var _val$split = val.split('.'),
         | 
| 68 71 | 
             
                    _val$split2 = _slicedToArray(_val$split, 2),
         | 
| 69 72 | 
             
                    int = _val$split2[0],
         | 
| 70 73 | 
             
                    _val$split2$ = _val$split2[1],
         | 
| 71 74 | 
             
                    float = _val$split2$ === void 0 ? '' : _val$split2$;
         | 
| 72 | 
            -
                   | 
| 75 | 
            +
                  if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
         | 
| 76 | 
            +
                    return int;
         | 
| 77 | 
            +
                  }
         | 
| 78 | 
            +
                  return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
         | 
| 73 79 | 
             
                }
         | 
| 74 80 | 
             
                return val;
         | 
| 75 81 | 
             
              };
         | 
| 76 82 | 
             
              var _parser = function parser(value, precision) {
         | 
| 77 | 
            -
                var num = Number(value.replace(/[\s,]+/g, ''));
         | 
| 78 83 | 
             
                if (value === '') return value;
         | 
| 79 | 
            -
                 | 
| 84 | 
            +
                var num = Number(value.replace(/[\s,]+/g, ''));
         | 
| 85 | 
            +
                return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
         | 
| 80 86 | 
             
              };
         | 
| 81 87 | 
             
              if (valueType) {
         | 
| 82 88 | 
             
                switch (valueType) {
         | 
| @@ -88,8 +94,10 @@ var InputNumber = function InputNumber(props) { | |
| 88 94 | 
             
                    valueProps = {
         | 
| 89 95 | 
             
                      formatter: formatter,
         | 
| 90 96 | 
             
                      parser: function parser(val) {
         | 
| 91 | 
            -
                         | 
| 92 | 
            -
             | 
| 97 | 
            +
                        var _props$precision3;
         | 
| 98 | 
            +
                        return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
         | 
| 99 | 
            +
                      },
         | 
| 100 | 
            +
                      precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
         | 
| 93 101 | 
             
                    };
         | 
| 94 102 | 
             
                    break;
         | 
| 95 103 | 
             
                  // 百分比
         | 
| @@ -177,7 +185,7 @@ var InputNumber = function InputNumber(props) { | |
| 177 185 | 
             
                      var originValue = calc(Number(value), '/', 100);
         | 
| 178 186 | 
             
                      // 获取真实数据的小数位数
         | 
| 179 187 | 
             
                      var decimalDigits = getDecimalDigits(originValue);
         | 
| 180 | 
            -
                      if (decimalDigits > (precision  | 
| 188 | 
            +
                      if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
         | 
| 181 189 | 
             
                        return _jsx(Container, {
         | 
| 182 190 | 
             
                          viewEmpty: viewEmpty,
         | 
| 183 191 | 
             
                          children: value
         | 
| @@ -195,7 +203,7 @@ var InputNumber = function InputNumber(props) { | |
| 195 203 | 
             
                      var _originValue = calc(Number(value), '/', 1000);
         | 
| 196 204 | 
             
                      // 获取真实数据的小数位数
         | 
| 197 205 | 
             
                      var _decimalDigits = getDecimalDigits(_originValue);
         | 
| 198 | 
            -
                      if (_decimalDigits > (precision  | 
| 206 | 
            +
                      if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
         | 
| 199 207 | 
             
                        return _jsx(Container, {
         | 
| 200 208 | 
             
                          viewEmpty: viewEmpty,
         | 
| 201 209 | 
             
                          children: value
         | 
| @@ -212,7 +220,7 @@ var InputNumber = function InputNumber(props) { | |
| 212 220 | 
             
                  case 'thousandth':
         | 
| 213 221 | 
             
                    return _jsx(Container, {
         | 
| 214 222 | 
             
                      viewEmpty: viewEmpty,
         | 
| 215 | 
            -
                      children: tools.formatAmount(value, precision  | 
| 223 | 
            +
                      children: tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
         | 
| 216 224 | 
             
                    });
         | 
| 217 225 | 
             
                  // CNY千分位
         | 
| 218 226 | 
             
                  case 'thousandthCNY':
         | 
| @@ -232,7 +240,7 @@ var InputNumber = function InputNumber(props) { | |
| 232 240 | 
             
              }
         | 
| 233 241 | 
             
              // 失去焦点时处理数字,
         | 
| 234 242 | 
             
              var handleBlur = function handleBlur(e) {
         | 
| 235 | 
            -
                var _e$target, _e$target2;
         | 
| 243 | 
            +
                var _e$target, _props$precision5, _valueProps3, _e$target2;
         | 
| 236 244 | 
             
                activateRef.current = false;
         | 
| 237 245 | 
             
                var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
         | 
| 238 246 | 
             
                if (_max !== undefined && value > _max) {
         | 
| @@ -241,7 +249,8 @@ var InputNumber = function InputNumber(props) { | |
| 241 249 | 
             
                if (_min !== undefined && value < _min) {
         | 
| 242 250 | 
             
                  value = _min;
         | 
| 243 251 | 
             
                }
         | 
| 244 | 
            -
                value = _parser(String(value), props.precision);
         | 
| 252 | 
            +
                value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
         | 
| 253 | 
            +
                rest === null || rest === void 0 ? void 0 : rest.onChange(value);
         | 
| 245 254 | 
             
                var limit = {
         | 
| 246 255 | 
             
                  min: Number(_min),
         | 
| 247 256 | 
             
                  max: Number(_max)
         | 
    
        package/es/ProForm/index.d.ts
    CHANGED
    
    | @@ -1,11 +1,12 @@ | |
| 1 | 
            -
            import {  | 
| 1 | 
            +
            import { FormInstance } from 'antd';
         | 
| 2 2 | 
             
            import React, { ForwardRefRenderFunction } from 'react';
         | 
| 3 3 | 
             
            import { FormProviderProps } from 'antd/es/form/context';
         | 
| 4 4 | 
             
            import { ProFormProps } from './propsType';
         | 
| 5 5 | 
             
            import { useForm } from './utils/useForm';
         | 
| 6 | 
            +
            import useWatch from './utils/useWatch';
         | 
| 6 7 | 
             
            interface IProForm<T = any> extends ForwardRefRenderFunction<FormInstance<T>, ProFormProps<T>> {
         | 
| 7 8 | 
             
                useForm: typeof useForm;
         | 
| 8 | 
            -
                useWatch: typeof  | 
| 9 | 
            +
                useWatch: typeof useWatch;
         | 
| 9 10 | 
             
                [key: string]: any;
         | 
| 10 11 | 
             
            }
         | 
| 11 12 | 
             
            declare const ProFormForward: IProForm;
         | 
    
        package/es/ProForm/index.js
    CHANGED
    
    | @@ -16,7 +16,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | |
| 16 16 | 
             
            import { DoubleLeftOutlined } from '@ant-design/icons';
         | 
| 17 17 | 
             
            import classnames from 'classnames';
         | 
| 18 18 | 
             
            import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
         | 
| 19 | 
            -
            import { isObject,  | 
| 19 | 
            +
            import { isObject, merge } from 'lodash';
         | 
| 20 20 | 
             
            import { FormFooter, InputRange, ProAddress, ProCascader, ProCertNo, ProCertValidity, ProCombination, ProModalSelect, ProNumberRange, ProRangeBox, ProTimeLimit, transferAddressInfoToRegion, ProUpload, ProTreeModal, ProTree, EnumSelect } from './components';
         | 
| 21 21 | 
             
            import RenderFields from './components/render/RenderFields';
         | 
| 22 22 | 
             
            import { useProConfig, useContextForms } from '../ProConfigProvider';
         | 
| @@ -24,6 +24,7 @@ import { getLayout, splitNameStr, useControlled, initialValuesToNames, filterInt | |
| 24 24 | 
             
            import { useForm } from './utils/useForm';
         | 
| 25 25 | 
             
            import { useFieldProps } from './utils/useFieldProps';
         | 
| 26 26 | 
             
            import locale from '../locale';
         | 
| 27 | 
            +
            import useWatch from './utils/useWatch';
         | 
| 27 28 | 
             
            var ProForm = function ProForm(props, ref) {
         | 
| 28 29 | 
             
              var _forms$formKey, _localStorage, _ref;
         | 
| 29 30 | 
             
              var _props$mode = props.mode,
         | 
| @@ -273,22 +274,7 @@ var ProForm = function ProForm(props, ref) { | |
| 273 274 | 
             
            // @ts-ignore
         | 
| 274 275 | 
             
            var ProFormForward = /*#__PURE__*/forwardRef(ProForm);
         | 
| 275 276 | 
             
            ProFormForward.useForm = useForm;
         | 
| 276 | 
            -
            ProFormForward.useWatch =  | 
| 277 | 
            -
              if (isString(watchValue)) {
         | 
| 278 | 
            -
                var watchValues = [watchValue];
         | 
| 279 | 
            -
                watchValues.forEach(function (item) {
         | 
| 280 | 
            -
                  _Form.useWatch(item, form);
         | 
| 281 | 
            -
                });
         | 
| 282 | 
            -
                return form.getFieldsValue(watchValues);
         | 
| 283 | 
            -
              }
         | 
| 284 | 
            -
              if (watchValue.length) {
         | 
| 285 | 
            -
                watchValue.forEach(function (item) {
         | 
| 286 | 
            -
                  _Form.useWatch(item, form);
         | 
| 287 | 
            -
                });
         | 
| 288 | 
            -
                return form.getFieldsValue(watchValue);
         | 
| 289 | 
            -
              }
         | 
| 290 | 
            -
              return _Form.useWatch([], form);
         | 
| 291 | 
            -
            };
         | 
| 277 | 
            +
            ProFormForward.useWatch = useWatch;
         | 
| 292 278 | 
             
            export var ProFormProvider = function ProFormProvider(props) {
         | 
| 293 279 | 
             
              var onFormChange = props.onFormChange,
         | 
| 294 280 | 
             
                onFormFinish = props.onFormFinish,
         | 
| @@ -22,6 +22,7 @@ var useShouldUpdate = function useShouldUpdate(props) { | |
| 22 22 | 
             
                names = formItemProps.names,
         | 
| 23 23 | 
             
                dependencies = formItemProps.dependencies;
         | 
| 24 24 | 
             
              var timerRef = useRef();
         | 
| 25 | 
            +
              var needClear = useRef(); // 是否需要执行清值操作
         | 
| 25 26 | 
             
              var showRef = useRef();
         | 
| 26 27 | 
             
              var disabledRef = useRef();
         | 
| 27 28 | 
             
              var requiredRef = useRef();
         | 
| @@ -158,17 +159,24 @@ var useShouldUpdate = function useShouldUpdate(props) { | |
| 158 159 | 
             
                  }) : fieldProps;
         | 
| 159 160 | 
             
                  // 清值防抖  多次刷新时以最后一次为准
         | 
| 160 161 | 
             
                  if (clearNotShow !== false && (name || names)) {
         | 
| 162 | 
            +
                    // 当show为其他变为false的时候记录一次需要清值
         | 
| 163 | 
            +
                    if (_show !== showRef.current && _show === false) {
         | 
| 164 | 
            +
                      needClear.current = true;
         | 
| 165 | 
            +
                    }
         | 
| 161 166 | 
             
                    if (_show === false) {
         | 
| 162 167 | 
             
                      clearTimeout(timerRef.current);
         | 
| 163 168 | 
             
                      timerRef.current = setTimeout(function () {
         | 
| 169 | 
            +
                        if (needClear.current !== true) return;
         | 
| 164 170 | 
             
                        if (Array.isArray(names)) {
         | 
| 165 171 | 
             
                          form.resetFields(names);
         | 
| 166 172 | 
             
                        } else {
         | 
| 167 173 | 
             
                          var clearName = formItemProps.namePath ? formItemProps.namePath.slice(0, -1).concat(formItemProps.name) : formItemProps.name;
         | 
| 168 174 | 
             
                          form.resetFields([clearName]);
         | 
| 169 175 | 
             
                        }
         | 
| 170 | 
            -
             | 
| 176 | 
            +
                        needClear.current = false;
         | 
| 177 | 
            +
                      }, 300);
         | 
| 171 178 | 
             
                    } else {
         | 
| 179 | 
            +
                      needClear.current = false;
         | 
| 172 180 | 
             
                      clearTimeout(timerRef.current);
         | 
| 173 181 | 
             
                    }
         | 
| 174 182 | 
             
                  }
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            import { InternalNamePath, FormInstance, NamePath } from 'rc-field-form/es/interface';
         | 
| 2 | 
            +
            export declare function toArray<T>(value?: T | T[] | null): T[];
         | 
| 3 | 
            +
            export declare function getNamePath(path: NamePath | null): InternalNamePath;
         | 
| 4 | 
            +
            export declare function stringify(value: any): string | number;
         | 
| 5 | 
            +
            declare function useWatch(dependencies: string, form?: FormInstance, wait?: number): any;
         | 
| 6 | 
            +
            declare function useWatch(dependencies: NamePath[], form?: FormInstance, wait?: number): any[];
         | 
| 7 | 
            +
            export default useWatch;
         | 
| @@ -0,0 +1,77 @@ | |
| 1 | 
            +
            import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
         | 
| 2 | 
            +
            import { debounce } from 'lodash';
         | 
| 3 | 
            +
            import { HOOK_MARK } from 'rc-field-form/es/FieldContext';
         | 
| 4 | 
            +
            import warning from 'rc-util/lib/warning';
         | 
| 5 | 
            +
            import { useState, useEffect, useRef, useMemo } from 'react';
         | 
| 6 | 
            +
            export function toArray(value) {
         | 
| 7 | 
            +
              if (value === undefined || value === null) {
         | 
| 8 | 
            +
                return [];
         | 
| 9 | 
            +
              }
         | 
| 10 | 
            +
              return Array.isArray(value) ? value : [value];
         | 
| 11 | 
            +
            }
         | 
| 12 | 
            +
            export function getNamePath(path) {
         | 
| 13 | 
            +
              return toArray(path);
         | 
| 14 | 
            +
            }
         | 
| 15 | 
            +
            export function stringify(value) {
         | 
| 16 | 
            +
              try {
         | 
| 17 | 
            +
                return JSON.stringify(value);
         | 
| 18 | 
            +
              } catch (err) {
         | 
| 19 | 
            +
                return Math.random();
         | 
| 20 | 
            +
              }
         | 
| 21 | 
            +
            }
         | 
| 22 | 
            +
            // 创建之后namepath就不可变
         | 
| 23 | 
            +
            var useWatchWarning = process.env.NODE_ENV !== 'production' ? function (namePath) {
         | 
| 24 | 
            +
              var fullyStr = JSON.stringify(namePath);
         | 
| 25 | 
            +
              var nameStrRef = useRef(fullyStr);
         | 
| 26 | 
            +
              warning(nameStrRef.current === fullyStr, '`useWatch` is not support dynamic `namePath`. Please provide static instead.');
         | 
| 27 | 
            +
            } : function () {};
         | 
| 28 | 
            +
            function useWatch(dependencies, form, wait) {
         | 
| 29 | 
            +
              var isSingle = typeof dependencies === 'string';
         | 
| 30 | 
            +
              var _useState = useState({}),
         | 
| 31 | 
            +
                _useState2 = _slicedToArray(_useState, 2),
         | 
| 32 | 
            +
                value = _useState2[0],
         | 
| 33 | 
            +
                setValue = _useState2[1];
         | 
| 34 | 
            +
              var valueStr = useMemo(function () {
         | 
| 35 | 
            +
                return stringify(value);
         | 
| 36 | 
            +
              }, [value]);
         | 
| 37 | 
            +
              var valueStrRef = useRef(valueStr);
         | 
| 38 | 
            +
              valueStrRef.current = valueStr;
         | 
| 39 | 
            +
              var formInstance = form;
         | 
| 40 | 
            +
              var isValidForm = formInstance && formInstance._init;
         | 
| 41 | 
            +
              var _dependencies = isSingle ? [dependencies] : dependencies;
         | 
| 42 | 
            +
              var namePaths = _dependencies === null || _dependencies === void 0 ? void 0 : _dependencies.map(function (item) {
         | 
| 43 | 
            +
                return getNamePath(item);
         | 
| 44 | 
            +
              });
         | 
| 45 | 
            +
              var namePathsRef = useRef(namePaths);
         | 
| 46 | 
            +
              namePathsRef.current = namePaths;
         | 
| 47 | 
            +
              useWatchWarning(namePaths);
         | 
| 48 | 
            +
              useEffect(function () {
         | 
| 49 | 
            +
                if (!isValidForm) return;
         | 
| 50 | 
            +
                var getFieldsValue = formInstance.getFieldsValue,
         | 
| 51 | 
            +
                  getInternalHooks = formInstance.getInternalHooks;
         | 
| 52 | 
            +
                var _getInternalHooks = getInternalHooks(HOOK_MARK),
         | 
| 53 | 
            +
                  registerWatch = _getInternalHooks.registerWatch;
         | 
| 54 | 
            +
                var callback = function callback() {
         | 
| 55 | 
            +
                  var newValue = getFieldsValue(_dependencies);
         | 
| 56 | 
            +
                  var nextValueStr = stringify(newValue);
         | 
| 57 | 
            +
                  // Compare stringify in case it's nest object
         | 
| 58 | 
            +
                  if (valueStrRef.current !== nextValueStr) {
         | 
| 59 | 
            +
                    valueStrRef.current = nextValueStr;
         | 
| 60 | 
            +
                    setValue(getFieldsValue(_dependencies));
         | 
| 61 | 
            +
                  }
         | 
| 62 | 
            +
                };
         | 
| 63 | 
            +
                // 增加防抖
         | 
| 64 | 
            +
                if (wait) {
         | 
| 65 | 
            +
                  callback = debounce(callback, wait);
         | 
| 66 | 
            +
                }
         | 
| 67 | 
            +
                var cancelRegister = registerWatch(callback);
         | 
| 68 | 
            +
                var initialValue = getFieldsValue(_dependencies);
         | 
| 69 | 
            +
                setValue(initialValue);
         | 
| 70 | 
            +
                return cancelRegister;
         | 
| 71 | 
            +
              },
         | 
| 72 | 
            +
              // We do not need re-register since namePath content is the same
         | 
| 73 | 
            +
              // eslint-disable-next-line react-hooks/exhaustive-deps
         | 
| 74 | 
            +
              [isValidForm]);
         | 
| 75 | 
            +
              return value;
         | 
| 76 | 
            +
            }
         | 
| 77 | 
            +
            export default useWatch;
         | 
    
        package/es/ProTable/utils.js
    CHANGED
    
    | @@ -105,7 +105,7 @@ export var formatColumn = function formatColumn(column, originalObj, dataSourceO | |
| 105 105 | 
             
              if (['percentage', 'permillage'].includes(valueType)) {
         | 
| 106 106 | 
             
                column.render = function (value, record, index) {
         | 
| 107 107 | 
             
                  var multiple = valueType === 'percentage' ? 100 : 1000;
         | 
| 108 | 
            -
                  var realValue = tools.calc(Number(value), '*', multiple);
         | 
| 108 | 
            +
                  var realValue = tools.calc(Number(value !== null && value !== void 0 ? value : 0), '*', multiple);
         | 
| 109 109 | 
             
                  var renderValue = getDecimalDigits(value) > valueTypePrecision ? realValue : realValue.toFixed(valueTypePrecision);
         | 
| 110 110 | 
             
                  var originalValue = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
         | 
| 111 111 | 
             
                  var originalRealValue = tools.calc(Number(originalValue || null), '*', multiple);
         | 
| @@ -355,9 +355,9 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) { | |
| 355 355 | 
             
                    }
         | 
| 356 356 | 
             
                    // 迭代完子节点向上回溯,如果有匹配到得子节点,那么加入当前节点得孩子对象上,否则加入得是空数组
         | 
| 357 357 | 
             
                    item.children = currentNodeChild;
         | 
| 358 | 
            -
                    // let tag = false;
         | 
| 359 358 | 
             
                    // 判断节点title是否包含关键字 如果有,那么直接进行下一循环
         | 
| 360 | 
            -
                     | 
| 359 | 
            +
                    // @ts-ignore
         | 
| 360 | 
            +
                    if (item[label].indexOf(keyWord) > -1 && (selectProps === null || selectProps === void 0 ? void 0 : selectProps.mode) !== 'treeSelect') {
         | 
| 361 361 | 
             
                      var regExp = new RegExp(keyWord);
         | 
| 362 362 | 
             
                      item[label] = item[label].replace(regExp, "<span class=\"highlight-search-text\">".concat(keyWord, "</span>"));
         | 
| 363 363 | 
             
                    }
         | 
| @@ -419,11 +419,22 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) { | |
| 419 419 | 
             
              }
         | 
| 420 420 | 
             
              var handleChange = function handleChange(newVal, label, extra) {
         | 
| 421 421 | 
             
                // newVal回来得一定是label、value
         | 
| 422 | 
            +
                var _selectList = selectList.map(function (item) {
         | 
| 423 | 
            +
                  var label = item.label;
         | 
| 424 | 
            +
                  var _label = label;
         | 
| 425 | 
            +
                  if (label) {
         | 
| 426 | 
            +
                    var regex = /<span class="highlight-search-text">(.*?)<\/span>/g;
         | 
| 427 | 
            +
                    _label = item[label] = label === null || label === void 0 ? void 0 : label.replace(regex, '$1');
         | 
| 428 | 
            +
                  }
         | 
| 429 | 
            +
                  return _objectSpread(_objectSpread({}, item), {}, {
         | 
| 430 | 
            +
                    label: _label
         | 
| 431 | 
            +
                  });
         | 
| 432 | 
            +
                });
         | 
| 422 433 | 
             
                var result = newVal;
         | 
| 423 434 | 
             
                if (props === null || props === void 0 ? void 0 : props.labelInValue) {
         | 
| 424 | 
            -
                  result = getLabelByValue( | 
| 435 | 
            +
                  result = getLabelByValue(_selectList, newVal);
         | 
| 425 436 | 
             
                }
         | 
| 426 | 
            -
                var options = findTreeNode( | 
| 437 | 
            +
                var options = findTreeNode(_selectList, extra === null || extra === void 0 ? void 0 : extra.triggerValue);
         | 
| 427 438 | 
             
                onChange && onChange(result, options, extra);
         | 
| 428 439 | 
             
                // 重置搜索
         | 
| 429 440 | 
             
                showSearch && searchTreeEvent('');
         | 
| @@ -30,7 +30,7 @@ var _useListChanged3 = require("../../../ProForm/utils/useListChanged"); | |
| 30 30 | 
             
            var _useRules = _interopRequireDefault(require("../../../ProForm/utils/useRules"));
         | 
| 31 31 | 
             
            var _utils = require("../../../ProForm/utils");
         | 
| 32 32 | 
             
            var _ConfirmWrapper = _interopRequireDefault(require("../../../ProForm/components/render/ConfirmWrapper"));
         | 
| 33 | 
            -
            var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
         | 
| 33 | 
            +
            var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm", "validateTrigger"];
         | 
| 34 34 | 
             
            /* eslint-disable prefer-destructuring */
         | 
| 35 35 | 
             
            /* eslint-disable prefer-const */
         | 
| 36 36 | 
             
            var RenderField = function RenderField(_ref) {
         | 
| @@ -63,6 +63,8 @@ var RenderField = function RenderField(_ref) { | |
| 63 63 | 
             
                className = column.className,
         | 
| 64 64 | 
             
                trim = column.trim,
         | 
| 65 65 | 
             
                confirm = column.confirm,
         | 
| 66 | 
            +
                _column$validateTrigg = column.validateTrigger,
         | 
| 67 | 
            +
                validateTrigger = _column$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSumbit'] : _column$validateTrigg,
         | 
| 66 68 | 
             
                resetProps = (0, _objectWithoutProperties2.default)(column, _excluded);
         | 
| 67 69 | 
             
              // editRender弃用使用component同ProForm
         | 
| 68 70 | 
             
              var _editRender = component || editRender;
         | 
| @@ -161,7 +163,9 @@ var RenderField = function RenderField(_ref) { | |
| 161 163 | 
             
              // 分离form item参数,防止对于参数透传(如onChange,防止重复触发)并优先级高于 _fieldProps 内部参数
         | 
| 162 164 | 
             
              var formItemChildProps = (0, _objectSpread2.default)({}, _fieldProps);
         | 
| 163 165 | 
             
              // 允许formItem的属性放在column最外层
         | 
| 164 | 
            -
              var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), internalRule) | 
| 166 | 
            +
              var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), internalRule), {}, {
         | 
| 167 | 
            +
                validateTrigger: validateTrigger
         | 
| 168 | 
            +
              });
         | 
| 165 169 | 
             
              if (['Switch', 'SwitchCheckbox'].includes(type)) {
         | 
| 166 170 | 
             
                _formItemProps.valuePropName = 'checked';
         | 
| 167 171 | 
             
                valueType = 'switch';
         | 
| @@ -321,6 +325,12 @@ var RenderField = function RenderField(_ref) { | |
| 321 325 | 
             
                return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
         | 
| 322 326 | 
             
                  while (1) switch (_context.prev = _context.next) {
         | 
| 323 327 | 
             
                    case 0:
         | 
| 328 | 
            +
                      if (!(!onFieldChange && !onChange)) {
         | 
| 329 | 
            +
                        _context.next = 2;
         | 
| 330 | 
            +
                        break;
         | 
| 331 | 
            +
                      }
         | 
| 332 | 
            +
                      return _context.abrupt("return", null);
         | 
| 333 | 
            +
                    case 2:
         | 
| 324 334 | 
             
                      for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
         | 
| 325 335 | 
             
                        args[_key2] = _args2[_key2];
         | 
| 326 336 | 
             
                      }
         | 
| @@ -329,58 +339,60 @@ var RenderField = function RenderField(_ref) { | |
| 329 339 | 
             
                      row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
         | 
| 330 340 | 
             
                      orgRow = (0, _lodash.cloneDeep)(row);
         | 
| 331 341 | 
             
                      if (!onFieldChange) {
         | 
| 332 | 
            -
                        _context.next =  | 
| 342 | 
            +
                        _context.next = 20;
         | 
| 333 343 | 
             
                        break;
         | 
| 334 344 | 
             
                      }
         | 
| 335 345 | 
             
                      _args = formatArgs(args);
         | 
| 336 346 | 
             
                      _args[1] = row;
         | 
| 337 347 | 
             
                      _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
         | 
| 338 348 | 
             
                      if (!_context.t0) {
         | 
| 339 | 
            -
                        _context.next =  | 
| 349 | 
            +
                        _context.next = 14;
         | 
| 340 350 | 
             
                        break;
         | 
| 341 351 | 
             
                      }
         | 
| 342 | 
            -
                      _context.next =  | 
| 352 | 
            +
                      _context.next = 14;
         | 
| 343 353 | 
             
                      return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
         | 
| 344 | 
            -
                    case  | 
| 354 | 
            +
                    case 14:
         | 
| 345 355 | 
             
                      _context.t1 = onFieldChange;
         | 
| 346 356 | 
             
                      if (!_context.t1) {
         | 
| 347 | 
            -
                        _context.next =  | 
| 357 | 
            +
                        _context.next = 18;
         | 
| 348 358 | 
             
                        break;
         | 
| 349 359 | 
             
                      }
         | 
| 350 | 
            -
                      _context.next =  | 
| 360 | 
            +
                      _context.next = 18;
         | 
| 351 361 | 
             
                      return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
         | 
| 352 | 
            -
                    case 16:
         | 
| 353 | 
            -
                      _context.next = 27;
         | 
| 354 | 
            -
                      break;
         | 
| 355 362 | 
             
                    case 18:
         | 
| 363 | 
            +
                      _context.next = 29;
         | 
| 364 | 
            +
                      break;
         | 
| 365 | 
            +
                    case 20:
         | 
| 356 366 | 
             
                      _args = _args.concat([row, index, form]);
         | 
| 357 367 | 
             
                      _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
         | 
| 358 368 | 
             
                      if (!_context.t2) {
         | 
| 359 | 
            -
                        _context.next =  | 
| 369 | 
            +
                        _context.next = 25;
         | 
| 360 370 | 
             
                        break;
         | 
| 361 371 | 
             
                      }
         | 
| 362 | 
            -
                      _context.next =  | 
| 372 | 
            +
                      _context.next = 25;
         | 
| 363 373 | 
             
                      return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
         | 
| 364 | 
            -
                    case  | 
| 374 | 
            +
                    case 25:
         | 
| 365 375 | 
             
                      _context.t3 = onChange;
         | 
| 366 376 | 
             
                      if (!_context.t3) {
         | 
| 367 | 
            -
                        _context.next =  | 
| 377 | 
            +
                        _context.next = 29;
         | 
| 368 378 | 
             
                        break;
         | 
| 369 379 | 
             
                      }
         | 
| 370 | 
            -
                      _context.next =  | 
| 380 | 
            +
                      _context.next = 29;
         | 
| 371 381 | 
             
                      return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
         | 
| 372 | 
            -
                    case  | 
| 382 | 
            +
                    case 29:
         | 
| 373 383 | 
             
                      // 判断属性是否变动
         | 
| 374 384 | 
             
                      form.setFieldValue(rowPath, row);
         | 
| 375 | 
            -
                      if ( | 
| 376 | 
            -
                         | 
| 377 | 
            -
             | 
| 378 | 
            -
                           | 
| 379 | 
            -
             | 
| 380 | 
            -
             | 
| 381 | 
            -
                           | 
| 382 | 
            -
                             | 
| 383 | 
            -
             | 
| 385 | 
            +
                      if (validateTrigger && validateTrigger.includes('onChange')) {
         | 
| 386 | 
            +
                        if (!(0, _lodash.isEqual)(orgRow, row)) {
         | 
| 387 | 
            +
                          diff = (0, _tools.difference)(row, orgRow) || {};
         | 
| 388 | 
            +
                          validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
         | 
| 389 | 
            +
                            return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
         | 
| 390 | 
            +
                          });
         | 
| 391 | 
            +
                          if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
         | 
| 392 | 
            +
                            setTimeout(function () {
         | 
| 393 | 
            +
                              form.validateFields(validateFieldKeys);
         | 
| 394 | 
            +
                            }, 100);
         | 
| 395 | 
            +
                          }
         | 
| 384 396 | 
             
                        }
         | 
| 385 397 | 
             
                      }
         | 
| 386 398 | 
             
                      setState({
         | 
| @@ -388,7 +400,7 @@ var RenderField = function RenderField(_ref) { | |
| 388 400 | 
             
                          d: Date.now()
         | 
| 389 401 | 
             
                        }
         | 
| 390 402 | 
             
                      });
         | 
| 391 | 
            -
                    case  | 
| 403 | 
            +
                    case 32:
         | 
| 392 404 | 
             
                    case "end":
         | 
| 393 405 | 
             
                      return _context.stop();
         | 
| 394 406 | 
             
                  }
         | 
| @@ -412,6 +424,12 @@ var RenderField = function RenderField(_ref) { | |
| 412 424 | 
             
                  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
         | 
| 413 425 | 
             
                    while (1) switch (_context2.prev = _context2.next) {
         | 
| 414 426 | 
             
                      case 0:
         | 
| 427 | 
            +
                        if (onBlur) {
         | 
| 428 | 
            +
                          _context2.next = 2;
         | 
| 429 | 
            +
                          break;
         | 
| 430 | 
            +
                        }
         | 
| 431 | 
            +
                        return _context2.abrupt("return", null);
         | 
| 432 | 
            +
                      case 2:
         | 
| 415 433 | 
             
                        for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
         | 
| 416 434 | 
             
                          args[_key3] = _args3[_key3];
         | 
| 417 435 | 
             
                        }
         | 
| @@ -422,49 +440,51 @@ var RenderField = function RenderField(_ref) { | |
| 422 440 | 
             
                        _args[1] = row;
         | 
| 423 441 | 
             
                        _context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
         | 
| 424 442 | 
             
                        if (!_context2.t0) {
         | 
| 425 | 
            -
                          _context2.next =  | 
| 443 | 
            +
                          _context2.next = 12;
         | 
| 426 444 | 
             
                          break;
         | 
| 427 445 | 
             
                        }
         | 
| 428 | 
            -
                        _context2.next =  | 
| 446 | 
            +
                        _context2.next = 12;
         | 
| 429 447 | 
             
                        return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, (0, _toConsumableArray2.default)(_args));
         | 
| 430 | 
            -
                      case  | 
| 448 | 
            +
                      case 12:
         | 
| 431 449 | 
             
                        _context2.t1 = onBlur;
         | 
| 432 450 | 
             
                        if (!_context2.t1) {
         | 
| 433 | 
            -
                          _context2.next =  | 
| 451 | 
            +
                          _context2.next = 16;
         | 
| 434 452 | 
             
                          break;
         | 
| 435 453 | 
             
                        }
         | 
| 436 | 
            -
                        _context2.next =  | 
| 454 | 
            +
                        _context2.next = 16;
         | 
| 437 455 | 
             
                        return onBlur.apply(void 0, (0, _toConsumableArray2.default)(_args));
         | 
| 438 | 
            -
                      case  | 
| 456 | 
            +
                      case 16:
         | 
| 439 457 | 
             
                        // 判断属性是否变动
         | 
| 440 458 | 
             
                        form.setFieldValue(rowPath, row);
         | 
| 441 | 
            -
                        if ( | 
| 442 | 
            -
                           | 
| 443 | 
            -
             | 
| 444 | 
            -
                             | 
| 445 | 
            -
             | 
| 446 | 
            -
             | 
| 447 | 
            -
                             | 
| 459 | 
            +
                        if (validateTrigger && validateTrigger.includes('onBlur')) {
         | 
| 460 | 
            +
                          if (!(0, _lodash.isEqual)(orgRow, row)) {
         | 
| 461 | 
            +
                            diff = (0, _tools.difference)(row, orgRow) || {};
         | 
| 462 | 
            +
                            validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
         | 
| 463 | 
            +
                              return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
         | 
| 464 | 
            +
                            });
         | 
| 465 | 
            +
                            if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
         | 
| 466 | 
            +
                              debounceValidate(validateFieldKeys);
         | 
| 467 | 
            +
                            }
         | 
| 448 468 | 
             
                          }
         | 
| 449 469 | 
             
                        }
         | 
| 450 470 | 
             
                        if (!isCell) {
         | 
| 451 | 
            -
                          _context2.next =  | 
| 471 | 
            +
                          _context2.next = 22;
         | 
| 452 472 | 
             
                          break;
         | 
| 453 473 | 
             
                        }
         | 
| 454 | 
            -
                        _context2.next =  | 
| 474 | 
            +
                        _context2.next = 21;
         | 
| 455 475 | 
             
                        return form.validateFields([cellName]);
         | 
| 456 | 
            -
                      case  | 
| 476 | 
            +
                      case 21:
         | 
| 457 477 | 
             
                        setState({
         | 
| 458 478 | 
             
                          cellNamePath: []
         | 
| 459 479 | 
             
                        });
         | 
| 460 | 
            -
                      case  | 
| 480 | 
            +
                      case 22:
         | 
| 461 481 | 
             
                        // 单行编辑时需要 强制更新视图
         | 
| 462 482 | 
             
                        setState({
         | 
| 463 483 | 
             
                          forceUpdate: {
         | 
| 464 484 | 
             
                            d: Date.now()
         | 
| 465 485 | 
             
                          }
         | 
| 466 486 | 
             
                        });
         | 
| 467 | 
            -
                      case  | 
| 487 | 
            +
                      case 23:
         | 
| 468 488 | 
             
                      case "end":
         | 
| 469 489 | 
             
                        return _context2.stop();
         | 
| 470 490 | 
             
                    }
         | 
| @@ -100,6 +100,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro | |
| 100 100 | 
             
                hiddenNames?: NamePath[] | NamePath[][];
         | 
| 101 101 | 
             
                rules?: ProRule[] | RulesFn<T>;
         | 
| 102 102 | 
             
                confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
         | 
| 103 | 
            +
                validateTrigger?: string | string[];
         | 
| 103 104 | 
             
                [key: string]: any;
         | 
| 104 105 | 
             
            }
         | 
| 105 106 | 
             
            export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
         | 
| @@ -39,6 +39,7 @@ var limitNumber = function limitNumber(num, _ref) { | |
| 39 39 | 
             
              return num;
         | 
| 40 40 | 
             
            };
         | 
| 41 41 | 
             
            var InputNumber = function InputNumber(props) {
         | 
| 42 | 
            +
              var _props$precision4;
         | 
| 42 43 | 
             
              var placeholder = props.placeholder,
         | 
| 43 44 | 
             
                className = props.className,
         | 
| 44 45 | 
             
                otherProps = props.otherProps,
         | 
| @@ -59,28 +60,33 @@ var InputNumber = function InputNumber(props) { | |
| 59 60 | 
             
              var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
         | 
| 60 61 | 
             
              var valueProps = {};
         | 
| 61 62 | 
             
              var formatter = function formatter(value) {
         | 
| 63 | 
            +
                var _props$precision;
         | 
| 62 64 | 
             
                if (value === '') return '';
         | 
| 63 65 | 
             
                var num = Number(value);
         | 
| 64 66 | 
             
                if (Number.isNaN(num)) {
         | 
| 65 67 | 
             
                  return value;
         | 
| 66 68 | 
             
                }
         | 
| 67 69 | 
             
                var val = num.toLocaleString('en-US', {
         | 
| 68 | 
            -
                  maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision)  | 
| 70 | 
            +
                  maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
         | 
| 69 71 | 
             
                });
         | 
| 70 72 | 
             
                if (!activateRef.current) {
         | 
| 73 | 
            +
                  var _props$precision2;
         | 
| 71 74 | 
             
                  var _val$split = val.split('.'),
         | 
| 72 75 | 
             
                    _val$split2 = (0, _slicedToArray2.default)(_val$split, 2),
         | 
| 73 76 | 
             
                    int = _val$split2[0],
         | 
| 74 77 | 
             
                    _val$split2$ = _val$split2[1],
         | 
| 75 78 | 
             
                    float = _val$split2$ === void 0 ? '' : _val$split2$;
         | 
| 76 | 
            -
                   | 
| 79 | 
            +
                  if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
         | 
| 80 | 
            +
                    return int;
         | 
| 81 | 
            +
                  }
         | 
| 82 | 
            +
                  return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
         | 
| 77 83 | 
             
                }
         | 
| 78 84 | 
             
                return val;
         | 
| 79 85 | 
             
              };
         | 
| 80 86 | 
             
              var _parser = function parser(value, precision) {
         | 
| 81 | 
            -
                var num = Number(value.replace(/[\s,]+/g, ''));
         | 
| 82 87 | 
             
                if (value === '') return value;
         | 
| 83 | 
            -
                 | 
| 88 | 
            +
                var num = Number(value.replace(/[\s,]+/g, ''));
         | 
| 89 | 
            +
                return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
         | 
| 84 90 | 
             
              };
         | 
| 85 91 | 
             
              if (valueType) {
         | 
| 86 92 | 
             
                switch (valueType) {
         | 
| @@ -92,8 +98,10 @@ var InputNumber = function InputNumber(props) { | |
| 92 98 | 
             
                    valueProps = {
         | 
| 93 99 | 
             
                      formatter: formatter,
         | 
| 94 100 | 
             
                      parser: function parser(val) {
         | 
| 95 | 
            -
                         | 
| 96 | 
            -
             | 
| 101 | 
            +
                        var _props$precision3;
         | 
| 102 | 
            +
                        return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
         | 
| 103 | 
            +
                      },
         | 
| 104 | 
            +
                      precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
         | 
| 97 105 | 
             
                    };
         | 
| 98 106 | 
             
                    break;
         | 
| 99 107 | 
             
                  // 百分比
         | 
| @@ -181,7 +189,7 @@ var InputNumber = function InputNumber(props) { | |
| 181 189 | 
             
                      var originValue = calc(Number(value), '/', 100);
         | 
| 182 190 | 
             
                      // 获取真实数据的小数位数
         | 
| 183 191 | 
             
                      var decimalDigits = (0, _index.getDecimalDigits)(originValue);
         | 
| 184 | 
            -
                      if (decimalDigits > (precision  | 
| 192 | 
            +
                      if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
         | 
| 185 193 | 
             
                        return (0, _jsxRuntime.jsx)(_Container.default, {
         | 
| 186 194 | 
             
                          viewEmpty: viewEmpty,
         | 
| 187 195 | 
             
                          children: value
         | 
| @@ -199,7 +207,7 @@ var InputNumber = function InputNumber(props) { | |
| 199 207 | 
             
                      var _originValue = calc(Number(value), '/', 1000);
         | 
| 200 208 | 
             
                      // 获取真实数据的小数位数
         | 
| 201 209 | 
             
                      var _decimalDigits = (0, _index.getDecimalDigits)(_originValue);
         | 
| 202 | 
            -
                      if (_decimalDigits > (precision  | 
| 210 | 
            +
                      if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
         | 
| 203 211 | 
             
                        return (0, _jsxRuntime.jsx)(_Container.default, {
         | 
| 204 212 | 
             
                          viewEmpty: viewEmpty,
         | 
| 205 213 | 
             
                          children: value
         | 
| @@ -216,7 +224,7 @@ var InputNumber = function InputNumber(props) { | |
| 216 224 | 
             
                  case 'thousandth':
         | 
| 217 225 | 
             
                    return (0, _jsxRuntime.jsx)(_Container.default, {
         | 
| 218 226 | 
             
                      viewEmpty: viewEmpty,
         | 
| 219 | 
            -
                      children: _utils.tools.formatAmount(value, precision  | 
| 227 | 
            +
                      children: _utils.tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
         | 
| 220 228 | 
             
                    });
         | 
| 221 229 | 
             
                  // CNY千分位
         | 
| 222 230 | 
             
                  case 'thousandthCNY':
         | 
| @@ -236,7 +244,7 @@ var InputNumber = function InputNumber(props) { | |
| 236 244 | 
             
              }
         | 
| 237 245 | 
             
              // 失去焦点时处理数字,
         | 
| 238 246 | 
             
              var handleBlur = function handleBlur(e) {
         | 
| 239 | 
            -
                var _e$target, _e$target2;
         | 
| 247 | 
            +
                var _e$target, _props$precision5, _valueProps3, _e$target2;
         | 
| 240 248 | 
             
                activateRef.current = false;
         | 
| 241 249 | 
             
                var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
         | 
| 242 250 | 
             
                if (_max !== undefined && value > _max) {
         | 
| @@ -245,7 +253,8 @@ var InputNumber = function InputNumber(props) { | |
| 245 253 | 
             
                if (_min !== undefined && value < _min) {
         | 
| 246 254 | 
             
                  value = _min;
         | 
| 247 255 | 
             
                }
         | 
| 248 | 
            -
                value = _parser(String(value), props.precision);
         | 
| 256 | 
            +
                value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
         | 
| 257 | 
            +
                rest === null || rest === void 0 ? void 0 : rest.onChange(value);
         | 
| 249 258 | 
             
                var limit = {
         | 
| 250 259 | 
             
                  min: Number(_min),
         | 
| 251 260 | 
             
                  max: Number(_max)
         | 
    
        package/lib/ProForm/index.d.ts
    CHANGED
    
    | @@ -1,11 +1,12 @@ | |
| 1 | 
            -
            import {  | 
| 1 | 
            +
            import { FormInstance } from 'antd';
         | 
| 2 2 | 
             
            import React, { ForwardRefRenderFunction } from 'react';
         | 
| 3 3 | 
             
            import { FormProviderProps } from 'antd/es/form/context';
         | 
| 4 4 | 
             
            import { ProFormProps } from './propsType';
         | 
| 5 5 | 
             
            import { useForm } from './utils/useForm';
         | 
| 6 | 
            +
            import useWatch from './utils/useWatch';
         | 
| 6 7 | 
             
            interface IProForm<T = any> extends ForwardRefRenderFunction<FormInstance<T>, ProFormProps<T>> {
         | 
| 7 8 | 
             
                useForm: typeof useForm;
         | 
| 8 | 
            -
                useWatch: typeof  | 
| 9 | 
            +
                useWatch: typeof useWatch;
         | 
| 9 10 | 
             
                [key: string]: any;
         | 
| 10 11 | 
             
            }
         | 
| 11 12 | 
             
            declare const ProFormForward: IProForm;
         | 
    
        package/lib/ProForm/index.js
    CHANGED
    
    | @@ -24,6 +24,7 @@ var _index = require("./utils/index"); | |
| 24 24 | 
             
            var _useForm3 = require("./utils/useForm");
         | 
| 25 25 | 
             
            var _useFieldProps = require("./utils/useFieldProps");
         | 
| 26 26 | 
             
            var _locale = _interopRequireDefault(require("../locale"));
         | 
| 27 | 
            +
            var _useWatch = _interopRequireDefault(require("./utils/useWatch"));
         | 
| 27 28 | 
             
            var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError", "optimize"];
         | 
| 28 29 | 
             
            var ProForm = function ProForm(props, ref) {
         | 
| 29 30 | 
             
              var _forms$formKey, _localStorage, _ref;
         | 
| @@ -274,22 +275,7 @@ var ProForm = function ProForm(props, ref) { | |
| 274 275 | 
             
            // @ts-ignore
         | 
| 275 276 | 
             
            var ProFormForward = /*#__PURE__*/(0, _react.forwardRef)(ProForm);
         | 
| 276 277 | 
             
            ProFormForward.useForm = _useForm3.useForm;
         | 
| 277 | 
            -
            ProFormForward.useWatch =  | 
| 278 | 
            -
              if ((0, _lodash.isString)(watchValue)) {
         | 
| 279 | 
            -
                var watchValues = [watchValue];
         | 
| 280 | 
            -
                watchValues.forEach(function (item) {
         | 
| 281 | 
            -
                  _antd.Form.useWatch(item, form);
         | 
| 282 | 
            -
                });
         | 
| 283 | 
            -
                return form.getFieldsValue(watchValues);
         | 
| 284 | 
            -
              }
         | 
| 285 | 
            -
              if (watchValue.length) {
         | 
| 286 | 
            -
                watchValue.forEach(function (item) {
         | 
| 287 | 
            -
                  _antd.Form.useWatch(item, form);
         | 
| 288 | 
            -
                });
         | 
| 289 | 
            -
                return form.getFieldsValue(watchValue);
         | 
| 290 | 
            -
              }
         | 
| 291 | 
            -
              return _antd.Form.useWatch([], form);
         | 
| 292 | 
            -
            };
         | 
| 278 | 
            +
            ProFormForward.useWatch = _useWatch.default;
         | 
| 293 279 | 
             
            var ProFormProvider = exports.ProFormProvider = function ProFormProvider(props) {
         | 
| 294 280 | 
             
              var onFormChange = props.onFormChange,
         | 
| 295 281 | 
             
                onFormFinish = props.onFormFinish,
         | 
| @@ -29,6 +29,7 @@ var useShouldUpdate = function useShouldUpdate(props) { | |
| 29 29 | 
             
                names = formItemProps.names,
         | 
| 30 30 | 
             
                dependencies = formItemProps.dependencies;
         | 
| 31 31 | 
             
              var timerRef = (0, _react.useRef)();
         | 
| 32 | 
            +
              var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
         | 
| 32 33 | 
             
              var showRef = (0, _react.useRef)();
         | 
| 33 34 | 
             
              var disabledRef = (0, _react.useRef)();
         | 
| 34 35 | 
             
              var requiredRef = (0, _react.useRef)();
         | 
| @@ -165,17 +166,24 @@ var useShouldUpdate = function useShouldUpdate(props) { | |
| 165 166 | 
             
                  }) : fieldProps;
         | 
| 166 167 | 
             
                  // 清值防抖  多次刷新时以最后一次为准
         | 
| 167 168 | 
             
                  if (clearNotShow !== false && (name || names)) {
         | 
| 169 | 
            +
                    // 当show为其他变为false的时候记录一次需要清值
         | 
| 170 | 
            +
                    if (_show !== showRef.current && _show === false) {
         | 
| 171 | 
            +
                      needClear.current = true;
         | 
| 172 | 
            +
                    }
         | 
| 168 173 | 
             
                    if (_show === false) {
         | 
| 169 174 | 
             
                      clearTimeout(timerRef.current);
         | 
| 170 175 | 
             
                      timerRef.current = setTimeout(function () {
         | 
| 176 | 
            +
                        if (needClear.current !== true) return;
         | 
| 171 177 | 
             
                        if (Array.isArray(names)) {
         | 
| 172 178 | 
             
                          form.resetFields(names);
         | 
| 173 179 | 
             
                        } else {
         | 
| 174 180 | 
             
                          var clearName = formItemProps.namePath ? formItemProps.namePath.slice(0, -1).concat(formItemProps.name) : formItemProps.name;
         | 
| 175 181 | 
             
                          form.resetFields([clearName]);
         | 
| 176 182 | 
             
                        }
         | 
| 177 | 
            -
             | 
| 183 | 
            +
                        needClear.current = false;
         | 
| 184 | 
            +
                      }, 300);
         | 
| 178 185 | 
             
                    } else {
         | 
| 186 | 
            +
                      needClear.current = false;
         | 
| 179 187 | 
             
                      clearTimeout(timerRef.current);
         | 
| 180 188 | 
             
                    }
         | 
| 181 189 | 
             
                  }
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            import { InternalNamePath, FormInstance, NamePath } from 'rc-field-form/es/interface';
         | 
| 2 | 
            +
            export declare function toArray<T>(value?: T | T[] | null): T[];
         | 
| 3 | 
            +
            export declare function getNamePath(path: NamePath | null): InternalNamePath;
         | 
| 4 | 
            +
            export declare function stringify(value: any): string | number;
         | 
| 5 | 
            +
            declare function useWatch(dependencies: string, form?: FormInstance, wait?: number): any;
         | 
| 6 | 
            +
            declare function useWatch(dependencies: NamePath[], form?: FormInstance, wait?: number): any[];
         | 
| 7 | 
            +
            export default useWatch;
         | 
| @@ -0,0 +1,87 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
         | 
| 4 | 
            +
            Object.defineProperty(exports, "__esModule", {
         | 
| 5 | 
            +
              value: true
         | 
| 6 | 
            +
            });
         | 
| 7 | 
            +
            exports.default = void 0;
         | 
| 8 | 
            +
            exports.getNamePath = getNamePath;
         | 
| 9 | 
            +
            exports.stringify = stringify;
         | 
| 10 | 
            +
            exports.toArray = toArray;
         | 
| 11 | 
            +
            var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
         | 
| 12 | 
            +
            var _lodash = require("lodash");
         | 
| 13 | 
            +
            var _FieldContext = require("rc-field-form/es/FieldContext");
         | 
| 14 | 
            +
            var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
         | 
| 15 | 
            +
            var _react = require("react");
         | 
| 16 | 
            +
            function toArray(value) {
         | 
| 17 | 
            +
              if (value === undefined || value === null) {
         | 
| 18 | 
            +
                return [];
         | 
| 19 | 
            +
              }
         | 
| 20 | 
            +
              return Array.isArray(value) ? value : [value];
         | 
| 21 | 
            +
            }
         | 
| 22 | 
            +
            function getNamePath(path) {
         | 
| 23 | 
            +
              return toArray(path);
         | 
| 24 | 
            +
            }
         | 
| 25 | 
            +
            function stringify(value) {
         | 
| 26 | 
            +
              try {
         | 
| 27 | 
            +
                return JSON.stringify(value);
         | 
| 28 | 
            +
              } catch (err) {
         | 
| 29 | 
            +
                return Math.random();
         | 
| 30 | 
            +
              }
         | 
| 31 | 
            +
            }
         | 
| 32 | 
            +
            // 创建之后namepath就不可变
         | 
| 33 | 
            +
            var useWatchWarning = process.env.NODE_ENV !== 'production' ? function (namePath) {
         | 
| 34 | 
            +
              var fullyStr = JSON.stringify(namePath);
         | 
| 35 | 
            +
              var nameStrRef = (0, _react.useRef)(fullyStr);
         | 
| 36 | 
            +
              (0, _warning.default)(nameStrRef.current === fullyStr, '`useWatch` is not support dynamic `namePath`. Please provide static instead.');
         | 
| 37 | 
            +
            } : function () {};
         | 
| 38 | 
            +
            function useWatch(dependencies, form, wait) {
         | 
| 39 | 
            +
              var isSingle = typeof dependencies === 'string';
         | 
| 40 | 
            +
              var _useState = (0, _react.useState)({}),
         | 
| 41 | 
            +
                _useState2 = (0, _slicedToArray2.default)(_useState, 2),
         | 
| 42 | 
            +
                value = _useState2[0],
         | 
| 43 | 
            +
                setValue = _useState2[1];
         | 
| 44 | 
            +
              var valueStr = (0, _react.useMemo)(function () {
         | 
| 45 | 
            +
                return stringify(value);
         | 
| 46 | 
            +
              }, [value]);
         | 
| 47 | 
            +
              var valueStrRef = (0, _react.useRef)(valueStr);
         | 
| 48 | 
            +
              valueStrRef.current = valueStr;
         | 
| 49 | 
            +
              var formInstance = form;
         | 
| 50 | 
            +
              var isValidForm = formInstance && formInstance._init;
         | 
| 51 | 
            +
              var _dependencies = isSingle ? [dependencies] : dependencies;
         | 
| 52 | 
            +
              var namePaths = _dependencies === null || _dependencies === void 0 ? void 0 : _dependencies.map(function (item) {
         | 
| 53 | 
            +
                return getNamePath(item);
         | 
| 54 | 
            +
              });
         | 
| 55 | 
            +
              var namePathsRef = (0, _react.useRef)(namePaths);
         | 
| 56 | 
            +
              namePathsRef.current = namePaths;
         | 
| 57 | 
            +
              useWatchWarning(namePaths);
         | 
| 58 | 
            +
              (0, _react.useEffect)(function () {
         | 
| 59 | 
            +
                if (!isValidForm) return;
         | 
| 60 | 
            +
                var getFieldsValue = formInstance.getFieldsValue,
         | 
| 61 | 
            +
                  getInternalHooks = formInstance.getInternalHooks;
         | 
| 62 | 
            +
                var _getInternalHooks = getInternalHooks(_FieldContext.HOOK_MARK),
         | 
| 63 | 
            +
                  registerWatch = _getInternalHooks.registerWatch;
         | 
| 64 | 
            +
                var callback = function callback() {
         | 
| 65 | 
            +
                  var newValue = getFieldsValue(_dependencies);
         | 
| 66 | 
            +
                  var nextValueStr = stringify(newValue);
         | 
| 67 | 
            +
                  // Compare stringify in case it's nest object
         | 
| 68 | 
            +
                  if (valueStrRef.current !== nextValueStr) {
         | 
| 69 | 
            +
                    valueStrRef.current = nextValueStr;
         | 
| 70 | 
            +
                    setValue(getFieldsValue(_dependencies));
         | 
| 71 | 
            +
                  }
         | 
| 72 | 
            +
                };
         | 
| 73 | 
            +
                // 增加防抖
         | 
| 74 | 
            +
                if (wait) {
         | 
| 75 | 
            +
                  callback = (0, _lodash.debounce)(callback, wait);
         | 
| 76 | 
            +
                }
         | 
| 77 | 
            +
                var cancelRegister = registerWatch(callback);
         | 
| 78 | 
            +
                var initialValue = getFieldsValue(_dependencies);
         | 
| 79 | 
            +
                setValue(initialValue);
         | 
| 80 | 
            +
                return cancelRegister;
         | 
| 81 | 
            +
              },
         | 
| 82 | 
            +
              // We do not need re-register since namePath content is the same
         | 
| 83 | 
            +
              // eslint-disable-next-line react-hooks/exhaustive-deps
         | 
| 84 | 
            +
              [isValidForm]);
         | 
| 85 | 
            +
              return value;
         | 
| 86 | 
            +
            }
         | 
| 87 | 
            +
            var _default = exports.default = useWatch;
         | 
    
        package/lib/ProTable/utils.js
    CHANGED
    
    | @@ -112,7 +112,7 @@ var formatColumn = exports.formatColumn = function formatColumn(column, original | |
| 112 112 | 
             
              if (['percentage', 'permillage'].includes(valueType)) {
         | 
| 113 113 | 
             
                column.render = function (value, record, index) {
         | 
| 114 114 | 
             
                  var multiple = valueType === 'percentage' ? 100 : 1000;
         | 
| 115 | 
            -
                  var realValue = _utils.tools.calc(Number(value), '*', multiple);
         | 
| 115 | 
            +
                  var realValue = _utils.tools.calc(Number(value !== null && value !== void 0 ? value : 0), '*', multiple);
         | 
| 116 116 | 
             
                  var renderValue = getDecimalDigits(value) > valueTypePrecision ? realValue : realValue.toFixed(valueTypePrecision);
         | 
| 117 117 | 
             
                  var originalValue = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
         | 
| 118 118 | 
             
                  var originalRealValue = _utils.tools.calc(Number(originalValue || null), '*', multiple);
         | 
| @@ -355,9 +355,9 @@ var ProTreeSelect = exports.ProTreeSelect = function ProTreeSelect(props, ref) { | |
| 355 355 | 
             
                    }
         | 
| 356 356 | 
             
                    // 迭代完子节点向上回溯,如果有匹配到得子节点,那么加入当前节点得孩子对象上,否则加入得是空数组
         | 
| 357 357 | 
             
                    item.children = currentNodeChild;
         | 
| 358 | 
            -
                    // let tag = false;
         | 
| 359 358 | 
             
                    // 判断节点title是否包含关键字 如果有,那么直接进行下一循环
         | 
| 360 | 
            -
                     | 
| 359 | 
            +
                    // @ts-ignore
         | 
| 360 | 
            +
                    if (item[label].indexOf(keyWord) > -1 && (selectProps === null || selectProps === void 0 ? void 0 : selectProps.mode) !== 'treeSelect') {
         | 
| 361 361 | 
             
                      var regExp = new RegExp(keyWord);
         | 
| 362 362 | 
             
                      item[label] = item[label].replace(regExp, "<span class=\"highlight-search-text\">".concat(keyWord, "</span>"));
         | 
| 363 363 | 
             
                    }
         | 
| @@ -419,11 +419,22 @@ var ProTreeSelect = exports.ProTreeSelect = function ProTreeSelect(props, ref) { | |
| 419 419 | 
             
              }
         | 
| 420 420 | 
             
              var handleChange = function handleChange(newVal, label, extra) {
         | 
| 421 421 | 
             
                // newVal回来得一定是label、value
         | 
| 422 | 
            +
                var _selectList = selectList.map(function (item) {
         | 
| 423 | 
            +
                  var label = item.label;
         | 
| 424 | 
            +
                  var _label = label;
         | 
| 425 | 
            +
                  if (label) {
         | 
| 426 | 
            +
                    var regex = /<span class="highlight-search-text">(.*?)<\/span>/g;
         | 
| 427 | 
            +
                    _label = item[label] = label === null || label === void 0 ? void 0 : label.replace(regex, '$1');
         | 
| 428 | 
            +
                  }
         | 
| 429 | 
            +
                  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
         | 
| 430 | 
            +
                    label: _label
         | 
| 431 | 
            +
                  });
         | 
| 432 | 
            +
                });
         | 
| 422 433 | 
             
                var result = newVal;
         | 
| 423 434 | 
             
                if (props === null || props === void 0 ? void 0 : props.labelInValue) {
         | 
| 424 | 
            -
                  result = getLabelByValue( | 
| 435 | 
            +
                  result = getLabelByValue(_selectList, newVal);
         | 
| 425 436 | 
             
                }
         | 
| 426 | 
            -
                var options = findTreeNode( | 
| 437 | 
            +
                var options = findTreeNode(_selectList, extra === null || extra === void 0 ? void 0 : extra.triggerValue);
         | 
| 427 438 | 
             
                onChange && onChange(result, options, extra);
         | 
| 428 439 | 
             
                // 重置搜索
         | 
| 429 440 | 
             
                showSearch && searchTreeEvent('');
         | 
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "@zat-design/sisyphus-react",
         | 
| 3 | 
            -
              "version": "3.6. | 
| 3 | 
            +
              "version": "3.6.6-beta.1",
         | 
| 4 4 | 
             
              "license": "Apache-2.0",
         | 
| 5 5 | 
             
              "main": "lib/index.js",
         | 
| 6 6 | 
             
              "module": "es/index.js",
         | 
| @@ -58,7 +58,7 @@ | |
| 58 58 | 
             
                "@dnd-kit/sortable": "^7.0.2",
         | 
| 59 59 | 
             
                "@dnd-kit/utilities": "^3.2.1",
         | 
| 60 60 | 
             
                "@pansy/react-watermark": "^3.1.13",
         | 
| 61 | 
            -
                "@zat-design/utils": "^1.1. | 
| 61 | 
            +
                "@zat-design/utils": "^1.1.29",
         | 
| 62 62 | 
             
                "ahooks": "3.7.4",
         | 
| 63 63 | 
             
                "antd": "4.24.8",
         | 
| 64 64 | 
             
                "big.js": "^6.2.1",
         |