@kne/super-select-plus 0.1.2 → 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 +311 -338
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +6 -2
- package/dist/index.modern.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,
|
|
@@ -666,15 +623,17 @@ const SelectFunctionInner = _ref => {
|
|
|
666
623
|
defaultMessage: '请选择职能'
|
|
667
624
|
}),
|
|
668
625
|
isPopup: isPopup,
|
|
626
|
+
overlayWidth: overlayWidth,
|
|
669
627
|
menuItemWidth: 200,
|
|
670
|
-
style:
|
|
671
|
-
width: overlayWidth
|
|
672
|
-
|
|
628
|
+
style: {
|
|
629
|
+
width: overlayWidth,
|
|
630
|
+
...props.style
|
|
631
|
+
},
|
|
673
632
|
options: options,
|
|
674
633
|
valueKey: "id",
|
|
675
634
|
labelKey: "name",
|
|
676
635
|
onSearch: onSearch || handleSearch
|
|
677
|
-
})
|
|
636
|
+
});
|
|
678
637
|
};
|
|
679
638
|
const SelectFunction = withLocale(SelectFunctionInner);
|
|
680
639
|
SelectFunction.defaultData = defaultFunctionData;
|
|
@@ -699,7 +658,7 @@ const defaultIndustryApi = {
|
|
|
699
658
|
ttl: 1000 * 60 * 60 * 24,
|
|
700
659
|
// 24小时
|
|
701
660
|
loader: () => {
|
|
702
|
-
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);
|
|
703
662
|
}
|
|
704
663
|
};
|
|
705
664
|
|
|
@@ -713,9 +672,8 @@ const IndustryEnum = createEnumComponent({
|
|
|
713
672
|
defaultApi: defaultIndustryApi
|
|
714
673
|
});
|
|
715
674
|
|
|
716
|
-
const _excluded$2 = ["value", "onChange", "single", "placeholder", "isPopup", "overlayWidth", "apis", "onSearch"];
|
|
717
675
|
const defaultIndustryData = () => {
|
|
718
|
-
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);
|
|
719
677
|
};
|
|
720
678
|
const transformToCascaderData = (data, locale) => {
|
|
721
679
|
// 过滤掉"全部行业"
|
|
@@ -724,11 +682,12 @@ const transformToCascaderData = (data, locale) => {
|
|
|
724
682
|
// 创建映射表
|
|
725
683
|
const mapping = new Map();
|
|
726
684
|
filteredData.forEach(item => {
|
|
727
|
-
mapping.set(item.code,
|
|
685
|
+
mapping.set(item.code, {
|
|
686
|
+
...item,
|
|
728
687
|
id: item.code,
|
|
729
688
|
name: getLabelForLocal$2(item, locale),
|
|
730
689
|
children: []
|
|
731
|
-
})
|
|
690
|
+
});
|
|
732
691
|
});
|
|
733
692
|
|
|
734
693
|
// 构建嵌套结构
|
|
@@ -756,24 +715,22 @@ const transformToCascaderData = (data, locale) => {
|
|
|
756
715
|
cleanEmptyChildren(roots);
|
|
757
716
|
return roots;
|
|
758
717
|
};
|
|
759
|
-
const SelectIndustryInner =
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
const
|
|
775
|
-
data = _useState[0],
|
|
776
|
-
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([]);
|
|
777
734
|
react.useEffect(() => {
|
|
778
735
|
defaultIndustryData().then(result => {
|
|
779
736
|
setData(result.data || result);
|
|
@@ -783,10 +740,11 @@ const SelectIndustryInner = _ref => {
|
|
|
783
740
|
const flatMapping = react.useMemo(() => {
|
|
784
741
|
const mapping = new Map();
|
|
785
742
|
data.filter(item => item.code !== '000').forEach(item => {
|
|
786
|
-
mapping.set(item.code,
|
|
743
|
+
mapping.set(item.code, {
|
|
744
|
+
...item,
|
|
787
745
|
id: item.code,
|
|
788
746
|
name: getLabelForLocal$2(item, locale)
|
|
789
|
-
})
|
|
747
|
+
});
|
|
790
748
|
});
|
|
791
749
|
return mapping;
|
|
792
750
|
}, [data, locale]);
|
|
@@ -812,15 +770,17 @@ const SelectIndustryInner = _ref => {
|
|
|
812
770
|
onChange(resolved);
|
|
813
771
|
}
|
|
814
772
|
}, [value, flatMapping, single, onChange]);
|
|
815
|
-
const handleSearch = (searchText,
|
|
816
|
-
|
|
773
|
+
const handleSearch = (searchText, {
|
|
774
|
+
mapping
|
|
775
|
+
}) => {
|
|
817
776
|
if (!searchText) return Array.from(mapping.values());
|
|
818
777
|
const keyword = searchText.toLowerCase();
|
|
819
778
|
return Array.from(mapping.values()).filter(item => {
|
|
820
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);
|
|
821
780
|
});
|
|
822
781
|
};
|
|
823
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader,
|
|
782
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, {
|
|
783
|
+
...props,
|
|
824
784
|
value: normalizedValue,
|
|
825
785
|
onChange: onChange,
|
|
826
786
|
single: single,
|
|
@@ -830,22 +790,22 @@ const SelectIndustryInner = _ref => {
|
|
|
830
790
|
defaultMessage: '请选择行业'
|
|
831
791
|
}),
|
|
832
792
|
isPopup: isPopup,
|
|
793
|
+
overlayWidth: overlayWidth,
|
|
833
794
|
menuItemWidth: 200,
|
|
834
|
-
style:
|
|
835
|
-
width: overlayWidth
|
|
836
|
-
|
|
795
|
+
style: {
|
|
796
|
+
width: overlayWidth,
|
|
797
|
+
...props.style
|
|
798
|
+
},
|
|
837
799
|
options: options,
|
|
838
800
|
valueKey: "id",
|
|
839
801
|
labelKey: "name",
|
|
840
802
|
onSearch: onSearch || handleSearch
|
|
841
|
-
})
|
|
803
|
+
});
|
|
842
804
|
};
|
|
843
805
|
const SelectIndustry = withLocale(SelectIndustryInner);
|
|
844
806
|
SelectIndustry.defaultData = defaultIndustryData;
|
|
845
807
|
SelectIndustry.Enum = IndustryEnum;
|
|
846
808
|
|
|
847
|
-
const _excluded$1 = ["data", "name", "names", "children", "displayParent"],
|
|
848
|
-
_excluded2$1 = ["displayParent"];
|
|
849
809
|
const getLabelForLocal$1 = (item, locale) => {
|
|
850
810
|
if (locale === 'en-US') {
|
|
851
811
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -862,61 +822,69 @@ const addressDefaultApi = {
|
|
|
862
822
|
ttl: 1000 * 60 * 60 * 24,
|
|
863
823
|
// 24小时
|
|
864
824
|
loader: () => {
|
|
865
|
-
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);
|
|
866
826
|
}
|
|
867
827
|
};
|
|
868
828
|
|
|
869
829
|
/**
|
|
870
830
|
* 地址枚举显示组件
|
|
871
831
|
*/
|
|
872
|
-
const AddressEnumInner = reactFetch.withFetch(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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();
|
|
881
843
|
const addressApi = react.useMemo(() => createAddressApi(data), [data]);
|
|
882
844
|
const formatCityData = cityData => {
|
|
883
|
-
const
|
|
884
|
-
|
|
845
|
+
const {
|
|
846
|
+
city,
|
|
847
|
+
parent
|
|
848
|
+
} = cityData;
|
|
885
849
|
if (!city) {
|
|
886
850
|
return '';
|
|
887
851
|
}
|
|
888
852
|
if (displayParent && parent) {
|
|
889
|
-
return getLabelForLocal$1(parent, locale)
|
|
853
|
+
return `${getLabelForLocal$1(parent, locale)}·${getLabelForLocal$1(city, locale)}`;
|
|
890
854
|
}
|
|
891
855
|
return getLabelForLocal$1(city, locale);
|
|
892
856
|
};
|
|
893
|
-
if (names
|
|
857
|
+
if (names?.length) {
|
|
894
858
|
const outputs = names.map(code => addressApi.getCity(code));
|
|
895
859
|
const labels = outputs.map(formatCityData).filter(Boolean);
|
|
896
860
|
if (children) {
|
|
897
|
-
return children(outputs,
|
|
861
|
+
return children(outputs, {
|
|
898
862
|
displayParent,
|
|
899
863
|
locale,
|
|
900
864
|
getLabelForLocal: getLabelForLocal$1,
|
|
901
865
|
names,
|
|
902
|
-
labels
|
|
903
|
-
|
|
866
|
+
labels,
|
|
867
|
+
...props
|
|
868
|
+
});
|
|
904
869
|
}
|
|
905
870
|
return labels.toString();
|
|
906
871
|
}
|
|
907
872
|
|
|
908
873
|
// 获取城市数据
|
|
909
874
|
const cityData = addressApi.getCity(name);
|
|
910
|
-
const
|
|
911
|
-
|
|
875
|
+
const {
|
|
876
|
+
city,
|
|
877
|
+
parent
|
|
878
|
+
} = cityData;
|
|
912
879
|
|
|
913
880
|
// 如果提供了自定义渲染函数
|
|
914
881
|
if (children) {
|
|
915
|
-
return children(cityData,
|
|
882
|
+
return children(cityData, {
|
|
916
883
|
displayParent,
|
|
917
884
|
locale,
|
|
918
|
-
getLabelForLocal: getLabelForLocal$1
|
|
919
|
-
|
|
885
|
+
getLabelForLocal: getLabelForLocal$1,
|
|
886
|
+
...props
|
|
887
|
+
});
|
|
920
888
|
}
|
|
921
889
|
|
|
922
890
|
// 默认渲染逻辑
|
|
@@ -924,17 +892,20 @@ const AddressEnumInner = reactFetch.withFetch(_ref => {
|
|
|
924
892
|
return '';
|
|
925
893
|
}
|
|
926
894
|
if (displayParent && parent) {
|
|
927
|
-
return getLabelForLocal$1(parent, locale)
|
|
895
|
+
return `${getLabelForLocal$1(parent, locale)}·${getLabelForLocal$1(city, locale)}`;
|
|
928
896
|
}
|
|
929
897
|
return getLabelForLocal$1(city, locale);
|
|
930
898
|
});
|
|
931
899
|
const AddressEnum = withLocale(props => {
|
|
932
|
-
const
|
|
933
|
-
displayParent =
|
|
934
|
-
restProps
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
900
|
+
const {
|
|
901
|
+
displayParent = false,
|
|
902
|
+
...restProps
|
|
903
|
+
} = props;
|
|
904
|
+
return /*#__PURE__*/jsxRuntime.jsx(AddressEnumInner, {
|
|
905
|
+
...addressDefaultApi,
|
|
906
|
+
displayParent: displayParent,
|
|
907
|
+
...restProps
|
|
908
|
+
});
|
|
938
909
|
});
|
|
939
910
|
AddressEnum.addressDefaultApi = addressDefaultApi;
|
|
940
911
|
|
|
@@ -1020,8 +991,6 @@ var classnames = createCommonjsModule(function (module) {
|
|
|
1020
991
|
|
|
1021
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"};
|
|
1022
993
|
|
|
1023
|
-
const _excluded = ["value", "single", "onChange"],
|
|
1024
|
-
_excluded2 = ["single", "isPopup", "showChinaQuan", "showForeignQuan"];
|
|
1025
994
|
const getLabelForLocal = (item, locale) => {
|
|
1026
995
|
if (locale === 'en-US') {
|
|
1027
996
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -1029,12 +998,13 @@ const getLabelForLocal = (item, locale) => {
|
|
|
1029
998
|
return get__default["default"](item, 'name');
|
|
1030
999
|
};
|
|
1031
1000
|
const defaultCityData = () => {
|
|
1032
|
-
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);
|
|
1033
1002
|
};
|
|
1034
|
-
const createAddressApi =
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1003
|
+
const createAddressApi = ({
|
|
1004
|
+
city,
|
|
1005
|
+
province,
|
|
1006
|
+
country
|
|
1007
|
+
}) => {
|
|
1038
1008
|
const getSearchList = memoize__default["default"](() => {
|
|
1039
1009
|
const list = [];
|
|
1040
1010
|
['gangaotai', 'municipality'].forEach(name => {
|
|
@@ -1076,24 +1046,25 @@ const createAddressApi = _ref => {
|
|
|
1076
1046
|
}, country.list[id])).filter(item => item.code);
|
|
1077
1047
|
}),
|
|
1078
1048
|
getList: memoize__default["default"]((pid, options) => {
|
|
1079
|
-
const
|
|
1080
|
-
showChinaQuan
|
|
1081
|
-
showForeignQuan
|
|
1049
|
+
const {
|
|
1050
|
+
showChinaQuan,
|
|
1051
|
+
showForeignQuan
|
|
1052
|
+
} = Object.assign({}, options);
|
|
1082
1053
|
if (pid === 'gangaotai') {
|
|
1083
1054
|
return (province.relations['gangaotai'] || []).map(id => city.list[id]).filter(Boolean);
|
|
1084
1055
|
}
|
|
1085
1056
|
const current = Object.assign({}, city.list[pid]);
|
|
1086
1057
|
if ((province.relations.municipality || []).indexOf(pid) > -1) {
|
|
1087
|
-
current.name =
|
|
1058
|
+
current.name = `${showChinaQuan ? '全' : ''}${current.name}`;
|
|
1088
1059
|
return [current];
|
|
1089
1060
|
}
|
|
1090
1061
|
const list = (city.relations[pid] || []).map(id => city.list[id]).filter(Boolean);
|
|
1091
1062
|
if ((province.relations.provinces || []).indexOf(pid) > -1 && showChinaQuan) {
|
|
1092
|
-
current.name =
|
|
1063
|
+
current.name = `全${current.name}`;
|
|
1093
1064
|
list.splice(0, 0, current);
|
|
1094
1065
|
}
|
|
1095
1066
|
if ((country.relations.continents || []).indexOf(pid) > -1 && showForeignQuan) {
|
|
1096
|
-
current.name =
|
|
1067
|
+
current.name = `全${current.name}`;
|
|
1097
1068
|
list.splice(0, 0, current);
|
|
1098
1069
|
}
|
|
1099
1070
|
return list;
|
|
@@ -1133,14 +1104,16 @@ const createAddressApi = _ref => {
|
|
|
1133
1104
|
});
|
|
1134
1105
|
}).map(item => {
|
|
1135
1106
|
const parent = item.parentCode ? city.list[item.parentCode] : null;
|
|
1136
|
-
return
|
|
1137
|
-
label: parent ? parent.name
|
|
1138
|
-
value: item.code
|
|
1139
|
-
|
|
1107
|
+
return {
|
|
1108
|
+
label: parent ? `${parent.name}·${item.name}` : item.name,
|
|
1109
|
+
value: item.code,
|
|
1110
|
+
...item
|
|
1111
|
+
};
|
|
1140
1112
|
});
|
|
1141
1113
|
}),
|
|
1142
1114
|
getCityList: memoize__default["default"](() => {
|
|
1143
|
-
return Object.values(city.list).map(item =>
|
|
1115
|
+
return Object.values(city.list).map(item => ({
|
|
1116
|
+
...item,
|
|
1144
1117
|
value: item.code,
|
|
1145
1118
|
label: item.name
|
|
1146
1119
|
}));
|
|
@@ -1148,22 +1121,18 @@ const createAddressApi = _ref => {
|
|
|
1148
1121
|
};
|
|
1149
1122
|
return apis;
|
|
1150
1123
|
};
|
|
1151
|
-
const AddressInner =
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
setMenuKey = _useState2[1];
|
|
1164
|
-
const _useState3 = react.useState(null),
|
|
1165
|
-
cityData = _useState3[0],
|
|
1166
|
-
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);
|
|
1167
1136
|
react.useEffect(() => {
|
|
1168
1137
|
defaultCityData().then(result => {
|
|
1169
1138
|
setCityData(result);
|
|
@@ -1173,20 +1142,21 @@ const AddressInner = _ref2 => {
|
|
|
1173
1142
|
if (!cityData) return null;
|
|
1174
1143
|
return createAddressApi(cityData);
|
|
1175
1144
|
}, [cityData]);
|
|
1176
|
-
const
|
|
1177
|
-
getCity
|
|
1178
|
-
getChinaCities
|
|
1179
|
-
getCountries
|
|
1180
|
-
getList
|
|
1181
|
-
searchCities
|
|
1145
|
+
const {
|
|
1146
|
+
getCity,
|
|
1147
|
+
getChinaCities,
|
|
1148
|
+
getCountries,
|
|
1149
|
+
getList,
|
|
1150
|
+
searchCities
|
|
1151
|
+
} = addressApi || {};
|
|
1182
1152
|
const onSelect = react.useCallback(code => {
|
|
1183
|
-
|
|
1184
|
-
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];
|
|
1185
1154
|
if (!cityInfo) return;
|
|
1186
|
-
const item =
|
|
1155
|
+
const item = {
|
|
1187
1156
|
value: code,
|
|
1188
|
-
label: cityInfo.name
|
|
1189
|
-
|
|
1157
|
+
label: cityInfo.name,
|
|
1158
|
+
...cityInfo
|
|
1159
|
+
};
|
|
1190
1160
|
if (props.single) {
|
|
1191
1161
|
setValue([item]);
|
|
1192
1162
|
return;
|
|
@@ -1226,7 +1196,7 @@ const AddressInner = _ref2 => {
|
|
|
1226
1196
|
})
|
|
1227
1197
|
})
|
|
1228
1198
|
});
|
|
1229
|
-
const currentCity = getCity
|
|
1199
|
+
const currentCity = getCity?.(menuKey);
|
|
1230
1200
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1231
1201
|
className: classnames(style['address'], {
|
|
1232
1202
|
[style['is-popup']]: props.isPopup
|
|
@@ -1311,7 +1281,7 @@ const AddressInner = _ref2 => {
|
|
|
1311
1281
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Divider, {
|
|
1312
1282
|
className: style['title'],
|
|
1313
1283
|
orientation: "left",
|
|
1314
|
-
children: currentCity
|
|
1284
|
+
children: currentCity?.city ? getLabelForLocal(currentCity.city, locale) : ''
|
|
1315
1285
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1316
1286
|
className: style['scroll-box'],
|
|
1317
1287
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
|
|
@@ -1334,15 +1304,17 @@ const AddressInner = _ref2 => {
|
|
|
1334
1304
|
});
|
|
1335
1305
|
};
|
|
1336
1306
|
const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
1337
|
-
const
|
|
1338
|
-
formatMessage
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
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);
|
|
1346
1318
|
react.useEffect(() => {
|
|
1347
1319
|
defaultCityData().then(setCityData);
|
|
1348
1320
|
}, []);
|
|
@@ -1365,44 +1337,45 @@ const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
1365
1337
|
onChange(resolved);
|
|
1366
1338
|
}
|
|
1367
1339
|
}, [value, addressApi, single, onChange]);
|
|
1368
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectInput,
|
|
1369
|
-
ref: ref
|
|
1370
|
-
|
|
1340
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectInput, {
|
|
1341
|
+
ref: ref,
|
|
1342
|
+
...restProps,
|
|
1371
1343
|
single: single,
|
|
1372
1344
|
value: normalizedValue,
|
|
1373
1345
|
onChange: onChange,
|
|
1346
|
+
overlayWidth: overlayWidth,
|
|
1374
1347
|
placeholder: restProps.placeholder || formatMessage({
|
|
1375
1348
|
id: 'addressPlaceholder'
|
|
1376
1349
|
}, {
|
|
1377
1350
|
defaultMessage: '请选择城市'
|
|
1378
1351
|
}),
|
|
1379
1352
|
children: contextProps => {
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1353
|
+
const {
|
|
1354
|
+
value: currentValue,
|
|
1355
|
+
setValue
|
|
1356
|
+
} = contextProps;
|
|
1382
1357
|
return /*#__PURE__*/jsxRuntime.jsx(AddressInner, {
|
|
1383
1358
|
value: currentValue,
|
|
1384
1359
|
setValue: setValue,
|
|
1385
1360
|
props: props
|
|
1386
1361
|
});
|
|
1387
1362
|
}
|
|
1388
|
-
})
|
|
1363
|
+
});
|
|
1389
1364
|
});
|
|
1390
|
-
const SelectAddress = withLocale(
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
showForeignQuan = _ref4$showForeignQuan === void 0 ? false : _ref4$showForeignQuan,
|
|
1399
|
-
props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
1400
|
-
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, {
|
|
1401
1373
|
single: single,
|
|
1402
1374
|
isPopup: isPopup,
|
|
1403
1375
|
showChinaQuan: showChinaQuan,
|
|
1404
|
-
showForeignQuan: showForeignQuan
|
|
1405
|
-
|
|
1376
|
+
showForeignQuan: showForeignQuan,
|
|
1377
|
+
...props
|
|
1378
|
+
});
|
|
1406
1379
|
}, 'SelectAddress');
|
|
1407
1380
|
SelectAddress.defaultData = defaultCityData;
|
|
1408
1381
|
SelectAddress.createAddressApi = createAddressApi;
|