@zat-design/sisyphus-react 3.13.4-beta.4 → 3.13.4-beta.6
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/es/ProEnum/hooks/useEnum.d.ts +2 -2
- package/es/ProEnum/hooks/useEnum.js +17 -46
- package/es/ProEnum/utils/index.d.ts +26 -1
- package/es/ProEnum/utils/index.js +27 -2
- package/es/ProForm/index.d.ts +2 -0
- package/es/ProForm/index.js +1 -0
- package/lib/ProEnum/hooks/useEnum.d.ts +2 -2
- package/lib/ProEnum/hooks/useEnum.js +17 -48
- package/lib/ProEnum/utils/index.d.ts +26 -1
- package/lib/ProEnum/utils/index.js +27 -2
- package/lib/ProForm/index.d.ts +2 -0
- package/lib/ProForm/index.js +1 -0
- package/package.json +1 -1
@@ -4,7 +4,7 @@ import { DataOption } from '../propsType';
|
|
4
4
|
* @param code
|
5
5
|
* const [options,fn] = useEnum("code")
|
6
6
|
*/
|
7
|
-
declare function useEnum(code
|
7
|
+
declare function useEnum(code: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
|
8
8
|
/**
|
9
9
|
* input codes output { code1:DataOption[],code2:DataOption[] }
|
10
10
|
* @param codes
|
@@ -17,5 +17,5 @@ declare function useEnum(codes: string[]): Record<string, DataOption[]>;
|
|
17
17
|
* @param value
|
18
18
|
* @param compose 展示 value-label
|
19
19
|
*/
|
20
|
-
declare function useEnum(code
|
20
|
+
declare function useEnum(code: string, value?: string, compose?: boolean): [string, DataOption];
|
21
21
|
export default useEnum;
|
@@ -1,17 +1,8 @@
|
|
1
|
-
|
1
|
+
var _ref;
|
2
2
|
/* eslint-disable no-redeclare */
|
3
3
|
import { useProConfig } from '../../ProConfigProvider';
|
4
4
|
import { getEnumData } from '../utils';
|
5
|
-
var baseEnumStorage = null;
|
6
|
-
try {
|
7
|
-
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
8
|
-
if (storedData) {
|
9
|
-
baseEnumStorage = JSON.parse(storedData);
|
10
|
-
}
|
11
|
-
} catch (error) {
|
12
|
-
console.error('解析枚举缓存数据失败', error);
|
13
|
-
baseEnumStorage = null;
|
14
|
-
}
|
5
|
+
var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
|
15
6
|
/**
|
16
7
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
17
8
|
* @param codes
|
@@ -20,44 +11,24 @@ try {
|
|
20
11
|
* @returns
|
21
12
|
*/
|
22
13
|
function useEnum(codes, value, compose) {
|
23
|
-
var
|
24
|
-
|
25
|
-
storage =
|
26
|
-
var
|
27
|
-
|
28
|
-
cacheKey =
|
29
|
-
|
30
|
-
fieldNames =
|
31
|
-
|
32
|
-
clear =
|
33
|
-
|
34
|
-
dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
|
35
|
-
var catchData = getEnumData(storage, cacheKey, baseEnumStorage, dataSource);
|
14
|
+
var _ref2 = useProConfig('globalConfig') || {},
|
15
|
+
_ref2$storage = _ref2.storage,
|
16
|
+
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
|
17
|
+
var _ref3 = useProConfig('ProEnum') || {},
|
18
|
+
_ref3$cacheKey = _ref3.cacheKey,
|
19
|
+
cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
|
20
|
+
_ref3$fieldNames = _ref3.fieldNames,
|
21
|
+
fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
|
22
|
+
_ref3$clear = _ref3.clear,
|
23
|
+
clear = _ref3$clear === void 0 ? true : _ref3$clear;
|
24
|
+
var catchData = getEnumData(storage, cacheKey, baseEnumStorage);
|
36
25
|
// 默认枚举缓存数据
|
37
26
|
baseEnumStorage = catchData;
|
38
27
|
if (!codes) {
|
39
|
-
if (!Object.keys(catchData).length) {
|
40
|
-
return [];
|
41
|
-
}
|
42
28
|
return catchData;
|
43
29
|
}
|
44
30
|
var fieldLabel = '';
|
45
31
|
var fieldValue = '';
|
46
|
-
// 获取枚举数据源
|
47
|
-
var enumDataSource = (catchData === null || catchData === void 0 ? void 0 : catchData.data) || {};
|
48
|
-
// 当dataSource有值时,检查是否需要合并
|
49
|
-
if (dataSource && Object.keys(dataSource).length > 0) {
|
50
|
-
// 创建合并后的数据源
|
51
|
-
var mergedDataSource = _objectSpread({}, enumDataSource);
|
52
|
-
// 遍历dataSource中的每个键
|
53
|
-
Object.keys(dataSource).forEach(function (key) {
|
54
|
-
// 如果enumDataSource中不存在该键或者该键对应的值为空数组,则合并
|
55
|
-
if (!enumDataSource[key] || enumDataSource[key].length === 0) {
|
56
|
-
mergedDataSource[key] = dataSource[key];
|
57
|
-
}
|
58
|
-
});
|
59
|
-
enumDataSource = mergedDataSource;
|
60
|
-
}
|
61
32
|
if (fieldNames && Object.keys(fieldNames).length) {
|
62
33
|
fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
|
63
34
|
fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
@@ -67,8 +38,8 @@ function useEnum(codes, value, compose) {
|
|
67
38
|
fieldValue = 'value';
|
68
39
|
}
|
69
40
|
if (typeof codes === 'string') {
|
70
|
-
var
|
71
|
-
var options = ((
|
41
|
+
var _catchData$data;
|
42
|
+
var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
|
72
43
|
var getEnumLabel = function getEnumLabel(v, composezTow) {
|
73
44
|
var option = options.find(function (item) {
|
74
45
|
return item[fieldValue] === v;
|
@@ -91,8 +62,8 @@ function useEnum(codes, value, compose) {
|
|
91
62
|
if (Array.isArray(codes)) {
|
92
63
|
var _options = {};
|
93
64
|
codes.forEach(function (code) {
|
94
|
-
var
|
95
|
-
var values = (
|
65
|
+
var _catchData$data2;
|
66
|
+
var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
|
96
67
|
if (Array.isArray(values) && values.length) {
|
97
68
|
_options[code] = values;
|
98
69
|
}
|
@@ -11,10 +11,35 @@ interface EnumRes {
|
|
11
11
|
* @param baseEnumStorage
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
15
|
+
/**
|
16
|
+
* 设置枚举数据
|
17
|
+
* @param storage
|
18
|
+
* @param cacheKey
|
19
|
+
* @param data
|
20
|
+
*/
|
15
21
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
22
|
+
/**
|
23
|
+
* 判断枚举列表是否存在
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param code
|
27
|
+
* @returns
|
28
|
+
*/
|
16
29
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
30
|
+
/**
|
31
|
+
* 判断是否是对象
|
32
|
+
* @param obj
|
33
|
+
* @returns
|
34
|
+
*/
|
17
35
|
export declare function isObject(obj: any): boolean;
|
36
|
+
/**
|
37
|
+
* 合并枚举数据
|
38
|
+
* @param storage
|
39
|
+
* @param code
|
40
|
+
* @param cacheKey
|
41
|
+
* @param responseData
|
42
|
+
*/
|
18
43
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
19
44
|
/**
|
20
45
|
* diff code 差异
|
@@ -8,8 +8,8 @@ import { isNull, isUndefined } from 'lodash';
|
|
8
8
|
* @param baseEnumStorage
|
9
9
|
* @returns
|
10
10
|
*/
|
11
|
-
export function getEnumData(storage, cacheKey, baseEnumStorage
|
12
|
-
if (baseEnumStorage
|
11
|
+
export function getEnumData(storage, cacheKey, baseEnumStorage) {
|
12
|
+
if (baseEnumStorage) {
|
13
13
|
return baseEnumStorage;
|
14
14
|
}
|
15
15
|
if (storage === 'localStorage') {
|
@@ -19,6 +19,12 @@ export function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
|
19
19
|
return JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
20
20
|
}
|
21
21
|
}
|
22
|
+
/**
|
23
|
+
* 设置枚举数据
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param data
|
27
|
+
*/
|
22
28
|
export function setEnumData(storage, cacheKey, data) {
|
23
29
|
var _Object$keys;
|
24
30
|
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
@@ -30,14 +36,33 @@ export function setEnumData(storage, cacheKey, data) {
|
|
30
36
|
window.sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
31
37
|
}
|
32
38
|
}
|
39
|
+
/**
|
40
|
+
* 判断枚举列表是否存在
|
41
|
+
* @param storage
|
42
|
+
* @param cacheKey
|
43
|
+
* @param code
|
44
|
+
* @returns
|
45
|
+
*/
|
33
46
|
export function hasEnumList(storage, cacheKey, code) {
|
34
47
|
var res = getEnumData(storage, cacheKey);
|
35
48
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
36
49
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
37
50
|
}
|
51
|
+
/**
|
52
|
+
* 判断是否是对象
|
53
|
+
* @param obj
|
54
|
+
* @returns
|
55
|
+
*/
|
38
56
|
export function isObject(obj) {
|
39
57
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
40
58
|
}
|
59
|
+
/**
|
60
|
+
* 合并枚举数据
|
61
|
+
* @param storage
|
62
|
+
* @param code
|
63
|
+
* @param cacheKey
|
64
|
+
* @param responseData
|
65
|
+
*/
|
41
66
|
export function mergeCacheData(storage, code, cacheKey, responseData) {
|
42
67
|
var _window, _window2;
|
43
68
|
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
package/es/ProForm/index.d.ts
CHANGED
@@ -4,9 +4,11 @@ import { FormProviderProps } from 'antd/es/form/context';
|
|
4
4
|
import type { ProFormType } from './propsType';
|
5
5
|
import { useForm } from './utils/useForm';
|
6
6
|
import useWatch from './utils/useWatch';
|
7
|
+
import { useForms } from '../FormsProvider';
|
7
8
|
interface IProForm<T = any> extends ForwardRefRenderFunction<FormInstance<T>, ProFormType<T>> {
|
8
9
|
useForm: typeof useForm;
|
9
10
|
useWatch: typeof useWatch;
|
11
|
+
useFormInstances: typeof useForms;
|
10
12
|
[key: string]: any;
|
11
13
|
}
|
12
14
|
declare const ProFormForward: IProForm;
|
package/es/ProForm/index.js
CHANGED
@@ -308,6 +308,7 @@ ProFormForward.useFieldProps = useFieldProps; // 获取每个字段的其他参
|
|
308
308
|
// 表单实例共享
|
309
309
|
ProFormForward.FormsProvider = FormsProvider; // 表单实例共享Provider
|
310
310
|
ProFormForward.useForms = useForms; // 获取上下文中的共享的表单实例map
|
311
|
+
ProFormForward.useFormInstances = useForms; // 获取上下文中的共享的表单实例map
|
311
312
|
ProFormForward.useContextForms = useContextForms; // 获取上下文中的共享的表单实例map
|
312
313
|
// 内置组合
|
313
314
|
ProFormForward.ProCascader = ProCascader;
|
@@ -4,7 +4,7 @@ import { DataOption } from '../propsType';
|
|
4
4
|
* @param code
|
5
5
|
* const [options,fn] = useEnum("code")
|
6
6
|
*/
|
7
|
-
declare function useEnum(code
|
7
|
+
declare function useEnum(code: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
|
8
8
|
/**
|
9
9
|
* input codes output { code1:DataOption[],code2:DataOption[] }
|
10
10
|
* @param codes
|
@@ -17,5 +17,5 @@ declare function useEnum(codes: string[]): Record<string, DataOption[]>;
|
|
17
17
|
* @param value
|
18
18
|
* @param compose 展示 value-label
|
19
19
|
*/
|
20
|
-
declare function useEnum(code
|
20
|
+
declare function useEnum(code: string, value?: string, compose?: boolean): [string, DataOption];
|
21
21
|
export default useEnum;
|
@@ -1,25 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.default = void 0;
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
7
|
var _ProConfigProvider = require("../../ProConfigProvider");
|
10
8
|
var _utils = require("../utils");
|
9
|
+
var _ref;
|
11
10
|
/* eslint-disable no-redeclare */
|
12
|
-
|
13
|
-
var baseEnumStorage = null;
|
14
|
-
try {
|
15
|
-
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
16
|
-
if (storedData) {
|
17
|
-
baseEnumStorage = JSON.parse(storedData);
|
18
|
-
}
|
19
|
-
} catch (error) {
|
20
|
-
console.error('解析枚举缓存数据失败', error);
|
21
|
-
baseEnumStorage = null;
|
22
|
-
}
|
11
|
+
var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
|
23
12
|
/**
|
24
13
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
25
14
|
* @param codes
|
@@ -28,44 +17,24 @@ try {
|
|
28
17
|
* @returns
|
29
18
|
*/
|
30
19
|
function useEnum(codes, value, compose) {
|
31
|
-
var
|
32
|
-
|
33
|
-
storage =
|
34
|
-
var
|
35
|
-
|
36
|
-
cacheKey =
|
37
|
-
|
38
|
-
fieldNames =
|
39
|
-
|
40
|
-
clear =
|
41
|
-
|
42
|
-
dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
|
43
|
-
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage, dataSource);
|
20
|
+
var _ref2 = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
|
21
|
+
_ref2$storage = _ref2.storage,
|
22
|
+
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
|
23
|
+
var _ref3 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
|
24
|
+
_ref3$cacheKey = _ref3.cacheKey,
|
25
|
+
cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
|
26
|
+
_ref3$fieldNames = _ref3.fieldNames,
|
27
|
+
fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
|
28
|
+
_ref3$clear = _ref3.clear,
|
29
|
+
clear = _ref3$clear === void 0 ? true : _ref3$clear;
|
30
|
+
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage);
|
44
31
|
// 默认枚举缓存数据
|
45
32
|
baseEnumStorage = catchData;
|
46
33
|
if (!codes) {
|
47
|
-
if (!Object.keys(catchData).length) {
|
48
|
-
return [];
|
49
|
-
}
|
50
34
|
return catchData;
|
51
35
|
}
|
52
36
|
var fieldLabel = '';
|
53
37
|
var fieldValue = '';
|
54
|
-
// 获取枚举数据源
|
55
|
-
var enumDataSource = (catchData === null || catchData === void 0 ? void 0 : catchData.data) || {};
|
56
|
-
// 当dataSource有值时,检查是否需要合并
|
57
|
-
if (dataSource && Object.keys(dataSource).length > 0) {
|
58
|
-
// 创建合并后的数据源
|
59
|
-
var mergedDataSource = (0, _objectSpread2.default)({}, enumDataSource);
|
60
|
-
// 遍历dataSource中的每个键
|
61
|
-
Object.keys(dataSource).forEach(function (key) {
|
62
|
-
// 如果enumDataSource中不存在该键或者该键对应的值为空数组,则合并
|
63
|
-
if (!enumDataSource[key] || enumDataSource[key].length === 0) {
|
64
|
-
mergedDataSource[key] = dataSource[key];
|
65
|
-
}
|
66
|
-
});
|
67
|
-
enumDataSource = mergedDataSource;
|
68
|
-
}
|
69
38
|
if (fieldNames && Object.keys(fieldNames).length) {
|
70
39
|
fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
|
71
40
|
fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
@@ -75,8 +44,8 @@ function useEnum(codes, value, compose) {
|
|
75
44
|
fieldValue = 'value';
|
76
45
|
}
|
77
46
|
if (typeof codes === 'string') {
|
78
|
-
var
|
79
|
-
var options = ((
|
47
|
+
var _catchData$data;
|
48
|
+
var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
|
80
49
|
var getEnumLabel = function getEnumLabel(v, composezTow) {
|
81
50
|
var option = options.find(function (item) {
|
82
51
|
return item[fieldValue] === v;
|
@@ -99,8 +68,8 @@ function useEnum(codes, value, compose) {
|
|
99
68
|
if (Array.isArray(codes)) {
|
100
69
|
var _options = {};
|
101
70
|
codes.forEach(function (code) {
|
102
|
-
var
|
103
|
-
var values = (
|
71
|
+
var _catchData$data2;
|
72
|
+
var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
|
104
73
|
if (Array.isArray(values) && values.length) {
|
105
74
|
_options[code] = values;
|
106
75
|
}
|
@@ -11,10 +11,35 @@ interface EnumRes {
|
|
11
11
|
* @param baseEnumStorage
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
15
|
+
/**
|
16
|
+
* 设置枚举数据
|
17
|
+
* @param storage
|
18
|
+
* @param cacheKey
|
19
|
+
* @param data
|
20
|
+
*/
|
15
21
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
22
|
+
/**
|
23
|
+
* 判断枚举列表是否存在
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param code
|
27
|
+
* @returns
|
28
|
+
*/
|
16
29
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
30
|
+
/**
|
31
|
+
* 判断是否是对象
|
32
|
+
* @param obj
|
33
|
+
* @returns
|
34
|
+
*/
|
17
35
|
export declare function isObject(obj: any): boolean;
|
36
|
+
/**
|
37
|
+
* 合并枚举数据
|
38
|
+
* @param storage
|
39
|
+
* @param code
|
40
|
+
* @param cacheKey
|
41
|
+
* @param responseData
|
42
|
+
*/
|
18
43
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
19
44
|
/**
|
20
45
|
* diff code 差异
|
@@ -21,8 +21,8 @@ var _excluded = ["children"];
|
|
21
21
|
* @param baseEnumStorage
|
22
22
|
* @returns
|
23
23
|
*/
|
24
|
-
function getEnumData(storage, cacheKey, baseEnumStorage
|
25
|
-
if (baseEnumStorage
|
24
|
+
function getEnumData(storage, cacheKey, baseEnumStorage) {
|
25
|
+
if (baseEnumStorage) {
|
26
26
|
return baseEnumStorage;
|
27
27
|
}
|
28
28
|
if (storage === 'localStorage') {
|
@@ -32,6 +32,12 @@ function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
|
32
32
|
return JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
33
33
|
}
|
34
34
|
}
|
35
|
+
/**
|
36
|
+
* 设置枚举数据
|
37
|
+
* @param storage
|
38
|
+
* @param cacheKey
|
39
|
+
* @param data
|
40
|
+
*/
|
35
41
|
function setEnumData(storage, cacheKey, data) {
|
36
42
|
var _Object$keys;
|
37
43
|
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
@@ -43,14 +49,33 @@ function setEnumData(storage, cacheKey, data) {
|
|
43
49
|
window.sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
44
50
|
}
|
45
51
|
}
|
52
|
+
/**
|
53
|
+
* 判断枚举列表是否存在
|
54
|
+
* @param storage
|
55
|
+
* @param cacheKey
|
56
|
+
* @param code
|
57
|
+
* @returns
|
58
|
+
*/
|
46
59
|
function hasEnumList(storage, cacheKey, code) {
|
47
60
|
var res = getEnumData(storage, cacheKey);
|
48
61
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
49
62
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
50
63
|
}
|
64
|
+
/**
|
65
|
+
* 判断是否是对象
|
66
|
+
* @param obj
|
67
|
+
* @returns
|
68
|
+
*/
|
51
69
|
function isObject(obj) {
|
52
70
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
53
71
|
}
|
72
|
+
/**
|
73
|
+
* 合并枚举数据
|
74
|
+
* @param storage
|
75
|
+
* @param code
|
76
|
+
* @param cacheKey
|
77
|
+
* @param responseData
|
78
|
+
*/
|
54
79
|
function mergeCacheData(storage, code, cacheKey, responseData) {
|
55
80
|
var _window, _window2;
|
56
81
|
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
package/lib/ProForm/index.d.ts
CHANGED
@@ -4,9 +4,11 @@ import { FormProviderProps } from 'antd/es/form/context';
|
|
4
4
|
import type { ProFormType } from './propsType';
|
5
5
|
import { useForm } from './utils/useForm';
|
6
6
|
import useWatch from './utils/useWatch';
|
7
|
+
import { useForms } from '../FormsProvider';
|
7
8
|
interface IProForm<T = any> extends ForwardRefRenderFunction<FormInstance<T>, ProFormType<T>> {
|
8
9
|
useForm: typeof useForm;
|
9
10
|
useWatch: typeof useWatch;
|
11
|
+
useFormInstances: typeof useForms;
|
10
12
|
[key: string]: any;
|
11
13
|
}
|
12
14
|
declare const ProFormForward: IProForm;
|
package/lib/ProForm/index.js
CHANGED
@@ -309,6 +309,7 @@ ProFormForward.useFieldProps = _useFieldProps.useFieldProps; // 获取每个字
|
|
309
309
|
// 表单实例共享
|
310
310
|
ProFormForward.FormsProvider = _FormsProvider.default; // 表单实例共享Provider
|
311
311
|
ProFormForward.useForms = _FormsProvider.useForms; // 获取上下文中的共享的表单实例map
|
312
|
+
ProFormForward.useFormInstances = _FormsProvider.useForms; // 获取上下文中的共享的表单实例map
|
312
313
|
ProFormForward.useContextForms = _FormsProvider.useContextForms; // 获取上下文中的共享的表单实例map
|
313
314
|
// 内置组合
|
314
315
|
ProFormForward.ProCascader = _components.ProCascader;
|