@alicloud/console-components-search 0.1.0 → 0.1.3
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 +5 -12
- package/config/components-with-style.tsx +1 -1
- package/demos/demo1.demo.tsx +5 -17
- package/demos/demo2.demo.tsx +3 -32
- package/demos/demo3.demo.tsx +12 -37
- package/demos/demo4.demo.tsx +1 -8
- package/dist/index.css +1 -1
- package/dist/index.js +9 -9
- 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/16.js +1 -1
- package/doc-dist/17.js +1 -1
- package/doc-dist/9.js +1 -1
- package/doc-dist/deps/main.css +1 -1
- package/doc-dist/deps/main.js +9 -9
- package/doc-dist/deps/main.os.css +1 -1
- package/doc-dist/index.js +1 -1
- package/doc-dist/log-deps-build.log +3 -3
- package/es/modeSingleMulti/index.js +141 -135
- package/es/modeSingleSingle/index.js +19 -31
- package/es/search.js +3 -2
- package/es/searchTagList/index.js +6 -3
- package/es/style.js +9 -4
- package/es/useCssVar.js +38 -0
- package/lib/modeSingleMulti/index.d.ts +2 -4
- package/lib/modeSingleMulti/index.js +141 -130
- package/lib/modeSingleSingle/index.d.ts +2 -4
- package/lib/modeSingleSingle/index.js +19 -30
- package/lib/provider/LoggerProvider.d.ts +1 -1
- package/lib/search.js +3 -2
- package/lib/searchTagList/index.d.ts +2 -4
- package/lib/searchTagList/index.js +6 -2
- package/lib/style.d.ts +12 -4
- package/lib/style.js +8 -4
- package/lib/types/IRcSearchOptions.type.d.ts +3 -2
- package/lib/types/IRcSearchProps.type.d.ts +6 -21
- package/lib/useCssVar.d.ts +1 -0
- package/lib/useCssVar.js +52 -0
- package/package.json +1 -2
|
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import React, { useState } from "react";
|
|
5
5
|
import classNames from 'classnames'; // import styled from "styled-components";
|
|
6
6
|
|
|
7
|
-
import { Button, Icon, Select } from '@alicloud/console-components';
|
|
7
|
+
import { Button, ConfigProvider, Icon, Select } from '@alicloud/console-components';
|
|
8
8
|
import { SearchWarp } from "../style";
|
|
9
9
|
import { getSelectOptionAdatp } from '../utils';
|
|
10
10
|
var AutoComplete = Select.AutoComplete;
|
|
@@ -12,8 +12,9 @@ var AutoComplete = Select.AutoComplete;
|
|
|
12
12
|
var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
13
13
|
var options = props.options,
|
|
14
14
|
onSuggest = props.onSuggest,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
onSearch = props.onSearch,
|
|
16
|
+
_props$prefix = props.prefix,
|
|
17
|
+
prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
|
|
17
18
|
var optionItem = options[0];
|
|
18
19
|
|
|
19
20
|
if (!optionItem.templateProps) {
|
|
@@ -47,7 +48,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
47
48
|
var key = searchKey.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
48
49
|
var reg = new RegExp("(".concat(key, ")"), 'ig');
|
|
49
50
|
label = label.replace(reg, function (x) {
|
|
50
|
-
return "<span class=\"
|
|
51
|
+
return "<span class=\"".concat(prefix, "-select-highlight\" style=\"background-color: #EFF3F8;font-weight: 500;\">").concat(x, "</span>");
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -70,30 +71,24 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
70
71
|
while (1) {
|
|
71
72
|
switch (_context.prev = _context.next) {
|
|
72
73
|
case 0:
|
|
73
|
-
if (!(actionType === 'itemClick'
|
|
74
|
-
_context.next =
|
|
74
|
+
if (!(actionType === 'itemClick')) {
|
|
75
|
+
_context.next = 7;
|
|
75
76
|
break;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
changeFileds = Object.create({});
|
|
79
80
|
changeFileds[dataIndex] = value;
|
|
80
|
-
onChange(changeFileds, changeFileds);
|
|
81
81
|
setAllFileds(changeFileds);
|
|
82
82
|
setVisible(false);
|
|
83
|
-
_context.next =
|
|
83
|
+
_context.next = 17;
|
|
84
84
|
break;
|
|
85
85
|
|
|
86
|
-
case
|
|
86
|
+
case 7:
|
|
87
87
|
setInputValue(value); // fuzzyDisable
|
|
88
88
|
|
|
89
89
|
if (!optionItem.templateProps || !optionItem.templateProps.fuzzyDisable) {
|
|
90
90
|
_changeFileds = Object.create({});
|
|
91
91
|
_changeFileds[dataIndex] = value;
|
|
92
|
-
|
|
93
|
-
if (onChange) {
|
|
94
|
-
onChange(_changeFileds, _changeFileds);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
92
|
setAllFileds(_changeFileds);
|
|
98
93
|
} //
|
|
99
94
|
|
|
@@ -103,14 +98,14 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
103
98
|
}
|
|
104
99
|
|
|
105
100
|
if (!onSuggest) {
|
|
106
|
-
_context.next =
|
|
101
|
+
_context.next = 17;
|
|
107
102
|
break;
|
|
108
103
|
}
|
|
109
104
|
|
|
110
|
-
_context.next =
|
|
105
|
+
_context.next = 13;
|
|
111
106
|
return onSuggest(value, dataIndex);
|
|
112
107
|
|
|
113
|
-
case
|
|
108
|
+
case 13:
|
|
114
109
|
list = _context.sent;
|
|
115
110
|
// console.log('res suggest', res);
|
|
116
111
|
newDataSource = [{
|
|
@@ -120,7 +115,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
120
115
|
setInputDataSource(newDataSource);
|
|
121
116
|
setVisible(true);
|
|
122
117
|
|
|
123
|
-
case
|
|
118
|
+
case 17:
|
|
124
119
|
case "end":
|
|
125
120
|
return _context.stop();
|
|
126
121
|
}
|
|
@@ -136,19 +131,10 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
136
131
|
|
|
137
132
|
function _selectChange() {
|
|
138
133
|
_selectChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value, dataIndex) {
|
|
139
|
-
var changeFileds;
|
|
140
134
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
141
135
|
while (1) {
|
|
142
136
|
switch (_context2.prev = _context2.next) {
|
|
143
137
|
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
138
|
case "end":
|
|
153
139
|
return _context2.stop();
|
|
154
140
|
}
|
|
@@ -164,8 +150,10 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
164
150
|
}
|
|
165
151
|
}
|
|
166
152
|
|
|
167
|
-
return /*#__PURE__*/React.createElement(SearchWarp,
|
|
168
|
-
|
|
153
|
+
return /*#__PURE__*/React.createElement(SearchWarp, {
|
|
154
|
+
prefix: prefix
|
|
155
|
+
}, optionItem.template === 'input' && /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: classNames('left-wrap', "".concat(prefix, "input"))
|
|
169
157
|
}, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
170
158
|
className: classNames('main-input', 'single'),
|
|
171
159
|
placeholder: optionItem.templateProps.placeholder || "\u9ED8\u8BA4\u6309".concat(optionItem.label, "\u641C\u7D22"),
|
|
@@ -183,7 +171,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
183
171
|
inputChange(value, actionType, optionItem.dataIndex);
|
|
184
172
|
}
|
|
185
173
|
})), optionItem.template === 'select' && /*#__PURE__*/React.createElement("div", {
|
|
186
|
-
className: classNames('left-wrap',
|
|
174
|
+
className: classNames('left-wrap', "".concat(prefix, "input"))
|
|
187
175
|
}, /*#__PURE__*/React.createElement("div", {
|
|
188
176
|
className: classNames('condition')
|
|
189
177
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -210,4 +198,4 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
|
|
|
210
198
|
}))));
|
|
211
199
|
};
|
|
212
200
|
|
|
213
|
-
export default ModeSingleSingle;
|
|
201
|
+
export default ConfigProvider.config(ModeSingleSingle);
|
package/es/search.js
CHANGED
|
@@ -10,7 +10,8 @@ var SearchWrap = styled.div.withConfig({
|
|
|
10
10
|
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
11
11
|
export var Search = function Search(props) {
|
|
12
12
|
var className = props.className,
|
|
13
|
-
|
|
13
|
+
_props$simple = props.simple,
|
|
14
|
+
simple = _props$simple === void 0 ? false : _props$simple,
|
|
14
15
|
style = props.style;
|
|
15
16
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoggerProvider, {
|
|
16
17
|
regionId: props.regionId,
|
|
@@ -19,5 +20,5 @@ export var Search = function Search(props) {
|
|
|
19
20
|
}), /*#__PURE__*/React.createElement(SearchWrap, {
|
|
20
21
|
className: classNames(baseClassName, className),
|
|
21
22
|
style: style
|
|
22
|
-
},
|
|
23
|
+
}, simple ? /*#__PURE__*/React.createElement(ModeSingleSingle, props) : /*#__PURE__*/React.createElement(ModeSingleMulti, props)));
|
|
23
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { Tag } from '@alicloud/console-components';
|
|
4
|
+
import { ConfigProvider, Tag } from '@alicloud/console-components';
|
|
5
5
|
import LoggerProvider from '../provider/LoggerProvider';
|
|
6
6
|
import { TagListWrap } from '../style';
|
|
7
7
|
import { baseTagListClassName } from '../constants';
|
|
@@ -12,7 +12,9 @@ var SearchTagList = function SearchTagList(props) {
|
|
|
12
12
|
var tagList = props.tagList,
|
|
13
13
|
className = props.className,
|
|
14
14
|
style = props.style,
|
|
15
|
-
onChange = props.onChange
|
|
15
|
+
onChange = props.onChange,
|
|
16
|
+
_props$prefix = props.prefix,
|
|
17
|
+
prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
|
|
16
18
|
|
|
17
19
|
function onRemoveTag(item) {
|
|
18
20
|
var newTagList = _toConsumableArray(tagList);
|
|
@@ -33,6 +35,7 @@ var SearchTagList = function SearchTagList(props) {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
return /*#__PURE__*/React.createElement(TagListWrap, {
|
|
38
|
+
prefix: prefix,
|
|
36
39
|
className: classNames(baseTagListClassName, className),
|
|
37
40
|
style: style
|
|
38
41
|
}, /*#__PURE__*/React.createElement(LoggerProvider, {
|
|
@@ -55,4 +58,4 @@ var SearchTagList = function SearchTagList(props) {
|
|
|
55
58
|
}, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
|
|
56
59
|
};
|
|
57
60
|
|
|
58
|
-
export default SearchTagList;
|
|
61
|
+
export default ConfigProvider.config(SearchTagList);
|
package/es/style.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
var prefix = function prefix(props) {
|
|
4
|
+
return props.prefix ? ".".concat(props.prefix) : '.next-';
|
|
5
|
+
};
|
|
6
|
+
|
|
2
7
|
var SearchWarp = styled.div.withConfig({
|
|
3
8
|
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
|
|
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-hover-border-color,#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;", "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;border-left:none;}}"], prefix, prefix, prefix, prefix, prefix);
|
|
5
10
|
var MenuContentWrap = styled.ul.withConfig({
|
|
6
11
|
componentId: "sc-1afc1cn-1"
|
|
7
|
-
})(["
|
|
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);
|
|
8
13
|
var MultiBtnWarp = styled.div.withConfig({
|
|
9
14
|
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;}
|
|
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);
|
|
11
16
|
var TagListWrap = styled.div.withConfig({
|
|
12
17
|
componentId: "sc-1afc1cn-3"
|
|
13
|
-
})(["
|
|
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;content:var(--icon-content-delete-filling);}.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);
|
|
14
19
|
export { SearchWarp, MultiBtnWarp, TagListWrap, MenuContentWrap };
|
package/es/useCssVar.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { ConfigProvider } from '@alicloud/console-components';
|
|
4
|
+
var nextId = 0;
|
|
5
|
+
export function useCssVar(cssVarName) {
|
|
6
|
+
var _useState = useState(''),
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
v = _useState2[0],
|
|
9
|
+
setV = _useState2[1];
|
|
10
|
+
|
|
11
|
+
var refElement = ConfigProvider.useRefElement();
|
|
12
|
+
useLayoutEffect(function () {
|
|
13
|
+
var _window$__recheck_css;
|
|
14
|
+
|
|
15
|
+
check(); // @ts-ignore
|
|
16
|
+
|
|
17
|
+
var checkArr = window['__recheck_css_var'] = (_window$__recheck_css = window['__recheck_css_var']) !== null && _window$__recheck_css !== void 0 ? _window$__recheck_css : [];
|
|
18
|
+
|
|
19
|
+
while (checkArr[nextId]) {
|
|
20
|
+
// 如果一个页面下有份此组件库(即有多个nextId指针),需要避免冲突
|
|
21
|
+
nextId++;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var id = nextId++;
|
|
25
|
+
checkArr[id] = check;
|
|
26
|
+
return function () {
|
|
27
|
+
delete checkArr[id];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function check() {
|
|
31
|
+
var _window$getComputedSt, _window$getComputedSt2, _window;
|
|
32
|
+
|
|
33
|
+
var val = (_window$getComputedSt = (_window$getComputedSt2 = (_window = window).getComputedStyle) === null || _window$getComputedSt2 === void 0 ? void 0 : _window$getComputedSt2.call(_window, refElement).getPropertyValue(cssVarName)) !== null && _window$getComputedSt !== void 0 ? _window$getComputedSt : '';
|
|
34
|
+
setV(val);
|
|
35
|
+
}
|
|
36
|
+
}, [refElement, cssVarName]);
|
|
37
|
+
return v;
|
|
38
|
+
}
|