@zat-design/sisyphus-react 3.13.4-beta.4 → 3.13.4-beta.5
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 +6 -27
- 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 +6 -28
- 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,4 +1,3 @@
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
1
|
/* eslint-disable no-redeclare */
|
3
2
|
import { useProConfig } from '../../ProConfigProvider';
|
4
3
|
import { getEnumData } from '../utils';
|
@@ -29,35 +28,15 @@ function useEnum(codes, value, compose) {
|
|
29
28
|
_ref2$fieldNames = _ref2.fieldNames,
|
30
29
|
fieldNames = _ref2$fieldNames === void 0 ? {} : _ref2$fieldNames,
|
31
30
|
_ref2$clear = _ref2.clear,
|
32
|
-
clear = _ref2$clear === void 0 ? true : _ref2$clear
|
33
|
-
|
34
|
-
dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
|
35
|
-
var catchData = getEnumData(storage, cacheKey, baseEnumStorage, dataSource);
|
31
|
+
clear = _ref2$clear === void 0 ? true : _ref2$clear;
|
32
|
+
var catchData = getEnumData(storage, cacheKey, baseEnumStorage);
|
36
33
|
// 默认枚举缓存数据
|
37
34
|
baseEnumStorage = catchData;
|
38
35
|
if (!codes) {
|
39
|
-
if (!Object.keys(catchData).length) {
|
40
|
-
return [];
|
41
|
-
}
|
42
36
|
return catchData;
|
43
37
|
}
|
44
38
|
var fieldLabel = '';
|
45
39
|
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
40
|
if (fieldNames && Object.keys(fieldNames).length) {
|
62
41
|
fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
|
63
42
|
fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
@@ -67,8 +46,8 @@ function useEnum(codes, value, compose) {
|
|
67
46
|
fieldValue = 'value';
|
68
47
|
}
|
69
48
|
if (typeof codes === 'string') {
|
70
|
-
var
|
71
|
-
var options = ((
|
49
|
+
var _catchData$data;
|
50
|
+
var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
|
72
51
|
var getEnumLabel = function getEnumLabel(v, composezTow) {
|
73
52
|
var option = options.find(function (item) {
|
74
53
|
return item[fieldValue] === v;
|
@@ -91,8 +70,8 @@ function useEnum(codes, value, compose) {
|
|
91
70
|
if (Array.isArray(codes)) {
|
92
71
|
var _options = {};
|
93
72
|
codes.forEach(function (code) {
|
94
|
-
var
|
95
|
-
var values = (
|
73
|
+
var _catchData$data2;
|
74
|
+
var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
|
96
75
|
if (Array.isArray(values) && values.length) {
|
97
76
|
_options[code] = values;
|
98
77
|
}
|
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,11 +1,9 @@
|
|
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");
|
11
9
|
/* eslint-disable no-redeclare */
|
@@ -37,35 +35,15 @@ function useEnum(codes, value, compose) {
|
|
37
35
|
_ref2$fieldNames = _ref2.fieldNames,
|
38
36
|
fieldNames = _ref2$fieldNames === void 0 ? {} : _ref2$fieldNames,
|
39
37
|
_ref2$clear = _ref2.clear,
|
40
|
-
clear = _ref2$clear === void 0 ? true : _ref2$clear
|
41
|
-
|
42
|
-
dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
|
43
|
-
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage, dataSource);
|
38
|
+
clear = _ref2$clear === void 0 ? true : _ref2$clear;
|
39
|
+
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage);
|
44
40
|
// 默认枚举缓存数据
|
45
41
|
baseEnumStorage = catchData;
|
46
42
|
if (!codes) {
|
47
|
-
if (!Object.keys(catchData).length) {
|
48
|
-
return [];
|
49
|
-
}
|
50
43
|
return catchData;
|
51
44
|
}
|
52
45
|
var fieldLabel = '';
|
53
46
|
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
47
|
if (fieldNames && Object.keys(fieldNames).length) {
|
70
48
|
fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
|
71
49
|
fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
@@ -75,8 +53,8 @@ function useEnum(codes, value, compose) {
|
|
75
53
|
fieldValue = 'value';
|
76
54
|
}
|
77
55
|
if (typeof codes === 'string') {
|
78
|
-
var
|
79
|
-
var options = ((
|
56
|
+
var _catchData$data;
|
57
|
+
var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
|
80
58
|
var getEnumLabel = function getEnumLabel(v, composezTow) {
|
81
59
|
var option = options.find(function (item) {
|
82
60
|
return item[fieldValue] === v;
|
@@ -99,8 +77,8 @@ function useEnum(codes, value, compose) {
|
|
99
77
|
if (Array.isArray(codes)) {
|
100
78
|
var _options = {};
|
101
79
|
codes.forEach(function (code) {
|
102
|
-
var
|
103
|
-
var values = (
|
80
|
+
var _catchData$data2;
|
81
|
+
var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
|
104
82
|
if (Array.isArray(values) && values.length) {
|
105
83
|
_options[code] = values;
|
106
84
|
}
|
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;
|