@alicloud/console-components-search 0.2.33 → 0.2.35
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/LICENSE +21 -0
- package/es/ComplexSearch/InputPrefix.js +6 -9
- package/es/ComplexSearch/index.js +46 -84
- package/es/constants.js +3 -1
- package/es/index.js +4 -4
- package/es/message.js +16 -17
- package/es/search.js +11 -18
- package/es/searchTagList/PureTag.js +10 -15
- package/es/searchTagList/index.js +27 -47
- package/es/style.js +13 -11
- package/es/types/IRcSearchOptions.type.js +1 -0
- package/es/types/IRcSearchProps.type.js +1 -0
- package/es/types/IRcSearchTagItemProps.type.js +1 -0
- package/es/types/IRcSearchTagListProps.type.js +1 -0
- package/es/useCssVar.js +6 -11
- package/es/utils.js +9 -41
- package/lib/ComplexSearch/InputPrefix.d.ts +2 -2
- package/lib/ComplexSearch/InputPrefix.js +7 -16
- package/lib/ComplexSearch/index.js +50 -107
- package/lib/constants.js +7 -9
- package/lib/index.d.ts +5 -5
- package/lib/index.js +10 -17
- package/lib/message.js +17 -22
- package/lib/search.d.ts +2 -2
- package/lib/search.js +9 -28
- package/lib/searchTagList/PureTag.js +11 -23
- package/lib/searchTagList/index.d.ts +1 -1
- package/lib/searchTagList/index.js +23 -57
- package/lib/style.d.ts +1 -1
- package/lib/style.js +13 -24
- package/lib/types/IRcSearchOptions.type.d.ts +13 -13
- package/lib/types/IRcSearchOptions.type.js +5 -1
- package/lib/types/IRcSearchProps.type.d.ts +2 -2
- package/lib/types/IRcSearchProps.type.js +5 -1
- package/lib/types/IRcSearchTagItemProps.type.js +5 -1
- package/lib/types/IRcSearchTagListProps.type.js +5 -1
- package/lib/useCssVar.js +6 -19
- package/lib/utils.d.ts +1 -3
- package/lib/utils.js +18 -72
- package/package.json +19 -16
- package/dist/index.css +0 -73
- package/dist/index.js +0 -135343
- package/doc-dist/0.js +0 -2094
- package/doc-dist/1.js +0 -27
- package/doc-dist/10.js +0 -6
- package/doc-dist/11.js +0 -6
- package/doc-dist/12.js +0 -6
- package/doc-dist/13.js +0 -6
- package/doc-dist/14.js +0 -6
- package/doc-dist/15.js +0 -6
- package/doc-dist/16.js +0 -6
- package/doc-dist/3.js +0 -89
- package/doc-dist/4.js +0 -6
- package/doc-dist/5.js +0 -13
- package/doc-dist/6.css +0 -1
- package/doc-dist/6.js +0 -6
- package/doc-dist/6.os.css +0 -1
- package/doc-dist/7.js +0 -6
- package/doc-dist/8.js +0 -6
- package/doc-dist/9.js +0 -6
- package/doc-dist/console-fe-test-rc-search-doc.manifest.json +0 -38
- package/doc-dist/deps/console-fe-test-rc-search-doc-deps.manifest.json +0 -33
- package/doc-dist/deps/index.html +0 -14
- package/doc-dist/deps/main.css +0 -1
- package/doc-dist/deps/main.js +0 -103
- package/doc-dist/deps/main.os.css +0 -1
- package/doc-dist/index.css +0 -1
- package/doc-dist/index.html +0 -14
- package/doc-dist/index.js +0 -19
- package/doc-dist/index.os.css +0 -1
- package/doc-dist/log-deps-build.log +0 -19
- package/es/provider/LoggerProvider.js +0 -37
- package/lib/provider/LoggerProvider.d.ts +0 -8
- package/lib/provider/LoggerProvider.js +0 -47
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Alibaba Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["defaultValue", "dataSource", "label"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
6
|
import { Icon, Select } from '@alicloud/console-components';
|
|
6
|
-
|
|
7
7
|
var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
8
8
|
var _dataSource$, _dataSource$$children;
|
|
9
|
-
|
|
10
9
|
var defaultValue = props.defaultValue,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
_props$dataSource = props.dataSource,
|
|
11
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
12
|
+
label = props.label,
|
|
13
|
+
reset = _objectWithoutProperties(props, _excluded);
|
|
16
14
|
var noSelect = dataSource.length < 2 && ((_dataSource$ = dataSource[0]) === null || _dataSource$ === void 0 ? void 0 : (_dataSource$$children = _dataSource$.children) === null || _dataSource$$children === void 0 ? void 0 : _dataSource$$children.length) < 2;
|
|
17
15
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
16
|
className: classNames('condition-item')
|
|
@@ -32,7 +30,7 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
32
30
|
dataSource: dataSource,
|
|
33
31
|
itemRender: function itemRender(_ref) {
|
|
34
32
|
var label = _ref.label,
|
|
35
|
-
|
|
33
|
+
value = _ref.value;
|
|
36
34
|
return /*#__PURE__*/React.createElement("span", {
|
|
37
35
|
"data-value": value
|
|
38
36
|
}, label);
|
|
@@ -42,5 +40,4 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
42
40
|
popupClassName: "rc-search-prefix"
|
|
43
41
|
})));
|
|
44
42
|
};
|
|
45
|
-
|
|
46
43
|
export default SearchConditionSelectPrefix;
|
|
@@ -2,11 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
-
|
|
5
|
+
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; }
|
|
6
|
+
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) { _defineProperty(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; }
|
|
10
7
|
import classNames from 'classnames';
|
|
11
8
|
import cloneDeep from 'lodash/cloneDeep';
|
|
12
9
|
import groupBy from 'lodash/groupBy';
|
|
@@ -24,17 +21,15 @@ var AutoComplete = Select.AutoComplete;
|
|
|
24
21
|
* @param IRcSearchOptionsProps options
|
|
25
22
|
* @returns
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
24
|
var normalizeOptions = function normalizeOptions(options) {
|
|
29
25
|
var optionsCopy = cloneDeep(options);
|
|
30
26
|
optionsCopy.forEach(function (o) {
|
|
31
|
-
|
|
27
|
+
!o.groupName && (o.groupName = message.defaultFilterGroupName);
|
|
32
28
|
});
|
|
33
29
|
return Object.entries(groupBy(optionsCopy, 'groupName')).map(function (_ref) {
|
|
34
30
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
groupName = _ref2[0],
|
|
32
|
+
children = _ref2[1];
|
|
38
33
|
return {
|
|
39
34
|
label: groupName,
|
|
40
35
|
children: children.map(function (l) {
|
|
@@ -46,7 +41,6 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
46
41
|
};
|
|
47
42
|
});
|
|
48
43
|
};
|
|
49
|
-
|
|
50
44
|
var normalizeSuggestion = function normalizeSuggestion(suggestion) {
|
|
51
45
|
var suggestionCopy = cloneDeep(suggestion);
|
|
52
46
|
suggestionCopy.forEach(function (s) {
|
|
@@ -60,38 +54,31 @@ var normalizeSuggestion = function normalizeSuggestion(suggestion) {
|
|
|
60
54
|
});
|
|
61
55
|
return suggestionCopy;
|
|
62
56
|
};
|
|
63
|
-
|
|
64
57
|
var normalizeSelectDataSource = function normalizeSelectDataSource(title, list) {
|
|
65
58
|
return [{
|
|
66
59
|
label: title || '',
|
|
67
60
|
children: _toConsumableArray(list)
|
|
68
61
|
}];
|
|
69
62
|
};
|
|
70
|
-
|
|
71
63
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
72
64
|
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
|
|
73
65
|
return o.dataIndex === dataIndex;
|
|
74
66
|
});
|
|
75
67
|
var valueLabel = value;
|
|
76
|
-
|
|
77
68
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
78
69
|
var _opt$templateProps, _opt$templateProps$da;
|
|
79
|
-
|
|
80
70
|
valueLabel = (_opt$templateProps = opt.templateProps) === null || _opt$templateProps === void 0 ? void 0 : (_opt$templateProps$da = _opt$templateProps.dataSource.find(function (d) {
|
|
81
71
|
return d.value === value;
|
|
82
72
|
})) === null || _opt$templateProps$da === void 0 ? void 0 : _opt$templateProps$da.label;
|
|
83
73
|
}
|
|
84
|
-
|
|
85
74
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
86
75
|
var _opt$templateProps2;
|
|
87
|
-
|
|
88
76
|
valueLabel = (_opt$templateProps2 = opt.templateProps) === null || _opt$templateProps2 === void 0 ? void 0 : _opt$templateProps2.dataSource.filter(function (d) {
|
|
89
77
|
return value === null || value === void 0 ? void 0 : value.includes(d.value);
|
|
90
78
|
}).map(function (d) {
|
|
91
79
|
return d.label;
|
|
92
80
|
}).join('/');
|
|
93
81
|
}
|
|
94
|
-
|
|
95
82
|
return {
|
|
96
83
|
label: opt === null || opt === void 0 ? void 0 : opt.label,
|
|
97
84
|
valueLabel: valueLabel,
|
|
@@ -99,7 +86,6 @@ var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, o
|
|
|
99
86
|
dataIndex: dataIndex
|
|
100
87
|
};
|
|
101
88
|
};
|
|
102
|
-
|
|
103
89
|
var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
104
90
|
var idx = value.toLowerCase().indexOf(keywords.toLowerCase());
|
|
105
91
|
var startValue = value.slice(0, idx);
|
|
@@ -111,39 +97,34 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
111
97
|
}
|
|
112
98
|
}, highlightValue), endValue);
|
|
113
99
|
};
|
|
114
|
-
|
|
115
100
|
var ComplexSearch = function ComplexSearch(props) {
|
|
116
101
|
var _props$options = props.options,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
102
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
103
|
+
fuzzy = props.fuzzy,
|
|
104
|
+
defaultDataIndex = props.defaultDataIndex,
|
|
105
|
+
defaultSelectedDataIndex = props.defaultSelectedDataIndex,
|
|
106
|
+
placeholder = props.placeholder,
|
|
107
|
+
onSearch = props.onSearch,
|
|
108
|
+
onSuggest = props.onSuggest,
|
|
109
|
+
_props$suggestions = props.suggestions,
|
|
110
|
+
suggestions = _props$suggestions === void 0 ? [] : _props$suggestions,
|
|
111
|
+
_props$prefix = props.prefix,
|
|
112
|
+
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix;
|
|
129
113
|
var _useState = useState(options.find(function (o) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
114
|
+
return o.dataIndex === defaultSelectedDataIndex;
|
|
115
|
+
})),
|
|
116
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
117
|
+
selectedFilterType = _useState2[0],
|
|
118
|
+
setSelectedFilterType = _useState2[1];
|
|
136
119
|
var _useState3 = useState(false),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
120
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
121
|
+
focused = _useState4[0],
|
|
122
|
+
setFocused = _useState4[1];
|
|
141
123
|
var autoRef = useRef(null);
|
|
142
|
-
var fuzzyAutoRef = useRef(null);
|
|
143
124
|
var field = Field.useField();
|
|
144
125
|
var init = field.init,
|
|
145
|
-
|
|
146
|
-
|
|
126
|
+
getValue = field.getValue,
|
|
127
|
+
reset = field.reset;
|
|
147
128
|
var focusProps = {
|
|
148
129
|
onFocus: function onFocus() {
|
|
149
130
|
setFocused(true);
|
|
@@ -151,29 +132,26 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
151
132
|
onBlur: function onBlur() {
|
|
152
133
|
setFocused(false);
|
|
153
134
|
}
|
|
154
|
-
};
|
|
135
|
+
};
|
|
155
136
|
|
|
137
|
+
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
156
138
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
|
|
157
139
|
var defaultFilter = options.find(function (t) {
|
|
158
140
|
return t.dataIndex === defaultDataIndex;
|
|
159
141
|
});
|
|
160
|
-
|
|
161
142
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
162
143
|
var label = item.label;
|
|
163
|
-
|
|
164
144
|
if (searchKey && searchKey.length) {
|
|
165
145
|
label = highlightKeyword(item.label, searchKey);
|
|
166
146
|
}
|
|
167
|
-
|
|
168
147
|
return /*#__PURE__*/React.createElement("span", {
|
|
169
148
|
"data-value": item === null || item === void 0 ? void 0 : item.value
|
|
170
149
|
}, label);
|
|
171
150
|
};
|
|
151
|
+
|
|
172
152
|
/**
|
|
173
153
|
* 处理筛选类型选中的情况
|
|
174
154
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
155
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
178
156
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
179
157
|
setSelectedFilterType(options.find(function (o) {
|
|
@@ -181,67 +159,58 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
181
159
|
}));
|
|
182
160
|
resetValue && reset();
|
|
183
161
|
};
|
|
162
|
+
|
|
184
163
|
/**
|
|
185
164
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
186
165
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
166
|
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
|
|
190
|
-
var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD);
|
|
167
|
+
var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD);
|
|
191
168
|
|
|
169
|
+
// 如果是模糊搜索,则直接处理
|
|
192
170
|
if (isFuzzySearch) {
|
|
193
171
|
if (actionType !== 'change') {
|
|
194
172
|
handleSearch(option.dataIndex);
|
|
195
173
|
} else {
|
|
196
174
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
197
175
|
}
|
|
198
|
-
|
|
199
176
|
return;
|
|
200
|
-
}
|
|
201
|
-
|
|
177
|
+
}
|
|
202
178
|
|
|
179
|
+
// 否则处理筛选项改变的情况
|
|
203
180
|
handlerFilterTypeChange(value, false);
|
|
204
181
|
};
|
|
205
|
-
|
|
206
182
|
var handlerFilterClear = function handlerFilterClear() {
|
|
207
183
|
setSelectedFilterType(null);
|
|
208
184
|
reset();
|
|
209
185
|
};
|
|
210
|
-
|
|
211
186
|
var handleSearch = function handleSearch(dataIndex) {
|
|
212
187
|
if (onSearch) {
|
|
213
|
-
var value = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
214
|
-
|
|
188
|
+
var value = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
189
|
+
// 如果是没有选择下拉
|
|
215
190
|
if (defaultDataIndex && !selectedFilterType) {
|
|
216
191
|
onSearch(getValue(SEARCH_FILTER_FIELD), defaultDataIndex, normalizeSearchOptions(defaultDataIndex, getValue(SEARCH_FILTER_FIELD), options));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
192
|
+
}
|
|
193
|
+
// 如果是用户没有指定 defaultDataIndex 但是设置了 fuzzy
|
|
220
194
|
if (fuzzy && !selectedFilterType) {
|
|
221
195
|
onSearch(getValue(SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(SEARCH_FILTER_FIELD), options));
|
|
222
196
|
}
|
|
223
|
-
|
|
224
197
|
if (selectedFilterType) {
|
|
225
198
|
onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
|
|
226
199
|
}
|
|
227
200
|
}
|
|
228
|
-
|
|
229
201
|
reset();
|
|
230
202
|
document.body.click();
|
|
231
203
|
setFocused(false);
|
|
232
204
|
};
|
|
233
|
-
|
|
234
205
|
var handleKeyUp = function handleKeyUp(e) {
|
|
235
206
|
if (e.keyCode === 13 && e.currentTarget.value) {
|
|
236
207
|
handleSearch();
|
|
237
208
|
document.body.click();
|
|
238
209
|
}
|
|
239
|
-
|
|
240
210
|
if (e.keyCode === 8 && !e.currentTarget.value) {
|
|
241
211
|
handlerFilterClear();
|
|
242
212
|
}
|
|
243
213
|
};
|
|
244
|
-
|
|
245
214
|
var renderMultipleSelectorItem = function renderMultipleSelectorItem(item) {
|
|
246
215
|
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
247
216
|
var checked = isArray(searchValue) && searchValue.some(function (v) {
|
|
@@ -251,13 +220,10 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
251
220
|
checked: checked
|
|
252
221
|
}, item.label);
|
|
253
222
|
};
|
|
254
|
-
|
|
255
223
|
var renderSelectedFilter = function renderSelectedFilter() {
|
|
256
224
|
var _selectedFilterType$t, _selectedFilterType$t2, _selectedFilterType$t3;
|
|
257
|
-
|
|
258
225
|
var type = selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template;
|
|
259
226
|
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
260
|
-
|
|
261
227
|
var props = _objectSpread({
|
|
262
228
|
hasBorder: false,
|
|
263
229
|
autoFocus: true,
|
|
@@ -267,7 +233,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
267
233
|
value: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label
|
|
268
234
|
})
|
|
269
235
|
}, focusProps);
|
|
270
|
-
|
|
271
236
|
var selectProps = {
|
|
272
237
|
dataSource: normalizeSelectDataSource(selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, (selectedFilterType === null || selectedFilterType === void 0 ? void 0 : (_selectedFilterType$t2 = selectedFilterType.templateProps) === null || _selectedFilterType$t2 === void 0 ? void 0 : _selectedFilterType$t2.dataSource) || []),
|
|
273
238
|
defaultVisible: true,
|
|
@@ -275,11 +240,11 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
275
240
|
width: 'auto'
|
|
276
241
|
}
|
|
277
242
|
};
|
|
278
|
-
|
|
279
243
|
switch (type) {
|
|
280
244
|
case 'input':
|
|
281
245
|
return /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_VALUE_FIELD, {}), {
|
|
282
|
-
className: classNames('main-input', 'multi')
|
|
246
|
+
className: classNames('main-input', 'multi')
|
|
247
|
+
// @ts-ignore
|
|
283
248
|
,
|
|
284
249
|
autoHighlightFirstItem: false
|
|
285
250
|
}, props, {
|
|
@@ -287,7 +252,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
287
252
|
onKeyUp: handleKeyUp,
|
|
288
253
|
dataSource: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : (_selectedFilterType$t3 = selectedFilterType.templateProps) === null || _selectedFilterType$t3 === void 0 ? void 0 : _selectedFilterType$t3.dataSource
|
|
289
254
|
}));
|
|
290
|
-
|
|
291
255
|
case 'select':
|
|
292
256
|
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
293
257
|
className: classNames('main-input', 'select')
|
|
@@ -299,14 +263,14 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
299
263
|
// @ts-ignore
|
|
300
264
|
autoHighlightFirstItem: false
|
|
301
265
|
}, props, selectProps));
|
|
302
|
-
|
|
303
266
|
case 'multiple':
|
|
304
267
|
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
305
268
|
className: classNames('main-input', 'multi')
|
|
306
269
|
}, init(SEARCH_FILTER_VALUE_FIELD, {}), props, selectProps, {
|
|
307
270
|
itemRender: renderMultipleSelectorItem,
|
|
308
271
|
popupClassName: "xconsole-rcsearch-multi-pop",
|
|
309
|
-
mode: "multiple"
|
|
272
|
+
mode: "multiple"
|
|
273
|
+
// @ts-ignore
|
|
310
274
|
,
|
|
311
275
|
autoHighlightFirstItem: false,
|
|
312
276
|
maxTagCount: 0,
|
|
@@ -332,12 +296,10 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
332
296
|
}, message.cancel))
|
|
333
297
|
}
|
|
334
298
|
}));
|
|
335
|
-
|
|
336
299
|
default:
|
|
337
300
|
return null;
|
|
338
301
|
}
|
|
339
302
|
};
|
|
340
|
-
|
|
341
303
|
var renderSelectFilterCloseIcon = function renderSelectFilterCloseIcon() {
|
|
342
304
|
var hasFilterTypeClearBtn = !!selectedFilterType && !((selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template) === 'input' && !!getValue(SEARCH_FILTER_VALUE_FIELD));
|
|
343
305
|
return hasFilterTypeClearBtn && /*#__PURE__*/React.createElement("div", {
|
|
@@ -354,7 +316,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
354
316
|
}
|
|
355
317
|
}))));
|
|
356
318
|
};
|
|
357
|
-
|
|
358
319
|
return /*#__PURE__*/React.createElement(SearchWarp, {
|
|
359
320
|
prefix: prefix
|
|
360
321
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -380,7 +341,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
380
341
|
}
|
|
381
342
|
}
|
|
382
343
|
}), {
|
|
383
|
-
autoHighlightFirstItem: false
|
|
344
|
+
autoHighlightFirstItem: false
|
|
345
|
+
// @ts-ignore
|
|
384
346
|
,
|
|
385
347
|
itemRender: highlightItem,
|
|
386
348
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? template(message.defaultPlaceHolder)({
|
|
@@ -389,7 +351,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
389
351
|
className: classNames('main-input', 'multi'),
|
|
390
352
|
hasBorder: false,
|
|
391
353
|
onKeyUp: handleKeyUp,
|
|
392
|
-
dataSource:
|
|
354
|
+
dataSource:
|
|
355
|
+
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
393
356
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
394
357
|
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
395
358
|
popupStyle: {
|
|
@@ -410,5 +373,4 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
410
373
|
type: "search"
|
|
411
374
|
}))));
|
|
412
375
|
};
|
|
413
|
-
|
|
414
376
|
export default ConfigProvider.config(ComplexSearch);
|
package/es/constants.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export var baseClassName = 'rc-search';
|
|
2
|
-
export var baseTagListClassName = "".concat(baseClassName, "-taglist");
|
|
2
|
+
export var baseTagListClassName = "".concat(baseClassName, "-taglist");
|
|
3
|
+
|
|
4
|
+
// export const titleClassName = `${baseClassName}-title`
|
|
3
5
|
// export const titleContainerClassName = `${titleClassName}-container`
|
|
4
6
|
// export const titleExtraClassName = `${titleClassName}-extra`
|
|
5
7
|
// export const titleChildrenClassName = `${titleClassName}-children`
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Search } from
|
|
2
|
-
import SearchTagList from
|
|
3
|
-
import { IRcSearchProps } from
|
|
4
|
-
import { IRcSearchTagListProps } from
|
|
1
|
+
import { Search } from './search';
|
|
2
|
+
import SearchTagList from './searchTagList';
|
|
3
|
+
import { IRcSearchProps } from './types/IRcSearchProps.type';
|
|
4
|
+
import { IRcSearchTagListProps } from './types/IRcSearchTagListProps.type';
|
|
5
5
|
import { IRcSearchTagItemProps } from './types/IRcSearchTagItemProps.type';
|
|
6
6
|
import { IRcSearchOptionsProps } from './types/IRcSearchOptions.type';
|
|
7
7
|
export { Search, SearchTagList as SearchFilter, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|
package/es/message.js
CHANGED
|
@@ -1,52 +1,51 @@
|
|
|
1
1
|
import Cookie from 'js-cookie';
|
|
2
2
|
var isSSR = typeof document === 'undefined';
|
|
3
3
|
var messages = {
|
|
4
|
-
|
|
4
|
+
zh: {
|
|
5
5
|
confirm: '确定',
|
|
6
6
|
cancel: '取消',
|
|
7
7
|
allValue: '全部值',
|
|
8
8
|
emptyValue: '空值',
|
|
9
|
-
tag:
|
|
10
|
-
defaultFilterGroupName:
|
|
9
|
+
tag: '标签',
|
|
10
|
+
defaultFilterGroupName: '选择筛选条件',
|
|
11
11
|
defaultPlaceHolder: '默认按${value}搜索',
|
|
12
12
|
clearFilter: '清除筛选条件'
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
en: {
|
|
15
15
|
confirm: 'OK',
|
|
16
16
|
cancel: 'Cancel',
|
|
17
17
|
allValue: 'All Values',
|
|
18
18
|
emptyValue: 'Empty',
|
|
19
|
-
tag:
|
|
20
|
-
defaultFilterGroupName:
|
|
19
|
+
tag: 'Tag',
|
|
20
|
+
defaultFilterGroupName: 'Select Filter Condition',
|
|
21
21
|
defaultPlaceHolder: 'Search By ${value}',
|
|
22
22
|
clearFilter: 'Clear Filter Condition'
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
'zh-TW': {
|
|
25
25
|
confirm: '確定',
|
|
26
26
|
cancel: '取消',
|
|
27
27
|
allValue: '全部值',
|
|
28
28
|
emptyValue: '空值',
|
|
29
|
-
tag:
|
|
30
|
-
defaultFilterGroupName:
|
|
29
|
+
tag: '標籤',
|
|
30
|
+
defaultFilterGroupName: '選擇篩選條件',
|
|
31
31
|
defaultPlaceHolder: '默認按${value}搜索',
|
|
32
32
|
clearFilter: '清除篩選條件'
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
ja: {
|
|
35
35
|
confirm: 'OK',
|
|
36
36
|
cancel: 'キャンセル',
|
|
37
37
|
allValue: 'すべての値',
|
|
38
38
|
emptyValue: '空',
|
|
39
|
-
tag:
|
|
40
|
-
defaultFilterGroupName:
|
|
39
|
+
tag: 'タグ',
|
|
40
|
+
defaultFilterGroupName: 'フィルタリング条件の選択',
|
|
41
41
|
defaultPlaceHolder: '${value} で検索',
|
|
42
42
|
clearFilter: 'フィルタリング条件のクリア'
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
var lang = isSSR ? '
|
|
46
|
-
|
|
45
|
+
var lang = isSSR ? 'zh' : Cookie.get('aliyun_lang') || 'zh';
|
|
47
46
|
if (!Object.keys(messages).includes(lang)) {
|
|
48
|
-
lang = '
|
|
49
|
-
}
|
|
50
|
-
|
|
47
|
+
lang = 'zh';
|
|
48
|
+
}
|
|
51
49
|
|
|
50
|
+
// @ts-ignore
|
|
52
51
|
export default messages[lang];
|
package/es/search.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var _templateObject;
|
|
4
|
-
|
|
5
|
-
import React from "react";
|
|
1
|
+
import React from 'react';
|
|
6
2
|
import classNames from 'classnames';
|
|
7
|
-
import styled from
|
|
3
|
+
import styled from 'styled-components';
|
|
8
4
|
import { baseClassName } from './constants';
|
|
9
|
-
import ComplexSearch from
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import ComplexSearch from './ComplexSearch/index';
|
|
6
|
+
import { useWindTheme } from './useCssVar';
|
|
7
|
+
var SearchWrap = styled.div.withConfig({
|
|
8
|
+
componentId: "sc-1szhzw4-0"
|
|
9
|
+
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
13
10
|
export var Search = function Search(props) {
|
|
14
11
|
var className = props.className,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
_props$simple = props.simple,
|
|
13
|
+
simple = _props$simple === void 0 ? false : _props$simple,
|
|
14
|
+
style = props.style;
|
|
18
15
|
var windThemeClass = useWindTheme();
|
|
19
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
20
|
-
regionId: props.regionId,
|
|
21
|
-
resourceType: props.resourceType || '',
|
|
22
|
-
componentName: "RcSearch"
|
|
23
|
-
}), /*#__PURE__*/React.createElement(SearchWrap, {
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchWrap, {
|
|
24
17
|
className: classNames(baseClassName, className, windThemeClass),
|
|
25
18
|
style: style
|
|
26
19
|
}, /*#__PURE__*/React.createElement(ComplexSearch, props)));
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["intl", "tagKey", "disableTruncate", "showDot", "tagValue", "showLabel", "closable"];
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { Tag, Badge } from '@alicloud/console-components';
|
|
5
6
|
import Truncate from '@alicloud/console-components-truncate';
|
|
6
7
|
import message from '../message';
|
|
7
|
-
|
|
8
8
|
var Empty = function Empty(_ref) {
|
|
9
9
|
var children = _ref.children;
|
|
10
10
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
var PureTag = function PureTag(props) {
|
|
14
13
|
var intl = props.intl,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
tagKey = props.tagKey,
|
|
15
|
+
disableTruncate = props.disableTruncate,
|
|
16
|
+
showDot = props.showDot,
|
|
17
|
+
tagValue = props.tagValue,
|
|
18
|
+
showLabel = props.showLabel,
|
|
19
|
+
_props$closable = props.closable,
|
|
20
|
+
closable = _props$closable === void 0 ? true : _props$closable,
|
|
21
|
+
resetProps = _objectWithoutProperties(props, _excluded);
|
|
24
22
|
var defaultTruncateProps = {
|
|
25
23
|
threshold: 20,
|
|
26
24
|
showTooltip: false
|
|
@@ -29,16 +27,14 @@ var PureTag = function PureTag(props) {
|
|
|
29
27
|
var DotWrapper = showDot ? Badge : Empty;
|
|
30
28
|
var TagWrapper = closable ? Tag.Closeable : Tag;
|
|
31
29
|
var transformedTagValue = tagValue;
|
|
32
|
-
|
|
33
30
|
if (tagValue === '') {
|
|
34
31
|
transformedTagValue = message.emptyValue;
|
|
35
32
|
} else if (tagValue === undefined || tagValue === null) {
|
|
36
33
|
transformedTagValue = message.allValue;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
return (
|
|
40
36
|
/*#__PURE__*/
|
|
41
|
-
|
|
37
|
+
// @ts-ignore
|
|
42
38
|
React.createElement(DotWrapper, {
|
|
43
39
|
className: "search-tags-tag-dot",
|
|
44
40
|
dot: true
|
|
@@ -52,5 +48,4 @@ var PureTag = function PureTag(props) {
|
|
|
52
48
|
}, transformedTagValue)))
|
|
53
49
|
);
|
|
54
50
|
};
|
|
55
|
-
|
|
56
51
|
export default PureTag;
|