@hzab/form-render 1.6.21-beta1 → 1.7.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
- # @hzab/form-render@1.6.21
1
+ # @hzab/form-render@1.7.1
2
+ feat: 文件上传组件删除后重走数据处理逻辑
2
3
 
3
- refactor: upload 接入 utils upload utils
4
+ # @hzab/form-render@1.7.0
5
+
6
+ refactor: upload 接入 @hzab/utils upload utils
7
+ feat: components 支持通过项目初始化时全局进行挂载 setFormilyGlobalComponents。便于对 formRender 进行组件拆分
4
8
 
5
9
  # @hzab/form-render@1.6.20
6
10
 
package/README.md CHANGED
@@ -10,6 +10,29 @@ formily schema 表单渲染组件
10
10
 
11
11
  ## 示例
12
12
 
13
+ #### 项目初始化时挂载全局组件
14
+
15
+ ```jsx
16
+ import { setFormilyGlobalComponents } from "@hzab/utils/src/formily/global-components";
17
+
18
+ // 挂载 Test1 组件到 formRender 组件
19
+ setFormilyGlobalComponents({
20
+ Test1() {
21
+ return <div>Test1</div>;
22
+ },
23
+ });
24
+
25
+ // 挂载 Test2 组件到 formRender 组件
26
+ setFormilyGlobalComponents({
27
+ Test2() {
28
+ return <div>Test2</div>;
29
+ },
30
+ Test3() {
31
+ return <div>Test3</div>;
32
+ },
33
+ });
34
+ ```
35
+
13
36
  ```jsx
14
37
  import FormRender from "@hzab/form-render";
15
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/form-render",
3
- "version": "1.6.21-beta1",
3
+ "version": "1.7.1",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@hzab/data-model": "^1.8.8",
23
23
  "@hzab/permissions": "^0.1.1",
24
+ "@hzab/utils": "^1.0.6",
24
25
  "@hzab/webpack-config": "0.0.12",
25
26
  "@types/react": "^17.0.62",
26
27
  "@types/react-dom": "^17.0.20",
@@ -34,7 +35,7 @@
34
35
  "typescript": "^4.9.4"
35
36
  },
36
37
  "peerDependencies": {
37
- "@hzab/utils": ">=1.0.5",
38
+ "@hzab/utils": ">=1.0.6",
38
39
  "antd": "4.x",
39
40
  "axios": ">=1.6.2",
40
41
  "react": ">=16.8.0",
@@ -1,4 +1,4 @@
1
- export * from "@hzab/utils/src/file/fileType";
2
- import { getFileTypeStr } from "@hzab/utils/src/file/fileType";
3
-
4
- export const checkFileType = getFileTypeStr;
1
+ export * from "@hzab/utils/src/file/fileType";
2
+ import { getFileTypeStr } from "@hzab/utils/src/file/fileType";
3
+
4
+ export const checkFileType = getFileTypeStr;
@@ -184,7 +184,7 @@ export const handleInputItem = (data, opt: IHandlerOpt) => {
184
184
  if (typeof _data === "string") {
185
185
  const obj = getFileNameObj(_data);
186
186
  file.id = obj?.id;
187
- file.uid = file.id;
187
+ file.uid = file.id || nanoidNumALetters();
188
188
  file.url = _data;
189
189
  file.storeUrl = _data;
190
190
  file.name = getFullFileName(file.url);
@@ -109,8 +109,8 @@ export function Uploader({ onChange, ...props }) {
109
109
  typeof promiseRes === "object"
110
110
  ? promiseRes.url
111
111
  : promiseRes || _file.ossUrl || typeof _file === "string"
112
- ? _file
113
- : "";
112
+ ? _file
113
+ : "";
114
114
 
115
115
  if (typeof _file.url === "string") {
116
116
  _files[i].url = _file.url;
@@ -153,8 +153,13 @@ export function Uploader({ onChange, ...props }) {
153
153
  }, [value]);
154
154
 
155
155
  const onRemove = (file) => {
156
- const files = (fileList || []).filter((v) => v.url !== file.url);
157
- onChange && onChange(files);
156
+ const files = (fileList || []).filter((v) => v.uid !== file.uid);
157
+ let _files = [...files];
158
+ // 处理出参格式
159
+ _files = handleOutputFileList(_files, {
160
+ ...fileListConf,
161
+ });
162
+ onChange && onChange(_files);
158
163
  };
159
164
 
160
165
  // 自定义请求逻辑
package/src/index.tsx CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  ArrayCards,
31
31
  } from "c-formily-antd";
32
32
  import { Card, Slider, Rate } from "antd";
33
+ import { getFormilyGlobalComponents } from "@hzab/utils/src/formily/global-components";
33
34
 
34
35
  // 自定义组件
35
36
  import * as customComponents from "./components/index";
@@ -67,8 +68,6 @@ const antdComponents = {
67
68
  ArrayCards,
68
69
  };
69
70
 
70
- const noop = () => {};
71
-
72
71
  const FormRender = forwardRef((props: any, parentRef) => {
73
72
  /** schema scope 解决父级无 schema Scope 导致 scope 对象刷新的问题 */
74
73
  const schemaScopeRef = useRef<{ _$tempData: Object }>();
@@ -112,6 +111,7 @@ const FormRender = forwardRef((props: any, parentRef) => {
112
111
  Slider,
113
112
  Rate,
114
113
  ...customComponents,
114
+ ...getFormilyGlobalComponents(),
115
115
  ...props.components,
116
116
  },
117
117
  scope: schemaScopeRef.current,