@hi-ui/form 4.3.2 → 5.0.0-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @hi-ui/form
2
2
 
3
+ ## 5.0.0-alpha.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1b05b44a4: feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
8
+
9
+ ### Patch Changes
10
+
11
+ - 5de7a848b: fix: 修复 5.0 UI 问题 (5.0)
12
+ - 0cd15438e: style: 修改样式问题 (5.0)
13
+ - abe1884ae: <br>
14
+ - fix(form): 错误提示字号改为 12px (5.0)
15
+ - fix(form): 必填星号调整为显示在右侧 (5.0)
16
+ - fix(form): 标题和控件间距改为 6px (5.0)
17
+ - fix(form): 包裹控件容器设置最小高度 32px (5.0)
18
+ - fix(form): 默认不显示标题冒号 (5.0)
19
+ - 61d132802: build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
20
+ - Updated dependencies [dfff90e7c]
21
+ - Updated dependencies [5de7a848b]
22
+ - Updated dependencies [1b05b44a4]
23
+ - Updated dependencies [67960d871]
24
+ - Updated dependencies [9fa354f31]
25
+ - Updated dependencies [77ed66eac]
26
+ - Updated dependencies [61d132802]
27
+ - Updated dependencies [489b27cb3]
28
+ - Updated dependencies [6eac4b78b]
29
+ - Updated dependencies [c125e4c48]
30
+ - Updated dependencies [b7ad460d8]
31
+ - @hi-ui/button@5.0.0-alpha.0
32
+ - @hi-ui/core@5.0.0-alpha.0
33
+ - @hi-ui/use-latest@5.0.0-alpha.0
34
+ - @hi-ui/array-utils@5.0.0-alpha.0
35
+ - @hi-ui/classname@5.0.0-alpha.0
36
+ - @hi-ui/dom-utils@5.0.0-alpha.0
37
+ - @hi-ui/env@5.0.0-alpha.0
38
+ - @hi-ui/func-utils@5.0.0-alpha.0
39
+ - @hi-ui/object-utils@5.0.0-alpha.0
40
+ - @hi-ui/type-assertion@5.0.0-alpha.0
41
+
42
+ ## 4.3.3
43
+
44
+ ### Patch Changes
45
+
46
+ - [#3277](https://github.com/XiaoMi/hiui/pull/3277) [`93df0aaff`](https://github.com/XiaoMi/hiui/commit/93df0aafff09be59faeb4bad0ceea57a00df5ccf) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(form): 处理规则消息为空的情况,将其设置为 undefined (#3276)
47
+
48
+ - [#3275](https://github.com/XiaoMi/hiui/pull/3275) [`b2b66a9e7`](https://github.com/XiaoMi/hiui/commit/b2b66a9e73a1a92d6b0604dc2ad711895154e518) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(form): 优化 valueType 为 number 情况下的校验逻辑 (#3274)
49
+
3
50
  ## 4.3.2
4
51
 
5
52
  ### Patch Changes
package/lib/cjs/Form.js CHANGED
@@ -49,8 +49,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (_a, ref) {
49
49
  contentPosition = _a$contentPosition === void 0 ? 'center' : _a$contentPosition,
50
50
  _a$showRequiredOnVali = _a.showRequiredOnValidateRequired,
51
51
  showRequiredOnValidateRequired = _a$showRequiredOnVali === void 0 ? false : _a$showRequiredOnVali,
52
- _a$showColon = _a.showColon,
53
- showColon = _a$showColon === void 0 ? true : _a$showColon,
52
+ showColon = _a.showColon,
54
53
  _a$showValidateMessag = _a.showValidateMessage,
55
54
  showValidateMessage = _a$showValidateMessag === void 0 ? true : _a$showValidateMessag,
56
55
  rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "innerRef", "labelWidth", "labelPlacement", "placement", "contentPosition", "showRequiredOnValidateRequired", "showColon", "showValidateMessage"]);
@@ -32,8 +32,7 @@ var FormReset = /*#__PURE__*/React.forwardRef(function (_a, ref) {
32
32
  prefixCls = _a$prefixCls === void 0 ? FORM_RESET_PREFIX : _a$prefixCls,
33
33
  className = _a.className,
34
34
  children = _a.children,
35
- _a$type = _a.type,
36
- type = _a$type === void 0 ? 'secondary' : _a$type,
35
+ type = _a.type,
37
36
  _onClick = _a.onClick,
38
37
  rest = tslib.__rest(_a, ["prefixCls", "className", "children", "type", "onClick"]);
39
38
  var _useFormContext = context.useFormContext(),
@@ -42,7 +41,8 @@ var FormReset = /*#__PURE__*/React.forwardRef(function (_a, ref) {
42
41
  return /*#__PURE__*/React__default["default"].createElement(Button__default["default"], Object.assign({
43
42
  ref: ref,
44
43
  className: cls,
45
- type: type
44
+ type: type,
45
+ appearance: "line"
46
46
  }, rest, {
47
47
  onClick: function onClick() {
48
48
  resetForm();
@@ -12,7 +12,7 @@
12
12
  Object.defineProperty(exports, '__esModule', {
13
13
  value: true
14
14
  });
15
- var css_248z = ".hi-v4-form {max-width: 100%;position: relative;}.hi-v4-form fieldset {margin: 0;padding: 0;border: 0;}.hi-v4-form fieldset + fieldset {margin-top: 16px;}.hi-v4-form legend {margin: 0 0 16px;color: var(--hi-v4-color-gray-800, #1f2937);}.hi-v4-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap;-webkit-column-gap: var(--hi-v4-spacing-10, 20px);-moz-column-gap: var(--hi-v4-spacing-10, 20px);column-gap: var(--hi-v4-spacing-10, 20px);}.hi-v4-form--placement-horizontal .hi-v4-form-label__indent {min-height: var(--hi-v4-height-8, 32px);}.hi-v4-form-label {font-size: var(--hi-v4-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;}.hi-v4-form-label__content {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-form-label--placement-top > .hi-v4-form-label__content {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;padding-right: 0;}.hi-v4-form-label__content__text, .hi-v4-form-label__content__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v4-color-gray-800, #1f2937);overflow-wrap: break-word;}.hi-v4-form-label__content__text {padding-right: var(--hi-v4-spacing-6, 12px);min-height: var(--hi-v4-height-8, 32px);line-height: var(--hi-v4-height-8, 32px);}.hi-v4-form-label--placement-left > .hi-v4-form-label__content > .hi-v4-form-label__content__text {text-align: left;}.hi-v4-form-label--placement-right > .hi-v4-form-label__content > .hi-v4-form-label__content__text {text-align: right;}.hi-v4-form-label--placement-top > .hi-v4-form-label__content > .hi-v4-form-label__content__text {min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v4-spacing-4, 8px);}.hi-v4-form-label--required > .hi-v4-form-label__content > .hi-v4-form-label__content__text::before {margin-right: var(--hi-v4-spacing-2, 4px);content: \"*\";color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));}.hi-v4-form-label__content__control {min-width: 1px;}.hi-v4-form-message {display: block;font-size: var(--hi-v4-text-size-md, 0.875rem);min-height: 24px;padding: 2px 0;-webkit-box-sizing: border-box;box-sizing: border-box;line-height: 20px;-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));-webkit-transition: all 0.3s;transition: all 0.3s;}.hi-v4-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0);}.hi-v4-form-item {position: relative;}";
15
+ var css_248z = ".hi-v5-form {max-width: 100%;position: relative;}.hi-v5-form fieldset {margin: 0;padding: 0;border: 0;}.hi-v5-form fieldset + fieldset {margin-top: 16px;}.hi-v5-form legend {margin: 0 0 16px;color: var(--hi-v5-color-gray-800, #1d1e26);}.hi-v5-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap;-webkit-column-gap: var(--hi-v5-spacing-10, 20px);-moz-column-gap: var(--hi-v5-spacing-10, 20px);column-gap: var(--hi-v5-spacing-10, 20px);}.hi-v5-form--placement-horizontal .hi-v5-form-label__indent {min-height: var(--hi-v5-height-8, 32px);}.hi-v5-form-label {font-size: var(--hi-v5-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;}.hi-v5-form-label__content {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v5-form-label--placement-top > .hi-v5-form-label__content {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;padding-right: 0;}.hi-v5-form-label__content__text, .hi-v5-form-label__content__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v5-color-gray-800, #1d1e26);overflow-wrap: break-word;}.hi-v5-form-label__content__text {padding-right: var(--hi-v5-spacing-6, 12px);min-height: var(--hi-v5-height-8, 32px);line-height: var(--hi-v5-height-8, 32px);}.hi-v5-form-label--placement-left > .hi-v5-form-label__content > .hi-v5-form-label__content__text {text-align: left;}.hi-v5-form-label--placement-right > .hi-v5-form-label__content > .hi-v5-form-label__content__text {text-align: right;}.hi-v5-form-label--placement-top > .hi-v5-form-label__content > .hi-v5-form-label__content__text {min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v5-spacing-3, 6px);}.hi-v5-form-label--required > .hi-v5-form-label__content > .hi-v5-form-label__content__text::after {margin-left: var(--hi-v5-spacing-2, 4px);content: \"*\";color: var(--hi-v5-color-danger-500, var(--hi-v5-color-red-500, #fa4646));}.hi-v5-form-label__content__control {min-width: 1px;min-height: var(--hi-v5-height-8, 32px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v5-form-message {-webkit-box-sizing: content-box;box-sizing: content-box;display: block;font-size: var(--hi-v5-text-size-sm, 0.75rem);line-height: var(--hi-v5-text-lineheight-sm, 1.25rem);min-height: var(--hi-v5-height-5, 20px);padding-bottom: var(--hi-v5-spacing-2, 4px);-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v5-color-danger-500, var(--hi-v5-color-red-500, #fa4646));-webkit-transition: all 0.3s;transition: all 0.3s;}.hi-v5-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0);}.hi-v5-form-item {position: relative;}";
16
16
  var __styleInject__ = require('@hi-ui/style-inject')["default"];
17
17
  __styleInject__(css_248z);
18
18
  exports["default"] = css_248z;
@@ -63,6 +63,9 @@ var useFormField = function useFormField(props) {
63
63
  // TODO: rules 处理成 Async Validate 的指定结构
64
64
  var fieldMD5 = index.stringify(field);
65
65
  var modifiedFieldRules = fieldRules.map(function (rule) {
66
+ if (rule.message === null || rule.message === '') {
67
+ rule.message = undefined;
68
+ }
66
69
  // 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
67
70
  // issue:https://github.com/XiaoMi/hiui/issues/2931
68
71
  if (rule.validator) {
@@ -79,7 +82,17 @@ var useFormField = function useFormField(props) {
79
82
  } else return Object.assign({}, rule);
80
83
  });
81
84
  var validater = new Validater__default["default"]((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
82
- return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
85
+ var valueToValidate = value;
86
+ if (valueType === 'number') {
87
+ if (typeAssertion.isNullish(value) || value === '') {
88
+ valueToValidate = value;
89
+ } else if (isNaN(value)) {
90
+ valueToValidate = value;
91
+ } else {
92
+ valueToValidate = Number(value);
93
+ }
94
+ }
95
+ return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueToValidate, _validater$validate), {
83
96
  firstFields: true
84
97
  });
85
98
  }, [fieldRules, field, valueType]);
package/lib/esm/Form.js CHANGED
@@ -37,8 +37,7 @@ var Form = /*#__PURE__*/forwardRef(function (_a, ref) {
37
37
  contentPosition = _a$contentPosition === void 0 ? 'center' : _a$contentPosition,
38
38
  _a$showRequiredOnVali = _a.showRequiredOnValidateRequired,
39
39
  showRequiredOnValidateRequired = _a$showRequiredOnVali === void 0 ? false : _a$showRequiredOnVali,
40
- _a$showColon = _a.showColon,
41
- showColon = _a$showColon === void 0 ? true : _a$showColon,
40
+ showColon = _a.showColon,
42
41
  _a$showValidateMessag = _a.showValidateMessage,
43
42
  showValidateMessage = _a$showValidateMessag === void 0 ? true : _a$showValidateMessag,
44
43
  rest = __rest(_a, ["prefixCls", "role", "className", "children", "innerRef", "labelWidth", "labelPlacement", "placement", "contentPosition", "showRequiredOnValidateRequired", "showColon", "showValidateMessage"]);
@@ -19,8 +19,7 @@ var FormReset = /*#__PURE__*/forwardRef(function (_a, ref) {
19
19
  prefixCls = _a$prefixCls === void 0 ? FORM_RESET_PREFIX : _a$prefixCls,
20
20
  className = _a.className,
21
21
  children = _a.children,
22
- _a$type = _a.type,
23
- type = _a$type === void 0 ? 'secondary' : _a$type,
22
+ type = _a.type,
24
23
  _onClick = _a.onClick,
25
24
  rest = __rest(_a, ["prefixCls", "className", "children", "type", "onClick"]);
26
25
  var _useFormContext = useFormContext(),
@@ -29,7 +28,8 @@ var FormReset = /*#__PURE__*/forwardRef(function (_a, ref) {
29
28
  return /*#__PURE__*/React.createElement(Button, Object.assign({
30
29
  ref: ref,
31
30
  className: cls,
32
- type: type
31
+ type: type,
32
+ appearance: "line"
33
33
  }, rest, {
34
34
  onClick: function onClick() {
35
35
  resetForm();
@@ -8,6 +8,6 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import __styleInject__ from '@hi-ui/style-inject';
11
- var css_248z = ".hi-v4-form {max-width: 100%;position: relative;}.hi-v4-form fieldset {margin: 0;padding: 0;border: 0;}.hi-v4-form fieldset + fieldset {margin-top: 16px;}.hi-v4-form legend {margin: 0 0 16px;color: var(--hi-v4-color-gray-800, #1f2937);}.hi-v4-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap;-webkit-column-gap: var(--hi-v4-spacing-10, 20px);-moz-column-gap: var(--hi-v4-spacing-10, 20px);column-gap: var(--hi-v4-spacing-10, 20px);}.hi-v4-form--placement-horizontal .hi-v4-form-label__indent {min-height: var(--hi-v4-height-8, 32px);}.hi-v4-form-label {font-size: var(--hi-v4-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;}.hi-v4-form-label__content {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-form-label--placement-top > .hi-v4-form-label__content {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;padding-right: 0;}.hi-v4-form-label__content__text, .hi-v4-form-label__content__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v4-color-gray-800, #1f2937);overflow-wrap: break-word;}.hi-v4-form-label__content__text {padding-right: var(--hi-v4-spacing-6, 12px);min-height: var(--hi-v4-height-8, 32px);line-height: var(--hi-v4-height-8, 32px);}.hi-v4-form-label--placement-left > .hi-v4-form-label__content > .hi-v4-form-label__content__text {text-align: left;}.hi-v4-form-label--placement-right > .hi-v4-form-label__content > .hi-v4-form-label__content__text {text-align: right;}.hi-v4-form-label--placement-top > .hi-v4-form-label__content > .hi-v4-form-label__content__text {min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v4-spacing-4, 8px);}.hi-v4-form-label--required > .hi-v4-form-label__content > .hi-v4-form-label__content__text::before {margin-right: var(--hi-v4-spacing-2, 4px);content: \"*\";color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));}.hi-v4-form-label__content__control {min-width: 1px;}.hi-v4-form-message {display: block;font-size: var(--hi-v4-text-size-md, 0.875rem);min-height: 24px;padding: 2px 0;-webkit-box-sizing: border-box;box-sizing: border-box;line-height: 20px;-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));-webkit-transition: all 0.3s;transition: all 0.3s;}.hi-v4-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0);}.hi-v4-form-item {position: relative;}";
11
+ var css_248z = ".hi-v5-form {max-width: 100%;position: relative;}.hi-v5-form fieldset {margin: 0;padding: 0;border: 0;}.hi-v5-form fieldset + fieldset {margin-top: 16px;}.hi-v5-form legend {margin: 0 0 16px;color: var(--hi-v5-color-gray-800, #1d1e26);}.hi-v5-form--placement-horizontal {display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-wrap: wrap;flex-wrap: wrap;-webkit-column-gap: var(--hi-v5-spacing-10, 20px);-moz-column-gap: var(--hi-v5-spacing-10, 20px);column-gap: var(--hi-v5-spacing-10, 20px);}.hi-v5-form--placement-horizontal .hi-v5-form-label__indent {min-height: var(--hi-v5-height-8, 32px);}.hi-v5-form-label {font-size: var(--hi-v5-text-size-md, 0.875rem);-webkit-box-sizing: border-box;box-sizing: border-box;margin-right: 0;}.hi-v5-form-label__content {display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v5-form-label--placement-top > .hi-v5-form-label__content {text-align: left;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;padding-right: 0;}.hi-v5-form-label__content__text, .hi-v5-form-label__content__indent {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-sizing: border-box;box-sizing: border-box;vertical-align: top;color: var(--hi-v5-color-gray-800, #1d1e26);overflow-wrap: break-word;}.hi-v5-form-label__content__text {padding-right: var(--hi-v5-spacing-6, 12px);min-height: var(--hi-v5-height-8, 32px);line-height: var(--hi-v5-height-8, 32px);}.hi-v5-form-label--placement-left > .hi-v5-form-label__content > .hi-v5-form-label__content__text {text-align: left;}.hi-v5-form-label--placement-right > .hi-v5-form-label__content > .hi-v5-form-label__content__text {text-align: right;}.hi-v5-form-label--placement-top > .hi-v5-form-label__content > .hi-v5-form-label__content__text {min-height: 22px;line-height: 22px;padding-right: 0;margin-bottom: var(--hi-v5-spacing-3, 6px);}.hi-v5-form-label--required > .hi-v5-form-label__content > .hi-v5-form-label__content__text::after {margin-left: var(--hi-v5-spacing-2, 4px);content: \"*\";color: var(--hi-v5-color-danger-500, var(--hi-v5-color-red-500, #fa4646));}.hi-v5-form-label__content__control {min-width: 1px;min-height: var(--hi-v5-height-8, 32px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v5-form-message {-webkit-box-sizing: content-box;box-sizing: content-box;display: block;font-size: var(--hi-v5-text-size-sm, 0.75rem);line-height: var(--hi-v5-text-lineheight-sm, 1.25rem);min-height: var(--hi-v5-height-5, 20px);padding-bottom: var(--hi-v5-spacing-2, 4px);-webkit-transform: translateY(-10%);transform: translateY(-10%);opacity: 0;color: var(--hi-v5-color-danger-500, var(--hi-v5-color-red-500, #fa4646));-webkit-transition: all 0.3s;transition: all 0.3s;}.hi-v5-form-message--show {opacity: 1;-webkit-transform: translateY(0);transform: translateY(0);}.hi-v5-form-item {position: relative;}";
12
12
  __styleInject__(css_248z);
13
13
  export { css_248z as default };
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { useMemo, useCallback, useEffect } from 'react';
11
11
  import { useFormContext } from './context.js';
12
- import { isArrayNonEmpty } from '@hi-ui/type-assertion';
12
+ import { isArrayNonEmpty, isNullish } from '@hi-ui/type-assertion';
13
13
  import Validater from 'async-validator';
14
14
  import { normalizeArray } from '@hi-ui/array-utils';
15
15
  import { stringify, isValidField } from './utils/index.js';
@@ -51,6 +51,9 @@ var useFormField = function useFormField(props) {
51
51
  // TODO: rules 处理成 Async Validate 的指定结构
52
52
  var fieldMD5 = stringify(field);
53
53
  var modifiedFieldRules = fieldRules.map(function (rule) {
54
+ if (rule.message === null || rule.message === '') {
55
+ rule.message = undefined;
56
+ }
54
57
  // 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
55
58
  // issue:https://github.com/XiaoMi/hiui/issues/2931
56
59
  if (rule.validator) {
@@ -67,7 +70,17 @@ var useFormField = function useFormField(props) {
67
70
  } else return Object.assign({}, rule);
68
71
  });
69
72
  var validater = new Validater((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
70
- return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
73
+ var valueToValidate = value;
74
+ if (valueType === 'number') {
75
+ if (isNullish(value) || value === '') {
76
+ valueToValidate = value;
77
+ } else if (isNaN(value)) {
78
+ valueToValidate = value;
79
+ } else {
80
+ valueToValidate = Number(value);
81
+ }
82
+ }
83
+ return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueToValidate, _validater$validate), {
71
84
  firstFields: true
72
85
  });
73
86
  }, [fieldRules, field, valueType]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/form",
3
- "version": "4.3.2",
3
+ "version": "5.0.0-alpha.0",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -19,6 +19,7 @@
19
19
  "typings": "lib/types/index.d.ts",
20
20
  "exports": {
21
21
  ".": {
22
+ "types": "./lib/types/index.d.ts",
22
23
  "require": "./lib/cjs/index.js",
23
24
  "default": "./lib/esm/index.js"
24
25
  }
@@ -43,26 +44,26 @@
43
44
  "url": "https://github.com/XiaoMi/hiui/issues"
44
45
  },
45
46
  "dependencies": {
46
- "@hi-ui/array-utils": "^4.0.5",
47
- "@hi-ui/button": "^4.0.10",
48
- "@hi-ui/classname": "^4.0.5",
49
- "@hi-ui/dom-utils": "^4.0.7",
50
- "@hi-ui/env": "^4.0.7",
51
- "@hi-ui/func-utils": "^4.0.4",
52
- "@hi-ui/object-utils": "^4.0.4",
53
- "@hi-ui/type-assertion": "^4.0.4",
54
- "@hi-ui/use-latest": "^4.0.4",
47
+ "@hi-ui/array-utils": "^5.0.0-alpha.0",
48
+ "@hi-ui/button": "^5.0.0-alpha.0",
49
+ "@hi-ui/classname": "^5.0.0-alpha.0",
50
+ "@hi-ui/dom-utils": "^5.0.0-alpha.0",
51
+ "@hi-ui/env": "^5.0.0-alpha.0",
52
+ "@hi-ui/func-utils": "^5.0.0-alpha.0",
53
+ "@hi-ui/object-utils": "^5.0.0-alpha.0",
54
+ "@hi-ui/type-assertion": "^5.0.0-alpha.0",
55
+ "@hi-ui/use-latest": "^5.0.0-alpha.0",
55
56
  "async-validator": "^4.0.7",
56
57
  "scroll-into-view-if-needed": "^3.1.0"
57
58
  },
58
59
  "peerDependencies": {
59
- "@hi-ui/core": ">=4.0.8",
60
+ "@hi-ui/core": ">=5.0.0-alpha.0",
60
61
  "react": ">=16.8.6",
61
62
  "react-dom": ">=16.8.6"
62
63
  },
63
64
  "devDependencies": {
64
- "@hi-ui/core": "^4.0.8",
65
- "@hi-ui/core-css": "^4.1.5",
65
+ "@hi-ui/core": "^5.0.0-alpha.0",
66
+ "@hi-ui/core-css": "^5.0.0-alpha.0",
66
67
  "react": "^17.0.1",
67
68
  "react-dom": "^17.0.1"
68
69
  }