@alicloud/console-components-search 0.2.1 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/components-with-style.tsx +1 -1
- package/demos/demo1.demo.tsx +15 -3
- package/doc-dist/10.js +1 -1
- package/doc-dist/14.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/log-deps-build.log +3 -3
- package/es/constants.js +4 -1
- package/es/modeSingleSingle/index2.js +44 -20
- package/es/searchTagList/PureTag.js +57 -0
- package/es/searchTagList/index.js +84 -10
- package/es/style.js +1 -1
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +6 -2
- package/lib/index.d.ts +1 -0
- package/lib/modeSingleSingle/index2.js +45 -20
- package/lib/searchTagList/PureTag.d.ts +14 -0
- package/lib/searchTagList/PureTag.js +71 -0
- package/lib/searchTagList/index.js +86 -10
- package/lib/style.js +1 -1
- package/lib/types/IRcSearchTagItemProps.type.d.ts +3 -3
- package/lib/types/IRcSearchTagListProps.type.d.ts +6 -2
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
html body .xconsole-rcsearch-multi-pop .next-select-menu-item{padding-left:0!important}html body .xconsole-rcsearch-multi-pop .next-select-menu-item .next-menu-icon-selected{display:none}html body .xconsole-rcsearch-multi-pop .next-menu-group-label{padding-left:0}html body .xconsole-rc-search-popup{margin-top:4px}
|
|
1
|
+
html body .xconsole-rcsearch-multi-pop.xconsole-rcsearch-multi-pop>ul{padding:8px}html body .xconsole-rcsearch-multi-pop .next-select-menu-item{padding-left:0!important}html body .xconsole-rcsearch-multi-pop .next-select-menu-item .next-menu-icon-selected{display:none}html body .xconsole-rcsearch-multi-pop .next-menu-group-label{padding-left:0}html body .xconsole-rc-search-popup{margin-top:4px}html .console-tags-tag.console-tags-tag{font-weight:600;color:var(--color-text1-9,#333)!important}html .console-tags-tag.console-tags-tag .console-tags-tag-label{color:var(--color-text1-6,grey);margin-right:8px}html .console-tags-tag.console-tags-tag[class*=tag-closable]>[class*=tag-close-btn]{margin-left:12px}html .console-tags-tag.console-tags-tag.console-tags-tag.console-tags-tag:hover [class*=-icon-close]{color:#181818}html .console-tags-tag.console-tags-tag.console-tags-tag.console-tags-tag [class*=-icon-close]:before{content:var(--icon-content-delete-filling)}html .console-tags-tag:not(:last-child){margin-right:8px}html .console-tags-tag_empty{color:var(--color-text1-6,grey)}html .console-tags-tag-dot.console-tags-tag-dot [class*=-badge-dot]{right:4px;top:0}
|
|
@@ -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 11.42s
|
|
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';
|
|
@@ -15,6 +15,7 @@ import React, { useState, useRef } from "react";
|
|
|
15
15
|
import { Button, Icon, Select, ConfigProvider, Field, Checkbox } from '@alicloud/console-components';
|
|
16
16
|
import { SearchWarp, MultiBtnWarp } from "../style";
|
|
17
17
|
import SearchConditionSelectPrefix from "./InputPrefix";
|
|
18
|
+
import { SEARCH_FILTER_FIELD, SEARCH_FILTER_VALUE_FIELD } from "../constants";
|
|
18
19
|
var AutoComplete = Select.AutoComplete;
|
|
19
20
|
/**
|
|
20
21
|
*
|
|
@@ -68,12 +69,9 @@ var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, o
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
71
|
-
var _opt$templateProps2
|
|
72
|
+
var _opt$templateProps2;
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
return value.indexOf(d.value) !== -1;
|
|
75
|
-
}));
|
|
76
|
-
valueLabel = (_opt$templateProps3 = opt.templateProps) === null || _opt$templateProps3 === void 0 ? void 0 : _opt$templateProps3.dataSource.filter(function (d) {
|
|
74
|
+
valueLabel = (_opt$templateProps2 = opt.templateProps) === null || _opt$templateProps2 === void 0 ? void 0 : _opt$templateProps2.dataSource.filter(function (d) {
|
|
77
75
|
return value.indexOf(d.value) !== -1;
|
|
78
76
|
}).map(function (d) {
|
|
79
77
|
return d.label;
|
|
@@ -88,6 +86,18 @@ var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, o
|
|
|
88
86
|
};
|
|
89
87
|
};
|
|
90
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
|
+
|
|
91
101
|
var ComplexSearch = function ComplexSearch(props) {
|
|
92
102
|
var options = props.options,
|
|
93
103
|
fuzzy = props.fuzzy,
|
|
@@ -114,8 +124,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
114
124
|
var field = Field.useField();
|
|
115
125
|
var init = field.init,
|
|
116
126
|
getValue = field.getValue,
|
|
117
|
-
reset = field.reset
|
|
118
|
-
getError = field.getError;
|
|
127
|
+
reset = field.reset;
|
|
119
128
|
var focusProps = {
|
|
120
129
|
onFocus: function onFocus() {
|
|
121
130
|
setFocused(true);
|
|
@@ -125,14 +134,25 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
125
134
|
}
|
|
126
135
|
}; //计算视图,根据内部状态和输入的 props 决定一些值
|
|
127
136
|
|
|
128
|
-
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(
|
|
137
|
+
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
|
|
129
138
|
var defaultFilter = options.find(function (t) {
|
|
130
139
|
return t.dataIndex === defaultDataIndex;
|
|
131
140
|
});
|
|
141
|
+
|
|
142
|
+
var highlightItem = function highlightItem(item, searchKey) {
|
|
143
|
+
var label = item.label;
|
|
144
|
+
|
|
145
|
+
if (searchKey && searchKey.length) {
|
|
146
|
+
label = highlightKeyword(item.label, searchKey);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return label;
|
|
150
|
+
};
|
|
132
151
|
/**
|
|
133
152
|
* 处理筛选类型选中的情况
|
|
134
153
|
*/
|
|
135
154
|
|
|
155
|
+
|
|
136
156
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
137
157
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
138
158
|
setSelectedFilterType(options.find(function (o) {
|
|
@@ -146,7 +166,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
146
166
|
|
|
147
167
|
|
|
148
168
|
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy) {
|
|
149
|
-
var isFuzzySearch = isFuzzy && getValue(
|
|
169
|
+
var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD); // 如果是模糊搜索,则直接处理
|
|
150
170
|
|
|
151
171
|
if (isFuzzySearch) {
|
|
152
172
|
if (actionType !== 'change') {
|
|
@@ -169,10 +189,10 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
169
189
|
|
|
170
190
|
var handleSearch = function handleSearch() {
|
|
171
191
|
if (onSearch) {
|
|
172
|
-
var value = getValue(
|
|
192
|
+
var value = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
173
193
|
|
|
174
194
|
if (defaultDataIndex && !selectedFilterType) {
|
|
175
|
-
onSearch(getValue(
|
|
195
|
+
onSearch(getValue(SEARCH_FILTER_FIELD), defaultDataIndex, normalizeSearchOptions(defaultDataIndex, getValue(SEARCH_FILTER_FIELD), options));
|
|
176
196
|
}
|
|
177
197
|
|
|
178
198
|
if (selectedFilterType) {
|
|
@@ -181,6 +201,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
181
201
|
}
|
|
182
202
|
|
|
183
203
|
reset();
|
|
204
|
+
document.body.click();
|
|
184
205
|
setFocused(false);
|
|
185
206
|
};
|
|
186
207
|
|
|
@@ -192,7 +213,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
192
213
|
};
|
|
193
214
|
|
|
194
215
|
var renderMultipleSelectorItem = function renderMultipleSelectorItem(item) {
|
|
195
|
-
var searchValue = getValue(
|
|
216
|
+
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
196
217
|
var checked = isArray(searchValue) && searchValue.some(function (v) {
|
|
197
218
|
return v === item.value;
|
|
198
219
|
});
|
|
@@ -205,7 +226,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
205
226
|
var _selectedFilterType$t, _selectedFilterType$t2;
|
|
206
227
|
|
|
207
228
|
var type = selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template;
|
|
208
|
-
var searchValue = getValue(
|
|
229
|
+
var searchValue = getValue(SEARCH_FILTER_VALUE_FIELD);
|
|
209
230
|
|
|
210
231
|
var props = _objectSpread({
|
|
211
232
|
hasBorder: false,
|
|
@@ -225,7 +246,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
225
246
|
|
|
226
247
|
switch (type) {
|
|
227
248
|
case 'input':
|
|
228
|
-
return /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(
|
|
249
|
+
return /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_VALUE_FIELD, {}), {
|
|
229
250
|
className: classNames('main-input', 'multi')
|
|
230
251
|
}, props, {
|
|
231
252
|
onKeyUp: handleKeyUp
|
|
@@ -234,7 +255,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
234
255
|
case 'select':
|
|
235
256
|
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
236
257
|
className: classNames('main-input', 'select')
|
|
237
|
-
}, init(
|
|
258
|
+
}, init(SEARCH_FILTER_VALUE_FIELD, {
|
|
238
259
|
props: {
|
|
239
260
|
onChange: handleSearch
|
|
240
261
|
}
|
|
@@ -243,7 +264,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
243
264
|
case 'multiple':
|
|
244
265
|
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
245
266
|
className: classNames('main-input', 'multi')
|
|
246
|
-
}, init(
|
|
267
|
+
}, init(SEARCH_FILTER_VALUE_FIELD, {}), props, selectProps, {
|
|
247
268
|
itemRender: renderMultipleSelectorItem,
|
|
248
269
|
popupClassName: "xconsole-rcsearch-multi-pop",
|
|
249
270
|
mode: "multiple",
|
|
@@ -265,6 +286,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
265
286
|
type: "normal",
|
|
266
287
|
onClick: function onClick() {
|
|
267
288
|
reset();
|
|
289
|
+
document.body.click();
|
|
268
290
|
}
|
|
269
291
|
}, "\u53D6\u6D88"))
|
|
270
292
|
}
|
|
@@ -276,7 +298,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
276
298
|
};
|
|
277
299
|
|
|
278
300
|
var renderSelectFilterCloseIcon = function renderSelectFilterCloseIcon() {
|
|
279
|
-
var hasFilterTypeClearBtn = !!selectedFilterType && !((selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template) === 'input' && !!getValue(
|
|
301
|
+
var hasFilterTypeClearBtn = !!selectedFilterType && !((selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.template) === 'input' && !!getValue(SEARCH_FILTER_VALUE_FIELD));
|
|
280
302
|
return hasFilterTypeClearBtn && /*#__PURE__*/React.createElement("div", {
|
|
281
303
|
className: "clear-level1"
|
|
282
304
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -310,7 +332,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
310
332
|
}
|
|
311
333
|
}) : null), /*#__PURE__*/React.createElement("div", {
|
|
312
334
|
className: classNames('forms')
|
|
313
|
-
}, !selectedFilterType ? /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(
|
|
335
|
+
}, !selectedFilterType ? /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_FIELD, {
|
|
314
336
|
props: {
|
|
315
337
|
// @ts-ignore
|
|
316
338
|
onChange: function onChange(value, actionType) {
|
|
@@ -318,7 +340,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
318
340
|
}
|
|
319
341
|
}
|
|
320
342
|
}), {
|
|
321
|
-
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
itemRender: highlightItem,
|
|
322
345
|
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") : '请搜索',
|
|
323
346
|
className: classNames('main-input', 'multi'),
|
|
324
347
|
hasBorder: false,
|
|
@@ -330,7 +353,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
330
353
|
width: 'auto'
|
|
331
354
|
}
|
|
332
355
|
}, focusProps)) : null, renderSelectedFilter(), renderSelectFilterCloseIcon())), /*#__PURE__*/React.createElement("div", {
|
|
333
|
-
className: classNames('right-wrap')
|
|
356
|
+
className: classNames('right-wrap'),
|
|
357
|
+
ref: autoRef
|
|
334
358
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
335
359
|
className: classNames('search-btn', {
|
|
336
360
|
'focus': focused
|
|
@@ -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;
|
|
@@ -1,55 +1,129 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
2
8
|
import React from "react";
|
|
3
9
|
import classNames from 'classnames';
|
|
4
10
|
import { ConfigProvider, Tag } from '@alicloud/console-components';
|
|
5
11
|
import { TagListWrap } from '../style';
|
|
6
12
|
import { baseTagListClassName } from '../constants';
|
|
13
|
+
import isArray from 'lodash/isArray';
|
|
14
|
+
import PureTag from "./PureTag";
|
|
7
15
|
var TagGroup = Tag.Group,
|
|
8
16
|
ClosableTag = Tag.Closeable;
|
|
17
|
+
/**
|
|
18
|
+
* 判断是否是 标签 的数据结构
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var isTagLikeDataStructure = function isTagLikeDataStructure(value) {
|
|
22
|
+
var isTag = !!value.tagKey;
|
|
23
|
+
|
|
24
|
+
if (isArray(value)) {
|
|
25
|
+
return value[0] && !!value[0].tagKey;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return isTag;
|
|
29
|
+
};
|
|
9
30
|
|
|
10
31
|
var SearchTagList = function SearchTagList(props) {
|
|
11
32
|
var dataSource = props.dataSource,
|
|
12
33
|
className = props.className,
|
|
13
34
|
style = props.style,
|
|
14
35
|
onChange = props.onChange,
|
|
36
|
+
onClear = props.onClear,
|
|
15
37
|
_props$prefix = props.prefix,
|
|
16
38
|
prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
|
|
17
39
|
|
|
18
|
-
function
|
|
40
|
+
var onRemoveFilter = function onRemoveFilter(item) {
|
|
19
41
|
var newTagList = _toConsumableArray(dataSource);
|
|
20
42
|
|
|
21
43
|
if (onChange) {
|
|
22
44
|
var resFindIndex = newTagList.findIndex(function (x) {
|
|
23
45
|
return x.dataIndex === item.dataIndex;
|
|
24
46
|
});
|
|
25
|
-
newTagList.splice(resFindIndex, 1);
|
|
26
|
-
onChange(newTagList);
|
|
47
|
+
var deletedTags = newTagList.splice(resFindIndex, 1);
|
|
48
|
+
onChange(deletedTags[0], newTagList);
|
|
27
49
|
}
|
|
28
|
-
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var onRemoveAllFilter = function onRemoveAllFilter() {
|
|
53
|
+
if (onClear) {
|
|
54
|
+
onClear();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var onRemoveTag = function onRemoveTag(item, tag) {
|
|
59
|
+
var newDataSource = _toConsumableArray(dataSource);
|
|
29
60
|
|
|
30
|
-
function onRemoveAllTag() {
|
|
31
61
|
if (onChange) {
|
|
32
|
-
|
|
62
|
+
var resFindIndex = item.value.findIndex(function (x) {
|
|
63
|
+
return x.tagKey === tag.tagKey && x.tagValue === tag.tagValue;
|
|
64
|
+
});
|
|
65
|
+
var deletedTags = item.value.splice(resFindIndex, 1);
|
|
66
|
+
onChange(_objectSpread(_objectSpread({}, item), {}, {
|
|
67
|
+
value: deletedTags
|
|
68
|
+
}), newDataSource);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var renderTags = function renderTags(tagItem) {
|
|
73
|
+
var value = tagItem.value;
|
|
74
|
+
|
|
75
|
+
if (isArray(value)) {
|
|
76
|
+
return value.map(function (t) {
|
|
77
|
+
return /*#__PURE__*/React.createElement(PureTag, {
|
|
78
|
+
showLabel: true,
|
|
79
|
+
key: "".concat(t.tagKey, "-").concat(t.tagValue),
|
|
80
|
+
tagKey: t.tagKey,
|
|
81
|
+
tagValue: t.tagValue,
|
|
82
|
+
closable: true,
|
|
83
|
+
onClose: function onClose() {
|
|
84
|
+
onRemoveTag(tagItem, t);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
33
89
|
}
|
|
34
|
-
|
|
90
|
+
|
|
91
|
+
return /*#__PURE__*/React.createElement(PureTag, {
|
|
92
|
+
showLabel: true,
|
|
93
|
+
tagKey: value.tagKey,
|
|
94
|
+
tagValue: value.tagValue,
|
|
95
|
+
closable: true,
|
|
96
|
+
onClose: function onClose() {
|
|
97
|
+
onRemoveFilter(tagItem);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
35
102
|
|
|
36
103
|
return /*#__PURE__*/React.createElement(TagListWrap, {
|
|
37
104
|
prefix: prefix,
|
|
38
105
|
className: classNames(baseTagListClassName, className),
|
|
39
106
|
style: style
|
|
40
107
|
}, /*#__PURE__*/React.createElement(TagGroup, null, dataSource && dataSource.length > 0 && dataSource.map(function (tagItem) {
|
|
108
|
+
if (isTagLikeDataStructure(tagItem.value)) {
|
|
109
|
+
return renderTags(tagItem);
|
|
110
|
+
}
|
|
111
|
+
|
|
41
112
|
return /*#__PURE__*/React.createElement(ClosableTag, {
|
|
113
|
+
className: "console-tags-tag",
|
|
42
114
|
key: tagItem.dataIndex + tagItem.value,
|
|
43
115
|
type: "normal",
|
|
44
116
|
size: "medium",
|
|
45
117
|
onClose: function onClose() {
|
|
46
|
-
|
|
118
|
+
onRemoveFilter(tagItem);
|
|
47
119
|
return true;
|
|
48
120
|
}
|
|
49
|
-
},
|
|
121
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("label", {
|
|
122
|
+
className: "console-tags-tag-label"
|
|
123
|
+
}, tagItem.label), tagItem.valueLabel || tagItem.value));
|
|
50
124
|
}), dataSource && dataSource.length > 0 && /*#__PURE__*/React.createElement("a", {
|
|
51
125
|
className: "remove-btn",
|
|
52
|
-
onClick:
|
|
126
|
+
onClick: onRemoveAllFilter
|
|
53
127
|
}, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
|
|
54
128
|
};
|
|
55
129
|
|
package/es/style.js
CHANGED
|
@@ -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
|
+
import './index.less';
|
|
7
8
|
export { Search, SearchTagList as SearchFilter, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|