@alicloud/console-components-search 0.1.0
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 +193 -0
- package/config/breezr.docs.config.ts +28 -0
- package/config/components-with-style.tsx +2 -0
- package/config/config.ts +14 -0
- package/config/demoOpts.ts +12 -0
- package/demos/demo1.demo.tsx +143 -0
- package/demos/demo2.demo.tsx +110 -0
- package/demos/demo3.demo.tsx +115 -0
- package/demos/demo4.demo.tsx +144 -0
- package/dist/index.css +1 -0
- package/dist/index.js +60 -0
- package/doc-dist/0.js +27 -0
- package/doc-dist/1.js +1928 -0
- package/doc-dist/10.js +6 -0
- package/doc-dist/11.js +6 -0
- package/doc-dist/12.js +6 -0
- package/doc-dist/13.js +6 -0
- package/doc-dist/14.js +6 -0
- package/doc-dist/15.js +6 -0
- package/doc-dist/16.js +6 -0
- package/doc-dist/17.js +6 -0
- package/doc-dist/18.js +6 -0
- package/doc-dist/19.js +6 -0
- package/doc-dist/20.js +6 -0
- package/doc-dist/3.js +104 -0
- package/doc-dist/4.js +6 -0
- package/doc-dist/5.js +13 -0
- package/doc-dist/6.css +1 -0
- package/doc-dist/6.js +6 -0
- package/doc-dist/6.os.css +1 -0
- package/doc-dist/7.js +6 -0
- package/doc-dist/8.js +6 -0
- package/doc-dist/9.js +6 -0
- package/doc-dist/console-fe-test-rc-search-doc.manifest.json +18 -0
- package/doc-dist/deps/console-fe-test-rc-search-doc-deps.manifest.json +18 -0
- package/doc-dist/deps/index.html +14 -0
- package/doc-dist/deps/main.css +1 -0
- package/doc-dist/deps/main.js +66 -0
- package/doc-dist/deps/main.os.css +1 -0
- package/doc-dist/index.css +1 -0
- package/doc-dist/index.html +14 -0
- package/doc-dist/index.js +19 -0
- package/doc-dist/index.os.css +1 -0
- package/doc-dist/log-deps-build.log +16 -0
- package/docs/markdown-render.doc.md +21 -0
- package/docs/test.doc.md +8 -0
- package/es/constants.js +6 -0
- package/es/index.js +7 -0
- package/es/modeSingleMulti/index.js +862 -0
- package/es/modeSingleSingle/index.js +213 -0
- package/es/provider/LoggerProvider.js +37 -0
- package/es/search.js +23 -0
- package/es/searchTagList/index.js +58 -0
- package/es/style.js +14 -0
- 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/utils.js +149 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +15 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +55 -0
- package/lib/modeSingleMulti/index.d.ts +4 -0
- package/lib/modeSingleMulti/index.js +883 -0
- package/lib/modeSingleSingle/index.d.ts +4 -0
- package/lib/modeSingleSingle/index.js +237 -0
- package/lib/provider/LoggerProvider.d.ts +8 -0
- package/lib/provider/LoggerProvider.js +47 -0
- package/lib/search.d.ts +4 -0
- package/lib/search.js +42 -0
- package/lib/searchTagList/index.d.ts +4 -0
- package/lib/searchTagList/index.js +75 -0
- package/lib/style.d.ts +5 -0
- package/lib/style.js +34 -0
- package/lib/types/IRcSearchOptions.type.d.ts +26 -0
- package/lib/types/IRcSearchOptions.type.js +5 -0
- package/lib/types/IRcSearchProps.type.d.ts +76 -0
- package/lib/types/IRcSearchProps.type.js +5 -0
- package/lib/types/IRcSearchTagItemProps.type.d.ts +23 -0
- package/lib/types/IRcSearchTagItemProps.type.js +5 -0
- package/lib/types/IRcSearchTagListProps.type.d.ts +32 -0
- package/lib/types/IRcSearchTagListProps.type.js +5 -0
- package/lib/utils.d.ts +14 -0
- package/lib/utils.js +177 -0
- package/package.json +41 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import classNames from 'classnames'; // import styled from "styled-components";
|
|
6
|
+
|
|
7
|
+
import { Button, Icon, Select } from '@alicloud/console-components';
|
|
8
|
+
import { SearchWarp } from "../style";
|
|
9
|
+
import { getSelectOptionAdatp } from '../utils';
|
|
10
|
+
var AutoComplete = Select.AutoComplete;
|
|
11
|
+
|
|
12
|
+
var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
13
|
+
var options = props.options,
|
|
14
|
+
onSuggest = props.onSuggest,
|
|
15
|
+
onChange = props.onChange,
|
|
16
|
+
onSearch = props.onSearch;
|
|
17
|
+
var optionItem = options[0];
|
|
18
|
+
|
|
19
|
+
if (!optionItem.templateProps) {
|
|
20
|
+
optionItem.templateProps = {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var _useState = useState([]),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
inputDataSource = _useState2[0],
|
|
26
|
+
setInputDataSource = _useState2[1];
|
|
27
|
+
|
|
28
|
+
var _useState3 = useState(false),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
visible = _useState4[0],
|
|
31
|
+
setVisible = _useState4[1];
|
|
32
|
+
|
|
33
|
+
var _useState5 = useState({}),
|
|
34
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
|
+
allFileds = _useState6[0],
|
|
36
|
+
setAllFileds = _useState6[1];
|
|
37
|
+
|
|
38
|
+
var _useState7 = useState(''),
|
|
39
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
40
|
+
inputValue = _useState8[0],
|
|
41
|
+
setInputValue = _useState8[1];
|
|
42
|
+
|
|
43
|
+
var itemRender = function itemRender(item, searchKey) {
|
|
44
|
+
var label = item.label;
|
|
45
|
+
|
|
46
|
+
if (searchKey && searchKey.length) {
|
|
47
|
+
var key = searchKey.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
48
|
+
var reg = new RegExp("(".concat(key, ")"), 'ig');
|
|
49
|
+
label = label.replace(reg, function (x) {
|
|
50
|
+
return "<span class=\"next-select-highlight\" style=\"background-color: #EFF3F8;font-weight: 500;\">".concat(x, "</span>");
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
55
|
+
dangerouslySetInnerHTML: {
|
|
56
|
+
__html: label
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function inputChange(_x, _x2, _x3) {
|
|
62
|
+
return _inputChange.apply(this, arguments);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function _inputChange() {
|
|
66
|
+
_inputChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, actionType, dataIndex) {
|
|
67
|
+
var changeFileds, _changeFileds, list, newDataSource;
|
|
68
|
+
|
|
69
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
70
|
+
while (1) {
|
|
71
|
+
switch (_context.prev = _context.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(actionType === 'itemClick' && onChange)) {
|
|
74
|
+
_context.next = 8;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
changeFileds = Object.create({});
|
|
79
|
+
changeFileds[dataIndex] = value;
|
|
80
|
+
onChange(changeFileds, changeFileds);
|
|
81
|
+
setAllFileds(changeFileds);
|
|
82
|
+
setVisible(false);
|
|
83
|
+
_context.next = 18;
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 8:
|
|
87
|
+
setInputValue(value); // fuzzyDisable
|
|
88
|
+
|
|
89
|
+
if (!optionItem.templateProps || !optionItem.templateProps.fuzzyDisable) {
|
|
90
|
+
_changeFileds = Object.create({});
|
|
91
|
+
_changeFileds[dataIndex] = value;
|
|
92
|
+
|
|
93
|
+
if (onChange) {
|
|
94
|
+
onChange(_changeFileds, _changeFileds);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setAllFileds(_changeFileds);
|
|
98
|
+
} //
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if (value === '') {
|
|
102
|
+
setInputDataSource([]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!onSuggest) {
|
|
106
|
+
_context.next = 18;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_context.next = 14;
|
|
111
|
+
return onSuggest(value, dataIndex);
|
|
112
|
+
|
|
113
|
+
case 14:
|
|
114
|
+
list = _context.sent;
|
|
115
|
+
// console.log('res suggest', res);
|
|
116
|
+
newDataSource = [{
|
|
117
|
+
label: optionItem.label,
|
|
118
|
+
children: list
|
|
119
|
+
}];
|
|
120
|
+
setInputDataSource(newDataSource);
|
|
121
|
+
setVisible(true);
|
|
122
|
+
|
|
123
|
+
case 18:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context.stop();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, _callee);
|
|
129
|
+
}));
|
|
130
|
+
return _inputChange.apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function selectChange(_x4, _x5) {
|
|
134
|
+
return _selectChange.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function _selectChange() {
|
|
138
|
+
_selectChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value, dataIndex) {
|
|
139
|
+
var changeFileds;
|
|
140
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
141
|
+
while (1) {
|
|
142
|
+
switch (_context2.prev = _context2.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
if (onChange) {
|
|
145
|
+
changeFileds = Object.create({});
|
|
146
|
+
changeFileds[dataIndex] = value;
|
|
147
|
+
onChange(changeFileds, changeFileds);
|
|
148
|
+
setAllFileds(changeFileds);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
case 1:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context2.stop();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, _callee2);
|
|
157
|
+
}));
|
|
158
|
+
return _selectChange.apply(this, arguments);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function onCommonSearch() {
|
|
162
|
+
if (onSearch) {
|
|
163
|
+
onSearch(allFileds);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return /*#__PURE__*/React.createElement(SearchWarp, null, optionItem.template === 'input' && /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
className: classNames('left-wrap', 'next-input')
|
|
169
|
+
}, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
170
|
+
className: classNames('main-input', 'single'),
|
|
171
|
+
placeholder: optionItem.templateProps.placeholder || "\u9ED8\u8BA4\u6309".concat(optionItem.label, "\u641C\u7D22"),
|
|
172
|
+
hasClear: true,
|
|
173
|
+
hasBorder: false,
|
|
174
|
+
dataSource: inputDataSource,
|
|
175
|
+
visible: visible,
|
|
176
|
+
value: inputValue,
|
|
177
|
+
onBlur: function onBlur() {
|
|
178
|
+
setVisible(false);
|
|
179
|
+
} // @ts-ignore
|
|
180
|
+
,
|
|
181
|
+
itemRender: itemRender,
|
|
182
|
+
onChange: function onChange(value, actionType) {
|
|
183
|
+
inputChange(value, actionType, optionItem.dataIndex);
|
|
184
|
+
}
|
|
185
|
+
})), optionItem.template === 'select' && /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: classNames('left-wrap', 'next-input')
|
|
187
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
className: classNames('condition')
|
|
189
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
190
|
+
className: classNames('condition-item')
|
|
191
|
+
}, optionItem.label)), /*#__PURE__*/React.createElement(Select, {
|
|
192
|
+
className: classNames('main-input', 'single'),
|
|
193
|
+
placeholder: optionItem.templateProps.placeholder || "\u8BF7\u9009\u62E9".concat(optionItem.label),
|
|
194
|
+
hasClear: true,
|
|
195
|
+
hasBorder: false,
|
|
196
|
+
dataSource: getSelectOptionAdatp(optionItem.label, optionItem.templateProps.dataSource),
|
|
197
|
+
onChange: function onChange(value) {
|
|
198
|
+
selectChange(value, optionItem.dataIndex);
|
|
199
|
+
},
|
|
200
|
+
popupStyle: {
|
|
201
|
+
minWidth: 'auto'
|
|
202
|
+
}
|
|
203
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
className: classNames('right-wrap')
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
206
|
+
className: classNames('search-btn'),
|
|
207
|
+
onClick: onCommonSearch
|
|
208
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
209
|
+
type: "search"
|
|
210
|
+
}))));
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default ModeSingleSingle;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { getEnv, getLogger, isValidKey } from '../utils';
|
|
3
|
+
;
|
|
4
|
+
var TOPIC = 'com-usage';
|
|
5
|
+
var SAMPLING = getEnv() === 'local' ? 1 : 0.5; // 用来记录是否已经发送过日志,防止日志量太多,比如在列表中使用组件
|
|
6
|
+
|
|
7
|
+
var LOGGER_RECORD = {};
|
|
8
|
+
|
|
9
|
+
var LoggerProvider = function LoggerProvider(props) {
|
|
10
|
+
var regionId = props.regionId,
|
|
11
|
+
resourceType = props.resourceType,
|
|
12
|
+
componentName = props.componentName;
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
var recordKey = "".concat(componentName, "-").concat(resourceType);
|
|
15
|
+
var propsArr = new Array();
|
|
16
|
+
["regionId", "resourceType"].forEach(function (t) {
|
|
17
|
+
if (t && isValidKey(t, props)) {
|
|
18
|
+
propsArr.push("".concat(t, "=").concat(props[t]));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var info = {
|
|
22
|
+
env: getEnv(),
|
|
23
|
+
properties: propsArr.join('&'),
|
|
24
|
+
component: componentName
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (!LOGGER_RECORD[recordKey]) {
|
|
28
|
+
getLogger().log(TOPIC, info, {
|
|
29
|
+
sampling: SAMPLING
|
|
30
|
+
});
|
|
31
|
+
LOGGER_RECORD[recordKey] = true;
|
|
32
|
+
}
|
|
33
|
+
}, [regionId, resourceType, componentName]);
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default LoggerProvider;
|
package/es/search.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ModeSingleSingle from "./modeSingleSingle";
|
|
3
|
+
import ModeSingleMulti from "./modeSingleMulti";
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { baseClassName } from './constants';
|
|
7
|
+
import LoggerProvider from './provider/LoggerProvider';
|
|
8
|
+
var SearchWrap = styled.div.withConfig({
|
|
9
|
+
componentId: "sc-1szhzw4-0"
|
|
10
|
+
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
11
|
+
export var Search = function Search(props) {
|
|
12
|
+
var className = props.className,
|
|
13
|
+
mode = props.mode,
|
|
14
|
+
style = props.style;
|
|
15
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoggerProvider, {
|
|
16
|
+
regionId: props.regionId,
|
|
17
|
+
resourceType: props.resourceType || '',
|
|
18
|
+
componentName: "RcSearch"
|
|
19
|
+
}), /*#__PURE__*/React.createElement(SearchWrap, {
|
|
20
|
+
className: classNames(baseClassName, className),
|
|
21
|
+
style: style
|
|
22
|
+
}, mode === 'single-single' && /*#__PURE__*/React.createElement(ModeSingleSingle, props), mode === 'single-multi' && /*#__PURE__*/React.createElement(ModeSingleMulti, props), mode === 'multi-multi' && /*#__PURE__*/React.createElement(ModeSingleMulti, props)));
|
|
23
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Tag } from '@alicloud/console-components';
|
|
5
|
+
import LoggerProvider from '../provider/LoggerProvider';
|
|
6
|
+
import { TagListWrap } from '../style';
|
|
7
|
+
import { baseTagListClassName } from '../constants';
|
|
8
|
+
var TagGroup = Tag.Group,
|
|
9
|
+
ClosableTag = Tag.Closeable;
|
|
10
|
+
|
|
11
|
+
var SearchTagList = function SearchTagList(props) {
|
|
12
|
+
var tagList = props.tagList,
|
|
13
|
+
className = props.className,
|
|
14
|
+
style = props.style,
|
|
15
|
+
onChange = props.onChange;
|
|
16
|
+
|
|
17
|
+
function onRemoveTag(item) {
|
|
18
|
+
var newTagList = _toConsumableArray(tagList);
|
|
19
|
+
|
|
20
|
+
if (onChange) {
|
|
21
|
+
var resFindIndex = newTagList.findIndex(function (x) {
|
|
22
|
+
return x.dataIndex === item.dataIndex;
|
|
23
|
+
});
|
|
24
|
+
newTagList.splice(resFindIndex, 1);
|
|
25
|
+
onChange(newTagList);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function onRemoveAllTag() {
|
|
30
|
+
if (onChange) {
|
|
31
|
+
onChange([]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return /*#__PURE__*/React.createElement(TagListWrap, {
|
|
36
|
+
className: classNames(baseTagListClassName, className),
|
|
37
|
+
style: style
|
|
38
|
+
}, /*#__PURE__*/React.createElement(LoggerProvider, {
|
|
39
|
+
regionId: props.regionId,
|
|
40
|
+
resourceType: props.resourceType || '',
|
|
41
|
+
componentName: "RcSearch"
|
|
42
|
+
}), /*#__PURE__*/React.createElement(TagGroup, null, tagList && tagList.length > 0 && tagList.map(function (tagItem) {
|
|
43
|
+
return /*#__PURE__*/React.createElement(ClosableTag, {
|
|
44
|
+
key: tagItem.dataIndex + tagItem.value,
|
|
45
|
+
type: "normal",
|
|
46
|
+
size: "medium",
|
|
47
|
+
onClose: function onClose() {
|
|
48
|
+
onRemoveTag(tagItem);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}, tagItem.label, ":", tagItem.valueShow);
|
|
52
|
+
}), tagList && tagList.length > 0 && /*#__PURE__*/React.createElement("a", {
|
|
53
|
+
className: "remove-btn",
|
|
54
|
+
onClick: onRemoveAllTag
|
|
55
|
+
}, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default SearchTagList;
|
package/es/style.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
var SearchWarp = styled.div.withConfig({
|
|
3
|
+
componentId: "sc-1afc1cn-0"
|
|
4
|
+
})(["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;}.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;.next-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%;}.next-input,.xdemo-input{height:auto;box-shadow:none;}}.xdemo-input.xdemo-medium{height:auto;}}.right-wrap{width:32px;.search-btn{width:32px;border-bottom-left-radius:0;border-top-left-radius:0;border-left:none;}}"]);
|
|
5
|
+
var MenuContentWrap = styled.ul.withConfig({
|
|
6
|
+
componentId: "sc-1afc1cn-1"
|
|
7
|
+
})([".next-tag-small.next-tag-closable > .next-tag-close-btn{margin-left:8px;padding-right:4px;padding-top:1px;}.next-tag-small.next-tag-closable > .next-tag-body{max-width:calc(100% - 8px - 8px - var(--tag-size-m-padding-lr,8px));}.next-tag-small.next-tag-closable > .next-tag-close-btn .next-icon:before,.next-tag-small.next-tag-closable > .next-tag-close-btn .next-icon .next-icon-remote{font-size:13px;}&& [class*='-icon-close']:hover::before{color:#181818;}&& [class*='-icon-close']::before{color:#808080;content:var(--icon-content-delete-filling);}"]);
|
|
8
|
+
var MultiBtnWarp = styled.div.withConfig({
|
|
9
|
+
componentId: "sc-1afc1cn-2"
|
|
10
|
+
})(["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;}.next-btn.next-small:not(.isOnlyIcon):not(.next-btn-text){min-width:auto;}"]);
|
|
11
|
+
var TagListWrap = styled.div.withConfig({
|
|
12
|
+
componentId: "sc-1afc1cn-3"
|
|
13
|
+
})([".next-tag-medium.next-tag-closable > .next-tag-close-btn{margin-left:8px;padding-right:6px;}.next-tag-medium.next-tag-closable > .next-tag-body{max-width:calc(100% - 8px - 8px - var(--tag-size-m-padding-lr,8px));}.next-tag-medium.next-tag-closable > .next-tag-close-btn .next-icon:before,.next-tag-medium.next-tag-closable > .next-tag-close-btn .next-icon .next-icon-remote{font-size:16px;}&& [class*='-icon-close']:hover::before{color:#181818;}&& [class*='-icon-close']::before{color:#808080;content:var(--icon-content-delete-filling);}.remove-btn{margin-bottom:8px;line-height:24px;display:inline-block;vertical-align:middle;cursor:pointer;}"]);
|
|
14
|
+
export { SearchWarp, MultiBtnWarp, TagListWrap, MenuContentWrap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/utils.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import { uniqWith, isEqual } from 'lodash';
|
|
4
|
+
import createLogger from '@alicloud/console-logger-sls';
|
|
5
|
+
var historyTagKey = "xconsole-rcsearch-historytag-".concat(location.origin).concat(location.pathname); // 从localStorage中获取tagList
|
|
6
|
+
|
|
7
|
+
var getHistoryTag = function getHistoryTag() {
|
|
8
|
+
var tagStr = localStorage.getItem(historyTagKey);
|
|
9
|
+
|
|
10
|
+
if (tagStr) {
|
|
11
|
+
return JSON.parse(tagStr);
|
|
12
|
+
} else {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}; // 向localStorage中存入tagList
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var setHistoryTag = function setHistoryTag(newTagList) {
|
|
19
|
+
var tagsHistory = getHistoryTag();
|
|
20
|
+
var newHTags = tagsHistory.concat(newTagList);
|
|
21
|
+
|
|
22
|
+
if (newHTags.length > 5) {
|
|
23
|
+
newHTags.reverse();
|
|
24
|
+
newHTags = uniqWith(newHTags, isEqual);
|
|
25
|
+
newHTags.length = 5;
|
|
26
|
+
newHTags.reverse();
|
|
27
|
+
} else {
|
|
28
|
+
newHTags = uniqWith(newHTags, isEqual);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
localStorage.setItem(historyTagKey, JSON.stringify(newHTags));
|
|
32
|
+
return newHTags;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var removeHistoryTagItem = function removeHistoryTagItem(tagItem) {
|
|
36
|
+
var tagsHistory = getHistoryTag();
|
|
37
|
+
var findTagIndex = -1;
|
|
38
|
+
|
|
39
|
+
if (tagsHistory && tagsHistory.length > 0) {
|
|
40
|
+
findTagIndex = tagsHistory.findIndex(function (x) {
|
|
41
|
+
if (tagItem.dataIndex === x.dataIndex && tagItem.valueShow === x.valueShow) {
|
|
42
|
+
return true;
|
|
43
|
+
} else {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (findTagIndex >= 0) {
|
|
50
|
+
tagsHistory.splice(findTagIndex, 1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
localStorage.setItem(historyTagKey, JSON.stringify(tagsHistory));
|
|
54
|
+
return tagsHistory;
|
|
55
|
+
}; // 将内部的表单对象, 转化成taglist array
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
var getTagByFileds = function getTagByFileds(fileds, options) {
|
|
59
|
+
var rtTags = new Array();
|
|
60
|
+
Object.keys(fileds).forEach(function (key) {
|
|
61
|
+
var resItem = options.find(function (x) {
|
|
62
|
+
return x.dataIndex === key;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (resItem && fileds[key]) {
|
|
66
|
+
var tagItem = {
|
|
67
|
+
label: resItem.label,
|
|
68
|
+
dataIndex: key,
|
|
69
|
+
value: fileds[key],
|
|
70
|
+
valueShow: ''
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (resItem.template === 'input') {
|
|
74
|
+
tagItem.valueShow = fileds[key];
|
|
75
|
+
} else if (resItem.template === 'select') {
|
|
76
|
+
tagItem.valueShow = resItem.templateProps.dataSource.find(function (y) {
|
|
77
|
+
return y.value === fileds[key];
|
|
78
|
+
}).label;
|
|
79
|
+
} else if (resItem.template === 'multiple') {
|
|
80
|
+
tagItem.valueShow = '';
|
|
81
|
+
var valueShowArr = new Array();
|
|
82
|
+
fileds[key].forEach(function (y) {
|
|
83
|
+
var findMul = resItem.templateProps.dataSource.find(function (z) {
|
|
84
|
+
return z.value === y;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (findMul) {
|
|
88
|
+
valueShowArr.push(findMul.label);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
tagItem.valueShow = valueShowArr.join('/');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
rtTags.push(tagItem);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return rtTags;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var checkNoIndexListFormat = function checkNoIndexListFormat(list) {
|
|
101
|
+
var isOk = true;
|
|
102
|
+
list.forEach(function (groupItem) {
|
|
103
|
+
if (groupItem && groupItem.children && Array.isArray(groupItem.children) && groupItem.children.length > 0) {
|
|
104
|
+
groupItem.children.forEach(function (item) {
|
|
105
|
+
if (_typeof(item) !== 'object' || !item.dataIndex) {
|
|
106
|
+
console.warn('onSuggestNoDataIndex的返回list应参考实例,每个下拉选择项应有dataIndex字段');
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var getSelectOptionAdatp = function getSelectOptionAdatp(title, list) {
|
|
114
|
+
return [{
|
|
115
|
+
label: title || '',
|
|
116
|
+
children: _toConsumableArray(list)
|
|
117
|
+
}];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var getEnv = function getEnv() {
|
|
121
|
+
var _window, _window$ALIYUN_CONSOL;
|
|
122
|
+
|
|
123
|
+
if (process.env.NODE_ENV === 'development') {
|
|
124
|
+
return 'local';
|
|
125
|
+
} // @ts-ignore
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
return ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.fEnv) || 'prod';
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var logger = null;
|
|
132
|
+
|
|
133
|
+
var getLogger = function getLogger() {
|
|
134
|
+
if (!logger) {
|
|
135
|
+
logger = createLogger({
|
|
136
|
+
project: 'stonehenge-console',
|
|
137
|
+
endpoint: 'cn-hangzhou.log.aliyuncs.com',
|
|
138
|
+
logstore: "com-usage-origin"
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return logger;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var isValidKey = function isValidKey(key, object) {
|
|
146
|
+
return key in object;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { getHistoryTag, setHistoryTag, removeHistoryTagItem, getTagByFileds, checkNoIndexListFormat, getSelectOptionAdatp, getEnv, getLogger, isValidKey };
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.baseTagListClassName = exports.baseClassName = void 0;
|
|
7
|
+
var baseClassName = 'rc-search';
|
|
8
|
+
exports.baseClassName = baseClassName;
|
|
9
|
+
var baseTagListClassName = "".concat(baseClassName, "-taglist"); // export const titleClassName = `${baseClassName}-title`
|
|
10
|
+
// export const titleContainerClassName = `${titleClassName}-container`
|
|
11
|
+
// export const titleExtraClassName = `${titleClassName}-extra`
|
|
12
|
+
// export const titleChildrenClassName = `${titleClassName}-children`
|
|
13
|
+
// export const contentClassName = `${baseClassName}-content`
|
|
14
|
+
|
|
15
|
+
exports.baseTagListClassName = baseTagListClassName;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
import { IRcSearchTagItemProps } from './types/IRcSearchTagItemProps.type';
|
|
6
|
+
import { IRcSearchOptionsProps } from './types/IRcSearchOptions.type';
|
|
7
|
+
export { Search, SearchTagList, IRcSearchProps, IRcSearchTagListProps, IRcSearchOptionsProps, IRcSearchTagItemProps };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "IRcSearchOptionsProps", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _IRcSearchOptions.IRcSearchOptionsProps;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "IRcSearchProps", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _IRcSearchProps.IRcSearchProps;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "IRcSearchTagItemProps", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _IRcSearchTagItemProps.IRcSearchTagItemProps;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "IRcSearchTagListProps", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _IRcSearchTagListProps.IRcSearchTagListProps;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "Search", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _search.Search;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "SearchTagList", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _searchTagList.default;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
var _search = require("./search");
|
|
46
|
+
|
|
47
|
+
var _searchTagList = _interopRequireDefault(require("./searchTagList"));
|
|
48
|
+
|
|
49
|
+
var _IRcSearchProps = require("./types/IRcSearchProps.type");
|
|
50
|
+
|
|
51
|
+
var _IRcSearchTagListProps = require("./types/IRcSearchTagListProps.type");
|
|
52
|
+
|
|
53
|
+
var _IRcSearchTagItemProps = require("./types/IRcSearchTagItemProps.type");
|
|
54
|
+
|
|
55
|
+
var _IRcSearchOptions = require("./types/IRcSearchOptions.type");
|