@zat-design/sisyphus-react 3.8.3-beta.2 → 3.8.3-beta.3

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.
@@ -50,7 +50,7 @@ var getViewLabel = function getViewLabel(_ref) {
50
50
  return viewLabel;
51
51
  };
52
52
  var ProCascader = function ProCascader(props) {
53
- var _props$otherProps, _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
53
+ var _props$otherProps, _value$slice, _ref5, _ref5$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
54
54
  var _ref2 = useProConfig('ProAddressBar') || {},
55
55
  configDetailMaxLength = _ref2.detailMaxLength,
56
56
  configEnumCode = _ref2.enumCode,
@@ -90,16 +90,18 @@ var ProCascader = function ProCascader(props) {
90
90
  var realLevel = Math.max(2, level);
91
91
  var detail = value === null || value === void 0 ? void 0 : value[realLevel];
92
92
  var enumData = useEnum(addressCode);
93
- var _ref4 = Array.isArray(enumData) ? enumData : [],
94
- _ref5 = _slicedToArray(_ref4, 1),
95
- _ref5$ = _ref5[0],
96
- enumDataSource = _ref5$ === void 0 ? [] : _ref5$;
93
+ var _useProConfig = useProConfig('ProEnum'),
94
+ _useProConfig$dics = _useProConfig.dics,
95
+ dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
96
+ var enumDataSource = useMemo(function () {
97
+ if (!(props === null || props === void 0 ? void 0 : props.mode)) {
98
+ return (dics === null || dics === void 0 ? void 0 : dics[addressCode]) || [];
99
+ }
100
+ return Array.isArray(enumData) ? enumData[0] : [];
101
+ }, [dics === null || dics === void 0 ? void 0 : dics[addressCode], enumData]);
97
102
  var realDataSource = useMemo(function () {
98
103
  var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
99
104
  var result = transformDataName(isAddressMode && realLevel === 2 ? _filterDataSource(innerDataSource, level, fieldNames) : innerDataSource, fieldNames);
100
- if (transformResponse) {
101
- return transformResponse(result);
102
- }
103
105
  return result;
104
106
  }, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
105
107
  var _useRequest = _objectSpread({}, useRequest),
@@ -115,7 +117,7 @@ var ProCascader = function ProCascader(props) {
115
117
  defaultLabel = _useState4[0],
116
118
  setDefaultLabel = _useState4[1];
117
119
  var getFirstLevelOptions = /*#__PURE__*/function () {
118
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
120
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
119
121
  var _yield$service, data, newData, transFormData, serviceData;
120
122
  return _regeneratorRuntime().wrap(function _callee$(_context) {
121
123
  while (1) switch (_context.prev = _context.next) {
@@ -143,9 +145,13 @@ var ProCascader = function ProCascader(props) {
143
145
  }, _callee);
144
146
  }));
145
147
  return function getFirstLevelOptions() {
146
- return _ref6.apply(this, arguments);
148
+ return _ref4.apply(this, arguments);
147
149
  };
148
150
  }();
151
+ // 提取出来默认每次都执行
152
+ if (transformResponse) {
153
+ realDataSource = transformResponse(realDataSource);
154
+ }
149
155
  useEffect(function () {
150
156
  if (service) {
151
157
  // 传入useRequest时,初次加载级联第一级数据源
@@ -154,13 +160,14 @@ var ProCascader = function ProCascader(props) {
154
160
  }, [service]);
155
161
  useEffect(function () {
156
162
  if (realIsView && value) {
163
+ var _realDataSource;
157
164
  // 传入dataSource + 查看时初始化展示
158
165
  if (service) {
159
166
  setDefaultLabel(getViewLabel({
160
167
  dataSource: serviceData,
161
168
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
162
169
  }));
163
- } else if ((realDataSource === null || realDataSource === void 0 ? void 0 : realDataSource.length) > 0) {
170
+ } else if (((_realDataSource = realDataSource) === null || _realDataSource === void 0 ? void 0 : _realDataSource.length) > 0) {
164
171
  setDefaultLabel(getViewLabel({
165
172
  dataSource: realDataSource,
166
173
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
@@ -194,9 +201,9 @@ var ProCascader = function ProCascader(props) {
194
201
  var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
195
202
  return !!item;
196
203
  })) ? value.slice(0, realLevel) : undefined : value;
197
- var viewValue = isAddressMode ? ((_ref7 = [].concat(_toConsumableArray(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
204
+ var viewValue = isAddressMode ? ((_ref5 = [].concat(_toConsumableArray(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref5 === void 0 ? void 0 : (_ref5$filter = _ref5.filter(function (item) {
198
205
  return !!item;
199
- })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
206
+ })) === null || _ref5$filter === void 0 ? void 0 : _ref5$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
200
207
  return !!item;
201
208
  })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
202
209
  var _findSelectedOptions = function findSelectedOptions(options, value) {
@@ -50,7 +50,7 @@ var getViewLabel = function getViewLabel(_ref) {
50
50
  return viewLabel;
51
51
  };
52
52
  var ProCascader = function ProCascader(props) {
53
- var _props$otherProps, _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
53
+ var _props$otherProps, _value$slice, _ref5, _ref5$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
54
54
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProAddressBar') || {},
55
55
  configDetailMaxLength = _ref2.detailMaxLength,
56
56
  configEnumCode = _ref2.enumCode,
@@ -90,16 +90,18 @@ var ProCascader = function ProCascader(props) {
90
90
  var realLevel = Math.max(2, level);
91
91
  var detail = value === null || value === void 0 ? void 0 : value[realLevel];
92
92
  var enumData = (0, _useEnum.default)(addressCode);
93
- var _ref4 = Array.isArray(enumData) ? enumData : [],
94
- _ref5 = (0, _slicedToArray2.default)(_ref4, 1),
95
- _ref5$ = _ref5[0],
96
- enumDataSource = _ref5$ === void 0 ? [] : _ref5$;
93
+ var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProEnum'),
94
+ _useProConfig$dics = _useProConfig.dics,
95
+ dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
96
+ var enumDataSource = (0, _react.useMemo)(function () {
97
+ if (!(props === null || props === void 0 ? void 0 : props.mode)) {
98
+ return (dics === null || dics === void 0 ? void 0 : dics[addressCode]) || [];
99
+ }
100
+ return Array.isArray(enumData) ? enumData[0] : [];
101
+ }, [dics === null || dics === void 0 ? void 0 : dics[addressCode], enumData]);
97
102
  var realDataSource = (0, _react.useMemo)(function () {
98
103
  var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
99
104
  var result = (0, _index.transformDataName)(isAddressMode && realLevel === 2 ? _filterDataSource(innerDataSource, level, fieldNames) : innerDataSource, fieldNames);
100
- if (transformResponse) {
101
- return transformResponse(result);
102
- }
103
105
  return result;
104
106
  }, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
105
107
  var _useRequest = (0, _objectSpread3.default)({}, useRequest),
@@ -115,7 +117,7 @@ var ProCascader = function ProCascader(props) {
115
117
  defaultLabel = _useState4[0],
116
118
  setDefaultLabel = _useState4[1];
117
119
  var getFirstLevelOptions = /*#__PURE__*/function () {
118
- var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
120
+ var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
119
121
  var _yield$service, data, newData, transFormData, serviceData;
120
122
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
121
123
  while (1) switch (_context.prev = _context.next) {
@@ -143,9 +145,13 @@ var ProCascader = function ProCascader(props) {
143
145
  }, _callee);
144
146
  }));
145
147
  return function getFirstLevelOptions() {
146
- return _ref6.apply(this, arguments);
148
+ return _ref4.apply(this, arguments);
147
149
  };
148
150
  }();
151
+ // 提取出来默认每次都执行
152
+ if (transformResponse) {
153
+ realDataSource = transformResponse(realDataSource);
154
+ }
149
155
  (0, _react.useEffect)(function () {
150
156
  if (service) {
151
157
  // 传入useRequest时,初次加载级联第一级数据源
@@ -154,13 +160,14 @@ var ProCascader = function ProCascader(props) {
154
160
  }, [service]);
155
161
  (0, _react.useEffect)(function () {
156
162
  if (realIsView && value) {
163
+ var _realDataSource;
157
164
  // 传入dataSource + 查看时初始化展示
158
165
  if (service) {
159
166
  setDefaultLabel(getViewLabel({
160
167
  dataSource: serviceData,
161
168
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
162
169
  }));
163
- } else if ((realDataSource === null || realDataSource === void 0 ? void 0 : realDataSource.length) > 0) {
170
+ } else if (((_realDataSource = realDataSource) === null || _realDataSource === void 0 ? void 0 : _realDataSource.length) > 0) {
164
171
  setDefaultLabel(getViewLabel({
165
172
  dataSource: realDataSource,
166
173
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
@@ -194,9 +201,9 @@ var ProCascader = function ProCascader(props) {
194
201
  var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
195
202
  return !!item;
196
203
  })) ? value.slice(0, realLevel) : undefined : value;
197
- var viewValue = isAddressMode ? ((_ref7 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
204
+ var viewValue = isAddressMode ? ((_ref5 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref5 === void 0 ? void 0 : (_ref5$filter = _ref5.filter(function (item) {
198
205
  return !!item;
199
- })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
206
+ })) === null || _ref5$filter === void 0 ? void 0 : _ref5$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
200
207
  return !!item;
201
208
  })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
202
209
  var _findSelectedOptions = function findSelectedOptions(options, value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.8.3-beta.2",
3
+ "version": "3.8.3-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",