@alicloud/console-components-search 0.2.34 → 0.2.36
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/dist/index.js +99108 -107888
- 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 +16 -37
- 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 +12 -48
- 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 +20 -16
- 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
|
@@ -1,65 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
-
|
|
18
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
-
|
|
20
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
-
|
|
22
14
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
23
|
-
|
|
24
15
|
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
|
|
25
|
-
|
|
26
16
|
var _isArray = _interopRequireDefault(require("lodash/isArray"));
|
|
27
|
-
|
|
28
17
|
var _react = _interopRequireWildcard(require("react"));
|
|
29
|
-
|
|
30
18
|
var _consoleComponents = require("@alicloud/console-components");
|
|
31
|
-
|
|
32
19
|
var _lodash = require("lodash");
|
|
33
|
-
|
|
34
20
|
var _style = require("../style");
|
|
35
|
-
|
|
36
21
|
var _InputPrefix = _interopRequireDefault(require("./InputPrefix"));
|
|
37
|
-
|
|
38
22
|
var _constants = require("../constants");
|
|
39
|
-
|
|
40
23
|
var _message = _interopRequireDefault(require("../message"));
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
function _objectSpread(
|
|
45
|
-
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
+
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; }
|
|
27
|
+
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; }
|
|
46
28
|
var AutoComplete = _consoleComponents.Select.AutoComplete;
|
|
47
29
|
/**
|
|
48
30
|
*
|
|
49
31
|
* @param IRcSearchOptionsProps options
|
|
50
32
|
* @returns
|
|
51
33
|
*/
|
|
52
|
-
|
|
53
34
|
var normalizeOptions = function normalizeOptions(options) {
|
|
54
35
|
var optionsCopy = (0, _cloneDeep.default)(options);
|
|
55
36
|
optionsCopy.forEach(function (o) {
|
|
56
|
-
|
|
37
|
+
!o.groupName && (o.groupName = _message.default.defaultFilterGroupName);
|
|
57
38
|
});
|
|
58
39
|
return Object.entries((0, _groupBy.default)(optionsCopy, 'groupName')).map(function (_ref) {
|
|
59
40
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
41
|
+
groupName = _ref2[0],
|
|
42
|
+
children = _ref2[1];
|
|
63
43
|
return {
|
|
64
44
|
label: groupName,
|
|
65
45
|
children: children.map(function (l) {
|
|
@@ -71,7 +51,6 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
71
51
|
};
|
|
72
52
|
});
|
|
73
53
|
};
|
|
74
|
-
|
|
75
54
|
var normalizeSuggestion = function normalizeSuggestion(suggestion) {
|
|
76
55
|
var suggestionCopy = (0, _cloneDeep.default)(suggestion);
|
|
77
56
|
suggestionCopy.forEach(function (s) {
|
|
@@ -85,38 +64,31 @@ var normalizeSuggestion = function normalizeSuggestion(suggestion) {
|
|
|
85
64
|
});
|
|
86
65
|
return suggestionCopy;
|
|
87
66
|
};
|
|
88
|
-
|
|
89
67
|
var normalizeSelectDataSource = function normalizeSelectDataSource(title, list) {
|
|
90
68
|
return [{
|
|
91
69
|
label: title || '',
|
|
92
70
|
children: (0, _toConsumableArray2.default)(list)
|
|
93
71
|
}];
|
|
94
72
|
};
|
|
95
|
-
|
|
96
73
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
97
74
|
var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
|
|
98
75
|
return o.dataIndex === dataIndex;
|
|
99
76
|
});
|
|
100
77
|
var valueLabel = value;
|
|
101
|
-
|
|
102
78
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
103
79
|
var _opt$templateProps, _opt$templateProps$da;
|
|
104
|
-
|
|
105
80
|
valueLabel = (_opt$templateProps = opt.templateProps) === null || _opt$templateProps === void 0 ? void 0 : (_opt$templateProps$da = _opt$templateProps.dataSource.find(function (d) {
|
|
106
81
|
return d.value === value;
|
|
107
82
|
})) === null || _opt$templateProps$da === void 0 ? void 0 : _opt$templateProps$da.label;
|
|
108
83
|
}
|
|
109
|
-
|
|
110
84
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
111
85
|
var _opt$templateProps2;
|
|
112
|
-
|
|
113
86
|
valueLabel = (_opt$templateProps2 = opt.templateProps) === null || _opt$templateProps2 === void 0 ? void 0 : _opt$templateProps2.dataSource.filter(function (d) {
|
|
114
87
|
return value === null || value === void 0 ? void 0 : value.includes(d.value);
|
|
115
88
|
}).map(function (d) {
|
|
116
89
|
return d.label;
|
|
117
90
|
}).join('/');
|
|
118
91
|
}
|
|
119
|
-
|
|
120
92
|
return {
|
|
121
93
|
label: opt === null || opt === void 0 ? void 0 : opt.label,
|
|
122
94
|
valueLabel: valueLabel,
|
|
@@ -124,7 +96,6 @@ var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, o
|
|
|
124
96
|
dataIndex: dataIndex
|
|
125
97
|
};
|
|
126
98
|
};
|
|
127
|
-
|
|
128
99
|
var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
129
100
|
var idx = value.toLowerCase().indexOf(keywords.toLowerCase());
|
|
130
101
|
var startValue = value.slice(0, idx);
|
|
@@ -136,41 +107,34 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
136
107
|
}
|
|
137
108
|
}, highlightValue), endValue);
|
|
138
109
|
};
|
|
139
|
-
|
|
140
110
|
var ComplexSearch = function ComplexSearch(props) {
|
|
141
111
|
var _props$options = props.options,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
112
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
113
|
+
fuzzy = props.fuzzy,
|
|
114
|
+
defaultDataIndex = props.defaultDataIndex,
|
|
115
|
+
defaultSelectedDataIndex = props.defaultSelectedDataIndex,
|
|
116
|
+
placeholder = props.placeholder,
|
|
117
|
+
onSearch = props.onSearch,
|
|
118
|
+
onSuggest = props.onSuggest,
|
|
119
|
+
_props$suggestions = props.suggestions,
|
|
120
|
+
suggestions = _props$suggestions === void 0 ? [] : _props$suggestions,
|
|
121
|
+
_props$prefix = props.prefix,
|
|
122
|
+
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix;
|
|
154
123
|
var _useState = (0, _react.useState)(options.find(function (o) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
124
|
+
return o.dataIndex === defaultSelectedDataIndex;
|
|
125
|
+
})),
|
|
126
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
127
|
+
selectedFilterType = _useState2[0],
|
|
128
|
+
setSelectedFilterType = _useState2[1];
|
|
161
129
|
var _useState3 = (0, _react.useState)(false),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
130
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
131
|
+
focused = _useState4[0],
|
|
132
|
+
setFocused = _useState4[1];
|
|
166
133
|
var autoRef = (0, _react.useRef)(null);
|
|
167
|
-
var fuzzyAutoRef = (0, _react.useRef)(null);
|
|
168
|
-
|
|
169
134
|
var field = _consoleComponents.Field.useField();
|
|
170
|
-
|
|
171
135
|
var init = field.init,
|
|
172
|
-
|
|
173
|
-
|
|
136
|
+
getValue = field.getValue,
|
|
137
|
+
reset = field.reset;
|
|
174
138
|
var focusProps = {
|
|
175
139
|
onFocus: function onFocus() {
|
|
176
140
|
setFocused(true);
|
|
@@ -178,29 +142,26 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
178
142
|
onBlur: function onBlur() {
|
|
179
143
|
setFocused(false);
|
|
180
144
|
}
|
|
181
|
-
};
|
|
145
|
+
};
|
|
182
146
|
|
|
147
|
+
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
183
148
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(_constants.SEARCH_FILTER_FIELD);
|
|
184
149
|
var defaultFilter = options.find(function (t) {
|
|
185
150
|
return t.dataIndex === defaultDataIndex;
|
|
186
151
|
});
|
|
187
|
-
|
|
188
152
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
189
153
|
var label = item.label;
|
|
190
|
-
|
|
191
154
|
if (searchKey && searchKey.length) {
|
|
192
155
|
label = highlightKeyword(item.label, searchKey);
|
|
193
156
|
}
|
|
194
|
-
|
|
195
157
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
196
158
|
"data-value": item === null || item === void 0 ? void 0 : item.value
|
|
197
159
|
}, label);
|
|
198
160
|
};
|
|
161
|
+
|
|
199
162
|
/**
|
|
200
163
|
* 处理筛选类型选中的情况
|
|
201
164
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
165
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
205
166
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
206
167
|
setSelectedFilterType(options.find(function (o) {
|
|
@@ -208,67 +169,58 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
208
169
|
}));
|
|
209
170
|
resetValue && reset();
|
|
210
171
|
};
|
|
172
|
+
|
|
211
173
|
/**
|
|
212
174
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
213
175
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
176
|
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
|
|
217
|
-
var isFuzzySearch = isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
|
|
177
|
+
var isFuzzySearch = isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
|
|
218
178
|
|
|
179
|
+
// 如果是模糊搜索,则直接处理
|
|
219
180
|
if (isFuzzySearch) {
|
|
220
181
|
if (actionType !== 'change') {
|
|
221
182
|
handleSearch(option.dataIndex);
|
|
222
183
|
} else {
|
|
223
184
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
224
185
|
}
|
|
225
|
-
|
|
226
186
|
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
187
|
+
}
|
|
229
188
|
|
|
189
|
+
// 否则处理筛选项改变的情况
|
|
230
190
|
handlerFilterTypeChange(value, false);
|
|
231
191
|
};
|
|
232
|
-
|
|
233
192
|
var handlerFilterClear = function handlerFilterClear() {
|
|
234
193
|
setSelectedFilterType(null);
|
|
235
194
|
reset();
|
|
236
195
|
};
|
|
237
|
-
|
|
238
196
|
var handleSearch = function handleSearch(dataIndex) {
|
|
239
197
|
if (onSearch) {
|
|
240
|
-
var value = getValue(_constants.SEARCH_FILTER_VALUE_FIELD);
|
|
241
|
-
|
|
198
|
+
var value = getValue(_constants.SEARCH_FILTER_VALUE_FIELD);
|
|
199
|
+
// 如果是没有选择下拉
|
|
242
200
|
if (defaultDataIndex && !selectedFilterType) {
|
|
243
201
|
onSearch(getValue(_constants.SEARCH_FILTER_FIELD), defaultDataIndex, normalizeSearchOptions(defaultDataIndex, getValue(_constants.SEARCH_FILTER_FIELD), options));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
202
|
+
}
|
|
203
|
+
// 如果是用户没有指定 defaultDataIndex 但是设置了 fuzzy
|
|
247
204
|
if (fuzzy && !selectedFilterType) {
|
|
248
205
|
onSearch(getValue(_constants.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(_constants.SEARCH_FILTER_FIELD), options));
|
|
249
206
|
}
|
|
250
|
-
|
|
251
207
|
if (selectedFilterType) {
|
|
252
208
|
onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
|
|
253
209
|
}
|
|
254
210
|
}
|
|
255
|
-
|
|
256
211
|
reset();
|
|
257
212
|
document.body.click();
|
|
258
213
|
setFocused(false);
|
|
259
214
|
};
|
|
260
|
-
|
|
261
215
|
var handleKeyUp = function handleKeyUp(e) {
|
|
262
216
|
if (e.keyCode === 13 && e.currentTarget.value) {
|
|
263
217
|
handleSearch();
|
|
264
218
|
document.body.click();
|
|
265
219
|
}
|
|
266
|
-
|
|
267
220
|
if (e.keyCode === 8 && !e.currentTarget.value) {
|
|
268
221
|
handlerFilterClear();
|
|
269
222
|
}
|
|
270
223
|
};
|
|
271
|
-
|
|
272
224
|
var renderMultipleSelectorItem = function renderMultipleSelectorItem(item) {
|
|
273
225
|
var searchValue = getValue(_constants.SEARCH_FILTER_VALUE_FIELD);
|
|
274
226
|
var checked = (0, _isArray.default)(searchValue) && searchValue.some(function (v) {
|
|
@@ -278,13 +230,10 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
278
230
|
checked: checked
|
|
279
231
|
}, item.label);
|
|
280
232
|
};
|
|
281
|
-
|
|
282
233
|
var renderSelectedFilter = function renderSelectedFilter() {
|
|
283
234
|
var _selectedFilterType$t, _selectedFilterType$t2, _selectedFilterType$t3;
|
|
284
|
-
|
|
285
235
|
var type = selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template;
|
|
286
236
|
var searchValue = getValue(_constants.SEARCH_FILTER_VALUE_FIELD);
|
|
287
|
-
|
|
288
237
|
var props = _objectSpread({
|
|
289
238
|
hasBorder: false,
|
|
290
239
|
autoFocus: true,
|
|
@@ -294,7 +243,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
294
243
|
value: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label
|
|
295
244
|
})
|
|
296
245
|
}, focusProps);
|
|
297
|
-
|
|
298
246
|
var selectProps = {
|
|
299
247
|
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) || []),
|
|
300
248
|
defaultVisible: true,
|
|
@@ -302,11 +250,11 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
302
250
|
width: 'auto'
|
|
303
251
|
}
|
|
304
252
|
};
|
|
305
|
-
|
|
306
253
|
switch (type) {
|
|
307
254
|
case 'input':
|
|
308
255
|
return /*#__PURE__*/_react.default.createElement(AutoComplete, (0, _extends2.default)({}, init(_constants.SEARCH_FILTER_VALUE_FIELD, {}), {
|
|
309
|
-
className: (0, _classnames.default)('main-input', 'multi')
|
|
256
|
+
className: (0, _classnames.default)('main-input', 'multi')
|
|
257
|
+
// @ts-ignore
|
|
310
258
|
,
|
|
311
259
|
autoHighlightFirstItem: false
|
|
312
260
|
}, props, {
|
|
@@ -314,7 +262,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
314
262
|
onKeyUp: handleKeyUp,
|
|
315
263
|
dataSource: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : (_selectedFilterType$t3 = selectedFilterType.templateProps) === null || _selectedFilterType$t3 === void 0 ? void 0 : _selectedFilterType$t3.dataSource
|
|
316
264
|
}));
|
|
317
|
-
|
|
318
265
|
case 'select':
|
|
319
266
|
return /*#__PURE__*/_react.default.createElement(_consoleComponents.Select, (0, _extends2.default)({
|
|
320
267
|
className: (0, _classnames.default)('main-input', 'select')
|
|
@@ -326,14 +273,14 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
326
273
|
// @ts-ignore
|
|
327
274
|
autoHighlightFirstItem: false
|
|
328
275
|
}, props, selectProps));
|
|
329
|
-
|
|
330
276
|
case 'multiple':
|
|
331
277
|
return /*#__PURE__*/_react.default.createElement(_consoleComponents.Select, (0, _extends2.default)({
|
|
332
278
|
className: (0, _classnames.default)('main-input', 'multi')
|
|
333
279
|
}, init(_constants.SEARCH_FILTER_VALUE_FIELD, {}), props, selectProps, {
|
|
334
280
|
itemRender: renderMultipleSelectorItem,
|
|
335
281
|
popupClassName: "xconsole-rcsearch-multi-pop",
|
|
336
|
-
mode: "multiple"
|
|
282
|
+
mode: "multiple"
|
|
283
|
+
// @ts-ignore
|
|
337
284
|
,
|
|
338
285
|
autoHighlightFirstItem: false,
|
|
339
286
|
maxTagCount: 0,
|
|
@@ -359,12 +306,10 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
359
306
|
}, _message.default.cancel))
|
|
360
307
|
}
|
|
361
308
|
}));
|
|
362
|
-
|
|
363
309
|
default:
|
|
364
310
|
return null;
|
|
365
311
|
}
|
|
366
312
|
};
|
|
367
|
-
|
|
368
313
|
var renderSelectFilterCloseIcon = function renderSelectFilterCloseIcon() {
|
|
369
314
|
var hasFilterTypeClearBtn = !!selectedFilterType && !((selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template) === 'input' && !!getValue(_constants.SEARCH_FILTER_VALUE_FIELD));
|
|
370
315
|
return hasFilterTypeClearBtn && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -381,7 +326,6 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
381
326
|
}
|
|
382
327
|
}))));
|
|
383
328
|
};
|
|
384
|
-
|
|
385
329
|
return /*#__PURE__*/_react.default.createElement(_style.SearchWarp, {
|
|
386
330
|
prefix: prefix
|
|
387
331
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -407,7 +351,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
407
351
|
}
|
|
408
352
|
}
|
|
409
353
|
}), {
|
|
410
|
-
autoHighlightFirstItem: false
|
|
354
|
+
autoHighlightFirstItem: false
|
|
355
|
+
// @ts-ignore
|
|
411
356
|
,
|
|
412
357
|
itemRender: highlightItem,
|
|
413
358
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? (0, _lodash.template)(_message.default.defaultPlaceHolder)({
|
|
@@ -416,7 +361,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
416
361
|
className: (0, _classnames.default)('main-input', 'multi'),
|
|
417
362
|
hasBorder: false,
|
|
418
363
|
onKeyUp: handleKeyUp,
|
|
419
|
-
dataSource:
|
|
364
|
+
dataSource:
|
|
365
|
+
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
420
366
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
421
367
|
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
422
368
|
popupStyle: {
|
|
@@ -437,7 +383,4 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
437
383
|
type: "search"
|
|
438
384
|
}))));
|
|
439
385
|
};
|
|
440
|
-
|
|
441
|
-
var _default = _consoleComponents.ConfigProvider.config(ComplexSearch);
|
|
442
|
-
|
|
443
|
-
exports.default = _default;
|
|
386
|
+
var _default = exports.default = _consoleComponents.ConfigProvider.config(ComplexSearch);
|
package/lib/constants.js
CHANGED
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var baseClassName = 'rc-search';
|
|
8
|
-
exports.
|
|
9
|
-
|
|
6
|
+
exports.baseTagListClassName = exports.baseClassName = exports.SEARCH_FILTER_VALUE_FIELD = exports.SEARCH_FILTER_FIELD = void 0;
|
|
7
|
+
var baseClassName = exports.baseClassName = 'rc-search';
|
|
8
|
+
var baseTagListClassName = exports.baseTagListClassName = "".concat(baseClassName, "-taglist");
|
|
9
|
+
|
|
10
|
+
// export const titleClassName = `${baseClassName}-title`
|
|
10
11
|
// export const titleContainerClassName = `${titleClassName}-container`
|
|
11
12
|
// export const titleExtraClassName = `${titleClassName}-extra`
|
|
12
13
|
// export const titleChildrenClassName = `${titleClassName}-children`
|
|
13
14
|
// export const contentClassName = `${baseClassName}-content`
|
|
14
15
|
|
|
15
|
-
exports.
|
|
16
|
-
var
|
|
17
|
-
exports.SEARCH_FILTER_FIELD = SEARCH_FILTER_FIELD;
|
|
18
|
-
var SEARCH_FILTER_VALUE_FIELD = 'searchValue';
|
|
19
|
-
exports.SEARCH_FILTER_VALUE_FIELD = SEARCH_FILTER_VALUE_FIELD;
|
|
16
|
+
var SEARCH_FILTER_FIELD = exports.SEARCH_FILTER_FIELD = 'filterInputValue';
|
|
17
|
+
var SEARCH_FILTER_VALUE_FIELD = exports.SEARCH_FILTER_VALUE_FIELD = 'searchValue';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
import './index.less';
|
|
8
|
-
export { Search, SearchTagList as SearchFilter, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|
|
8
|
+
export { Search, SearchTagList as SearchFilter, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps, };
|
package/lib/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "IRcSearchOptionsProps", {
|
|
9
8
|
enumerable: true,
|
|
10
9
|
get: function get() {
|
|
11
|
-
return
|
|
10
|
+
return _IRcSearchOptions.IRcSearchOptionsProps;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "IRcSearchProps", {
|
|
15
14
|
enumerable: true,
|
|
16
15
|
get: function get() {
|
|
17
|
-
return
|
|
16
|
+
return _IRcSearchProps.IRcSearchProps;
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
Object.defineProperty(exports, "
|
|
19
|
+
Object.defineProperty(exports, "IRcSearchTagItemProps", {
|
|
21
20
|
enumerable: true,
|
|
22
21
|
get: function get() {
|
|
23
|
-
return
|
|
22
|
+
return _IRcSearchTagItemProps.IRcSearchTagItemProps;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
Object.defineProperty(exports, "IRcSearchTagListProps", {
|
|
@@ -29,27 +28,21 @@ Object.defineProperty(exports, "IRcSearchTagListProps", {
|
|
|
29
28
|
return _IRcSearchTagListProps.IRcSearchTagListProps;
|
|
30
29
|
}
|
|
31
30
|
});
|
|
32
|
-
Object.defineProperty(exports, "
|
|
31
|
+
Object.defineProperty(exports, "Search", {
|
|
33
32
|
enumerable: true,
|
|
34
33
|
get: function get() {
|
|
35
|
-
return
|
|
34
|
+
return _search.Search;
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
Object.defineProperty(exports, "
|
|
37
|
+
Object.defineProperty(exports, "SearchFilter", {
|
|
39
38
|
enumerable: true,
|
|
40
39
|
get: function get() {
|
|
41
|
-
return
|
|
40
|
+
return _searchTagList.default;
|
|
42
41
|
}
|
|
43
42
|
});
|
|
44
|
-
|
|
45
43
|
var _search = require("./search");
|
|
46
|
-
|
|
47
44
|
var _searchTagList = _interopRequireDefault(require("./searchTagList"));
|
|
48
|
-
|
|
49
45
|
var _IRcSearchProps = require("./types/IRcSearchProps.type");
|
|
50
|
-
|
|
51
46
|
var _IRcSearchTagListProps = require("./types/IRcSearchTagListProps.type");
|
|
52
|
-
|
|
53
47
|
var _IRcSearchTagItemProps = require("./types/IRcSearchTagItemProps.type");
|
|
54
|
-
|
|
55
48
|
var _IRcSearchOptions = require("./types/IRcSearchOptions.type");
|
package/lib/message.js
CHANGED
|
@@ -1,63 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _jsCookie = _interopRequireDefault(require("js-cookie"));
|
|
11
|
-
|
|
12
9
|
var isSSR = typeof document === 'undefined';
|
|
13
10
|
var messages = {
|
|
14
|
-
|
|
11
|
+
zh: {
|
|
15
12
|
confirm: '确定',
|
|
16
13
|
cancel: '取消',
|
|
17
14
|
allValue: '全部值',
|
|
18
15
|
emptyValue: '空值',
|
|
19
|
-
tag:
|
|
20
|
-
defaultFilterGroupName:
|
|
16
|
+
tag: '标签',
|
|
17
|
+
defaultFilterGroupName: '选择筛选条件',
|
|
21
18
|
defaultPlaceHolder: '默认按${value}搜索',
|
|
22
19
|
clearFilter: '清除筛选条件'
|
|
23
20
|
},
|
|
24
|
-
|
|
21
|
+
en: {
|
|
25
22
|
confirm: 'OK',
|
|
26
23
|
cancel: 'Cancel',
|
|
27
24
|
allValue: 'All Values',
|
|
28
25
|
emptyValue: 'Empty',
|
|
29
|
-
tag:
|
|
30
|
-
defaultFilterGroupName:
|
|
26
|
+
tag: 'Tag',
|
|
27
|
+
defaultFilterGroupName: 'Select Filter Condition',
|
|
31
28
|
defaultPlaceHolder: 'Search By ${value}',
|
|
32
29
|
clearFilter: 'Clear Filter Condition'
|
|
33
30
|
},
|
|
34
|
-
|
|
31
|
+
'zh-TW': {
|
|
35
32
|
confirm: '確定',
|
|
36
33
|
cancel: '取消',
|
|
37
34
|
allValue: '全部值',
|
|
38
35
|
emptyValue: '空值',
|
|
39
|
-
tag:
|
|
40
|
-
defaultFilterGroupName:
|
|
36
|
+
tag: '標籤',
|
|
37
|
+
defaultFilterGroupName: '選擇篩選條件',
|
|
41
38
|
defaultPlaceHolder: '默認按${value}搜索',
|
|
42
39
|
clearFilter: '清除篩選條件'
|
|
43
40
|
},
|
|
44
|
-
|
|
41
|
+
ja: {
|
|
45
42
|
confirm: 'OK',
|
|
46
43
|
cancel: 'キャンセル',
|
|
47
44
|
allValue: 'すべての値',
|
|
48
45
|
emptyValue: '空',
|
|
49
|
-
tag:
|
|
50
|
-
defaultFilterGroupName:
|
|
46
|
+
tag: 'タグ',
|
|
47
|
+
defaultFilterGroupName: 'フィルタリング条件の選択',
|
|
51
48
|
defaultPlaceHolder: '${value} で検索',
|
|
52
49
|
clearFilter: 'フィルタリング条件のクリア'
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
|
-
var lang = isSSR ? '
|
|
56
|
-
|
|
52
|
+
var lang = isSSR ? 'zh' : _jsCookie.default.get('aliyun_lang') || 'zh';
|
|
57
53
|
if (!Object.keys(messages).includes(lang)) {
|
|
58
|
-
lang = '
|
|
59
|
-
}
|
|
60
|
-
|
|
54
|
+
lang = 'zh';
|
|
55
|
+
}
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
exports.default =
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
var _default = exports.default = messages[lang];
|
package/lib/search.d.ts
CHANGED
package/lib/search.js
CHANGED
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Search = void 0;
|
|
9
|
-
|
|
10
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
-
|
|
12
8
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
-
|
|
18
11
|
var _constants = require("./constants");
|
|
19
|
-
|
|
20
12
|
var _index = _interopRequireDefault(require("./ComplexSearch/index"));
|
|
21
|
-
|
|
22
|
-
var _LoggerProvider = _interopRequireDefault(require("./provider/LoggerProvider"));
|
|
23
|
-
|
|
24
13
|
var _useCssVar = require("./useCssVar");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var Search = function Search(props) {
|
|
14
|
+
var SearchWrap = _styledComponents.default.div.withConfig({
|
|
15
|
+
componentId: "sc-1szhzw4-0"
|
|
16
|
+
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
17
|
+
var Search = exports.Search = function Search(props) {
|
|
31
18
|
var className = props.className,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
_props$simple = props.simple,
|
|
20
|
+
simple = _props$simple === void 0 ? false : _props$simple,
|
|
21
|
+
style = props.style;
|
|
35
22
|
var windThemeClass = (0, _useCssVar.useWindTheme)();
|
|
36
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
37
|
-
regionId: props.regionId,
|
|
38
|
-
resourceType: props.resourceType || '',
|
|
39
|
-
componentName: "RcSearch"
|
|
40
|
-
}), /*#__PURE__*/_react.default.createElement(SearchWrap, {
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SearchWrap, {
|
|
41
24
|
className: (0, _classnames.default)(_constants.baseClassName, className, windThemeClass),
|
|
42
25
|
style: style
|
|
43
26
|
}, /*#__PURE__*/_react.default.createElement(_index.default, props)));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.Search = Search;
|
|
27
|
+
};
|