@hi-ui/form 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @hi-ui/form
|
|
2
2
|
|
|
3
|
+
## 4.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2933](https://github.com/XiaoMi/hiui/pull/2933) [`369cdf935`](https://github.com/XiaoMi/hiui/commit/369cdf935fb4e3a81478dcbd8e199c1a7cac1875) Thanks [@xiamiao1121](https://github.com/xiamiao1121)! - fix: 修复 validator 回调中第一个参数带有多余的引号
|
|
8
|
+
|
|
9
|
+
## 4.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#2842](https://github.com/XiaoMi/hiui/pull/2842) [`3dc8c1556`](https://github.com/XiaoMi/hiui/commit/3dc8c155674bb8d702187cc4a33e684d22f04bf6) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复标签顶对齐时样式问题
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`3afbf239e`](https://github.com/XiaoMi/hiui/commit/3afbf239e816ede48d6a85cbd99b6b099b8c8eb3)]:
|
|
16
|
+
- @hi-ui/env@4.0.7
|
|
17
|
+
|
|
3
18
|
## 4.2.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -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 {
|
|
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;}";
|
|
16
16
|
var __styleInject__ = require('@hi-ui/style-inject')["default"];
|
|
17
17
|
__styleInject__(css_248z);
|
|
18
18
|
exports["default"] = css_248z;
|
|
@@ -62,7 +62,23 @@ var useFormField = function useFormField(props) {
|
|
|
62
62
|
}
|
|
63
63
|
// TODO: rules 处理成 Async Validate 的指定结构
|
|
64
64
|
var fieldMD5 = index.stringify(field);
|
|
65
|
-
var
|
|
65
|
+
var modifiedFieldRules = fieldRules.map(function (rule) {
|
|
66
|
+
// 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
|
|
67
|
+
// issue:https://github.com/XiaoMi/hiui/issues/2931
|
|
68
|
+
if (rule.validator) {
|
|
69
|
+
return Object.assign(Object.assign({}, rule), {
|
|
70
|
+
validator: function validator(validatorRule, value, callback, source, options) {
|
|
71
|
+
var field = validatorRule.field.replace(/"/g, '');
|
|
72
|
+
var fullField = validatorRule.fullField.replace(/"/g, '');
|
|
73
|
+
rule.validator(Object.assign(Object.assign({}, validatorRule), {
|
|
74
|
+
field: field,
|
|
75
|
+
fullField: fullField
|
|
76
|
+
}), value, callback, source, options);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else return Object.assign({}, rule);
|
|
80
|
+
});
|
|
81
|
+
var validater = new Validater__default["default"]((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
|
|
66
82
|
return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
|
|
67
83
|
firstFields: true
|
|
68
84
|
});
|
|
@@ -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 {
|
|
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;}";
|
|
12
12
|
__styleInject__(css_248z);
|
|
13
13
|
export { css_248z as default };
|
|
@@ -50,7 +50,23 @@ var useFormField = function useFormField(props) {
|
|
|
50
50
|
}
|
|
51
51
|
// TODO: rules 处理成 Async Validate 的指定结构
|
|
52
52
|
var fieldMD5 = stringify(field);
|
|
53
|
-
var
|
|
53
|
+
var modifiedFieldRules = fieldRules.map(function (rule) {
|
|
54
|
+
// 重写 rule 的 validator 函数,正则匹配 validatorRule 中的 field 和 fullField,消除 field 和 fullField 中的双引号
|
|
55
|
+
// issue:https://github.com/XiaoMi/hiui/issues/2931
|
|
56
|
+
if (rule.validator) {
|
|
57
|
+
return Object.assign(Object.assign({}, rule), {
|
|
58
|
+
validator: function validator(validatorRule, value, callback, source, options) {
|
|
59
|
+
var field = validatorRule.field.replace(/"/g, '');
|
|
60
|
+
var fullField = validatorRule.fullField.replace(/"/g, '');
|
|
61
|
+
rule.validator(Object.assign(Object.assign({}, validatorRule), {
|
|
62
|
+
field: field,
|
|
63
|
+
fullField: fullField
|
|
64
|
+
}), value, callback, source, options);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
} else return Object.assign({}, rule);
|
|
68
|
+
});
|
|
69
|
+
var validater = new Validater((_Validater = {}, _Validater[fieldMD5] = modifiedFieldRules, _Validater));
|
|
54
70
|
return validater.validate((_validater$validate = {}, _validater$validate[fieldMD5] = valueType !== 'number' || value === '' ? value : isNaN(value) ? value : Number(value), _validater$validate), {
|
|
55
71
|
firstFields: true
|
|
56
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/form",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@hi-ui/button": "^4.0.10",
|
|
48
48
|
"@hi-ui/classname": "^4.0.5",
|
|
49
49
|
"@hi-ui/dom-utils": "^4.0.7",
|
|
50
|
-
"@hi-ui/env": "^4.0.
|
|
50
|
+
"@hi-ui/env": "^4.0.7",
|
|
51
51
|
"@hi-ui/func-utils": "^4.0.4",
|
|
52
52
|
"@hi-ui/object-utils": "^4.0.4",
|
|
53
53
|
"@hi-ui/type-assertion": "^4.0.4",
|