@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.
- package/CHANGELOG.md +4 -0
- package/LICENSE +21 -0
- package/dist/common/array-base-utils.d.ts +9 -0
- package/dist/common/global-props-context.d.ts +8 -0
- package/dist/common/location-utils.d.ts +80 -0
- package/dist/components/ArrayCards/index.d.ts +10 -0
- package/dist/components/ArrayTable/common/utils.d.ts +23 -0
- package/dist/components/ArrayTable/index.d.ts +8 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/DatePicker/common/utils.d.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +16 -0
- package/dist/components/FormCollapse/index.d.ts +30 -0
- package/dist/components/FormItem/common/useFormItemLayout.d.ts +83 -0
- package/dist/components/FormItem/index.d.ts +9 -0
- package/dist/components/FormLayout/index.d.ts +76 -0
- package/dist/components/FormLayout/style.d.ts +1 -0
- package/dist/components/FormLayout/useResponsiveFormLayout.d.ts +17 -0
- package/dist/components/LocationPicker/Map/AMap/common/loader.d.ts +2 -0
- package/dist/components/LocationPicker/Map/AMap/common/utils.d.ts +74 -0
- package/dist/components/LocationPicker/common/utils.d.ts +24 -0
- package/dist/components/LocationPicker/components/ModalContent/index.d.ts +3 -0
- package/dist/components/LocationPicker/components/Notice/index.d.ts +2 -0
- package/dist/components/LocationPicker/components/PickerInfo/index.d.ts +3 -0
- package/dist/components/LocationPicker/components/ResInfo/index.d.ts +8 -0
- package/dist/components/LocationPicker/index.d.ts +3 -0
- package/dist/components/LocationPicker/servers/index.d.ts +21 -0
- package/dist/components/PickerRightOutline/index.d.ts +3 -0
- package/dist/components/Placeholder/index.d.ts +7 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/Select/index.d.ts +8 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Text/index.d.ts +9 -0
- package/dist/components/TimePicker/common/utils.d.ts +1 -0
- package/dist/components/TimePicker/index.d.ts +6 -0
- package/dist/components/TreeSelect/SelectList/index.d.ts +3 -0
- package/dist/components/TreeSelect/TreeSearch/index.d.ts +3 -0
- package/dist/components/TreeSelect/common/data-handler.d.ts +70 -0
- package/dist/components/TreeSelect/index.d.ts +3 -0
- package/dist/components/Uploader/common/checkFileType.d.ts +4 -0
- package/dist/components/Uploader/common/img.d.ts +10 -0
- package/dist/components/Uploader/components/Image/index.d.ts +3 -0
- package/dist/components/Uploader/components/ItemList/ItemRender.d.ts +2 -0
- package/dist/components/Uploader/components/ItemList/index.d.ts +2 -0
- package/dist/components/UserSelect/index.d.ts +37 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/globalConfig.d.ts +6 -0
- package/dist/index.cjs +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3178 -0
- package/package.json +65 -76
- package/src/common/array-base-utils.ts +1 -1
- package/src/components/ArrayCards/index.tsx +5 -3
- package/src/components/ArrayTable/common/utils.tsx +2 -2
- package/src/components/ArrayTable/index.tsx +6 -3
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/DatePicker/index.tsx +3 -3
- package/src/components/FormCollapse/index.tsx +5 -3
- package/src/components/FormItem/index.tsx +2 -1
- package/src/components/FormLayout/useResponsiveFormLayout.ts +1 -1
- package/src/components/LocationPicker/Map/AMap/common/utils.ts +6 -6
- package/src/components/LocationPicker/common/utils.ts +3 -3
- package/src/components/LocationPicker/components/ModalContent/index.tsx +1 -1
- package/src/components/LocationPicker/index.tsx +1 -1
- package/src/components/Radio/index.tsx +2 -1
- package/src/components/Select/index.tsx +2 -2
- package/src/components/TimePicker/common/utils.ts +1 -1
- package/src/components/TimePicker/index.tsx +2 -2
- package/src/components/Uploader/common/img.ts +4 -4
- package/src/components/Uploader/uploader.jsx +23 -16
- package/src/components/UserSelect/index.tsx +1 -1
- package/src/global.d.ts +14 -0
- package/src/index.tsx +1 -1
- package/src/type.d.ts +7 -6
- package/src/vite-env.d.ts +1 -0
- package/README.md +0 -111
package/package.json
CHANGED
|
@@ -1,76 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hzab/form-render-mobile",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
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,10 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
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 {
|
|
4
|
-
import {
|
|
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 {
|
|
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<
|
|
34
|
+
dataSource: Array<object>;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
type DatePickerPropsT = {
|
|
38
|
-
value: string | number |
|
|
38
|
+
value: string | number | object;
|
|
39
39
|
disabled: boolean;
|
|
40
40
|
readOnly: boolean;
|
|
41
41
|
placeholder: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
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
|
|
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?:
|
|
28
|
-
map?:
|
|
29
|
-
AMap?:
|
|
30
|
-
markerIconConf?:
|
|
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]:
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 {
|
|
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<
|
|
14
|
+
dataSource: Array<object>;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
type SelectPropsT = {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
49
|
+
const mime = arr[0].match(/:(.*?);/)[1];
|
|
50
|
+
const bstr = atob(arr[1]);
|
|
51
51
|
let n = bstr.length;
|
|
52
|
-
|
|
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(
|
|
50
|
-
|
|
51
|
-
|
|
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(
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
package/src/global.d.ts
ADDED
|
@@ -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
|
|
3
|
-
import {
|
|
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?:
|
|
10
|
+
initialValues?: object;
|
|
10
11
|
/** 表单 schema */
|
|
11
12
|
schema: any;
|
|
12
13
|
/** formily scope 自定义数据 */
|
|
13
|
-
schemaScope?:
|
|
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?:
|
|
24
|
+
formOptions?: object;
|
|
24
25
|
/** 是否有提交按钮 */
|
|
25
26
|
hasSubmit?: boolean;
|
|
26
27
|
/** 提交按钮文案 */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|