@hw-component/form 1.7.7 → 1.8.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/.eslintcache +1 -1
- package/es/Form/Basic.d.ts +1 -1
- package/es/Input/InputNumberGroup.js +15 -7
- package/es/Select/hooks/changeHooks.js +52 -8
- package/es/index.css +15 -11
- package/lib/Form/Basic.d.ts +1 -1
- package/lib/Input/InputNumberGroup.js +15 -7
- package/lib/Select/hooks/changeHooks.js +52 -8
- package/lib/index.css +15 -11
- package/package.json +1 -1
- package/src/components/Form/Basic.tsx +3 -2
- package/src/components/Form/FormItem/hooks.tsx +1 -1
- package/src/components/Form/modal.ts +5 -5
- package/src/components/Input/InputNumberGroup.tsx +15 -4
- package/src/components/Input/index.less +11 -2
- package/src/components/Select/hooks/changeHooks.tsx +35 -9
- package/src/pages/Form/index.tsx +79 -70
- package/src/pages/Input/index.tsx +2 -0
- package/src/pages/Select/index.tsx +12 -61
package/src/pages/Form/index.tsx
CHANGED
|
@@ -4,86 +4,100 @@ import {
|
|
|
4
4
|
HFormConfigProvider,
|
|
5
5
|
HSwitch,
|
|
6
6
|
useHForm,
|
|
7
|
+
HSelect
|
|
7
8
|
} from "../../components";
|
|
8
9
|
import { useState } from "react";
|
|
9
|
-
import {
|
|
10
|
+
import {Button, DatePicker, Form, Input, Row, Space} from "antd";
|
|
10
11
|
const Test2 = () => {
|
|
11
12
|
return <Row style={{ background: "red" }} />;
|
|
12
13
|
};
|
|
13
|
-
const Test3 = ({ value, onChange }) => {
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const Test3 = ({ value={}, onChange }) => {
|
|
15
|
+
const {fs,end}=value;
|
|
16
|
+
return <Space>
|
|
17
|
+
<HSelect
|
|
18
|
+
options={[{value:"1321",key:1}]}
|
|
19
|
+
value={fs}
|
|
20
|
+
allowClear
|
|
21
|
+
onChange={()=>{
|
|
22
|
+
onChange?.({})
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
<HSelect options={[{value:"112",key:2}]}
|
|
26
|
+
allowClear
|
|
27
|
+
value={end}
|
|
28
|
+
onChange={(val)=>{
|
|
29
|
+
onChange?.({
|
|
30
|
+
...value,
|
|
31
|
+
end:val
|
|
32
|
+
})
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</Space>
|
|
26
36
|
};
|
|
37
|
+
const TestItem=()=>{
|
|
38
|
+
return <Form.Item name="name1">
|
|
39
|
+
<Test3/>
|
|
40
|
+
</Form.Item>
|
|
41
|
+
}
|
|
42
|
+
const Test3Item=()=>{
|
|
43
|
+
return <Form.List name="users">
|
|
44
|
+
{(fields, { add, remove }) => (
|
|
45
|
+
<>
|
|
46
|
+
{fields.map(({ key, name, ...restField }) => (
|
|
47
|
+
<Form.Item
|
|
48
|
+
{...restField}
|
|
49
|
+
name={name}
|
|
50
|
+
key={key}
|
|
51
|
+
>
|
|
52
|
+
<Test3/>
|
|
53
|
+
</Form.Item>
|
|
54
|
+
))}
|
|
55
|
+
<Form.Item>
|
|
56
|
+
<Button type="dashed" onClick={() => add({})} block>
|
|
57
|
+
Add field
|
|
58
|
+
</Button>
|
|
59
|
+
</Form.Item>
|
|
60
|
+
</>
|
|
61
|
+
)}
|
|
62
|
+
|
|
63
|
+
</Form.List>
|
|
64
|
+
}
|
|
27
65
|
const formData = (options) => {
|
|
28
66
|
return [
|
|
29
67
|
{
|
|
30
|
-
label: "下拉123",
|
|
31
|
-
className: "xiala",
|
|
32
|
-
type: "select",
|
|
33
|
-
name: "name1",
|
|
34
|
-
rules:[{required:true}],
|
|
35
|
-
itemProps: {
|
|
36
|
-
options: [
|
|
37
|
-
{
|
|
38
|
-
value: "选项1",
|
|
39
|
-
key: 1,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
value: "选项2",
|
|
43
|
-
key: 2,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
showSearch: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
noStyle:true,
|
|
51
68
|
render:()=>{
|
|
52
|
-
return <HBasicForm
|
|
69
|
+
return <HBasicForm
|
|
70
|
+
configData={[
|
|
53
71
|
{
|
|
54
|
-
label: "下拉",
|
|
72
|
+
label: "下拉123",
|
|
55
73
|
className: "xiala",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rules:[{required:true}],
|
|
60
|
-
hover:()=>{
|
|
61
|
-
return "ff"
|
|
62
|
-
},
|
|
63
|
-
hide:()=>{
|
|
64
|
-
return false;
|
|
65
|
-
},
|
|
66
|
-
labelAlign:"right",
|
|
67
|
-
itemProps: {
|
|
68
|
-
options: [
|
|
69
|
-
{
|
|
70
|
-
value: "选项1",
|
|
71
|
-
key: 1,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
value: "选项2",
|
|
75
|
-
key: 2,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
showSearch: true,
|
|
79
|
-
},
|
|
74
|
+
render:()=>{
|
|
75
|
+
return <TestItem/>
|
|
76
|
+
}
|
|
80
77
|
},
|
|
81
78
|
]}/>
|
|
82
79
|
}
|
|
83
80
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
{
|
|
82
|
+
label: '会员标签',
|
|
83
|
+
hover: '添加新的会员标签后会覆盖用户原有的会员标签类型',
|
|
84
|
+
nameKey: 'userTags',
|
|
85
|
+
style: {
|
|
86
|
+
marginBottom: 0,
|
|
87
|
+
},
|
|
88
|
+
render:()=>{
|
|
89
|
+
return <HBasicForm
|
|
90
|
+
configData={[
|
|
91
|
+
{
|
|
92
|
+
label: "333",
|
|
93
|
+
className: "xiala",
|
|
94
|
+
render:()=>{
|
|
95
|
+
return <Test3Item/>
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
]}/>
|
|
99
|
+
}
|
|
100
|
+
},
|
|
87
101
|
];
|
|
88
102
|
};
|
|
89
103
|
function Ttta({ form }) {
|
|
@@ -135,12 +149,7 @@ export default () => {
|
|
|
135
149
|
console.log(val, "onValuesChange");
|
|
136
150
|
}}
|
|
137
151
|
initialValues={{
|
|
138
|
-
|
|
139
|
-
min: 1,
|
|
140
|
-
max: 2,
|
|
141
|
-
inputNumberGroup: {
|
|
142
|
-
input: "xxxxxxx",
|
|
143
|
-
},
|
|
152
|
+
name1:{}
|
|
144
153
|
}}
|
|
145
154
|
request={(params) => {
|
|
146
155
|
return new Promise<any>((resolve) => {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
HInputNumber,
|
|
6
6
|
HColorInput,
|
|
7
7
|
HVerificationCodeInput,
|
|
8
|
+
HInputNumberGroup,
|
|
8
9
|
} from "../../components";
|
|
9
10
|
import { Space } from "antd";
|
|
10
11
|
export default () => {
|
|
@@ -25,6 +26,7 @@ export default () => {
|
|
|
25
26
|
return Promise.resolve({ code: 200 });
|
|
26
27
|
}}
|
|
27
28
|
/>
|
|
29
|
+
<HInputNumberGroup/>
|
|
28
30
|
</Space>
|
|
29
31
|
);
|
|
30
32
|
};
|
|
@@ -1,56 +1,28 @@
|
|
|
1
1
|
import { HSelect } from "../../components";
|
|
2
|
-
import { Space } from "antd";
|
|
2
|
+
import { Space ,Select} from "antd";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
export default () => {
|
|
5
|
-
const [selectVal, setSelectVal] = useState(
|
|
5
|
+
const [selectVal, setSelectVal] = useState([{name:"11",id:-100}]);
|
|
6
6
|
return (
|
|
7
7
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
8
|
-
<HSelect
|
|
9
|
-
options={[{ label: "测试", value: 1 }]}
|
|
10
|
-
value={1}
|
|
11
|
-
placeholder="基础"
|
|
12
|
-
allowClear={true}
|
|
13
|
-
/>
|
|
14
|
-
<HSelect
|
|
15
|
-
fieldNames={{ label: "name", value: "value" }}
|
|
16
|
-
options={[
|
|
17
|
-
{ name: "测试1", value: 10, userId: 112321, disabled: true },
|
|
18
|
-
{ name: "测试2", value: 20, userId: 112321 },
|
|
19
|
-
]}
|
|
20
|
-
placeholder="多选"
|
|
21
|
-
value={null}
|
|
22
|
-
onChange={(val, option) => {
|
|
23
|
-
console.log(val);
|
|
24
|
-
setSelectVal(val);
|
|
25
|
-
}}
|
|
26
|
-
allSelect={true}
|
|
27
|
-
mode={"multiple"}
|
|
28
|
-
allowClear={true}
|
|
29
|
-
showSearch={true}
|
|
30
|
-
/>
|
|
31
|
-
<HSelect
|
|
32
|
-
mode={"tags"}
|
|
33
|
-
placeholder="tags模式"
|
|
34
|
-
showSearch={true}
|
|
35
|
-
allowClear={true}
|
|
36
|
-
value={null}
|
|
37
|
-
options={[
|
|
38
|
-
{ label: "测试1", value: 10 },
|
|
39
|
-
{ label: "测试2", value: 20 },
|
|
40
|
-
]}
|
|
41
|
-
/>
|
|
42
8
|
<HSelect
|
|
43
9
|
placeholder="分页"
|
|
44
10
|
serviceSearch
|
|
45
11
|
allowClear={true}
|
|
46
12
|
labelInValue
|
|
47
|
-
|
|
48
|
-
|
|
13
|
+
fieldNames={{
|
|
14
|
+
label:"name",
|
|
15
|
+
value:"id"
|
|
16
|
+
}}
|
|
17
|
+
value={selectVal}
|
|
18
|
+
onChange={(val,item)=>{
|
|
19
|
+
setSelectVal(val)
|
|
20
|
+
}}
|
|
49
21
|
request={async (params) => {
|
|
50
22
|
const { page, size } = params;
|
|
51
23
|
const op = [];
|
|
52
|
-
for (let i = 0; i <
|
|
53
|
-
op.push({
|
|
24
|
+
for (let i = 0; i < 5; i += 1) {
|
|
25
|
+
op.push({ name: `第${page}页第${i}条`, id: i + page });
|
|
54
26
|
}
|
|
55
27
|
return Promise.resolve({
|
|
56
28
|
page,
|
|
@@ -61,27 +33,6 @@ export default () => {
|
|
|
61
33
|
}}
|
|
62
34
|
isList
|
|
63
35
|
/>
|
|
64
|
-
<HSelect
|
|
65
|
-
serviceSearch={true}
|
|
66
|
-
request={(params) => {
|
|
67
|
-
return new Promise((resolve) => {
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
resolve([
|
|
70
|
-
{
|
|
71
|
-
label: `我是搜索文案${params.inputValue}`,
|
|
72
|
-
value: new Date().valueOf(),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
label: `我是搜索文案${params.inputValue}`,
|
|
76
|
-
value: new Date().valueOf() + 1,
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
}, 2000);
|
|
80
|
-
});
|
|
81
|
-
}}
|
|
82
|
-
placeholder="远程搜索"
|
|
83
|
-
mode={"multiple"}
|
|
84
|
-
/>
|
|
85
36
|
</Space>
|
|
86
37
|
);
|
|
87
38
|
};
|