@zat-design/sisyphus-react 3.6.4-beta.7 → 3.6.4-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| @@ -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,23 +240,17 @@ 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 | 
            -
                var changed = false;
         | 
| 238 245 | 
             
                var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
         | 
| 239 246 | 
             
                if (_max !== undefined && value > _max) {
         | 
| 240 247 | 
             
                  value = _max;
         | 
| 241 | 
            -
                  changed = true;
         | 
| 242 248 | 
             
                }
         | 
| 243 249 | 
             
                if (_min !== undefined && value < _min) {
         | 
| 244 250 | 
             
                  value = _min;
         | 
| 245 | 
            -
                  changed = true;
         | 
| 246 | 
            -
                }
         | 
| 247 | 
            -
                value = _parser(String(value), props.precision);
         | 
| 248 | 
            -
                if (changed) {
         | 
| 249 | 
            -
                  rest === null || rest === void 0 ? void 0 : rest.onChange(value);
         | 
| 250 | 
            -
                  changed = null;
         | 
| 251 251 | 
             
                }
         | 
| 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);
         | 
| 252 254 | 
             
                var limit = {
         | 
| 253 255 | 
             
                  min: Number(_min),
         | 
| 254 256 | 
             
                  max: Number(_max)
         | 
| @@ -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,23 +244,17 @@ 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 | 
            -
                var changed = false;
         | 
| 242 249 | 
             
                var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
         | 
| 243 250 | 
             
                if (_max !== undefined && value > _max) {
         | 
| 244 251 | 
             
                  value = _max;
         | 
| 245 | 
            -
                  changed = true;
         | 
| 246 252 | 
             
                }
         | 
| 247 253 | 
             
                if (_min !== undefined && value < _min) {
         | 
| 248 254 | 
             
                  value = _min;
         | 
| 249 | 
            -
                  changed = true;
         | 
| 250 | 
            -
                }
         | 
| 251 | 
            -
                value = _parser(String(value), props.precision);
         | 
| 252 | 
            -
                if (changed) {
         | 
| 253 | 
            -
                  rest === null || rest === void 0 ? void 0 : rest.onChange(value);
         | 
| 254 | 
            -
                  changed = null;
         | 
| 255 255 | 
             
                }
         | 
| 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);
         | 
| 256 258 | 
             
                var limit = {
         | 
| 257 259 | 
             
                  min: Number(_min),
         | 
| 258 260 | 
             
                  max: Number(_max)
         |