@hw-component/form 1.9.26 → 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 +20 -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 +20 -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 +19 -7
- 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 -31
- 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
|
@@ -19,9 +19,9 @@ interface IProps<T = any> {
|
|
|
19
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
20
|
noHandlerWrap?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
|
-
addonBefore?:React.ReactNode;
|
|
23
|
-
minValMk?:(val:number)=>number;
|
|
24
|
-
maxValMk?:(val:number)=>number;
|
|
22
|
+
addonBefore?: React.ReactNode;
|
|
23
|
+
minValMk?: (val: number) => number;
|
|
24
|
+
maxValMk?: (val: number) => number;
|
|
25
25
|
}
|
|
26
26
|
const useArrayProps = (props: any) => {
|
|
27
27
|
return useMemo(() => {
|
|
@@ -31,20 +31,20 @@ const useArrayProps = (props: any) => {
|
|
|
31
31
|
return [props, props];
|
|
32
32
|
}, [props]);
|
|
33
33
|
};
|
|
34
|
-
const Addon:React.FC<IProps
|
|
35
|
-
const addonClassname=useClassName(["hw-input-group-addon"])
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (React.isValidElement(children)){
|
|
40
|
-
return <div className={addonClassname}>
|
|
41
|
-
{ React.cloneElement(children as any, { value, onChange })}
|
|
42
|
-
</div>
|
|
34
|
+
const Addon: React.FC<IProps> = ({ children, value, onChange }) => {
|
|
35
|
+
const addonClassname = useClassName(["hw-input-group-addon"]);
|
|
36
|
+
if (!children) {
|
|
37
|
+
return <></>;
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
39
|
+
if (React.isValidElement(children)) {
|
|
40
|
+
return (
|
|
41
|
+
<div className={addonClassname}>
|
|
42
|
+
{React.cloneElement(children as any, { value, onChange })}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return <div className={addonClassname}>{children}</div>;
|
|
47
|
+
};
|
|
48
48
|
const InputNumberGroup = ({
|
|
49
49
|
value = {},
|
|
50
50
|
valueMap = { min: "min", max: "max" },
|
|
@@ -55,9 +55,9 @@ const InputNumberGroup = ({
|
|
|
55
55
|
noHandlerWrap = true,
|
|
56
56
|
addFormat,
|
|
57
57
|
disabled,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
addonBefore,
|
|
59
|
+
minValMk,
|
|
60
|
+
maxValMk,
|
|
61
61
|
}: IProps) => {
|
|
62
62
|
const { min, max } = valueMap;
|
|
63
63
|
const { [min]: minVal, [max]: maxVal } = value;
|
|
@@ -115,7 +115,9 @@ const InputNumberGroup = ({
|
|
|
115
115
|
};
|
|
116
116
|
return (
|
|
117
117
|
<Input.Group compact className={contentClassname}>
|
|
118
|
-
<Addon value={value} onChange={onChange}>
|
|
118
|
+
<Addon value={value} onChange={onChange}>
|
|
119
|
+
{addonBefore}
|
|
120
|
+
</Addon>
|
|
119
121
|
<div
|
|
120
122
|
className={`${bodyClassname}
|
|
121
123
|
${focus ? activeClassname : ""}
|
|
@@ -127,7 +129,7 @@ const InputNumberGroup = ({
|
|
|
127
129
|
<InputNumber<number>
|
|
128
130
|
bordered={false}
|
|
129
131
|
value={minVal}
|
|
130
|
-
max={maxValMk?maxValMk(maxVal):maxVal}
|
|
132
|
+
max={maxValMk ? maxValMk(maxVal) : maxVal}
|
|
131
133
|
min={0}
|
|
132
134
|
className={oneClassname}
|
|
133
135
|
onFocus={() => {
|
|
@@ -151,7 +153,7 @@ const InputNumberGroup = ({
|
|
|
151
153
|
value={maxVal}
|
|
152
154
|
className={oneClassname}
|
|
153
155
|
placeholder={edPlaceholder}
|
|
154
|
-
min={minValMk?minValMk(minVal):minVal}
|
|
156
|
+
min={minValMk ? minValMk(minVal) : minVal}
|
|
155
157
|
onFocus={() => {
|
|
156
158
|
setFocus(true);
|
|
157
159
|
}}
|
|
@@ -165,7 +167,9 @@ const InputNumberGroup = ({
|
|
|
165
167
|
disabled={disabled}
|
|
166
168
|
/>
|
|
167
169
|
</div>
|
|
168
|
-
<Addon value={value} onChange={onChange}>
|
|
170
|
+
<Addon value={value} onChange={onChange}>
|
|
171
|
+
{addonAfter}
|
|
172
|
+
</Addon>
|
|
169
173
|
</Input.Group>
|
|
170
174
|
);
|
|
171
175
|
};
|
|
@@ -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%;
|
|
@@ -51,12 +63,12 @@
|
|
|
51
63
|
border-color: #40a9ff;
|
|
52
64
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
53
65
|
}
|
|
54
|
-
.@{all-input-group}-addon{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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;
|
|
60
72
|
}
|
|
61
73
|
}
|
|
62
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,46 +70,105 @@ const formData = (options) => {
|
|
|
70
70
|
{
|
|
71
71
|
name: "name",
|
|
72
72
|
label: "输入框",
|
|
73
|
+
rules: [
|
|
74
|
+
{
|
|
75
|
+
validator: () => {
|
|
76
|
+
return Promise.reject(new Error("错误"));
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
73
80
|
itemProps: {
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
addonBefore: "前面",
|
|
82
|
+
addonAfter: "后面",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
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: "后面",
|
|
99
|
+
},
|
|
76
100
|
},
|
|
77
101
|
{
|
|
78
102
|
name: "url",
|
|
79
103
|
type: "urlUpload",
|
|
80
104
|
label: "文本",
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
};
|
|
83
120
|
},
|
|
84
|
-
|
|
85
|
-
itemProps: {
|
|
86
|
-
initValueProvider:(props,val)=>{
|
|
87
|
-
console.log(props,val,"fff")
|
|
88
|
-
return {
|
|
89
|
-
...val,
|
|
90
|
-
name:"ffffsfsadasda"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
121
|
+
},
|
|
94
122
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
);
|
|
107
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
|
+
},
|
|
108
167
|
{
|
|
109
168
|
label: "输入框",
|
|
110
169
|
type: "checkboxGroup",
|
|
111
170
|
name: "check",
|
|
112
|
-
hover:"你好",
|
|
171
|
+
hover: "你好",
|
|
113
172
|
itemProps: {
|
|
114
173
|
options: [
|
|
115
174
|
{
|
|
@@ -162,9 +221,6 @@ export default () => {
|
|
|
162
221
|
configData={formData(options)}
|
|
163
222
|
dismissOnPressEnter={false}
|
|
164
223
|
labelWidth={88}
|
|
165
|
-
itemSpan={{
|
|
166
|
-
span:12
|
|
167
|
-
}}
|
|
168
224
|
form={form}
|
|
169
225
|
labelAlign={"left"}
|
|
170
226
|
onFinish={(value) => {
|
|
@@ -195,7 +251,7 @@ export default () => {
|
|
|
195
251
|
</div>
|
|
196
252
|
<div
|
|
197
253
|
onClick={() => {
|
|
198
|
-
|
|
254
|
+
form.submit();
|
|
199
255
|
}}
|
|
200
256
|
>
|
|
201
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
|
};
|