@hzab/form-render-mobile 1.2.7 → 1.2.9

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 (76) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE +21 -0
  3. package/dist/common/array-base-utils.d.ts +9 -0
  4. package/dist/common/global-props-context.d.ts +8 -0
  5. package/dist/common/location-utils.d.ts +80 -0
  6. package/dist/components/ArrayCards/index.d.ts +10 -0
  7. package/dist/components/ArrayTable/common/utils.d.ts +23 -0
  8. package/dist/components/ArrayTable/index.d.ts +8 -0
  9. package/dist/components/Checkbox/index.d.ts +2 -0
  10. package/dist/components/DatePicker/common/utils.d.ts +1 -0
  11. package/dist/components/DatePicker/index.d.ts +16 -0
  12. package/dist/components/FormCollapse/index.d.ts +30 -0
  13. package/dist/components/FormItem/common/useFormItemLayout.d.ts +83 -0
  14. package/dist/components/FormItem/index.d.ts +9 -0
  15. package/dist/components/FormLayout/index.d.ts +76 -0
  16. package/dist/components/FormLayout/style.d.ts +1 -0
  17. package/dist/components/FormLayout/useResponsiveFormLayout.d.ts +17 -0
  18. package/dist/components/LocationPicker/Map/AMap/common/loader.d.ts +2 -0
  19. package/dist/components/LocationPicker/Map/AMap/common/utils.d.ts +74 -0
  20. package/dist/components/LocationPicker/common/utils.d.ts +24 -0
  21. package/dist/components/LocationPicker/components/ModalContent/index.d.ts +3 -0
  22. package/dist/components/LocationPicker/components/Notice/index.d.ts +2 -0
  23. package/dist/components/LocationPicker/components/PickerInfo/index.d.ts +3 -0
  24. package/dist/components/LocationPicker/components/ResInfo/index.d.ts +8 -0
  25. package/dist/components/LocationPicker/index.d.ts +3 -0
  26. package/dist/components/LocationPicker/servers/index.d.ts +21 -0
  27. package/dist/components/PickerRightOutline/index.d.ts +3 -0
  28. package/dist/components/Placeholder/index.d.ts +7 -0
  29. package/dist/components/Radio/index.d.ts +2 -0
  30. package/dist/components/Select/index.d.ts +8 -0
  31. package/dist/components/Slider/index.d.ts +2 -0
  32. package/dist/components/Text/index.d.ts +9 -0
  33. package/dist/components/TimePicker/common/utils.d.ts +1 -0
  34. package/dist/components/TimePicker/index.d.ts +6 -0
  35. package/dist/components/TreeSelect/SelectList/index.d.ts +3 -0
  36. package/dist/components/TreeSelect/TreeSearch/index.d.ts +3 -0
  37. package/dist/components/TreeSelect/common/data-handler.d.ts +70 -0
  38. package/dist/components/TreeSelect/index.d.ts +3 -0
  39. package/dist/components/Uploader/common/checkFileType.d.ts +4 -0
  40. package/dist/components/Uploader/common/img.d.ts +10 -0
  41. package/dist/components/Uploader/components/Image/index.d.ts +3 -0
  42. package/dist/components/Uploader/components/ItemList/ItemRender.d.ts +2 -0
  43. package/dist/components/Uploader/components/ItemList/index.d.ts +2 -0
  44. package/dist/components/UserSelect/index.d.ts +37 -0
  45. package/dist/components/index.d.ts +20 -0
  46. package/dist/globalConfig.d.ts +6 -0
  47. package/dist/index.cjs +1 -0
  48. package/dist/index.css +2 -0
  49. package/dist/index.d.ts +6 -0
  50. package/dist/index.js +3178 -0
  51. package/package.json +65 -76
  52. package/src/common/array-base-utils.ts +1 -1
  53. package/src/components/ArrayCards/index.tsx +5 -3
  54. package/src/components/ArrayTable/common/utils.tsx +2 -2
  55. package/src/components/ArrayTable/index.tsx +6 -3
  56. package/src/components/Checkbox/index.tsx +1 -1
  57. package/src/components/DatePicker/index.tsx +3 -3
  58. package/src/components/FormCollapse/index.tsx +5 -3
  59. package/src/components/FormItem/index.tsx +2 -1
  60. package/src/components/FormLayout/useResponsiveFormLayout.ts +1 -1
  61. package/src/components/LocationPicker/Map/AMap/common/utils.ts +6 -6
  62. package/src/components/LocationPicker/common/utils.ts +3 -3
  63. package/src/components/LocationPicker/components/ModalContent/index.tsx +1 -1
  64. package/src/components/LocationPicker/index.tsx +1 -1
  65. package/src/components/Radio/index.tsx +2 -1
  66. package/src/components/Select/index.tsx +2 -2
  67. package/src/components/TimePicker/common/utils.ts +1 -1
  68. package/src/components/TimePicker/index.tsx +2 -2
  69. package/src/components/Uploader/common/img.ts +4 -4
  70. package/src/components/Uploader/uploader.jsx +23 -16
  71. package/src/components/UserSelect/index.tsx +1 -1
  72. package/src/global.d.ts +14 -0
  73. package/src/index.tsx +1 -1
  74. package/src/type.d.ts +7 -6
  75. package/src/vite-env.d.ts +1 -0
  76. package/README.md +0 -111
package/package.json CHANGED
@@ -1,76 +1,65 @@
1
- {
2
- "name": "@hzab/form-render-mobile",
3
- "version": "1.2.7",
4
- "description": "formily-form-render-mobile",
5
- "main": "src",
6
- "scripts": {
7
- "dev": "npm run prepare && webpack serve -c ./config/webpack.config.js --env local",
8
- "build": "webpack -c ./config/webpack.config.js --env production",
9
- "version:alpha": "npm version prerelease --preid=alpha",
10
- "publish:alpha": "npm publish --tag alpha",
11
- "version:beta": "npm version prerelease --preid=beta",
12
- "publish:beta": "npm publish --tag beta",
13
- "version:patch": "npm version patch",
14
- "version:minior": "npm version minor",
15
- "version:major": "npm version major",
16
- "publish:stable": "npm publish --access public",
17
- "prepare": "husky install",
18
- "mac-chmod": "chmod +x .husky && chmod +x .husky/pre-commit",
19
- "docs": "typedoc"
20
- },
21
- "files": [
22
- "src",
23
- "CHANGELOG.md"
24
- ],
25
- "keywords": [],
26
- "author": "CaiYansong",
27
- "license": "ISC",
28
- "devDependencies": {
29
- "@ant-design/icons": "^5.2.6",
30
- "@hzab/permissions": "^0.1.1",
31
- "@hzab/webpack-config": "0.0.12",
32
- "@types/react": "^17.0.62",
33
- "@types/react-dom": "^17.0.20",
34
- "axios": "^1.4.0",
35
- "babel-plugin-import": "^1.13.8",
36
- "eslint": "^8.30.0",
37
- "less": "^4.1.3",
38
- "mobx": "^6.7.0",
39
- "mobx-react": "^7.6.0",
40
- "react": "^17.0.2",
41
- "react-dom": "^17.0.2",
42
- "react-router-dom": "^6.14.1",
43
- "typedoc": "^0.24.8",
44
- "typescript": "^4.9.4"
45
- },
46
- "dependencies": {
47
- "@amap/amap-jsapi-loader": "^1.0.1",
48
- "@formily/antd-mobile": "1.0.0-beta.3",
49
- "@formily/core": "2.2.29",
50
- "@formily/react": "2.2.29",
51
- "@hzab/data-model": "^0.0.3",
52
- "@hzab/utils": "^1.0.16",
53
- "antd-mobile": "^5.32.0",
54
- "antd-mobile-icons": "^0.2.2",
55
- "nanoid": "^3.3.7",
56
- "postcss-px-to-viewport": "^1.1.1",
57
- "react-virtualized": "^9.22.5"
58
- },
59
- "directories": {
60
- "lib": "lib"
61
- },
62
- "lint-staged": {
63
- "src/**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
64
- "prettier --write"
65
- ],
66
- "src/**/**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
67
- "prettier --write"
68
- ],
69
- "example/**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
70
- "prettier --write"
71
- ],
72
- "example/**/**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
73
- "prettier --write"
74
- ]
75
- }
76
- }
1
+ {
2
+ "name": "@hzab/form-render-mobile",
3
+ "version": "1.2.9",
4
+ "private": false,
5
+ "src-direct": true,
6
+ "type": "module",
7
+ "description": "formily-form-render-mobile",
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
+ "CHANGELOG.md"
19
+ ],
20
+ "sideEffects": [
21
+ "**/*.less"
22
+ ],
23
+ "peerDependencies": {
24
+ "react": ">=16.8.0",
25
+ "react-dom": ">=16.8.0"
26
+ },
27
+ "dependencies": {
28
+ "@amap/amap-jsapi-loader": "^1.0.1",
29
+ "@formily/antd-mobile": "1.0.0-beta.3",
30
+ "@formily/core": "2.2.29",
31
+ "@formily/json-schema": "2.2.29",
32
+ "@formily/react": "2.2.29",
33
+ "@formily/reactive": "2.2.29",
34
+ "@formily/shared": "2.2.29",
35
+ "@hzab/data-model": ">=0.0.3",
36
+ "@hzab/utils": ">=1.0.16",
37
+ "antd-mobile": "^5.32.0",
38
+ "antd-mobile-icons": "^0.2.2",
39
+ "classnames": "^2.3.2",
40
+ "dayjs": "^1.11.7",
41
+ "lodash": "^4.17.21",
42
+ "nanoid": "^3.3.7",
43
+ "react-virtualized": "^9.22.5"
44
+ },
45
+ "devDependencies": {
46
+ "@types/react": "^17.0.62",
47
+ "@types/react-dom": "^17.0.20",
48
+ "@vitest/coverage-v8": "4.1.10",
49
+ "happy-dom": "^20.11.1",
50
+ "react": "^17.0.2",
51
+ "react-dom": "^17.0.2",
52
+ "typescript": "^5.9.3",
53
+ "vite": "^8.0.0",
54
+ "vitest": "^4.1.10",
55
+ "@hzab/typescript-config": "^0.0.0",
56
+ "@hzab/eslint-config": "^0.0.0",
57
+ "@hzab/vite-config": "^0.0.3-alpha.0"
58
+ },
59
+ "scripts": {
60
+ "build": "vite build && tsc -p tsconfig.build.json",
61
+ "typecheck": "tsc -p tsconfig.json",
62
+ "test": "vitest run --passWithNoTests",
63
+ "test:watch": "vitest"
64
+ }
65
+ }
@@ -1,4 +1,4 @@
1
- import { ISchema } from "@formily/json-schema";
1
+ import type { ISchema } from "@formily/json-schema";
2
2
 
3
3
  export const isAdditionComponent = (schema: ISchema) => {
4
4
  return schema["x-component"]?.indexOf("Addition") > -1;
@@ -1,10 +1,12 @@
1
1
  import React from "react";
2
- import { Card, Empty, CardProps } from "antd-mobile";
3
- import { ArrayField } from "@formily/core";
2
+ import type { CardProps } from "antd-mobile";
3
+ import { Card, Empty } from "antd-mobile";
4
+ import type { ArrayField } from "@formily/core";
4
5
  import { useField, observer, useFieldSchema, RecursionField } from "@formily/react";
5
6
  import cls from "classnames";
6
7
  import { usePrefixCls } from "@formily/antd-mobile/esm/__builtins__";
7
- import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "@formily/antd-mobile/esm/array-base";
8
+ import type { ArrayBaseMixins, IArrayBaseProps } from "@formily/antd-mobile/esm/array-base";
9
+ import { ArrayBase } from "@formily/antd-mobile/esm/array-base";
8
10
  import {
9
11
  isAdditionComponent,
10
12
  isIndexComponent,
@@ -1,8 +1,8 @@
1
1
  import { createContext, useContext } from "react";
2
- import { GeneralField, FieldDisplayTypes, ArrayField } from "@formily/core";
2
+ import type { GeneralField, FieldDisplayTypes, ArrayField } from "@formily/core";
3
3
  import { useField, observer, useFieldSchema, RecursionField, ReactFC } from "@formily/react";
4
4
  import { isArr } from "@formily/shared";
5
- import { Schema } from "@formily/json-schema";
5
+ import type { Schema } from "@formily/json-schema";
6
6
  import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "@formily/antd-mobile/esm/array-base";
7
7
 
8
8
  import { isAdditionComponent } from "../../../common/array-base-utils";
@@ -1,11 +1,14 @@
1
1
  import React, { Fragment, useState, useRef, useEffect, createContext, useContext, useCallback } from "react";
2
2
  import cls from "classnames";
3
- import { GeneralField, FieldDisplayTypes, ArrayField } from "@formily/core";
4
- import { useField, observer, useFieldSchema, RecursionField, ReactFC } from "@formily/react";
3
+ import type { ArrayField } from "@formily/core";
4
+ import { GeneralField, FieldDisplayTypes } from "@formily/core";
5
+ import type { ReactFC } from "@formily/react";
6
+ import { useField, observer, useFieldSchema, RecursionField } from "@formily/react";
5
7
  import { isArr, isBool, isFn } from "@formily/shared";
6
8
  import { Schema } from "@formily/json-schema";
7
9
  import { usePrefixCls } from "@formily/antd-mobile/esm/__builtins__";
8
- import { ArrayBase, ArrayBaseMixins, IArrayBaseProps } from "@formily/antd-mobile/esm/array-base";
10
+ import type { ArrayBaseMixins, IArrayBaseProps } from "@formily/antd-mobile/esm/array-base";
11
+ import { ArrayBase } from "@formily/antd-mobile/esm/array-base";
9
12
 
10
13
  import {
11
14
  isColumnComponent,
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from "react";
2
2
  import { Checkbox as AntdCheckbox, Selector, List, Space } from "antd-mobile";
3
3
  import { useField, useFieldSchema, observer } from "@formily/react";
4
4
  import type { ISchema } from "@formily/react";
5
- import { CheckboxProps, CheckboxGroupProps } from "antd-mobile/es/components/checkbox";
5
+ import type { CheckboxProps, CheckboxGroupProps } from "antd-mobile/es/components/checkbox";
6
6
 
7
7
  const checkboxColorMap = {
8
8
  defaultColor: "#f5f5f5",
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useMemo } from "react";
2
2
  import { useField, observer } from "@formily/react";
3
3
  import { DatePicker as ADataPicker } from "antd-mobile";
4
- import { Precision } from "antd-mobile/2x/es/components/date-picker/date-picker-utils";
4
+ import type { Precision } from "antd-mobile/2x/es/components/date-picker/date-picker-utils";
5
5
  import { RightOutline } from "antd-mobile-icons";
6
6
  import dayjs from "dayjs";
7
7
 
@@ -31,11 +31,11 @@ const formatEnum = {
31
31
  };
32
32
 
33
33
  type fieldT = {
34
- dataSource: Array<Object>;
34
+ dataSource: Array<object>;
35
35
  };
36
36
 
37
37
  type DatePickerPropsT = {
38
- value: string | number | Object;
38
+ value: string | number | object;
39
39
  disabled: boolean;
40
40
  readOnly: boolean;
41
41
  placeholder: string;
@@ -1,8 +1,10 @@
1
- import React, { Fragment, ReactNode, useMemo, useState } from "react";
2
- import { Collapse, Badge, CollapseProps, CollapsePanelProps } from "antd-mobile";
1
+ import type { ReactNode} from "react";
2
+ import React, { Fragment, useMemo, useState } from "react";
3
+ import type { CollapsePanelProps } from "antd-mobile";
4
+ import { Collapse, Badge, CollapseProps } from "antd-mobile";
3
5
  import { model, markRaw } from "@formily/reactive";
4
6
  import { useField, observer, useFieldSchema, RecursionField } from "@formily/react";
5
- import { Schema, SchemaKey } from "@formily/json-schema";
7
+ import type { Schema, SchemaKey } from "@formily/json-schema";
6
8
  import cls from "classnames";
7
9
  import { usePrefixCls } from "@formily/antd-mobile/esm/__builtins__";
8
10
  import { toArr } from "@formily/shared";
@@ -9,7 +9,8 @@ import { Popover } from "antd-mobile";
9
9
  import { CheckCircleOutline, CloseCircleOutline, ExclamationCircleOutline } from "antd-mobile-icons";
10
10
 
11
11
  import { useGlobalPropsContext } from "../../common/global-props-context";
12
- import { IFormItemProps, useFormItemLayout } from "./common/useFormItemLayout";
12
+ import type { IFormItemProps} from "./common/useFormItemLayout";
13
+ import { useFormItemLayout } from "./common/useFormItemLayout";
13
14
 
14
15
  import "./index.less";
15
16
 
@@ -44,7 +44,7 @@ const calcFactor = <T>(value: T | T[], breakpointIndex: number): T => {
44
44
  };
45
45
 
46
46
  const factor = <T>(value: T | T[], breakpointIndex: number): T =>
47
- isValid(value) ? calcFactor(value as any, breakpointIndex) : value;
47
+ isValid(value) ? calcFactor(value as any, breakpointIndex) : (value as T);
48
48
 
49
49
  const calculateProps: ICalculateProps = (target, props) => {
50
50
  const { clientWidth } = target;
@@ -24,14 +24,14 @@ export function setSecurityJsCode(securityJsCode) {
24
24
 
25
25
  export type setMarkerOptT = {
26
26
  id?: number | string;
27
- marker?: Object;
28
- map?: Object;
29
- AMap?: Object;
30
- markerIconConf?: Object;
27
+ marker?: object;
28
+ map?: object;
29
+ AMap?: object;
30
+ markerIconConf?: object;
31
31
  };
32
32
 
33
33
  export type markersT = {
34
- [k: number | string]: Object;
34
+ [k: number | string]: object;
35
35
  };
36
36
 
37
37
  export class MapUtils {
@@ -128,7 +128,7 @@ export class MapUtils {
128
128
  return;
129
129
  }
130
130
  const position = new AMap.LngLat(lon, lat);
131
- let _marker = marker || this.markers[id];
131
+ const _marker = marker || this.markers[id];
132
132
  // 创建 Marker 或修改位置
133
133
  if (_marker) {
134
134
  // @ts-ignore
@@ -12,9 +12,9 @@
12
12
  */
13
13
  export function getPropsValue(value = {}, opt) {
14
14
  const { lonKey = "longitude", latKey = "latitude", addrKey = "address" } = opt || {};
15
- let lon = value[lonKey];
16
- let lat = value[latKey];
17
- let addr = value[addrKey];
15
+ const lon = value[lonKey];
16
+ const lat = value[latKey];
17
+ const addr = value[addrKey];
18
18
  const res = {
19
19
  lon,
20
20
  lat,
@@ -9,7 +9,7 @@ import Notice from "../Notice";
9
9
  import MapSearch from "../MapSearch";
10
10
 
11
11
  import { getCurrentPosition } from "../../../../common/location-utils";
12
- import { MapUtils } from "../../Map/AMap/common/utils";
12
+ import type { MapUtils } from "../../Map/AMap/common/utils";
13
13
  import { getAddress } from "../../servers";
14
14
  import { getPropsValue } from "../../common/utils";
15
15
 
@@ -5,7 +5,7 @@ import { observer } from "@formily/react";
5
5
  import ResInfo from "./components/ResInfo";
6
6
  import ModalContent from "./components/ModalContent";
7
7
 
8
- import { MapUtils } from "./Map/AMap/common/utils";
8
+ import type { MapUtils } from "./Map/AMap/common/utils";
9
9
  import { getCurrentPosition } from "../../common/location-utils";
10
10
  import { getPropsValue } from "./common/utils";
11
11
  import { getAddress } from "./servers";
@@ -2,7 +2,8 @@ import React, { useEffect } from "react";
2
2
  import { Radio as AntdRadio, Selector } from "antd-mobile";
3
3
  import { observer, useField, useFieldSchema } from "@formily/react";
4
4
  import type { ISchema } from "@formily/react";
5
- import { RadioProps, RadioGroupProps } from "antd-mobile/es/components/radio";
5
+ import type { RadioGroupProps } from "antd-mobile/es/components/radio";
6
+ import { RadioProps } from "antd-mobile/es/components/radio";
6
7
 
7
8
  const CustomRadio: React.FC<RadioGroupProps> = (props) => {
8
9
  const field: any = useField();
@@ -6,12 +6,12 @@ import { RightOutline } from "antd-mobile-icons";
6
6
  import PickerRightOutline from "../PickerRightOutline";
7
7
  import Placeholder from "../Placeholder";
8
8
 
9
- import { formItemProps } from "../form-item";
9
+ import type { formItemProps } from "../form-item";
10
10
 
11
11
  import "./index.less";
12
12
 
13
13
  type fieldT = {
14
- dataSource: Array<Object>;
14
+ dataSource: Array<object>;
15
15
  };
16
16
 
17
17
  type SelectPropsT = {
@@ -50,7 +50,7 @@ export function getTimeColumns(opt: any = {}) {
50
50
  }
51
51
 
52
52
  while (i <= max) {
53
- let _val = `${i > 9 ? i : "0" + i}`;
53
+ const _val = `${i > 9 ? i : "0" + i}`;
54
54
  columns[idx].push({
55
55
  label: _val,
56
56
  value: _val,
@@ -4,7 +4,7 @@ import { Picker } from "antd-mobile";
4
4
  import PickerRightOutline from "../PickerRightOutline";
5
5
  import Placeholder from "../Placeholder";
6
6
  import { getTimeColumns } from "./common/utils";
7
- import { formItemProps } from "../form-item";
7
+ import type { formItemProps } from "../form-item";
8
8
 
9
9
  type TimePickerPropsT = {
10
10
  use12Hours: boolean;
@@ -50,7 +50,7 @@ export const TimePicker = observer((props: TimePickerPropsT) => {
50
50
  }
51
51
 
52
52
  // 拆分字符串数据并转为数字格式
53
- let pickerVal = value?.split(":");
53
+ const pickerVal = value?.split(":");
54
54
  if (use12Hours && pickerVal && pickerVal.length > 0) {
55
55
  const t = pickerVal[2];
56
56
  pickerVal.splice(2, 1, t.split(" ")?.[0]);
@@ -10,7 +10,7 @@ export const loadHeaderImage = (src, headers) => {
10
10
  }
11
11
  xhr.onload = function () {
12
12
  if (xhr.status === 200) {
13
- var blob = xhr.response;
13
+ const blob = xhr.response;
14
14
  resolve(URL.createObjectURL(blob));
15
15
  }
16
16
  };
@@ -46,10 +46,10 @@ export function scaleImg(src, size = { width: 1024 }) {
46
46
 
47
47
  export function dataURLtoBlob(dataurl) {
48
48
  const arr = dataurl.split(",");
49
- let mime = arr[0].match(/:(.*?);/)[1];
50
- let bstr = atob(arr[1]);
49
+ const mime = arr[0].match(/:(.*?);/)[1];
50
+ const bstr = atob(arr[1]);
51
51
  let n = bstr.length;
52
- let u8arr = new Uint8Array(n);
52
+ const u8arr = new Uint8Array(n);
53
53
 
54
54
  while (n--) {
55
55
  u8arr[n] = bstr.charCodeAt(n);
@@ -40,24 +40,29 @@ function Uploader(props, ref) {
40
40
  onCountExceed,
41
41
  headers,
42
42
  uploadBtnNode,
43
+ uploadCallback,
43
44
  // cordova插件上传类型 cordova-plugin-chooser | cordova-plugin-camera
44
45
  cordovaPlugin = "cordova-plugin-camera",
45
46
  uploaderProps,
46
47
  thumbnailParams = { image_process: "resize,w_200" },
47
48
  } = props;
48
49
  const [loading, setLoading] = useState(false);
49
- const [fileList, setFileList] = useState(handleInputFileList(value, maxCount, {
50
- thumbnailParams,
51
- ossOpt,
52
- }));
50
+ const [fileList, setFileList] = useState(
51
+ handleInputFileList(value, maxCount, {
52
+ thumbnailParams,
53
+ ossOpt,
54
+ }),
55
+ );
53
56
  const [actionSheetVisible, setActionSheetVisible] = useState(false);
54
57
  const uploadManagerRef = useRef(new uploadManager(new ChooserUploader()));
55
58
 
56
59
  useEffect(() => {
57
- setFileList(handleInputFileList(value, maxCount, {
58
- thumbnailParams,
59
- ossOpt,
60
- }));
60
+ setFileList(
61
+ handleInputFileList(value, maxCount, {
62
+ thumbnailParams,
63
+ ossOpt,
64
+ }),
65
+ );
61
66
  }, [value, ossOpt]);
62
67
 
63
68
  useImperativeHandle(ref, () => ({ onPicker, setActionSheetVisible }));
@@ -96,7 +101,7 @@ function Uploader(props, ref) {
96
101
  axiosConf: props?.axiosConf,
97
102
  ...ossOpt,
98
103
  ossUrl,
99
- thumbnailParams
104
+ thumbnailParams,
100
105
  });
101
106
  setLoading(false);
102
107
  }
@@ -152,7 +157,7 @@ function Uploader(props, ref) {
152
157
  onGalleryUopload?.({
153
158
  onUploadSuccess: (res) => {
154
159
  onFileChange({
155
- persist: () => { },
160
+ persist: () => {},
156
161
  target: {
157
162
  value: "",
158
163
  files: [res],
@@ -161,8 +166,8 @@ function Uploader(props, ref) {
161
166
  },
162
167
  options: {
163
168
  cameraDirection: uploaderProps?.CameraConf?.frontCamera ? Camera.Direction.FRONT : null,
164
- ...uploaderProps?.CameraConf
165
- }
169
+ ...uploaderProps?.CameraConf,
170
+ },
166
171
  });
167
172
  } else if (window?.chooser && cordovaPlugin === "cordova-plugin-chooser") {
168
173
  uploadManagerRef.current.uploadFile({
@@ -173,7 +178,7 @@ function Uploader(props, ref) {
173
178
  },
174
179
  onSuccess(values) {
175
180
  onFileChange({
176
- persist: () => { },
181
+ persist: () => {},
177
182
  target: {
178
183
  value: "",
179
184
  files: [values.blob],
@@ -192,7 +197,7 @@ function Uploader(props, ref) {
192
197
  case "captureImage":
193
198
  getImage(props.imgPluginOpt, props.getImgOpt).then((res) => {
194
199
  onFileChange({
195
- persist: () => { },
200
+ persist: () => {},
196
201
  target: {
197
202
  value: "",
198
203
  files: [res],
@@ -204,7 +209,7 @@ function Uploader(props, ref) {
204
209
  case "captureVideo":
205
210
  getVideo().then((res) => {
206
211
  onFileChange({
207
- persist: () => { },
212
+ persist: () => {},
208
213
  target: {
209
214
  value: "",
210
215
  files: [res],
@@ -270,10 +275,12 @@ function Uploader(props, ref) {
270
275
  <>
271
276
  <div
272
277
  className={`uploader-add-btn ${loading ? "uploader-add-btn-loading" : ""}`}
273
- onClick={() => {
278
+ onClick={async () => {
274
279
  if (loading) {
275
280
  return;
276
281
  }
282
+ uploadCallback && (await uploadCallback());
283
+
277
284
  setActionSheetVisible(true);
278
285
  }}
279
286
  loading={loading}
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useMemo, useState } from "react";
2
2
  import { Popup, CheckList, Avatar, Button, type AvatarProps } from "antd-mobile";
3
3
  import { useField, useFieldSchema } from "@formily/react";
4
- import { IFieldState } from "@formily/core";
4
+ import type { IFieldState } from "@formily/core";
5
5
 
6
6
  import styles from "./index.module.less";
7
7
 
@@ -0,0 +1,14 @@
1
+ export {};
2
+ declare global {
3
+ interface Window {
4
+ AMap?: any;
5
+ _AMapLoaderTemp?: any;
6
+ _AMapSecurityConfig?: { securityJsCode?: string };
7
+ formRenderGlobalServeConfig?: Record<string, any>;
8
+ // 下潜进 @hzab/utils 源码(node10)时会 typecheck 到 utils 的全局,需在此声明。
9
+ _$offlineSignatureRes?: any;
10
+ _$ossSignatureRes?: any;
11
+ formilyGlobalComponents?: Record<string, any>;
12
+ utilsGlobalServeConfig?: Record<string, any>;
13
+ }
14
+ }
package/src/index.tsx CHANGED
@@ -28,7 +28,7 @@ import { schemaHandler } from "./common/schemaHandler";
28
28
 
29
29
  import FormLayout, { FormLayoutDeepContext } from "./components/FormLayout";
30
30
 
31
- import { formPropsI } from "./type.d";
31
+ import type { formPropsI } from "./type.d";
32
32
 
33
33
  import "./index.less";
34
34
 
package/src/type.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { ReactElement } from "react";
2
- import { SchemaReactComponents, Schema } from "@formily/react";
3
- import { Form } from "@formily/core";
1
+ import type { ReactElement } from "react";
2
+ import type { SchemaReactComponents} from "@formily/react";
3
+ import { Schema } from "@formily/react";
4
+ import type { Form } from "@formily/core";
4
5
 
5
6
  export interface formPropsI {
6
7
  /** 元素类名 */
7
8
  className?: string;
8
9
  /** 表单初始值 */
9
- initialValues?: Object;
10
+ initialValues?: object;
10
11
  /** 表单 schema */
11
12
  schema: any;
12
13
  /** formily scope 自定义数据 */
13
- schemaScope?: Object;
14
+ schemaScope?: object;
14
15
  /** formily 自定义组件 */
15
16
  components?: SchemaReactComponents;
16
17
  /** 是否详情页面 */
@@ -20,7 +21,7 @@ export interface formPropsI {
20
21
  /** 是否禁用 */
21
22
  disabled?: boolean;
22
23
  /** createForm 配置项 */
23
- formOptions?: Object;
24
+ formOptions?: object;
24
25
  /** 是否有提交按钮 */
25
26
  hasSubmit?: boolean;
26
27
  /** 提交按钮文案 */
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />