@hw-component/form 0.0.1-beta-v6 → 0.0.1-beta-v7

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.
Files changed (72) hide show
  1. package/es/CheckboxGroup/index.d.ts +1 -1
  2. package/es/DiaLogForm/DrawerForm/Footer.d.ts +4 -0
  3. package/es/DiaLogForm/DrawerForm/Footer.js +23 -0
  4. package/es/DiaLogForm/DrawerForm/Title.d.ts +4 -0
  5. package/es/DiaLogForm/DrawerForm/Title.js +18 -0
  6. package/es/DiaLogForm/DrawerForm/index.d.ts +4 -0
  7. package/es/DiaLogForm/DrawerForm/index.js +111 -0
  8. package/es/DiaLogForm/ModalForm.d.ts +4 -0
  9. package/es/{ModalForm/index.js → DiaLogForm/ModalForm.js} +36 -6
  10. package/es/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
  11. package/es/{ModalForm → DiaLogForm}/hooks.js +52 -7
  12. package/es/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
  13. package/es/Form/HFormConnect.d.ts +1 -2
  14. package/es/Form/HFormConnect.js +8 -15
  15. package/es/Form/config.d.ts +4 -4
  16. package/es/Form/config.js +4 -4
  17. package/es/Form/modal.d.ts +7 -1
  18. package/es/Input/SelectInput.d.ts +1 -1
  19. package/es/TDPicker/RangePicker.d.ts +1 -1
  20. package/es/Upload/UrlUpload/index.d.ts +2 -2
  21. package/es/Upload/UrlUpload/index.js +3 -3
  22. package/es/Upload/index.d.ts +1 -2
  23. package/es/Upload/index.js +39 -5
  24. package/es/Upload/modal.d.ts +2 -0
  25. package/es/index.d.ts +7 -6
  26. package/es/index.js +5 -3
  27. package/lib/CheckboxGroup/index.d.ts +1 -1
  28. package/lib/DiaLogForm/DrawerForm/Footer.d.ts +4 -0
  29. package/lib/DiaLogForm/DrawerForm/Footer.js +26 -0
  30. package/lib/DiaLogForm/DrawerForm/Title.d.ts +4 -0
  31. package/lib/DiaLogForm/DrawerForm/Title.js +21 -0
  32. package/lib/DiaLogForm/DrawerForm/index.d.ts +4 -0
  33. package/lib/DiaLogForm/DrawerForm/index.js +114 -0
  34. package/lib/DiaLogForm/ModalForm.d.ts +4 -0
  35. package/lib/{ModalForm/index.js → DiaLogForm/ModalForm.js} +35 -5
  36. package/lib/{ModalForm → DiaLogForm}/hooks.d.ts +5 -2
  37. package/lib/{ModalForm → DiaLogForm}/hooks.js +52 -6
  38. package/lib/{ModalForm → DiaLogForm}/modal.d.ts +4 -1
  39. package/lib/Form/HFormConnect.d.ts +1 -2
  40. package/lib/Form/HFormConnect.js +8 -15
  41. package/lib/Form/config.d.ts +4 -4
  42. package/lib/Form/modal.d.ts +7 -1
  43. package/lib/Input/SelectInput.d.ts +1 -1
  44. package/lib/TDPicker/RangePicker.d.ts +1 -1
  45. package/lib/Upload/UrlUpload/index.d.ts +2 -2
  46. package/lib/Upload/UrlUpload/index.js +3 -3
  47. package/lib/Upload/index.d.ts +1 -2
  48. package/lib/Upload/index.js +39 -5
  49. package/lib/Upload/modal.d.ts +2 -0
  50. package/lib/index.d.ts +7 -6
  51. package/lib/index.js +6 -3
  52. package/package.json +1 -1
  53. package/src/components/DiaLogForm/DrawerForm/Footer.tsx +19 -0
  54. package/src/components/DiaLogForm/DrawerForm/Title.tsx +12 -0
  55. package/src/components/DiaLogForm/DrawerForm/index.tsx +85 -0
  56. package/src/components/{ModalForm/index.tsx → DiaLogForm/ModalForm.tsx} +10 -2
  57. package/src/components/{ModalForm → DiaLogForm}/hooks.ts +27 -2
  58. package/src/components/{ModalForm → DiaLogForm}/modal.ts +4 -1
  59. package/src/components/Form/HFormConnect.tsx +21 -7
  60. package/src/components/Form/config.ts +2 -2
  61. package/src/components/Form/modal.ts +7 -1
  62. package/src/components/Input/SelectInput.tsx +1 -0
  63. package/src/components/TDPicker/modal.ts +0 -1
  64. package/src/components/Upload/UrlUpload/index.tsx +2 -2
  65. package/src/components/Upload/index.tsx +39 -7
  66. package/src/components/Upload/modal.ts +2 -0
  67. package/src/components/index.tsx +5 -4
  68. package/src/pages/DrawerForm/index.tsx +127 -0
  69. package/src/pages/Form/index.tsx +3 -0
  70. package/src/routes.tsx +7 -0
  71. package/es/ModalForm/index.d.ts +0 -4
  72. package/lib/ModalForm/index.d.ts +0 -4
@@ -5,8 +5,7 @@ import type { IUploadRefModal, IUrlUploadProps } from "../modal";
5
5
  import TypeEle from "../MediaTypeEle/TypeEle";
6
6
  import { useRef, useState } from "react";
7
7
  import type { RcFile, UploadFile } from "antd/es/upload/interface";
8
-
9
- export default ({
8
+ const Index = ({
10
9
  placeholder = "请输入文件地址",
11
10
  value = [],
12
11
  onChange,
@@ -89,3 +88,4 @@ export default ({
89
88
  </Space>
90
89
  );
91
90
  };
91
+ export default Index;
@@ -1,11 +1,12 @@
1
- import { Upload } from "antd";
2
- import Btn from "./Btn";
3
1
  import React, { useImperativeHandle, useMemo, useState } from "react";
2
+ import type { IUpLoadProps, IUploadRefModal } from "./modal";
3
+ import { useProps } from "./hooks/propsMaker";
4
4
  import type { IPreviewProps } from "./Preview";
5
5
  import Preview from "./Preview";
6
6
  import { useChange } from "./hooks/change";
7
- import type { IUpLoadProps, IUploadRefModal } from "./modal";
8
- import { useProps } from "./hooks/propsMaker";
7
+ import { Upload } from "antd";
8
+ import Btn from "./Btn";
9
+ import HFormConnect from "../Form/HFormConnect";
9
10
 
10
11
  const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
11
12
  {
@@ -18,6 +19,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
18
19
  onPreview,
19
20
  request,
20
21
  maxSize,
22
+ addFormat,
21
23
  ...props
22
24
  },
23
25
  ref
@@ -52,10 +54,40 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
52
54
  file,
53
55
  });
54
56
  };
55
-
56
57
  const maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
57
58
  const { visible, file: previewFile } = previewModal;
58
-
59
+ addFormat?.({
60
+ float: {
61
+ inputValue: (item, initValue) => {
62
+ const { name = "" } = item;
63
+ const initFileList = initValue[name] || [];
64
+ const fileList = initFileList.map((url, index) => {
65
+ return {
66
+ name: url,
67
+ response: {
68
+ url,
69
+ },
70
+ status: "done",
71
+ uid: `init-${index}`,
72
+ thumbUrl: url,
73
+ };
74
+ });
75
+ return {
76
+ [name]: fileList,
77
+ };
78
+ },
79
+ outputValue: (item, outputValue) => {
80
+ const { name: valueName = "" } = item;
81
+ const { [valueName]: itemVal = [] } = outputValue;
82
+ const urls = itemVal.map((fileItem) => {
83
+ return fileItem.response.url;
84
+ });
85
+ return {
86
+ [valueName]: urls,
87
+ };
88
+ },
89
+ },
90
+ });
59
91
  return (
60
92
  <div style={contentStyle}>
61
93
  <Upload
@@ -82,4 +114,4 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
82
114
  );
83
115
  };
84
116
 
85
- export default React.forwardRef(Index);
117
+ export default HFormConnect(React.forwardRef(Index));
@@ -3,6 +3,7 @@ import type { UploadFile } from "antd/es/upload/interface";
3
3
  import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
4
4
  import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
+ import type { addFormatItemModal } from "@/components/Form/modal";
6
7
 
7
8
  export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
8
9
  exFiles?: string[];
@@ -14,6 +15,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
14
15
  value?: UploadFile[];
15
16
  maxRowNum?: number;
16
17
  maxSize?: number;
18
+ addFormat?: (config: Record<string, addFormatItemModal>) => void;
17
19
  }
18
20
  export interface IMediaTypeEleProps {
19
21
  file?: UploadFile;
@@ -3,9 +3,9 @@ import FormConfig from "./Form/config";
3
3
  import PageHandler from "./PageHandler";
4
4
  export { default as HForm } from "./Form";
5
5
  export { default as useHForm } from "./Form/hooks/useHForm";
6
- export { useHModalForm } from "./ModalForm/hooks";
7
- import ModalForm from "./ModalForm";
8
-
6
+ export { useHModalForm } from "./DiaLogForm/hooks";
7
+ import ModalForm from "./DiaLogForm/ModalForm";
8
+ import DrawerForm from "./DiaLogForm/DrawerForm";
9
9
  export const HSelect = FormConfig.select;
10
10
  export const HInput = FormConfig.input;
11
11
  export const HSelectInput = FormConfig.selectInput;
@@ -22,5 +22,6 @@ export const HTimePicker = FormConfig.timePicker;
22
22
  export const HInputNumber = FormConfig.inputNumber;
23
23
  export const HPageHandler = PageHandler;
24
24
  export const HFormConfigProvider = FormConfig.formConfigProvider;
25
- export const HTextArea=FormConfig.textArea;
25
+ export const HTextArea = FormConfig.textArea;
26
26
  export const HModalForm = ModalForm;
27
+ export const HDrawerForm = DrawerForm;
@@ -0,0 +1,127 @@
1
+ import { Button } from "antd";
2
+ import { HDrawerForm, useHModalForm } from "../../components";
3
+ const data = [
4
+ {
5
+ label: "输入框",
6
+ name: "name",
7
+ rules: [
8
+ () => {
9
+ return {
10
+ required: true,
11
+ };
12
+ },
13
+ ],
14
+ },
15
+ {
16
+ label: "数字",
17
+ name: "sz",
18
+ type: "inputNumber",
19
+ rules: [{ required: true }],
20
+ },
21
+ {
22
+ label: "下拉输入框",
23
+ name: "selectInput",
24
+ type: "selectInput",
25
+ rules: [{ required: true }],
26
+ itemProps: {
27
+ valueName: {
28
+ select: "op",
29
+ input: "opInput",
30
+ },
31
+ selectProps: {
32
+ options: [{ label: "测试", value: 1 }],
33
+ },
34
+ },
35
+ },
36
+ {
37
+ label: "按钮输入框",
38
+ name: "buttonInput",
39
+ type: "buttonInput",
40
+ children: "点击",
41
+ rules: [{ required: true }],
42
+ },
43
+ {
44
+ label: "选择",
45
+ name: "checkboxGroup",
46
+ type: "checkboxGroup",
47
+ rules: [{ required: true }],
48
+ helper: "帮助我",
49
+ options: [
50
+ { label: "选择1", value: "check1" },
51
+ { label: "选择2", value: "check2" },
52
+ ],
53
+ },
54
+ {
55
+ label: "开关",
56
+ name: "switch",
57
+ type: "switch",
58
+ rules: [{ required: true }],
59
+ },
60
+ {
61
+ label: "时间",
62
+ name: "datePicker",
63
+ type: "datePicker",
64
+ hover: "时间选择",
65
+ helper: "帮助我",
66
+ rules: [{ required: true }],
67
+ },
68
+ {
69
+ label: "时间段",
70
+ name: "rangePicker",
71
+ type: "rangePicker",
72
+ helper: "帮助我",
73
+ rules: [{ required: true }],
74
+ itemProps: {
75
+ valueMap: {
76
+ start: "testStart",
77
+ end: "testEnd",
78
+ },
79
+ },
80
+ },
81
+ {
82
+ label: "时分秒",
83
+ name: "timePicker",
84
+ type: "timePicker",
85
+ rules: [{ required: true }],
86
+ },
87
+ {
88
+ label: "文件",
89
+ name: "upload",
90
+ type: "upload",
91
+ rules: [{ required: true }],
92
+ },
93
+ {
94
+ label: "地址文件",
95
+ name: "urlUpload",
96
+ type: "urlUpload",
97
+ rules: [{ required: true }],
98
+ },
99
+ ];
100
+ export default () => {
101
+ const modalForm = useHModalForm();
102
+ return (
103
+ <>
104
+ <Button
105
+ onClick={() => {
106
+ modalForm.show({
107
+ initialValues: {
108
+ check1: 1,
109
+ testStart: "1694747960",
110
+ testEnd: "1693538359",
111
+ op: 1,
112
+ opInput: "12121",
113
+ },
114
+ });
115
+ }}
116
+ >
117
+ 打开
118
+ </Button>
119
+ <HDrawerForm
120
+ configData={data}
121
+ labelWidth={88}
122
+ modalForm={modalForm}
123
+ title="测试"
124
+ />
125
+ </>
126
+ );
127
+ };
@@ -128,6 +128,9 @@ export default () => {
128
128
  testEnd: "1693538359",
129
129
  op: 1,
130
130
  opInput: "12121",
131
+ upload: [
132
+ "https://img2.baidu.com/it/u=2048195462,703560066&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",
133
+ ],
131
134
  });
132
135
  }, 3000);
133
136
  });
package/src/routes.tsx CHANGED
@@ -9,6 +9,8 @@ import DatePicker from "./pages/DatePicker";
9
9
  import Upload from "./pages/Upload";
10
10
  import Form from "./pages/Form";
11
11
  import ModalForm from "./pages/ModalForm";
12
+ import DrawerForm from "./pages/DrawerForm";
13
+
12
14
  export interface RouteModal {
13
15
  path?: string;
14
16
  name?: string;
@@ -68,6 +70,11 @@ const routes: RouteModal[] = [
68
70
  name: "弹窗表单",
69
71
  element: <ModalForm />,
70
72
  },
73
+ {
74
+ path: "/drawerForm",
75
+ name: "抽屉表单",
76
+ element: <DrawerForm />,
77
+ },
71
78
  ];
72
79
 
73
80
  export default routes;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ModalFormProps } from "@/components/ModalForm/modal";
3
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, ...props }: ModalFormProps) => JSX.Element;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ModalFormProps } from "@/components/ModalForm/modal";
3
- declare const _default: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, ...props }: ModalFormProps) => JSX.Element;
4
- export default _default;