@alicloud/console-components-search 0.2.37-alpha.2 → 0.2.37-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demos/demo1.demo.tsx +0 -3
- package/dist/index.js +25 -4
- package/es/ComplexSearch/index.js +25 -4
- package/lib/ComplexSearch/index.js +25 -4
- package/package.json +1 -1
package/demos/demo1.demo.tsx
CHANGED
|
@@ -15,7 +15,6 @@ const options = [
|
|
|
15
15
|
// placeholder: '按实例名称搜索',
|
|
16
16
|
dataSource: [],
|
|
17
17
|
},
|
|
18
|
-
groupName: 'test',
|
|
19
18
|
},
|
|
20
19
|
{
|
|
21
20
|
label: '网络类型',
|
|
@@ -30,7 +29,6 @@ const options = [
|
|
|
30
29
|
{ label: 'D', value: 'd' },
|
|
31
30
|
],
|
|
32
31
|
},
|
|
33
|
-
groupName: 'test',
|
|
34
32
|
},
|
|
35
33
|
{
|
|
36
34
|
label: '付费类型',
|
|
@@ -45,7 +43,6 @@ const options = [
|
|
|
45
43
|
{ label: 'D', value: 'd' },
|
|
46
44
|
],
|
|
47
45
|
},
|
|
48
|
-
groupName: 'test2',
|
|
49
46
|
},
|
|
50
47
|
];
|
|
51
48
|
|
package/dist/index.js
CHANGED
|
@@ -90211,12 +90211,33 @@ var InputPrefix_1 = __importDefault(__webpack_require__(423));
|
|
|
90211
90211
|
var constants_1 = __webpack_require__(135);
|
|
90212
90212
|
var message_1 = __importDefault(__webpack_require__(165));
|
|
90213
90213
|
var AutoComplete = console_components_1.Select.AutoComplete;
|
|
90214
|
+
function formatOptionsChildren(children) {
|
|
90215
|
+
if (!children)
|
|
90216
|
+
return undefined;
|
|
90217
|
+
return children.map(function (o) {
|
|
90218
|
+
return {
|
|
90219
|
+
label: o.label,
|
|
90220
|
+
value: o.dataIndex || o.label,
|
|
90221
|
+
children: formatOptionsChildren(o.children),
|
|
90222
|
+
};
|
|
90223
|
+
});
|
|
90224
|
+
}
|
|
90214
90225
|
/**
|
|
90215
90226
|
*
|
|
90216
90227
|
* @param IRcSearchOptionsProps options
|
|
90217
90228
|
* @returns
|
|
90218
90229
|
*/
|
|
90219
|
-
var normalizeOptions = function (options) {
|
|
90230
|
+
var normalizeOptions = function (options, prefixSelectMode) {
|
|
90231
|
+
if (prefixSelectMode === 'cascader') {
|
|
90232
|
+
return options.map(function (o) {
|
|
90233
|
+
return {
|
|
90234
|
+
label: o.label,
|
|
90235
|
+
value: o.dataIndex || o.label,
|
|
90236
|
+
// @ts-ignore
|
|
90237
|
+
children: formatOptionsChildren(o.children),
|
|
90238
|
+
};
|
|
90239
|
+
});
|
|
90240
|
+
}
|
|
90220
90241
|
var optionsCopy = (0, cloneDeep_1.default)(options);
|
|
90221
90242
|
optionsCopy.forEach(function (o) { !o.groupName && (o.groupName = message_1.default.defaultFilterGroupName); });
|
|
90222
90243
|
return Object.entries((0, groupBy_1.default)(optionsCopy, 'groupName')).map(function (_a) {
|
|
@@ -90427,11 +90448,11 @@ var ComplexSearch = function (props) {
|
|
|
90427
90448
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
|
|
90428
90449
|
focus: focused,
|
|
90429
90450
|
}) },
|
|
90430
|
-
react_1.default.createElement("div", { className: (0, classnames_1.default)('condition') }, selectedFilterType ? (react_1.default.createElement(InputPrefix_1.default, { type: prefixSelectMode, dataSource: normalizeOptions(options), label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex, onChange: function (value) {
|
|
90451
|
+
react_1.default.createElement("div", { className: (0, classnames_1.default)('condition') }, selectedFilterType ? (react_1.default.createElement(InputPrefix_1.default, { type: prefixSelectMode, dataSource: normalizeOptions(options, prefixSelectMode), label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex, onChange: function (value) {
|
|
90431
90452
|
handlerFilterTypeChange(value);
|
|
90432
90453
|
}, itemRender: prefixSelectItemRender })) : null),
|
|
90433
90454
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('forms') },
|
|
90434
|
-
!selectedFilterType && prefixSelectMode === 'cascader' ? react_1.default.createElement(console_components_1.CascaderSelect, { className: (0, classnames_1.default)('main-input', 'multi'), hasBorder: false, dataSource: normalizeOptions(options), placeholder: placeholder ||
|
|
90455
|
+
!selectedFilterType && prefixSelectMode === 'cascader' ? react_1.default.createElement(console_components_1.CascaderSelect, { className: (0, classnames_1.default)('main-input', 'multi'), hasBorder: false, dataSource: normalizeOptions(options, prefixSelectMode), placeholder: placeholder ||
|
|
90435
90456
|
((defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label)
|
|
90436
90457
|
? (0, lodash_1.template)(message_1.default.defaultPlaceHolder)({
|
|
90437
90458
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label,
|
|
@@ -90458,7 +90479,7 @@ var ComplexSearch = function (props) {
|
|
|
90458
90479
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
90459
90480
|
isFuzzy
|
|
90460
90481
|
? normalizeSuggestion(suggestions)
|
|
90461
|
-
: normalizeOptions(options), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90482
|
+
: normalizeOptions(options, prefixSelectMode), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90462
90483
|
renderSelectedFilter(),
|
|
90463
90484
|
renderSelectFilterCloseIcon())),
|
|
90464
90485
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('right-wrap'), ref: autoRef },
|
|
@@ -16,12 +16,33 @@ import SearchConditionSelectPrefix from './InputPrefix';
|
|
|
16
16
|
import { SEARCH_FILTER_FIELD, SEARCH_FILTER_VALUE_FIELD } from '../constants';
|
|
17
17
|
import message from '../message';
|
|
18
18
|
var AutoComplete = Select.AutoComplete;
|
|
19
|
+
function formatOptionsChildren(children) {
|
|
20
|
+
if (!children) return undefined;
|
|
21
|
+
return children.map(function (o) {
|
|
22
|
+
return {
|
|
23
|
+
label: o.label,
|
|
24
|
+
value: o.dataIndex || o.label,
|
|
25
|
+
children: formatOptionsChildren(o.children)
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
/**
|
|
20
31
|
*
|
|
21
32
|
* @param IRcSearchOptionsProps options
|
|
22
33
|
* @returns
|
|
23
34
|
*/
|
|
24
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
35
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
36
|
+
if (prefixSelectMode === 'cascader') {
|
|
37
|
+
return options.map(function (o) {
|
|
38
|
+
return {
|
|
39
|
+
label: o.label,
|
|
40
|
+
value: o.dataIndex || o.label,
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
children: formatOptionsChildren(o.children)
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
25
46
|
var optionsCopy = cloneDeep(options);
|
|
26
47
|
optionsCopy.forEach(function (o) {
|
|
27
48
|
!o.groupName && (o.groupName = message.defaultFilterGroupName);
|
|
@@ -330,7 +351,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
330
351
|
className: classNames('condition')
|
|
331
352
|
}, selectedFilterType ? /*#__PURE__*/React.createElement(SearchConditionSelectPrefix, {
|
|
332
353
|
type: prefixSelectMode,
|
|
333
|
-
dataSource: normalizeOptions(options),
|
|
354
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
334
355
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
335
356
|
defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
|
|
336
357
|
onChange: function onChange(value) {
|
|
@@ -342,7 +363,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
342
363
|
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/React.createElement(CascaderSelect, {
|
|
343
364
|
className: classNames('main-input', 'multi'),
|
|
344
365
|
hasBorder: false,
|
|
345
|
-
dataSource: normalizeOptions(options),
|
|
366
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
346
367
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? template(message.defaultPlaceHolder)({
|
|
347
368
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
348
369
|
}) : ''),
|
|
@@ -371,7 +392,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
371
392
|
dataSource:
|
|
372
393
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
373
394
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
374
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
395
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
375
396
|
popupStyle: {
|
|
376
397
|
width: 'auto'
|
|
377
398
|
},
|
|
@@ -25,12 +25,33 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
25
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
26
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
27
|
var AutoComplete = _consoleComponents.Select.AutoComplete;
|
|
28
|
+
function formatOptionsChildren(children) {
|
|
29
|
+
if (!children) return undefined;
|
|
30
|
+
return children.map(function (o) {
|
|
31
|
+
return {
|
|
32
|
+
label: o.label,
|
|
33
|
+
value: o.dataIndex || o.label,
|
|
34
|
+
children: formatOptionsChildren(o.children)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
/**
|
|
29
40
|
*
|
|
30
41
|
* @param IRcSearchOptionsProps options
|
|
31
42
|
* @returns
|
|
32
43
|
*/
|
|
33
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
44
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
45
|
+
if (prefixSelectMode === 'cascader') {
|
|
46
|
+
return options.map(function (o) {
|
|
47
|
+
return {
|
|
48
|
+
label: o.label,
|
|
49
|
+
value: o.dataIndex || o.label,
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
children: formatOptionsChildren(o.children)
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
34
55
|
var optionsCopy = (0, _cloneDeep.default)(options);
|
|
35
56
|
optionsCopy.forEach(function (o) {
|
|
36
57
|
!o.groupName && (o.groupName = _message.default.defaultFilterGroupName);
|
|
@@ -339,7 +360,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
339
360
|
className: (0, _classnames.default)('condition')
|
|
340
361
|
}, selectedFilterType ? /*#__PURE__*/_react.default.createElement(_InputPrefix.default, {
|
|
341
362
|
type: prefixSelectMode,
|
|
342
|
-
dataSource: normalizeOptions(options),
|
|
363
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
343
364
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
344
365
|
defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
|
|
345
366
|
onChange: function onChange(value) {
|
|
@@ -351,7 +372,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
351
372
|
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/_react.default.createElement(_consoleComponents.CascaderSelect, {
|
|
352
373
|
className: (0, _classnames.default)('main-input', 'multi'),
|
|
353
374
|
hasBorder: false,
|
|
354
|
-
dataSource: normalizeOptions(options),
|
|
375
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
355
376
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? (0, _lodash.template)(_message.default.defaultPlaceHolder)({
|
|
356
377
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
357
378
|
}) : ''),
|
|
@@ -380,7 +401,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
380
401
|
dataSource:
|
|
381
402
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
382
403
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
383
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
404
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
384
405
|
popupStyle: {
|
|
385
406
|
width: 'auto'
|
|
386
407
|
},
|