@zat-design/sisyphus-react 3.4.5-beta.2 → 3.4.5-beta.4
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/dist/index.esm.css +3 -0
- package/dist/less.esm.css +3 -0
- package/es/ProConfigProvider/index.d.ts +2 -2
- package/es/ProEditTable/components/RenderField/index.js +1 -1
- package/es/ProForm/components/combination/Container/index.js +3 -2
- package/es/ProForm/components/combination/Container/style/index.less +5 -1
- package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/index.d.ts +2 -2
- package/es/ProForm/components/combination/ProCascader/index.js +259 -0
- package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.d.ts +8 -6
- package/es/ProForm/components/index.d.ts +1 -2
- package/es/ProForm/components/index.js +1 -4
- package/es/ProForm/components/render/Render.js +1 -1
- package/es/ProForm/components/render/propsType.d.ts +3 -7
- package/es/ProForm/index.js +2 -2
- package/es/ProForm/style/index.less +1 -1
- package/es/ProForm/utils/index.js +1 -1
- package/es/ProIcon/index.js +7 -55
- package/es/ProIcon/utils/index.d.ts +5 -0
- package/es/ProIcon/utils/index.js +60 -0
- package/es/ProTable/utils.js +6 -3
- package/lib/ProConfigProvider/index.d.ts +2 -2
- package/lib/ProEditTable/components/RenderField/index.js +1 -1
- package/lib/ProForm/components/combination/Container/index.js +3 -2
- package/lib/ProForm/components/combination/Container/style/index.less +5 -1
- package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/index.d.ts +2 -2
- package/lib/ProForm/components/combination/ProCascader/index.js +259 -0
- package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.d.ts +8 -6
- package/lib/ProForm/components/index.d.ts +1 -2
- package/lib/ProForm/components/index.js +1 -8
- package/lib/ProForm/components/render/Render.js +1 -1
- package/lib/ProForm/components/render/propsType.d.ts +3 -7
- package/lib/ProForm/index.js +1 -1
- package/lib/ProForm/style/index.less +1 -1
- package/lib/ProForm/utils/index.js +1 -1
- package/lib/ProIcon/index.js +5 -53
- package/lib/ProIcon/utils/index.d.ts +5 -0
- package/lib/ProIcon/utils/index.js +62 -1
- package/lib/ProTable/utils.js +6 -3
- package/package.json +1 -1
- package/es/ProForm/components/base/ProCascader/index.d.ts +0 -14
- package/es/ProForm/components/base/ProCascader/index.js +0 -72
- package/es/ProForm/components/combination/ProAddressBar/index.js +0 -437
- package/lib/ProForm/components/base/ProCascader/index.d.ts +0 -14
- package/lib/ProForm/components/base/ProCascader/index.js +0 -78
- package/lib/ProForm/components/combination/ProAddressBar/index.js +0 -437
- /package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.js +0 -0
- /package/es/ProForm/components/combination/{ProAddressBar → ProCascader}/style/index.less +0 -0
- /package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/propsType.js +0 -0
- /package/lib/ProForm/components/combination/{ProAddressBar → ProCascader}/style/index.less +0 -0
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
var _react = require("react");
|
|
16
|
-
var _ahooks = require("ahooks");
|
|
17
|
-
var _antd = require("antd");
|
|
18
|
-
var _utils = require("@zat-design/utils");
|
|
19
|
-
var _ProConfigProvider = require("../../../../ProConfigProvider");
|
|
20
|
-
var _useEnum = _interopRequireDefault(require("../../../../ProEnum/hooks/useEnum"));
|
|
21
|
-
var _locale = _interopRequireDefault(require("../../../../locale"));
|
|
22
|
-
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
|
23
|
-
var transformDataName = _utils.tools.transformDataName;
|
|
24
|
-
var Text = _antd.Typography.Text;
|
|
25
|
-
var filterDataSource = function filterDataSource(dataSource, level) {
|
|
26
|
-
return dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
27
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
|
|
28
|
-
children: level === 1 ? [] : filterDataSource(item === null || item === void 0 ? void 0 : item.children, level - 1)
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var getAddressLabel = function getAddressLabel(dataSource, value) {
|
|
33
|
-
// 传入dataSource时,得到地址省市区的label,查看模式展示需要
|
|
34
|
-
return ['province', 'city', 'county'].reduce(function (acc, cur, index) {
|
|
35
|
-
var _dataSource;
|
|
36
|
-
var temp = (_dataSource = dataSource) === null || _dataSource === void 0 ? void 0 : _dataSource.find(function (item) {
|
|
37
|
-
return (item === null || item === void 0 ? void 0 : item.value) === (value === null || value === void 0 ? void 0 : value[index]);
|
|
38
|
-
});
|
|
39
|
-
dataSource = (temp === null || temp === void 0 ? void 0 : temp.children) || [];
|
|
40
|
-
acc[cur] = temp === null || temp === void 0 ? void 0 : temp.label;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
};
|
|
44
|
-
var levelMap = {
|
|
45
|
-
1: 'province',
|
|
46
|
-
2: 'city',
|
|
47
|
-
3: 'county'
|
|
48
|
-
};
|
|
49
|
-
var ProAddressBar = function ProAddressBar(props) {
|
|
50
|
-
var _ref12, _ref12$filter, _locale$ProAddressBar, _locale$ProAddressBar2, _locale$ProAddressBar3;
|
|
51
|
-
var _ref = (0, _ProConfigProvider.useProConfig)('ProAddressBar') || {},
|
|
52
|
-
configUseRequest = _ref.useRequest,
|
|
53
|
-
configTransformResponse = _ref.transformResponse,
|
|
54
|
-
configDataSource = _ref.dataSource,
|
|
55
|
-
configDetailMaxLength = _ref.detailMaxLength,
|
|
56
|
-
configFieldNames = _ref.fieldNames,
|
|
57
|
-
configEnumCode = _ref.enumCode,
|
|
58
|
-
configCode = _ref.code;
|
|
59
|
-
var className = props.className,
|
|
60
|
-
getPopupContainer = props.getPopupContainer,
|
|
61
|
-
_props$hasDetail = props.hasDetail,
|
|
62
|
-
hasDetail = _props$hasDetail === void 0 ? true : _props$hasDetail,
|
|
63
|
-
_props$detailMaxLengt = props.detailMaxLength,
|
|
64
|
-
detailMaxLength = _props$detailMaxLengt === void 0 ? configDetailMaxLength || 100 : _props$detailMaxLengt,
|
|
65
|
-
_props$fieldNames = props.fieldNames,
|
|
66
|
-
fieldNames = _props$fieldNames === void 0 ? configFieldNames || {
|
|
67
|
-
label: 'name',
|
|
68
|
-
value: 'code'
|
|
69
|
-
} : _props$fieldNames,
|
|
70
|
-
value = props.value,
|
|
71
|
-
disabled = props.disabled,
|
|
72
|
-
_props$dataSource = props.dataSource,
|
|
73
|
-
dataSource = _props$dataSource === void 0 ? configDataSource : _props$dataSource,
|
|
74
|
-
onChange = props.onChange,
|
|
75
|
-
useRequest = props.useRequest,
|
|
76
|
-
_props$transformRespo = props.transformResponse,
|
|
77
|
-
transformResponse = _props$transformRespo === void 0 ? configTransformResponse : _props$transformRespo,
|
|
78
|
-
_props$level = props.level,
|
|
79
|
-
level = _props$level === void 0 ? 3 : _props$level,
|
|
80
|
-
isView = props.isView,
|
|
81
|
-
_props$enumCode = props.enumCode,
|
|
82
|
-
enumCode = _props$enumCode === void 0 ? configEnumCode : _props$enumCode,
|
|
83
|
-
_props$code = props.code,
|
|
84
|
-
code = _props$code === void 0 ? configCode : _props$code,
|
|
85
|
-
tooltip = props.tooltip,
|
|
86
|
-
_props$separator = props.separator,
|
|
87
|
-
separator = _props$separator === void 0 ? '' : _props$separator;
|
|
88
|
-
var _ref2 = _ProForm.default.useFieldProps() || {},
|
|
89
|
-
isViewCon = _ref2.isView;
|
|
90
|
-
var addressCode = code || enumCode;
|
|
91
|
-
var realIsView = typeof isView === 'boolean' ? isView : isViewCon;
|
|
92
|
-
var _ref3 = value || [],
|
|
93
|
-
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
94
|
-
province = _ref4[0],
|
|
95
|
-
city = _ref4[1];
|
|
96
|
-
var realLevel = Math.max(2, level);
|
|
97
|
-
var county = realLevel === 3 ? value === null || value === void 0 ? void 0 : value[realLevel - 1] : undefined;
|
|
98
|
-
var address = value === null || value === void 0 ? void 0 : value[realLevel];
|
|
99
|
-
var enumData = (0, _useEnum.default)(addressCode);
|
|
100
|
-
var _ref5 = Array.isArray(enumData) ? enumData : [],
|
|
101
|
-
_ref6 = (0, _slicedToArray2.default)(_ref5, 1),
|
|
102
|
-
_ref6$ = _ref6[0],
|
|
103
|
-
enumDataSource = _ref6$ === void 0 ? [] : _ref6$;
|
|
104
|
-
var realDataSource = (0, _react.useMemo)(function () {
|
|
105
|
-
var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
|
|
106
|
-
return realLevel === 2 ? filterDataSource(innerDataSource, level) : innerDataSource;
|
|
107
|
-
}, [addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
|
|
108
|
-
var _configUseRequest$use = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, configUseRequest), useRequest),
|
|
109
|
-
service = _configUseRequest$use.service,
|
|
110
|
-
_configUseRequest$use2 = _configUseRequest$use.defaultParams,
|
|
111
|
-
defaultParams = _configUseRequest$use2 === void 0 ? {
|
|
112
|
-
dictType: 'basicCode',
|
|
113
|
-
code: 'CD000049'
|
|
114
|
-
} : _configUseRequest$use2,
|
|
115
|
-
_configUseRequest$use3 = _configUseRequest$use.loadData,
|
|
116
|
-
loadData = _configUseRequest$use3 === void 0 ? true : _configUseRequest$use3,
|
|
117
|
-
_configUseRequest$use4 = _configUseRequest$use.parentKey,
|
|
118
|
-
parentKey = _configUseRequest$use4 === void 0 ? 'parentCode' : _configUseRequest$use4;
|
|
119
|
-
var _useState = (0, _react.useState)([]),
|
|
120
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
121
|
-
serviceData = _useState2[0],
|
|
122
|
-
setServiceData = _useState2[1];
|
|
123
|
-
var _useState3 = (0, _react.useState)([]),
|
|
124
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
125
|
-
provinces = _useState4[0],
|
|
126
|
-
setProvinces = _useState4[1];
|
|
127
|
-
var _useState5 = (0, _react.useState)([]),
|
|
128
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
129
|
-
provinceOptions = _useState6[0],
|
|
130
|
-
setProvinceOptions = _useState6[1];
|
|
131
|
-
var _useState7 = (0, _react.useState)(false),
|
|
132
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
133
|
-
fetched = _useState8[0],
|
|
134
|
-
setFetched = _useState8[1];
|
|
135
|
-
var _useSetState = (0, _ahooks.useSetState)({
|
|
136
|
-
province: '',
|
|
137
|
-
city: '',
|
|
138
|
-
county: ''
|
|
139
|
-
}),
|
|
140
|
-
_useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
|
|
141
|
-
defaultLabel = _useSetState2[0],
|
|
142
|
-
setDefaultLabel = _useSetState2[1];
|
|
143
|
-
var _ref7 = defaultLabel || {},
|
|
144
|
-
provinceLabel = _ref7.province,
|
|
145
|
-
cityLabel = _ref7.city,
|
|
146
|
-
countyLabel = _ref7.county;
|
|
147
|
-
var getProvinces = /*#__PURE__*/function () {
|
|
148
|
-
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(loadData) {
|
|
149
|
-
var _yield$service, data, newData, _newData, _provinces, transFormData;
|
|
150
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
151
|
-
while (1) switch (_context.prev = _context.next) {
|
|
152
|
-
case 0:
|
|
153
|
-
_context.next = 2;
|
|
154
|
-
return service(defaultParams);
|
|
155
|
-
case 2:
|
|
156
|
-
_yield$service = _context.sent;
|
|
157
|
-
data = _yield$service.data;
|
|
158
|
-
newData = data;
|
|
159
|
-
if (transformResponse) {
|
|
160
|
-
newData = transformResponse(data);
|
|
161
|
-
}
|
|
162
|
-
if (loadData) {
|
|
163
|
-
_provinces = (_newData = newData) === null || _newData === void 0 ? void 0 : _newData.map(function (item) {
|
|
164
|
-
return {
|
|
165
|
-
value: item[fieldNames.value],
|
|
166
|
-
label: item[fieldNames.label],
|
|
167
|
-
isLeaf: levelMap[realLevel] === 'province',
|
|
168
|
-
key: 'province'
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
setProvinces(_provinces);
|
|
172
|
-
setProvinceOptions(_provinces);
|
|
173
|
-
} else {
|
|
174
|
-
transFormData = transformDataName(newData, {
|
|
175
|
-
label: fieldNames.label,
|
|
176
|
-
value: fieldNames.value,
|
|
177
|
-
children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
|
|
178
|
-
});
|
|
179
|
-
setServiceData(realLevel === 2 ? filterDataSource(transFormData, level) : transFormData);
|
|
180
|
-
}
|
|
181
|
-
case 7:
|
|
182
|
-
case "end":
|
|
183
|
-
return _context.stop();
|
|
184
|
-
}
|
|
185
|
-
}, _callee);
|
|
186
|
-
}));
|
|
187
|
-
return function getProvinces(_x) {
|
|
188
|
-
return _ref8.apply(this, arguments);
|
|
189
|
-
};
|
|
190
|
-
}();
|
|
191
|
-
var getAddressData = /*#__PURE__*/function () {
|
|
192
|
-
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(params) {
|
|
193
|
-
var _yield$service2, data;
|
|
194
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
195
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
196
|
-
case 0:
|
|
197
|
-
_context2.next = 2;
|
|
198
|
-
return service((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultParams), params));
|
|
199
|
-
case 2:
|
|
200
|
-
_yield$service2 = _context2.sent;
|
|
201
|
-
data = _yield$service2.data;
|
|
202
|
-
if (!transformResponse) {
|
|
203
|
-
_context2.next = 6;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
return _context2.abrupt("return", transformResponse(data));
|
|
207
|
-
case 6:
|
|
208
|
-
return _context2.abrupt("return", data);
|
|
209
|
-
case 7:
|
|
210
|
-
case "end":
|
|
211
|
-
return _context2.stop();
|
|
212
|
-
}
|
|
213
|
-
}, _callee2);
|
|
214
|
-
}));
|
|
215
|
-
return function getAddressData(_x2) {
|
|
216
|
-
return _ref9.apply(this, arguments);
|
|
217
|
-
};
|
|
218
|
-
}();
|
|
219
|
-
// 传入useRequest时,得到地址省市区的label,初次加载需要
|
|
220
|
-
var initAddressLabel = /*#__PURE__*/function () {
|
|
221
|
-
var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(key, value, extra) {
|
|
222
|
-
var selectProvince, _newData2, _yield$service3, data, newData;
|
|
223
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
224
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
225
|
-
case 0:
|
|
226
|
-
if (!(key === 'province')) {
|
|
227
|
-
_context3.next = 5;
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
selectProvince = extra === null || extra === void 0 ? void 0 : extra.find(function (item) {
|
|
231
|
-
return item.value === value;
|
|
232
|
-
});
|
|
233
|
-
selectProvince && setDefaultLabel({
|
|
234
|
-
province: selectProvince.label
|
|
235
|
-
});
|
|
236
|
-
_context3.next = 12;
|
|
237
|
-
break;
|
|
238
|
-
case 5:
|
|
239
|
-
_context3.next = 7;
|
|
240
|
-
return service((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultParams), extra));
|
|
241
|
-
case 7:
|
|
242
|
-
_yield$service3 = _context3.sent;
|
|
243
|
-
data = _yield$service3.data;
|
|
244
|
-
newData = data;
|
|
245
|
-
if (transformResponse) {
|
|
246
|
-
newData = transformResponse(data);
|
|
247
|
-
}
|
|
248
|
-
(_newData2 = newData) === null || _newData2 === void 0 ? void 0 : _newData2.forEach(function (item) {
|
|
249
|
-
if (item[fieldNames.value] === value) {
|
|
250
|
-
// @ts-ignore
|
|
251
|
-
setDefaultLabel((0, _defineProperty2.default)({}, key, item[fieldNames.label]));
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
case 12:
|
|
255
|
-
case "end":
|
|
256
|
-
return _context3.stop();
|
|
257
|
-
}
|
|
258
|
-
}, _callee3);
|
|
259
|
-
}));
|
|
260
|
-
return function initAddressLabel(_x3, _x4, _x5) {
|
|
261
|
-
return _ref10.apply(this, arguments);
|
|
262
|
-
};
|
|
263
|
-
}();
|
|
264
|
-
(0, _react.useEffect)(function () {
|
|
265
|
-
if (service) {
|
|
266
|
-
getProvinces(loadData);
|
|
267
|
-
}
|
|
268
|
-
}, [service]);
|
|
269
|
-
(0, _react.useEffect)(function () {
|
|
270
|
-
// 传入useRequest时初始化province展示
|
|
271
|
-
if (service && loadData && !fetched && province) {
|
|
272
|
-
initAddressLabel('province', province, provinceOptions);
|
|
273
|
-
}
|
|
274
|
-
}, [province, fetched, provinceOptions]);
|
|
275
|
-
(0, _react.useEffect)(function () {
|
|
276
|
-
// 传入useRequest时初始化city展示
|
|
277
|
-
if (service && loadData && !fetched && province && city) {
|
|
278
|
-
initAddressLabel('city', city, (0, _defineProperty2.default)({}, parentKey, province));
|
|
279
|
-
}
|
|
280
|
-
}, [province, city, fetched]);
|
|
281
|
-
(0, _react.useEffect)(function () {
|
|
282
|
-
// 传入useRequest时初始化county展示
|
|
283
|
-
if (service && loadData && !fetched && city && county) {
|
|
284
|
-
initAddressLabel('county', county, (0, _defineProperty2.default)({}, parentKey, city));
|
|
285
|
-
}
|
|
286
|
-
}, [city, county, fetched]);
|
|
287
|
-
(0, _react.useEffect)(function () {
|
|
288
|
-
// 没有传入useRequest并且是查看时初始化展示
|
|
289
|
-
if (realIsView && value && realDataSource) {
|
|
290
|
-
setDefaultLabel(getAddressLabel(realDataSource, value));
|
|
291
|
-
}
|
|
292
|
-
}, [realIsView, value, realDataSource]);
|
|
293
|
-
(0, _react.useEffect)(function () {
|
|
294
|
-
// 传入useRequest但loadData为fasle查看时初始化展示
|
|
295
|
-
if (realIsView && value && (serviceData === null || serviceData === void 0 ? void 0 : serviceData.length) > 0) {
|
|
296
|
-
setDefaultLabel(getAddressLabel(serviceData, value));
|
|
297
|
-
}
|
|
298
|
-
}, [realIsView, value, serviceData]);
|
|
299
|
-
var handleLoadData = /*#__PURE__*/function () {
|
|
300
|
-
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4(selectedOptions) {
|
|
301
|
-
var targetOption, data;
|
|
302
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
303
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
304
|
-
case 0:
|
|
305
|
-
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
306
|
-
targetOption.loading = true;
|
|
307
|
-
_context4.next = 4;
|
|
308
|
-
return getAddressData((0, _defineProperty2.default)({}, parentKey, targetOption === null || targetOption === void 0 ? void 0 : targetOption.value));
|
|
309
|
-
case 4:
|
|
310
|
-
data = _context4.sent;
|
|
311
|
-
targetOption.loading = false;
|
|
312
|
-
targetOption.children = data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
313
|
-
return {
|
|
314
|
-
value: item[fieldNames.value],
|
|
315
|
-
label: item[fieldNames.label],
|
|
316
|
-
isLeaf: targetOption.key === levelMap[realLevel - 1],
|
|
317
|
-
key: targetOption.key === 'province' ? 'city' : 'county'
|
|
318
|
-
};
|
|
319
|
-
});
|
|
320
|
-
setProvinces((0, _toConsumableArray2.default)(provinces));
|
|
321
|
-
setFetched(true);
|
|
322
|
-
case 9:
|
|
323
|
-
case "end":
|
|
324
|
-
return _context4.stop();
|
|
325
|
-
}
|
|
326
|
-
}, _callee4);
|
|
327
|
-
}));
|
|
328
|
-
return function handleLoadData(_x6) {
|
|
329
|
-
return _ref11.apply(this, arguments);
|
|
330
|
-
};
|
|
331
|
-
}();
|
|
332
|
-
var handleChange = function handleChange(changeValue, selectedOptions) {
|
|
333
|
-
if (onChange) {
|
|
334
|
-
if (hasDetail && address) {
|
|
335
|
-
var realValue = changeValue || [];
|
|
336
|
-
realValue[realLevel] = address;
|
|
337
|
-
onChange(realValue, selectedOptions);
|
|
338
|
-
} else {
|
|
339
|
-
onChange(changeValue, selectedOptions);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
var handlefilter = function handlefilter(inputValue, path) {
|
|
344
|
-
return path.some(function (option) {
|
|
345
|
-
return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
var handleAddressChange = function handleAddressChange(e) {
|
|
349
|
-
if (onChange) {
|
|
350
|
-
if (!e.target.value && !province && !city && !county) {
|
|
351
|
-
onChange(undefined);
|
|
352
|
-
} else {
|
|
353
|
-
var realValue = value ? (0, _toConsumableArray2.default)(value) : [];
|
|
354
|
-
realValue[realLevel] = e.target.value;
|
|
355
|
-
onChange(realValue);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
var displayRender = function displayRender(label) {
|
|
360
|
-
var _filter;
|
|
361
|
-
if (fetched) {
|
|
362
|
-
return label === null || label === void 0 ? void 0 : label.filter(function (item) {
|
|
363
|
-
return !!item;
|
|
364
|
-
}).join('/');
|
|
365
|
-
}
|
|
366
|
-
return value ? (_filter = [provinceLabel, cityLabel, countyLabel].filter(function (item) {
|
|
367
|
-
return !!item;
|
|
368
|
-
})) === null || _filter === void 0 ? void 0 : _filter.join('/') : undefined;
|
|
369
|
-
};
|
|
370
|
-
var addressValue = value && (province || city || county) ? [province, city, county].slice(0, realLevel) : undefined;
|
|
371
|
-
var viewValue = ((_ref12 = [provinceLabel, cityLabel, countyLabel, value === null || value === void 0 ? void 0 : value[realLevel]]) === null || _ref12 === void 0 ? void 0 : (_ref12$filter = _ref12.filter(function (item) {
|
|
372
|
-
return !!item;
|
|
373
|
-
})) === null || _ref12$filter === void 0 ? void 0 : _ref12$filter.join(separator)) || '-';
|
|
374
|
-
return realIsView ? tooltip ? (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
375
|
-
className: className,
|
|
376
|
-
title: tooltip === true ? viewValue : tooltip,
|
|
377
|
-
children: (0, _jsxRuntime.jsx)(Text, {
|
|
378
|
-
ellipsis: {
|
|
379
|
-
tooltip: false
|
|
380
|
-
},
|
|
381
|
-
children: viewValue
|
|
382
|
-
})
|
|
383
|
-
}) : (0, _jsxRuntime.jsx)("span", {
|
|
384
|
-
className: className,
|
|
385
|
-
children: viewValue
|
|
386
|
-
}) : (0, _jsxRuntime.jsxs)("div", {
|
|
387
|
-
className: "pro-address ".concat(className),
|
|
388
|
-
children: [dataSource || addressCode || !loadData ? (0, _jsxRuntime.jsx)(_antd.Cascader, {
|
|
389
|
-
className: hasDetail ? '' : 'no-detail',
|
|
390
|
-
placeholder: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProAddressBar = _locale.default.ProAddressBar) === null || _locale$ProAddressBar === void 0 ? void 0 : _locale$ProAddressBar.placeholder,
|
|
391
|
-
value: addressValue,
|
|
392
|
-
options: !loadData ? serviceData : realDataSource,
|
|
393
|
-
disabled: disabled,
|
|
394
|
-
displayRender: function displayRender(label) {
|
|
395
|
-
return label === null || label === void 0 ? void 0 : label.filter(function (item) {
|
|
396
|
-
return !!item;
|
|
397
|
-
}).join('/');
|
|
398
|
-
},
|
|
399
|
-
showSearch: {
|
|
400
|
-
filter: handlefilter
|
|
401
|
-
},
|
|
402
|
-
onChange: handleChange
|
|
403
|
-
}) : (0, _jsxRuntime.jsx)(_antd.Cascader, {
|
|
404
|
-
className: hasDetail ? '' : 'no-detail',
|
|
405
|
-
placeholder: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProAddressBar2 = _locale.default.ProAddressBar) === null || _locale$ProAddressBar2 === void 0 ? void 0 : _locale$ProAddressBar2.placeholder,
|
|
406
|
-
value: addressValue,
|
|
407
|
-
loadData: handleLoadData,
|
|
408
|
-
// @ts-ignore
|
|
409
|
-
options: provinces,
|
|
410
|
-
disabled: disabled,
|
|
411
|
-
displayRender: displayRender,
|
|
412
|
-
changeOnSelect: true,
|
|
413
|
-
// @ts-ignore
|
|
414
|
-
onChange: handleChange
|
|
415
|
-
}), hasDetail && (tooltip && disabled && address ? (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
416
|
-
title: address,
|
|
417
|
-
children: (0, _jsxRuntime.jsx)("span", {
|
|
418
|
-
className: "pro-address-detail",
|
|
419
|
-
children: (0, _jsxRuntime.jsx)(_antd.Input, {
|
|
420
|
-
disabled: disabled,
|
|
421
|
-
value: address
|
|
422
|
-
})
|
|
423
|
-
})
|
|
424
|
-
}) : (0, _jsxRuntime.jsx)(_antd.Input, {
|
|
425
|
-
allowClear: true,
|
|
426
|
-
autoComplete: "off",
|
|
427
|
-
disabled: disabled,
|
|
428
|
-
value: address,
|
|
429
|
-
maxLength: detailMaxLength,
|
|
430
|
-
placeholder: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProAddressBar3 = _locale.default.ProAddressBar) === null || _locale$ProAddressBar3 === void 0 ? void 0 : _locale$ProAddressBar3.detailPlaceholder,
|
|
431
|
-
// @ts-ignore
|
|
432
|
-
onChange: handleAddressChange
|
|
433
|
-
}))]
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
// @ts-ignore
|
|
437
|
-
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(ProAddressBar);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|