@kne/super-select-plus 0.1.3 → 0.1.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/{city-39702d3a.js → city-8aa3edf6.js} +1 -1
- package/dist/{city-39702d3a.js.map → city-8aa3edf6.js.map} +1 -1
- package/dist/{function-871311da.js → function-f92c83bd.js} +1 -1
- package/dist/{function-871311da.js.map → function-f92c83bd.js.map} +1 -1
- package/dist/index.css +55 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +308 -340
- package/dist/index.js.map +1 -1
- package/dist/{industry-f570d549.js → industry-4005a16d.js} +1 -1
- package/dist/{industry-f570d549.js.map → industry-4005a16d.js.map} +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18,25 +18,6 @@ var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
|
|
|
18
18
|
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
19
19
|
var SearchInput__default = /*#__PURE__*/_interopDefaultLegacy(SearchInput);
|
|
20
20
|
|
|
21
|
-
function _extends() {
|
|
22
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
23
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
24
|
-
var t = arguments[e];
|
|
25
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
26
|
-
}
|
|
27
|
-
return n;
|
|
28
|
-
}, _extends.apply(null, arguments);
|
|
29
|
-
}
|
|
30
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
31
|
-
if (null == r) return {};
|
|
32
|
-
var t = {};
|
|
33
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
34
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
35
|
-
t[n] = r[n];
|
|
36
|
-
}
|
|
37
|
-
return t;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
21
|
const locale$1 = {
|
|
41
22
|
placeholder: '请选择',
|
|
42
23
|
searchPlaceholder: '搜索',
|
|
@@ -78,7 +59,6 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
78
59
|
namespace: 'super-select-plus'
|
|
79
60
|
});
|
|
80
61
|
|
|
81
|
-
const _excluded$4 = ["data", "name", "names", "type", "cache", "children", "getLabel", "dataFormat", "transformItem"];
|
|
82
62
|
const enumCache = new Map();
|
|
83
63
|
|
|
84
64
|
// 默认子组件渲染函数
|
|
@@ -95,61 +75,49 @@ const getLabels = output => Array.isArray(output) ? output.map(item => get__defa
|
|
|
95
75
|
* @param {Array|Object} items createEnumComponent children 第一个参数
|
|
96
76
|
* @param {Object} options valueKey / labelKey 字段映射
|
|
97
77
|
*/
|
|
98
|
-
const enumItemsToSelectValue =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var _item$id, _ref2, _item$label;
|
|
106
|
-
return {
|
|
107
|
-
[valueKey]: (_item$id = item.id) != null ? _item$id : item.code,
|
|
108
|
-
[labelKey]: (_ref2 = (_item$label = item.label) != null ? _item$label : item.name) != null ? _ref2 : item.chName
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
};
|
|
78
|
+
const enumItemsToSelectValue = (items, {
|
|
79
|
+
valueKey = 'id',
|
|
80
|
+
labelKey = 'name'
|
|
81
|
+
} = {}) => (Array.isArray(items) ? items : [items]).filter(Boolean).map(item => ({
|
|
82
|
+
[valueKey]: item.id ?? item.code,
|
|
83
|
+
[labelKey]: item.label ?? item.name ?? item.chName
|
|
84
|
+
}));
|
|
112
85
|
|
|
113
86
|
/**
|
|
114
87
|
* 将单个 Enum 解析结果转为选择器 value(单选)
|
|
115
88
|
*/
|
|
116
|
-
const enumItemToSelectValue = (item, options) =>
|
|
117
|
-
var _enumItemsToSelectVal;
|
|
118
|
-
return (_enumItemsToSelectVal = enumItemsToSelectValue(item, options)[0]) != null ? _enumItemsToSelectVal : null;
|
|
119
|
-
};
|
|
89
|
+
const enumItemToSelectValue = (item, options) => enumItemsToSelectValue(item, options)[0] ?? null;
|
|
120
90
|
|
|
121
91
|
/**
|
|
122
92
|
* 将 AddressEnum 解析结果转为 SelectAddress value(支持 name 单值或 names 数组)
|
|
123
93
|
*/
|
|
124
94
|
const addressEnumToSelectValue = outputs => {
|
|
125
95
|
const list = Array.isArray(outputs) ? outputs : outputs ? [outputs] : [];
|
|
126
|
-
return list.filter(item => item
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
96
|
+
return list.filter(item => item?.city).map(({
|
|
97
|
+
city
|
|
98
|
+
}) => ({
|
|
99
|
+
value: city.code,
|
|
100
|
+
label: city.name,
|
|
101
|
+
...city
|
|
102
|
+
}));
|
|
133
103
|
};
|
|
134
104
|
|
|
135
105
|
/**
|
|
136
106
|
* 将单个 AddressEnum 解析结果转为 SelectAddress value(单选)
|
|
137
107
|
*/
|
|
138
|
-
const addressEnumToSelectValueSingle = output =>
|
|
139
|
-
var _addressEnumToSelectV;
|
|
140
|
-
return (_addressEnumToSelectV = addressEnumToSelectValue(output)[0]) != null ? _addressEnumToSelectV : null;
|
|
141
|
-
};
|
|
108
|
+
const addressEnumToSelectValueSingle = output => addressEnumToSelectValue(output)[0] ?? null;
|
|
142
109
|
const resolveOutput = (mapping, name, names) => {
|
|
143
110
|
if (names) {
|
|
144
111
|
return names.map(code => mapping.get(code));
|
|
145
112
|
}
|
|
146
113
|
return mapping.get(name);
|
|
147
114
|
};
|
|
148
|
-
const cacheOutput = (output,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
115
|
+
const cacheOutput = (output, {
|
|
116
|
+
cacheKey,
|
|
117
|
+
type,
|
|
118
|
+
name,
|
|
119
|
+
names
|
|
120
|
+
}) => {
|
|
153
121
|
if (!cacheKey || !type) {
|
|
154
122
|
return;
|
|
155
123
|
}
|
|
@@ -157,33 +125,33 @@ const cacheOutput = (output, _ref4) => {
|
|
|
157
125
|
names.forEach((code, index) => {
|
|
158
126
|
const item = output[index];
|
|
159
127
|
if (item) {
|
|
160
|
-
enumCache.set(cacheKey
|
|
128
|
+
enumCache.set(`${cacheKey}_${type}_${code}`, item);
|
|
161
129
|
}
|
|
162
130
|
});
|
|
163
131
|
return;
|
|
164
132
|
}
|
|
165
133
|
if (output) {
|
|
166
|
-
enumCache.set(cacheKey
|
|
134
|
+
enumCache.set(`${cacheKey}_${type}_${name}`, output);
|
|
167
135
|
}
|
|
168
136
|
};
|
|
169
|
-
const getCachedOutput =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
137
|
+
const getCachedOutput = ({
|
|
138
|
+
cacheKey,
|
|
139
|
+
type,
|
|
140
|
+
name,
|
|
141
|
+
names,
|
|
142
|
+
force
|
|
143
|
+
}) => {
|
|
176
144
|
if (force) {
|
|
177
145
|
return null;
|
|
178
146
|
}
|
|
179
|
-
if (names
|
|
180
|
-
const items = names.map(code => enumCache.get(cacheKey
|
|
147
|
+
if (names?.length) {
|
|
148
|
+
const items = names.map(code => enumCache.get(`${cacheKey}_${type}_${code}`));
|
|
181
149
|
return items.every(Boolean) ? items : null;
|
|
182
150
|
}
|
|
183
151
|
if (name == null) {
|
|
184
152
|
return null;
|
|
185
153
|
}
|
|
186
|
-
return
|
|
154
|
+
return enumCache.get(`${cacheKey}_${type}_${name}`) ?? null;
|
|
187
155
|
};
|
|
188
156
|
|
|
189
157
|
/**
|
|
@@ -204,7 +172,8 @@ const defaultDataFormat = data => data.data || data;
|
|
|
204
172
|
/**
|
|
205
173
|
* 默认映射项转换函数
|
|
206
174
|
*/
|
|
207
|
-
const defaultTransformItem = (item, label) =>
|
|
175
|
+
const defaultTransformItem = (item, label) => ({
|
|
176
|
+
...item,
|
|
208
177
|
id: item.code,
|
|
209
178
|
label,
|
|
210
179
|
parentId: item.parentCode || null
|
|
@@ -213,19 +182,21 @@ const defaultTransformItem = (item, label) => _extends({}, item, {
|
|
|
213
182
|
/**
|
|
214
183
|
* 内部枚举显示组件
|
|
215
184
|
*/
|
|
216
|
-
const EnumDisplayInner = reactFetch.withFetch(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
185
|
+
const EnumDisplayInner = reactFetch.withFetch(({
|
|
186
|
+
data,
|
|
187
|
+
name,
|
|
188
|
+
names,
|
|
189
|
+
type,
|
|
190
|
+
cache: cacheKey,
|
|
191
|
+
children,
|
|
192
|
+
getLabel,
|
|
193
|
+
dataFormat,
|
|
194
|
+
transformItem,
|
|
195
|
+
...props
|
|
196
|
+
}) => {
|
|
197
|
+
const {
|
|
198
|
+
locale
|
|
199
|
+
} = reactIntl.useIntl();
|
|
229
200
|
|
|
230
201
|
// 格式化数据
|
|
231
202
|
const formattedData = react.useMemo(() => dataFormat(data), [data, dataFormat]);
|
|
@@ -245,34 +216,30 @@ const EnumDisplayInner = reactFetch.withFetch(_ref6 => {
|
|
|
245
216
|
name,
|
|
246
217
|
names
|
|
247
218
|
});
|
|
248
|
-
return children(output,
|
|
219
|
+
return children(output, {
|
|
220
|
+
...props,
|
|
249
221
|
locale,
|
|
250
222
|
mapping,
|
|
251
223
|
names,
|
|
252
224
|
labels: getLabels(output)
|
|
253
|
-
})
|
|
225
|
+
});
|
|
254
226
|
});
|
|
255
227
|
|
|
256
228
|
/**
|
|
257
229
|
* 枚举显示组件
|
|
258
230
|
*/
|
|
259
231
|
const EnumDisplay = withLocale(props => {
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
type =
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
dataFormat = _props$dataFormat === void 0 ? defaultDataFormat : _props$dataFormat,
|
|
272
|
-
_props$transformItem = props.transformItem,
|
|
273
|
-
transformItem = _props$transformItem === void 0 ? defaultTransformItem : _props$transformItem,
|
|
274
|
-
_props$children = props.children,
|
|
275
|
-
children = _props$children === void 0 ? defaultChildren : _props$children;
|
|
232
|
+
const {
|
|
233
|
+
name,
|
|
234
|
+
names,
|
|
235
|
+
type = 'default',
|
|
236
|
+
cache: cacheKey = 'ENUM_DATA',
|
|
237
|
+
force = false,
|
|
238
|
+
getLabel = defaultGetLabel,
|
|
239
|
+
dataFormat = defaultDataFormat,
|
|
240
|
+
transformItem = defaultTransformItem,
|
|
241
|
+
children = defaultChildren
|
|
242
|
+
} = props;
|
|
276
243
|
const cached = getCachedOutput({
|
|
277
244
|
cacheKey,
|
|
278
245
|
type,
|
|
@@ -287,14 +254,15 @@ const EnumDisplay = withLocale(props => {
|
|
|
287
254
|
labels: getLabels(cached)
|
|
288
255
|
});
|
|
289
256
|
}
|
|
290
|
-
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner,
|
|
257
|
+
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, {
|
|
258
|
+
...props,
|
|
291
259
|
type: type,
|
|
292
260
|
cache: cacheKey,
|
|
293
261
|
getLabel: getLabel,
|
|
294
262
|
dataFormat: dataFormat,
|
|
295
263
|
transformItem: transformItem,
|
|
296
264
|
children: children
|
|
297
|
-
})
|
|
265
|
+
});
|
|
298
266
|
});
|
|
299
267
|
|
|
300
268
|
/**
|
|
@@ -309,22 +277,21 @@ const EnumDisplay = withLocale(props => {
|
|
|
309
277
|
* @returns {React.Component} 枚举组件
|
|
310
278
|
*/
|
|
311
279
|
const createEnumComponent = options => {
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
getLabel =
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
defaultApi = options.defaultApi;
|
|
280
|
+
const {
|
|
281
|
+
type,
|
|
282
|
+
cache,
|
|
283
|
+
getLabel = defaultGetLabel,
|
|
284
|
+
dataFormat = defaultDataFormat,
|
|
285
|
+
transformItem = defaultTransformItem,
|
|
286
|
+
defaultApi
|
|
287
|
+
} = options;
|
|
321
288
|
const EnumComponent = withLocale(props => {
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
force =
|
|
326
|
-
|
|
327
|
-
|
|
289
|
+
const {
|
|
290
|
+
name,
|
|
291
|
+
names,
|
|
292
|
+
force = false,
|
|
293
|
+
children = defaultChildren
|
|
294
|
+
} = props;
|
|
328
295
|
const cached = getCachedOutput({
|
|
329
296
|
cacheKey: cache,
|
|
330
297
|
type,
|
|
@@ -339,14 +306,16 @@ const createEnumComponent = options => {
|
|
|
339
306
|
labels: getLabels(cached)
|
|
340
307
|
});
|
|
341
308
|
}
|
|
342
|
-
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner,
|
|
309
|
+
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, {
|
|
310
|
+
...props,
|
|
311
|
+
...defaultApi,
|
|
343
312
|
type: type,
|
|
344
313
|
cache: cache,
|
|
345
314
|
getLabel: getLabel,
|
|
346
315
|
dataFormat: dataFormat,
|
|
347
316
|
transformItem: transformItem,
|
|
348
317
|
children: children
|
|
349
|
-
})
|
|
318
|
+
});
|
|
350
319
|
});
|
|
351
320
|
|
|
352
321
|
// 附加静态属性
|
|
@@ -379,7 +348,7 @@ const defaultFunctionApi = {
|
|
|
379
348
|
ttl: 1000 * 60 * 60 * 24,
|
|
380
349
|
// 24小时
|
|
381
350
|
loader: () => {
|
|
382
|
-
return Promise.resolve().then(function () { return require('./function-
|
|
351
|
+
return Promise.resolve().then(function () { return require('./function-f92c83bd.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
383
352
|
}
|
|
384
353
|
};
|
|
385
354
|
|
|
@@ -393,35 +362,25 @@ const FunctionEnum = createEnumComponent({
|
|
|
393
362
|
defaultApi: defaultFunctionApi
|
|
394
363
|
});
|
|
395
364
|
|
|
396
|
-
const getItemId =
|
|
397
|
-
var _ref, _ref2, _item$valueKey;
|
|
398
|
-
if (valueKey === void 0) {
|
|
399
|
-
valueKey = 'id';
|
|
400
|
-
}
|
|
365
|
+
const getItemId = (item, valueKey = 'id') => {
|
|
401
366
|
if (item == null) {
|
|
402
367
|
return null;
|
|
403
368
|
}
|
|
404
369
|
if (typeof item !== 'object') {
|
|
405
370
|
return item;
|
|
406
371
|
}
|
|
407
|
-
return
|
|
372
|
+
return item[valueKey] ?? item.id ?? item.code ?? null;
|
|
408
373
|
};
|
|
409
|
-
const getItemLabel =
|
|
410
|
-
var _ref3, _ref4, _item$labelKey;
|
|
411
|
-
if (labelKey === void 0) {
|
|
412
|
-
labelKey = 'name';
|
|
413
|
-
}
|
|
374
|
+
const getItemLabel = (item, labelKey = 'name') => {
|
|
414
375
|
if (item == null || typeof item !== 'object') {
|
|
415
376
|
return null;
|
|
416
377
|
}
|
|
417
|
-
return
|
|
378
|
+
return item[labelKey] ?? item.label ?? item.name ?? null;
|
|
418
379
|
};
|
|
419
|
-
const resolveItemFromNode =
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
_ref5$labelKey = _ref5.labelKey,
|
|
424
|
-
labelKey = _ref5$labelKey === void 0 ? 'name' : _ref5$labelKey;
|
|
380
|
+
const resolveItemFromNode = (item, node, {
|
|
381
|
+
valueKey = 'id',
|
|
382
|
+
labelKey = 'name'
|
|
383
|
+
} = {}) => {
|
|
425
384
|
const id = getItemId(item, valueKey);
|
|
426
385
|
if (id == null) {
|
|
427
386
|
return item;
|
|
@@ -429,10 +388,11 @@ const resolveItemFromNode = function (item, node, _temp) {
|
|
|
429
388
|
if (!node) {
|
|
430
389
|
const label = getItemLabel(item, labelKey);
|
|
431
390
|
if (typeof item === 'object') {
|
|
432
|
-
return label != null && label !== String(id) ? item :
|
|
391
|
+
return label != null && label !== String(id) ? item : {
|
|
392
|
+
...(typeof item === 'object' ? item : {}),
|
|
433
393
|
[valueKey]: id,
|
|
434
394
|
[labelKey]: label || String(id)
|
|
435
|
-
}
|
|
395
|
+
};
|
|
436
396
|
}
|
|
437
397
|
return {
|
|
438
398
|
[valueKey]: id,
|
|
@@ -440,24 +400,23 @@ const resolveItemFromNode = function (item, node, _temp) {
|
|
|
440
400
|
};
|
|
441
401
|
}
|
|
442
402
|
const label = getItemLabel(item, labelKey) || node[labelKey] || node.name;
|
|
443
|
-
return
|
|
403
|
+
return {
|
|
404
|
+
...node,
|
|
405
|
+
...(typeof item === 'object' ? item : {}),
|
|
444
406
|
[valueKey]: id,
|
|
445
407
|
[labelKey]: label
|
|
446
|
-
}
|
|
408
|
+
};
|
|
447
409
|
};
|
|
448
410
|
|
|
449
411
|
/**
|
|
450
412
|
* 通过扁平 Map 解析 value(推荐,不依赖级联树结构)
|
|
451
413
|
*/
|
|
452
|
-
const resolveCascaderValueFromMap =
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
_ref6$single = _ref6.single,
|
|
459
|
-
single = _ref6$single === void 0 ? false : _ref6$single;
|
|
460
|
-
if (value == null || !(mapping != null && mapping.size)) {
|
|
414
|
+
const resolveCascaderValueFromMap = (value, mapping, {
|
|
415
|
+
valueKey = 'id',
|
|
416
|
+
labelKey = 'name',
|
|
417
|
+
single = false
|
|
418
|
+
} = {}) => {
|
|
419
|
+
if (value == null || !mapping?.size) {
|
|
461
420
|
return value;
|
|
462
421
|
}
|
|
463
422
|
const resolveItem = item => resolveItemFromNode(item, mapping.get(getItemId(item, valueKey)), {
|
|
@@ -474,35 +433,35 @@ const resolveCascaderValueFromMap = function (value, mapping, _temp2) {
|
|
|
474
433
|
/**
|
|
475
434
|
* 将仅含编码的 value 解析为含 label 的完整对象(城市选择器)
|
|
476
435
|
*/
|
|
477
|
-
const resolveAddressValue =
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
single = _ref8$single === void 0 ? false : _ref8$single;
|
|
436
|
+
const resolveAddressValue = (value, addressApi, {
|
|
437
|
+
single = false
|
|
438
|
+
} = {}) => {
|
|
481
439
|
if (value == null || !addressApi) {
|
|
482
440
|
return value;
|
|
483
441
|
}
|
|
484
442
|
const resolveItem = item => {
|
|
485
|
-
var _item$value, _item$label;
|
|
486
443
|
if (item == null) {
|
|
487
444
|
return item;
|
|
488
445
|
}
|
|
489
|
-
const code = typeof item === 'object' ?
|
|
446
|
+
const code = typeof item === 'object' ? item.value ?? item.code : item;
|
|
490
447
|
if (!code) {
|
|
491
448
|
return typeof item === 'object' ? item : null;
|
|
492
449
|
}
|
|
493
|
-
const label = typeof item === 'object' ?
|
|
450
|
+
const label = typeof item === 'object' ? item.label ?? item.name : null;
|
|
494
451
|
if (label && label !== String(code)) {
|
|
495
452
|
return typeof item === 'object' ? item : {
|
|
496
453
|
value: code,
|
|
497
454
|
label
|
|
498
455
|
};
|
|
499
456
|
}
|
|
500
|
-
const
|
|
501
|
-
city
|
|
502
|
-
|
|
457
|
+
const {
|
|
458
|
+
city
|
|
459
|
+
} = addressApi.getCity(code);
|
|
460
|
+
return city ? {
|
|
503
461
|
value: code,
|
|
504
|
-
label: city.name
|
|
505
|
-
|
|
462
|
+
label: city.name,
|
|
463
|
+
...city
|
|
464
|
+
} : {
|
|
506
465
|
value: code,
|
|
507
466
|
label: String(code)
|
|
508
467
|
};
|
|
@@ -517,14 +476,11 @@ const resolveAddressValue = function (value, addressApi, _temp3) {
|
|
|
517
476
|
/**
|
|
518
477
|
* 判断是否需要将解析后的 value 同步回 onChange(仅编码 -> 含 label)
|
|
519
478
|
*/
|
|
520
|
-
const shouldSyncSelectValue =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
labelKey = _ref9$labelKey === void 0 ? 'name' : _ref9$labelKey,
|
|
526
|
-
_ref9$single = _ref9.single,
|
|
527
|
-
single = _ref9$single === void 0 ? false : _ref9$single;
|
|
479
|
+
const shouldSyncSelectValue = (value, resolved, {
|
|
480
|
+
valueKey = 'id',
|
|
481
|
+
labelKey = 'name',
|
|
482
|
+
single = false
|
|
483
|
+
} = {}) => {
|
|
528
484
|
if (resolved == null || value == null) {
|
|
529
485
|
return false;
|
|
530
486
|
}
|
|
@@ -552,19 +508,19 @@ const shouldSyncSelectValue = function (value, resolved, _temp4) {
|
|
|
552
508
|
return resolved.some((item, index) => needSyncItem(value[index], item));
|
|
553
509
|
};
|
|
554
510
|
|
|
555
|
-
const _excluded$3 = ["value", "onChange", "single", "placeholder", "isPopup", "overlayWidth", "apis", "onSearch"];
|
|
556
511
|
const defaultFunctionData = () => {
|
|
557
|
-
return Promise.resolve().then(function () { return require('./function-
|
|
512
|
+
return Promise.resolve().then(function () { return require('./function-f92c83bd.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
558
513
|
};
|
|
559
514
|
const transformToCascaderData$1 = (data, locale) => {
|
|
560
515
|
// 创建映射表
|
|
561
516
|
const mapping = new Map();
|
|
562
517
|
data.forEach(item => {
|
|
563
|
-
mapping.set(item.code,
|
|
518
|
+
mapping.set(item.code, {
|
|
519
|
+
...item,
|
|
564
520
|
id: item.code,
|
|
565
521
|
name: getLabelForLocal$3(item, locale),
|
|
566
522
|
children: []
|
|
567
|
-
})
|
|
523
|
+
});
|
|
568
524
|
});
|
|
569
525
|
|
|
570
526
|
// 构建嵌套结构
|
|
@@ -592,24 +548,22 @@ const transformToCascaderData$1 = (data, locale) => {
|
|
|
592
548
|
cleanEmptyChildren(roots);
|
|
593
549
|
return roots;
|
|
594
550
|
};
|
|
595
|
-
const SelectFunctionInner =
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
data = _useState[0],
|
|
612
|
-
setData = _useState[1];
|
|
551
|
+
const SelectFunctionInner = ({
|
|
552
|
+
value,
|
|
553
|
+
onChange,
|
|
554
|
+
single = false,
|
|
555
|
+
placeholder,
|
|
556
|
+
isPopup = true,
|
|
557
|
+
overlayWidth = 320,
|
|
558
|
+
apis: currentApis,
|
|
559
|
+
onSearch,
|
|
560
|
+
...props
|
|
561
|
+
}) => {
|
|
562
|
+
const {
|
|
563
|
+
locale,
|
|
564
|
+
formatMessage
|
|
565
|
+
} = reactIntl.useIntl();
|
|
566
|
+
const [data, setData] = react.useState([]);
|
|
613
567
|
react.useEffect(() => {
|
|
614
568
|
defaultFunctionData().then(result => {
|
|
615
569
|
setData(result.data || result);
|
|
@@ -619,10 +573,11 @@ const SelectFunctionInner = _ref => {
|
|
|
619
573
|
const flatMapping = react.useMemo(() => {
|
|
620
574
|
const mapping = new Map();
|
|
621
575
|
data.forEach(item => {
|
|
622
|
-
mapping.set(item.code,
|
|
576
|
+
mapping.set(item.code, {
|
|
577
|
+
...item,
|
|
623
578
|
id: item.code,
|
|
624
579
|
name: getLabelForLocal$3(item, locale)
|
|
625
|
-
})
|
|
580
|
+
});
|
|
626
581
|
});
|
|
627
582
|
return mapping;
|
|
628
583
|
}, [data, locale]);
|
|
@@ -648,15 +603,17 @@ const SelectFunctionInner = _ref => {
|
|
|
648
603
|
onChange(resolved);
|
|
649
604
|
}
|
|
650
605
|
}, [value, flatMapping, single, onChange]);
|
|
651
|
-
const handleSearch = (searchText,
|
|
652
|
-
|
|
606
|
+
const handleSearch = (searchText, {
|
|
607
|
+
mapping
|
|
608
|
+
}) => {
|
|
653
609
|
if (!searchText) return Array.from(mapping.values());
|
|
654
610
|
const keyword = searchText.toLowerCase();
|
|
655
611
|
return Array.from(mapping.values()).filter(item => {
|
|
656
612
|
return item.chName && item.chName.toLowerCase().includes(keyword) || item.enName && item.enName.toLowerCase().includes(keyword) || item.pinyin && item.pinyin.toLowerCase().includes(keyword) || item.spelling && item.spelling.toLowerCase().includes(keyword);
|
|
657
613
|
});
|
|
658
614
|
};
|
|
659
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader,
|
|
615
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, {
|
|
616
|
+
...props,
|
|
660
617
|
value: normalizedValue,
|
|
661
618
|
onChange: onChange,
|
|
662
619
|
single: single,
|
|
@@ -668,14 +625,15 @@ const SelectFunctionInner = _ref => {
|
|
|
668
625
|
isPopup: isPopup,
|
|
669
626
|
overlayWidth: overlayWidth,
|
|
670
627
|
menuItemWidth: 200,
|
|
671
|
-
style:
|
|
672
|
-
width: overlayWidth
|
|
673
|
-
|
|
628
|
+
style: {
|
|
629
|
+
width: overlayWidth,
|
|
630
|
+
...props.style
|
|
631
|
+
},
|
|
674
632
|
options: options,
|
|
675
633
|
valueKey: "id",
|
|
676
634
|
labelKey: "name",
|
|
677
635
|
onSearch: onSearch || handleSearch
|
|
678
|
-
})
|
|
636
|
+
});
|
|
679
637
|
};
|
|
680
638
|
const SelectFunction = withLocale(SelectFunctionInner);
|
|
681
639
|
SelectFunction.defaultData = defaultFunctionData;
|
|
@@ -700,7 +658,7 @@ const defaultIndustryApi = {
|
|
|
700
658
|
ttl: 1000 * 60 * 60 * 24,
|
|
701
659
|
// 24小时
|
|
702
660
|
loader: () => {
|
|
703
|
-
return Promise.resolve().then(function () { return require('./industry-
|
|
661
|
+
return Promise.resolve().then(function () { return require('./industry-4005a16d.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
704
662
|
}
|
|
705
663
|
};
|
|
706
664
|
|
|
@@ -714,9 +672,8 @@ const IndustryEnum = createEnumComponent({
|
|
|
714
672
|
defaultApi: defaultIndustryApi
|
|
715
673
|
});
|
|
716
674
|
|
|
717
|
-
const _excluded$2 = ["value", "onChange", "single", "placeholder", "isPopup", "overlayWidth", "apis", "onSearch"];
|
|
718
675
|
const defaultIndustryData = () => {
|
|
719
|
-
return Promise.resolve().then(function () { return require('./industry-
|
|
676
|
+
return Promise.resolve().then(function () { return require('./industry-4005a16d.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
720
677
|
};
|
|
721
678
|
const transformToCascaderData = (data, locale) => {
|
|
722
679
|
// 过滤掉"全部行业"
|
|
@@ -725,11 +682,12 @@ const transformToCascaderData = (data, locale) => {
|
|
|
725
682
|
// 创建映射表
|
|
726
683
|
const mapping = new Map();
|
|
727
684
|
filteredData.forEach(item => {
|
|
728
|
-
mapping.set(item.code,
|
|
685
|
+
mapping.set(item.code, {
|
|
686
|
+
...item,
|
|
729
687
|
id: item.code,
|
|
730
688
|
name: getLabelForLocal$2(item, locale),
|
|
731
689
|
children: []
|
|
732
|
-
})
|
|
690
|
+
});
|
|
733
691
|
});
|
|
734
692
|
|
|
735
693
|
// 构建嵌套结构
|
|
@@ -757,24 +715,22 @@ const transformToCascaderData = (data, locale) => {
|
|
|
757
715
|
cleanEmptyChildren(roots);
|
|
758
716
|
return roots;
|
|
759
717
|
};
|
|
760
|
-
const SelectIndustryInner =
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const
|
|
776
|
-
data = _useState[0],
|
|
777
|
-
setData = _useState[1];
|
|
718
|
+
const SelectIndustryInner = ({
|
|
719
|
+
value,
|
|
720
|
+
onChange,
|
|
721
|
+
single = false,
|
|
722
|
+
placeholder,
|
|
723
|
+
isPopup = true,
|
|
724
|
+
overlayWidth = 320,
|
|
725
|
+
apis: currentApis,
|
|
726
|
+
onSearch,
|
|
727
|
+
...props
|
|
728
|
+
}) => {
|
|
729
|
+
const {
|
|
730
|
+
locale,
|
|
731
|
+
formatMessage
|
|
732
|
+
} = reactIntl.useIntl();
|
|
733
|
+
const [data, setData] = react.useState([]);
|
|
778
734
|
react.useEffect(() => {
|
|
779
735
|
defaultIndustryData().then(result => {
|
|
780
736
|
setData(result.data || result);
|
|
@@ -784,10 +740,11 @@ const SelectIndustryInner = _ref => {
|
|
|
784
740
|
const flatMapping = react.useMemo(() => {
|
|
785
741
|
const mapping = new Map();
|
|
786
742
|
data.filter(item => item.code !== '000').forEach(item => {
|
|
787
|
-
mapping.set(item.code,
|
|
743
|
+
mapping.set(item.code, {
|
|
744
|
+
...item,
|
|
788
745
|
id: item.code,
|
|
789
746
|
name: getLabelForLocal$2(item, locale)
|
|
790
|
-
})
|
|
747
|
+
});
|
|
791
748
|
});
|
|
792
749
|
return mapping;
|
|
793
750
|
}, [data, locale]);
|
|
@@ -813,15 +770,17 @@ const SelectIndustryInner = _ref => {
|
|
|
813
770
|
onChange(resolved);
|
|
814
771
|
}
|
|
815
772
|
}, [value, flatMapping, single, onChange]);
|
|
816
|
-
const handleSearch = (searchText,
|
|
817
|
-
|
|
773
|
+
const handleSearch = (searchText, {
|
|
774
|
+
mapping
|
|
775
|
+
}) => {
|
|
818
776
|
if (!searchText) return Array.from(mapping.values());
|
|
819
777
|
const keyword = searchText.toLowerCase();
|
|
820
778
|
return Array.from(mapping.values()).filter(item => {
|
|
821
779
|
return item.chName && item.chName.toLowerCase().includes(keyword) || item.enName && item.enName.toLowerCase().includes(keyword) || item.pinyin && item.pinyin.toLowerCase().includes(keyword) || item.spelling && item.spelling.toLowerCase().includes(keyword);
|
|
822
780
|
});
|
|
823
781
|
};
|
|
824
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader,
|
|
782
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, {
|
|
783
|
+
...props,
|
|
825
784
|
value: normalizedValue,
|
|
826
785
|
onChange: onChange,
|
|
827
786
|
single: single,
|
|
@@ -833,21 +792,20 @@ const SelectIndustryInner = _ref => {
|
|
|
833
792
|
isPopup: isPopup,
|
|
834
793
|
overlayWidth: overlayWidth,
|
|
835
794
|
menuItemWidth: 200,
|
|
836
|
-
style:
|
|
837
|
-
width: overlayWidth
|
|
838
|
-
|
|
795
|
+
style: {
|
|
796
|
+
width: overlayWidth,
|
|
797
|
+
...props.style
|
|
798
|
+
},
|
|
839
799
|
options: options,
|
|
840
800
|
valueKey: "id",
|
|
841
801
|
labelKey: "name",
|
|
842
802
|
onSearch: onSearch || handleSearch
|
|
843
|
-
})
|
|
803
|
+
});
|
|
844
804
|
};
|
|
845
805
|
const SelectIndustry = withLocale(SelectIndustryInner);
|
|
846
806
|
SelectIndustry.defaultData = defaultIndustryData;
|
|
847
807
|
SelectIndustry.Enum = IndustryEnum;
|
|
848
808
|
|
|
849
|
-
const _excluded$1 = ["data", "name", "names", "children", "displayParent"],
|
|
850
|
-
_excluded2$1 = ["displayParent"];
|
|
851
809
|
const getLabelForLocal$1 = (item, locale) => {
|
|
852
810
|
if (locale === 'en-US') {
|
|
853
811
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -864,61 +822,69 @@ const addressDefaultApi = {
|
|
|
864
822
|
ttl: 1000 * 60 * 60 * 24,
|
|
865
823
|
// 24小时
|
|
866
824
|
loader: () => {
|
|
867
|
-
return Promise.resolve().then(function () { return require('./city-
|
|
825
|
+
return Promise.resolve().then(function () { return require('./city-8aa3edf6.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
868
826
|
}
|
|
869
827
|
};
|
|
870
828
|
|
|
871
829
|
/**
|
|
872
830
|
* 地址枚举显示组件
|
|
873
831
|
*/
|
|
874
|
-
const AddressEnumInner = reactFetch.withFetch(
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
832
|
+
const AddressEnumInner = reactFetch.withFetch(({
|
|
833
|
+
data,
|
|
834
|
+
name,
|
|
835
|
+
names,
|
|
836
|
+
children,
|
|
837
|
+
displayParent,
|
|
838
|
+
...props
|
|
839
|
+
}) => {
|
|
840
|
+
const {
|
|
841
|
+
locale
|
|
842
|
+
} = reactIntl.useIntl();
|
|
883
843
|
const addressApi = react.useMemo(() => createAddressApi(data), [data]);
|
|
884
844
|
const formatCityData = cityData => {
|
|
885
|
-
const
|
|
886
|
-
|
|
845
|
+
const {
|
|
846
|
+
city,
|
|
847
|
+
parent
|
|
848
|
+
} = cityData;
|
|
887
849
|
if (!city) {
|
|
888
850
|
return '';
|
|
889
851
|
}
|
|
890
852
|
if (displayParent && parent) {
|
|
891
|
-
return getLabelForLocal$1(parent, locale)
|
|
853
|
+
return `${getLabelForLocal$1(parent, locale)}·${getLabelForLocal$1(city, locale)}`;
|
|
892
854
|
}
|
|
893
855
|
return getLabelForLocal$1(city, locale);
|
|
894
856
|
};
|
|
895
|
-
if (names
|
|
857
|
+
if (names?.length) {
|
|
896
858
|
const outputs = names.map(code => addressApi.getCity(code));
|
|
897
859
|
const labels = outputs.map(formatCityData).filter(Boolean);
|
|
898
860
|
if (children) {
|
|
899
|
-
return children(outputs,
|
|
861
|
+
return children(outputs, {
|
|
900
862
|
displayParent,
|
|
901
863
|
locale,
|
|
902
864
|
getLabelForLocal: getLabelForLocal$1,
|
|
903
865
|
names,
|
|
904
|
-
labels
|
|
905
|
-
|
|
866
|
+
labels,
|
|
867
|
+
...props
|
|
868
|
+
});
|
|
906
869
|
}
|
|
907
870
|
return labels.toString();
|
|
908
871
|
}
|
|
909
872
|
|
|
910
873
|
// 获取城市数据
|
|
911
874
|
const cityData = addressApi.getCity(name);
|
|
912
|
-
const
|
|
913
|
-
|
|
875
|
+
const {
|
|
876
|
+
city,
|
|
877
|
+
parent
|
|
878
|
+
} = cityData;
|
|
914
879
|
|
|
915
880
|
// 如果提供了自定义渲染函数
|
|
916
881
|
if (children) {
|
|
917
|
-
return children(cityData,
|
|
882
|
+
return children(cityData, {
|
|
918
883
|
displayParent,
|
|
919
884
|
locale,
|
|
920
|
-
getLabelForLocal: getLabelForLocal$1
|
|
921
|
-
|
|
885
|
+
getLabelForLocal: getLabelForLocal$1,
|
|
886
|
+
...props
|
|
887
|
+
});
|
|
922
888
|
}
|
|
923
889
|
|
|
924
890
|
// 默认渲染逻辑
|
|
@@ -926,17 +892,20 @@ const AddressEnumInner = reactFetch.withFetch(_ref => {
|
|
|
926
892
|
return '';
|
|
927
893
|
}
|
|
928
894
|
if (displayParent && parent) {
|
|
929
|
-
return getLabelForLocal$1(parent, locale)
|
|
895
|
+
return `${getLabelForLocal$1(parent, locale)}·${getLabelForLocal$1(city, locale)}`;
|
|
930
896
|
}
|
|
931
897
|
return getLabelForLocal$1(city, locale);
|
|
932
898
|
});
|
|
933
899
|
const AddressEnum = withLocale(props => {
|
|
934
|
-
const
|
|
935
|
-
displayParent =
|
|
936
|
-
restProps
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
900
|
+
const {
|
|
901
|
+
displayParent = false,
|
|
902
|
+
...restProps
|
|
903
|
+
} = props;
|
|
904
|
+
return /*#__PURE__*/jsxRuntime.jsx(AddressEnumInner, {
|
|
905
|
+
...addressDefaultApi,
|
|
906
|
+
displayParent: displayParent,
|
|
907
|
+
...restProps
|
|
908
|
+
});
|
|
940
909
|
});
|
|
941
910
|
AddressEnum.addressDefaultApi = addressDefaultApi;
|
|
942
911
|
|
|
@@ -1022,8 +991,6 @@ var classnames = createCommonjsModule(function (module) {
|
|
|
1022
991
|
|
|
1023
992
|
var style = {"address":"kne-super-select-plus_MMoPf","is-popup":"kne-super-select-plus_bYKMf","title":"kne-super-select-plus_pKOHI","scroll-box":"kne-super-select-plus_MObpF","scroll-plus-box":"kne-super-select-plus_iKm8i","content":"kne-super-select-plus_BfCap","col-left":"kne-super-select-plus_BEChX","menu-list":"kne-super-select-plus_gXzFG","menu-item":"kne-super-select-plus_LasXn","col-right":"kne-super-select-plus_1jQmu","search-input":"kne-super-select-plus_YB45l","list":"kne-super-select-plus_Y-MIq","list-item":"kne-super-select-plus_6JEMZ","item-label":"kne-super-select-plus_nlduJ"};
|
|
1024
993
|
|
|
1025
|
-
const _excluded = ["value", "single", "onChange", "overlayWidth"],
|
|
1026
|
-
_excluded2 = ["single", "isPopup", "showChinaQuan", "showForeignQuan"];
|
|
1027
994
|
const getLabelForLocal = (item, locale) => {
|
|
1028
995
|
if (locale === 'en-US') {
|
|
1029
996
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -1031,12 +998,13 @@ const getLabelForLocal = (item, locale) => {
|
|
|
1031
998
|
return get__default["default"](item, 'name');
|
|
1032
999
|
};
|
|
1033
1000
|
const defaultCityData = () => {
|
|
1034
|
-
return Promise.resolve().then(function () { return require('./city-
|
|
1001
|
+
return Promise.resolve().then(function () { return require('./city-8aa3edf6.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
1035
1002
|
};
|
|
1036
|
-
const createAddressApi =
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1003
|
+
const createAddressApi = ({
|
|
1004
|
+
city,
|
|
1005
|
+
province,
|
|
1006
|
+
country
|
|
1007
|
+
}) => {
|
|
1040
1008
|
const getSearchList = memoize__default["default"](() => {
|
|
1041
1009
|
const list = [];
|
|
1042
1010
|
['gangaotai', 'municipality'].forEach(name => {
|
|
@@ -1078,24 +1046,25 @@ const createAddressApi = _ref => {
|
|
|
1078
1046
|
}, country.list[id])).filter(item => item.code);
|
|
1079
1047
|
}),
|
|
1080
1048
|
getList: memoize__default["default"]((pid, options) => {
|
|
1081
|
-
const
|
|
1082
|
-
showChinaQuan
|
|
1083
|
-
showForeignQuan
|
|
1049
|
+
const {
|
|
1050
|
+
showChinaQuan,
|
|
1051
|
+
showForeignQuan
|
|
1052
|
+
} = Object.assign({}, options);
|
|
1084
1053
|
if (pid === 'gangaotai') {
|
|
1085
1054
|
return (province.relations['gangaotai'] || []).map(id => city.list[id]).filter(Boolean);
|
|
1086
1055
|
}
|
|
1087
1056
|
const current = Object.assign({}, city.list[pid]);
|
|
1088
1057
|
if ((province.relations.municipality || []).indexOf(pid) > -1) {
|
|
1089
|
-
current.name =
|
|
1058
|
+
current.name = `${showChinaQuan ? '全' : ''}${current.name}`;
|
|
1090
1059
|
return [current];
|
|
1091
1060
|
}
|
|
1092
1061
|
const list = (city.relations[pid] || []).map(id => city.list[id]).filter(Boolean);
|
|
1093
1062
|
if ((province.relations.provinces || []).indexOf(pid) > -1 && showChinaQuan) {
|
|
1094
|
-
current.name =
|
|
1063
|
+
current.name = `全${current.name}`;
|
|
1095
1064
|
list.splice(0, 0, current);
|
|
1096
1065
|
}
|
|
1097
1066
|
if ((country.relations.continents || []).indexOf(pid) > -1 && showForeignQuan) {
|
|
1098
|
-
current.name =
|
|
1067
|
+
current.name = `全${current.name}`;
|
|
1099
1068
|
list.splice(0, 0, current);
|
|
1100
1069
|
}
|
|
1101
1070
|
return list;
|
|
@@ -1135,14 +1104,16 @@ const createAddressApi = _ref => {
|
|
|
1135
1104
|
});
|
|
1136
1105
|
}).map(item => {
|
|
1137
1106
|
const parent = item.parentCode ? city.list[item.parentCode] : null;
|
|
1138
|
-
return
|
|
1139
|
-
label: parent ? parent.name
|
|
1140
|
-
value: item.code
|
|
1141
|
-
|
|
1107
|
+
return {
|
|
1108
|
+
label: parent ? `${parent.name}·${item.name}` : item.name,
|
|
1109
|
+
value: item.code,
|
|
1110
|
+
...item
|
|
1111
|
+
};
|
|
1142
1112
|
});
|
|
1143
1113
|
}),
|
|
1144
1114
|
getCityList: memoize__default["default"](() => {
|
|
1145
|
-
return Object.values(city.list).map(item =>
|
|
1115
|
+
return Object.values(city.list).map(item => ({
|
|
1116
|
+
...item,
|
|
1146
1117
|
value: item.code,
|
|
1147
1118
|
label: item.name
|
|
1148
1119
|
}));
|
|
@@ -1150,22 +1121,18 @@ const createAddressApi = _ref => {
|
|
|
1150
1121
|
};
|
|
1151
1122
|
return apis;
|
|
1152
1123
|
};
|
|
1153
|
-
const AddressInner =
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
setMenuKey = _useState2[1];
|
|
1166
|
-
const _useState3 = react.useState(null),
|
|
1167
|
-
cityData = _useState3[0],
|
|
1168
|
-
setCityData = _useState3[1];
|
|
1124
|
+
const AddressInner = ({
|
|
1125
|
+
value,
|
|
1126
|
+
setValue,
|
|
1127
|
+
props
|
|
1128
|
+
}) => {
|
|
1129
|
+
const {
|
|
1130
|
+
locale,
|
|
1131
|
+
formatMessage
|
|
1132
|
+
} = reactIntl.useIntl();
|
|
1133
|
+
const [searchText, setSearchText] = react.useState('');
|
|
1134
|
+
const [menuKey, setMenuKey] = react.useState('2');
|
|
1135
|
+
const [cityData, setCityData] = react.useState(null);
|
|
1169
1136
|
react.useEffect(() => {
|
|
1170
1137
|
defaultCityData().then(result => {
|
|
1171
1138
|
setCityData(result);
|
|
@@ -1175,20 +1142,21 @@ const AddressInner = _ref2 => {
|
|
|
1175
1142
|
if (!cityData) return null;
|
|
1176
1143
|
return createAddressApi(cityData);
|
|
1177
1144
|
}, [cityData]);
|
|
1178
|
-
const
|
|
1179
|
-
getCity
|
|
1180
|
-
getChinaCities
|
|
1181
|
-
getCountries
|
|
1182
|
-
getList
|
|
1183
|
-
searchCities
|
|
1145
|
+
const {
|
|
1146
|
+
getCity,
|
|
1147
|
+
getChinaCities,
|
|
1148
|
+
getCountries,
|
|
1149
|
+
getList,
|
|
1150
|
+
searchCities
|
|
1151
|
+
} = addressApi || {};
|
|
1184
1152
|
const onSelect = react.useCallback(code => {
|
|
1185
|
-
|
|
1186
|
-
const cityInfo = cityData == null || (_cityData$city = cityData.city) == null || (_cityData$city = _cityData$city.list) == null ? void 0 : _cityData$city[code];
|
|
1153
|
+
const cityInfo = cityData?.city?.list?.[code];
|
|
1187
1154
|
if (!cityInfo) return;
|
|
1188
|
-
const item =
|
|
1155
|
+
const item = {
|
|
1189
1156
|
value: code,
|
|
1190
|
-
label: cityInfo.name
|
|
1191
|
-
|
|
1157
|
+
label: cityInfo.name,
|
|
1158
|
+
...cityInfo
|
|
1159
|
+
};
|
|
1192
1160
|
if (props.single) {
|
|
1193
1161
|
setValue([item]);
|
|
1194
1162
|
return;
|
|
@@ -1228,7 +1196,7 @@ const AddressInner = _ref2 => {
|
|
|
1228
1196
|
})
|
|
1229
1197
|
})
|
|
1230
1198
|
});
|
|
1231
|
-
const currentCity = getCity
|
|
1199
|
+
const currentCity = getCity?.(menuKey);
|
|
1232
1200
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1233
1201
|
className: classnames(style['address'], {
|
|
1234
1202
|
[style['is-popup']]: props.isPopup
|
|
@@ -1313,7 +1281,7 @@ const AddressInner = _ref2 => {
|
|
|
1313
1281
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Divider, {
|
|
1314
1282
|
className: style['title'],
|
|
1315
1283
|
orientation: "left",
|
|
1316
|
-
children: currentCity
|
|
1284
|
+
children: currentCity?.city ? getLabelForLocal(currentCity.city, locale) : ''
|
|
1317
1285
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1318
1286
|
className: style['scroll-box'],
|
|
1319
1287
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
|
|
@@ -1336,17 +1304,17 @@ const AddressInner = _ref2 => {
|
|
|
1336
1304
|
});
|
|
1337
1305
|
};
|
|
1338
1306
|
const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
1339
|
-
const
|
|
1340
|
-
formatMessage
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1307
|
+
const {
|
|
1308
|
+
formatMessage
|
|
1309
|
+
} = reactIntl.useIntl();
|
|
1310
|
+
const {
|
|
1311
|
+
value,
|
|
1312
|
+
single,
|
|
1313
|
+
onChange,
|
|
1314
|
+
overlayWidth = 500,
|
|
1315
|
+
...restProps
|
|
1316
|
+
} = props;
|
|
1317
|
+
const [cityData, setCityData] = react.useState(null);
|
|
1350
1318
|
react.useEffect(() => {
|
|
1351
1319
|
defaultCityData().then(setCityData);
|
|
1352
1320
|
}, []);
|
|
@@ -1369,9 +1337,9 @@ const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
1369
1337
|
onChange(resolved);
|
|
1370
1338
|
}
|
|
1371
1339
|
}, [value, addressApi, single, onChange]);
|
|
1372
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectInput,
|
|
1373
|
-
ref: ref
|
|
1374
|
-
|
|
1340
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectInput, {
|
|
1341
|
+
ref: ref,
|
|
1342
|
+
...restProps,
|
|
1375
1343
|
single: single,
|
|
1376
1344
|
value: normalizedValue,
|
|
1377
1345
|
onChange: onChange,
|
|
@@ -1382,32 +1350,32 @@ const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
1382
1350
|
defaultMessage: '请选择城市'
|
|
1383
1351
|
}),
|
|
1384
1352
|
children: contextProps => {
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1353
|
+
const {
|
|
1354
|
+
value: currentValue,
|
|
1355
|
+
setValue
|
|
1356
|
+
} = contextProps;
|
|
1387
1357
|
return /*#__PURE__*/jsxRuntime.jsx(AddressInner, {
|
|
1388
1358
|
value: currentValue,
|
|
1389
1359
|
setValue: setValue,
|
|
1390
1360
|
props: props
|
|
1391
1361
|
});
|
|
1392
1362
|
}
|
|
1393
|
-
})
|
|
1363
|
+
});
|
|
1394
1364
|
});
|
|
1395
|
-
const SelectAddress = withLocale(
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
showForeignQuan = _ref4$showForeignQuan === void 0 ? false : _ref4$showForeignQuan,
|
|
1404
|
-
props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
1405
|
-
return /*#__PURE__*/jsxRuntime.jsx(SelectAddressInner, _extends({
|
|
1365
|
+
const SelectAddress = withLocale(({
|
|
1366
|
+
single = false,
|
|
1367
|
+
isPopup = true,
|
|
1368
|
+
showChinaQuan = false,
|
|
1369
|
+
showForeignQuan = false,
|
|
1370
|
+
...props
|
|
1371
|
+
}) => {
|
|
1372
|
+
return /*#__PURE__*/jsxRuntime.jsx(SelectAddressInner, {
|
|
1406
1373
|
single: single,
|
|
1407
1374
|
isPopup: isPopup,
|
|
1408
1375
|
showChinaQuan: showChinaQuan,
|
|
1409
|
-
showForeignQuan: showForeignQuan
|
|
1410
|
-
|
|
1376
|
+
showForeignQuan: showForeignQuan,
|
|
1377
|
+
...props
|
|
1378
|
+
});
|
|
1411
1379
|
}, 'SelectAddress');
|
|
1412
1380
|
SelectAddress.defaultData = defaultCityData;
|
|
1413
1381
|
SelectAddress.createAddressApi = createAddressApi;
|