@alicloud/console-components-search 0.2.37-alpha.2 → 0.2.37-alpha.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/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,23 +90211,46 @@ 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.value || o.dataIndex || o.label,
|
|
90221
|
+
disabled: o.disabled,
|
|
90222
|
+
children: formatOptionsChildren(o.children),
|
|
90223
|
+
};
|
|
90224
|
+
});
|
|
90225
|
+
}
|
|
90214
90226
|
/**
|
|
90215
90227
|
*
|
|
90216
90228
|
* @param IRcSearchOptionsProps options
|
|
90217
90229
|
* @returns
|
|
90218
90230
|
*/
|
|
90219
|
-
var normalizeOptions = function (options) {
|
|
90231
|
+
var normalizeOptions = function (options, prefixSelectMode) {
|
|
90232
|
+
if (prefixSelectMode === 'cascader') {
|
|
90233
|
+
return options.map(function (o) {
|
|
90234
|
+
return {
|
|
90235
|
+
label: o.label,
|
|
90236
|
+
value: o.value || o.dataIndex || o.label,
|
|
90237
|
+
disabled: o.disabled,
|
|
90238
|
+
// @ts-ignore
|
|
90239
|
+
children: formatOptionsChildren(o.children),
|
|
90240
|
+
};
|
|
90241
|
+
});
|
|
90242
|
+
}
|
|
90220
90243
|
var optionsCopy = (0, cloneDeep_1.default)(options);
|
|
90221
90244
|
optionsCopy.forEach(function (o) { !o.groupName && (o.groupName = message_1.default.defaultFilterGroupName); });
|
|
90222
90245
|
return Object.entries((0, groupBy_1.default)(optionsCopy, 'groupName')).map(function (_a) {
|
|
90223
90246
|
var groupName = _a[0], children = _a[1];
|
|
90224
90247
|
return {
|
|
90225
90248
|
label: groupName,
|
|
90226
|
-
value: groupName,
|
|
90227
90249
|
children: children.map(function (l) {
|
|
90228
90250
|
return {
|
|
90229
90251
|
label: l.label,
|
|
90230
90252
|
value: l.dataIndex,
|
|
90253
|
+
disabled: l.disabled,
|
|
90231
90254
|
};
|
|
90232
90255
|
}),
|
|
90233
90256
|
};
|
|
@@ -90427,11 +90450,11 @@ var ComplexSearch = function (props) {
|
|
|
90427
90450
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
|
|
90428
90451
|
focus: focused,
|
|
90429
90452
|
}) },
|
|
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) {
|
|
90453
|
+
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
90454
|
handlerFilterTypeChange(value);
|
|
90432
90455
|
}, itemRender: prefixSelectItemRender })) : null),
|
|
90433
90456
|
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 ||
|
|
90457
|
+
!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
90458
|
((defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label)
|
|
90436
90459
|
? (0, lodash_1.template)(message_1.default.defaultPlaceHolder)({
|
|
90437
90460
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label,
|
|
@@ -90458,7 +90481,7 @@ var ComplexSearch = function (props) {
|
|
|
90458
90481
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
90459
90482
|
isFuzzy
|
|
90460
90483
|
? normalizeSuggestion(suggestions)
|
|
90461
|
-
: normalizeOptions(options), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90484
|
+
: normalizeOptions(options, prefixSelectMode), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90462
90485
|
renderSelectedFilter(),
|
|
90463
90486
|
renderSelectFilterCloseIcon())),
|
|
90464
90487
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('right-wrap'), ref: autoRef },
|
|
@@ -16,12 +16,35 @@ 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.value || o.dataIndex || o.label,
|
|
25
|
+
disabled: o.disabled,
|
|
26
|
+
children: formatOptionsChildren(o.children)
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
/**
|
|
20
32
|
*
|
|
21
33
|
* @param IRcSearchOptionsProps options
|
|
22
34
|
* @returns
|
|
23
35
|
*/
|
|
24
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
36
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
37
|
+
if (prefixSelectMode === 'cascader') {
|
|
38
|
+
return options.map(function (o) {
|
|
39
|
+
return {
|
|
40
|
+
label: o.label,
|
|
41
|
+
value: o.value || o.dataIndex || o.label,
|
|
42
|
+
disabled: o.disabled,
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
children: formatOptionsChildren(o.children)
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
25
48
|
var optionsCopy = cloneDeep(options);
|
|
26
49
|
optionsCopy.forEach(function (o) {
|
|
27
50
|
!o.groupName && (o.groupName = message.defaultFilterGroupName);
|
|
@@ -32,11 +55,11 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
32
55
|
children = _ref2[1];
|
|
33
56
|
return {
|
|
34
57
|
label: groupName,
|
|
35
|
-
value: groupName,
|
|
36
58
|
children: children.map(function (l) {
|
|
37
59
|
return {
|
|
38
60
|
label: l.label,
|
|
39
|
-
value: l.dataIndex
|
|
61
|
+
value: l.dataIndex,
|
|
62
|
+
disabled: l.disabled
|
|
40
63
|
};
|
|
41
64
|
})
|
|
42
65
|
};
|
|
@@ -330,7 +353,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
330
353
|
className: classNames('condition')
|
|
331
354
|
}, selectedFilterType ? /*#__PURE__*/React.createElement(SearchConditionSelectPrefix, {
|
|
332
355
|
type: prefixSelectMode,
|
|
333
|
-
dataSource: normalizeOptions(options),
|
|
356
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
334
357
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
335
358
|
defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
|
|
336
359
|
onChange: function onChange(value) {
|
|
@@ -342,7 +365,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
342
365
|
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/React.createElement(CascaderSelect, {
|
|
343
366
|
className: classNames('main-input', 'multi'),
|
|
344
367
|
hasBorder: false,
|
|
345
|
-
dataSource: normalizeOptions(options),
|
|
368
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
346
369
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? template(message.defaultPlaceHolder)({
|
|
347
370
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
348
371
|
}) : ''),
|
|
@@ -371,7 +394,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
371
394
|
dataSource:
|
|
372
395
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
373
396
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
374
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
397
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
375
398
|
popupStyle: {
|
|
376
399
|
width: 'auto'
|
|
377
400
|
},
|
|
@@ -25,12 +25,35 @@ 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.value || o.dataIndex || o.label,
|
|
34
|
+
disabled: o.disabled,
|
|
35
|
+
children: formatOptionsChildren(o.children)
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
/**
|
|
29
41
|
*
|
|
30
42
|
* @param IRcSearchOptionsProps options
|
|
31
43
|
* @returns
|
|
32
44
|
*/
|
|
33
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
45
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
46
|
+
if (prefixSelectMode === 'cascader') {
|
|
47
|
+
return options.map(function (o) {
|
|
48
|
+
return {
|
|
49
|
+
label: o.label,
|
|
50
|
+
value: o.value || o.dataIndex || o.label,
|
|
51
|
+
disabled: o.disabled,
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
children: formatOptionsChildren(o.children)
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
34
57
|
var optionsCopy = (0, _cloneDeep.default)(options);
|
|
35
58
|
optionsCopy.forEach(function (o) {
|
|
36
59
|
!o.groupName && (o.groupName = _message.default.defaultFilterGroupName);
|
|
@@ -41,11 +64,11 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
41
64
|
children = _ref2[1];
|
|
42
65
|
return {
|
|
43
66
|
label: groupName,
|
|
44
|
-
value: groupName,
|
|
45
67
|
children: children.map(function (l) {
|
|
46
68
|
return {
|
|
47
69
|
label: l.label,
|
|
48
|
-
value: l.dataIndex
|
|
70
|
+
value: l.dataIndex,
|
|
71
|
+
disabled: l.disabled
|
|
49
72
|
};
|
|
50
73
|
})
|
|
51
74
|
};
|
|
@@ -339,7 +362,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
339
362
|
className: (0, _classnames.default)('condition')
|
|
340
363
|
}, selectedFilterType ? /*#__PURE__*/_react.default.createElement(_InputPrefix.default, {
|
|
341
364
|
type: prefixSelectMode,
|
|
342
|
-
dataSource: normalizeOptions(options),
|
|
365
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
343
366
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
344
367
|
defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
|
|
345
368
|
onChange: function onChange(value) {
|
|
@@ -351,7 +374,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
351
374
|
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/_react.default.createElement(_consoleComponents.CascaderSelect, {
|
|
352
375
|
className: (0, _classnames.default)('main-input', 'multi'),
|
|
353
376
|
hasBorder: false,
|
|
354
|
-
dataSource: normalizeOptions(options),
|
|
377
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
355
378
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? (0, _lodash.template)(_message.default.defaultPlaceHolder)({
|
|
356
379
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
357
380
|
}) : ''),
|
|
@@ -380,7 +403,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
380
403
|
dataSource:
|
|
381
404
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
382
405
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
383
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
406
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
384
407
|
popupStyle: {
|
|
385
408
|
width: 'auto'
|
|
386
409
|
},
|