@kne/super-select-plus 0.1.0 → 0.1.1
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/README.md +160 -20
- package/dist/{city-230db4c1.js → city-39702d3a.js} +1 -1
- package/dist/{city-230db4c1.js.map → city-39702d3a.js.map} +1 -1
- package/dist/{function-9db71e91.js → function-871311da.js} +1 -1
- package/dist/{function-9db71e91.js.map → function-871311da.js.map} +1 -1
- package/dist/index.css +32 -32
- package/dist/index.js +298 -232
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +92 -25
- package/dist/index.modern.js.map +1 -1
- package/dist/{industry-2e3bda15.js → industry-f570d549.js} +1 -1
- package/dist/{industry-2e3bda15.js.map → industry-f570d549.js.map} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,6 +18,25 @@ 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
|
+
|
|
21
40
|
const locale$1 = {
|
|
22
41
|
placeholder: '请选择',
|
|
23
42
|
searchPlaceholder: '搜索',
|
|
@@ -59,10 +78,63 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
59
78
|
namespace: 'super-select-plus'
|
|
60
79
|
});
|
|
61
80
|
|
|
81
|
+
const _excluded$4 = ["data", "name", "names", "type", "cache", "children", "getLabel", "dataFormat", "transformItem"];
|
|
62
82
|
const enumCache = new Map();
|
|
63
83
|
|
|
64
84
|
// 默认子组件渲染函数
|
|
65
|
-
const defaultChildren =
|
|
85
|
+
const defaultChildren = output => {
|
|
86
|
+
if (Array.isArray(output)) {
|
|
87
|
+
return output.map(item => get__default["default"](item, 'label', '')).filter(Boolean).toString();
|
|
88
|
+
}
|
|
89
|
+
return get__default["default"](output, 'label', '');
|
|
90
|
+
};
|
|
91
|
+
const getLabels = output => Array.isArray(output) ? output.map(item => get__default["default"](item, 'label', '')).filter(Boolean) : output ? [get__default["default"](output, 'label', '')].filter(Boolean) : [];
|
|
92
|
+
const resolveOutput = (mapping, name, names) => {
|
|
93
|
+
if (names) {
|
|
94
|
+
return names.map(code => mapping.get(code));
|
|
95
|
+
}
|
|
96
|
+
return mapping.get(name);
|
|
97
|
+
};
|
|
98
|
+
const cacheOutput = (output, _ref) => {
|
|
99
|
+
let cacheKey = _ref.cacheKey,
|
|
100
|
+
type = _ref.type,
|
|
101
|
+
name = _ref.name,
|
|
102
|
+
names = _ref.names;
|
|
103
|
+
if (!cacheKey || !type) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (names) {
|
|
107
|
+
names.forEach((code, index) => {
|
|
108
|
+
const item = output[index];
|
|
109
|
+
if (item) {
|
|
110
|
+
enumCache.set(cacheKey + "_" + type + "_" + code, item);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (output) {
|
|
116
|
+
enumCache.set(cacheKey + "_" + type + "_" + name, output);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const getCachedOutput = _ref2 => {
|
|
120
|
+
var _enumCache$get;
|
|
121
|
+
let cacheKey = _ref2.cacheKey,
|
|
122
|
+
type = _ref2.type,
|
|
123
|
+
name = _ref2.name,
|
|
124
|
+
names = _ref2.names,
|
|
125
|
+
force = _ref2.force;
|
|
126
|
+
if (force) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (names != null && names.length) {
|
|
130
|
+
const items = names.map(code => enumCache.get(cacheKey + "_" + type + "_" + code));
|
|
131
|
+
return items.every(Boolean) ? items : null;
|
|
132
|
+
}
|
|
133
|
+
if (name == null) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return (_enumCache$get = enumCache.get(cacheKey + "_" + type + "_" + name)) != null ? _enumCache$get : null;
|
|
137
|
+
};
|
|
66
138
|
|
|
67
139
|
/**
|
|
68
140
|
* 默认获取标签函数
|
|
@@ -82,8 +154,7 @@ const defaultDataFormat = data => data.data || data;
|
|
|
82
154
|
/**
|
|
83
155
|
* 默认映射项转换函数
|
|
84
156
|
*/
|
|
85
|
-
const defaultTransformItem = (item, label) => ({
|
|
86
|
-
...item,
|
|
157
|
+
const defaultTransformItem = (item, label) => _extends({}, item, {
|
|
87
158
|
id: item.code,
|
|
88
159
|
label,
|
|
89
160
|
parentId: item.parentCode || null
|
|
@@ -92,21 +163,19 @@ const defaultTransformItem = (item, label) => ({
|
|
|
92
163
|
/**
|
|
93
164
|
* 内部枚举显示组件
|
|
94
165
|
*/
|
|
95
|
-
const EnumDisplayInner = reactFetch.withFetch(
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
type,
|
|
100
|
-
cache
|
|
101
|
-
children,
|
|
102
|
-
getLabel,
|
|
103
|
-
dataFormat,
|
|
104
|
-
transformItem,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
locale
|
|
109
|
-
} = reactIntl.useIntl();
|
|
166
|
+
const EnumDisplayInner = reactFetch.withFetch(_ref3 => {
|
|
167
|
+
let data = _ref3.data,
|
|
168
|
+
name = _ref3.name,
|
|
169
|
+
names = _ref3.names,
|
|
170
|
+
type = _ref3.type,
|
|
171
|
+
cacheKey = _ref3.cache,
|
|
172
|
+
children = _ref3.children,
|
|
173
|
+
getLabel = _ref3.getLabel,
|
|
174
|
+
dataFormat = _ref3.dataFormat,
|
|
175
|
+
transformItem = _ref3.transformItem,
|
|
176
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded$4);
|
|
177
|
+
const _useIntl = reactIntl.useIntl(),
|
|
178
|
+
locale = _useIntl.locale;
|
|
110
179
|
|
|
111
180
|
// 格式化数据
|
|
112
181
|
const formattedData = react.useMemo(() => dataFormat(data), [data, dataFormat]);
|
|
@@ -119,54 +188,63 @@ const EnumDisplayInner = reactFetch.withFetch(_ref => {
|
|
|
119
188
|
return [item.code, transformedItem];
|
|
120
189
|
}));
|
|
121
190
|
}, [formattedData, getLabel, locale, transformItem]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
enumCache.set(`${cacheKey}_${type}_${name}`, output);
|
|
129
|
-
}
|
|
130
|
-
return children(output, {
|
|
131
|
-
...props,
|
|
132
|
-
locale,
|
|
133
|
-
mapping
|
|
191
|
+
const output = react.useMemo(() => resolveOutput(mapping, name, names), [mapping, name, names]);
|
|
192
|
+
cacheOutput(output, {
|
|
193
|
+
cacheKey,
|
|
194
|
+
type,
|
|
195
|
+
name,
|
|
196
|
+
names
|
|
134
197
|
});
|
|
198
|
+
return children(output, _extends({}, props, {
|
|
199
|
+
locale,
|
|
200
|
+
mapping,
|
|
201
|
+
names,
|
|
202
|
+
labels: getLabels(output)
|
|
203
|
+
}));
|
|
135
204
|
});
|
|
136
205
|
|
|
137
206
|
/**
|
|
138
207
|
* 枚举显示组件
|
|
139
208
|
*/
|
|
140
209
|
const EnumDisplay = withLocale(props => {
|
|
141
|
-
|
|
142
|
-
|
|
210
|
+
const name = props.name,
|
|
211
|
+
names = props.names,
|
|
212
|
+
_props$type = props.type,
|
|
213
|
+
type = _props$type === void 0 ? 'default' : _props$type,
|
|
214
|
+
_props$cache = props.cache,
|
|
215
|
+
cacheKey = _props$cache === void 0 ? 'ENUM_DATA' : _props$cache,
|
|
216
|
+
_props$force = props.force,
|
|
217
|
+
force = _props$force === void 0 ? false : _props$force,
|
|
218
|
+
_props$getLabel = props.getLabel,
|
|
219
|
+
getLabel = _props$getLabel === void 0 ? defaultGetLabel : _props$getLabel,
|
|
220
|
+
_props$dataFormat = props.dataFormat,
|
|
221
|
+
dataFormat = _props$dataFormat === void 0 ? defaultDataFormat : _props$dataFormat,
|
|
222
|
+
_props$transformItem = props.transformItem,
|
|
223
|
+
transformItem = _props$transformItem === void 0 ? defaultTransformItem : _props$transformItem,
|
|
224
|
+
_props$children = props.children,
|
|
225
|
+
children = _props$children === void 0 ? defaultChildren : _props$children;
|
|
226
|
+
const cached = getCachedOutput({
|
|
227
|
+
cacheKey,
|
|
228
|
+
type,
|
|
143
229
|
name,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
dataFormat = defaultDataFormat,
|
|
149
|
-
transformItem = defaultTransformItem,
|
|
150
|
-
children = defaultChildren
|
|
151
|
-
} = props;
|
|
152
|
-
|
|
153
|
-
// 检查缓存
|
|
154
|
-
const key = `${cacheKey}_${type}_${name}`;
|
|
155
|
-
const cached = enumCache.get(key);
|
|
156
|
-
if (cached && !force) {
|
|
230
|
+
names,
|
|
231
|
+
force
|
|
232
|
+
});
|
|
233
|
+
if (cached) {
|
|
157
234
|
return children(cached, {
|
|
158
|
-
locale: props.locale
|
|
235
|
+
locale: props.locale,
|
|
236
|
+
names,
|
|
237
|
+
labels: getLabels(cached)
|
|
159
238
|
});
|
|
160
239
|
}
|
|
161
|
-
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, {
|
|
162
|
-
...props,
|
|
240
|
+
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, _extends({}, props, {
|
|
163
241
|
type: type,
|
|
164
242
|
cache: cacheKey,
|
|
165
243
|
getLabel: getLabel,
|
|
166
244
|
dataFormat: dataFormat,
|
|
167
245
|
transformItem: transformItem,
|
|
168
246
|
children: children
|
|
169
|
-
});
|
|
247
|
+
}));
|
|
170
248
|
});
|
|
171
249
|
|
|
172
250
|
/**
|
|
@@ -181,39 +259,44 @@ const EnumDisplay = withLocale(props => {
|
|
|
181
259
|
* @returns {React.Component} 枚举组件
|
|
182
260
|
*/
|
|
183
261
|
const createEnumComponent = options => {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
getLabel = defaultGetLabel,
|
|
188
|
-
dataFormat =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
262
|
+
const type = options.type,
|
|
263
|
+
cache = options.cache,
|
|
264
|
+
_options$getLabel = options.getLabel,
|
|
265
|
+
getLabel = _options$getLabel === void 0 ? defaultGetLabel : _options$getLabel,
|
|
266
|
+
_options$dataFormat = options.dataFormat,
|
|
267
|
+
dataFormat = _options$dataFormat === void 0 ? defaultDataFormat : _options$dataFormat,
|
|
268
|
+
_options$transformIte = options.transformItem,
|
|
269
|
+
transformItem = _options$transformIte === void 0 ? defaultTransformItem : _options$transformIte,
|
|
270
|
+
defaultApi = options.defaultApi;
|
|
192
271
|
const EnumComponent = withLocale(props => {
|
|
193
|
-
const
|
|
272
|
+
const name = props.name,
|
|
273
|
+
names = props.names,
|
|
274
|
+
_props$force2 = props.force,
|
|
275
|
+
force = _props$force2 === void 0 ? false : _props$force2,
|
|
276
|
+
_props$children2 = props.children,
|
|
277
|
+
children = _props$children2 === void 0 ? defaultChildren : _props$children2;
|
|
278
|
+
const cached = getCachedOutput({
|
|
279
|
+
cacheKey: cache,
|
|
280
|
+
type,
|
|
194
281
|
name,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// 检查缓存
|
|
200
|
-
const key = `${cache}_${type}_${name}`;
|
|
201
|
-
const cached = enumCache.get(key);
|
|
202
|
-
if (cached && !force) {
|
|
282
|
+
names,
|
|
283
|
+
force
|
|
284
|
+
});
|
|
285
|
+
if (cached) {
|
|
203
286
|
return children(cached, {
|
|
204
|
-
locale: props.locale
|
|
287
|
+
locale: props.locale,
|
|
288
|
+
names,
|
|
289
|
+
labels: getLabels(cached)
|
|
205
290
|
});
|
|
206
291
|
}
|
|
207
|
-
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, {
|
|
208
|
-
...props,
|
|
209
|
-
...defaultApi,
|
|
292
|
+
return /*#__PURE__*/jsxRuntime.jsx(EnumDisplayInner, _extends({}, props, defaultApi, {
|
|
210
293
|
type: type,
|
|
211
294
|
cache: cache,
|
|
212
295
|
getLabel: getLabel,
|
|
213
296
|
dataFormat: dataFormat,
|
|
214
297
|
transformItem: transformItem,
|
|
215
298
|
children: children
|
|
216
|
-
});
|
|
299
|
+
}));
|
|
217
300
|
});
|
|
218
301
|
|
|
219
302
|
// 附加静态属性
|
|
@@ -246,7 +329,7 @@ const defaultFunctionApi = {
|
|
|
246
329
|
ttl: 1000 * 60 * 60 * 24,
|
|
247
330
|
// 24小时
|
|
248
331
|
loader: () => {
|
|
249
|
-
return Promise.resolve().then(function () { return require('./function-
|
|
332
|
+
return Promise.resolve().then(function () { return require('./function-871311da.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
250
333
|
}
|
|
251
334
|
};
|
|
252
335
|
|
|
@@ -260,19 +343,19 @@ const FunctionEnum = createEnumComponent({
|
|
|
260
343
|
defaultApi: defaultFunctionApi
|
|
261
344
|
});
|
|
262
345
|
|
|
346
|
+
const _excluded$3 = ["value", "onChange", "single", "placeholder", "isPopup", "overlayWidth", "apis", "onSearch"];
|
|
263
347
|
const defaultFunctionData = () => {
|
|
264
|
-
return Promise.resolve().then(function () { return require('./function-
|
|
348
|
+
return Promise.resolve().then(function () { return require('./function-871311da.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
265
349
|
};
|
|
266
350
|
const transformToCascaderData$1 = (data, locale) => {
|
|
267
351
|
// 创建映射表
|
|
268
352
|
const mapping = new Map();
|
|
269
353
|
data.forEach(item => {
|
|
270
|
-
mapping.set(item.code, {
|
|
271
|
-
...item,
|
|
354
|
+
mapping.set(item.code, _extends({}, item, {
|
|
272
355
|
id: item.code,
|
|
273
356
|
name: getLabelForLocal$3(item, locale),
|
|
274
357
|
children: []
|
|
275
|
-
});
|
|
358
|
+
}));
|
|
276
359
|
});
|
|
277
360
|
|
|
278
361
|
// 构建嵌套结构
|
|
@@ -301,22 +384,23 @@ const transformToCascaderData$1 = (data, locale) => {
|
|
|
301
384
|
return roots;
|
|
302
385
|
};
|
|
303
386
|
const SelectFunctionInner = _ref => {
|
|
304
|
-
let
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
single = false,
|
|
308
|
-
placeholder,
|
|
309
|
-
isPopup =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
locale,
|
|
317
|
-
formatMessage
|
|
318
|
-
|
|
319
|
-
|
|
387
|
+
let value = _ref.value,
|
|
388
|
+
onChange = _ref.onChange,
|
|
389
|
+
_ref$single = _ref.single,
|
|
390
|
+
single = _ref$single === void 0 ? false : _ref$single,
|
|
391
|
+
placeholder = _ref.placeholder,
|
|
392
|
+
_ref$isPopup = _ref.isPopup,
|
|
393
|
+
isPopup = _ref$isPopup === void 0 ? true : _ref$isPopup,
|
|
394
|
+
_ref$overlayWidth = _ref.overlayWidth,
|
|
395
|
+
overlayWidth = _ref$overlayWidth === void 0 ? 320 : _ref$overlayWidth,
|
|
396
|
+
onSearch = _ref.onSearch,
|
|
397
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
398
|
+
const _useIntl = reactIntl.useIntl(),
|
|
399
|
+
locale = _useIntl.locale,
|
|
400
|
+
formatMessage = _useIntl.formatMessage;
|
|
401
|
+
const _useState = react.useState([]),
|
|
402
|
+
data = _useState[0],
|
|
403
|
+
setData = _useState[1];
|
|
320
404
|
react.useEffect(() => {
|
|
321
405
|
defaultFunctionData().then(result => {
|
|
322
406
|
setData(result.data || result);
|
|
@@ -324,17 +408,14 @@ const SelectFunctionInner = _ref => {
|
|
|
324
408
|
}, []);
|
|
325
409
|
const options = react.useMemo(() => transformToCascaderData$1(data, locale), [data, locale]);
|
|
326
410
|
const handleSearch = (searchText, _ref2) => {
|
|
327
|
-
let
|
|
328
|
-
mapping
|
|
329
|
-
} = _ref2;
|
|
411
|
+
let mapping = _ref2.mapping;
|
|
330
412
|
if (!searchText) return Array.from(mapping.values());
|
|
331
413
|
const keyword = searchText.toLowerCase();
|
|
332
414
|
return Array.from(mapping.values()).filter(item => {
|
|
333
415
|
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);
|
|
334
416
|
});
|
|
335
417
|
};
|
|
336
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, {
|
|
337
|
-
...props,
|
|
418
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, _extends({}, props, {
|
|
338
419
|
value: value,
|
|
339
420
|
onChange: onChange,
|
|
340
421
|
single: single,
|
|
@@ -345,15 +426,14 @@ const SelectFunctionInner = _ref => {
|
|
|
345
426
|
}),
|
|
346
427
|
isPopup: isPopup,
|
|
347
428
|
menuItemWidth: 200,
|
|
348
|
-
style: {
|
|
349
|
-
width: overlayWidth
|
|
350
|
-
|
|
351
|
-
},
|
|
429
|
+
style: _extends({
|
|
430
|
+
width: overlayWidth
|
|
431
|
+
}, props.style),
|
|
352
432
|
options: options,
|
|
353
433
|
valueKey: "id",
|
|
354
434
|
labelKey: "name",
|
|
355
435
|
onSearch: onSearch || handleSearch
|
|
356
|
-
});
|
|
436
|
+
}));
|
|
357
437
|
};
|
|
358
438
|
const SelectFunction = withLocale(SelectFunctionInner);
|
|
359
439
|
SelectFunction.defaultData = defaultFunctionData;
|
|
@@ -378,7 +458,7 @@ const defaultIndustryApi = {
|
|
|
378
458
|
ttl: 1000 * 60 * 60 * 24,
|
|
379
459
|
// 24小时
|
|
380
460
|
loader: () => {
|
|
381
|
-
return Promise.resolve().then(function () { return require('./industry-
|
|
461
|
+
return Promise.resolve().then(function () { return require('./industry-f570d549.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
382
462
|
}
|
|
383
463
|
};
|
|
384
464
|
|
|
@@ -392,8 +472,9 @@ const IndustryEnum = createEnumComponent({
|
|
|
392
472
|
defaultApi: defaultIndustryApi
|
|
393
473
|
});
|
|
394
474
|
|
|
475
|
+
const _excluded$2 = ["value", "onChange", "single", "placeholder", "isPopup", "overlayWidth", "apis", "onSearch"];
|
|
395
476
|
const defaultIndustryData = () => {
|
|
396
|
-
return Promise.resolve().then(function () { return require('./industry-
|
|
477
|
+
return Promise.resolve().then(function () { return require('./industry-f570d549.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
397
478
|
};
|
|
398
479
|
const transformToCascaderData = (data, locale) => {
|
|
399
480
|
// 过滤掉"全部行业"
|
|
@@ -402,12 +483,11 @@ const transformToCascaderData = (data, locale) => {
|
|
|
402
483
|
// 创建映射表
|
|
403
484
|
const mapping = new Map();
|
|
404
485
|
filteredData.forEach(item => {
|
|
405
|
-
mapping.set(item.code, {
|
|
406
|
-
...item,
|
|
486
|
+
mapping.set(item.code, _extends({}, item, {
|
|
407
487
|
id: item.code,
|
|
408
488
|
name: getLabelForLocal$2(item, locale),
|
|
409
489
|
children: []
|
|
410
|
-
});
|
|
490
|
+
}));
|
|
411
491
|
});
|
|
412
492
|
|
|
413
493
|
// 构建嵌套结构
|
|
@@ -436,22 +516,23 @@ const transformToCascaderData = (data, locale) => {
|
|
|
436
516
|
return roots;
|
|
437
517
|
};
|
|
438
518
|
const SelectIndustryInner = _ref => {
|
|
439
|
-
let
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
single = false,
|
|
443
|
-
placeholder,
|
|
444
|
-
isPopup =
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
locale,
|
|
452
|
-
formatMessage
|
|
453
|
-
|
|
454
|
-
|
|
519
|
+
let value = _ref.value,
|
|
520
|
+
onChange = _ref.onChange,
|
|
521
|
+
_ref$single = _ref.single,
|
|
522
|
+
single = _ref$single === void 0 ? false : _ref$single,
|
|
523
|
+
placeholder = _ref.placeholder,
|
|
524
|
+
_ref$isPopup = _ref.isPopup,
|
|
525
|
+
isPopup = _ref$isPopup === void 0 ? true : _ref$isPopup,
|
|
526
|
+
_ref$overlayWidth = _ref.overlayWidth,
|
|
527
|
+
overlayWidth = _ref$overlayWidth === void 0 ? 320 : _ref$overlayWidth,
|
|
528
|
+
onSearch = _ref.onSearch,
|
|
529
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
530
|
+
const _useIntl = reactIntl.useIntl(),
|
|
531
|
+
locale = _useIntl.locale,
|
|
532
|
+
formatMessage = _useIntl.formatMessage;
|
|
533
|
+
const _useState = react.useState([]),
|
|
534
|
+
data = _useState[0],
|
|
535
|
+
setData = _useState[1];
|
|
455
536
|
react.useEffect(() => {
|
|
456
537
|
defaultIndustryData().then(result => {
|
|
457
538
|
setData(result.data || result);
|
|
@@ -459,17 +540,14 @@ const SelectIndustryInner = _ref => {
|
|
|
459
540
|
}, []);
|
|
460
541
|
const options = react.useMemo(() => transformToCascaderData(data, locale), [data, locale]);
|
|
461
542
|
const handleSearch = (searchText, _ref2) => {
|
|
462
|
-
let
|
|
463
|
-
mapping
|
|
464
|
-
} = _ref2;
|
|
543
|
+
let mapping = _ref2.mapping;
|
|
465
544
|
if (!searchText) return Array.from(mapping.values());
|
|
466
545
|
const keyword = searchText.toLowerCase();
|
|
467
546
|
return Array.from(mapping.values()).filter(item => {
|
|
468
547
|
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);
|
|
469
548
|
});
|
|
470
549
|
};
|
|
471
|
-
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, {
|
|
472
|
-
...props,
|
|
550
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectCascader, _extends({}, props, {
|
|
473
551
|
value: value,
|
|
474
552
|
onChange: onChange,
|
|
475
553
|
single: single,
|
|
@@ -480,20 +558,21 @@ const SelectIndustryInner = _ref => {
|
|
|
480
558
|
}),
|
|
481
559
|
isPopup: isPopup,
|
|
482
560
|
menuItemWidth: 200,
|
|
483
|
-
style: {
|
|
484
|
-
width: overlayWidth
|
|
485
|
-
|
|
486
|
-
},
|
|
561
|
+
style: _extends({
|
|
562
|
+
width: overlayWidth
|
|
563
|
+
}, props.style),
|
|
487
564
|
options: options,
|
|
488
565
|
valueKey: "id",
|
|
489
566
|
labelKey: "name",
|
|
490
567
|
onSearch: onSearch || handleSearch
|
|
491
|
-
});
|
|
568
|
+
}));
|
|
492
569
|
};
|
|
493
570
|
const SelectIndustry = withLocale(SelectIndustryInner);
|
|
494
571
|
SelectIndustry.defaultData = defaultIndustryData;
|
|
495
572
|
SelectIndustry.Enum = IndustryEnum;
|
|
496
573
|
|
|
574
|
+
const _excluded$1 = ["data", "name", "children", "displayParent"],
|
|
575
|
+
_excluded2 = ["displayParent"];
|
|
497
576
|
const getLabelForLocal$1 = (item, locale) => {
|
|
498
577
|
if (locale === 'en-US') {
|
|
499
578
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -510,7 +589,7 @@ const addressDefaultApi = {
|
|
|
510
589
|
ttl: 1000 * 60 * 60 * 24,
|
|
511
590
|
// 24小时
|
|
512
591
|
loader: () => {
|
|
513
|
-
return Promise.resolve().then(function () { return require('./city-
|
|
592
|
+
return Promise.resolve().then(function () { return require('./city-39702d3a.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
514
593
|
}
|
|
515
594
|
};
|
|
516
595
|
|
|
@@ -518,33 +597,27 @@ const addressDefaultApi = {
|
|
|
518
597
|
* 地址枚举显示组件
|
|
519
598
|
*/
|
|
520
599
|
const AddressEnumInner = reactFetch.withFetch(_ref => {
|
|
521
|
-
let
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const {
|
|
529
|
-
locale
|
|
530
|
-
} = reactIntl.useIntl();
|
|
600
|
+
let data = _ref.data,
|
|
601
|
+
name = _ref.name,
|
|
602
|
+
children = _ref.children,
|
|
603
|
+
displayParent = _ref.displayParent,
|
|
604
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
605
|
+
const _useIntl = reactIntl.useIntl(),
|
|
606
|
+
locale = _useIntl.locale;
|
|
531
607
|
const addressApi = react.useMemo(() => createAddressApi(data), [data]);
|
|
532
608
|
|
|
533
609
|
// 获取城市数据
|
|
534
610
|
const cityData = addressApi.getCity(name);
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
parent
|
|
538
|
-
} = cityData;
|
|
611
|
+
const city = cityData.city,
|
|
612
|
+
parent = cityData.parent;
|
|
539
613
|
|
|
540
614
|
// 如果提供了自定义渲染函数
|
|
541
615
|
if (children) {
|
|
542
|
-
return children(cityData, {
|
|
616
|
+
return children(cityData, _extends({
|
|
543
617
|
displayParent,
|
|
544
618
|
locale,
|
|
545
|
-
getLabelForLocal: getLabelForLocal$1
|
|
546
|
-
|
|
547
|
-
});
|
|
619
|
+
getLabelForLocal: getLabelForLocal$1
|
|
620
|
+
}, props));
|
|
548
621
|
}
|
|
549
622
|
|
|
550
623
|
// 默认渲染逻辑
|
|
@@ -552,20 +625,17 @@ const AddressEnumInner = reactFetch.withFetch(_ref => {
|
|
|
552
625
|
return '';
|
|
553
626
|
}
|
|
554
627
|
if (displayParent && parent) {
|
|
555
|
-
return
|
|
628
|
+
return getLabelForLocal$1(parent, locale) + "\xB7" + getLabelForLocal$1(city, locale);
|
|
556
629
|
}
|
|
557
630
|
return getLabelForLocal$1(city, locale);
|
|
558
631
|
});
|
|
559
632
|
const AddressEnum = withLocale(props => {
|
|
560
|
-
const
|
|
561
|
-
displayParent = false,
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
displayParent: displayParent,
|
|
567
|
-
...restProps
|
|
568
|
-
});
|
|
633
|
+
const _props$displayParent = props.displayParent,
|
|
634
|
+
displayParent = _props$displayParent === void 0 ? false : _props$displayParent,
|
|
635
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
636
|
+
return /*#__PURE__*/jsxRuntime.jsx(AddressEnumInner, _extends({}, addressDefaultApi, {
|
|
637
|
+
displayParent: displayParent
|
|
638
|
+
}, restProps));
|
|
569
639
|
});
|
|
570
640
|
AddressEnum.addressDefaultApi = addressDefaultApi;
|
|
571
641
|
|
|
@@ -649,8 +719,9 @@ var classnames = createCommonjsModule(function (module) {
|
|
|
649
719
|
}());
|
|
650
720
|
});
|
|
651
721
|
|
|
652
|
-
var style = {"address":"
|
|
722
|
+
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"};
|
|
653
723
|
|
|
724
|
+
const _excluded = ["single", "isPopup", "showChinaQuan", "showForeignQuan"];
|
|
654
725
|
const getLabelForLocal = (item, locale) => {
|
|
655
726
|
if (locale === 'en-US') {
|
|
656
727
|
return get__default["default"](item, 'enName') || get__default["default"](item, 'name');
|
|
@@ -658,14 +729,12 @@ const getLabelForLocal = (item, locale) => {
|
|
|
658
729
|
return get__default["default"](item, 'name');
|
|
659
730
|
};
|
|
660
731
|
const defaultCityData = () => {
|
|
661
|
-
return Promise.resolve().then(function () { return require('./city-
|
|
732
|
+
return Promise.resolve().then(function () { return require('./city-39702d3a.js'); }).then(module => module['__esModule'] ? module.default : module);
|
|
662
733
|
};
|
|
663
734
|
const createAddressApi = _ref => {
|
|
664
|
-
let
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
country
|
|
668
|
-
} = _ref;
|
|
735
|
+
let city = _ref.city,
|
|
736
|
+
province = _ref.province,
|
|
737
|
+
country = _ref.country;
|
|
669
738
|
const getSearchList = memoize__default["default"](() => {
|
|
670
739
|
const list = [];
|
|
671
740
|
['gangaotai', 'municipality'].forEach(name => {
|
|
@@ -707,25 +776,24 @@ const createAddressApi = _ref => {
|
|
|
707
776
|
}, country.list[id])).filter(item => item.code);
|
|
708
777
|
}),
|
|
709
778
|
getList: memoize__default["default"]((pid, options) => {
|
|
710
|
-
const {
|
|
711
|
-
showChinaQuan,
|
|
712
|
-
showForeignQuan
|
|
713
|
-
} = Object.assign({}, options);
|
|
779
|
+
const _Object$assign = Object.assign({}, options),
|
|
780
|
+
showChinaQuan = _Object$assign.showChinaQuan,
|
|
781
|
+
showForeignQuan = _Object$assign.showForeignQuan;
|
|
714
782
|
if (pid === 'gangaotai') {
|
|
715
783
|
return (province.relations['gangaotai'] || []).map(id => city.list[id]).filter(Boolean);
|
|
716
784
|
}
|
|
717
785
|
const current = Object.assign({}, city.list[pid]);
|
|
718
786
|
if ((province.relations.municipality || []).indexOf(pid) > -1) {
|
|
719
|
-
current.name =
|
|
787
|
+
current.name = "" + (showChinaQuan ? '全' : '') + current.name;
|
|
720
788
|
return [current];
|
|
721
789
|
}
|
|
722
790
|
const list = (city.relations[pid] || []).map(id => city.list[id]).filter(Boolean);
|
|
723
791
|
if ((province.relations.provinces || []).indexOf(pid) > -1 && showChinaQuan) {
|
|
724
|
-
current.name =
|
|
792
|
+
current.name = "\u5168" + current.name;
|
|
725
793
|
list.splice(0, 0, current);
|
|
726
794
|
}
|
|
727
795
|
if ((country.relations.continents || []).indexOf(pid) > -1 && showForeignQuan) {
|
|
728
|
-
current.name =
|
|
796
|
+
current.name = "\u5168" + current.name;
|
|
729
797
|
list.splice(0, 0, current);
|
|
730
798
|
}
|
|
731
799
|
return list;
|
|
@@ -765,16 +833,14 @@ const createAddressApi = _ref => {
|
|
|
765
833
|
});
|
|
766
834
|
}).map(item => {
|
|
767
835
|
const parent = item.parentCode ? city.list[item.parentCode] : null;
|
|
768
|
-
return {
|
|
769
|
-
label: parent ?
|
|
770
|
-
value: item.code
|
|
771
|
-
|
|
772
|
-
};
|
|
836
|
+
return _extends({
|
|
837
|
+
label: parent ? parent.name + "\xB7" + item.name : item.name,
|
|
838
|
+
value: item.code
|
|
839
|
+
}, item);
|
|
773
840
|
});
|
|
774
841
|
}),
|
|
775
842
|
getCityList: memoize__default["default"](() => {
|
|
776
|
-
return Object.values(city.list).map(item => ({
|
|
777
|
-
...item,
|
|
843
|
+
return Object.values(city.list).map(item => _extends({}, item, {
|
|
778
844
|
value: item.code,
|
|
779
845
|
label: item.name
|
|
780
846
|
}));
|
|
@@ -783,18 +849,21 @@ const createAddressApi = _ref => {
|
|
|
783
849
|
return apis;
|
|
784
850
|
};
|
|
785
851
|
const AddressInner = _ref2 => {
|
|
786
|
-
let
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
852
|
+
let value = _ref2.value,
|
|
853
|
+
setValue = _ref2.setValue,
|
|
854
|
+
props = _ref2.props;
|
|
855
|
+
const _useIntl = reactIntl.useIntl(),
|
|
856
|
+
locale = _useIntl.locale,
|
|
857
|
+
formatMessage = _useIntl.formatMessage;
|
|
858
|
+
const _useState = react.useState(''),
|
|
859
|
+
searchText = _useState[0],
|
|
860
|
+
setSearchText = _useState[1];
|
|
861
|
+
const _useState2 = react.useState('2'),
|
|
862
|
+
menuKey = _useState2[0],
|
|
863
|
+
setMenuKey = _useState2[1];
|
|
864
|
+
const _useState3 = react.useState(null),
|
|
865
|
+
cityData = _useState3[0],
|
|
866
|
+
setCityData = _useState3[1];
|
|
798
867
|
react.useEffect(() => {
|
|
799
868
|
defaultCityData().then(result => {
|
|
800
869
|
setCityData(result);
|
|
@@ -804,21 +873,20 @@ const AddressInner = _ref2 => {
|
|
|
804
873
|
if (!cityData) return null;
|
|
805
874
|
return createAddressApi(cityData);
|
|
806
875
|
}, [cityData]);
|
|
807
|
-
const {
|
|
808
|
-
getCity,
|
|
809
|
-
getChinaCities,
|
|
810
|
-
getCountries,
|
|
811
|
-
getList,
|
|
812
|
-
searchCities
|
|
813
|
-
} = addressApi || {};
|
|
876
|
+
const _ref3 = addressApi || {},
|
|
877
|
+
getCity = _ref3.getCity,
|
|
878
|
+
getChinaCities = _ref3.getChinaCities,
|
|
879
|
+
getCountries = _ref3.getCountries,
|
|
880
|
+
getList = _ref3.getList,
|
|
881
|
+
searchCities = _ref3.searchCities;
|
|
814
882
|
const onSelect = react.useCallback(code => {
|
|
815
|
-
|
|
883
|
+
var _cityData$city;
|
|
884
|
+
const cityInfo = cityData == null || (_cityData$city = cityData.city) == null || (_cityData$city = _cityData$city.list) == null ? void 0 : _cityData$city[code];
|
|
816
885
|
if (!cityInfo) return;
|
|
817
|
-
const item = {
|
|
886
|
+
const item = _extends({
|
|
818
887
|
value: code,
|
|
819
|
-
label: cityInfo.name
|
|
820
|
-
|
|
821
|
-
};
|
|
888
|
+
label: cityInfo.name
|
|
889
|
+
}, cityInfo);
|
|
822
890
|
if (props.single) {
|
|
823
891
|
setValue([item]);
|
|
824
892
|
return;
|
|
@@ -858,7 +926,7 @@ const AddressInner = _ref2 => {
|
|
|
858
926
|
})
|
|
859
927
|
})
|
|
860
928
|
});
|
|
861
|
-
const currentCity = getCity
|
|
929
|
+
const currentCity = getCity == null ? void 0 : getCity(menuKey);
|
|
862
930
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
863
931
|
className: classnames(style['address'], {
|
|
864
932
|
[style['is-popup']]: props.isPopup
|
|
@@ -943,7 +1011,7 @@ const AddressInner = _ref2 => {
|
|
|
943
1011
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Divider, {
|
|
944
1012
|
className: style['title'],
|
|
945
1013
|
orientation: "left",
|
|
946
|
-
children: currentCity
|
|
1014
|
+
children: currentCity != null && currentCity.city ? getLabelForLocal(currentCity.city, locale) : ''
|
|
947
1015
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
948
1016
|
className: style['scroll-box'],
|
|
949
1017
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
|
|
@@ -966,45 +1034,43 @@ const AddressInner = _ref2 => {
|
|
|
966
1034
|
});
|
|
967
1035
|
};
|
|
968
1036
|
const SelectAddressInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
969
|
-
const
|
|
970
|
-
formatMessage
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
...props,
|
|
1037
|
+
const _useIntl2 = reactIntl.useIntl(),
|
|
1038
|
+
formatMessage = _useIntl2.formatMessage;
|
|
1039
|
+
return /*#__PURE__*/jsxRuntime.jsx(superSelect.SelectInput, _extends({
|
|
1040
|
+
ref: ref
|
|
1041
|
+
}, props, {
|
|
975
1042
|
placeholder: props.placeholder || formatMessage({
|
|
976
1043
|
id: 'addressPlaceholder'
|
|
977
1044
|
}, {
|
|
978
1045
|
defaultMessage: '请选择城市'
|
|
979
1046
|
}),
|
|
980
1047
|
children: contextProps => {
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
setValue
|
|
984
|
-
} = contextProps;
|
|
1048
|
+
const value = contextProps.value,
|
|
1049
|
+
setValue = contextProps.setValue;
|
|
985
1050
|
return /*#__PURE__*/jsxRuntime.jsx(AddressInner, {
|
|
986
1051
|
value: value,
|
|
987
1052
|
setValue: setValue,
|
|
988
1053
|
props: props
|
|
989
1054
|
});
|
|
990
1055
|
}
|
|
991
|
-
});
|
|
1056
|
+
}));
|
|
992
1057
|
});
|
|
993
|
-
const SelectAddress = withLocale(
|
|
994
|
-
let
|
|
995
|
-
single = false,
|
|
996
|
-
isPopup =
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1058
|
+
const SelectAddress = withLocale(_ref4 => {
|
|
1059
|
+
let _ref4$single = _ref4.single,
|
|
1060
|
+
single = _ref4$single === void 0 ? false : _ref4$single,
|
|
1061
|
+
_ref4$isPopup = _ref4.isPopup,
|
|
1062
|
+
isPopup = _ref4$isPopup === void 0 ? true : _ref4$isPopup,
|
|
1063
|
+
_ref4$showChinaQuan = _ref4.showChinaQuan,
|
|
1064
|
+
showChinaQuan = _ref4$showChinaQuan === void 0 ? false : _ref4$showChinaQuan,
|
|
1065
|
+
_ref4$showForeignQuan = _ref4.showForeignQuan,
|
|
1066
|
+
showForeignQuan = _ref4$showForeignQuan === void 0 ? false : _ref4$showForeignQuan,
|
|
1067
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
1068
|
+
return /*#__PURE__*/jsxRuntime.jsx(SelectAddressInner, _extends({
|
|
1002
1069
|
single: single,
|
|
1003
1070
|
isPopup: isPopup,
|
|
1004
1071
|
showChinaQuan: showChinaQuan,
|
|
1005
|
-
showForeignQuan: showForeignQuan
|
|
1006
|
-
|
|
1007
|
-
});
|
|
1072
|
+
showForeignQuan: showForeignQuan
|
|
1073
|
+
}, props));
|
|
1008
1074
|
}, 'SelectAddress');
|
|
1009
1075
|
SelectAddress.defaultData = defaultCityData;
|
|
1010
1076
|
SelectAddress.createAddressApi = createAddressApi;
|