@hw-component/form 1.11.0 → 1.11.2
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 +3 -2
- package/es/Form/config.js +3 -1
- package/es/Input/SelectInput.js +0 -1
- package/es/TDPicker/RangePicker.js +18 -3
- package/es/TDPicker/modal.d.ts +1 -1
- package/es/Upload/ImgCropUpload.d.ts +3 -0
- package/es/Upload/ImgCropUpload.js +71 -0
- package/es/Upload/MediaTypeEle/index.js +2 -1
- package/es/Upload/hooks/change.js +0 -1
- package/es/Upload/util.js +0 -2
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/lib/Form/config.d.ts +3 -2
- package/lib/Form/config.js +3 -1
- package/lib/Input/SelectInput.js +0 -1
- package/lib/TDPicker/RangePicker.js +17 -2
- package/lib/TDPicker/modal.d.ts +1 -1
- package/lib/Upload/ImgCropUpload.d.ts +3 -0
- package/lib/Upload/ImgCropUpload.js +74 -0
- package/lib/Upload/MediaTypeEle/index.js +2 -1
- package/lib/Upload/hooks/change.js +0 -1
- package/lib/Upload/util.js +0 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -0
- package/package.json +3 -2
- package/src/components/Form/config.ts +3 -0
- package/src/components/Form/hooks/useHForm.ts +12 -12
- package/src/components/Input/SelectInput.tsx +0 -1
- package/src/components/InputGroup/index.tsx +1 -2
- package/src/components/Select/index.tsx +4 -4
- package/src/components/TDPicker/RangePicker.tsx +15 -4
- package/src/components/TDPicker/modal.ts +1 -1
- package/src/components/Upload/ImgCropUpload.tsx +50 -0
- package/src/components/Upload/MediaTypeEle/index.tsx +1 -1
- package/src/components/Upload/hooks/change.ts +0 -1
- package/src/components/Upload/hooks/customRequest.ts +0 -1
- package/src/components/Upload/util.ts +0 -2
- package/src/components/index.tsx +2 -0
- package/src/pages/DatePicker/index.tsx +2 -1
- package/src/pages/Form/index.tsx +26 -3
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
useRangePickerTimeVal,
|
|
6
6
|
useRangeValueProvider,
|
|
7
7
|
} from "./hooks";
|
|
8
|
-
import React, {
|
|
8
|
+
import React, {useMemo, useState} from "react";
|
|
9
9
|
import type { RangePickerProps } from "antd/es/date-picker";
|
|
10
10
|
import { useMatchConfigProps } from "../hooks";
|
|
11
11
|
import type { HItemProps } from "../Form/modal";
|
|
@@ -15,6 +15,8 @@ import InputGroup from "../InputGroup";
|
|
|
15
15
|
|
|
16
16
|
const RangePicker = DatePicker.RangePicker as any;
|
|
17
17
|
|
|
18
|
+
type RangeValue = (Moment|null) [];
|
|
19
|
+
|
|
18
20
|
const PickerContent: React.ForwardRefRenderFunction<
|
|
19
21
|
HRangePickerPropsRef,
|
|
20
22
|
HRangePickerProps
|
|
@@ -38,6 +40,7 @@ const PickerContent: React.ForwardRefRenderFunction<
|
|
|
38
40
|
valueRangePickerValueMap: valueMap,
|
|
39
41
|
dateRanges: undefined,
|
|
40
42
|
});
|
|
43
|
+
const [dates, setDates] = useState<RangeValue>([null,null]);
|
|
41
44
|
const dateMapKeys = useGetTimeKey({
|
|
42
45
|
valueMap: valueRangePickerValueMap,
|
|
43
46
|
name,
|
|
@@ -102,6 +105,13 @@ const PickerContent: React.ForwardRefRenderFunction<
|
|
|
102
105
|
});
|
|
103
106
|
onChange?.(paramsProvider(subVal));
|
|
104
107
|
};
|
|
108
|
+
const onOpenChange = (open: boolean) => {
|
|
109
|
+
if (open) {
|
|
110
|
+
setDates(timeVal);
|
|
111
|
+
} else {
|
|
112
|
+
setDates([null,null]);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
105
115
|
return (
|
|
106
116
|
<RangePicker
|
|
107
117
|
value={timeVal}
|
|
@@ -109,10 +119,11 @@ const PickerContent: React.ForwardRefRenderFunction<
|
|
|
109
119
|
style={{ width: "100%", ...style }}
|
|
110
120
|
onChange={change}
|
|
111
121
|
showTime={showTime}
|
|
112
|
-
onCalendarChange={
|
|
122
|
+
onCalendarChange={val => setDates(val)}
|
|
123
|
+
onOpenChange={onOpenChange}
|
|
113
124
|
ranges={defaultRanges as RangePickerProps["ranges"]}
|
|
114
125
|
disabledDate={(currentDate) => {
|
|
115
|
-
return !!disabledDate?.(currentDate,
|
|
126
|
+
return !!disabledDate?.(currentDate, dates);
|
|
116
127
|
}}
|
|
117
128
|
{...props}
|
|
118
129
|
/>
|
|
@@ -126,7 +137,7 @@ const HRangePicker: React.ForwardRefRenderFunction<
|
|
|
126
137
|
> = (props, ref) => {
|
|
127
138
|
return (
|
|
128
139
|
<InputGroup {...props}>
|
|
129
|
-
<Content ref={ref}
|
|
140
|
+
<Content ref={ref}/>
|
|
130
141
|
</InputGroup>
|
|
131
142
|
);
|
|
132
143
|
};
|
|
@@ -38,7 +38,7 @@ export interface HRangePickerProps
|
|
|
38
38
|
valueMap?: DateRangePickerValueMapModal;
|
|
39
39
|
ranges?: RangePickerProps["ranges"] | boolean;
|
|
40
40
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
41
|
-
disabledDate?: DisabledDateFnModal<Moment[]
|
|
41
|
+
disabledDate?: DisabledDateFnModal<(Moment|null) []>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface HTimePickerProps
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import ImgCrop from 'antd-img-crop';
|
|
2
|
+
import {message, Upload} from "antd";
|
|
3
|
+
import Btn from "./Btn";
|
|
4
|
+
import React, {useState} from "react";
|
|
5
|
+
import type {IUpLoadProps} from "./modal";
|
|
6
|
+
import {checkFileType} from "./util";
|
|
7
|
+
import Preview, {type IPreviewProps} from "./Preview";
|
|
8
|
+
|
|
9
|
+
export default ({value,onChange,maxCount=1,exFiles=["PNG","JPEG","JPG","GIF"]}:IUpLoadProps)=>{
|
|
10
|
+
const [previewModal, setPreviewModal] = useState<IPreviewProps>({});
|
|
11
|
+
const change=({file,fileList})=>{
|
|
12
|
+
if (!checkFileType(file, exFiles)) {
|
|
13
|
+
return message.error(new Error("文件格式错误!"));
|
|
14
|
+
}
|
|
15
|
+
if (maxCount===1){
|
|
16
|
+
onChange?.([file]);
|
|
17
|
+
return ;
|
|
18
|
+
}
|
|
19
|
+
onChange?.(fileList);
|
|
20
|
+
}
|
|
21
|
+
const { visible, file: previewFile } = previewModal;
|
|
22
|
+
const preview = (file) => {
|
|
23
|
+
setPreviewModal({
|
|
24
|
+
visible: true,
|
|
25
|
+
file,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
return <>
|
|
29
|
+
<ImgCrop rotate>
|
|
30
|
+
<Upload
|
|
31
|
+
customRequest={({onSuccess})=>{
|
|
32
|
+
onSuccess?.({});
|
|
33
|
+
}}
|
|
34
|
+
fileList={value}
|
|
35
|
+
listType="picture-card"
|
|
36
|
+
onChange={change}
|
|
37
|
+
onPreview={preview}
|
|
38
|
+
>
|
|
39
|
+
<Btn value={value} maxCount={maxCount} listType="picture-card"/>
|
|
40
|
+
</Upload>
|
|
41
|
+
</ImgCrop>
|
|
42
|
+
<Preview
|
|
43
|
+
visible={visible}
|
|
44
|
+
file={previewFile}
|
|
45
|
+
onCancel={() => {
|
|
46
|
+
setPreviewModal({});
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</>
|
|
50
|
+
}
|
|
@@ -4,7 +4,6 @@ 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";
|
|
8
7
|
|
|
9
8
|
interface SubReqParamsModal {
|
|
10
9
|
request?: IUpLoadProps["request"];
|
|
@@ -3,7 +3,6 @@ import type { UploadFile } from "antd/es/upload/interface";
|
|
|
3
3
|
export const getFileExt = (file: UploadFile): string => {
|
|
4
4
|
const { name } = file;
|
|
5
5
|
const index = name.lastIndexOf(".");
|
|
6
|
-
console.log(index, name, file);
|
|
7
6
|
return name.substring(index + 1).toUpperCase();
|
|
8
7
|
};
|
|
9
8
|
|
|
@@ -11,7 +10,6 @@ export const checkFileType = (
|
|
|
11
10
|
file: UploadFile,
|
|
12
11
|
exFiles: string[] | null = []
|
|
13
12
|
) => {
|
|
14
|
-
console.log(file);
|
|
15
13
|
if (!exFiles) {
|
|
16
14
|
return true;
|
|
17
15
|
}
|
package/src/components/index.tsx
CHANGED
|
@@ -12,6 +12,8 @@ export { default as HInputGroup } from "./InputGroup";
|
|
|
12
12
|
import ModalForm from "./DialogForm/ModalForm";
|
|
13
13
|
import DrawerForm from "./DialogForm/DrawerForm";
|
|
14
14
|
export const HSelect = FormConfig.select;
|
|
15
|
+
export const HImgCropUpload = FormConfig.imgCropUpload;
|
|
16
|
+
|
|
15
17
|
export const HInput = FormConfig.input;
|
|
16
18
|
export const HRichEditor = FormConfig.richEditor;
|
|
17
19
|
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
HBasicForm,
|
|
7
7
|
HRangePicker,
|
|
8
8
|
HSelectInput,
|
|
9
|
+
HUpload
|
|
9
10
|
} from "../../components";
|
|
10
11
|
import { useEffect, useState } from "react";
|
|
11
12
|
import { Button, Col, Form, Input, Row, Space } from "antd";
|
|
13
|
+
import ImgCrop from 'antd-img-crop';
|
|
12
14
|
|
|
13
15
|
const Test3 = ({ value = {}, onChange }) => {
|
|
14
16
|
const { fs, end } = value;
|
|
@@ -143,6 +145,25 @@ const TestItem1 = ({ value, onChange }) => {
|
|
|
143
145
|
);
|
|
144
146
|
};
|
|
145
147
|
|
|
148
|
+
const HeaderImg=({ value=[], onChange }) => {
|
|
149
|
+
console.log(value);
|
|
150
|
+
return (
|
|
151
|
+
<ImgCrop rotate>
|
|
152
|
+
<HUpload
|
|
153
|
+
value={value}
|
|
154
|
+
request={null}
|
|
155
|
+
onChange={(info)=>{
|
|
156
|
+
console.log(info,"info")
|
|
157
|
+
onChange(info.fileList)
|
|
158
|
+
}}
|
|
159
|
+
|
|
160
|
+
>
|
|
161
|
+
天际
|
|
162
|
+
</HUpload>
|
|
163
|
+
</ImgCrop>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
146
167
|
export default () => {
|
|
147
168
|
const form = useHForm();
|
|
148
169
|
const [id, setId] = useState(1);
|
|
@@ -226,7 +247,9 @@ export default () => {
|
|
|
226
247
|
label: "你好啊",
|
|
227
248
|
type: "rangePicker",
|
|
228
249
|
hover: ["123123213", "22222"],
|
|
229
|
-
|
|
250
|
+
rules: [
|
|
251
|
+
{ required: true, message: "Please input your password!" },
|
|
252
|
+
],
|
|
230
253
|
itemProps: {
|
|
231
254
|
valueMap: {
|
|
232
255
|
start: "start",
|
|
@@ -237,14 +260,14 @@ export default () => {
|
|
|
237
260
|
{
|
|
238
261
|
name: "num1",
|
|
239
262
|
label: "必填",
|
|
240
|
-
|
|
263
|
+
type:"imgCropUpload",
|
|
241
264
|
dependencies: ["num"],
|
|
242
265
|
},
|
|
243
266
|
]}
|
|
244
267
|
dismissOnPressEnter={false}
|
|
245
268
|
form={form}
|
|
246
269
|
initialValues={{
|
|
247
|
-
|
|
270
|
+
|
|
248
271
|
}}
|
|
249
272
|
labelAlign={"top"}
|
|
250
273
|
onValuesChange={(val) => {
|