@alicloud/console-components-search 0.1.3 → 0.2.2
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/README.md +104 -131
- package/demos/demo1.demo.tsx +100 -90
- package/doc-dist/0.js +1917 -16
- package/doc-dist/1.js +16 -1917
- package/doc-dist/10.js +1 -1
- package/doc-dist/11.js +1 -1
- package/doc-dist/12.js +1 -1
- package/doc-dist/13.js +1 -1
- package/doc-dist/14.js +1 -1
- package/doc-dist/15.js +1 -1
- package/doc-dist/3.js +5 -5
- package/doc-dist/4.js +1 -1
- package/doc-dist/5.js +2 -2
- package/doc-dist/6.js +1 -1
- package/doc-dist/7.js +1 -1
- package/doc-dist/8.js +1 -1
- package/doc-dist/9.js +1 -1
- package/doc-dist/deps/main.css +1 -1
- package/doc-dist/deps/main.js +8 -8
- package/doc-dist/deps/main.os.css +1 -1
- package/doc-dist/index.js +3 -3
- package/doc-dist/log-deps-build.log +3 -3
- package/es/constants.js +4 -1
- package/es/index.js +1 -1
- package/es/modeSingleSingle/InputPrefix.js +29 -0
- package/es/modeSingleSingle/index2.js +369 -0
- package/es/search.js +2 -3
- package/es/searchTagList/PureTag.js +57 -0
- package/es/searchTagList/index.js +30 -14
- package/es/style.js +2 -2
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +6 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/modeSingleSingle/InputPrefix.d.ts +2 -0
- package/lib/modeSingleSingle/InputPrefix.js +43 -0
- package/lib/modeSingleSingle/index2.d.ts +4 -0
- package/lib/modeSingleSingle/index2.js +400 -0
- package/lib/search.js +2 -4
- package/lib/searchTagList/PureTag.d.ts +14 -0
- package/lib/searchTagList/PureTag.js +71 -0
- package/lib/searchTagList/index.d.ts +3 -1
- package/lib/searchTagList/index.js +31 -15
- package/lib/style.js +2 -2
- package/lib/types/IRcSearchProps.type.d.ts +22 -21
- package/lib/types/IRcSearchTagItemProps.type.d.ts +2 -2
- package/lib/types/IRcSearchTagListProps.type.d.ts +9 -5
- package/package.json +2 -1
- package/demos/demo2.demo.tsx +0 -81
- package/demos/demo3.demo.tsx +0 -90
- package/demos/demo4.demo.tsx +0 -137
- package/dist/index.css +0 -1
- package/dist/index.js +0 -60
- package/doc-dist/16.js +0 -6
- package/doc-dist/17.js +0 -6
- package/doc-dist/18.js +0 -6
- package/doc-dist/19.js +0 -6
- package/doc-dist/20.js +0 -6
- package/docs/markdown-render.doc.md +0 -21
- package/docs/test.doc.md +0 -8
- package/es/modeSingleMulti/index.js +0 -868
- package/es/modeSingleSingle/index.js +0 -201
- package/lib/modeSingleMulti/index.d.ts +0 -2
- package/lib/modeSingleMulti/index.js +0 -894
- package/lib/modeSingleSingle/index.d.ts +0 -2
- package/lib/modeSingleSingle/index.js +0 -226
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
开始构建微应用external依赖...
|
|
2
2
|
BreezrPluginStyledComponentsIsolation The plugin will trying to use the package's name as isolation id of styled-components. This behavior usually occurred on dev mode. And if you were received this warning on publish mode then you should to set `options.styledComponentStyleSheetId` implicitly.
|
|
3
3
|
ℹ Compiling Webpack
|
|
4
|
-
✔ Webpack: Compiled successfully in
|
|
4
|
+
✔ Webpack: Compiled successfully in 12.79s
|
|
5
5
|
WARN asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
|
|
6
6
|
This can impact web performance.
|
|
7
7
|
Assets:
|
|
8
|
-
main.js (2.
|
|
8
|
+
main.js (2.49 MiB),entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
|
|
9
9
|
Entrypoints:
|
|
10
|
-
main (2.
|
|
10
|
+
main (2.49 MiB)
|
|
11
11
|
main.css
|
|
12
12
|
main.js
|
|
13
13
|
,webpack performance recommendations:
|
package/es/constants.js
CHANGED
|
@@ -3,4 +3,7 @@ export var baseTagListClassName = "".concat(baseClassName, "-taglist"); // expor
|
|
|
3
3
|
// export const titleContainerClassName = `${titleClassName}-container`
|
|
4
4
|
// export const titleExtraClassName = `${titleClassName}-extra`
|
|
5
5
|
// export const titleChildrenClassName = `${titleClassName}-children`
|
|
6
|
-
// export const contentClassName = `${baseClassName}-content`
|
|
6
|
+
// export const contentClassName = `${baseClassName}-content`
|
|
7
|
+
|
|
8
|
+
export var SEARCH_FILTER_FIELD = 'filterInputValue';
|
|
9
|
+
export var SEARCH_FILTER_VALUE_FIELD = 'searchValue';
|
package/es/index.js
CHANGED
|
@@ -4,4 +4,4 @@ import { IRcSearchProps } from "./types/IRcSearchProps.type";
|
|
|
4
4
|
import { IRcSearchTagListProps } from "./types/IRcSearchTagListProps.type";
|
|
5
5
|
import { IRcSearchTagItemProps } from './types/IRcSearchTagItemProps.type';
|
|
6
6
|
import { IRcSearchOptionsProps } from './types/IRcSearchOptions.type';
|
|
7
|
-
export { Search, SearchTagList, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|
|
7
|
+
export { Search, SearchTagList as SearchFilter, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["dataSource", "label"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { Icon, Select } from '@alicloud/console-components';
|
|
7
|
+
|
|
8
|
+
var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
9
|
+
var _props$dataSource = props.dataSource,
|
|
10
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
11
|
+
label = props.label,
|
|
12
|
+
reset = _objectWithoutProperties(props, _excluded);
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: classNames('condition-item')
|
|
16
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
17
|
+
className: classNames('condition-item-txt')
|
|
18
|
+
}, label), /*#__PURE__*/React.createElement(Icon, {
|
|
19
|
+
type: "caret-down",
|
|
20
|
+
size: "xxs"
|
|
21
|
+
}), /*#__PURE__*/React.createElement(Select, _extends({
|
|
22
|
+
className: classNames('condition-select'),
|
|
23
|
+
hasBorder: false,
|
|
24
|
+
dataSource: dataSource,
|
|
25
|
+
autoWidth: true
|
|
26
|
+
}, reset)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default SearchConditionSelectPrefix;
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
12
|
+
import groupBy from 'lodash/groupBy';
|
|
13
|
+
import isArray from 'lodash/isArray';
|
|
14
|
+
import React, { useState, useRef } from "react";
|
|
15
|
+
import { Button, Icon, Select, ConfigProvider, Field, Checkbox } from '@alicloud/console-components';
|
|
16
|
+
import { SearchWarp, MultiBtnWarp } from "../style";
|
|
17
|
+
import SearchConditionSelectPrefix from "./InputPrefix";
|
|
18
|
+
import { SEARCH_FILTER_FIELD, SEARCH_FILTER_VALUE_FIELD } from "../constants";
|
|
19
|
+
var AutoComplete = Select.AutoComplete;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param IRcSearchOptionsProps options
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var normalizeOptions = function normalizeOptions(options) {
|
|
27
|
+
var optionsCopy = cloneDeep(options);
|
|
28
|
+
optionsCopy.forEach(function (o) {
|
|
29
|
+
var _o$groupName;
|
|
30
|
+
|
|
31
|
+
return (_o$groupName = o.groupName) !== null && _o$groupName !== void 0 ? _o$groupName : o.groupName = "选择筛选条件";
|
|
32
|
+
});
|
|
33
|
+
return Object.entries(groupBy(optionsCopy, 'groupName')).map(function (_ref) {
|
|
34
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
+
groupName = _ref2[0],
|
|
36
|
+
children = _ref2[1];
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
label: groupName,
|
|
40
|
+
children: children.map(function (l) {
|
|
41
|
+
return {
|
|
42
|
+
label: l.label,
|
|
43
|
+
value: l.dataIndex
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var normalizeSelectDataSource = function normalizeSelectDataSource(title, list) {
|
|
51
|
+
return [{
|
|
52
|
+
label: title || '',
|
|
53
|
+
children: _toConsumableArray(list)
|
|
54
|
+
}];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
58
|
+
var opt = options.find(function (o) {
|
|
59
|
+
return o.dataIndex === dataIndex;
|
|
60
|
+
});
|
|
61
|
+
var valueLabel = value;
|
|
62
|
+
|
|
63
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
64
|
+
var _opt$templateProps;
|
|
65
|
+
|
|
66
|
+
valueLabel = (_opt$templateProps = opt.templateProps) === null || _opt$templateProps === void 0 ? void 0 : _opt$templateProps.dataSource.find(function (d) {
|
|
67
|
+
return d.value === value;
|
|
68
|
+
}).label;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
72
|
+
var _opt$templateProps2;
|
|
73
|
+
|
|
74
|
+
valueLabel = (_opt$templateProps2 = opt.templateProps) === null || _opt$templateProps2 === void 0 ? void 0 : _opt$templateProps2.dataSource.filter(function (d) {
|
|
75
|
+
return value.indexOf(d.value) !== -1;
|
|
76
|
+
}).map(function (d) {
|
|
77
|
+
return d.label;
|
|
78
|
+
}).join('/');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
label: opt === null || opt === void 0 ? void 0 : opt.label,
|
|
83
|
+
valueLabel: valueLabel,
|
|
84
|
+
value: value,
|
|
85
|
+
dataIndex: dataIndex
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
90
|
+
var idx = value.toLowerCase().indexOf(keywords.toLowerCase());
|
|
91
|
+
var startValue = value.slice(0, idx);
|
|
92
|
+
var highlightValue = value.slice(idx, idx + keywords.length);
|
|
93
|
+
var endValue = value.slice(idx + keywords.length);
|
|
94
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, startValue, /*#__PURE__*/React.createElement("span", {
|
|
95
|
+
style: {
|
|
96
|
+
color: 'var(--color-brand1-6)'
|
|
97
|
+
}
|
|
98
|
+
}, highlightValue), endValue);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var ComplexSearch = function ComplexSearch(props) {
|
|
102
|
+
var options = props.options,
|
|
103
|
+
fuzzy = props.fuzzy,
|
|
104
|
+
defaultDataIndex = props.defaultDataIndex,
|
|
105
|
+
placeholder = props.placeholder,
|
|
106
|
+
onSearch = props.onSearch,
|
|
107
|
+
onSuggest = props.onSuggest,
|
|
108
|
+
_props$suggestions = props.suggestions,
|
|
109
|
+
suggestions = _props$suggestions === void 0 ? [] : _props$suggestions,
|
|
110
|
+
_props$prefix = props.prefix,
|
|
111
|
+
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix;
|
|
112
|
+
|
|
113
|
+
var _useState = useState(null),
|
|
114
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
115
|
+
selectedFilterType = _useState2[0],
|
|
116
|
+
setSelectedFilterType = _useState2[1];
|
|
117
|
+
|
|
118
|
+
var _useState3 = useState(false),
|
|
119
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
120
|
+
focused = _useState4[0],
|
|
121
|
+
setFocused = _useState4[1];
|
|
122
|
+
|
|
123
|
+
var autoRef = useRef(null);
|
|
124
|
+
var field = Field.useField();
|
|
125
|
+
var init = field.init,
|
|
126
|
+
getValue = field.getValue,
|
|
127
|
+
reset = field.reset,
|
|
128
|
+
getError = field.getError;
|
|
129
|
+
var focusProps = {
|
|
130
|
+
onFocus: function onFocus() {
|
|
131
|
+
setFocused(true);
|
|
132
|
+
},
|
|
133
|
+
onBlur: function onBlur() {
|
|
134
|
+
setFocused(false);
|
|
135
|
+
}
|
|
136
|
+
}; //计算视图,根据内部状态和输入的 props 决定一些值
|
|
137
|
+
|
|
138
|
+
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
|
|
139
|
+
var defaultFilter = options.find(function (t) {
|
|
140
|
+
return t.dataIndex === defaultDataIndex;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
var highlightItem = function highlightItem(item, searchKey) {
|
|
144
|
+
var label = item.label;
|
|
145
|
+
|
|
146
|
+
if (searchKey && searchKey.length) {
|
|
147
|
+
label = highlightKeyword(item.label, searchKey);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return label;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* 处理筛选类型选中的情况
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
158
|
+
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
159
|
+
setSelectedFilterType(options.find(function (o) {
|
|
160
|
+
return o.dataIndex === type;
|
|
161
|
+
}));
|
|
162
|
+
resetValue && reset();
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy) {
|
|
170
|
+
var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD); // 如果是模糊搜索,则直接处理
|
|
171
|
+
|
|
172
|
+
if (isFuzzySearch) {
|
|
173
|
+
if (actionType !== 'change') {
|
|
174
|
+
handleSearch();
|
|
175
|
+
} else {
|
|
176
|
+
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return;
|
|
180
|
+
} // 否则处理筛选项改变的情况
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
handlerFilterTypeChange(value, false);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
var handlerFilterClear = function handlerFilterClear() {
|
|
187
|
+
setSelectedFilterType(null);
|
|
188
|
+
reset();
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
var handleSearch = function handleSearch() {
|
|
192
|
+
if (onSearch) {
|
|
193
|
+
var value = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
194
|
+
|
|
195
|
+
if (defaultDataIndex && !selectedFilterType) {
|
|
196
|
+
onSearch(getValue(SEARCH_FILTER_FIELD), defaultDataIndex, normalizeSearchOptions(defaultDataIndex, getValue(SEARCH_FILTER_FIELD), options));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (selectedFilterType) {
|
|
200
|
+
onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
reset();
|
|
205
|
+
document.body.click();
|
|
206
|
+
setFocused(false);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
var handleKeyUp = function handleKeyUp(e) {
|
|
210
|
+
if (e.keyCode === 13 && e.currentTarget.value) {
|
|
211
|
+
handleSearch();
|
|
212
|
+
document.body.click();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
var renderMultipleSelectorItem = function renderMultipleSelectorItem(item) {
|
|
217
|
+
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
218
|
+
var checked = isArray(searchValue) && searchValue.some(function (v) {
|
|
219
|
+
return v === item.value;
|
|
220
|
+
});
|
|
221
|
+
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
222
|
+
checked: checked
|
|
223
|
+
}, item.label);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var renderSelectedFilter = function renderSelectedFilter() {
|
|
227
|
+
var _selectedFilterType$t, _selectedFilterType$t2;
|
|
228
|
+
|
|
229
|
+
var type = selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template;
|
|
230
|
+
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
231
|
+
|
|
232
|
+
var props = _objectSpread({
|
|
233
|
+
hasBorder: false,
|
|
234
|
+
autoFocus: true,
|
|
235
|
+
hasClear: true,
|
|
236
|
+
key: type,
|
|
237
|
+
placeholder: (selectedFilterType === null || selectedFilterType === void 0 ? void 0 : (_selectedFilterType$t = selectedFilterType.templateProps) === null || _selectedFilterType$t === void 0 ? void 0 : _selectedFilterType$t.placeholder) || "\u9ED8\u8BA4\u6309".concat(selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, "\u641C\u7D22")
|
|
238
|
+
}, focusProps);
|
|
239
|
+
|
|
240
|
+
var selectProps = {
|
|
241
|
+
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) || []),
|
|
242
|
+
defaultVisible: true,
|
|
243
|
+
popupStyle: {
|
|
244
|
+
width: 'auto'
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
switch (type) {
|
|
249
|
+
case 'input':
|
|
250
|
+
return /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_VALUE_FIELD, {}), {
|
|
251
|
+
className: classNames('main-input', 'multi')
|
|
252
|
+
}, props, {
|
|
253
|
+
onKeyUp: handleKeyUp
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
case 'select':
|
|
257
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
258
|
+
className: classNames('main-input', 'select')
|
|
259
|
+
}, init(SEARCH_FILTER_VALUE_FIELD, {
|
|
260
|
+
props: {
|
|
261
|
+
onChange: handleSearch
|
|
262
|
+
}
|
|
263
|
+
}), props, selectProps));
|
|
264
|
+
|
|
265
|
+
case 'multiple':
|
|
266
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
267
|
+
className: classNames('main-input', 'multi')
|
|
268
|
+
}, init(SEARCH_FILTER_VALUE_FIELD, {}), props, selectProps, {
|
|
269
|
+
itemRender: renderMultipleSelectorItem,
|
|
270
|
+
popupClassName: "xconsole-rcsearch-multi-pop",
|
|
271
|
+
mode: "multiple",
|
|
272
|
+
maxTagCount: 0,
|
|
273
|
+
menuProps: {
|
|
274
|
+
footer: /*#__PURE__*/React.createElement(MultiBtnWarp, {
|
|
275
|
+
prefix: prefix
|
|
276
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
277
|
+
size: "small",
|
|
278
|
+
className: classNames("pri-btn"),
|
|
279
|
+
type: "primary",
|
|
280
|
+
disabled: !(searchValue !== null && searchValue !== void 0 && searchValue.length),
|
|
281
|
+
onClick: function onClick() {
|
|
282
|
+
handleSearch();
|
|
283
|
+
}
|
|
284
|
+
}, "\u786E\u5B9A"), /*#__PURE__*/React.createElement(Button, {
|
|
285
|
+
size: "small",
|
|
286
|
+
className: classNames("cancel-btn"),
|
|
287
|
+
type: "normal",
|
|
288
|
+
onClick: function onClick() {
|
|
289
|
+
reset();
|
|
290
|
+
document.body.click();
|
|
291
|
+
}
|
|
292
|
+
}, "\u53D6\u6D88"))
|
|
293
|
+
}
|
|
294
|
+
}));
|
|
295
|
+
|
|
296
|
+
default:
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
var renderSelectFilterCloseIcon = function renderSelectFilterCloseIcon() {
|
|
302
|
+
var hasFilterTypeClearBtn = !!selectedFilterType && !((selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template) === 'input' && !!getValue(SEARCH_FILTER_VALUE_FIELD));
|
|
303
|
+
return hasFilterTypeClearBtn && /*#__PURE__*/React.createElement("div", {
|
|
304
|
+
className: "clear-level1"
|
|
305
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
306
|
+
className: "".concat(prefix, "input-control")
|
|
307
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
308
|
+
className: "".concat(prefix, "input-hint-wrap")
|
|
309
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
310
|
+
className: "".concat(prefix, "icon ").concat(prefix, "icon-delete-filling ").concat(prefix, "medium ").concat(prefix, "input-hint ").concat(prefix, "input-clear-icon"),
|
|
311
|
+
role: "button",
|
|
312
|
+
"aria-label": "\u6E05\u9664",
|
|
313
|
+
onClick: function onClick() {
|
|
314
|
+
handlerFilterClear();
|
|
315
|
+
}
|
|
316
|
+
}))));
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
return /*#__PURE__*/React.createElement(SearchWarp, {
|
|
320
|
+
prefix: prefix
|
|
321
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
322
|
+
className: classNames('left-wrap', "".concat(prefix, "input"), {
|
|
323
|
+
'focus': focused
|
|
324
|
+
})
|
|
325
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
326
|
+
className: classNames('condition')
|
|
327
|
+
}, selectedFilterType ? /*#__PURE__*/React.createElement(SearchConditionSelectPrefix, {
|
|
328
|
+
dataSource: normalizeOptions(options),
|
|
329
|
+
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
330
|
+
defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
|
|
331
|
+
onChange: function onChange(value) {
|
|
332
|
+
handlerFilterTypeChange(value);
|
|
333
|
+
}
|
|
334
|
+
}) : null), /*#__PURE__*/React.createElement("div", {
|
|
335
|
+
className: classNames('forms')
|
|
336
|
+
}, !selectedFilterType ? /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_FIELD, {
|
|
337
|
+
props: {
|
|
338
|
+
// @ts-ignore
|
|
339
|
+
onChange: function onChange(value, actionType) {
|
|
340
|
+
handlerFilterTypeInput(value, actionType, isFuzzy);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}), {
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
itemRender: highlightItem,
|
|
346
|
+
placeholder: placeholder ? placeholder : defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? "\u9ED8\u8BA4\u6309".concat(defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label, "\u641C\u7D22") : '请搜索',
|
|
347
|
+
className: classNames('main-input', 'multi'),
|
|
348
|
+
hasBorder: false,
|
|
349
|
+
onKeyUp: handleKeyUp,
|
|
350
|
+
dataSource: // 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
351
|
+
// 则表示需要模糊搜索,调用 handleSuggest
|
|
352
|
+
isFuzzy ? suggestions : normalizeOptions(options),
|
|
353
|
+
popupStyle: {
|
|
354
|
+
width: 'auto'
|
|
355
|
+
}
|
|
356
|
+
}, focusProps)) : null, renderSelectedFilter(), renderSelectFilterCloseIcon())), /*#__PURE__*/React.createElement("div", {
|
|
357
|
+
className: classNames('right-wrap'),
|
|
358
|
+
ref: autoRef
|
|
359
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
360
|
+
className: classNames('search-btn', {
|
|
361
|
+
'focus': focused
|
|
362
|
+
}),
|
|
363
|
+
onClick: handleSearch
|
|
364
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
365
|
+
type: "search"
|
|
366
|
+
}))));
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
export default ConfigProvider.config(ComplexSearch);
|
package/es/search.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import ModeSingleMulti from "./modeSingleMulti";
|
|
2
|
+
import ComplexSearch from "./modeSingleSingle/index2";
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import styled from "styled-components";
|
|
6
5
|
import { baseClassName } from './constants';
|
|
@@ -20,5 +19,5 @@ export var Search = function Search(props) {
|
|
|
20
19
|
}), /*#__PURE__*/React.createElement(SearchWrap, {
|
|
21
20
|
className: classNames(baseClassName, className),
|
|
22
21
|
style: style
|
|
23
|
-
},
|
|
22
|
+
}, /*#__PURE__*/React.createElement(ComplexSearch, props)));
|
|
24
23
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["intl", "tagKey", "disableTruncate", "showDot", "tagValue", "showLabel", "closable"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Tag, Badge } from '@alicloud/console-components';
|
|
6
|
+
import Truncate from '@alicloud/console-components-truncate';
|
|
7
|
+
|
|
8
|
+
var Empty = function Empty(_ref) {
|
|
9
|
+
var children = _ref.children;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var PureTag = function PureTag(props) {
|
|
14
|
+
var intl = props.intl,
|
|
15
|
+
tagKey = props.tagKey,
|
|
16
|
+
disableTruncate = props.disableTruncate,
|
|
17
|
+
showDot = props.showDot,
|
|
18
|
+
tagValue = props.tagValue,
|
|
19
|
+
showLabel = props.showLabel,
|
|
20
|
+
_props$closable = props.closable,
|
|
21
|
+
closable = _props$closable === void 0 ? true : _props$closable,
|
|
22
|
+
resetProps = _objectWithoutProperties(props, _excluded);
|
|
23
|
+
|
|
24
|
+
var defaultTruncateProps = {
|
|
25
|
+
threshold: 20,
|
|
26
|
+
showTooltip: false
|
|
27
|
+
};
|
|
28
|
+
var TruncateWrapper = disableTruncate ? Empty : Truncate;
|
|
29
|
+
var DotWrapper = showDot ? Badge : Empty;
|
|
30
|
+
var TagWrapper = closable ? Tag.Closeable : Tag;
|
|
31
|
+
var transformedTagValue = tagValue;
|
|
32
|
+
|
|
33
|
+
if (tagValue === '') {
|
|
34
|
+
transformedTagValue = '空值';
|
|
35
|
+
} else if (tagValue === undefined || tagValue === null) {
|
|
36
|
+
transformedTagValue = '全部值';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
/*#__PURE__*/
|
|
41
|
+
//@ts-ignore
|
|
42
|
+
React.createElement(DotWrapper, {
|
|
43
|
+
title: "\u5373\u5C06\u65B0\u5EFA",
|
|
44
|
+
className: "console-tags-tag-dot",
|
|
45
|
+
dot: true
|
|
46
|
+
}, /*#__PURE__*/React.createElement(TagWrapper, _extends({
|
|
47
|
+
title: "".concat(tagKey, ":").concat(tagValue),
|
|
48
|
+
className: "console-tags-tag"
|
|
49
|
+
}, resetProps), showLabel && /*#__PURE__*/React.createElement("label", {
|
|
50
|
+
className: "console-tags-tag-label"
|
|
51
|
+
}, "\u6807\u7B7E"), /*#__PURE__*/React.createElement(TruncateWrapper, defaultTruncateProps, tagKey), ":", tagValue ? /*#__PURE__*/React.createElement(TruncateWrapper, defaultTruncateProps, tagValue) : /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "console-tags-tag_empty"
|
|
53
|
+
}, transformedTagValue)))
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default PureTag;
|
|
@@ -2,35 +2,36 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { ConfigProvider, Tag } from '@alicloud/console-components';
|
|
5
|
-
import LoggerProvider from '../provider/LoggerProvider';
|
|
6
5
|
import { TagListWrap } from '../style';
|
|
7
6
|
import { baseTagListClassName } from '../constants';
|
|
7
|
+
import PureTag from "./PureTag";
|
|
8
8
|
var TagGroup = Tag.Group,
|
|
9
9
|
ClosableTag = Tag.Closeable;
|
|
10
10
|
|
|
11
11
|
var SearchTagList = function SearchTagList(props) {
|
|
12
|
-
var
|
|
12
|
+
var dataSource = props.dataSource,
|
|
13
13
|
className = props.className,
|
|
14
14
|
style = props.style,
|
|
15
15
|
onChange = props.onChange,
|
|
16
|
+
onClear = props.onClear,
|
|
16
17
|
_props$prefix = props.prefix,
|
|
17
18
|
prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
|
|
18
19
|
|
|
19
20
|
function onRemoveTag(item) {
|
|
20
|
-
var newTagList = _toConsumableArray(
|
|
21
|
+
var newTagList = _toConsumableArray(dataSource);
|
|
21
22
|
|
|
22
23
|
if (onChange) {
|
|
23
24
|
var resFindIndex = newTagList.findIndex(function (x) {
|
|
24
25
|
return x.dataIndex === item.dataIndex;
|
|
25
26
|
});
|
|
26
|
-
newTagList.splice(resFindIndex, 1);
|
|
27
|
-
onChange(newTagList);
|
|
27
|
+
var deletedTags = newTagList.splice(resFindIndex, 1);
|
|
28
|
+
onChange(deletedTags[0], newTagList);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
function onRemoveAllTag() {
|
|
32
|
-
if (
|
|
33
|
-
|
|
33
|
+
if (onClear) {
|
|
34
|
+
onClear();
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -38,12 +39,25 @@ var SearchTagList = function SearchTagList(props) {
|
|
|
38
39
|
prefix: prefix,
|
|
39
40
|
className: classNames(baseTagListClassName, className),
|
|
40
41
|
style: style
|
|
41
|
-
}, /*#__PURE__*/React.createElement(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
}, /*#__PURE__*/React.createElement(TagGroup, null, dataSource && dataSource.length > 0 && dataSource.map(function (tagItem) {
|
|
43
|
+
var value = tagItem.value;
|
|
44
|
+
var isTag = !!value.tagKey;
|
|
45
|
+
|
|
46
|
+
if (isTag) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(PureTag, {
|
|
48
|
+
showLabel: true,
|
|
49
|
+
tagKey: value.tagKey,
|
|
50
|
+
tagValue: value.tagKey,
|
|
51
|
+
closable: true,
|
|
52
|
+
onClose: function onClose() {
|
|
53
|
+
onRemoveTag(tagItem);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
return /*#__PURE__*/React.createElement(ClosableTag, {
|
|
60
|
+
className: "console-tags-tag",
|
|
47
61
|
key: tagItem.dataIndex + tagItem.value,
|
|
48
62
|
type: "normal",
|
|
49
63
|
size: "medium",
|
|
@@ -51,8 +65,10 @@ var SearchTagList = function SearchTagList(props) {
|
|
|
51
65
|
onRemoveTag(tagItem);
|
|
52
66
|
return true;
|
|
53
67
|
}
|
|
54
|
-
},
|
|
55
|
-
|
|
68
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
69
|
+
className: "console-tags-tag-label"
|
|
70
|
+
}, tagItem.label), tagItem.value || tagItem.valueLabel);
|
|
71
|
+
}), dataSource && dataSource.length > 0 && /*#__PURE__*/React.createElement("a", {
|
|
56
72
|
className: "remove-btn",
|
|
57
73
|
onClick: onRemoveAllTag
|
|
58
74
|
}, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
|
package/es/style.js
CHANGED
|
@@ -6,7 +6,7 @@ var prefix = function prefix(props) {
|
|
|
6
6
|
|
|
7
7
|
var SearchWarp = styled.div.withConfig({
|
|
8
8
|
componentId: "sc-1afc1cn-0"
|
|
9
|
-
})(["height:100%;width:100%;display:flex;.left-wrap{flex:1;border-left:1px solid rgba(192,198,204,1);border-bottom:1px solid rgba(192,198,204,1);border-top:1px solid rgba(192,198,204,1);border-right:1px solid rgba(192,198,204,1);display:flex;border-bottom-left-radius:2px;border-top-left-radius:2px;&.focus{border:1px solid #0064c8;border:1px solid var(--input-
|
|
9
|
+
})(["height:100%;width:100%;display:flex;.left-wrap{flex:1;border-left:1px solid rgba(192,198,204,1);border-bottom:1px solid rgba(192,198,204,1);border-top:1px solid rgba(192,198,204,1);border-right:1px solid rgba(192,198,204,1);display:flex;border-bottom-left-radius:2px;border-top-left-radius:2px;&.focus{border:1px solid #0064c8;border:1px solid var(--input-focus-border-color,#0064c8);;border-right:1px solid rgba(192,198,204,1);}.condition{height:26px;display:inline-block;margin-top:2px;}.condition-item{height:26px;display:inline-block;line-height:26px;background:#EFF3F8;border-radius:2px;background-color:#EFF3F8;padding:0 8px;margin:0 2px;font-size:12px;color:#333;position:relative;&-txt{padding-right:4px;}&:hover{background-color:#E0E4E8;}}.condition-select{width:100%;height:100%;opacity:0;position:absolute;top:0;left:0;min-width:auto;", "select-inner{min-width:auto;}}.forms{flex:1;position:relative;.clear-level1{position:absolute;top:1px;right:1px;height:28px;width:30px;background-color:#fff;z-index:99;color:#333;text-align:center;line-height:28px;font-size:12px;cursor:pointer;padding:6px 0 0 6px;}}.main-input{height:auto;border:none;box-shadow:none;&.single{flex:1;}&.select{width:100%;}&.multi{width:100%;}", "input,", "input{height:auto;box-shadow:none;}}", "input", "medium{height:auto;}}.right-wrap{width:32px;.search-btn{width:32px;padding:0 !important;border-bottom-left-radius:0;border-top-left-radius:0;&.focus{border-color:#0064c8;border-color:var(--input-focus-border-color,#0064c8);}border-left:none;}}"], prefix, prefix, prefix, prefix, prefix);
|
|
10
10
|
var MenuContentWrap = styled.ul.withConfig({
|
|
11
11
|
componentId: "sc-1afc1cn-1"
|
|
12
12
|
})(["", "tag-small", "tag-closable > ", "tag-close-btn{margin-left:8px;padding-right:4px;padding-top:1px;}", "tag-small", "tag-closable > ", "tag-body{max-width:calc(100% - 8px - 8px - var(--tag-size-m-padding-lr,8px));}", "tag-small", "tag-closable > ", "tag-close-btn ", "icon:before,", "tag-small", "tag-closable > ", "tag-close-btn ", "icon ", "icon-remote{font-size:13px;}&& [class*='-icon-close']:hover::before{color:#181818;}&& [class*='-icon-close']::before{color:#808080;content:var(--icon-content-delete-filling);}"], prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix);
|
|
@@ -15,5 +15,5 @@ var MultiBtnWarp = styled.div.withConfig({
|
|
|
15
15
|
})(["padding:\"0 4px\";text-align:\"center\";.pri-btn{margin-right:8px;width:auto;min-width:auto;padding:3px 12px;}.cancel-btn{padding:3px 12px;width:auto;min-width:auto;}", "btn", "small:not(.isOnlyIcon):not(", "btn-text){min-width:auto;}"], prefix, prefix, prefix);
|
|
16
16
|
var TagListWrap = styled.div.withConfig({
|
|
17
17
|
componentId: "sc-1afc1cn-3"
|
|
18
|
-
})(["", "tag-medium", "tag-closable > ", "tag-close-btn{margin-left:8px;padding-right:6px;}", "tag-medium", "tag-closable > ", "tag-body{max-width:calc(100% - 8px - 8px - var(--tag-size-m-padding-lr,8px));}", "tag-medium", "tag-closable > ", "tag-close-btn ", "icon:before,", "tag-medium", "tag-closable > ", "tag-close-btn ", "icon ", "icon-remote{font-size:16px;}&& [class*='-icon-close']:hover::before{color:#181818;}&& [class*='-icon-close']::before{color:#808080;
|
|
18
|
+
})(["", "tag-medium", "tag-closable > ", "tag-close-btn{margin-left:8px;padding-right:6px;}", "tag-medium", "tag-closable > ", "tag-body{max-width:calc(100% - 8px - 8px - var(--tag-size-m-padding-lr,8px));}", "tag-medium", "tag-closable > ", "tag-close-btn ", "icon:before,", "tag-medium", "tag-closable > ", "tag-close-btn ", "icon ", "icon-remote{font-size:16px;}&& [class*='-icon-close']:hover::before{color:#181818;}&& [class*='-icon-close']::before{color:#808080;font-size:12px !important;}.remove-btn{margin-bottom:8px;line-height:24px;display:inline-block;vertical-align:middle;cursor:pointer;}"], prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix, prefix);
|
|
19
19
|
export { SearchWarp, MultiBtnWarp, TagListWrap, MenuContentWrap };
|
package/lib/constants.d.ts
CHANGED
package/lib/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.baseTagListClassName = exports.baseClassName = void 0;
|
|
6
|
+
exports.baseTagListClassName = exports.baseClassName = exports.SEARCH_FILTER_VALUE_FIELD = exports.SEARCH_FILTER_FIELD = void 0;
|
|
7
7
|
var baseClassName = 'rc-search';
|
|
8
8
|
exports.baseClassName = baseClassName;
|
|
9
9
|
var baseTagListClassName = "".concat(baseClassName, "-taglist"); // export const titleClassName = `${baseClassName}-title`
|
|
@@ -12,4 +12,8 @@ var baseTagListClassName = "".concat(baseClassName, "-taglist"); // export const
|
|
|
12
12
|
// export const titleChildrenClassName = `${titleClassName}-children`
|
|
13
13
|
// export const contentClassName = `${baseClassName}-content`
|
|
14
14
|
|
|
15
|
-
exports.baseTagListClassName = baseTagListClassName;
|
|
15
|
+
exports.baseTagListClassName = baseTagListClassName;
|
|
16
|
+
var SEARCH_FILTER_FIELD = 'filterInputValue';
|
|
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;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import { IRcSearchProps } from "./types/IRcSearchProps.type";
|
|
|
4
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 };
|
package/lib/index.js
CHANGED
|
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "Search", {
|
|
|
35
35
|
return _search.Search;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
Object.defineProperty(exports, "
|
|
38
|
+
Object.defineProperty(exports, "SearchFilter", {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
get: function get() {
|
|
41
41
|
return _searchTagList.default;
|