@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,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
+
|
|
22
|
+
var _consoleComponents = require("@alicloud/console-components");
|
|
23
|
+
|
|
24
|
+
var _style = require("../style");
|
|
25
|
+
|
|
26
|
+
var _utils = require("../utils");
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
32
|
+
// import styled from "styled-components";
|
|
33
|
+
var AutoComplete = _consoleComponents.Select.AutoComplete;
|
|
34
|
+
|
|
35
|
+
var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
36
|
+
var options = props.options,
|
|
37
|
+
onSuggest = props.onSuggest,
|
|
38
|
+
onChange = props.onChange,
|
|
39
|
+
onSearch = props.onSearch;
|
|
40
|
+
var optionItem = options[0];
|
|
41
|
+
|
|
42
|
+
if (!optionItem.templateProps) {
|
|
43
|
+
optionItem.templateProps = {};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var _useState = (0, _react.useState)([]),
|
|
47
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
+
inputDataSource = _useState2[0],
|
|
49
|
+
setInputDataSource = _useState2[1];
|
|
50
|
+
|
|
51
|
+
var _useState3 = (0, _react.useState)(false),
|
|
52
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
53
|
+
visible = _useState4[0],
|
|
54
|
+
setVisible = _useState4[1];
|
|
55
|
+
|
|
56
|
+
var _useState5 = (0, _react.useState)({}),
|
|
57
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
+
allFileds = _useState6[0],
|
|
59
|
+
setAllFileds = _useState6[1];
|
|
60
|
+
|
|
61
|
+
var _useState7 = (0, _react.useState)(''),
|
|
62
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
63
|
+
inputValue = _useState8[0],
|
|
64
|
+
setInputValue = _useState8[1];
|
|
65
|
+
|
|
66
|
+
var itemRender = function itemRender(item, searchKey) {
|
|
67
|
+
var label = item.label;
|
|
68
|
+
|
|
69
|
+
if (searchKey && searchKey.length) {
|
|
70
|
+
var key = searchKey.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
71
|
+
var reg = new RegExp("(".concat(key, ")"), 'ig');
|
|
72
|
+
label = label.replace(reg, function (x) {
|
|
73
|
+
return "<span class=\"next-select-highlight\" style=\"background-color: #EFF3F8;font-weight: 500;\">".concat(x, "</span>");
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
78
|
+
dangerouslySetInnerHTML: {
|
|
79
|
+
__html: label
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
function inputChange(_x, _x2, _x3) {
|
|
85
|
+
return _inputChange.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _inputChange() {
|
|
89
|
+
_inputChange = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(value, actionType, dataIndex) {
|
|
90
|
+
var changeFileds, _changeFileds, list, newDataSource;
|
|
91
|
+
|
|
92
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
93
|
+
while (1) {
|
|
94
|
+
switch (_context.prev = _context.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
if (!(actionType === 'itemClick' && onChange)) {
|
|
97
|
+
_context.next = 8;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
changeFileds = Object.create({});
|
|
102
|
+
changeFileds[dataIndex] = value;
|
|
103
|
+
onChange(changeFileds, changeFileds);
|
|
104
|
+
setAllFileds(changeFileds);
|
|
105
|
+
setVisible(false);
|
|
106
|
+
_context.next = 18;
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
case 8:
|
|
110
|
+
setInputValue(value); // fuzzyDisable
|
|
111
|
+
|
|
112
|
+
if (!optionItem.templateProps || !optionItem.templateProps.fuzzyDisable) {
|
|
113
|
+
_changeFileds = Object.create({});
|
|
114
|
+
_changeFileds[dataIndex] = value;
|
|
115
|
+
|
|
116
|
+
if (onChange) {
|
|
117
|
+
onChange(_changeFileds, _changeFileds);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
setAllFileds(_changeFileds);
|
|
121
|
+
} //
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if (value === '') {
|
|
125
|
+
setInputDataSource([]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!onSuggest) {
|
|
129
|
+
_context.next = 18;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_context.next = 14;
|
|
134
|
+
return onSuggest(value, dataIndex);
|
|
135
|
+
|
|
136
|
+
case 14:
|
|
137
|
+
list = _context.sent;
|
|
138
|
+
// console.log('res suggest', res);
|
|
139
|
+
newDataSource = [{
|
|
140
|
+
label: optionItem.label,
|
|
141
|
+
children: list
|
|
142
|
+
}];
|
|
143
|
+
setInputDataSource(newDataSource);
|
|
144
|
+
setVisible(true);
|
|
145
|
+
|
|
146
|
+
case 18:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context.stop();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}, _callee);
|
|
152
|
+
}));
|
|
153
|
+
return _inputChange.apply(this, arguments);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function selectChange(_x4, _x5) {
|
|
157
|
+
return _selectChange.apply(this, arguments);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _selectChange() {
|
|
161
|
+
_selectChange = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(value, dataIndex) {
|
|
162
|
+
var changeFileds;
|
|
163
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
164
|
+
while (1) {
|
|
165
|
+
switch (_context2.prev = _context2.next) {
|
|
166
|
+
case 0:
|
|
167
|
+
if (onChange) {
|
|
168
|
+
changeFileds = Object.create({});
|
|
169
|
+
changeFileds[dataIndex] = value;
|
|
170
|
+
onChange(changeFileds, changeFileds);
|
|
171
|
+
setAllFileds(changeFileds);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
case 1:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context2.stop();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, _callee2);
|
|
180
|
+
}));
|
|
181
|
+
return _selectChange.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function onCommonSearch() {
|
|
185
|
+
if (onSearch) {
|
|
186
|
+
onSearch(allFileds);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return /*#__PURE__*/_react.default.createElement(_style.SearchWarp, null, optionItem.template === 'input' && /*#__PURE__*/_react.default.createElement("div", {
|
|
191
|
+
className: (0, _classnames.default)('left-wrap', 'next-input')
|
|
192
|
+
}, /*#__PURE__*/_react.default.createElement(AutoComplete, {
|
|
193
|
+
className: (0, _classnames.default)('main-input', 'single'),
|
|
194
|
+
placeholder: optionItem.templateProps.placeholder || "\u9ED8\u8BA4\u6309".concat(optionItem.label, "\u641C\u7D22"),
|
|
195
|
+
hasClear: true,
|
|
196
|
+
hasBorder: false,
|
|
197
|
+
dataSource: inputDataSource,
|
|
198
|
+
visible: visible,
|
|
199
|
+
value: inputValue,
|
|
200
|
+
onBlur: function onBlur() {
|
|
201
|
+
setVisible(false);
|
|
202
|
+
} // @ts-ignore
|
|
203
|
+
,
|
|
204
|
+
itemRender: itemRender,
|
|
205
|
+
onChange: function onChange(value, actionType) {
|
|
206
|
+
inputChange(value, actionType, optionItem.dataIndex);
|
|
207
|
+
}
|
|
208
|
+
})), optionItem.template === 'select' && /*#__PURE__*/_react.default.createElement("div", {
|
|
209
|
+
className: (0, _classnames.default)('left-wrap', 'next-input')
|
|
210
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
211
|
+
className: (0, _classnames.default)('condition')
|
|
212
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
213
|
+
className: (0, _classnames.default)('condition-item')
|
|
214
|
+
}, optionItem.label)), /*#__PURE__*/_react.default.createElement(_consoleComponents.Select, {
|
|
215
|
+
className: (0, _classnames.default)('main-input', 'single'),
|
|
216
|
+
placeholder: optionItem.templateProps.placeholder || "\u8BF7\u9009\u62E9".concat(optionItem.label),
|
|
217
|
+
hasClear: true,
|
|
218
|
+
hasBorder: false,
|
|
219
|
+
dataSource: (0, _utils.getSelectOptionAdatp)(optionItem.label, optionItem.templateProps.dataSource),
|
|
220
|
+
onChange: function onChange(value) {
|
|
221
|
+
selectChange(value, optionItem.dataIndex);
|
|
222
|
+
},
|
|
223
|
+
popupStyle: {
|
|
224
|
+
minWidth: 'auto'
|
|
225
|
+
}
|
|
226
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
227
|
+
className: (0, _classnames.default)('right-wrap')
|
|
228
|
+
}, /*#__PURE__*/_react.default.createElement(_consoleComponents.Button, {
|
|
229
|
+
className: (0, _classnames.default)('search-btn'),
|
|
230
|
+
onClick: onCommonSearch
|
|
231
|
+
}, /*#__PURE__*/_react.default.createElement(_consoleComponents.Icon, {
|
|
232
|
+
type: "search"
|
|
233
|
+
}))));
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
var _default = ModeSingleSingle;
|
|
237
|
+
exports.default = _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
|
|
12
|
+
;
|
|
13
|
+
var TOPIC = 'com-usage';
|
|
14
|
+
var SAMPLING = (0, _utils.getEnv)() === 'local' ? 1 : 0.5; // 用来记录是否已经发送过日志,防止日志量太多,比如在列表中使用组件
|
|
15
|
+
|
|
16
|
+
var LOGGER_RECORD = {};
|
|
17
|
+
|
|
18
|
+
var LoggerProvider = function LoggerProvider(props) {
|
|
19
|
+
var regionId = props.regionId,
|
|
20
|
+
resourceType = props.resourceType,
|
|
21
|
+
componentName = props.componentName;
|
|
22
|
+
(0, _react.useEffect)(function () {
|
|
23
|
+
var recordKey = "".concat(componentName, "-").concat(resourceType);
|
|
24
|
+
var propsArr = new Array();
|
|
25
|
+
["regionId", "resourceType"].forEach(function (t) {
|
|
26
|
+
if (t && (0, _utils.isValidKey)(t, props)) {
|
|
27
|
+
propsArr.push("".concat(t, "=").concat(props[t]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var info = {
|
|
31
|
+
env: (0, _utils.getEnv)(),
|
|
32
|
+
properties: propsArr.join('&'),
|
|
33
|
+
component: componentName
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!LOGGER_RECORD[recordKey]) {
|
|
37
|
+
(0, _utils.getLogger)().log(TOPIC, info, {
|
|
38
|
+
sampling: SAMPLING
|
|
39
|
+
});
|
|
40
|
+
LOGGER_RECORD[recordKey] = true;
|
|
41
|
+
}
|
|
42
|
+
}, [regionId, resourceType, componentName]);
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var _default = LoggerProvider;
|
|
47
|
+
exports.default = _default;
|
package/lib/search.d.ts
ADDED
package/lib/search.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Search = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _modeSingleSingle = _interopRequireDefault(require("./modeSingleSingle"));
|
|
13
|
+
|
|
14
|
+
var _modeSingleMulti = _interopRequireDefault(require("./modeSingleMulti"));
|
|
15
|
+
|
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
|
|
18
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
+
|
|
20
|
+
var _constants = require("./constants");
|
|
21
|
+
|
|
22
|
+
var _LoggerProvider = _interopRequireDefault(require("./provider/LoggerProvider"));
|
|
23
|
+
|
|
24
|
+
var SearchWrap = _styledComponents.default.div.withConfig({
|
|
25
|
+
componentId: "sc-1szhzw4-0"
|
|
26
|
+
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
27
|
+
|
|
28
|
+
var Search = function Search(props) {
|
|
29
|
+
var className = props.className,
|
|
30
|
+
mode = props.mode,
|
|
31
|
+
style = props.style;
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_LoggerProvider.default, {
|
|
33
|
+
regionId: props.regionId,
|
|
34
|
+
resourceType: props.resourceType || '',
|
|
35
|
+
componentName: "RcSearch"
|
|
36
|
+
}), /*#__PURE__*/_react.default.createElement(SearchWrap, {
|
|
37
|
+
className: (0, _classnames.default)(_constants.baseClassName, className),
|
|
38
|
+
style: style
|
|
39
|
+
}, mode === 'single-single' && /*#__PURE__*/_react.default.createElement(_modeSingleSingle.default, props), mode === 'single-multi' && /*#__PURE__*/_react.default.createElement(_modeSingleMulti.default, props), mode === 'multi-multi' && /*#__PURE__*/_react.default.createElement(_modeSingleMulti.default, props)));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.Search = Search;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
16
|
+
var _consoleComponents = require("@alicloud/console-components");
|
|
17
|
+
|
|
18
|
+
var _LoggerProvider = _interopRequireDefault(require("../provider/LoggerProvider"));
|
|
19
|
+
|
|
20
|
+
var _style = require("../style");
|
|
21
|
+
|
|
22
|
+
var _constants = require("../constants");
|
|
23
|
+
|
|
24
|
+
var TagGroup = _consoleComponents.Tag.Group,
|
|
25
|
+
ClosableTag = _consoleComponents.Tag.Closeable;
|
|
26
|
+
|
|
27
|
+
var SearchTagList = function SearchTagList(props) {
|
|
28
|
+
var tagList = props.tagList,
|
|
29
|
+
className = props.className,
|
|
30
|
+
style = props.style,
|
|
31
|
+
onChange = props.onChange;
|
|
32
|
+
|
|
33
|
+
function onRemoveTag(item) {
|
|
34
|
+
var newTagList = (0, _toConsumableArray2.default)(tagList);
|
|
35
|
+
|
|
36
|
+
if (onChange) {
|
|
37
|
+
var resFindIndex = newTagList.findIndex(function (x) {
|
|
38
|
+
return x.dataIndex === item.dataIndex;
|
|
39
|
+
});
|
|
40
|
+
newTagList.splice(resFindIndex, 1);
|
|
41
|
+
onChange(newTagList);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onRemoveAllTag() {
|
|
46
|
+
if (onChange) {
|
|
47
|
+
onChange([]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_style.TagListWrap, {
|
|
52
|
+
className: (0, _classnames.default)(_constants.baseTagListClassName, className),
|
|
53
|
+
style: style
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement(_LoggerProvider.default, {
|
|
55
|
+
regionId: props.regionId,
|
|
56
|
+
resourceType: props.resourceType || '',
|
|
57
|
+
componentName: "RcSearch"
|
|
58
|
+
}), /*#__PURE__*/_react.default.createElement(TagGroup, null, tagList && tagList.length > 0 && tagList.map(function (tagItem) {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(ClosableTag, {
|
|
60
|
+
key: tagItem.dataIndex + tagItem.value,
|
|
61
|
+
type: "normal",
|
|
62
|
+
size: "medium",
|
|
63
|
+
onClose: function onClose() {
|
|
64
|
+
onRemoveTag(tagItem);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}, tagItem.label, ":", tagItem.valueShow);
|
|
68
|
+
}), tagList && tagList.length > 0 && /*#__PURE__*/_react.default.createElement("a", {
|
|
69
|
+
className: "remove-btn",
|
|
70
|
+
onClick: onRemoveAllTag
|
|
71
|
+
}, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var _default = SearchTagList;
|
|
75
|
+
exports.default = _default;
|
package/lib/style.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const SearchWarp: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
declare const MenuContentWrap: import("styled-components").StyledComponent<"ul", any, {}, never>;
|
|
3
|
+
declare const MultiBtnWarp: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const TagListWrap: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export { SearchWarp, MultiBtnWarp, TagListWrap, MenuContentWrap };
|
package/lib/style.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.TagListWrap = exports.SearchWarp = exports.MultiBtnWarp = exports.MenuContentWrap = void 0;
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var SearchWarp = _styledComponents.default.div.withConfig({
|
|
13
|
+
componentId: "sc-1afc1cn-0"
|
|
14
|
+
})(["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;}}"]);
|
|
15
|
+
|
|
16
|
+
exports.SearchWarp = SearchWarp;
|
|
17
|
+
|
|
18
|
+
var MenuContentWrap = _styledComponents.default.ul.withConfig({
|
|
19
|
+
componentId: "sc-1afc1cn-1"
|
|
20
|
+
})([".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);}"]);
|
|
21
|
+
|
|
22
|
+
exports.MenuContentWrap = MenuContentWrap;
|
|
23
|
+
|
|
24
|
+
var MultiBtnWarp = _styledComponents.default.div.withConfig({
|
|
25
|
+
componentId: "sc-1afc1cn-2"
|
|
26
|
+
})(["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;}"]);
|
|
27
|
+
|
|
28
|
+
exports.MultiBtnWarp = MultiBtnWarp;
|
|
29
|
+
|
|
30
|
+
var TagListWrap = _styledComponents.default.div.withConfig({
|
|
31
|
+
componentId: "sc-1afc1cn-3"
|
|
32
|
+
})([".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;}"]);
|
|
33
|
+
|
|
34
|
+
exports.TagListWrap = TagListWrap;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
4
|
+
export interface IRcSearchOptionsProps {
|
|
5
|
+
/**
|
|
6
|
+
* 字段展示名称
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* 字段表单key
|
|
11
|
+
*/
|
|
12
|
+
dataIndex: string;
|
|
13
|
+
/**
|
|
14
|
+
* 字段,交互组件类型(input/select/multiple)<br />
|
|
15
|
+
* - input:搜索框<br />
|
|
16
|
+
* - select:单选<br />
|
|
17
|
+
* - multiple:多选<br />
|
|
18
|
+
*/
|
|
19
|
+
template: string;
|
|
20
|
+
/**
|
|
21
|
+
* 定义传给表单项的属性
|
|
22
|
+
* templateProps.placeholder
|
|
23
|
+
* templateProps.dataSource
|
|
24
|
+
*/
|
|
25
|
+
templateProps: any;
|
|
26
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IRcSearchOptionsProps } from './IRcSearchOptions.type';
|
|
2
|
+
import { IRcSearchTagItemProps } from './IRcSearchTagItemProps.type';
|
|
3
|
+
export interface IRcSearchProps {
|
|
4
|
+
/**
|
|
5
|
+
* 组件适应的场景:<br />
|
|
6
|
+
* - 场景一:single-single:单维度单类别单选<br />
|
|
7
|
+
* - 场景二:single-multi:单维度多类别单选<br />
|
|
8
|
+
* - 场景三:multi-multi:多维度多类别单选<br />
|
|
9
|
+
* @default "single-single"
|
|
10
|
+
*/
|
|
11
|
+
mode?: "single-single" | "single-multi" | "multi-multi" | string;
|
|
12
|
+
/**
|
|
13
|
+
* 类名
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 样式
|
|
18
|
+
*/
|
|
19
|
+
style?: any;
|
|
20
|
+
/**
|
|
21
|
+
* 对应不同场景值的类型数组,后面要详细展开列一下
|
|
22
|
+
* @default []
|
|
23
|
+
*/
|
|
24
|
+
options: IRcSearchOptionsProps[];
|
|
25
|
+
/**
|
|
26
|
+
* tags 传入的taglist, 用于, 同步
|
|
27
|
+
*/
|
|
28
|
+
tags?: IRcSearchTagItemProps[];
|
|
29
|
+
/**
|
|
30
|
+
* 默认类别
|
|
31
|
+
* 仅在mode是"single-multi" | "multi-multi"生效
|
|
32
|
+
*/
|
|
33
|
+
defaultDataIndex?: string;
|
|
34
|
+
/**
|
|
35
|
+
* 默认placeholder
|
|
36
|
+
* 仅在mode是"single-multi" | "multi-multi"生效, 且, 未配置默认值时生效
|
|
37
|
+
*/
|
|
38
|
+
defaultPlaceholder?: string;
|
|
39
|
+
/**
|
|
40
|
+
* regionId
|
|
41
|
+
*/
|
|
42
|
+
regionId: string;
|
|
43
|
+
/**
|
|
44
|
+
* resourceType
|
|
45
|
+
*/
|
|
46
|
+
resourceType?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 点击搜索按钮, 触发搜索回调。
|
|
49
|
+
*/
|
|
50
|
+
onSearch?: (allFileds: any) => void;
|
|
51
|
+
/**
|
|
52
|
+
* 包括onInput的回车;onSelect; 对Tag的增减。
|
|
53
|
+
*/
|
|
54
|
+
onChange?: (changeFileds: any, allFileds: any) => void;
|
|
55
|
+
/**
|
|
56
|
+
* input的input
|
|
57
|
+
*/
|
|
58
|
+
onInput?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* 模糊搜索的回调函数(仅输入框返回),用于构建模糊搜索的联想列表
|
|
61
|
+
*/
|
|
62
|
+
onSuggest?: (value: string, dataIndex: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* 模糊搜索的回调函数(仅输入框返回),当没设置defaultDataIndex,且有多个input类别时触发,
|
|
65
|
+
* 可自定义二级返回List
|
|
66
|
+
*/
|
|
67
|
+
onSuggestNoDataIndex?: (value: string) => Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* 提供单选和多选, 触发。
|
|
70
|
+
*/
|
|
71
|
+
onSelect?: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* tag有增减时。
|
|
74
|
+
*/
|
|
75
|
+
onTagChange?: (newTags: any) => void;
|
|
76
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 这是IRcSearchTagItemProps的说明。breezr-docs支持从源码中提取接口信息并文档化,因此你可以使用接口来定义Props,从而能便捷地将Props的信息通过文档透出。
|
|
3
|
+
*
|
|
4
|
+
* 下面列举的props其实是随便写的,仅仅用来说明breezr-docs的接口提取功能。
|
|
5
|
+
*/
|
|
6
|
+
export interface IRcSearchTagItemProps {
|
|
7
|
+
/**
|
|
8
|
+
* tag的类别展示名称
|
|
9
|
+
*/
|
|
10
|
+
label: string;
|
|
11
|
+
/**
|
|
12
|
+
* tag的类别的key
|
|
13
|
+
*/
|
|
14
|
+
dataIndex: string;
|
|
15
|
+
/**
|
|
16
|
+
* tag的类别的值
|
|
17
|
+
*/
|
|
18
|
+
value: any;
|
|
19
|
+
/**
|
|
20
|
+
* tag的类别的展示值
|
|
21
|
+
*/
|
|
22
|
+
valueShow: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 这是IRcSearchTagListProps的说明。breezr-docs支持从源码中提取接口信息并文档化,因此你可以使用接口来定义Props,从而能便捷地将Props的信息通过文档透出。
|
|
3
|
+
*
|
|
4
|
+
* 下面列举的props其实是随便写的,仅仅用来说明breezr-docs的接口提取功能。
|
|
5
|
+
*/
|
|
6
|
+
import { IRcSearchTagItemProps } from './IRcSearchTagItemProps.type';
|
|
7
|
+
export interface IRcSearchTagListProps {
|
|
8
|
+
/**
|
|
9
|
+
* 类名
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 样式
|
|
14
|
+
*/
|
|
15
|
+
style?: any;
|
|
16
|
+
/**
|
|
17
|
+
* tags 传入的taglist, 用于, 同步
|
|
18
|
+
*/
|
|
19
|
+
tagList: IRcSearchTagItemProps[];
|
|
20
|
+
/**
|
|
21
|
+
* regionId
|
|
22
|
+
*/
|
|
23
|
+
regionId: string;
|
|
24
|
+
/**
|
|
25
|
+
* resourceType
|
|
26
|
+
*/
|
|
27
|
+
resourceType?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 当删减tag时, 返回新的taglist, 可直接赋值给rc-search组件
|
|
30
|
+
*/
|
|
31
|
+
onChange?: (newTags: any) => void;
|
|
32
|
+
}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LogFn } from '@alicloud/console-logger-sls';
|
|
2
|
+
declare const getHistoryTag: () => any;
|
|
3
|
+
declare const setHistoryTag: (newTagList: any) => any;
|
|
4
|
+
declare const removeHistoryTagItem: (tagItem: any) => any;
|
|
5
|
+
declare const getTagByFileds: (fileds: any, options: any) => any[];
|
|
6
|
+
declare const checkNoIndexListFormat: (list: any) => void;
|
|
7
|
+
declare const getSelectOptionAdatp: (title: string, list: any) => {
|
|
8
|
+
label: string;
|
|
9
|
+
children: any[];
|
|
10
|
+
}[];
|
|
11
|
+
declare const getEnv: () => any;
|
|
12
|
+
declare const getLogger: () => LogFn;
|
|
13
|
+
declare const isValidKey: (key: string | number | symbol, object: object) => key is never;
|
|
14
|
+
export { getHistoryTag, setHistoryTag, removeHistoryTagItem, getTagByFileds, checkNoIndexListFormat, getSelectOptionAdatp, getEnv, getLogger, isValidKey };
|