@hw-component/form 1.9.25 → 1.9.27
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/Switch/index.js +6 -4
- package/es/index.css +15 -2
- package/lib/Switch/index.js +6 -4
- package/lib/index.css +15 -2
- package/package.json +1 -1
- package/src/components/Input/index.less +13 -1
- package/src/components/Switch/index.less +5 -3
- package/src/components/Switch/index.tsx +7 -6
- package/src/pages/Form/index.tsx +21 -8
package/es/Switch/index.js
CHANGED
|
@@ -29,7 +29,8 @@ var Index = function Index(_ref) {
|
|
|
29
29
|
_useMatchConfigProps$ = _useMatchConfigProps.valueSwitchMap,
|
|
30
30
|
valueSwitchMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$;
|
|
31
31
|
var switchClassName = useClassName("hw-switch");
|
|
32
|
-
var
|
|
32
|
+
var switchBefore = useClassName("hw-switch-before");
|
|
33
|
+
var switchAfter = useClassName("hw-switch-after");
|
|
33
34
|
var swChecked = useMemo(function () {
|
|
34
35
|
var open = valueSwitchMap.open;
|
|
35
36
|
return value === open;
|
|
@@ -63,15 +64,16 @@ var Index = function Index(_ref) {
|
|
|
63
64
|
return jsxs("div", {
|
|
64
65
|
style: style,
|
|
65
66
|
className: switchClassName,
|
|
66
|
-
children: [jsx("span", {
|
|
67
|
+
children: [beforeText && jsx("span", {
|
|
68
|
+
className: switchBefore,
|
|
67
69
|
children: beforeText
|
|
68
70
|
}), jsx(Switch, _objectSpread({
|
|
69
71
|
checked: swChecked,
|
|
70
72
|
checkedChildren: checkedChildren,
|
|
71
73
|
unCheckedChildren: unCheckedChildren,
|
|
72
|
-
className: switchBody,
|
|
73
74
|
onChange: change
|
|
74
|
-
}, props)), jsx("span", {
|
|
75
|
+
}, props)), children && jsx("span", {
|
|
76
|
+
className: switchAfter,
|
|
75
77
|
children: children
|
|
76
78
|
})]
|
|
77
79
|
});
|
package/es/index.css
CHANGED
|
@@ -125,6 +125,17 @@
|
|
|
125
125
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
126
126
|
overflow: visible;
|
|
127
127
|
}
|
|
128
|
+
.ant-form-item-has-error .ant-hw-input-group-body {
|
|
129
|
+
border-color: #ff4d4f !important;
|
|
130
|
+
}
|
|
131
|
+
.ant-form-item-has-error .ant-hw-input-group-active {
|
|
132
|
+
border-color: #ff4d4f !important;
|
|
133
|
+
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) !important;
|
|
134
|
+
}
|
|
135
|
+
.ant-form-item-has-error .ant-hw-input-group-addon {
|
|
136
|
+
color: #ff4d4f;
|
|
137
|
+
border-color: #ff4d4f !important;
|
|
138
|
+
}
|
|
128
139
|
.ant-hw-input-group {
|
|
129
140
|
display: -webkit-box !important;
|
|
130
141
|
display: -webkit-flex !important;
|
|
@@ -227,7 +238,9 @@
|
|
|
227
238
|
-ms-flex-align: center;
|
|
228
239
|
align-items: center;
|
|
229
240
|
}
|
|
230
|
-
.ant-hw-switch .ant-hw-switch-
|
|
231
|
-
margin-left: 4px;
|
|
241
|
+
.ant-hw-switch .ant-hw-switch-before {
|
|
232
242
|
margin-right: 4px;
|
|
233
243
|
}
|
|
244
|
+
.ant-hw-switch .ant-hw-switch-after {
|
|
245
|
+
margin-left: 4px;
|
|
246
|
+
}
|
package/lib/Switch/index.js
CHANGED
|
@@ -32,7 +32,8 @@ var Index = function Index(_ref) {
|
|
|
32
32
|
_useMatchConfigProps$ = _useMatchConfigProps.valueSwitchMap,
|
|
33
33
|
valueSwitchMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$;
|
|
34
34
|
var switchClassName = index.useClassName("hw-switch");
|
|
35
|
-
var
|
|
35
|
+
var switchBefore = index.useClassName("hw-switch-before");
|
|
36
|
+
var switchAfter = index.useClassName("hw-switch-after");
|
|
36
37
|
var swChecked = React.useMemo(function () {
|
|
37
38
|
var open = valueSwitchMap.open;
|
|
38
39
|
return value === open;
|
|
@@ -66,15 +67,16 @@ var Index = function Index(_ref) {
|
|
|
66
67
|
return jsxRuntime.jsxs("div", {
|
|
67
68
|
style: style,
|
|
68
69
|
className: switchClassName,
|
|
69
|
-
children: [jsxRuntime.jsx("span", {
|
|
70
|
+
children: [beforeText && jsxRuntime.jsx("span", {
|
|
71
|
+
className: switchBefore,
|
|
70
72
|
children: beforeText
|
|
71
73
|
}), jsxRuntime.jsx(antd.Switch, _objectSpread({
|
|
72
74
|
checked: swChecked,
|
|
73
75
|
checkedChildren: checkedChildren,
|
|
74
76
|
unCheckedChildren: unCheckedChildren,
|
|
75
|
-
className: switchBody,
|
|
76
77
|
onChange: change
|
|
77
|
-
}, props)), jsxRuntime.jsx("span", {
|
|
78
|
+
}, props)), children && jsxRuntime.jsx("span", {
|
|
79
|
+
className: switchAfter,
|
|
78
80
|
children: children
|
|
79
81
|
})]
|
|
80
82
|
});
|
package/lib/index.css
CHANGED
|
@@ -125,6 +125,17 @@
|
|
|
125
125
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
126
126
|
overflow: visible;
|
|
127
127
|
}
|
|
128
|
+
.ant-form-item-has-error .ant-hw-input-group-body {
|
|
129
|
+
border-color: #ff4d4f !important;
|
|
130
|
+
}
|
|
131
|
+
.ant-form-item-has-error .ant-hw-input-group-active {
|
|
132
|
+
border-color: #ff4d4f !important;
|
|
133
|
+
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) !important;
|
|
134
|
+
}
|
|
135
|
+
.ant-form-item-has-error .ant-hw-input-group-addon {
|
|
136
|
+
color: #ff4d4f;
|
|
137
|
+
border-color: #ff4d4f !important;
|
|
138
|
+
}
|
|
128
139
|
.ant-hw-input-group {
|
|
129
140
|
display: -webkit-box !important;
|
|
130
141
|
display: -webkit-flex !important;
|
|
@@ -227,7 +238,9 @@
|
|
|
227
238
|
-ms-flex-align: center;
|
|
228
239
|
align-items: center;
|
|
229
240
|
}
|
|
230
|
-
.ant-hw-switch .ant-hw-switch-
|
|
231
|
-
margin-left: 4px;
|
|
241
|
+
.ant-hw-switch .ant-hw-switch-before {
|
|
232
242
|
margin-right: 4px;
|
|
233
243
|
}
|
|
244
|
+
.ant-hw-switch .ant-hw-switch-after {
|
|
245
|
+
margin-left: 4px;
|
|
246
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
@import "../styles/local.less";
|
|
2
2
|
@all-input-group: ~"@{ant-prefix}-hw-input-group";
|
|
3
|
-
|
|
3
|
+
.@{ant-prefix}-form-item-has-error {
|
|
4
|
+
.@{all-input-group}-body {
|
|
5
|
+
border-color:#ff4d4f !important;
|
|
6
|
+
}
|
|
7
|
+
.@{all-input-group}-active {
|
|
8
|
+
border-color: #ff4d4f !important;
|
|
9
|
+
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) !important;
|
|
10
|
+
}
|
|
11
|
+
.@{all-input-group}-addon{
|
|
12
|
+
color:#ff4d4f;
|
|
13
|
+
border-color:#ff4d4f !important;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
4
16
|
.@{all-input-group} {
|
|
5
17
|
display: flex !important;
|
|
6
18
|
width: 100%;
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: row;
|
|
6
6
|
align-items: center;
|
|
7
|
-
.@{ant-prefix}-hw-switch-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
.@{ant-prefix}-hw-switch-before{
|
|
8
|
+
margin-right: 4px;
|
|
9
|
+
}
|
|
10
|
+
.@{ant-prefix}-hw-switch-after{
|
|
11
|
+
margin-left: 4px;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SwitchProps } from "antd";
|
|
2
|
-
import {
|
|
2
|
+
import {Switch } from "antd";
|
|
3
3
|
import React, { useMemo } from "react";
|
|
4
4
|
import {useClassName, useMatchConfigProps} from "../hooks";
|
|
5
5
|
import type { ValueSwitchMapModal } from "../modal";
|
|
@@ -29,7 +29,9 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
29
29
|
valueSwitchMap: propsValueSwitchMap,
|
|
30
30
|
});
|
|
31
31
|
const switchClassName=useClassName("hw-switch");
|
|
32
|
-
const
|
|
32
|
+
const switchBefore=useClassName("hw-switch-before");
|
|
33
|
+
const switchAfter=useClassName("hw-switch-after")
|
|
34
|
+
|
|
33
35
|
const swChecked = useMemo(() => {
|
|
34
36
|
const { open } = valueSwitchMap;
|
|
35
37
|
return value === open;
|
|
@@ -64,18 +66,17 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
64
66
|
});
|
|
65
67
|
return (
|
|
66
68
|
<div style={style} className={switchClassName}>
|
|
67
|
-
|
|
69
|
+
{beforeText&&<span className={switchBefore}>
|
|
68
70
|
{beforeText}
|
|
69
|
-
</span>
|
|
71
|
+
</span>}
|
|
70
72
|
<Switch
|
|
71
73
|
checked={swChecked}
|
|
72
74
|
checkedChildren={checkedChildren}
|
|
73
75
|
unCheckedChildren={unCheckedChildren}
|
|
74
|
-
className={switchBody}
|
|
75
76
|
onChange={change}
|
|
76
77
|
{...props}
|
|
77
78
|
/>
|
|
78
|
-
<span >{children}</span>
|
|
79
|
+
{children&& <span className={switchAfter}>{children}</span>}
|
|
79
80
|
</div>
|
|
80
81
|
);
|
|
81
82
|
};
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -70,18 +70,34 @@ const formData = (options) => {
|
|
|
70
70
|
{
|
|
71
71
|
name: "name",
|
|
72
72
|
label: "输入框",
|
|
73
|
+
rules:[{validator:()=>{
|
|
74
|
+
return Promise.reject(new Error("错误"))
|
|
75
|
+
}}],
|
|
73
76
|
itemProps: {
|
|
74
|
-
|
|
77
|
+
addonBefore:"前面",
|
|
78
|
+
addonAfter:"后面"
|
|
75
79
|
}
|
|
76
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: "inputNumberGroup",
|
|
83
|
+
label: "输入框",
|
|
84
|
+
rules:[{validator:()=>{
|
|
85
|
+
return Promise.reject(new Error("错误"))
|
|
86
|
+
}}],
|
|
87
|
+
type: "inputNumberGroup",
|
|
88
|
+
itemProps: {
|
|
89
|
+
addonBefore:"前面",
|
|
90
|
+
addonAfter:"后面"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
77
93
|
{
|
|
78
94
|
name: "url",
|
|
79
95
|
type: "urlUpload",
|
|
80
96
|
label: "文本",
|
|
81
|
-
itemSpan:{
|
|
82
|
-
span:24
|
|
83
|
-
},
|
|
84
97
|
hideLabel:true,
|
|
98
|
+
rules:[{validator:()=>{
|
|
99
|
+
return Promise.reject(new Error("错误"))
|
|
100
|
+
}}],
|
|
85
101
|
itemProps: {
|
|
86
102
|
initValueProvider:(props,val)=>{
|
|
87
103
|
console.log(props,val,"fff")
|
|
@@ -162,9 +178,6 @@ export default () => {
|
|
|
162
178
|
configData={formData(options)}
|
|
163
179
|
dismissOnPressEnter={false}
|
|
164
180
|
labelWidth={88}
|
|
165
|
-
itemSpan={{
|
|
166
|
-
span:12
|
|
167
|
-
}}
|
|
168
181
|
form={form}
|
|
169
182
|
labelAlign={"left"}
|
|
170
183
|
onFinish={(value) => {
|
|
@@ -195,7 +208,7 @@ export default () => {
|
|
|
195
208
|
</div>
|
|
196
209
|
<div
|
|
197
210
|
onClick={() => {
|
|
198
|
-
|
|
211
|
+
form.submit()
|
|
199
212
|
}}
|
|
200
213
|
>
|
|
201
214
|
提交
|