@hw-component/form 1.9.84 → 1.9.86
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/DialogForm/ModalForm.js +2 -1
- package/es/DialogForm/hooks.d.ts +1 -1
- package/es/Form/hooks/useHForm.js +10 -0
- package/es/Form/modal.d.ts +1 -0
- package/lib/DialogForm/ModalForm.js +2 -1
- package/lib/DialogForm/hooks.d.ts +1 -1
- package/lib/Form/hooks/useHForm.js +10 -0
- package/lib/Form/modal.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Btn.tsx +36 -36
- package/src/components/CheckboxGroup/index.tsx +4 -3
- package/src/components/DialogForm/DrawerForm/index.tsx +13 -13
- package/src/components/DialogForm/ModalForm.tsx +16 -15
- package/src/components/DialogForm/hooks.tsx +3 -3
- package/src/components/DialogForm/modal.ts +8 -2
- package/src/components/Form/HFormConnect.tsx +8 -3
- package/src/components/Form/InitSet.tsx +4 -4
- package/src/components/Form/hooks/index.ts +1 -3
- package/src/components/Form/hooks/useAddFormat.tsx +34 -36
- package/src/components/Form/hooks/useHForm.ts +14 -2
- package/src/components/Form/modal.ts +3 -2
- package/src/components/RichEditor/hooks.ts +36 -34
- package/src/components/RichEditor/index.tsx +31 -23
- package/src/components/RichEditor/modal.ts +2 -2
- package/src/components/TDPicker/TimePicker.tsx +1 -1
- package/src/components/TDPicker/hooks.ts +1 -1
- package/src/components/TextArea/index.tsx +2 -2
- package/src/components/Upload/Btn.tsx +13 -9
- package/src/components/Upload/hooks/customRequest.ts +1 -1
- package/src/components/Upload/index.tsx +8 -8
- package/src/components/Upload/modal.ts +5 -4
- package/src/pages/DrawerForm/index.tsx +17 -15
- package/src/pages/Form/index.tsx +44 -44
- package/src/pages/ModalForm/index.tsx +12 -8
- package/src/pages/Upload/index.tsx +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BraftEditor, { EditorState } from "braft-editor";
|
|
2
2
|
import "braft-editor/dist/index.css";
|
|
3
3
|
import { IHRichEditorProps } from "./modal";
|
|
4
|
-
import {useFocusClassname, useProps, useUploadFn, useVC} from "./hooks";
|
|
4
|
+
import { useFocusClassname, useProps, useUploadFn, useVC } from "./hooks";
|
|
5
5
|
import { useClassName } from "../hooks";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import HFormConnect from "../Form/HFormConnect";
|
|
@@ -19,8 +19,8 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
19
19
|
media,
|
|
20
20
|
contentStyle = defaultContentStyle,
|
|
21
21
|
bordered = true,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
onBlur,
|
|
23
|
+
onFocus,
|
|
24
24
|
addFormat,
|
|
25
25
|
...props
|
|
26
26
|
},
|
|
@@ -30,37 +30,45 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
30
30
|
fileRequest,
|
|
31
31
|
valueType,
|
|
32
32
|
});
|
|
33
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
focusClassname,
|
|
35
|
+
onFocus: selfFocus,
|
|
36
|
+
onBlur: selfBlur,
|
|
37
|
+
} = useFocusClassname({
|
|
34
38
|
bordered,
|
|
35
39
|
onBlur,
|
|
36
|
-
onFocus
|
|
40
|
+
onFocus,
|
|
37
41
|
});
|
|
38
|
-
const {richValue,change}=useVC({value,onChange,valueType:vType});
|
|
39
|
-
const uploadFn = useUploadFn({fileRequest:fileReq});
|
|
42
|
+
const { richValue, change } = useVC({ value, onChange, valueType: vType });
|
|
43
|
+
const uploadFn = useUploadFn({ fileRequest: fileReq });
|
|
40
44
|
const bodyClassName = useClassName("hw-rich-editor");
|
|
41
45
|
const borderClassName = useClassName("hw-rich-editor-border");
|
|
42
46
|
addFormat?.({
|
|
43
|
-
float:{
|
|
44
|
-
inputValue:(item, initValue)=>{
|
|
47
|
+
float: {
|
|
48
|
+
inputValue: (item, initValue) => {
|
|
45
49
|
const { name = "" } = item;
|
|
46
|
-
const keyName=
|
|
47
|
-
const itemVal=initValue[keyName];
|
|
48
|
-
const initVal=
|
|
50
|
+
const keyName = name as string;
|
|
51
|
+
const itemVal = initValue[keyName];
|
|
52
|
+
const initVal =
|
|
53
|
+
typeof itemVal === "string"
|
|
54
|
+
? BraftEditor.createEditorState(itemVal)
|
|
55
|
+
: itemVal;
|
|
49
56
|
return {
|
|
50
|
-
|
|
57
|
+
[keyName]: initVal,
|
|
51
58
|
};
|
|
52
59
|
},
|
|
53
|
-
outputValue:(item, outputValue)=>{
|
|
60
|
+
outputValue: (item, outputValue) => {
|
|
54
61
|
const { name = "" } = item;
|
|
55
|
-
|
|
56
|
-
const itemVal=outputValue[keyName];
|
|
57
|
-
const outputVal=
|
|
62
|
+
const keyName = name as string;
|
|
63
|
+
const itemVal = outputValue[keyName];
|
|
64
|
+
const outputVal =
|
|
65
|
+
typeof itemVal === "string" ? itemVal : itemVal?.toHTML();
|
|
58
66
|
return {
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
})
|
|
67
|
+
[keyName]: outputVal,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
64
72
|
return (
|
|
65
73
|
<div
|
|
66
74
|
className={`${bodyClassName} ${
|
|
@@ -81,4 +89,4 @@ const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
|
81
89
|
);
|
|
82
90
|
};
|
|
83
91
|
|
|
84
|
-
export default HFormConnect(
|
|
92
|
+
export default HFormConnect(React.forwardRef(Index) as any);
|
|
@@ -2,7 +2,8 @@ import { BraftEditorProps, EditorState } from "braft-editor";
|
|
|
2
2
|
import { PromiseFnResult } from "../modal";
|
|
3
3
|
import { addFormatItemModal } from "../Form/modal";
|
|
4
4
|
|
|
5
|
-
export interface IHRichEditorProps
|
|
5
|
+
export interface IHRichEditorProps
|
|
6
|
+
extends Omit<BraftEditorProps, "value" | "onChange"> {
|
|
6
7
|
value?: string | EditorState;
|
|
7
8
|
onChange?: (value: string | EditorState) => void;
|
|
8
9
|
fileRequest?: PromiseFnResult;
|
|
@@ -10,4 +11,3 @@ export interface IHRichEditorProps extends Omit<BraftEditorProps, "value"|"onCha
|
|
|
10
11
|
bordered?: boolean;
|
|
11
12
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
12
13
|
}
|
|
13
|
-
|
|
@@ -9,7 +9,7 @@ export default ({
|
|
|
9
9
|
autoSize = { minRows: 4, maxRows: 4 },
|
|
10
10
|
bordered = true,
|
|
11
11
|
className,
|
|
12
|
-
style={},
|
|
12
|
+
style = {},
|
|
13
13
|
...props
|
|
14
14
|
}: HTextAreaProps) => {
|
|
15
15
|
const noBorderClassName = useClassName("hw-text-area-no-border");
|
|
@@ -17,7 +17,7 @@ export default ({
|
|
|
17
17
|
return (
|
|
18
18
|
<Input.TextArea
|
|
19
19
|
autoSize={autoSize}
|
|
20
|
-
style={{width:"100%"
|
|
20
|
+
style={{ width: "100%", ...style }}
|
|
21
21
|
{...props}
|
|
22
22
|
className={`${borderClassName} ${className}`}
|
|
23
23
|
/>
|
|
@@ -3,7 +3,7 @@ import type { IUpLoadProps } from "./modal";
|
|
|
3
3
|
import React, { useMemo } from "react";
|
|
4
4
|
import { Button } from "antd";
|
|
5
5
|
|
|
6
|
-
export default ({ value, maxCount = 1, listType
|
|
6
|
+
export default ({ value, maxCount = 1, listType, children }: IUpLoadProps) => {
|
|
7
7
|
const len = value?.length || 0;
|
|
8
8
|
const text = useMemo(() => {
|
|
9
9
|
if (len === maxCount) {
|
|
@@ -19,13 +19,17 @@ export default ({ value, maxCount = 1, listType ,children}: IUpLoadProps) => {
|
|
|
19
19
|
</div>
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
const loading=useMemo(()=>{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},[value]);
|
|
27
|
-
if (children){
|
|
28
|
-
return
|
|
22
|
+
const loading = useMemo(() => {
|
|
23
|
+
return value?.some(({ status }) => {
|
|
24
|
+
return status === "uploading";
|
|
25
|
+
});
|
|
26
|
+
}, [value]);
|
|
27
|
+
if (children) {
|
|
28
|
+
return React.cloneElement<any>(children as any, { loading });
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<Button icon={<UploadOutlined />} loading={loading}>
|
|
32
|
+
{text}
|
|
33
|
+
</Button>
|
|
34
|
+
);
|
|
31
35
|
};
|
|
@@ -4,7 +4,7 @@ import type { RcFile } from "antd/lib/upload";
|
|
|
4
4
|
import { useEffect, useMemo } from "react";
|
|
5
5
|
import type { UploadFileStatus } from "antd/es/upload/interface";
|
|
6
6
|
import { message } from "antd";
|
|
7
|
-
import {useRequest} from "ahooks";
|
|
7
|
+
import { useRequest } from "ahooks";
|
|
8
8
|
|
|
9
9
|
interface SubReqParamsModal {
|
|
10
10
|
request?: IUpLoadProps["request"];
|
|
@@ -22,7 +22,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
22
22
|
addFormat,
|
|
23
23
|
thumbUrl,
|
|
24
24
|
hideAddBtn,
|
|
25
|
-
|
|
25
|
+
children,
|
|
26
26
|
...props
|
|
27
27
|
},
|
|
28
28
|
ref
|
|
@@ -49,9 +49,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
49
49
|
}, [maxRowNum, listType]);
|
|
50
50
|
|
|
51
51
|
const preview = (file) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (onPreview === null) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
55
|
if (onPreview) {
|
|
56
56
|
onPreview(file);
|
|
57
57
|
return;
|
|
@@ -101,7 +101,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
101
101
|
},
|
|
102
102
|
});
|
|
103
103
|
const relVal = Array.isArray(value) ? value : [];
|
|
104
|
-
const upListType=listType===null?undefined:listType;
|
|
104
|
+
const upListType = listType === null ? undefined : listType;
|
|
105
105
|
return (
|
|
106
106
|
<div style={contentStyle}>
|
|
107
107
|
<Upload
|
|
@@ -116,9 +116,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
116
116
|
{...props}
|
|
117
117
|
>
|
|
118
118
|
{hideAddBtn ? null : (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
<Btn value={relVal} maxCount={maxCount} listType={upListType}>
|
|
120
|
+
{children}
|
|
121
|
+
</Btn>
|
|
122
122
|
)}
|
|
123
123
|
</Upload>
|
|
124
124
|
<Preview
|
|
@@ -5,9 +5,10 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
|
5
5
|
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
7
|
import type React from "react";
|
|
8
|
-
import {UploadListType} from "antd/lib/upload/interface";
|
|
8
|
+
import { UploadListType } from "antd/lib/upload/interface";
|
|
9
9
|
|
|
10
|
-
export interface IUpLoadProps
|
|
10
|
+
export interface IUpLoadProps
|
|
11
|
+
extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
|
|
11
12
|
exFiles?: string[] | null;
|
|
12
13
|
request?: (
|
|
13
14
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
@@ -20,8 +21,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"|"listType"|"o
|
|
|
20
21
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
21
22
|
thumbUrl?: string;
|
|
22
23
|
hideAddBtn?: boolean;
|
|
23
|
-
listType?:UploadListType|null;
|
|
24
|
-
onPreview?:UploadProps["onPreview"]|null
|
|
24
|
+
listType?: UploadListType | null;
|
|
25
|
+
onPreview?: UploadProps["onPreview"] | null;
|
|
25
26
|
}
|
|
26
27
|
export interface IMediaTypeEleProps {
|
|
27
28
|
file?: UploadFile;
|
|
@@ -13,17 +13,19 @@ const data = [
|
|
|
13
13
|
return <Test />;
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
{
|
|
17
|
+
type: "select",
|
|
18
|
+
label: "下啦",
|
|
19
|
+
name: "select",
|
|
20
|
+
itemProps: {
|
|
21
|
+
options: [
|
|
22
|
+
{
|
|
23
|
+
value: "123",
|
|
24
|
+
key: 1,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
26
27
|
},
|
|
28
|
+
},
|
|
27
29
|
];
|
|
28
30
|
let num = 0;
|
|
29
31
|
const Test1 = ({ formNode, dialogForm, params }) => {
|
|
@@ -65,11 +67,11 @@ export default () => {
|
|
|
65
67
|
</Button>
|
|
66
68
|
<Button
|
|
67
69
|
onClick={() => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
modalForm.show({
|
|
71
|
+
initialValues: {
|
|
72
|
+
input: "12312",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
73
75
|
}}
|
|
74
76
|
>
|
|
75
77
|
打开
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -75,34 +75,34 @@ export default () => {
|
|
|
75
75
|
<div style={{ width: 1000 }}>
|
|
76
76
|
<HForm
|
|
77
77
|
configData={[
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
78
|
+
{
|
|
79
|
+
label: "文字",
|
|
80
|
+
name: "wz",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "文字1",
|
|
84
|
+
name: "wz1",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: "inputSelect",
|
|
88
|
+
type: "richEditor",
|
|
89
|
+
name: "richEditor",
|
|
90
|
+
rules: [
|
|
91
|
+
{
|
|
92
|
+
validator: (rule, value, callback) => {
|
|
93
|
+
console.log(value);
|
|
94
|
+
return Promise.resolve();
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
99
|
{
|
|
100
100
|
label: "富文本",
|
|
101
101
|
type: "timePicker",
|
|
102
102
|
name: "textArea",
|
|
103
|
-
itemProps:{
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
itemProps: {
|
|
104
|
+
showCount: true,
|
|
105
|
+
maxLength: 100,
|
|
106
106
|
},
|
|
107
107
|
rules: [
|
|
108
108
|
{
|
|
@@ -191,10 +191,10 @@ export default () => {
|
|
|
191
191
|
label: "文字",
|
|
192
192
|
type: "text",
|
|
193
193
|
name: "text",
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
render: () => {
|
|
195
|
+
return <div>fff</div>;
|
|
196
|
+
},
|
|
197
|
+
itemProps: {
|
|
198
198
|
type: "danger",
|
|
199
199
|
addonBefore: (
|
|
200
200
|
<div style={{ height: 100, backgroundColor: "red" }}>
|
|
@@ -206,12 +206,12 @@ export default () => {
|
|
|
206
206
|
wohao
|
|
207
207
|
</div>
|
|
208
208
|
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
initValueProvider: (...data) => {
|
|
210
|
+
console.log("initValueProvider");
|
|
211
|
+
return {
|
|
212
|
+
text: "你好",
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
215
|
},
|
|
216
216
|
},
|
|
217
217
|
]}
|
|
@@ -219,7 +219,7 @@ export default () => {
|
|
|
219
219
|
labelWidth={88}
|
|
220
220
|
form={form}
|
|
221
221
|
initialValues={{
|
|
222
|
-
|
|
222
|
+
richEditor: "1312312",
|
|
223
223
|
}}
|
|
224
224
|
labelAlign={"left"}
|
|
225
225
|
onFinish={(value) => {
|
|
@@ -246,15 +246,15 @@ export default () => {
|
|
|
246
246
|
>
|
|
247
247
|
点我
|
|
248
248
|
</div>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
249
|
+
<div
|
|
250
|
+
onClick={() => {
|
|
251
|
+
form.setFieldsValue({
|
|
252
|
+
wz: "你好",
|
|
253
|
+
});
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
设置
|
|
257
|
+
</div>
|
|
258
258
|
<div
|
|
259
259
|
onClick={() => {
|
|
260
260
|
form.submit();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Button, Input} from "antd";
|
|
1
|
+
import { Button, Input } from "antd";
|
|
2
2
|
import {
|
|
3
3
|
HModalForm,
|
|
4
4
|
useHDialogForm,
|
|
@@ -11,12 +11,16 @@ import { ShowParamsModal } from "@/components/DialogForm/modal";
|
|
|
11
11
|
const Test = (props) => {
|
|
12
12
|
return <HUrlUpload {...props} />;
|
|
13
13
|
};
|
|
14
|
-
const ITest=()=>{
|
|
15
|
-
|
|
14
|
+
const ITest = () => {
|
|
15
|
+
return (
|
|
16
|
+
<Input
|
|
17
|
+
onPressEnter={(e) => {
|
|
16
18
|
e.preventDefault();
|
|
17
|
-
console.log("ITest")
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
console.log("ITest");
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
20
24
|
const data = [
|
|
21
25
|
{
|
|
22
26
|
label: "输入框",
|
|
@@ -207,12 +211,12 @@ export default () => {
|
|
|
207
211
|
destroyOnClose={false}
|
|
208
212
|
autoClear={false}
|
|
209
213
|
onOk={() => {
|
|
210
|
-
|
|
214
|
+
console.log("fff");
|
|
211
215
|
return false;
|
|
212
216
|
}}
|
|
213
217
|
labelAlign={"left"}
|
|
214
218
|
request={(values, params) => {
|
|
215
|
-
|
|
219
|
+
console.log(values, params);
|
|
216
220
|
return Promise.resolve();
|
|
217
221
|
}}
|
|
218
222
|
dialogForm={modalForm}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Button, Space} from "antd";
|
|
1
|
+
import { Button, Space } from "antd";
|
|
2
2
|
import { HUpload, HUrlUpload } from "../../components";
|
|
3
3
|
import React, { useState } from "react";
|
|
4
4
|
import { MediaTypeEnum } from "../../components/Upload/enums";
|
|
@@ -33,7 +33,7 @@ export default () => {
|
|
|
33
33
|
}}
|
|
34
34
|
onChange={setFiles1}
|
|
35
35
|
>
|
|
36
|
-
|
|
36
|
+
<Button>按钮</Button>
|
|
37
37
|
</HUpload>
|
|
38
38
|
<HUrlUpload
|
|
39
39
|
inputHelper="测试"
|