@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.
@@ -35,8 +35,9 @@ var AutoComplete = _consoleComponents.Select.AutoComplete;
35
35
  var ModeSingleSingle = function ModeSingleSingle(props) {
36
36
  var options = props.options,
37
37
  onSuggest = props.onSuggest,
38
- onChange = props.onChange,
39
- onSearch = props.onSearch;
38
+ onSearch = props.onSearch,
39
+ _props$prefix = props.prefix,
40
+ prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
40
41
  var optionItem = options[0];
41
42
 
42
43
  if (!optionItem.templateProps) {
@@ -70,7 +71,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
70
71
  var key = searchKey.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
71
72
  var reg = new RegExp("(".concat(key, ")"), 'ig');
72
73
  label = label.replace(reg, function (x) {
73
- return "<span class=\"next-select-highlight\" style=\"background-color: #EFF3F8;font-weight: 500;\">".concat(x, "</span>");
74
+ return "<span class=\"".concat(prefix, "-select-highlight\" style=\"background-color: #EFF3F8;font-weight: 500;\">").concat(x, "</span>");
74
75
  });
75
76
  }
76
77
 
@@ -93,30 +94,24 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
93
94
  while (1) {
94
95
  switch (_context.prev = _context.next) {
95
96
  case 0:
96
- if (!(actionType === 'itemClick' && onChange)) {
97
- _context.next = 8;
97
+ if (!(actionType === 'itemClick')) {
98
+ _context.next = 7;
98
99
  break;
99
100
  }
100
101
 
101
102
  changeFileds = Object.create({});
102
103
  changeFileds[dataIndex] = value;
103
- onChange(changeFileds, changeFileds);
104
104
  setAllFileds(changeFileds);
105
105
  setVisible(false);
106
- _context.next = 18;
106
+ _context.next = 17;
107
107
  break;
108
108
 
109
- case 8:
109
+ case 7:
110
110
  setInputValue(value); // fuzzyDisable
111
111
 
112
112
  if (!optionItem.templateProps || !optionItem.templateProps.fuzzyDisable) {
113
113
  _changeFileds = Object.create({});
114
114
  _changeFileds[dataIndex] = value;
115
-
116
- if (onChange) {
117
- onChange(_changeFileds, _changeFileds);
118
- }
119
-
120
115
  setAllFileds(_changeFileds);
121
116
  } //
122
117
 
@@ -126,14 +121,14 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
126
121
  }
127
122
 
128
123
  if (!onSuggest) {
129
- _context.next = 18;
124
+ _context.next = 17;
130
125
  break;
131
126
  }
132
127
 
133
- _context.next = 14;
128
+ _context.next = 13;
134
129
  return onSuggest(value, dataIndex);
135
130
 
136
- case 14:
131
+ case 13:
137
132
  list = _context.sent;
138
133
  // console.log('res suggest', res);
139
134
  newDataSource = [{
@@ -143,7 +138,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
143
138
  setInputDataSource(newDataSource);
144
139
  setVisible(true);
145
140
 
146
- case 18:
141
+ case 17:
147
142
  case "end":
148
143
  return _context.stop();
149
144
  }
@@ -159,19 +154,10 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
159
154
 
160
155
  function _selectChange() {
161
156
  _selectChange = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(value, dataIndex) {
162
- var changeFileds;
163
157
  return _regenerator.default.wrap(function _callee2$(_context2) {
164
158
  while (1) {
165
159
  switch (_context2.prev = _context2.next) {
166
160
  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
161
  case "end":
176
162
  return _context2.stop();
177
163
  }
@@ -187,8 +173,10 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
187
173
  }
188
174
  }
189
175
 
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')
176
+ return /*#__PURE__*/_react.default.createElement(_style.SearchWarp, {
177
+ prefix: prefix
178
+ }, optionItem.template === 'input' && /*#__PURE__*/_react.default.createElement("div", {
179
+ className: (0, _classnames.default)('left-wrap', "".concat(prefix, "input"))
192
180
  }, /*#__PURE__*/_react.default.createElement(AutoComplete, {
193
181
  className: (0, _classnames.default)('main-input', 'single'),
194
182
  placeholder: optionItem.templateProps.placeholder || "\u9ED8\u8BA4\u6309".concat(optionItem.label, "\u641C\u7D22"),
@@ -206,7 +194,7 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
206
194
  inputChange(value, actionType, optionItem.dataIndex);
207
195
  }
208
196
  })), optionItem.template === 'select' && /*#__PURE__*/_react.default.createElement("div", {
209
- className: (0, _classnames.default)('left-wrap', 'next-input')
197
+ className: (0, _classnames.default)('left-wrap', "".concat(prefix, "input"))
210
198
  }, /*#__PURE__*/_react.default.createElement("div", {
211
199
  className: (0, _classnames.default)('condition')
212
200
  }, /*#__PURE__*/_react.default.createElement("span", {
@@ -233,5 +221,6 @@ var ModeSingleSingle = function ModeSingleSingle(props) {
233
221
  }))));
234
222
  };
235
223
 
236
- var _default = ModeSingleSingle;
224
+ var _default = _consoleComponents.ConfigProvider.config(ModeSingleSingle);
225
+
237
226
  exports.default = _default;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface LoggerProviderProps {
3
- regionId: string;
3
+ regionId?: string;
4
4
  resourceType: string;
5
5
  componentName: string;
6
6
  }
package/lib/search.js CHANGED
@@ -27,7 +27,8 @@ var SearchWrap = _styledComponents.default.div.withConfig({
27
27
 
28
28
  var Search = function Search(props) {
29
29
  var className = props.className,
30
- mode = props.mode,
30
+ _props$simple = props.simple,
31
+ simple = _props$simple === void 0 ? false : _props$simple,
31
32
  style = props.style;
32
33
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_LoggerProvider.default, {
33
34
  regionId: props.regionId,
@@ -36,7 +37,7 @@ var Search = function Search(props) {
36
37
  }), /*#__PURE__*/_react.default.createElement(SearchWrap, {
37
38
  className: (0, _classnames.default)(_constants.baseClassName, className),
38
39
  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
+ }, simple ? /*#__PURE__*/_react.default.createElement(_modeSingleSingle.default, props) : /*#__PURE__*/_react.default.createElement(_modeSingleMulti.default, props)));
40
41
  };
41
42
 
42
43
  exports.Search = Search;
@@ -1,4 +1,2 @@
1
- import React from "react";
2
- import { IRcSearchTagListProps } from '../types/IRcSearchTagListProps.type';
3
- declare const SearchTagList: React.FC<IRcSearchTagListProps>;
4
- export default SearchTagList;
1
+ declare const _default: any;
2
+ export default _default;
@@ -28,7 +28,9 @@ var SearchTagList = function SearchTagList(props) {
28
28
  var tagList = props.tagList,
29
29
  className = props.className,
30
30
  style = props.style,
31
- onChange = props.onChange;
31
+ onChange = props.onChange,
32
+ _props$prefix = props.prefix,
33
+ prefix = _props$prefix === void 0 ? "next-" : _props$prefix;
32
34
 
33
35
  function onRemoveTag(item) {
34
36
  var newTagList = (0, _toConsumableArray2.default)(tagList);
@@ -49,6 +51,7 @@ var SearchTagList = function SearchTagList(props) {
49
51
  }
50
52
 
51
53
  return /*#__PURE__*/_react.default.createElement(_style.TagListWrap, {
54
+ prefix: prefix,
52
55
  className: (0, _classnames.default)(_constants.baseTagListClassName, className),
53
56
  style: style
54
57
  }, /*#__PURE__*/_react.default.createElement(_LoggerProvider.default, {
@@ -71,5 +74,6 @@ var SearchTagList = function SearchTagList(props) {
71
74
  }, "\u6E05\u9664\u7B5B\u9009\u6761\u4EF6")));
72
75
  };
73
76
 
74
- var _default = SearchTagList;
77
+ var _default = _consoleComponents.ConfigProvider.config(SearchTagList);
78
+
75
79
  exports.default = _default;
package/lib/style.d.ts CHANGED
@@ -1,5 +1,13 @@
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>;
1
+ declare const SearchWarp: import("styled-components").StyledComponent<"div", any, {
2
+ prefix: string;
3
+ }, never>;
4
+ declare const MenuContentWrap: import("styled-components").StyledComponent<"ul", any, {
5
+ prefix: string;
6
+ }, never>;
7
+ declare const MultiBtnWarp: import("styled-components").StyledComponent<"div", any, {
8
+ prefix: string;
9
+ }, never>;
10
+ declare const TagListWrap: import("styled-components").StyledComponent<"div", any, {
11
+ prefix: string;
12
+ }, never>;
5
13
  export { SearchWarp, MultiBtnWarp, TagListWrap, MenuContentWrap };
package/lib/style.js CHANGED
@@ -9,26 +9,30 @@ exports.TagListWrap = exports.SearchWarp = exports.MultiBtnWarp = exports.MenuCo
9
9
 
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
+ var prefix = function prefix(props) {
13
+ return props.prefix ? ".".concat(props.prefix) : '.next-';
14
+ };
15
+
12
16
  var SearchWarp = _styledComponents.default.div.withConfig({
13
17
  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;}}"]);
18
+ })(["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);
15
19
 
16
20
  exports.SearchWarp = SearchWarp;
17
21
 
18
22
  var MenuContentWrap = _styledComponents.default.ul.withConfig({
19
23
  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);}"]);
24
+ })(["", "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);
21
25
 
22
26
  exports.MenuContentWrap = MenuContentWrap;
23
27
 
24
28
  var MultiBtnWarp = _styledComponents.default.div.withConfig({
25
29
  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;}"]);
30
+ })(["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);
27
31
 
28
32
  exports.MultiBtnWarp = MultiBtnWarp;
29
33
 
30
34
  var TagListWrap = _styledComponents.default.div.withConfig({
31
35
  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;}"]);
36
+ })(["", "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);
33
37
 
34
38
  exports.TagListWrap = TagListWrap;
@@ -16,11 +16,12 @@ export interface IRcSearchOptionsProps {
16
16
  * - select:单选<br />
17
17
  * - multiple:多选<br />
18
18
  */
19
- template: string;
19
+ template?: string;
20
20
  /**
21
21
  * 定义传给表单项的属性
22
22
  * templateProps.placeholder
23
23
  * templateProps.dataSource
24
24
  */
25
- templateProps: any;
25
+ templateProps?: any;
26
+ groupName?: string;
26
27
  }
@@ -2,13 +2,10 @@ import { IRcSearchOptionsProps } from './IRcSearchOptions.type';
2
2
  import { IRcSearchTagItemProps } from './IRcSearchTagItemProps.type';
3
3
  export interface IRcSearchProps {
4
4
  /**
5
- * 组件适应的场景:<br />
6
- * - 场景一:single-single:单维度单类别单选<br />
7
- * - 场景二:single-multi:单维度多类别单选<br />
8
- * - 场景三:multi-multi:多维度多类别单选<br />
9
- * @default "single-single"
5
+ * 是否是简单搜索, 不支持多 filter, 但是支持模糊
6
+ * @default false
10
7
  */
11
- mode?: "single-single" | "single-multi" | "multi-multi" | string;
8
+ simple?: boolean;
12
9
  /**
13
10
  * 类名
14
11
  */
@@ -39,23 +36,15 @@ export interface IRcSearchProps {
39
36
  /**
40
37
  * regionId
41
38
  */
42
- regionId: string;
39
+ regionId?: string;
43
40
  /**
44
41
  * resourceType
45
42
  */
46
43
  resourceType?: string;
47
44
  /**
48
- * 点击搜索按钮, 触发搜索回调。
45
+ * 搜索触发
49
46
  */
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;
47
+ onSearch?: (allFields: any) => void;
59
48
  /**
60
49
  * 模糊搜索的回调函数(仅输入框返回),用于构建模糊搜索的联想列表
61
50
  */
@@ -69,8 +58,4 @@ export interface IRcSearchProps {
69
58
  * 提供单选和多选, 触发。
70
59
  */
71
60
  onSelect?: () => void;
72
- /**
73
- * tag有增减时。
74
- */
75
- onTagChange?: (newTags: any) => void;
76
61
  }
@@ -0,0 +1 @@
1
+ export declare function useCssVar(cssVarName: string): string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useCssVar = useCssVar;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _react = require("react");
13
+
14
+ var _consoleComponents = require("@alicloud/console-components");
15
+
16
+ var nextId = 0;
17
+
18
+ function useCssVar(cssVarName) {
19
+ var _useState = (0, _react.useState)(''),
20
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
21
+ v = _useState2[0],
22
+ setV = _useState2[1];
23
+
24
+ var refElement = _consoleComponents.ConfigProvider.useRefElement();
25
+
26
+ (0, _react.useLayoutEffect)(function () {
27
+ var _window$__recheck_css;
28
+
29
+ check(); // @ts-ignore
30
+
31
+ var checkArr = window['__recheck_css_var'] = (_window$__recheck_css = window['__recheck_css_var']) !== null && _window$__recheck_css !== void 0 ? _window$__recheck_css : [];
32
+
33
+ while (checkArr[nextId]) {
34
+ // 如果一个页面下有份此组件库(即有多个nextId指针),需要避免冲突
35
+ nextId++;
36
+ }
37
+
38
+ var id = nextId++;
39
+ checkArr[id] = check;
40
+ return function () {
41
+ delete checkArr[id];
42
+ };
43
+
44
+ function check() {
45
+ var _window$getComputedSt, _window$getComputedSt2, _window;
46
+
47
+ 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 : '';
48
+ setV(val);
49
+ }
50
+ }, [refElement, cssVarName]);
51
+ return v;
52
+ }
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@alicloud/console-components-search",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "main": "lib/index.js",
5
- "module": "es/index.js",
6
5
  "types": "lib/index.d.ts",
7
6
  "license": "MIT",
8
7
  "scripts": {