@zat-design/sisyphus-react 3.13.19-beta.5 → 3.13.19-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.
@@ -20,14 +20,14 @@ import _cloneDeep from "lodash/cloneDeep";
20
20
  var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps", "isView"],
21
21
  _excluded2 = ["fieldNames", "clear", "storage", "cacheKey", "showCodeName", "useRequest", "transformResponse"];
22
22
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
23
- import { useDeepCompareEffect, useRequest as useRequestFunc, useLocalStorageState } from 'ahooks';
23
+ import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
24
24
  import React, { useState, useEffect, useMemo } from 'react';
25
25
  import ProSelect from '../ProSelect';
26
26
  import { useProConfig } from '../ProConfigProvider';
27
27
  import ProEnumTag from './components/Tag';
28
28
  import ProEnumGroup from './components/Group';
29
29
  import Container from '../ProForm/components/Container';
30
- import { isObject } from './utils';
30
+ import { isObject, getEnumData } from './utils';
31
31
  import getEnumLabel from './utils/getEnumLabel';
32
32
  import useEnum from './hooks/useEnum';
33
33
  import locale from '../locale';
@@ -67,11 +67,7 @@ var ProEnum = function ProEnum(props) {
67
67
  // 优先使用props中的配置,如果没有则使用全局配置
68
68
  var finalUseRequest = useRequest || configUseRequest;
69
69
  var finalTransformResponse = transformResponse || configTransformResponse;
70
- var _useLocalStorageState = useLocalStorageState(cacheKey, {
71
- listenStorageChange: true
72
- }),
73
- _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 1),
74
- cacheData = _useLocalStorageState2[0];
70
+ var cacheData = getEnumData(storage, cacheKey);
75
71
  var _isView = isView !== undefined && isView !== null ? isView : (_otherProps$isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView) !== null && _otherProps$isView !== void 0 ? _otherProps$isView : configIsView;
76
72
  enumProps.showCodeName = (_enumProps$showCodeNa = enumProps.showCodeName) !== null && _enumProps$showCodeNa !== void 0 ? _enumProps$showCodeNa : showCodeName;
77
73
  var label = 'label';
@@ -152,22 +148,17 @@ var ProEnum = function ProEnum(props) {
152
148
  }, [finalUseRequest === null || finalUseRequest === void 0 ? void 0 : finalUseRequest.options]);
153
149
  var enumLists = useMemo(function () {
154
150
  var lists = [];
155
- var nextDics = dics;
156
- if (cacheData && Object.keys(cacheData.data).length) {
157
- nextDics = cacheData.data;
158
- }
159
151
  if (_isString(code)) {
160
- var _nextDics;
161
- lists = ((_nextDics = nextDics) === null || _nextDics === void 0 ? void 0 : _nextDics[code]) || [];
152
+ lists = (dics === null || dics === void 0 ? void 0 : dics[code]) || [];
162
153
  }
163
154
  if (_isArray(code)) {
164
155
  code.forEach(function (enumCode) {
165
- var _nextDics2, _lists, _nextDics3;
166
- _isArray((_nextDics2 = nextDics) === null || _nextDics2 === void 0 ? void 0 : _nextDics2[enumCode]) && (_lists = lists).push.apply(_lists, _toConsumableArray((_nextDics3 = nextDics) === null || _nextDics3 === void 0 ? void 0 : _nextDics3[enumCode]));
156
+ var _lists;
157
+ _isArray(dics === null || dics === void 0 ? void 0 : dics[enumCode]) && (_lists = lists).push.apply(_lists, _toConsumableArray(dics === null || dics === void 0 ? void 0 : dics[enumCode]));
167
158
  });
168
159
  }
169
160
  return lists;
170
- }, [dics, code, cacheData]);
161
+ }, [dics, code]);
171
162
  var renderComponent = function renderComponent() {
172
163
  var list = [];
173
164
  // 优先使用组件内部自己传入的数据源或者请求得到的数据
@@ -75,11 +75,7 @@ var ProEnum = function ProEnum(props) {
75
75
  // 优先使用props中的配置,如果没有则使用全局配置
76
76
  var finalUseRequest = useRequest || configUseRequest;
77
77
  var finalTransformResponse = transformResponse || configTransformResponse;
78
- var _useLocalStorageState = (0, _ahooks.useLocalStorageState)(cacheKey, {
79
- listenStorageChange: true
80
- }),
81
- _useLocalStorageState2 = (0, _slicedToArray2.default)(_useLocalStorageState, 1),
82
- cacheData = _useLocalStorageState2[0];
78
+ var cacheData = (0, _utils.getEnumData)(storage, cacheKey);
83
79
  var _isView = isView !== undefined && isView !== null ? isView : (_otherProps$isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView) !== null && _otherProps$isView !== void 0 ? _otherProps$isView : configIsView;
84
80
  enumProps.showCodeName = (_enumProps$showCodeNa = enumProps.showCodeName) !== null && _enumProps$showCodeNa !== void 0 ? _enumProps$showCodeNa : showCodeName;
85
81
  var label = 'label';
@@ -160,22 +156,17 @@ var ProEnum = function ProEnum(props) {
160
156
  }, [finalUseRequest === null || finalUseRequest === void 0 ? void 0 : finalUseRequest.options]);
161
157
  var enumLists = (0, _react.useMemo)(function () {
162
158
  var lists = [];
163
- var nextDics = dics;
164
- if (cacheData && Object.keys(cacheData.data).length) {
165
- nextDics = cacheData.data;
166
- }
167
159
  if ((0, _isString2.default)(code)) {
168
- var _nextDics;
169
- lists = ((_nextDics = nextDics) === null || _nextDics === void 0 ? void 0 : _nextDics[code]) || [];
160
+ lists = (dics === null || dics === void 0 ? void 0 : dics[code]) || [];
170
161
  }
171
162
  if ((0, _isArray2.default)(code)) {
172
163
  code.forEach(function (enumCode) {
173
- var _nextDics2, _lists, _nextDics3;
174
- (0, _isArray2.default)((_nextDics2 = nextDics) === null || _nextDics2 === void 0 ? void 0 : _nextDics2[enumCode]) && (_lists = lists).push.apply(_lists, (0, _toConsumableArray2.default)((_nextDics3 = nextDics) === null || _nextDics3 === void 0 ? void 0 : _nextDics3[enumCode]));
164
+ var _lists;
165
+ (0, _isArray2.default)(dics === null || dics === void 0 ? void 0 : dics[enumCode]) && (_lists = lists).push.apply(_lists, (0, _toConsumableArray2.default)(dics === null || dics === void 0 ? void 0 : dics[enumCode]));
175
166
  });
176
167
  }
177
168
  return lists;
178
- }, [dics, code, cacheData]);
169
+ }, [dics, code]);
179
170
  var renderComponent = function renderComponent() {
180
171
  var list = [];
181
172
  // 优先使用组件内部自己传入的数据源或者请求得到的数据
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.13.19-beta.5",
3
+ "version": "3.13.19-beta.6",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",