@zat-design/sisyphus-react 3.13.4-beta.3 → 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.
@@ -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?: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
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?: string, value?: string, compose?: boolean): [string, DataOption];
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
- _ref2$dataSource = _ref2.dataSource,
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 _enumDataSource;
71
- var options = ((_enumDataSource = enumDataSource) === null || _enumDataSource === void 0 ? void 0 : _enumDataSource[codes]) || [];
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 _enumDataSource2;
95
- var values = (_enumDataSource2 = enumDataSource) === null || _enumDataSource2 === void 0 ? void 0 : _enumDataSource2[code];
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
  }
@@ -2,10 +2,14 @@
2
2
  export var hideTooltipIfOpen = function hideTooltipIfOpen(dom, open) {
3
3
  if (!open && document.querySelector('.pro-modal-select-parent-open') && dom) {
4
4
  var _parent = dom.closest('.pro-form-item-changed');
5
- var _grandParent = _parent.parentElement;
6
- _parent.className = 'pro-form-item-changed';
7
- _grandParent === null || _grandParent === void 0 ? void 0 : _grandParent.classList.remove('pro-modal-select-parent-open');
8
- var tooltip = _grandParent.querySelector('.ant-tooltip');
5
+ var _grandParent = _parent === null || _parent === void 0 ? void 0 : _parent.parentElement;
6
+ if (_parent) {
7
+ _parent.className = 'pro-form-item-changed';
8
+ }
9
+ if (_grandParent) {
10
+ _grandParent.classList.remove('pro-modal-select-parent-open');
11
+ }
12
+ var tooltip = _grandParent === null || _grandParent === void 0 ? void 0 : _grandParent.querySelector('.ant-tooltip');
9
13
  if (tooltip) {
10
14
  tooltip.classList.add('ant-tooltip-hidden');
11
15
  }
@@ -14,8 +18,8 @@ export var hideTooltipIfOpen = function hideTooltipIfOpen(dom, open) {
14
18
  var modal = dom.className.includes('pro-modal-select-open');
15
19
  if (!modal) return;
16
20
  var parent = dom.closest('.pro-form-item-changed');
17
- var grandParent = parent.parentElement;
18
- if (open) {
21
+ var grandParent = parent === null || parent === void 0 ? void 0 : parent.parentElement;
22
+ if (open && grandParent) {
19
23
  grandParent.classList.add('pro-modal-select-parent-open');
20
24
  }
21
25
  };
@@ -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;
@@ -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?: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
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?: string, value?: string, compose?: boolean): [string, DataOption];
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
- _ref2$dataSource = _ref2.dataSource,
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 _enumDataSource;
79
- var options = ((_enumDataSource = enumDataSource) === null || _enumDataSource === void 0 ? void 0 : _enumDataSource[codes]) || [];
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 _enumDataSource2;
103
- var values = (_enumDataSource2 = enumDataSource) === null || _enumDataSource2 === void 0 ? void 0 : _enumDataSource2[code];
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
  }
@@ -8,10 +8,14 @@ exports.hideTooltipIfOpen = void 0;
8
8
  var hideTooltipIfOpen = exports.hideTooltipIfOpen = function hideTooltipIfOpen(dom, open) {
9
9
  if (!open && document.querySelector('.pro-modal-select-parent-open') && dom) {
10
10
  var _parent = dom.closest('.pro-form-item-changed');
11
- var _grandParent = _parent.parentElement;
12
- _parent.className = 'pro-form-item-changed';
13
- _grandParent === null || _grandParent === void 0 ? void 0 : _grandParent.classList.remove('pro-modal-select-parent-open');
14
- var tooltip = _grandParent.querySelector('.ant-tooltip');
11
+ var _grandParent = _parent === null || _parent === void 0 ? void 0 : _parent.parentElement;
12
+ if (_parent) {
13
+ _parent.className = 'pro-form-item-changed';
14
+ }
15
+ if (_grandParent) {
16
+ _grandParent.classList.remove('pro-modal-select-parent-open');
17
+ }
18
+ var tooltip = _grandParent === null || _grandParent === void 0 ? void 0 : _grandParent.querySelector('.ant-tooltip');
15
19
  if (tooltip) {
16
20
  tooltip.classList.add('ant-tooltip-hidden');
17
21
  }
@@ -20,8 +24,8 @@ var hideTooltipIfOpen = exports.hideTooltipIfOpen = function hideTooltipIfOpen(d
20
24
  var modal = dom.className.includes('pro-modal-select-open');
21
25
  if (!modal) return;
22
26
  var parent = dom.closest('.pro-form-item-changed');
23
- var grandParent = parent.parentElement;
24
- if (open) {
27
+ var grandParent = parent === null || parent === void 0 ? void 0 : parent.parentElement;
28
+ if (open && grandParent) {
25
29
  grandParent.classList.add('pro-modal-select-parent-open');
26
30
  }
27
31
  };
@@ -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;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.13.4-beta.3",
3
+ "version": "3.13.4-beta.5",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",