@hzab/form-render 1.6.17 → 1.6.19

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 (60) hide show
  1. package/CHANGELOG.md +291 -283
  2. package/README.md +239 -239
  3. package/package.json +57 -57
  4. package/src/common/formily-utils.ts +125 -125
  5. package/src/common/schema-handler.ts +253 -253
  6. package/src/common/schema-merge.ts +68 -68
  7. package/src/components/ArrayBase/index.tsx +349 -349
  8. package/src/components/ArrayBase/style.less +90 -90
  9. package/src/components/ArrayBase/style.ts +2 -2
  10. package/src/components/ArrayCards/index.tsx +149 -149
  11. package/src/components/ArrayCards/style.less +14 -14
  12. package/src/components/ArrayCards/style.ts +4 -4
  13. package/src/components/ArrayTable/index.tsx +411 -411
  14. package/src/components/ArrayTable/style.less +52 -52
  15. package/src/components/ArrayTable/style.ts +7 -7
  16. package/src/components/DatePicker/index.tsx +108 -108
  17. package/src/components/LocationListPicker/assets/icon.js +1 -1
  18. package/src/components/LocationListPicker/components/AddrList/index.less +55 -55
  19. package/src/components/LocationListPicker/components/AddrList/index.tsx +75 -75
  20. package/src/components/LocationListPicker/components/Popup/address.schema.json +21 -21
  21. package/src/components/LocationListPicker/components/Popup/index.less +22 -22
  22. package/src/components/LocationListPicker/components/Popup/index.tsx +92 -92
  23. package/src/components/LocationListPicker/index.less +34 -34
  24. package/src/components/LocationListPicker/index.tsx +521 -520
  25. package/src/components/LocationPicker/Map/AMap/common/loader.ts +58 -58
  26. package/src/components/LocationPicker/Map/AMap/common/utils.ts +431 -431
  27. package/src/components/LocationPicker/Map/AMap/index.jsx +51 -51
  28. package/src/components/LocationPicker/README.md +44 -44
  29. package/src/components/LocationPicker/common/utils.ts +30 -30
  30. package/src/components/LocationPicker/components/ModalContent/index.tsx +387 -387
  31. package/src/components/LocationPicker/components/PickerInfo/index.tsx +109 -109
  32. package/src/components/LocationPicker/components/ResInfo/index.less +38 -38
  33. package/src/components/LocationPicker/components/ResInfo/index.tsx +65 -65
  34. package/src/components/LocationPicker/index.tsx +197 -197
  35. package/src/components/PersonnelSelect/index.less +21 -21
  36. package/src/components/PersonnelSelect/index.module.less +33 -33
  37. package/src/components/PersonnelSelect/index.tsx +305 -300
  38. package/src/components/PersonnelSelect/type.ts +92 -92
  39. package/src/components/RichEditor/index.less +38 -38
  40. package/src/components/RichEditor/index.tsx +238 -238
  41. package/src/components/TreeCheckbox/components/CheckboxTable/index.tsx +55 -55
  42. package/src/components/TreeCheckbox/components/TabsRender/index.tsx +58 -58
  43. package/src/components/TreeCheckbox/index.less +12 -12
  44. package/src/components/TreeCheckbox/index.tsx +63 -63
  45. package/src/components/Upload/README.md +64 -64
  46. package/src/components/Upload/common/OfflineUpload.ts +339 -339
  47. package/src/components/Upload/common/customRequest.ts +81 -81
  48. package/src/components/Upload/common/fileName.ts +142 -142
  49. package/src/components/Upload/common/handleIOFileList.ts +393 -393
  50. package/src/components/Upload/common/nanoid.ts +7 -7
  51. package/src/components/Upload/common/ossUpload.js +159 -159
  52. package/src/components/Upload/common/utils.js +194 -194
  53. package/src/components/Upload/components/ItemList/index.tsx +52 -52
  54. package/src/components/Upload/components/PreviewModal/previewRender.tsx +80 -80
  55. package/src/components/Upload/index.tsx +17 -17
  56. package/src/components/Upload/uploader-input.jsx +187 -187
  57. package/src/components/Upload/uploader.jsx +316 -316
  58. package/src/components/UserSelect/index.tsx +123 -123
  59. package/src/components/index.tsx +17 -17
  60. package/src/index.tsx +198 -198
@@ -1,17 +1,17 @@
1
- import UploaderCom from "./uploader";
2
- import { useGlobalPropsContext } from "../../common/global-props-context";
3
-
4
- export const Upload = (props) => {
5
- // 组件外部传入的 props
6
- const globalProps = useGlobalPropsContext() || {};
7
-
8
- const _props = {
9
- axios: globalProps?.axios,
10
- axiosConf: globalProps?.axiosConf,
11
- ...props,
12
- };
13
-
14
- return <UploaderCom {..._props} />;
15
- };
16
-
17
- export default Upload;
1
+ import UploaderCom from "./uploader";
2
+ import { useGlobalPropsContext } from "../../common/global-props-context";
3
+
4
+ export const Upload = (props) => {
5
+ // 组件外部传入的 props
6
+ const globalProps = useGlobalPropsContext() || {};
7
+
8
+ const _props = {
9
+ axios: globalProps?.axios,
10
+ axiosConf: globalProps?.axiosConf,
11
+ ...props,
12
+ };
13
+
14
+ return <UploaderCom {..._props} />;
15
+ };
16
+
17
+ export default Upload;
@@ -1,187 +1,187 @@
1
- import { useState, useRef, useEffect, useMemo } from "react";
2
- import { Button, Modal, message } from "antd";
3
-
4
- import ItemList from "./components/ItemList";
5
-
6
- import { handleMaxCount } from "./common/utils";
7
- import { handleInputFileList, handleOutputFileList } from "./common/handleIOFileList";
8
- import { handleOssUpload } from "./common/ossUpload";
9
-
10
- import "./uploader.less";
11
-
12
- const _ = require("lodash");
13
-
14
- function Uploader(props) {
15
- const {
16
- name,
17
- multiple,
18
- // 模式字符串: all | select | image | video 或 数组 select | image | video 组合:如:['select', 'image']
19
- mode = "select",
20
- /** 上传模式
21
- * 阿里云 oss: oss
22
- * 内部定制私有化部署: offline
23
- * 自定义: custom
24
- * 文件: file
25
- */
26
- uploadMode: _uploadMode = "oss",
27
- /**
28
- * 数据格式配置
29
- */
30
- fileListConf = {
31
- /** 列表数据模式 "array" | "jsonStr" | "splitStr" */
32
- listMode: "array",
33
- /** 字符串列表数据模式下的分隔符 */
34
- split: ", ",
35
- /** 子项数据模式 "object" | "file" | "url" | "jsonStr" */
36
- itemMode: "url",
37
- /** 预览配置参数 */
38
- previewConfig: {},
39
- },
40
- onChange,
41
- accept,
42
- disabled,
43
- readOnly,
44
- value,
45
- baseUrl = "",
46
- // 文件大小限制
47
- maxSize,
48
- maxCount = 1,
49
- // 是否使用 oss 上传文件
50
- isOssUpload = true,
51
- // 是否使用字符串结果
52
- isStrRes,
53
- // maxCount === 1 时,结果是否自动去除数组嵌套
54
- isResRemoveArr = true,
55
- ossUrl,
56
- ossOpt,
57
- onCountExceed,
58
- isFileJson,
59
- isFileObj,
60
- } = props;
61
-
62
- // 参数归一化,兼容老参数
63
- const uploadMode = isOssUpload === true ? "oss" : _uploadMode;
64
- if (isStrRes === true && isFileObj === false) {
65
- fileListConf.itemMode = "url";
66
- }
67
- if (isFileJson === true) {
68
- fileListConf.listMode = "jsonStr";
69
- }
70
- if (isFileObj === true) {
71
- fileListConf.itemMode = "object";
72
- }
73
-
74
- const [loading, setLoading] = useState(false);
75
- const [fileList, setFileList] = useState([]);
76
- useEffect(() => {
77
- setFileList(handleInputFileList(value, maxCount));
78
- }, [value]);
79
-
80
- async function onFileChange(e) {
81
- e.persist();
82
- const { files: rawFiles } = e.target;
83
- let files = [...fileList, ...[].slice.call(rawFiles)];
84
- // 超出个数限制只保留前面的 maxCount 个
85
- if (maxCount > 0 && files.length > maxCount) {
86
- onCountExceed && onCountExceed(files.length - maxCount);
87
- files.length = maxCount;
88
- message.error("文件个数超出限制");
89
- }
90
- files = files.filter((it) => {
91
- if (maxSize && it.size > maxSize) {
92
- message.error("文件大小超出限制:" + it.size);
93
- return false;
94
- }
95
- return it;
96
- });
97
- // 处理 oss 逻辑
98
- if (uploadMode === "oss") {
99
- setLoading(true);
100
- files = await handleOssUpload(files, {
101
- axios: props.axios,
102
- axiosConf: props?.axiosConf,
103
- ...ossOpt,
104
- ossUrl,
105
- });
106
- setLoading(false);
107
- }
108
-
109
- e.target.value = ""; // HACK: fix the same file doesn't trigger onChange
110
- handleChange(files);
111
- }
112
-
113
- function handleChange(files, optType) {
114
- let _files = files;
115
- if (optType !== "del" && maxCount > 1) {
116
- _files = [...fileList, ..._files];
117
- }
118
- _files = handleMaxCount(files, maxCount);
119
- setFileList(_files);
120
-
121
- // 处理出参格式
122
- _files = handleOutputFileList(_files, {
123
- ...fileListConf,
124
- });
125
-
126
- if (isResRemoveArr && maxCount === 1) {
127
- // maxCount 为1的时候返回结果去除数组
128
- _files = _files[0];
129
- }
130
-
131
- onChange && onChange(_files);
132
- }
133
-
134
- const uploaderRef = useRef();
135
-
136
- function onItemDel(idx) {
137
- Modal.confirm({
138
- content: "确认删除?",
139
- onOk: () => {
140
- const middleValue = _.cloneDeep(fileList);
141
- middleValue.splice(idx, 1);
142
- handleChange(middleValue, "del");
143
- setFileList(middleValue);
144
- },
145
- });
146
- }
147
-
148
- const inputProps = {
149
- className: "aria-hidden",
150
- style: { display: "none" },
151
- id: name,
152
- onChange: onFileChange,
153
- type: "file",
154
- name: name,
155
- multiple: multiple,
156
- accept: accept,
157
- capture: props.capture,
158
- };
159
-
160
- return (
161
- <div className="uploader">
162
- <input {...inputProps} ref={uploaderRef}></input>
163
- <ItemList
164
- fileList={fileList}
165
- baseUrl={uploadMode === "oss" ? baseUrl : ""}
166
- disabled={disabled}
167
- readOnly={readOnly}
168
- onItemDel={onItemDel}
169
- />
170
- {disabled || readOnly || (maxCount > 0 && fileList.length >= maxCount) ? null : (
171
- <>
172
- <Button
173
- className="uploader-add-btn"
174
- onClick={() => {
175
- uploaderRef.current.click();
176
- }}
177
- loading={loading}
178
- >
179
- {loading ? "" : "+"}
180
- </Button>
181
- </>
182
- )}
183
- </div>
184
- );
185
- }
186
-
187
- export default Uploader;
1
+ import { useState, useRef, useEffect, useMemo } from "react";
2
+ import { Button, Modal, message } from "antd";
3
+
4
+ import ItemList from "./components/ItemList";
5
+
6
+ import { handleMaxCount } from "./common/utils";
7
+ import { handleInputFileList, handleOutputFileList } from "./common/handleIOFileList";
8
+ import { handleOssUpload } from "./common/ossUpload";
9
+
10
+ import "./uploader.less";
11
+
12
+ const _ = require("lodash");
13
+
14
+ function Uploader(props) {
15
+ const {
16
+ name,
17
+ multiple,
18
+ // 模式字符串: all | select | image | video 或 数组 select | image | video 组合:如:['select', 'image']
19
+ mode = "select",
20
+ /** 上传模式
21
+ * 阿里云 oss: oss
22
+ * 内部定制私有化部署: offline
23
+ * 自定义: custom
24
+ * 文件: file
25
+ */
26
+ uploadMode: _uploadMode = "oss",
27
+ /**
28
+ * 数据格式配置
29
+ */
30
+ fileListConf = {
31
+ /** 列表数据模式 "array" | "jsonStr" | "splitStr" */
32
+ listMode: "array",
33
+ /** 字符串列表数据模式下的分隔符 */
34
+ split: ", ",
35
+ /** 子项数据模式 "object" | "file" | "url" | "jsonStr" */
36
+ itemMode: "url",
37
+ /** 预览配置参数 */
38
+ previewConfig: {},
39
+ },
40
+ onChange,
41
+ accept,
42
+ disabled,
43
+ readOnly,
44
+ value,
45
+ baseUrl = "",
46
+ // 文件大小限制
47
+ maxSize,
48
+ maxCount = 1,
49
+ // 是否使用 oss 上传文件
50
+ isOssUpload = true,
51
+ // 是否使用字符串结果
52
+ isStrRes,
53
+ // maxCount === 1 时,结果是否自动去除数组嵌套
54
+ isResRemoveArr = true,
55
+ ossUrl,
56
+ ossOpt,
57
+ onCountExceed,
58
+ isFileJson,
59
+ isFileObj,
60
+ } = props;
61
+
62
+ // 参数归一化,兼容老参数
63
+ const uploadMode = isOssUpload === true ? "oss" : _uploadMode;
64
+ if (isStrRes === true && isFileObj === false) {
65
+ fileListConf.itemMode = "url";
66
+ }
67
+ if (isFileJson === true) {
68
+ fileListConf.listMode = "jsonStr";
69
+ }
70
+ if (isFileObj === true) {
71
+ fileListConf.itemMode = "object";
72
+ }
73
+
74
+ const [loading, setLoading] = useState(false);
75
+ const [fileList, setFileList] = useState([]);
76
+ useEffect(() => {
77
+ setFileList(handleInputFileList(value, maxCount));
78
+ }, [value]);
79
+
80
+ async function onFileChange(e) {
81
+ e.persist();
82
+ const { files: rawFiles } = e.target;
83
+ let files = [...fileList, ...[].slice.call(rawFiles)];
84
+ // 超出个数限制只保留前面的 maxCount 个
85
+ if (maxCount > 0 && files.length > maxCount) {
86
+ onCountExceed && onCountExceed(files.length - maxCount);
87
+ files.length = maxCount;
88
+ message.error("文件个数超出限制");
89
+ }
90
+ files = files.filter((it) => {
91
+ if (maxSize && it.size > maxSize) {
92
+ message.error("文件大小超出限制:" + it.size);
93
+ return false;
94
+ }
95
+ return it;
96
+ });
97
+ // 处理 oss 逻辑
98
+ if (uploadMode === "oss") {
99
+ setLoading(true);
100
+ files = await handleOssUpload(files, {
101
+ axios: props.axios,
102
+ axiosConf: props?.axiosConf,
103
+ ...ossOpt,
104
+ ossUrl,
105
+ });
106
+ setLoading(false);
107
+ }
108
+
109
+ e.target.value = ""; // HACK: fix the same file doesn't trigger onChange
110
+ handleChange(files);
111
+ }
112
+
113
+ function handleChange(files, optType) {
114
+ let _files = files;
115
+ if (optType !== "del" && maxCount > 1) {
116
+ _files = [...fileList, ..._files];
117
+ }
118
+ _files = handleMaxCount(files, maxCount);
119
+ setFileList(_files);
120
+
121
+ // 处理出参格式
122
+ _files = handleOutputFileList(_files, {
123
+ ...fileListConf,
124
+ });
125
+
126
+ if (isResRemoveArr && maxCount === 1) {
127
+ // maxCount 为1的时候返回结果去除数组
128
+ _files = _files[0];
129
+ }
130
+
131
+ onChange && onChange(_files);
132
+ }
133
+
134
+ const uploaderRef = useRef();
135
+
136
+ function onItemDel(idx) {
137
+ Modal.confirm({
138
+ content: "确认删除?",
139
+ onOk: () => {
140
+ const middleValue = _.cloneDeep(fileList);
141
+ middleValue.splice(idx, 1);
142
+ handleChange(middleValue, "del");
143
+ setFileList(middleValue);
144
+ },
145
+ });
146
+ }
147
+
148
+ const inputProps = {
149
+ className: "aria-hidden",
150
+ style: { display: "none" },
151
+ id: name,
152
+ onChange: onFileChange,
153
+ type: "file",
154
+ name: name,
155
+ multiple: multiple,
156
+ accept: accept,
157
+ capture: props.capture,
158
+ };
159
+
160
+ return (
161
+ <div className="uploader">
162
+ <input {...inputProps} ref={uploaderRef}></input>
163
+ <ItemList
164
+ fileList={fileList}
165
+ baseUrl={uploadMode === "oss" ? baseUrl : ""}
166
+ disabled={disabled}
167
+ readOnly={readOnly}
168
+ onItemDel={onItemDel}
169
+ />
170
+ {disabled || readOnly || (maxCount > 0 && fileList.length >= maxCount) ? null : (
171
+ <>
172
+ <Button
173
+ className="uploader-add-btn"
174
+ onClick={() => {
175
+ uploaderRef.current.click();
176
+ }}
177
+ loading={loading}
178
+ >
179
+ {loading ? "" : "+"}
180
+ </Button>
181
+ </>
182
+ )}
183
+ </div>
184
+ );
185
+ }
186
+
187
+ export default Uploader;