@hzab/form-render 1.7.18 → 1.7.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 (98) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/LICENSE +21 -0
  3. package/dist/common/date-utils.d.ts +1 -0
  4. package/dist/common/event.d.ts +5 -0
  5. package/dist/common/formily-utils.d.ts +54 -0
  6. package/dist/common/global-props-context.d.ts +8 -0
  7. package/dist/common/location-utils.d.ts +6 -0
  8. package/dist/common/schema-handler.d.ts +90 -0
  9. package/dist/common/schema-merge.d.ts +12 -0
  10. package/dist/components/ArrayBase/index.d.ts +75 -0
  11. package/dist/components/ArrayBase/style.d.ts +2 -0
  12. package/dist/components/ArrayCards/index.d.ts +13 -0
  13. package/dist/components/ArrayCards/style.d.ts +4 -0
  14. package/dist/components/ArrayTable/index.d.ts +51 -0
  15. package/dist/components/ArrayTable/style.d.ts +7 -0
  16. package/dist/components/CheckboxWithTip/index.d.ts +15 -0
  17. package/dist/components/DatePicker/index.d.ts +5 -0
  18. package/dist/components/LocationListPicker/components/AddrList/index.d.ts +3 -0
  19. package/dist/components/LocationListPicker/components/Popup/index.d.ts +15 -0
  20. package/dist/components/LocationListPicker/index.d.ts +3 -0
  21. package/dist/components/LocationPicker/Map/AMap/common/loader.d.ts +2 -0
  22. package/dist/components/LocationPicker/Map/AMap/common/utils.d.ts +130 -0
  23. package/dist/components/LocationPicker/common/utils.d.ts +19 -0
  24. package/dist/components/LocationPicker/components/ModalContent/index.d.ts +3 -0
  25. package/dist/components/LocationPicker/components/Notice/index.d.ts +2 -0
  26. package/dist/components/LocationPicker/components/PickerInfo/index.d.ts +3 -0
  27. package/dist/components/LocationPicker/components/ResInfo/index.d.ts +8 -0
  28. package/dist/components/LocationPicker/index.d.ts +3 -0
  29. package/dist/components/LocationPicker/servers/index.d.ts +21 -0
  30. package/dist/components/PersonnelSelect/index.d.ts +6 -0
  31. package/dist/components/PersonnelSelect/type.d.ts +88 -0
  32. package/dist/components/RadioGroupWithTip/index.d.ts +14 -0
  33. package/dist/components/RichEditor/components/handleMobileRem/index.d.ts +3 -0
  34. package/dist/components/RichEditor/components/handleMobileVw/index.d.ts +3 -0
  35. package/dist/components/RichEditor/index.d.ts +32 -0
  36. package/dist/components/Text/index.d.ts +9 -0
  37. package/dist/components/TreeCheckbox/common/utils.d.ts +74 -0
  38. package/dist/components/TreeCheckbox/components/CheckboxTable/index.d.ts +2 -0
  39. package/dist/components/TreeCheckbox/components/Render/index.d.ts +2 -0
  40. package/dist/components/TreeCheckbox/components/TabsRender/index.d.ts +2 -0
  41. package/dist/components/TreeCheckbox/index.d.ts +3 -0
  42. package/dist/components/Upload/common/OfflineUpload.d.ts +3 -0
  43. package/dist/components/Upload/common/checkFileType.d.ts +3 -0
  44. package/dist/components/Upload/common/customRequest.d.ts +32 -0
  45. package/dist/components/Upload/common/fileName.d.ts +3 -0
  46. package/dist/components/Upload/common/handleIOFileList.d.ts +133 -0
  47. package/dist/components/Upload/common/nanoid.d.ts +2 -0
  48. package/dist/components/Upload/components/Image/index.d.ts +3 -0
  49. package/dist/components/Upload/components/ItemList/ItemRender.d.ts +2 -0
  50. package/dist/components/Upload/components/ItemList/index.d.ts +2 -0
  51. package/dist/components/Upload/components/PreviewModal/index.d.ts +5 -0
  52. package/dist/components/Upload/components/PreviewModal/previewRender.d.ts +12 -0
  53. package/dist/components/Upload/index.d.ts +2 -0
  54. package/dist/components/UserSelect/index.d.ts +29 -0
  55. package/dist/components/index.d.ts +14 -0
  56. package/dist/globalConfig.d.ts +6 -0
  57. package/dist/index.cjs +9 -0
  58. package/dist/index.css +2 -0
  59. package/dist/index.d.ts +7 -0
  60. package/dist/index.js +3227 -0
  61. package/package.json +79 -72
  62. package/src/common/schema-handler.ts +2 -2
  63. package/src/components/ArrayBase/index.tsx +7 -5
  64. package/src/components/ArrayCards/index.tsx +5 -4
  65. package/src/components/ArrayTable/index.tsx +9 -7
  66. package/src/components/DatePicker/index.tsx +1 -1
  67. package/src/components/LocationListPicker/components/Popup/index.tsx +1 -1
  68. package/src/components/LocationListPicker/index.tsx +3 -3
  69. package/src/components/LocationPicker/Map/AMap/common/utils.ts +9 -9
  70. package/src/components/LocationPicker/common/utils.ts +5 -5
  71. package/src/components/LocationPicker/components/ModalContent/index.tsx +5 -5
  72. package/src/components/PersonnelSelect/type.ts +1 -1
  73. package/src/components/RichEditor/components/handleMobileRem/index.tsx +2 -2
  74. package/src/components/RichEditor/components/handleMobileVw/index.tsx +1 -1
  75. package/src/components/RichEditor/index.tsx +1 -1
  76. package/src/components/TreeCheckbox/common/utils.ts +1 -1
  77. package/src/components/Upload/common/handleIOFileList.ts +2 -2
  78. package/src/components/Upload/uploader-input.jsx +1 -1
  79. package/src/components/Upload/uploader.jsx +6 -12
  80. package/src/components/UserSelect/index.tsx +1 -1
  81. package/src/global.d.ts +12 -0
  82. package/src/index.tsx +2 -2
  83. package/src/vite-env.d.ts +1 -0
  84. package/README.md +0 -330
  85. package/docs/README.md +0 -21
  86. package/docs/components/ArrayCards.md +0 -68
  87. package/docs/components/ArrayTable.md +0 -111
  88. package/docs/components/CheckboxWithTip.md +0 -43
  89. package/docs/components/DatePicker.md +0 -54
  90. package/docs/components/LocationListPicker.md +0 -41
  91. package/docs/components/LocationPicker.md +0 -67
  92. package/docs/components/PersonnelSelect.md +0 -77
  93. package/docs/components/RadioGroupWithTip.md +0 -43
  94. package/docs/components/RichEditor.md +0 -94
  95. package/docs/components/Text.md +0 -26
  96. package/docs/components/TreeCheckbox.md +0 -52
  97. package/docs/components/Upload.md +0 -77
  98. package/docs/components/UserSelect.md +0 -59
package/package.json CHANGED
@@ -1,72 +1,79 @@
1
- {
2
- "name": "@hzab/form-render",
3
- "version": "1.7.18",
4
- "description": "",
5
- "main": "src",
6
- "scripts": {
7
- "dev": "webpack serve -c ./config/webpack.config.js --env local",
8
- "build": "webpack -c ./config/webpack.config.js --env production",
9
- "test": "vitest run",
10
- "test:watch": "vitest",
11
- "test:coverage": "vitest run --coverage",
12
- "version:alpha": "npm version prerelease --preid=alpha",
13
- "publish:alpha": "npm publish --tag alpha",
14
- "version:beta": "npm version prerelease --preid=beta",
15
- "publish:beta": "npm publish --tag beta",
16
- "version:patch": "npm version patch",
17
- "version:minior": "npm version minor",
18
- "version:major": "npm version major",
19
- "publish:stable": "npm publish --access public"
20
- },
21
- "files": [
22
- "src",
23
- "docs",
24
- "CHANGELOG.md"
25
- ],
26
- "keywords": [],
27
- "author": "CaiYansong",
28
- "license": "ISC",
29
- "devDependencies": {
30
- "@hzab/data-model": "^1.8.8",
31
- "@hzab/permissions": "^0.1.1",
32
- "@hzab/utils": "^1.0.16",
33
- "@hzab/webpack-config": "0.0.12",
34
- "@testing-library/jest-dom": "^5.17.0",
35
- "@testing-library/react": "^12.1.5",
36
- "@testing-library/user-event": "^13.5.0",
37
- "@types/react": "^17.0.62",
38
- "@types/react-dom": "^17.0.20",
39
- "antd": "^4.24.12",
40
- "dayjs": "1.11.10",
41
- "eslint": "^8.30.0",
42
- "jsdom": "^30.0.1",
43
- "less": "^4.1.3",
44
- "react": "^17.0.2",
45
- "react-dom": "^17.0.2",
46
- "react-router-dom": "^6.8.1",
47
- "typescript": "^4.9.4",
48
- "vitest": "^4.1.10"
49
- },
50
- "peerDependencies": {
51
- "@hzab/utils": ">=1.0.6",
52
- "antd": "4.x",
53
- "axios": ">=1.6.2",
54
- "react": ">=16.8.0",
55
- "react-dom": ">=16.8.0"
56
- },
57
- "dependencies": {
58
- "@amap/amap-jsapi-loader": "^1.0.1",
59
- "@formily/core": "2.3.1",
60
- "@formily/react": "2.3.1",
61
- "@formily/reactive-react": "2.3.1",
62
- "@turf/turf": "^6.5.0",
63
- "@wangeditor/editor": "^5.1.23",
64
- "@wangeditor/editor-for-react": "^1.0.6",
65
- "ajv": "^8.12.0",
66
- "c-formily-antd": "^2.3.1",
67
- "nanoid": "^3.3.7"
68
- },
69
- "directories": {
70
- "src": "src"
71
- }
72
- }
1
+ {
2
+ "name": "@hzab/form-render",
3
+ "version": "1.7.19",
4
+ "private": false,
5
+ "src-direct": true,
6
+ "type": "module",
7
+ "description": "基于 Formily 的动态表单渲染",
8
+ "license": "ISC",
9
+ "author": "CaiYansong",
10
+ "engines": {
11
+ "node": ">=24"
12
+ },
13
+ "main": "src",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "src",
17
+ "dist",
18
+ "docs",
19
+ "CHANGELOG.md"
20
+ ],
21
+ "sideEffects": [
22
+ "**/*.less"
23
+ ],
24
+ "peerDependencies": {
25
+ "antd": "4.x",
26
+ "axios": ">=1.4.0",
27
+ "react": ">=16.8.0",
28
+ "react-dom": ">=16.8.0"
29
+ },
30
+ "dependencies": {
31
+ "@amap/amap-jsapi-loader": "^1.0.1",
32
+ "@ant-design/icons": "^4.8.0",
33
+ "@formily/core": "2.3.1",
34
+ "@formily/json-schema": "2.3.1",
35
+ "@formily/react": "2.3.1",
36
+ "@formily/reactive-react": "2.3.1",
37
+ "@formily/shared": "2.3.1",
38
+ "@turf/turf": "^6.5.0",
39
+ "@wangeditor/editor": "^5.1.23",
40
+ "@wangeditor/editor-for-react": "^1.0.6",
41
+ "ajv": "^8.12.0",
42
+ "c-formily-antd": "^2.3.1",
43
+ "classnames": "^2.3.2",
44
+ "dayjs": "^1.11.7",
45
+ "lodash": "^4.17.21",
46
+ "nanoid": "^3.3.7",
47
+ "@hzab/utils": ">=1.0.6"
48
+ },
49
+ "devDependencies": {
50
+ "@formily/core": "2.3.1",
51
+ "@formily/json-schema": "2.3.1",
52
+ "@formily/react": "2.3.1",
53
+ "@formily/reactive-react": "2.3.1",
54
+ "@formily/shared": "2.3.1",
55
+ "@types/lodash": "^4.17.12",
56
+ "@types/react": "^17.0.62",
57
+ "@types/react-dom": "^17.0.20",
58
+ "@vitest/coverage-v8": "4.1.10",
59
+ "antd": "^4.24.12",
60
+ "axios": "^1.4.0",
61
+ "c-formily-antd": "^2.3.1",
62
+ "happy-dom": "^20.11.1",
63
+ "less": "^4.1.3",
64
+ "react": "^17.0.2",
65
+ "react-dom": "^17.0.2",
66
+ "typescript": "^5.9.3",
67
+ "vite": "^8.0.0",
68
+ "vitest": "^4.1.10",
69
+ "@hzab/typescript-config": "^0.0.0",
70
+ "@hzab/eslint-config": "^0.0.0",
71
+ "@hzab/vite-config": "^0.0.3-alpha.0"
72
+ },
73
+ "scripts": {
74
+ "build": "vite build && tsc -p tsconfig.build.json",
75
+ "typecheck": "tsc -p tsconfig.json",
76
+ "test": "vitest run --passWithNoTests",
77
+ "test:watch": "vitest"
78
+ }
79
+ }
@@ -50,7 +50,7 @@ export const bindOnChange = (schema, opt) => {
50
50
  let _schema = isCloneDeep ? _.cloneDeep(schema) : schema;
51
51
  _schema = _schema.schema || _schema;
52
52
  Object.keys(_schema.properties || {})?.forEach((key) => {
53
- let item = _schema.properties[key];
53
+ const item = _schema.properties[key];
54
54
  if (!item) {
55
55
  return;
56
56
  }
@@ -216,7 +216,7 @@ export const handleSchemaStrVal = (strKey, schemaScope) => {
216
216
  if (!_str) {
217
217
  return strKey;
218
218
  }
219
- let fn = getScopeKeyVal(_str, schemaScope);
219
+ const fn = getScopeKeyVal(_str, schemaScope);
220
220
  if (fn) {
221
221
  return fn;
222
222
  }
@@ -1,11 +1,13 @@
1
1
  import { CopyOutlined, DeleteOutlined, DownOutlined, MenuOutlined, PlusOutlined, UpOutlined } from "@ant-design/icons";
2
- import { ArrayField } from "@formily/core";
3
- import { JSXComponent, Schema, useField, useFieldSchema } from "@formily/react";
2
+ import type { ArrayField } from "@formily/core";
3
+ import type { JSXComponent, Schema} from "@formily/react";
4
+ import { useField, useFieldSchema } from "@formily/react";
4
5
  import { clone, isUndef, isValid } from "@formily/shared";
5
6
  import { Button, Popconfirm } from "antd";
6
- import { ButtonProps } from "antd/lib/button";
7
+ import type { ButtonProps } from "antd/lib/button";
7
8
  import cls from "classnames";
8
- import React, { createContext, ReactNode, useContext } from "react";
9
+ import type { ReactNode} from "react";
10
+ import React, { createContext, useContext } from "react";
9
11
  import { SortableHandle, usePrefixCls } from "c-formily-antd/lib/__builtins__";
10
12
 
11
13
  export interface IArrayBaseAdditionProps extends ButtonProps {
@@ -88,7 +90,7 @@ export const getSchemaDefaultValue = (schema: Schema) => {
88
90
  if (schema?.type === "array") return [];
89
91
  if (schema?.type === "object") return {};
90
92
  if (schema?.type === "void") {
91
- for (let key in schema.properties) {
93
+ for (const key in schema.properties) {
92
94
  const value = getSchemaDefaultValue(schema.properties[key]);
93
95
  if (isValid(value)) return value;
94
96
  }
@@ -1,12 +1,13 @@
1
1
  import React from "react";
2
2
  import { Card, Empty } from "antd";
3
- import { CardProps } from "antd/lib/card";
4
- import { ArrayField } from "@formily/core";
3
+ import type { CardProps } from "antd/lib/card";
4
+ import type { ArrayField } from "@formily/core";
5
5
  import { useField, observer, useFieldSchema, RecursionField } from "@formily/react";
6
6
  import cls from "classnames";
7
- import { ISchema } from "@formily/json-schema";
7
+ import type { ISchema } from "@formily/json-schema";
8
8
  import { usePrefixCls } from "c-formily-antd/lib/__builtins__";
9
- import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
9
+ import type { ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
10
+ import { ArrayBase } from "../ArrayBase";
10
11
 
11
12
  export type ComposedArrayCards = React.FC<React.PropsWithChildren<CardProps & IArrayBaseProps>> & ArrayBaseMixins;
12
13
 
@@ -1,15 +1,17 @@
1
1
  import React, { Fragment, useState, useRef, useEffect, createContext, useContext, useCallback } from "react";
2
2
  import { Table, Pagination, Space, Select, Badge } from "antd";
3
- import { PaginationProps } from "antd/lib/pagination";
4
- import { TableProps, ColumnProps } from "antd/lib/table";
5
- import { SelectProps } from "antd/lib/select";
3
+ import type { PaginationProps } from "antd/lib/pagination";
4
+ import type { TableProps, ColumnProps } from "antd/lib/table";
5
+ import type { SelectProps } from "antd/lib/select";
6
6
  import cls from "classnames";
7
- import { GeneralField, FieldDisplayTypes, ArrayField } from "@formily/core";
8
- import { useField, observer, useFieldSchema, RecursionField, ReactFC } from "@formily/react";
7
+ import type { GeneralField, FieldDisplayTypes, ArrayField } from "@formily/core";
8
+ import type { ReactFC } from "@formily/react";
9
+ import { useField, observer, useFieldSchema, RecursionField } from "@formily/react";
9
10
  import { isArr, isBool, isFn } from "@formily/shared";
10
- import { Schema } from "@formily/json-schema";
11
+ import type { Schema } from "@formily/json-schema";
11
12
  import { usePrefixCls, SortableContainer, SortableElement } from "c-formily-antd/lib/__builtins__";
12
- import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
13
+ import type { ArrayBaseMixins, IArrayBaseProps } from "../ArrayBase";
14
+ import { ArrayBase } from "../ArrayBase";
13
15
 
14
16
  export interface ObservableColumnSource {
15
17
  field: GeneralField;
@@ -1,7 +1,7 @@
1
1
  import { useField, useFieldSchema, connect, mapProps } from "@formily/react";
2
2
  import { DatePicker as AntdDatePicker } from "c-formily-antd";
3
3
 
4
- import { DatePickerProps, RangePickerProps } from "antd/lib/date-picker";
4
+ import type { DatePickerProps, RangePickerProps } from "antd/lib/date-picker";
5
5
 
6
6
  import { getParentValue } from "../../common/formily-utils";
7
7
  import { dateable } from "../../common/date-utils";
@@ -13,7 +13,7 @@ import "./index.less";
13
13
  export interface IPopupProps {
14
14
  formProps?: {
15
15
  schema;
16
- initialValues?: Object;
16
+ initialValues?: object;
17
17
  };
18
18
  mountElement?: HTMLElement;
19
19
  }
@@ -10,7 +10,7 @@ import Popup from "./components/Popup";
10
10
 
11
11
  import AMapCom from "../LocationPicker/Map/AMap";
12
12
  import MapSearch from "../LocationPicker/components/MapSearch";
13
- import { MapUtils } from "../LocationPicker/Map/AMap/common/utils";
13
+ import type { MapUtils } from "../LocationPicker/Map/AMap/common/utils";
14
14
  import { getAddress } from "../LocationPicker/servers";
15
15
  import { markerIconBase64 } from "../LocationPicker/assets/svg-icon";
16
16
 
@@ -172,8 +172,8 @@ export const LocationListPicker = observer((props) => {
172
172
 
173
173
  function getPolygonCenter(coordinate) {
174
174
  if (coordinate.length > 0) {
175
- let features = turf.featureCollection(coordinate.map((item) => turf.point(item)));
176
- let center = turf.center(features).geometry.coordinates;
175
+ const features = turf.featureCollection(coordinate.map((item) => turf.point(item)));
176
+ const center = turf.center(features).geometry.coordinates;
177
177
  return center;
178
178
  }
179
179
  return [];
@@ -35,12 +35,12 @@ export interface IMarker {
35
35
  export type setMarkerOptT = {
36
36
  id?: number | string;
37
37
  marker?: IMarker;
38
- map?: Object;
39
- AMap?: Object;
40
- markerIconConf?: Object;
41
- markerConf?: Object;
38
+ map?: object;
39
+ AMap?: object;
40
+ markerIconConf?: object;
41
+ markerConf?: object;
42
42
  onClick?: Function;
43
- data?: Object;
43
+ data?: object;
44
44
  };
45
45
 
46
46
  export type markersT = {
@@ -141,7 +141,7 @@ export class MapUtils {
141
141
  }
142
142
 
143
143
  const position = new AMap.LngLat(lon, lat);
144
- let _marker = marker || this.markers[id];
144
+ const _marker = marker || this.markers[id];
145
145
 
146
146
  // 创建 Marker 或修改位置
147
147
  if (_marker) {
@@ -343,7 +343,7 @@ export class MapUtils {
343
343
  // circles
344
344
 
345
345
  const center = new AMap.LngLat(lon, lat);
346
- let _circle = circle || this.circles[id];
346
+ const _circle = circle || this.circles[id];
347
347
 
348
348
  // 创建 Marker 或修改位置
349
349
  if (_circle) {
@@ -412,8 +412,8 @@ export class MapUtils {
412
412
 
413
413
  getPolygonCenter(coordinate) {
414
414
  if (coordinate.length > 0) {
415
- let features = turf.featureCollection(coordinate.map((item) => turf.point(item)));
416
- let center = turf.center(features).geometry.coordinates;
415
+ const features = turf.featureCollection(coordinate.map((item) => turf.point(item)));
416
+ const center = turf.center(features).geometry.coordinates;
417
417
  return center;
418
418
  }
419
419
  return [];
@@ -13,11 +13,11 @@
13
13
  export function getPropsValue(value = {}, opt) {
14
14
  const { lonKey = "longitude", latKey = "latitude", addrKey = "address", pointsKey = "points", rangeKey = "range" } = opt || {};
15
15
 
16
- let lon = value[lonKey];
17
- let lat = value[latKey];
18
- let addr = value[addrKey];
19
- let points = value[pointsKey];
20
- let range = value[rangeKey];
16
+ const lon = value[lonKey];
17
+ const lat = value[latKey];
18
+ const addr = value[addrKey];
19
+ const points = value[pointsKey];
20
+ const range = value[rangeKey];
21
21
 
22
22
  const res = {
23
23
  lon,
@@ -8,7 +8,7 @@ import Notice from "../Notice";
8
8
  import MapSearch from "../MapSearch";
9
9
 
10
10
  import { getCurrentPosition } from "../../../../common/location-utils";
11
- import { MapUtils } from "../../Map/AMap/common/utils";
11
+ import type { MapUtils } from "../../Map/AMap/common/utils";
12
12
  import { getAddress } from "../../servers";
13
13
  import { getPropsValue } from "../../common/utils";
14
14
 
@@ -85,9 +85,9 @@ export const ModalContent = observer((props: any) => {
85
85
  useEffect(() => {
86
86
  if (isShowMode) {
87
87
  // mode === 'show' 的情况
88
- let _lon = formatVal.lon;
89
- let _lat = formatVal.lat;
90
- let _points = formatVal.points;
88
+ const _lon = formatVal.lon;
89
+ const _lat = formatVal.lat;
90
+ const _points = formatVal.points;
91
91
  formatValRef.current = {
92
92
  ...formatVal,
93
93
  };
@@ -116,7 +116,7 @@ export const ModalContent = observer((props: any) => {
116
116
  // 处理弹窗展示数据回显逻辑
117
117
  let _lon = defaultLocation.lon;
118
118
  let _lat = defaultLocation.lat;
119
- let _points = defaultLocation.points || [];
119
+ const _points = defaultLocation.points || [];
120
120
  let addr = defaultLocation.addr;
121
121
  if (formatVal.lon && formatVal.lat) {
122
122
  _lon = formatVal.lon;
@@ -1,5 +1,5 @@
1
1
  import type { SelectProps } from "antd/lib/select";
2
- import React from "react";
2
+ import type React from "react";
3
3
  import type { AvatarProps } from "antd/lib/avatar";
4
4
 
5
5
  export interface ScrollPagination {
@@ -6,8 +6,8 @@ const HandleMobileRem: any = (props) => {
6
6
 
7
7
  const init = () => {
8
8
  const newStr = content.replace(/(\d+(\.\d+)?)px/g, function (match) {
9
- var num = parseInt(match); // 提取数字部分
10
- var remValue = num / (designWidth / 10); // 根据换算比例计算 rem 值
9
+ const num = parseInt(match); // 提取数字部分
10
+ const remValue = num / (designWidth / 10); // 根据换算比例计算 rem 值
11
11
  return remValue + 'rem';
12
12
  });
13
13
  (editorArticleRef.current as HTMLElement).innerHTML = newStr
@@ -10,7 +10,7 @@ const HandleMobileVw: any = (props) => {
10
10
 
11
11
  const init = () => {
12
12
  const newStr = content.replace(/(\d+(\.\d+)?)px/g, function (match) {
13
- var num = parseInt(match); // 提取数字部分
13
+ const num = parseInt(match); // 提取数字部分
14
14
  return `${getClientRate(num, designWidth) * 100}vw`;
15
15
  });
16
16
  (editorArticleRef.current as HTMLElement).innerHTML = newStr
@@ -1,7 +1,7 @@
1
1
  import "@wangeditor/editor/dist/css/style.css"; // 引入 css
2
2
  import React, { useState, useEffect, useImperativeHandle, forwardRef } from "react";
3
3
  import { Editor as WangEditor, Toolbar } from "@wangeditor/editor-for-react";
4
- import { IDomEditor, IEditorConfig, IToolbarConfig } from "@wangeditor/editor";
4
+ import type { IDomEditor, IEditorConfig, IToolbarConfig } from "@wangeditor/editor";
5
5
  import { getOssUploadRequest, getOfflineUploadRequest } from "../Upload/common/customRequest";
6
6
  import { handlePreviewUrls } from "../Upload/common/OfflineUpload";
7
7
  import "./index.less";
@@ -25,7 +25,7 @@ export function getTabTableData(_treeData = [], opt: ITabTableDataOpt = {}) {
25
25
  const treeData = _.cloneDeep(_treeData);
26
26
  const { tabLevel = 0, _level = 0, fieldNames } = opt || {};
27
27
  const { value, children } = fieldNames || {};
28
- let resList = [];
28
+ const resList = [];
29
29
  // 当前层级小于 tabLevel,视为当前层级渲染为 tab
30
30
  const isTab = _level < tabLevel;
31
31
 
@@ -70,7 +70,7 @@ export interface IHandlerOpt {
70
70
  /** 子项数据模式: 格式化对象 | file 文件格式 | url 地址 | JSON 序列化字符串 */
71
71
  itemMode: "object" | "file" | "url" | "jsonStr";
72
72
  /** 预览配置参数 */
73
- previewConfig?: Object;
73
+ previewConfig?: object;
74
74
  thumbnailParams?: string;
75
75
  /** maxCount === 1 时是否去除数组,直接返回内容 */
76
76
  isResRemoveArr: boolean;
@@ -153,7 +153,7 @@ export const handleInputItem = (data, opt: IHandlerOpt) => {
153
153
  }
154
154
  const { thumbnailParams } = opt;
155
155
 
156
- let file = {
156
+ const file = {
157
157
  ...fileTpl,
158
158
  };
159
159
  // 对象字符串 转为 对象
@@ -4,7 +4,7 @@ import _ from "lodash";
4
4
 
5
5
  import ItemList from "./components/ItemList";
6
6
 
7
- import { handleMaxCount } from "@hzab/utils/upload/uploadUtils";
7
+ import { handleMaxCount } from "@hzab/utils/src/upload/uploadUtils";
8
8
  import { handleInputFileList, handleOutputFileList } from "./common/handleIOFileList";
9
9
  import { handleOssUpload } from "./common/ossUpload";
10
10
 
@@ -68,7 +68,7 @@ export function Uploader({ onChange, ...props }) {
68
68
  isFileJson = false,
69
69
  thumbnailParams = { image_process: "resize,w_200" },
70
70
  readPretty,
71
- afterUpload
71
+ afterUpload,
72
72
  } = props;
73
73
  const isPrivateStore =
74
74
  props.uploadParams?.fileAcl === "private" || props.ossOpt?.signatureParams?.fileAcl === "private";
@@ -120,7 +120,6 @@ export function Uploader({ onChange, ...props }) {
120
120
  * @returns
121
121
  */
122
122
  const handleChange = async ({ fileList, file, event }) => {
123
-
124
123
  setFileList(fileList);
125
124
  // 上传中不进行处理,结局 ossPromise 不存在的问题
126
125
  if (file.status !== "done") {
@@ -128,7 +127,6 @@ export function Uploader({ onChange, ...props }) {
128
127
  }
129
128
 
130
129
  let _files = [...fileList];
131
-
132
130
  // 取出异步 url
133
131
  for (let i = 0; i < _files.length; i++) {
134
132
  let _file = _files[i]?.originFileObj || _files[i];
@@ -158,16 +156,15 @@ export function Uploader({ onChange, ...props }) {
158
156
  });
159
157
 
160
158
  onChange && onChange?.(_files);
161
- afterUpload && await afterUpload({
162
- files: fileList,
163
- urls: _files
164
- })
165
159
 
166
- setChecking(false);
160
+ // 上传完成后回调(同步自源仓 1.7.18)
161
+ if (afterUpload) {
162
+ await afterUpload({ files: fileList, urls: _files });
163
+ }
167
164
 
165
+ setChecking(false);
168
166
  };
169
167
 
170
-
171
168
  useEffect(() => {
172
169
  const list = handleInputFileList(value, {
173
170
  ...fileListConf,
@@ -345,7 +342,6 @@ export function Uploader({ onChange, ...props }) {
345
342
  // },
346
343
  ...(props || {}),
347
344
  };
348
-
349
345
  const isShowUploadBtn = useMemo(() => {
350
346
  if (disabled || readOnly || readPretty) {
351
347
  return null;
@@ -364,8 +360,6 @@ export function Uploader({ onChange, ...props }) {
364
360
  )
365
361
  ) : null;
366
362
  }, [maxCount, fileList, disabled, readOnly, readPretty, checking, btnText, listType]);
367
-
368
-
369
363
  return (
370
364
  <>
371
365
  <AUpload className="oss-uploader" {..._uploadProps}>
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from "react";
2
2
  import { Select as AntdSelect, Avatar, type AvatarProps } from "antd";
3
3
  import { useField, useFieldSchema } from "@formily/react";
4
4
  import { observer } from "@formily/reactive-react";
5
- import { SelectProps as AntdSelectProps } from "antd/lib/select";
5
+ import type { SelectProps as AntdSelectProps } from "antd/lib/select";
6
6
 
7
7
  import styles from "./index.module.less";
8
8
 
@@ -0,0 +1,12 @@
1
+ export {};
2
+ declare global {
3
+ interface Window {
4
+ AMap?: any;
5
+ _AMapLoaderTemp?: any;
6
+ _AMapSecurityConfig?: { securityJsCode?: string };
7
+ formRenderPCGlobalServeConfig?: Record<string, any>;
8
+ // 下潜进 @hzab/utils 源码(node10)时会 typecheck 到 utils 的全局,需在此声明。
9
+ _$offlineSignatureRes?: any;
10
+ formilyGlobalComponents?: Record<string, any>;
11
+ }
12
+ }
package/src/index.tsx CHANGED
@@ -39,7 +39,7 @@ import { bindOnChange } from "./common/schema-handler";
39
39
 
40
40
  import "./index.less";
41
41
 
42
- const antdComponents = {
42
+ const antdComponents: any = {
43
43
  Form,
44
44
  FormItem,
45
45
  DatePicker,
@@ -70,7 +70,7 @@ const antdComponents = {
70
70
 
71
71
  const FormRender = forwardRef((props: any, parentRef) => {
72
72
  /** schema scope 解决父级无 schema Scope 导致 scope 对象刷新的问题 */
73
- const schemaScopeRef = useRef<{ _$tempData: Object }>({
73
+ const schemaScopeRef = useRef<{ _$tempData: object }>({
74
74
  scenario: "form-render",
75
75
  _$tempData: {},
76
76
  ...props.schemaScope,
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />