@hw-component/form 1.9.70 → 1.9.72
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/DrawerForm/index.js +40 -32
- package/es/DialogForm/ModalForm.js +40 -32
- package/es/DialogForm/hooks.d.ts +7 -3
- package/es/DialogForm/hooks.js +3 -4
- package/es/DialogForm/modal.d.ts +3 -2
- package/es/Form/Basic.d.ts +1 -1
- package/es/Form/FormItem/index.js +2 -0
- package/es/Form/HFormConnect.d.ts +2 -3
- package/es/Form/HFormConnect.js +2 -32
- package/es/Form/config.d.ts +1 -0
- package/es/Form/config.js +4 -2
- package/es/Form/hooks/index.d.ts +1 -0
- package/es/Form/hooks/useAddFormat.d.ts +8 -0
- package/es/Form/hooks/useAddFormat.js +44 -0
- package/es/Form/modal.d.ts +5 -0
- package/es/RichEditor/hooks.d.ts +15 -0
- package/es/RichEditor/hooks.js +110 -0
- package/es/RichEditor/index.d.ts +4 -0
- package/es/RichEditor/index.js +96 -0
- package/es/RichEditor/modal.d.ts +11 -0
- package/es/config.js +27 -1
- package/es/index.css +22 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/lib/DialogForm/DrawerForm/index.js +40 -32
- package/lib/DialogForm/ModalForm.js +40 -32
- package/lib/DialogForm/hooks.d.ts +7 -3
- package/lib/DialogForm/hooks.js +3 -4
- package/lib/DialogForm/modal.d.ts +3 -2
- package/lib/Form/Basic.d.ts +1 -1
- package/lib/Form/FormItem/index.js +2 -0
- package/lib/Form/HFormConnect.d.ts +2 -3
- package/lib/Form/HFormConnect.js +2 -32
- package/lib/Form/config.d.ts +1 -0
- package/lib/Form/config.js +4 -2
- package/lib/Form/hooks/index.d.ts +1 -0
- package/lib/Form/hooks/useAddFormat.d.ts +8 -0
- package/lib/Form/hooks/useAddFormat.js +48 -0
- package/lib/Form/modal.d.ts +5 -0
- package/lib/RichEditor/hooks.d.ts +15 -0
- package/lib/RichEditor/hooks.js +114 -0
- package/lib/RichEditor/index.d.ts +4 -0
- package/lib/RichEditor/index.js +99 -0
- package/lib/RichEditor/modal.d.ts +11 -0
- package/lib/config.js +27 -1
- package/lib/index.css +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/package.json +2 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +18 -10
- package/src/components/DialogForm/ModalForm.tsx +18 -9
- package/src/components/DialogForm/hooks.tsx +12 -10
- package/src/components/DialogForm/modal.ts +4 -3
- package/src/components/Form/Basic.tsx +5 -9
- package/src/components/Form/FormItem/BasicItem.tsx +5 -3
- package/src/components/Form/FormItem/index.tsx +2 -0
- package/src/components/Form/HFormConnect.tsx +3 -39
- package/src/components/Form/config.ts +4 -0
- package/src/components/Form/hooks/index.ts +4 -0
- package/src/components/Form/hooks/useAddFormat.tsx +44 -0
- package/src/components/Form/index.less +4 -3
- package/src/components/Form/modal.ts +9 -3
- package/src/components/InputGroup/index.tsx +2 -2
- package/src/components/RichEditor/hooks.ts +83 -0
- package/src/components/RichEditor/index.less +26 -0
- package/src/components/RichEditor/index.tsx +84 -0
- package/src/components/RichEditor/modal.ts +13 -0
- package/src/components/Upload/hooks/change.ts +4 -5
- package/src/components/config.ts +8 -0
- package/src/components/index.tsx +2 -0
- package/src/components/styles/index.less +1 -0
- package/src/pages/Form/index.tsx +31 -19
- package/src/pages/Input/index.tsx +1 -1
- package/src/pages/ModalForm/index.tsx +1 -0
- package/src/pages/Select/index.tsx +2 -2
|
@@ -22,6 +22,8 @@ import TrimInput from "../Input/TrimInput";
|
|
|
22
22
|
import TrimTextArea from "../TextArea/TrimTextArea";
|
|
23
23
|
import HInputNumberGroup from "../Input/InputNumberGroup";
|
|
24
24
|
import HText from "../Text";
|
|
25
|
+
import HRichEditor from "../RichEditor";
|
|
26
|
+
|
|
25
27
|
export const placeholderConfig = {
|
|
26
28
|
inputType: [
|
|
27
29
|
"input",
|
|
@@ -32,6 +34,7 @@ export const placeholderConfig = {
|
|
|
32
34
|
"trimInput",
|
|
33
35
|
"urlUpload",
|
|
34
36
|
"textArea",
|
|
37
|
+
"richEditor",
|
|
35
38
|
],
|
|
36
39
|
selectType: [
|
|
37
40
|
"select",
|
|
@@ -66,6 +69,7 @@ const componentConfig = {
|
|
|
66
69
|
inputNumberGroup: HInputNumberGroup,
|
|
67
70
|
treeSelect: HTreeSelect,
|
|
68
71
|
text: HText,
|
|
72
|
+
richEditor: HRichEditor,
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
export default componentConfig;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {addFormatItemModal, HFormItemProps} from "../modal";
|
|
2
|
+
import {useFormContext} from "@/components/Form/Context";
|
|
3
|
+
import {useEffect} from "react";
|
|
4
|
+
|
|
5
|
+
interface ResultModal {
|
|
6
|
+
inputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
7
|
+
outputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const formatMaker = (
|
|
11
|
+
itemProps: HFormItemProps,
|
|
12
|
+
formats?: addFormatItemModal
|
|
13
|
+
) => {
|
|
14
|
+
const { inputValue, outputValue } = formats || {};
|
|
15
|
+
const { initValueProvider = inputValue, subProvider = outputValue } =
|
|
16
|
+
itemProps;
|
|
17
|
+
const resultObj: ResultModal = {};
|
|
18
|
+
if (initValueProvider) {
|
|
19
|
+
resultObj.inputValue = (value) => {
|
|
20
|
+
return initValueProvider(itemProps, value);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (subProvider) {
|
|
24
|
+
resultObj.outputValue = (value) => {
|
|
25
|
+
return subProvider(itemProps, value);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const keysLen = Object.keys(resultObj).length;
|
|
29
|
+
return keysLen === 0 ? undefined : resultObj;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export default (props:HFormItemProps)=>{
|
|
35
|
+
const {name,itemProps}=props;
|
|
36
|
+
const { form, valueType = "float" } = useFormContext();
|
|
37
|
+
const relName = Array.isArray(name) ? name.join(".") : name;
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!relName||!itemProps) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
form?.addFormat(relName, formatMaker((itemProps as HFormItemProps)));
|
|
43
|
+
}, [valueType, props]);
|
|
44
|
+
}
|
|
@@ -96,8 +96,9 @@
|
|
|
96
96
|
overflow: visible;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
.@{ant-prefix}-hw-form-item-row{
|
|
100
|
-
.@{ant-prefix}-form-item-control-input-content
|
|
101
|
-
|
|
99
|
+
.@{ant-prefix}-hw-form-item-row {
|
|
100
|
+
.@{ant-prefix}-form-item-control-input-content
|
|
101
|
+
> .@{ant-prefix}-space-vertical {
|
|
102
|
+
display: flex;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -93,7 +93,7 @@ export interface HItemProps
|
|
|
93
93
|
labelWidth?: number;
|
|
94
94
|
hide?: boolean | HideModal;
|
|
95
95
|
placeholder?: string | string[];
|
|
96
|
-
name?: string | any
|
|
96
|
+
name?: string | any[];
|
|
97
97
|
dispatch?: DispatchModal;
|
|
98
98
|
itemSpan?: ColProps;
|
|
99
99
|
hideLabel?: boolean;
|
|
@@ -102,7 +102,7 @@ export interface HItemProps
|
|
|
102
102
|
hidden?: boolean | HideModal;
|
|
103
103
|
rowWrapper?: boolean;
|
|
104
104
|
nameKey?: string;
|
|
105
|
-
flexBox?:boolean;
|
|
105
|
+
flexBox?: boolean;
|
|
106
106
|
}
|
|
107
107
|
interface InfoRequestOp extends BaseOptions<any, any> {
|
|
108
108
|
request: PromiseFnResult;
|
|
@@ -126,7 +126,7 @@ export interface HFormProps<T = any, R = any>
|
|
|
126
126
|
itemProps?: ItemPropsType;
|
|
127
127
|
dismissOnPressEnter?: boolean;
|
|
128
128
|
rowWrapper?: boolean;
|
|
129
|
-
flexBox?:boolean;
|
|
129
|
+
flexBox?: boolean;
|
|
130
130
|
}
|
|
131
131
|
export interface HFormItemProps extends HItemProps {
|
|
132
132
|
required?: boolean;
|
|
@@ -157,6 +157,11 @@ interface ConfigUploadProps {
|
|
|
157
157
|
maxSize?: number;
|
|
158
158
|
request?: PromiseFnResult;
|
|
159
159
|
}
|
|
160
|
+
|
|
161
|
+
interface ConfigRichEditorProps {
|
|
162
|
+
fileRequest?: PromiseFnResult;
|
|
163
|
+
valueType?: "html" | "state";
|
|
164
|
+
}
|
|
160
165
|
export type ComponentModal =
|
|
161
166
|
| React.FunctionComponent<any>
|
|
162
167
|
| React.ComponentClass<any>
|
|
@@ -179,6 +184,7 @@ export interface IFormConfigContextProps {
|
|
|
179
184
|
defaultComponent?: DefaultComponentModal;
|
|
180
185
|
formItemStyle?: React.CSSProperties;
|
|
181
186
|
itemProps?: ItemPropsType;
|
|
187
|
+
richEditorProps?: ConfigRichEditorProps;
|
|
182
188
|
}
|
|
183
189
|
interface ActionModal {
|
|
184
190
|
key: string;
|
|
@@ -6,7 +6,7 @@ interface HInputGroupProps<T = any> {
|
|
|
6
6
|
value?: T;
|
|
7
7
|
onChange?: (value: T) => void;
|
|
8
8
|
addonBefore?: React.ReactNode;
|
|
9
|
-
className?:string;
|
|
9
|
+
className?: string;
|
|
10
10
|
}
|
|
11
11
|
const Addon: React.FC<HInputGroupProps> = ({ children, value, onChange }) => {
|
|
12
12
|
const addonClassname = useClassName(["hw-addon"]);
|
|
@@ -28,7 +28,7 @@ const Index: React.FC<HInputGroupProps> = ({
|
|
|
28
28
|
addonBefore,
|
|
29
29
|
children,
|
|
30
30
|
value,
|
|
31
|
-
|
|
31
|
+
className = "",
|
|
32
32
|
onChange,
|
|
33
33
|
...props
|
|
34
34
|
}) => {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useFormConfigContext } from "../Form/Context/FormConfigProvider";
|
|
2
|
+
import { baseConfig } from "../config";
|
|
3
|
+
import { IHRichEditorProps } from "src/components/RichEditor/modal";
|
|
4
|
+
import { useClassName } from "../hooks";
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import BraftEditor, {EditorState} from "braft-editor";
|
|
7
|
+
|
|
8
|
+
export const useProps = ({ fileRequest, valueType }: IHRichEditorProps) => {
|
|
9
|
+
const {
|
|
10
|
+
fileRequest: contextFileRequest = fileRequest,
|
|
11
|
+
valueType: contextValueType = valueType,
|
|
12
|
+
} = useFormConfigContext("richEditorProps");
|
|
13
|
+
const cuRequest =
|
|
14
|
+
fileRequest === null
|
|
15
|
+
? baseConfig.richEditorProps?.fileRequest
|
|
16
|
+
: contextFileRequest;
|
|
17
|
+
return {
|
|
18
|
+
fileRequest: cuRequest,
|
|
19
|
+
valueType: contextValueType,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const useFocusClassname = ({
|
|
24
|
+
bordered,
|
|
25
|
+
onFocus: focusProps,
|
|
26
|
+
onBlur: blurProps,
|
|
27
|
+
}: IHRichEditorProps) => {
|
|
28
|
+
const styleFocusClassName = useClassName("hw-rich-editor-focus");
|
|
29
|
+
const [focusClassname, setFocusClassname] = useState("");
|
|
30
|
+
const onFocus = (editState) => {
|
|
31
|
+
focusProps?.(editState);
|
|
32
|
+
if (!bordered) {
|
|
33
|
+
setFocusClassname("");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
setFocusClassname(styleFocusClassName);
|
|
37
|
+
};
|
|
38
|
+
const onBlur = (editState) => {
|
|
39
|
+
setFocusClassname("");
|
|
40
|
+
blurProps?.(editState);
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
focusClassname,
|
|
44
|
+
onFocus,
|
|
45
|
+
onBlur,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const useVC=({value,onChange,valueType}:IHRichEditorProps)=>{
|
|
50
|
+
const richValue: EditorState | undefined = valueType === "html" ? BraftEditor.createEditorState(value) : (value as EditorState);
|
|
51
|
+
const change = (editorState) => {
|
|
52
|
+
const changeVal = valueType === "html" ? editorState.toHTML() : editorState;
|
|
53
|
+
const isEmpty = !!richValue ? richValue.isEmpty() : true;
|
|
54
|
+
if (isEmpty && editorState.isEmpty()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
onChange?.(changeVal);
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
richValue,
|
|
61
|
+
change
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export const useUploadFn=({fileRequest}:IHRichEditorProps)=>{
|
|
67
|
+
return async (params)=>{
|
|
68
|
+
const { file, id } = params;
|
|
69
|
+
const { url } = await fileRequest?.(file, params);
|
|
70
|
+
params.success({
|
|
71
|
+
url,
|
|
72
|
+
meta: {
|
|
73
|
+
id,
|
|
74
|
+
title: file.name,
|
|
75
|
+
alt: "媒体资源",
|
|
76
|
+
loop: false,
|
|
77
|
+
autoPlay: false,
|
|
78
|
+
controls: true,
|
|
79
|
+
poster: url,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@import "../styles/local.less";
|
|
2
|
+
.@{ant-prefix}-hw-rich-editor {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
width: 100%;
|
|
5
|
+
.bf-container .public-DraftEditorPlaceholder-root {
|
|
6
|
+
color: #bfbfbf;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
.@{ant-prefix}-hw-rich-editor-border {
|
|
11
|
+
border: 1px solid #d9d9d9;
|
|
12
|
+
border-radius: 2px;
|
|
13
|
+
&:hover {
|
|
14
|
+
border-color: #40a9ff;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.@{ant-prefix}-hw-rich-editor-focus {
|
|
18
|
+
border-color: #40a9ff;
|
|
19
|
+
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.@{ant-prefix}-form-item-has-error {
|
|
23
|
+
.@{ant-prefix}-hw-rich-editor-border {
|
|
24
|
+
border-color: #ff4d4f !important;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import BraftEditor, { EditorState } from "braft-editor";
|
|
2
|
+
import "braft-editor/dist/index.css";
|
|
3
|
+
import { IHRichEditorProps } from "./modal";
|
|
4
|
+
import {useFocusClassname, useProps, useUploadFn, useVC} from "./hooks";
|
|
5
|
+
import { useClassName } from "../hooks";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import HFormConnect from "../Form/HFormConnect";
|
|
8
|
+
|
|
9
|
+
const defaultContentStyle = {
|
|
10
|
+
height: 400,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Index: React.ForwardRefRenderFunction<any, IHRichEditorProps> = (
|
|
14
|
+
{
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
valueType,
|
|
18
|
+
fileRequest,
|
|
19
|
+
media,
|
|
20
|
+
contentStyle = defaultContentStyle,
|
|
21
|
+
bordered = true,
|
|
22
|
+
onBlur,
|
|
23
|
+
onFocus,
|
|
24
|
+
addFormat,
|
|
25
|
+
...props
|
|
26
|
+
},
|
|
27
|
+
ref
|
|
28
|
+
) => {
|
|
29
|
+
const { fileRequest: fileReq, valueType: vType } = useProps({
|
|
30
|
+
fileRequest,
|
|
31
|
+
valueType,
|
|
32
|
+
});
|
|
33
|
+
const { focusClassname, onFocus:selfFocus, onBlur:selfBlur } = useFocusClassname({
|
|
34
|
+
bordered,
|
|
35
|
+
onBlur,
|
|
36
|
+
onFocus
|
|
37
|
+
});
|
|
38
|
+
const {richValue,change}=useVC({value,onChange,valueType:vType});
|
|
39
|
+
const uploadFn = useUploadFn({fileRequest:fileReq});
|
|
40
|
+
const bodyClassName = useClassName("hw-rich-editor");
|
|
41
|
+
const borderClassName = useClassName("hw-rich-editor-border");
|
|
42
|
+
addFormat?.({
|
|
43
|
+
float:{
|
|
44
|
+
inputValue:(item, initValue)=>{
|
|
45
|
+
const { name = "" } = item;
|
|
46
|
+
const keyName=(name as string);
|
|
47
|
+
const itemVal=initValue[keyName];
|
|
48
|
+
const initVal=typeof itemVal==="string"?BraftEditor.createEditorState(itemVal):itemVal;
|
|
49
|
+
return {
|
|
50
|
+
[keyName]:initVal
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
outputValue:(item, outputValue)=>{
|
|
54
|
+
const { name = "" } = item;
|
|
55
|
+
const keyName=(name as string);
|
|
56
|
+
const itemVal=outputValue[keyName];
|
|
57
|
+
const outputVal=typeof itemVal==="string"?itemVal:itemVal?.toHTML();
|
|
58
|
+
return {
|
|
59
|
+
[keyName]:outputVal
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className={`${bodyClassName} ${
|
|
67
|
+
bordered ? borderClassName : ""
|
|
68
|
+
} ${focusClassname}`}
|
|
69
|
+
>
|
|
70
|
+
<BraftEditor
|
|
71
|
+
contentStyle={contentStyle}
|
|
72
|
+
value={richValue as EditorState}
|
|
73
|
+
onChange={change}
|
|
74
|
+
onFocus={selfFocus}
|
|
75
|
+
ref={ref}
|
|
76
|
+
onBlur={selfBlur}
|
|
77
|
+
media={{ uploadFn, ...media }}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default HFormConnect((React.forwardRef(Index) as any));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BraftEditorProps, EditorState } from "braft-editor";
|
|
2
|
+
import { PromiseFnResult } from "../modal";
|
|
3
|
+
import { addFormatItemModal } from "../Form/modal";
|
|
4
|
+
|
|
5
|
+
export interface IHRichEditorProps extends Omit<BraftEditorProps, "value"|"onChange"> {
|
|
6
|
+
value?: string | EditorState;
|
|
7
|
+
onChange?: (value: string | EditorState) => void;
|
|
8
|
+
fileRequest?: PromiseFnResult;
|
|
9
|
+
valueType?: "html" | "state";
|
|
10
|
+
bordered?: boolean;
|
|
11
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -52,14 +52,13 @@ export const useChange = ({
|
|
|
52
52
|
thumbUrl,
|
|
53
53
|
}: IUpLoadProps) => {
|
|
54
54
|
const customRequest = useCustomRequest({ request, onChange, value });
|
|
55
|
-
const checkGo=(errList:Error[])=>{
|
|
56
|
-
const len=errList.length;
|
|
55
|
+
const checkGo = (errList: Error[]) => {
|
|
56
|
+
const len = errList.length;
|
|
57
57
|
if (len) {
|
|
58
58
|
message.error(errList[0].message);
|
|
59
59
|
}
|
|
60
|
-
return !(maxCount === 1 && len > 0)
|
|
61
|
-
|
|
62
|
-
}
|
|
60
|
+
return !(maxCount === 1 && len > 0); //为1时存在错误不调用onChange
|
|
61
|
+
};
|
|
63
62
|
const { run } = useRequest(
|
|
64
63
|
async ({ fileList }: UploadChangeParam<UploadFile>) => {
|
|
65
64
|
if (fileList.length > maxCount) {
|
package/src/components/config.ts
CHANGED
|
@@ -49,6 +49,14 @@ export const baseConfig: IFormConfigContextProps = {
|
|
|
49
49
|
defaultComponent: {},
|
|
50
50
|
formItemStyle: {},
|
|
51
51
|
itemProps: {},
|
|
52
|
+
richEditorProps: {
|
|
53
|
+
fileRequest: async (file: any) => {
|
|
54
|
+
const url = await fileToBase64(file);
|
|
55
|
+
return {
|
|
56
|
+
url,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
},
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
export default {
|
package/src/components/index.tsx
CHANGED
|
@@ -13,6 +13,8 @@ import ModalForm from "./DialogForm/ModalForm";
|
|
|
13
13
|
import DrawerForm from "./DialogForm/DrawerForm";
|
|
14
14
|
export const HSelect = FormConfig.select;
|
|
15
15
|
export const HInput = FormConfig.input;
|
|
16
|
+
export const HRichEditor = FormConfig.richEditor;
|
|
17
|
+
|
|
16
18
|
export const HSelectInput = FormConfig.selectInput;
|
|
17
19
|
export const HUpload = FormConfig.upload;
|
|
18
20
|
export const HUrlUpload = FormConfig.urlUpload.Component;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -75,11 +75,24 @@ export default () => {
|
|
|
75
75
|
<div style={{ width: 1000 }}>
|
|
76
76
|
<HForm
|
|
77
77
|
configData={[
|
|
78
|
+
{
|
|
79
|
+
label: "富文本",
|
|
80
|
+
type: "richEditor",
|
|
81
|
+
name: "richEditor",
|
|
82
|
+
rules: [
|
|
83
|
+
{
|
|
84
|
+
validator: (rule, value, callback) => {
|
|
85
|
+
console.log(value);
|
|
86
|
+
return Promise.resolve();
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
78
91
|
{
|
|
79
92
|
label: "运营商账号",
|
|
80
93
|
name: "mobile",
|
|
81
94
|
type: "buttonInput",
|
|
82
|
-
|
|
95
|
+
flexBox: true,
|
|
83
96
|
itemProps: {
|
|
84
97
|
children: "修改手机号",
|
|
85
98
|
disabled: true,
|
|
@@ -143,17 +156,20 @@ export default () => {
|
|
|
143
156
|
name: "yyy",
|
|
144
157
|
type: "inputNumberGroup",
|
|
145
158
|
rules: [{ required: true }],
|
|
146
|
-
itemProps:{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
159
|
+
itemProps: {
|
|
160
|
+
inputNumberProps: {
|
|
161
|
+
precision: 2,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
151
164
|
},
|
|
152
165
|
{
|
|
153
166
|
label: "文字",
|
|
154
167
|
type: "text",
|
|
155
168
|
name: "text",
|
|
156
|
-
|
|
169
|
+
render:()=>{
|
|
170
|
+
return <div>fff</div>
|
|
171
|
+
},
|
|
172
|
+
itemProps: {
|
|
157
173
|
type: "danger",
|
|
158
174
|
addonBefore: (
|
|
159
175
|
<div style={{ height: 100, backgroundColor: "red" }}>
|
|
@@ -165,6 +181,12 @@ export default () => {
|
|
|
165
181
|
wohao
|
|
166
182
|
</div>
|
|
167
183
|
),
|
|
184
|
+
initValueProvider:(...data)=>{
|
|
185
|
+
console.log("initValueProvider")
|
|
186
|
+
return {
|
|
187
|
+
text:"你好"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
168
190
|
},
|
|
169
191
|
},
|
|
170
192
|
]}
|
|
@@ -174,18 +196,8 @@ export default () => {
|
|
|
174
196
|
}}
|
|
175
197
|
labelWidth={88}
|
|
176
198
|
form={form}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (id === 1) {
|
|
180
|
-
return {
|
|
181
|
-
name: "你好",
|
|
182
|
-
select: 1,
|
|
183
|
-
text: "hdj",
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
return {};
|
|
187
|
-
},
|
|
188
|
-
refreshDeps: [id],
|
|
199
|
+
initialValues={{
|
|
200
|
+
richEditor:"1312312"
|
|
189
201
|
}}
|
|
190
202
|
labelAlign={"left"}
|
|
191
203
|
onFinish={(value) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HSelect } from "../../components";
|
|
2
|
-
import {Form, Space} from "antd";
|
|
3
|
-
import {useEffect, useState} from "react";
|
|
2
|
+
import { Form, Space } from "antd";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
4
|
export default () => {
|
|
5
5
|
const [selectVal, setSelectVal] = useState([{ name: "11", id: -100 }]);
|
|
6
6
|
const [op, setOp] = useState([{ label: "1", value: 1 }]);
|