@hi-ui/form 4.1.7-alpha.0 → 4.2.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 +14 -11
- package/lib/cjs/Form.js +6 -3
- package/lib/cjs/FormLabel.js +7 -4
- package/lib/esm/Form.js +6 -3
- package/lib/esm/FormLabel.js +7 -4
- package/lib/types/Form.d.ts +5 -0
- package/lib/types/FormLabel.d.ts +4 -0
- package/lib/types/context.d.ts +1 -0
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
# @hi-ui/form
|
|
2
2
|
|
|
3
|
-
## 4.
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2818](https://github.com/XiaoMi/hiui/pull/2818) [`39d555903`](https://github.com/XiaoMi/hiui/commit/39d555903c81207d5d2bf34a2a5d1942152dcee0) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: add showValidateMessage api
|
|
8
|
+
|
|
9
|
+
## 4.1.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
|
-
- 1a00f9fc4
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- @hi-ui/
|
|
11
|
-
- @hi-ui/
|
|
12
|
-
- @hi-ui/
|
|
13
|
-
- @hi-ui/
|
|
14
|
-
- @hi-ui/core@4.0.9-alpha.0
|
|
15
|
-
- @hi-ui/object-utils@4.0.5-alpha.0
|
|
16
|
-
- @hi-ui/func-utils@4.0.5-alpha.0
|
|
13
|
+
- [#2791](https://github.com/XiaoMi/hiui/pull/2791) [`1a00f9fc4`](https://github.com/XiaoMi/hiui/commit/1a00f9fc4a44619059d7852e846b54fedbd56715) Thanks [@zyprepare](https://github.com/zyprepare)! - build: style-inject(node 环境下有问题) 替换为 @hi-ui/style-inject
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`1a00f9fc4`](https://github.com/XiaoMi/hiui/commit/1a00f9fc4a44619059d7852e846b54fedbd56715)]:
|
|
16
|
+
- @hi-ui/env@4.0.5
|
|
17
|
+
- @hi-ui/button@4.0.10
|
|
18
|
+
- @hi-ui/array-utils@4.0.5
|
|
19
|
+
- @hi-ui/classname@4.0.5
|
|
17
20
|
|
|
18
21
|
## 4.1.6
|
|
19
22
|
|
package/lib/cjs/Form.js
CHANGED
|
@@ -51,7 +51,9 @@ var Form = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
51
51
|
showRequiredOnValidateRequired = _a$showRequiredOnVali === void 0 ? false : _a$showRequiredOnVali,
|
|
52
52
|
_a$showColon = _a.showColon,
|
|
53
53
|
showColon = _a$showColon === void 0 ? true : _a$showColon,
|
|
54
|
-
|
|
54
|
+
_a$showValidateMessag = _a.showValidateMessage,
|
|
55
|
+
showValidateMessage = _a$showValidateMessag === void 0 ? true : _a$showValidateMessag,
|
|
56
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "innerRef", "labelWidth", "labelPlacement", "placement", "contentPosition", "showRequiredOnValidateRequired", "showColon", "showValidateMessage"]);
|
|
55
57
|
var formContext = useForm.useForm(rest);
|
|
56
58
|
var getRootProps = formContext.getRootProps;
|
|
57
59
|
// @ts-ignore
|
|
@@ -76,11 +78,12 @@ var Form = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
76
78
|
labelPlacement: labelPlacement,
|
|
77
79
|
showColon: showColon,
|
|
78
80
|
contentPosition: contentPosition,
|
|
79
|
-
showRequiredOnValidateRequired: showRequiredOnValidateRequired
|
|
81
|
+
showRequiredOnValidateRequired: showRequiredOnValidateRequired,
|
|
82
|
+
showValidateMessage: showValidateMessage
|
|
80
83
|
}, formContext), {
|
|
81
84
|
prefixCls: prefixCls
|
|
82
85
|
});
|
|
83
|
-
}, [labelWidth,
|
|
86
|
+
}, [labelWidth, labelPlacement, showColon, contentPosition, showRequiredOnValidateRequired, showValidateMessage, formContext, prefixCls]);
|
|
84
87
|
var cls = classname.cx(prefixCls, className, placement && prefixCls + "--placement-" + placement);
|
|
85
88
|
return /*#__PURE__*/(
|
|
86
89
|
// @ts-ignore
|
package/lib/cjs/FormLabel.js
CHANGED
|
@@ -34,7 +34,8 @@ var FormLabel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
34
34
|
labelWidthContext = _useFormContext.labelWidth,
|
|
35
35
|
labelPlacementContext = _useFormContext.labelPlacement,
|
|
36
36
|
showColonContext = _useFormContext.showColon,
|
|
37
|
-
contentPositionContext = _useFormContext.contentPosition
|
|
37
|
+
contentPositionContext = _useFormContext.contentPosition,
|
|
38
|
+
showValidateMessageContext = _useFormContext.showValidateMessage;
|
|
38
39
|
var _props$prefixCls = props.prefixCls,
|
|
39
40
|
prefixCls = _props$prefixCls === void 0 ? _prefix : _props$prefixCls,
|
|
40
41
|
_props$role = props.role,
|
|
@@ -54,7 +55,9 @@ var FormLabel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
54
55
|
_props$labelPlacement = props.labelPlacement,
|
|
55
56
|
labelPlacement = _props$labelPlacement === void 0 ? labelPlacementContext : _props$labelPlacement,
|
|
56
57
|
formMessage = props.formMessage,
|
|
57
|
-
|
|
58
|
+
_props$showValidateMe = props.showValidateMessage,
|
|
59
|
+
showValidateMessageProp = _props$showValidateMe === void 0 ? showValidateMessageContext : _props$showValidateMe,
|
|
60
|
+
rest = tslib.__rest(props, ["prefixCls", "role", "className", "style", "children", "label", "required", "labelWidth", "showColon", "contentPosition", "labelPlacement", "formMessage", "showValidateMessage"]);
|
|
58
61
|
var _useMemo = React.useMemo(function () {
|
|
59
62
|
if (labelPlacement === 'top') return {
|
|
60
63
|
labelWidth: '100%',
|
|
@@ -111,11 +114,11 @@ var FormLabel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
111
114
|
style: {
|
|
112
115
|
width: controlWidth
|
|
113
116
|
}
|
|
114
|
-
}, children)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
117
|
+
}, children)), showValidateMessageProp && ( /*#__PURE__*/React__default["default"].createElement("div", {
|
|
115
118
|
style: {
|
|
116
119
|
paddingLeft: "calc(100% - " + controlWidth + ")"
|
|
117
120
|
}
|
|
118
|
-
}, formMessage));
|
|
121
|
+
}, formMessage)));
|
|
119
122
|
});
|
|
120
123
|
if (env.__DEV__) {
|
|
121
124
|
FormLabel.displayName = 'FormLabel';
|
package/lib/esm/Form.js
CHANGED
|
@@ -39,7 +39,9 @@ var Form = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
39
39
|
showRequiredOnValidateRequired = _a$showRequiredOnVali === void 0 ? false : _a$showRequiredOnVali,
|
|
40
40
|
_a$showColon = _a.showColon,
|
|
41
41
|
showColon = _a$showColon === void 0 ? true : _a$showColon,
|
|
42
|
-
|
|
42
|
+
_a$showValidateMessag = _a.showValidateMessage,
|
|
43
|
+
showValidateMessage = _a$showValidateMessag === void 0 ? true : _a$showValidateMessag,
|
|
44
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "children", "innerRef", "labelWidth", "labelPlacement", "placement", "contentPosition", "showRequiredOnValidateRequired", "showColon", "showValidateMessage"]);
|
|
43
45
|
var formContext = useForm(rest);
|
|
44
46
|
var getRootProps = formContext.getRootProps;
|
|
45
47
|
// @ts-ignore
|
|
@@ -64,11 +66,12 @@ var Form = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
64
66
|
labelPlacement: labelPlacement,
|
|
65
67
|
showColon: showColon,
|
|
66
68
|
contentPosition: contentPosition,
|
|
67
|
-
showRequiredOnValidateRequired: showRequiredOnValidateRequired
|
|
69
|
+
showRequiredOnValidateRequired: showRequiredOnValidateRequired,
|
|
70
|
+
showValidateMessage: showValidateMessage
|
|
68
71
|
}, formContext), {
|
|
69
72
|
prefixCls: prefixCls
|
|
70
73
|
});
|
|
71
|
-
}, [labelWidth,
|
|
74
|
+
}, [labelWidth, labelPlacement, showColon, contentPosition, showRequiredOnValidateRequired, showValidateMessage, formContext, prefixCls]);
|
|
72
75
|
var cls = cx(prefixCls, className, placement && prefixCls + "--placement-" + placement);
|
|
73
76
|
return /*#__PURE__*/(
|
|
74
77
|
// @ts-ignore
|
package/lib/esm/FormLabel.js
CHANGED
|
@@ -22,7 +22,8 @@ var FormLabel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
22
22
|
labelWidthContext = _useFormContext.labelWidth,
|
|
23
23
|
labelPlacementContext = _useFormContext.labelPlacement,
|
|
24
24
|
showColonContext = _useFormContext.showColon,
|
|
25
|
-
contentPositionContext = _useFormContext.contentPosition
|
|
25
|
+
contentPositionContext = _useFormContext.contentPosition,
|
|
26
|
+
showValidateMessageContext = _useFormContext.showValidateMessage;
|
|
26
27
|
var _props$prefixCls = props.prefixCls,
|
|
27
28
|
prefixCls = _props$prefixCls === void 0 ? _prefix : _props$prefixCls,
|
|
28
29
|
_props$role = props.role,
|
|
@@ -42,7 +43,9 @@ var FormLabel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
42
43
|
_props$labelPlacement = props.labelPlacement,
|
|
43
44
|
labelPlacement = _props$labelPlacement === void 0 ? labelPlacementContext : _props$labelPlacement,
|
|
44
45
|
formMessage = props.formMessage,
|
|
45
|
-
|
|
46
|
+
_props$showValidateMe = props.showValidateMessage,
|
|
47
|
+
showValidateMessageProp = _props$showValidateMe === void 0 ? showValidateMessageContext : _props$showValidateMe,
|
|
48
|
+
rest = __rest(props, ["prefixCls", "role", "className", "style", "children", "label", "required", "labelWidth", "showColon", "contentPosition", "labelPlacement", "formMessage", "showValidateMessage"]);
|
|
46
49
|
var _useMemo = useMemo(function () {
|
|
47
50
|
if (labelPlacement === 'top') return {
|
|
48
51
|
labelWidth: '100%',
|
|
@@ -99,11 +102,11 @@ var FormLabel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
99
102
|
style: {
|
|
100
103
|
width: controlWidth
|
|
101
104
|
}
|
|
102
|
-
}, children)), /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
}, children)), showValidateMessageProp && ( /*#__PURE__*/React.createElement("div", {
|
|
103
106
|
style: {
|
|
104
107
|
paddingLeft: "calc(100% - " + controlWidth + ")"
|
|
105
108
|
}
|
|
106
|
-
}, formMessage));
|
|
109
|
+
}, formMessage)));
|
|
107
110
|
});
|
|
108
111
|
if (__DEV__) {
|
|
109
112
|
FormLabel.displayName = 'FormLabel';
|
package/lib/types/Form.d.ts
CHANGED
|
@@ -36,4 +36,9 @@ export interface FormProps<Values = Record<string, any>> extends Omit<HiBaseHTML
|
|
|
36
36
|
* FormItem 开启 filed 的 required 校验时,展示红色星号
|
|
37
37
|
*/
|
|
38
38
|
showRequiredOnValidateRequired?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 是否显示校验提示
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
showValidateMessage?: boolean;
|
|
39
44
|
}
|
package/lib/types/FormLabel.d.ts
CHANGED
package/lib/types/context.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface FormContextProps extends UseFormReturn {
|
|
|
6
6
|
contentPosition: 'top' | 'center' | 'bottom';
|
|
7
7
|
showColon: boolean;
|
|
8
8
|
showRequiredOnValidateRequired: boolean;
|
|
9
|
+
showValidateMessage: boolean;
|
|
9
10
|
prefixCls: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const FormProvider: React.Provider<Omit<FormContextProps, "rootProps"> | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/form",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
44
44
|
},
|
|
45
45
|
"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.
|
|
50
|
-
"@hi-ui/env": "^4.0.5
|
|
51
|
-
"@hi-ui/func-utils": "^4.0.
|
|
52
|
-
"@hi-ui/object-utils": "^4.0.
|
|
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.5",
|
|
51
|
+
"@hi-ui/func-utils": "^4.0.4",
|
|
52
|
+
"@hi-ui/object-utils": "^4.0.4",
|
|
53
53
|
"@hi-ui/type-assertion": "^4.0.4",
|
|
54
54
|
"@hi-ui/use-latest": "^4.0.4",
|
|
55
55
|
"async-validator": "^4.0.7"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@hi-ui/core": ">=4.0.
|
|
58
|
+
"@hi-ui/core": ">=4.0.8",
|
|
59
59
|
"react": ">=16.8.6",
|
|
60
60
|
"react-dom": ">=16.8.6"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@hi-ui/core": "^4.0.
|
|
63
|
+
"@hi-ui/core": "^4.0.8",
|
|
64
64
|
"@hi-ui/core-css": "^4.1.5",
|
|
65
65
|
"react": "^17.0.1",
|
|
66
66
|
"react-dom": "^17.0.1"
|