@hw-component/form 0.0.9-beta-v19 → 0.0.9-beta-v21
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 -0
- package/.idea/hw-component-form.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/es/Select/modal.d.ts +1 -3
- package/lib/Select/modal.d.ts +1 -3
- package/package.json +1 -1
- package/public/index.html +0 -19
- package/scripts/rollup.config.js +0 -90
- package/scripts/webpack.config.js +0 -76
- package/src/Layout.tsx +0 -61
- package/src/app.tsx +0 -33
- package/src/components/Cascader/index.tsx +0 -31
- package/src/components/CheckboxGroup/CheckBox/index.tsx +0 -38
- package/src/components/CheckboxGroup/hooks.ts +0 -105
- package/src/components/CheckboxGroup/index.tsx +0 -85
- package/src/components/CheckboxGroup/modal.ts +0 -17
- package/src/components/DialogForm/DrawerForm/Footer.tsx +0 -20
- package/src/components/DialogForm/DrawerForm/Title.tsx +0 -12
- package/src/components/DialogForm/DrawerForm/index.tsx +0 -110
- package/src/components/DialogForm/ModalForm.tsx +0 -91
- package/src/components/DialogForm/hooks.ts +0 -122
- package/src/components/DialogForm/modal.ts +0 -44
- package/src/components/Form/Context/FormConfigProvider.tsx +0 -38
- package/src/components/Form/Context/index.tsx +0 -14
- package/src/components/Form/FormItem/BasicItem.tsx +0 -95
- package/src/components/Form/FormItem/Helper.tsx +0 -25
- package/src/components/Form/FormItem/RegularFormItem.tsx +0 -13
- package/src/components/Form/FormItem/UpFormItem.tsx +0 -21
- package/src/components/Form/FormItem/hooks.tsx +0 -54
- package/src/components/Form/FormItem/index.tsx +0 -8
- package/src/components/Form/HFormConnect.tsx +0 -74
- package/src/components/Form/InitSet.tsx +0 -10
- package/src/components/Form/Label.tsx +0 -50
- package/src/components/Form/config.ts +0 -58
- package/src/components/Form/hooks/index.ts +0 -114
- package/src/components/Form/hooks/useDefaultRender.tsx +0 -45
- package/src/components/Form/hooks/useHForm.ts +0 -182
- package/src/components/Form/hooks/useInitConfigData.tsx +0 -194
- package/src/components/Form/index.less +0 -54
- package/src/components/Form/index.tsx +0 -113
- package/src/components/Form/modal.ts +0 -206
- package/src/components/Input/ButtonInput.tsx +0 -47
- package/src/components/Input/ColorInput/Picker.tsx +0 -18
- package/src/components/Input/ColorInput/data.ts +0 -102
- package/src/components/Input/ColorInput/index.less +0 -10
- package/src/components/Input/ColorInput/index.tsx +0 -58
- package/src/components/Input/InputNumber.tsx +0 -5
- package/src/components/Input/SelectInput.tsx +0 -75
- package/src/components/Input/TrimInput.tsx +0 -26
- package/src/components/Input/VerificationCodeInput.tsx +0 -74
- package/src/components/Input/defaultConfig.ts +0 -8
- package/src/components/Input/index.tsx +0 -26
- package/src/components/Input/modal.ts +0 -40
- package/src/components/PageHandler/ErrorComponent.tsx +0 -20
- package/src/components/PageHandler/LoadingComponent.tsx +0 -9
- package/src/components/PageHandler/index.tsx +0 -14
- package/src/components/PageHandler/modal.ts +0 -6
- package/src/components/RadioGroup/index.tsx +0 -45
- package/src/components/Select/components/AllSelect.tsx +0 -54
- package/src/components/Select/components/CheckBoxOption.tsx +0 -14
- package/src/components/Select/components/DropdownComponent.tsx +0 -36
- package/src/components/Select/components/NoFindItem.tsx +0 -7
- package/src/components/Select/components/NotFoundContent.tsx +0 -25
- package/src/components/Select/defaultConfig.tsx +0 -23
- package/src/components/Select/hooks/changeHooks.tsx +0 -159
- package/src/components/Select/hooks/norHooks.ts +0 -85
- package/src/components/Select/index.less +0 -22
- package/src/components/Select/index.tsx +0 -126
- package/src/components/Select/modal.ts +0 -38
- package/src/components/Select/utils.ts +0 -18
- package/src/components/Submit/components.tsx +0 -57
- package/src/components/Submit/hooks.ts +0 -31
- package/src/components/Submit/index.tsx +0 -33
- package/src/components/Switch/index.tsx +0 -77
- package/src/components/TDPicker/RangePicker.tsx +0 -109
- package/src/components/TDPicker/TimePicker.tsx +0 -29
- package/src/components/TDPicker/hooks.ts +0 -150
- package/src/components/TDPicker/index.tsx +0 -33
- package/src/components/TDPicker/modal.ts +0 -48
- package/src/components/TextArea/TrimTextArea.tsx +0 -30
- package/src/components/TextArea/index.tsx +0 -8
- package/src/components/Upload/Btn.tsx +0 -24
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +0 -26
- package/src/components/Upload/MediaTypeEle/index.tsx +0 -34
- package/src/components/Upload/Preview/index.tsx +0 -14
- package/src/components/Upload/UrlUpload/index.tsx +0 -104
- package/src/components/Upload/enums.ts +0 -5
- package/src/components/Upload/hooks/change.ts +0 -79
- package/src/components/Upload/hooks/customRequest.ts +0 -87
- package/src/components/Upload/hooks/propsMaker.ts +0 -20
- package/src/components/Upload/index.tsx +0 -119
- package/src/components/Upload/modal.ts +0 -33
- package/src/components/Upload/util.ts +0 -27
- package/src/components/config.ts +0 -47
- package/src/components/hooks/index.ts +0 -53
- package/src/components/index.tsx +0 -37
- package/src/components/modal.ts +0 -20
- package/src/components/styles/index.less +0 -3
- package/src/components/styles/local.less +0 -1
- package/src/components/typings.d.ts +0 -11
- package/src/index.less +0 -20
- package/src/index.tsx +0 -12
- package/src/pages/Checkbox/index.tsx +0 -14
- package/src/pages/DatePicker/index.tsx +0 -33
- package/src/pages/DrawerForm/index.tsx +0 -145
- package/src/pages/Form/index.tsx +0 -172
- package/src/pages/Input/index.tsx +0 -30
- package/src/pages/ModalForm/index.tsx +0 -191
- package/src/pages/Radio/index.tsx +0 -18
- package/src/pages/Select/index.tsx +0 -63
- package/src/pages/Switch/index.tsx +0 -18
- package/src/pages/Upload/index.tsx +0 -14
- package/src/routes.tsx +0 -80
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CascaderProps,
|
|
3
|
-
FormInstance,
|
|
4
|
-
FormItemProps,
|
|
5
|
-
FormProps,
|
|
6
|
-
} from "antd";
|
|
7
|
-
import type { HCheckboxProps } from "../CheckboxGroup/modal";
|
|
8
|
-
import type React from "react";
|
|
9
|
-
import type {
|
|
10
|
-
HButtonProps,
|
|
11
|
-
HInputProps,
|
|
12
|
-
HSelectInputProps,
|
|
13
|
-
} from "../Input/modal";
|
|
14
|
-
import type { HRadioGroupProps } from "../RadioGroup";
|
|
15
|
-
import type { HSelectProps } from "../Select/modal";
|
|
16
|
-
import type { ButtonProps } from "antd/es";
|
|
17
|
-
import type { HSwitchProps } from "../Switch";
|
|
18
|
-
import type {
|
|
19
|
-
HDatePickerProps,
|
|
20
|
-
HRangePickerProps,
|
|
21
|
-
HTimePickerProps,
|
|
22
|
-
} from "../TDPicker/modal";
|
|
23
|
-
import type { TextAreaProps } from "antd/es/input";
|
|
24
|
-
import type { IUpLoadProps } from "../Upload/modal";
|
|
25
|
-
import type { SelectProps } from "antd";
|
|
26
|
-
import type { RangePickerProps } from "antd/es/date-picker";
|
|
27
|
-
import type {
|
|
28
|
-
PromiseFnResult,
|
|
29
|
-
ValueCheckMapModal,
|
|
30
|
-
ValueSwitchMapModal,
|
|
31
|
-
DateRangePickerValueMapModal,
|
|
32
|
-
} from "../modal";
|
|
33
|
-
import type { ForwardedRef } from "react";
|
|
34
|
-
import type { DataFnProvider } from "../modal";
|
|
35
|
-
import type { ColProps } from "antd/lib/grid/col";
|
|
36
|
-
import type { Gutter } from "antd/lib/grid/row";
|
|
37
|
-
|
|
38
|
-
type RenderFun = (
|
|
39
|
-
props: HItemProps,
|
|
40
|
-
node: React.ReactNode,
|
|
41
|
-
form: FormInstance
|
|
42
|
-
) => React.ReactNode;
|
|
43
|
-
export type ItemPropsType =
|
|
44
|
-
| HCheckboxProps
|
|
45
|
-
| HInputProps
|
|
46
|
-
| HSelectInputProps
|
|
47
|
-
| HButtonProps
|
|
48
|
-
| HRadioGroupProps
|
|
49
|
-
| HSelectProps
|
|
50
|
-
| ButtonProps
|
|
51
|
-
| HSwitchProps
|
|
52
|
-
| HDatePickerProps
|
|
53
|
-
| HRangePickerProps
|
|
54
|
-
| HTimePickerProps
|
|
55
|
-
| TextAreaProps
|
|
56
|
-
| IUpLoadProps
|
|
57
|
-
| CascaderProps<any>;
|
|
58
|
-
|
|
59
|
-
export interface HoverModal {
|
|
60
|
-
text?: string;
|
|
61
|
-
icon?: React.ReactNode;
|
|
62
|
-
}
|
|
63
|
-
type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
64
|
-
|
|
65
|
-
export type HideModal = (form: HFormInstance) => boolean;
|
|
66
|
-
|
|
67
|
-
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
68
|
-
export type DispatchSourceDataModal = Record<
|
|
69
|
-
string,
|
|
70
|
-
Record<string, DispatchModal>
|
|
71
|
-
>;
|
|
72
|
-
export interface DispatchModal<T = string | string[]> {
|
|
73
|
-
fnKey?: string;
|
|
74
|
-
dependencies?: T;
|
|
75
|
-
manual?: boolean;
|
|
76
|
-
reset?: boolean;
|
|
77
|
-
}
|
|
78
|
-
export type LabelAlignModal = "left" | "right" | "topLeft" | "topRight" | "top";
|
|
79
|
-
|
|
80
|
-
export interface HItemProps extends Omit<FormItemProps, "name"|"labelAlign"> {
|
|
81
|
-
type?: string;
|
|
82
|
-
itemProps?: ItemPropsType;
|
|
83
|
-
render?: RenderFun;
|
|
84
|
-
helper?: HelperModal | string;
|
|
85
|
-
hover?: string | HoverModal;
|
|
86
|
-
// formItems?: HItemProps[]; 保留感觉没必要
|
|
87
|
-
labelWidth?: number;
|
|
88
|
-
hide?: boolean | HideModal;
|
|
89
|
-
placeholder?: string | string[];
|
|
90
|
-
// formatKeys?: string[];
|
|
91
|
-
name?: string;
|
|
92
|
-
dispatch?: DispatchModal;
|
|
93
|
-
itemSpan?: ColProps;
|
|
94
|
-
hideLabel?: boolean;
|
|
95
|
-
labelAlign?: LabelAlignModal;
|
|
96
|
-
}
|
|
97
|
-
export interface HFormProps<T = any, R = any>
|
|
98
|
-
extends Omit<FormProps, "form" | "onFinish"|"labelAlign"> {
|
|
99
|
-
configData: HItemProps[];
|
|
100
|
-
labelWidth?: number;
|
|
101
|
-
request?: (values: T, params?: any) => Promise<R>;
|
|
102
|
-
infoRequest?: PromiseFnResult;
|
|
103
|
-
valueType?: string;
|
|
104
|
-
form?: HFormInstance;
|
|
105
|
-
params?: any;
|
|
106
|
-
onFinish?: (values: T, params?: any) => void;
|
|
107
|
-
itemSpan?: ColProps;
|
|
108
|
-
hideLabel?: boolean;
|
|
109
|
-
gutter?: Gutter | [Gutter, Gutter];
|
|
110
|
-
submitLoading?: boolean;
|
|
111
|
-
labelAlign?: LabelAlignModal;
|
|
112
|
-
formItemStyle?:React.CSSProperties;
|
|
113
|
-
itemProps?:ItemPropsType
|
|
114
|
-
}
|
|
115
|
-
export interface HFormItemProps extends HItemProps {
|
|
116
|
-
required?: boolean;
|
|
117
|
-
value?: any;
|
|
118
|
-
onChange?: (val: any, item: any) => void;
|
|
119
|
-
itemSpan?: ColProps;
|
|
120
|
-
initValueProvider?: AddValueFormat;
|
|
121
|
-
subProvider?: AddValueFormat;
|
|
122
|
-
labelAlign?: LabelAlignModal;
|
|
123
|
-
}
|
|
124
|
-
export type argsFn = (...args: any[]) => void;
|
|
125
|
-
export interface FormContextProps {
|
|
126
|
-
loading?: boolean;
|
|
127
|
-
form: HFormInstance;
|
|
128
|
-
valueType?: string;
|
|
129
|
-
}
|
|
130
|
-
interface ConfigUploadProps {
|
|
131
|
-
exFiles?: string[];
|
|
132
|
-
maxSize?: number;
|
|
133
|
-
request?: PromiseFnResult;
|
|
134
|
-
}
|
|
135
|
-
export type ComponentModal =
|
|
136
|
-
| React.FunctionComponent<any>
|
|
137
|
-
| React.ComponentClass<any>
|
|
138
|
-
| React.ForwardRefExoticComponent<any>;
|
|
139
|
-
|
|
140
|
-
export interface ConfigComponentModal {
|
|
141
|
-
Component: ComponentModal;
|
|
142
|
-
placeholder?: DataFnProvider<HItemProps>;
|
|
143
|
-
requiredErrMsg?: DataFnProvider<HItemProps>;
|
|
144
|
-
}
|
|
145
|
-
export type DefaultComponentItemModal = ComponentModal | ConfigComponentModal;
|
|
146
|
-
export type DefaultComponentModal = Record<string, DefaultComponentItemModal>;
|
|
147
|
-
export interface IFormConfigContextProps {
|
|
148
|
-
fieldNames?: SelectProps["fieldNames"];
|
|
149
|
-
valueCheckMap?: ValueCheckMapModal;
|
|
150
|
-
valueSwitchMap?: ValueSwitchMapModal;
|
|
151
|
-
valueRangePickerValueMap?: DateRangePickerValueMapModal;
|
|
152
|
-
dateRanges?: RangePickerProps["ranges"];
|
|
153
|
-
uploadProps?: ConfigUploadProps;
|
|
154
|
-
defaultComponent?: DefaultComponentModal;
|
|
155
|
-
formItemStyle?:React.CSSProperties;
|
|
156
|
-
itemProps?:ItemPropsType
|
|
157
|
-
}
|
|
158
|
-
interface ActionModal {
|
|
159
|
-
key: string;
|
|
160
|
-
name?: string;
|
|
161
|
-
dispatch?: DispatchModal;
|
|
162
|
-
}
|
|
163
|
-
export interface HFormInstance extends FormInstance {
|
|
164
|
-
addFormat: (name: string, formats?: FormatItemModal) => void;
|
|
165
|
-
initValues: VoidFunction;
|
|
166
|
-
formatValues: (
|
|
167
|
-
values?: Record<string, any>,
|
|
168
|
-
formatKey?: string
|
|
169
|
-
) => Record<string, any>;
|
|
170
|
-
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
171
|
-
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
172
|
-
addDispatchListener: AddDispatchListenerFn;
|
|
173
|
-
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
174
|
-
reload: PromiseFnResult;
|
|
175
|
-
clear: VoidFunction;
|
|
176
|
-
resetFieldsInitValue: VoidFunction;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface ConnectConfigModal {
|
|
180
|
-
format?: Record<string, addFormatItemModal>;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
184
|
-
|
|
185
|
-
export interface FormatItemModal {
|
|
186
|
-
inputValue?: ValueFormat;
|
|
187
|
-
outputValue?: ValueFormat;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
type AddValueFormat = (
|
|
191
|
-
item: HFormItemProps,
|
|
192
|
-
value: Record<string, any>
|
|
193
|
-
) => Record<string, any>;
|
|
194
|
-
|
|
195
|
-
export interface addFormatItemModal {
|
|
196
|
-
inputValue: AddValueFormat;
|
|
197
|
-
outputValue: AddValueFormat;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface ConnectResultProps extends HFormItemProps {
|
|
201
|
-
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
202
|
-
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
203
|
-
ref?: ForwardedRef<any>;
|
|
204
|
-
value?: any;
|
|
205
|
-
onChange?: (value: any, item?: any) => void;
|
|
206
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Input, Button } from "antd";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { useRequest } from "ahooks";
|
|
4
|
-
import type { HButtonInputProps } from "./modal";
|
|
5
|
-
|
|
6
|
-
const Index: React.FC<HButtonInputProps> = ({
|
|
7
|
-
buttonProps = {},
|
|
8
|
-
value,
|
|
9
|
-
onChange,
|
|
10
|
-
children,
|
|
11
|
-
request,
|
|
12
|
-
...props
|
|
13
|
-
}) => {
|
|
14
|
-
const { onClick, type = "primary", ...oProps } = buttonProps;
|
|
15
|
-
const { run, loading } = useRequest(
|
|
16
|
-
(val) => {
|
|
17
|
-
return request?.(val);
|
|
18
|
-
},
|
|
19
|
-
{ manual: true }
|
|
20
|
-
);
|
|
21
|
-
const change = (e) => {
|
|
22
|
-
onChange?.(e.target.value);
|
|
23
|
-
};
|
|
24
|
-
const click = async () => {
|
|
25
|
-
let result = value;
|
|
26
|
-
if (request) {
|
|
27
|
-
result = await run(value);
|
|
28
|
-
}
|
|
29
|
-
onClick?.(result, onChange);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Input.Group compact style={{ display: "flex" }}>
|
|
34
|
-
<Input {...props} style={{ flex: 1 }} value={value} onChange={change} />
|
|
35
|
-
<Button
|
|
36
|
-
{...oProps}
|
|
37
|
-
type={type}
|
|
38
|
-
onClick={click}
|
|
39
|
-
loading={loading}
|
|
40
|
-
style={{ marginLeft: 4 }}
|
|
41
|
-
>
|
|
42
|
-
{children}
|
|
43
|
-
</Button>
|
|
44
|
-
</Input.Group>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
export default Index;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SketchPicker } from "react-color";
|
|
2
|
-
import type { HInputProps } from "@/components/Input/modal";
|
|
3
|
-
import { presetColors } from "./data";
|
|
4
|
-
import { useClassName } from "../../hooks";
|
|
5
|
-
|
|
6
|
-
export default ({ value, onChange }: HInputProps) => {
|
|
7
|
-
const classname = useClassName("hw-color-input-picker");
|
|
8
|
-
return (
|
|
9
|
-
<SketchPicker
|
|
10
|
-
width={"250px"}
|
|
11
|
-
styles={{}}
|
|
12
|
-
presetColors={presetColors}
|
|
13
|
-
color={value}
|
|
14
|
-
onChangeComplete={onChange}
|
|
15
|
-
className={classname}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
export const presetColors = [
|
|
2
|
-
"#fff1f0",
|
|
3
|
-
"#ffccc7",
|
|
4
|
-
"#ffa39e",
|
|
5
|
-
"#ff7875",
|
|
6
|
-
"#ff4d4f",
|
|
7
|
-
"#f5222d",
|
|
8
|
-
"#cf1322",
|
|
9
|
-
"#a8071a",
|
|
10
|
-
"#820014",
|
|
11
|
-
"#5c0011",
|
|
12
|
-
"#fff7e6",
|
|
13
|
-
"#ffe7ba",
|
|
14
|
-
"#ffd591",
|
|
15
|
-
"#ffc069",
|
|
16
|
-
"#ffa940",
|
|
17
|
-
"#fa8c16",
|
|
18
|
-
"#d46b08",
|
|
19
|
-
"#ad4e00",
|
|
20
|
-
"#873800",
|
|
21
|
-
"#612500",
|
|
22
|
-
"#feffe6",
|
|
23
|
-
"#ffffb8",
|
|
24
|
-
"#fffb8f",
|
|
25
|
-
"#fff566",
|
|
26
|
-
"#ffec3d",
|
|
27
|
-
"#fadb14",
|
|
28
|
-
"#d4b106",
|
|
29
|
-
"#ad8b00",
|
|
30
|
-
"#876800",
|
|
31
|
-
"#614700",
|
|
32
|
-
"#f6ffed",
|
|
33
|
-
"#d9f7be",
|
|
34
|
-
"#b7eb8f",
|
|
35
|
-
"#95de64",
|
|
36
|
-
"#73d13d",
|
|
37
|
-
"#52c41a",
|
|
38
|
-
"#389e0d",
|
|
39
|
-
"#237804",
|
|
40
|
-
"#135200",
|
|
41
|
-
"#092b00",
|
|
42
|
-
"#e6fffb",
|
|
43
|
-
"#b5f5ec",
|
|
44
|
-
"#87e8de",
|
|
45
|
-
"#5cdbd3",
|
|
46
|
-
"#36cfc9",
|
|
47
|
-
"#13c2c2",
|
|
48
|
-
"#08979c",
|
|
49
|
-
"#006d75",
|
|
50
|
-
"#00474f",
|
|
51
|
-
"#002329",
|
|
52
|
-
"#e6f7ff",
|
|
53
|
-
"#bae7ff",
|
|
54
|
-
"#91d5ff",
|
|
55
|
-
"#69c0ff",
|
|
56
|
-
"#40a9ff",
|
|
57
|
-
"#1890ff",
|
|
58
|
-
"#096dd9",
|
|
59
|
-
"#0050b3",
|
|
60
|
-
"#003a8c",
|
|
61
|
-
"#002766",
|
|
62
|
-
"#f0f5ff",
|
|
63
|
-
"#d6e4ff",
|
|
64
|
-
"#adc6ff",
|
|
65
|
-
"#85a5ff",
|
|
66
|
-
"#597ef7",
|
|
67
|
-
"#2f54eb",
|
|
68
|
-
"#1d39c4",
|
|
69
|
-
"#10239e",
|
|
70
|
-
"#061178",
|
|
71
|
-
"#030852",
|
|
72
|
-
"#f9f0ff",
|
|
73
|
-
"#efdbff",
|
|
74
|
-
"#d3adf7",
|
|
75
|
-
"#b37feb",
|
|
76
|
-
"#9254de",
|
|
77
|
-
"#722ed1",
|
|
78
|
-
"#531dab",
|
|
79
|
-
"#391085",
|
|
80
|
-
"#22075e",
|
|
81
|
-
"#120338",
|
|
82
|
-
"#fff0f6",
|
|
83
|
-
"#ffd6e7",
|
|
84
|
-
"#ffadd2",
|
|
85
|
-
"#ff85c0",
|
|
86
|
-
"#f759ab",
|
|
87
|
-
"#eb2f96",
|
|
88
|
-
"#c41d7f",
|
|
89
|
-
"#9e1068",
|
|
90
|
-
"#780650",
|
|
91
|
-
"#520339",
|
|
92
|
-
"#ffffff",
|
|
93
|
-
"#fafafa",
|
|
94
|
-
"#f5f5f5",
|
|
95
|
-
"#f0f0f0",
|
|
96
|
-
"#d9d9d9",
|
|
97
|
-
"#bfbfbf",
|
|
98
|
-
"#8c8c8c",
|
|
99
|
-
"#595959",
|
|
100
|
-
"#434343",
|
|
101
|
-
"#262626",
|
|
102
|
-
];
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { HInputProps } from "@/components/Input/modal";
|
|
2
|
-
import { Input, Popover } from "antd";
|
|
3
|
-
import Picker from "./Picker";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { useClassName } from "../../hooks";
|
|
6
|
-
export default ({
|
|
7
|
-
value,
|
|
8
|
-
onChange,
|
|
9
|
-
defaultColor = "rgba(0,0,0,1)",
|
|
10
|
-
...props
|
|
11
|
-
}: HInputProps) => {
|
|
12
|
-
const classname = useClassName("hw-color-box");
|
|
13
|
-
const inputVal = value?.trim();
|
|
14
|
-
const pickerValue = useMemo(() => {
|
|
15
|
-
const matchVal = inputVal || defaultColor;
|
|
16
|
-
if (typeof matchVal === "string") {
|
|
17
|
-
if (matchVal.startsWith("#")) {
|
|
18
|
-
return matchVal;
|
|
19
|
-
}
|
|
20
|
-
const rgbaRegular = /((rgba\())(?<rgba>.*?)(?=(\)))/;
|
|
21
|
-
const result = matchVal.match(rgbaRegular);
|
|
22
|
-
if (result?.groups?.rgba) {
|
|
23
|
-
const rgbas = result.groups.rgba.split(",");
|
|
24
|
-
return {
|
|
25
|
-
r: Number(rgbas[0]),
|
|
26
|
-
g: Number(rgbas[1]),
|
|
27
|
-
b: Number(rgbas[2]),
|
|
28
|
-
a: Number(rgbas[3]),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return "";
|
|
33
|
-
}, [inputVal]);
|
|
34
|
-
const colorChange = (val) => {
|
|
35
|
-
const { rgb } = val;
|
|
36
|
-
const text = `rgba(${rgb.r},${rgb.g},${rgb.b},${rgb.a})`;
|
|
37
|
-
onChange?.(text);
|
|
38
|
-
};
|
|
39
|
-
return (
|
|
40
|
-
<Input
|
|
41
|
-
{...props}
|
|
42
|
-
value={value}
|
|
43
|
-
onChange={onChange}
|
|
44
|
-
suffix={
|
|
45
|
-
<Popover
|
|
46
|
-
trigger="click"
|
|
47
|
-
content={<Picker value={pickerValue} onChange={colorChange} />}
|
|
48
|
-
placement="topLeft"
|
|
49
|
-
>
|
|
50
|
-
<div
|
|
51
|
-
style={{ backgroundColor: inputVal || defaultColor }}
|
|
52
|
-
className={classname}
|
|
53
|
-
/>
|
|
54
|
-
</Popover>
|
|
55
|
-
}
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Input } from "antd";
|
|
2
|
-
import type { HSelectInputProps } from "./modal";
|
|
3
|
-
import HSelect from "../Select";
|
|
4
|
-
import { defaultSelectStyle, defaultValueName } from "./defaultConfig";
|
|
5
|
-
import HFormConnect from "../Form/HFormConnect";
|
|
6
|
-
export enum SelectInputType {
|
|
7
|
-
input,
|
|
8
|
-
select,
|
|
9
|
-
}
|
|
10
|
-
export const Index = ({
|
|
11
|
-
selectProps = {},
|
|
12
|
-
value = {},
|
|
13
|
-
onChange,
|
|
14
|
-
valueName = defaultValueName,
|
|
15
|
-
addFormat,
|
|
16
|
-
addDispatchListener,
|
|
17
|
-
...props
|
|
18
|
-
}: HSelectInputProps) => {
|
|
19
|
-
const { input = "", select = "" } = valueName;
|
|
20
|
-
const { [input]: inputVal, [select]: selectVal } = value;
|
|
21
|
-
const {
|
|
22
|
-
style = defaultSelectStyle,
|
|
23
|
-
placeholder = "请选择",
|
|
24
|
-
...sProps
|
|
25
|
-
} = selectProps;
|
|
26
|
-
const change = (val, key) => {
|
|
27
|
-
const newVal = { ...value };
|
|
28
|
-
newVal[key] = val;
|
|
29
|
-
const type = key === input ? SelectInputType.input : SelectInputType.select;
|
|
30
|
-
onChange?.(newVal, type);
|
|
31
|
-
};
|
|
32
|
-
addFormat?.({
|
|
33
|
-
float: {
|
|
34
|
-
inputValue: (item, initValue) => {
|
|
35
|
-
const { name = "" } = item;
|
|
36
|
-
const resultObj = {};
|
|
37
|
-
Object.values(valueName).forEach((key) => {
|
|
38
|
-
resultObj[key] = initValue[key];
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
[name]: resultObj,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
outputValue: (item, outputValue) => {
|
|
45
|
-
const { name = "" } = item;
|
|
46
|
-
const { [name]: itemVal = {} } = outputValue;
|
|
47
|
-
const newItemVal = { [itemVal[select]]: itemVal[input] };
|
|
48
|
-
return {
|
|
49
|
-
...newItemVal,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
return (
|
|
55
|
-
<Input
|
|
56
|
-
value={inputVal}
|
|
57
|
-
onChange={(e) => {
|
|
58
|
-
change(e.target.value, input);
|
|
59
|
-
}}
|
|
60
|
-
addonBefore={
|
|
61
|
-
<HSelect
|
|
62
|
-
{...sProps}
|
|
63
|
-
style={style}
|
|
64
|
-
placeholder={placeholder}
|
|
65
|
-
value={selectVal}
|
|
66
|
-
onChange={(val) => {
|
|
67
|
-
change(val, select);
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
}
|
|
71
|
-
{...props}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
export default HFormConnect(Index);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Input from "./index";
|
|
2
|
-
import type { HInputProps } from "./modal";
|
|
3
|
-
import HFormConnect from "../Form/HFormConnect";
|
|
4
|
-
|
|
5
|
-
const Index = ({ addFormat, ...props }: HInputProps) => {
|
|
6
|
-
addFormat?.({
|
|
7
|
-
float: {
|
|
8
|
-
inputValue: (item, initValue) => {
|
|
9
|
-
const { name: valueName = "" } = item;
|
|
10
|
-
return {
|
|
11
|
-
[valueName]: initValue[valueName],
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
outputValue: (item, outputValue) => {
|
|
15
|
-
const { name = "" } = item;
|
|
16
|
-
const { [name]: itemVal } = outputValue;
|
|
17
|
-
return {
|
|
18
|
-
[name]: itemVal?.trim(),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return <Input {...props} />;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default HFormConnect(Index);
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import ButtonInput from "./ButtonInput";
|
|
3
|
-
import { useRequest } from "ahooks";
|
|
4
|
-
import type { HFormInstance } from "../Form/modal";
|
|
5
|
-
import type { InputProps } from "antd";
|
|
6
|
-
export interface HVerificationCodeInputProps extends Omit<InputProps, "form"> {
|
|
7
|
-
request?: (value: any) => Promise<any>;
|
|
8
|
-
form?: HFormInstance;
|
|
9
|
-
}
|
|
10
|
-
export default ({
|
|
11
|
-
value,
|
|
12
|
-
request,
|
|
13
|
-
form,
|
|
14
|
-
onChange,
|
|
15
|
-
...props
|
|
16
|
-
}: HVerificationCodeInputProps) => {
|
|
17
|
-
const [countdown, setCountdown] = useState<number>(0);
|
|
18
|
-
const timer = useMemo<{ time: any }>(() => {
|
|
19
|
-
return {
|
|
20
|
-
time: undefined,
|
|
21
|
-
};
|
|
22
|
-
}, []);
|
|
23
|
-
const timerControl = useCallback(() => {
|
|
24
|
-
timer.time = setInterval(() => {
|
|
25
|
-
setCountdown((oldVal = 0) => {
|
|
26
|
-
const newVal = oldVal - 1;
|
|
27
|
-
if (newVal <= 0) {
|
|
28
|
-
clearInterval(timer.time);
|
|
29
|
-
}
|
|
30
|
-
return newVal;
|
|
31
|
-
});
|
|
32
|
-
}, 1000);
|
|
33
|
-
}, []);
|
|
34
|
-
const { run, loading } = useRequest(
|
|
35
|
-
async () => {
|
|
36
|
-
if (!request) {
|
|
37
|
-
return Promise.resolve({});
|
|
38
|
-
}
|
|
39
|
-
const val = form?.getFieldsValue();
|
|
40
|
-
const result = await request?.(val);
|
|
41
|
-
if (result) {
|
|
42
|
-
setCountdown(60);
|
|
43
|
-
}
|
|
44
|
-
timerControl();
|
|
45
|
-
return result;
|
|
46
|
-
},
|
|
47
|
-
{ manual: true }
|
|
48
|
-
);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
return () => {
|
|
51
|
-
clearInterval(timer.time);
|
|
52
|
-
};
|
|
53
|
-
}, []);
|
|
54
|
-
const text = () => {
|
|
55
|
-
if (!countdown) {
|
|
56
|
-
return "获取验证码";
|
|
57
|
-
}
|
|
58
|
-
let countdownStr = `${countdown}`;
|
|
59
|
-
if (countdown < 10) {
|
|
60
|
-
countdownStr = `0${countdownStr}`;
|
|
61
|
-
}
|
|
62
|
-
return `${countdownStr}秒后重新获取`;
|
|
63
|
-
};
|
|
64
|
-
return (
|
|
65
|
-
<ButtonInput
|
|
66
|
-
value={value}
|
|
67
|
-
onChange={onChange}
|
|
68
|
-
buttonProps={{ onClick: run, loading, disabled: !!countdown }}
|
|
69
|
-
{...props}
|
|
70
|
-
>
|
|
71
|
-
{text()}
|
|
72
|
-
</ButtonInput>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Input, message } from "antd";
|
|
2
|
-
import type { HInputProps } from "./modal";
|
|
3
|
-
import { CopyOutlined } from "@ant-design/icons";
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import { CopyToClipboard } from "react-copy-to-clipboard";
|
|
6
|
-
const CopyDom = ({ value }: HInputProps) => {
|
|
7
|
-
return (
|
|
8
|
-
<CopyToClipboard
|
|
9
|
-
text={value}
|
|
10
|
-
onCopy={() => {
|
|
11
|
-
message.success("复制成功!");
|
|
12
|
-
}}
|
|
13
|
-
>
|
|
14
|
-
<CopyOutlined />
|
|
15
|
-
</CopyToClipboard>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
export default ({ copy, value, addonAfter, ...props }: HInputProps) => {
|
|
19
|
-
return (
|
|
20
|
-
<Input
|
|
21
|
-
{...props}
|
|
22
|
-
value={value}
|
|
23
|
-
addonAfter={copy ? <CopyDom value={value} /> : addonAfter}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
};
|