@hw-component/form 1.9.27 → 1.9.28
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/.eslintcache +1 -1
- package/es/Form/config.d.ts +5 -0
- package/es/Form/config.js +4 -2
- package/es/Select/TreeSelect.d.ts +7 -0
- package/es/Select/TreeSelect.js +30 -0
- package/es/Upload/UrlUpload/index.d.ts +1 -1
- package/es/index.css +9 -9
- package/lib/Form/config.d.ts +5 -0
- package/lib/Form/config.js +4 -2
- package/lib/Select/TreeSelect.d.ts +7 -0
- package/lib/Select/TreeSelect.js +33 -0
- package/lib/Upload/UrlUpload/index.d.ts +1 -1
- package/lib/index.css +9 -9
- package/package.json +1 -1
- package/src/components/DialogForm/hooks.ts +0 -1
- package/src/components/Form/Basic.tsx +5 -5
- package/src/components/Form/FormItem/BasicItem.tsx +11 -9
- package/src/components/Form/FormItem/index.tsx +2 -2
- package/src/components/Form/Label.tsx +1 -1
- package/src/components/Form/config.ts +9 -1
- package/src/components/Form/hooks/index.ts +2 -2
- package/src/components/Form/index.less +3 -3
- package/src/components/Form/index.tsx +2 -2
- package/src/components/Form/modal.ts +3 -3
- package/src/components/Input/ColorInput/index.tsx +2 -2
- package/src/components/Input/InputNumberGroup.tsx +27 -23
- package/src/components/Input/index.less +10 -10
- package/src/components/Select/TreeSelect.tsx +16 -0
- package/src/components/Switch/index.less +2 -2
- package/src/components/Switch/index.tsx +12 -14
- package/src/components/Upload/UrlUpload/index.tsx +1 -1
- package/src/pages/Form/index.tsx +87 -44
- package/src/pages/Input/index.tsx +3 -3
- package/src/pages/InputNumberGroup/index.tsx +21 -13
- package/src/pages/Switch/index.tsx +10 -11
- package/src/routes.tsx +1 -1
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
@all-input-group: ~"@{ant-prefix}-hw-input-group";
|
|
3
3
|
.@{ant-prefix}-form-item-has-error {
|
|
4
4
|
.@{all-input-group}-body {
|
|
5
|
-
border-color
|
|
5
|
+
border-color: #ff4d4f !important;
|
|
6
6
|
}
|
|
7
7
|
.@{all-input-group}-active {
|
|
8
8
|
border-color: #ff4d4f !important;
|
|
9
9
|
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) !important;
|
|
10
10
|
}
|
|
11
|
-
.@{all-input-group}-addon{
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
.@{all-input-group}-addon {
|
|
12
|
+
color: #ff4d4f;
|
|
13
|
+
border-color: #ff4d4f !important;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
.@{all-input-group} {
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
border-color: #40a9ff;
|
|
64
64
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
65
65
|
}
|
|
66
|
-
.@{all-input-group}-addon{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
.@{all-input-group}-addon {
|
|
67
|
+
display: flex !important;
|
|
68
|
+
align-items: center;
|
|
69
|
+
padding: 0 11px;
|
|
70
|
+
background-color: #fafafa;
|
|
71
|
+
border: 1px solid #d9d9d9;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TreeSelect } from "antd";
|
|
2
|
+
import { TreeSelectProps } from "antd/lib/tree-select";
|
|
3
|
+
import { PromiseFnResult } from "../modal";
|
|
4
|
+
import { useRequest } from "ahooks";
|
|
5
|
+
interface IProps extends TreeSelectProps {
|
|
6
|
+
request?: PromiseFnResult;
|
|
7
|
+
}
|
|
8
|
+
export default ({ request,treeData, ...props }: IProps) => {
|
|
9
|
+
const { loading, data } = useRequest(() => {
|
|
10
|
+
if (request) {
|
|
11
|
+
return request({});
|
|
12
|
+
}
|
|
13
|
+
return Promise.resolve(treeData);
|
|
14
|
+
});
|
|
15
|
+
return <TreeSelect treeData={data} loading={loading} {...props}/>;
|
|
16
|
+
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: row;
|
|
6
6
|
align-items: center;
|
|
7
|
-
.@{ant-prefix}-hw-switch-before{
|
|
7
|
+
.@{ant-prefix}-hw-switch-before {
|
|
8
8
|
margin-right: 4px;
|
|
9
9
|
}
|
|
10
|
-
.@{ant-prefix}-hw-switch-after{
|
|
10
|
+
.@{ant-prefix}-hw-switch-after {
|
|
11
11
|
margin-left: 4px;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SwitchProps } from "antd";
|
|
2
|
-
import {Switch } from "antd";
|
|
2
|
+
import { Switch } from "antd";
|
|
3
3
|
import React, { useMemo } from "react";
|
|
4
|
-
import {useClassName, useMatchConfigProps} from "../hooks";
|
|
4
|
+
import { useClassName, useMatchConfigProps } from "../hooks";
|
|
5
5
|
import type { ValueSwitchMapModal } from "../modal";
|
|
6
6
|
import type { addFormatItemModal } from "../Form/modal";
|
|
7
7
|
import HFormConnect from "../Form/HFormConnect";
|
|
@@ -28,9 +28,9 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
28
28
|
const { valueSwitchMap = {} } = useMatchConfigProps({
|
|
29
29
|
valueSwitchMap: propsValueSwitchMap,
|
|
30
30
|
});
|
|
31
|
-
const switchClassName=useClassName("hw-switch");
|
|
32
|
-
const switchBefore=useClassName("hw-switch-before");
|
|
33
|
-
const switchAfter=useClassName("hw-switch-after")
|
|
31
|
+
const switchClassName = useClassName("hw-switch");
|
|
32
|
+
const switchBefore = useClassName("hw-switch-before");
|
|
33
|
+
const switchAfter = useClassName("hw-switch-after");
|
|
34
34
|
|
|
35
35
|
const swChecked = useMemo(() => {
|
|
36
36
|
const { open } = valueSwitchMap;
|
|
@@ -66,17 +66,15 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
66
66
|
});
|
|
67
67
|
return (
|
|
68
68
|
<div style={style} className={switchClassName}>
|
|
69
|
-
{beforeText
|
|
70
|
-
{beforeText}
|
|
71
|
-
</span>}
|
|
69
|
+
{beforeText && <span className={switchBefore}>{beforeText}</span>}
|
|
72
70
|
<Switch
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
checked={swChecked}
|
|
72
|
+
checkedChildren={checkedChildren}
|
|
73
|
+
unCheckedChildren={unCheckedChildren}
|
|
74
|
+
onChange={change}
|
|
75
|
+
{...props}
|
|
78
76
|
/>
|
|
79
|
-
{children&&
|
|
77
|
+
{children && <span className={switchAfter}>{children}</span>}
|
|
80
78
|
</div>
|
|
81
79
|
);
|
|
82
80
|
};
|
|
@@ -6,7 +6,7 @@ import TypeEle from "../MediaTypeEle/TypeEle";
|
|
|
6
6
|
import { useRef, useState } from "react";
|
|
7
7
|
import type { RcFile, UploadFile } from "antd/es/upload/interface";
|
|
8
8
|
import { useDefaultExFiles } from "./hooks";
|
|
9
|
-
import { HItemProps } from "@/components/Form/modal";
|
|
9
|
+
import type { HItemProps } from "@/components/Form/modal";
|
|
10
10
|
const { Text } = Typography;
|
|
11
11
|
const mkSubFileList = (fileList: UploadFile[], maxCount = 1) => {
|
|
12
12
|
const len = fileList.length;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -70,62 +70,105 @@ const formData = (options) => {
|
|
|
70
70
|
{
|
|
71
71
|
name: "name",
|
|
72
72
|
label: "输入框",
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
rules: [
|
|
74
|
+
{
|
|
75
|
+
validator: () => {
|
|
76
|
+
return Promise.reject(new Error("错误"));
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
76
80
|
itemProps: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
81
|
+
addonBefore: "前面",
|
|
82
|
+
addonAfter: "后面",
|
|
83
|
+
},
|
|
80
84
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
{
|
|
86
|
+
name: "inputNumberGroup",
|
|
87
|
+
label: "输入框",
|
|
88
|
+
rules: [
|
|
89
|
+
{
|
|
90
|
+
validator: () => {
|
|
91
|
+
return Promise.reject(new Error("错误"));
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
type: "inputNumberGroup",
|
|
96
|
+
itemProps: {
|
|
97
|
+
addonBefore: "前面",
|
|
98
|
+
addonAfter: "后面",
|
|
92
99
|
},
|
|
100
|
+
},
|
|
93
101
|
{
|
|
94
102
|
name: "url",
|
|
95
103
|
type: "urlUpload",
|
|
96
104
|
label: "文本",
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
hideLabel: true,
|
|
106
|
+
rules: [
|
|
107
|
+
{
|
|
108
|
+
validator: () => {
|
|
109
|
+
return Promise.reject(new Error("错误"));
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
itemProps: {
|
|
114
|
+
initValueProvider: (props, val) => {
|
|
115
|
+
console.log(props, val, "fff");
|
|
116
|
+
return {
|
|
117
|
+
...val,
|
|
118
|
+
name: "ffffsfsadasda",
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
},
|
|
110
122
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
{
|
|
124
|
+
nameKey: "name1",
|
|
125
|
+
label: "输入框",
|
|
126
|
+
render: () => {
|
|
127
|
+
return (
|
|
128
|
+
<Basic
|
|
129
|
+
configData={[
|
|
130
|
+
{
|
|
131
|
+
label: "1",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: "2",
|
|
135
|
+
},
|
|
136
|
+
]}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
123
139
|
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "treeSelect",
|
|
143
|
+
label: "treeSelect",
|
|
144
|
+
type: "treeSelect",
|
|
145
|
+
itemProps: {
|
|
146
|
+
request: async () => {
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
name: "父亲",
|
|
150
|
+
key: "1",
|
|
151
|
+
child: [
|
|
152
|
+
{
|
|
153
|
+
name: "儿子",
|
|
154
|
+
key: "1-1",
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
},
|
|
160
|
+
fieldNames: {
|
|
161
|
+
label: "name",
|
|
162
|
+
value: "key",
|
|
163
|
+
children: "child",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
124
167
|
{
|
|
125
168
|
label: "输入框",
|
|
126
169
|
type: "checkboxGroup",
|
|
127
170
|
name: "check",
|
|
128
|
-
hover:"你好",
|
|
171
|
+
hover: "你好",
|
|
129
172
|
itemProps: {
|
|
130
173
|
options: [
|
|
131
174
|
{
|
|
@@ -208,7 +251,7 @@ export default () => {
|
|
|
208
251
|
</div>
|
|
209
252
|
<div
|
|
210
253
|
onClick={() => {
|
|
211
|
-
form.submit()
|
|
254
|
+
form.submit();
|
|
212
255
|
}}
|
|
213
256
|
>
|
|
214
257
|
提交
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
HInputNumberGroup,
|
|
9
9
|
} from "../../components";
|
|
10
10
|
import { Space } from "antd";
|
|
11
|
-
import {useState} from "react";
|
|
11
|
+
import { useState } from "react";
|
|
12
12
|
export default () => {
|
|
13
|
-
const [colorVal,setColorVal]=useState();
|
|
13
|
+
const [colorVal, setColorVal] = useState();
|
|
14
14
|
return (
|
|
15
15
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
16
16
|
<HInput placeholder="基础输入框" copy value="11111" />
|
|
@@ -22,7 +22,7 @@ export default () => {
|
|
|
22
22
|
/>
|
|
23
23
|
<HButtonInput>点我</HButtonInput>
|
|
24
24
|
<HInputNumber />
|
|
25
|
-
<HColorInput value={colorVal} onChange={setColorVal}/>
|
|
25
|
+
<HColorInput value={colorVal} onChange={setColorVal} />
|
|
26
26
|
<HVerificationCodeInput
|
|
27
27
|
request={() => {
|
|
28
28
|
return Promise.resolve({ code: 200 });
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import {HInputNumberGroup} from
|
|
2
|
-
import {Col, Row} from
|
|
3
|
-
const Test=({value,onChange})=>{
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { HInputNumberGroup } from "@/components";
|
|
2
|
+
import { Col, Row } from "antd";
|
|
3
|
+
const Test = ({ value, onChange }) => {
|
|
4
|
+
console.log(value);
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
onClick={() => {
|
|
6
8
|
onChange(1);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
}}
|
|
10
|
+
>
|
|
11
|
+
1231
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export default () => {
|
|
16
|
+
return (
|
|
17
|
+
<Row style={{ marginTop: 20, marginLeft: 20 }}>
|
|
18
|
+
<Col span={10}>
|
|
19
|
+
<HInputNumberGroup addonBefore={<Test />} />
|
|
20
|
+
</Col>
|
|
14
21
|
</Row>
|
|
15
|
-
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -15,17 +15,16 @@ export default () => {
|
|
|
15
15
|
打开
|
|
16
16
|
</HSwitch>
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</HSwitch>
|
|
18
|
+
<HSwitch
|
|
19
|
+
value={1}
|
|
20
|
+
beforeText="开关"
|
|
21
|
+
valueMap={{ open: 1, close: 0 }}
|
|
22
|
+
onChange={(val) => {
|
|
23
|
+
console.log(val);
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
手机设备发送微信红包
|
|
27
|
+
</HSwitch>
|
|
29
28
|
</Space>
|
|
30
29
|
);
|
|
31
30
|
};
|