@alicloud/console-components-search 0.2.37-alpha.4 → 0.2.37-alpha.5
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/index.js +15 -12
- package/es/ComplexSearch/index.js +15 -12
- package/lib/ComplexSearch/index.js +15 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -90217,7 +90217,7 @@ function formatOptionsChildren(children) {
|
|
|
90217
90217
|
return children.map(function (o) {
|
|
90218
90218
|
return {
|
|
90219
90219
|
label: o.label,
|
|
90220
|
-
value: o.
|
|
90220
|
+
value: o.dataIndex || o.value || o.label,
|
|
90221
90221
|
disabled: o.disabled,
|
|
90222
90222
|
children: formatOptionsChildren(o.children),
|
|
90223
90223
|
};
|
|
@@ -90233,7 +90233,7 @@ var normalizeOptions = function (options, prefixSelectMode) {
|
|
|
90233
90233
|
return options.map(function (o) {
|
|
90234
90234
|
return {
|
|
90235
90235
|
label: o.label,
|
|
90236
|
-
value: o.
|
|
90236
|
+
value: o.dataIndex || o.value || o.label,
|
|
90237
90237
|
disabled: o.disabled,
|
|
90238
90238
|
// @ts-ignore
|
|
90239
90239
|
children: formatOptionsChildren(o.children),
|
|
@@ -90249,7 +90249,7 @@ var normalizeOptions = function (options, prefixSelectMode) {
|
|
|
90249
90249
|
children: children.map(function (l) {
|
|
90250
90250
|
return {
|
|
90251
90251
|
label: l.label,
|
|
90252
|
-
value: l.dataIndex,
|
|
90252
|
+
value: l.dataIndex || l.value,
|
|
90253
90253
|
disabled: l.disabled,
|
|
90254
90254
|
};
|
|
90255
90255
|
}),
|
|
@@ -90279,7 +90279,7 @@ var normalizeSelectDataSource = function (title, list) {
|
|
|
90279
90279
|
};
|
|
90280
90280
|
var normalizeSearchOptions = function (dataIndex, value, options) {
|
|
90281
90281
|
var _a, _b, _c;
|
|
90282
|
-
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) { return o
|
|
90282
|
+
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) { return getDataIndex(o) === dataIndex; });
|
|
90283
90283
|
var valueLabel = value;
|
|
90284
90284
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
90285
90285
|
valueLabel = (_b = (_a = opt.templateProps) === null || _a === void 0 ? void 0 : _a.dataSource.find(function (d) { return d.value === value; })) === null || _b === void 0 ? void 0 : _b.label;
|
|
@@ -90304,9 +90304,12 @@ var highlightKeyword = function (value, keywords) {
|
|
|
90304
90304
|
react_1.default.createElement("span", { style: { color: 'var(--color-brand1-6)' } }, highlightValue),
|
|
90305
90305
|
endValue));
|
|
90306
90306
|
};
|
|
90307
|
+
var getDataIndex = function (option) {
|
|
90308
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
90309
|
+
};
|
|
90307
90310
|
var ComplexSearch = function (props) {
|
|
90308
90311
|
var _a = props.options, options = _a === void 0 ? [] : _a, fuzzy = props.fuzzy, defaultDataIndex = props.defaultDataIndex, defaultSelectedDataIndex = props.defaultSelectedDataIndex, placeholder = props.placeholder, onSearch = props.onSearch, onSuggest = props.onSuggest, _b = props.suggestions, suggestions = _b === void 0 ? [] : _b, _c = props.prefix, prefix = _c === void 0 ? 'next-' : _c, _d = props.prefixSelectMode, prefixSelectMode = _d === void 0 ? 'select' : _d, prefixSelectItemRender = props.prefixSelectItemRender;
|
|
90309
|
-
var _e = (0, react_1.useState)(options.find(function (o) { return o
|
|
90312
|
+
var _e = (0, react_1.useState)(options.find(function (o) { return getDataIndex(o) === defaultSelectedDataIndex; })), selectedFilterType = _e[0], setSelectedFilterType = _e[1];
|
|
90310
90313
|
var _f = (0, react_1.useState)(false), focused = _f[0], setFocused = _f[1];
|
|
90311
90314
|
var autoRef = (0, react_1.useRef)(null);
|
|
90312
90315
|
var field = console_components_1.Field.useField();
|
|
@@ -90321,7 +90324,7 @@ var ComplexSearch = function (props) {
|
|
|
90321
90324
|
};
|
|
90322
90325
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
90323
90326
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(constants_1.SEARCH_FILTER_FIELD);
|
|
90324
|
-
var defaultFilter = options.find(function (t) { return t
|
|
90327
|
+
var defaultFilter = options.find(function (t) { return getDataIndex(t) === defaultDataIndex; });
|
|
90325
90328
|
var highlightItem = function (item, searchKey) {
|
|
90326
90329
|
var label = item.label;
|
|
90327
90330
|
if (searchKey && searchKey.length) {
|
|
@@ -90334,18 +90337,18 @@ var ComplexSearch = function (props) {
|
|
|
90334
90337
|
*/
|
|
90335
90338
|
var handlerFilterTypeChange = function (type, resetValue) {
|
|
90336
90339
|
if (resetValue === void 0) { resetValue = true; }
|
|
90337
|
-
setSelectedFilterType(options.find(function (o) { return o
|
|
90340
|
+
setSelectedFilterType(options.find(function (o) { return getDataIndex(o) === type; }));
|
|
90338
90341
|
resetValue && reset();
|
|
90339
90342
|
};
|
|
90340
90343
|
/**
|
|
90341
90344
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
90342
90345
|
*/
|
|
90343
|
-
var handlerFilterTypeInput = function (value, actionType,
|
|
90344
|
-
var isFuzzySearch =
|
|
90346
|
+
var handlerFilterTypeInput = function (value, actionType, _isFuzzy, option) {
|
|
90347
|
+
var isFuzzySearch = _isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
|
|
90345
90348
|
// 如果是模糊搜索,则直接处理
|
|
90346
90349
|
if (isFuzzySearch) {
|
|
90347
90350
|
if (actionType !== 'change') {
|
|
90348
|
-
handleSearch(option
|
|
90351
|
+
handleSearch(getDataIndex(option));
|
|
90349
90352
|
}
|
|
90350
90353
|
else {
|
|
90351
90354
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
@@ -90371,7 +90374,7 @@ var ComplexSearch = function (props) {
|
|
|
90371
90374
|
onSearch(getValue(constants_1.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(constants_1.SEARCH_FILTER_FIELD), options));
|
|
90372
90375
|
}
|
|
90373
90376
|
if (selectedFilterType) {
|
|
90374
|
-
onSearch(value, selectedFilterType
|
|
90377
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
90375
90378
|
}
|
|
90376
90379
|
}
|
|
90377
90380
|
reset();
|
|
@@ -90450,7 +90453,7 @@ var ComplexSearch = function (props) {
|
|
|
90450
90453
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
|
|
90451
90454
|
focus: focused,
|
|
90452
90455
|
}) },
|
|
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
|
|
90456
|
+
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: getDataIndex(selectedFilterType), onChange: function (value) {
|
|
90454
90457
|
handlerFilterTypeChange(value);
|
|
90455
90458
|
}, itemRender: prefixSelectItemRender })) : null),
|
|
90456
90459
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('forms') },
|
|
@@ -21,7 +21,7 @@ function formatOptionsChildren(children) {
|
|
|
21
21
|
return children.map(function (o) {
|
|
22
22
|
return {
|
|
23
23
|
label: o.label,
|
|
24
|
-
value: o.
|
|
24
|
+
value: o.dataIndex || o.value || o.label,
|
|
25
25
|
disabled: o.disabled,
|
|
26
26
|
children: formatOptionsChildren(o.children)
|
|
27
27
|
};
|
|
@@ -38,7 +38,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
|
38
38
|
return options.map(function (o) {
|
|
39
39
|
return {
|
|
40
40
|
label: o.label,
|
|
41
|
-
value: o.
|
|
41
|
+
value: o.dataIndex || o.value || o.label,
|
|
42
42
|
disabled: o.disabled,
|
|
43
43
|
// @ts-ignore
|
|
44
44
|
children: formatOptionsChildren(o.children)
|
|
@@ -58,7 +58,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
|
58
58
|
children: children.map(function (l) {
|
|
59
59
|
return {
|
|
60
60
|
label: l.label,
|
|
61
|
-
value: l.dataIndex,
|
|
61
|
+
value: l.dataIndex || l.value,
|
|
62
62
|
disabled: l.disabled
|
|
63
63
|
};
|
|
64
64
|
})
|
|
@@ -86,7 +86,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
86
86
|
};
|
|
87
87
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
88
88
|
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
|
|
89
|
-
return o
|
|
89
|
+
return getDataIndex(o) === dataIndex;
|
|
90
90
|
});
|
|
91
91
|
var valueLabel = value;
|
|
92
92
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
@@ -121,6 +121,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
121
121
|
}
|
|
122
122
|
}, highlightValue), endValue);
|
|
123
123
|
};
|
|
124
|
+
var getDataIndex = function getDataIndex(option) {
|
|
125
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
126
|
+
};
|
|
124
127
|
var ComplexSearch = function ComplexSearch(props) {
|
|
125
128
|
var _props$options = props.options,
|
|
126
129
|
options = _props$options === void 0 ? [] : _props$options,
|
|
@@ -138,7 +141,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
138
141
|
prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
|
|
139
142
|
prefixSelectItemRender = props.prefixSelectItemRender;
|
|
140
143
|
var _useState = useState(options.find(function (o) {
|
|
141
|
-
return o
|
|
144
|
+
return getDataIndex(o) === defaultSelectedDataIndex;
|
|
142
145
|
})),
|
|
143
146
|
_useState2 = _slicedToArray(_useState, 2),
|
|
144
147
|
selectedFilterType = _useState2[0],
|
|
@@ -164,7 +167,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
164
167
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
165
168
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
|
|
166
169
|
var defaultFilter = options.find(function (t) {
|
|
167
|
-
return t
|
|
170
|
+
return getDataIndex(t) === defaultDataIndex;
|
|
168
171
|
});
|
|
169
172
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
170
173
|
var label = item.label;
|
|
@@ -182,7 +185,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
182
185
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
183
186
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
184
187
|
setSelectedFilterType(options.find(function (o) {
|
|
185
|
-
return o
|
|
188
|
+
return getDataIndex(o) === type;
|
|
186
189
|
}));
|
|
187
190
|
resetValue && reset();
|
|
188
191
|
};
|
|
@@ -190,13 +193,13 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
190
193
|
/**
|
|
191
194
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
192
195
|
*/
|
|
193
|
-
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType,
|
|
194
|
-
var isFuzzySearch =
|
|
196
|
+
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
|
|
197
|
+
var isFuzzySearch = _isFuzzy && getValue(SEARCH_FILTER_FIELD);
|
|
195
198
|
|
|
196
199
|
// 如果是模糊搜索,则直接处理
|
|
197
200
|
if (isFuzzySearch) {
|
|
198
201
|
if (actionType !== 'change') {
|
|
199
|
-
handleSearch(option
|
|
202
|
+
handleSearch(getDataIndex(option));
|
|
200
203
|
} else {
|
|
201
204
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
202
205
|
}
|
|
@@ -222,7 +225,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
222
225
|
onSearch(getValue(SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(SEARCH_FILTER_FIELD), options));
|
|
223
226
|
}
|
|
224
227
|
if (selectedFilterType) {
|
|
225
|
-
onSearch(value, selectedFilterType
|
|
228
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
reset();
|
|
@@ -355,7 +358,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
355
358
|
type: prefixSelectMode,
|
|
356
359
|
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
357
360
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
358
|
-
defaultValue: selectedFilterType
|
|
361
|
+
defaultValue: getDataIndex(selectedFilterType),
|
|
359
362
|
onChange: function onChange(value) {
|
|
360
363
|
handlerFilterTypeChange(value);
|
|
361
364
|
},
|
|
@@ -30,7 +30,7 @@ function formatOptionsChildren(children) {
|
|
|
30
30
|
return children.map(function (o) {
|
|
31
31
|
return {
|
|
32
32
|
label: o.label,
|
|
33
|
-
value: o.
|
|
33
|
+
value: o.dataIndex || o.value || o.label,
|
|
34
34
|
disabled: o.disabled,
|
|
35
35
|
children: formatOptionsChildren(o.children)
|
|
36
36
|
};
|
|
@@ -47,7 +47,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
|
47
47
|
return options.map(function (o) {
|
|
48
48
|
return {
|
|
49
49
|
label: o.label,
|
|
50
|
-
value: o.
|
|
50
|
+
value: o.dataIndex || o.value || o.label,
|
|
51
51
|
disabled: o.disabled,
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
children: formatOptionsChildren(o.children)
|
|
@@ -67,7 +67,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
|
67
67
|
children: children.map(function (l) {
|
|
68
68
|
return {
|
|
69
69
|
label: l.label,
|
|
70
|
-
value: l.dataIndex,
|
|
70
|
+
value: l.dataIndex || l.value,
|
|
71
71
|
disabled: l.disabled
|
|
72
72
|
};
|
|
73
73
|
})
|
|
@@ -95,7 +95,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
95
95
|
};
|
|
96
96
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
97
97
|
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
|
|
98
|
-
return o
|
|
98
|
+
return getDataIndex(o) === dataIndex;
|
|
99
99
|
});
|
|
100
100
|
var valueLabel = value;
|
|
101
101
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
@@ -130,6 +130,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
130
130
|
}
|
|
131
131
|
}, highlightValue), endValue);
|
|
132
132
|
};
|
|
133
|
+
var getDataIndex = function getDataIndex(option) {
|
|
134
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
135
|
+
};
|
|
133
136
|
var ComplexSearch = function ComplexSearch(props) {
|
|
134
137
|
var _props$options = props.options,
|
|
135
138
|
options = _props$options === void 0 ? [] : _props$options,
|
|
@@ -147,7 +150,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
147
150
|
prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
|
|
148
151
|
prefixSelectItemRender = props.prefixSelectItemRender;
|
|
149
152
|
var _useState = (0, _react.useState)(options.find(function (o) {
|
|
150
|
-
return o
|
|
153
|
+
return getDataIndex(o) === defaultSelectedDataIndex;
|
|
151
154
|
})),
|
|
152
155
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
153
156
|
selectedFilterType = _useState2[0],
|
|
@@ -173,7 +176,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
173
176
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
174
177
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(_constants.SEARCH_FILTER_FIELD);
|
|
175
178
|
var defaultFilter = options.find(function (t) {
|
|
176
|
-
return t
|
|
179
|
+
return getDataIndex(t) === defaultDataIndex;
|
|
177
180
|
});
|
|
178
181
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
179
182
|
var label = item.label;
|
|
@@ -191,7 +194,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
191
194
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
192
195
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
193
196
|
setSelectedFilterType(options.find(function (o) {
|
|
194
|
-
return o
|
|
197
|
+
return getDataIndex(o) === type;
|
|
195
198
|
}));
|
|
196
199
|
resetValue && reset();
|
|
197
200
|
};
|
|
@@ -199,13 +202,13 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
199
202
|
/**
|
|
200
203
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
201
204
|
*/
|
|
202
|
-
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType,
|
|
203
|
-
var isFuzzySearch =
|
|
205
|
+
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
|
|
206
|
+
var isFuzzySearch = _isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
|
|
204
207
|
|
|
205
208
|
// 如果是模糊搜索,则直接处理
|
|
206
209
|
if (isFuzzySearch) {
|
|
207
210
|
if (actionType !== 'change') {
|
|
208
|
-
handleSearch(option
|
|
211
|
+
handleSearch(getDataIndex(option));
|
|
209
212
|
} else {
|
|
210
213
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
211
214
|
}
|
|
@@ -231,7 +234,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
231
234
|
onSearch(getValue(_constants.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(_constants.SEARCH_FILTER_FIELD), options));
|
|
232
235
|
}
|
|
233
236
|
if (selectedFilterType) {
|
|
234
|
-
onSearch(value, selectedFilterType
|
|
237
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
reset();
|
|
@@ -364,7 +367,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
364
367
|
type: prefixSelectMode,
|
|
365
368
|
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
366
369
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
367
|
-
defaultValue: selectedFilterType
|
|
370
|
+
defaultValue: getDataIndex(selectedFilterType),
|
|
368
371
|
onChange: function onChange(value) {
|
|
369
372
|
handlerFilterTypeChange(value);
|
|
370
373
|
},
|