@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
package/lib/utils.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.setHistoryTag = exports.removeHistoryTagItem = exports.isValidKey = exports.getTagByFileds = exports.getSelectOptionAdatp = exports.getLogger = exports.getHistoryTag = exports.getEnv = exports.checkNoIndexListFormat = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
14
|
+
var _lodash = require("lodash");
|
|
15
|
+
|
|
16
|
+
var _consoleLoggerSls = _interopRequireDefault(require("@alicloud/console-logger-sls"));
|
|
17
|
+
|
|
18
|
+
var historyTagKey = "xconsole-rcsearch-historytag-".concat(location.origin).concat(location.pathname); // 从localStorage中获取tagList
|
|
19
|
+
|
|
20
|
+
var getHistoryTag = function getHistoryTag() {
|
|
21
|
+
var tagStr = localStorage.getItem(historyTagKey);
|
|
22
|
+
|
|
23
|
+
if (tagStr) {
|
|
24
|
+
return JSON.parse(tagStr);
|
|
25
|
+
} else {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}; // 向localStorage中存入tagList
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.getHistoryTag = getHistoryTag;
|
|
32
|
+
|
|
33
|
+
var setHistoryTag = function setHistoryTag(newTagList) {
|
|
34
|
+
var tagsHistory = getHistoryTag();
|
|
35
|
+
var newHTags = tagsHistory.concat(newTagList);
|
|
36
|
+
|
|
37
|
+
if (newHTags.length > 5) {
|
|
38
|
+
newHTags.reverse();
|
|
39
|
+
newHTags = (0, _lodash.uniqWith)(newHTags, _lodash.isEqual);
|
|
40
|
+
newHTags.length = 5;
|
|
41
|
+
newHTags.reverse();
|
|
42
|
+
} else {
|
|
43
|
+
newHTags = (0, _lodash.uniqWith)(newHTags, _lodash.isEqual);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
localStorage.setItem(historyTagKey, JSON.stringify(newHTags));
|
|
47
|
+
return newHTags;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.setHistoryTag = setHistoryTag;
|
|
51
|
+
|
|
52
|
+
var removeHistoryTagItem = function removeHistoryTagItem(tagItem) {
|
|
53
|
+
var tagsHistory = getHistoryTag();
|
|
54
|
+
var findTagIndex = -1;
|
|
55
|
+
|
|
56
|
+
if (tagsHistory && tagsHistory.length > 0) {
|
|
57
|
+
findTagIndex = tagsHistory.findIndex(function (x) {
|
|
58
|
+
if (tagItem.dataIndex === x.dataIndex && tagItem.valueShow === x.valueShow) {
|
|
59
|
+
return true;
|
|
60
|
+
} else {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (findTagIndex >= 0) {
|
|
67
|
+
tagsHistory.splice(findTagIndex, 1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
localStorage.setItem(historyTagKey, JSON.stringify(tagsHistory));
|
|
71
|
+
return tagsHistory;
|
|
72
|
+
}; // 将内部的表单对象, 转化成taglist array
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
exports.removeHistoryTagItem = removeHistoryTagItem;
|
|
76
|
+
|
|
77
|
+
var getTagByFileds = function getTagByFileds(fileds, options) {
|
|
78
|
+
var rtTags = new Array();
|
|
79
|
+
Object.keys(fileds).forEach(function (key) {
|
|
80
|
+
var resItem = options.find(function (x) {
|
|
81
|
+
return x.dataIndex === key;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (resItem && fileds[key]) {
|
|
85
|
+
var tagItem = {
|
|
86
|
+
label: resItem.label,
|
|
87
|
+
dataIndex: key,
|
|
88
|
+
value: fileds[key],
|
|
89
|
+
valueShow: ''
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (resItem.template === 'input') {
|
|
93
|
+
tagItem.valueShow = fileds[key];
|
|
94
|
+
} else if (resItem.template === 'select') {
|
|
95
|
+
tagItem.valueShow = resItem.templateProps.dataSource.find(function (y) {
|
|
96
|
+
return y.value === fileds[key];
|
|
97
|
+
}).label;
|
|
98
|
+
} else if (resItem.template === 'multiple') {
|
|
99
|
+
tagItem.valueShow = '';
|
|
100
|
+
var valueShowArr = new Array();
|
|
101
|
+
fileds[key].forEach(function (y) {
|
|
102
|
+
var findMul = resItem.templateProps.dataSource.find(function (z) {
|
|
103
|
+
return z.value === y;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (findMul) {
|
|
107
|
+
valueShowArr.push(findMul.label);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
tagItem.valueShow = valueShowArr.join('/');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
rtTags.push(tagItem);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return rtTags;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
exports.getTagByFileds = getTagByFileds;
|
|
120
|
+
|
|
121
|
+
var checkNoIndexListFormat = function checkNoIndexListFormat(list) {
|
|
122
|
+
var isOk = true;
|
|
123
|
+
list.forEach(function (groupItem) {
|
|
124
|
+
if (groupItem && groupItem.children && Array.isArray(groupItem.children) && groupItem.children.length > 0) {
|
|
125
|
+
groupItem.children.forEach(function (item) {
|
|
126
|
+
if ((0, _typeof2.default)(item) !== 'object' || !item.dataIndex) {
|
|
127
|
+
console.warn('onSuggestNoDataIndex的返回list应参考实例,每个下拉选择项应有dataIndex字段');
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
exports.checkNoIndexListFormat = checkNoIndexListFormat;
|
|
135
|
+
|
|
136
|
+
var getSelectOptionAdatp = function getSelectOptionAdatp(title, list) {
|
|
137
|
+
return [{
|
|
138
|
+
label: title || '',
|
|
139
|
+
children: (0, _toConsumableArray2.default)(list)
|
|
140
|
+
}];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
exports.getSelectOptionAdatp = getSelectOptionAdatp;
|
|
144
|
+
|
|
145
|
+
var getEnv = function getEnv() {
|
|
146
|
+
var _window, _window$ALIYUN_CONSOL;
|
|
147
|
+
|
|
148
|
+
if (process.env.NODE_ENV === 'development') {
|
|
149
|
+
return 'local';
|
|
150
|
+
} // @ts-ignore
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
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';
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
exports.getEnv = getEnv;
|
|
157
|
+
var logger = null;
|
|
158
|
+
|
|
159
|
+
var getLogger = function getLogger() {
|
|
160
|
+
if (!logger) {
|
|
161
|
+
logger = (0, _consoleLoggerSls.default)({
|
|
162
|
+
project: 'stonehenge-console',
|
|
163
|
+
endpoint: 'cn-hangzhou.log.aliyuncs.com',
|
|
164
|
+
logstore: "com-usage-origin"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return logger;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
exports.getLogger = getLogger;
|
|
172
|
+
|
|
173
|
+
var isValidKey = function isValidKey(key, object) {
|
|
174
|
+
return key in object;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
exports.isValidKey = isValidKey;
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alicloud/console-components-search",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "lib/index.js",
|
|
5
|
+
"module": "es/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "breezr start --config config/breezr.docs.config.ts",
|
|
10
|
+
"doc:build": "rm -rf doc-dist && breezr build --config config/breezr.docs.config.ts",
|
|
11
|
+
"doc:serve": "echo \"访问 https://xconsole.aliyun-inc.com/demo-playground?consoleOSId=console-fe-test-rc-search-doc&servePath=http://localhost:5556/doc-dist/ ,预览本地打包好的文档资源!\n\n您还可以将文档资源部署到自己的cdn,然后将上述url中的servePath修改为自己的cdn地址,得到你自己的文档预览链接。\" && serve -l 5556 --cors",
|
|
12
|
+
"upload": "breezr upload --config config/breezr.docs.config.ts",
|
|
13
|
+
"upload:pre": "npm run upload -- --tag=pre",
|
|
14
|
+
"babel": "breezr build --engine babel",
|
|
15
|
+
"babel:esm": "breezr build --engine babel --es-module",
|
|
16
|
+
"types": "tsc -p src --emitDeclarationOnly",
|
|
17
|
+
"build": "breezr build --engine webpack",
|
|
18
|
+
"clean": "rm -rf dist lib es doc-dist",
|
|
19
|
+
"prepublishOnly": "npm run clean && npm run babel && npm run babel:esm && npm run types && npm run build && npm run doc:build"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@alicloud/console-toolkit-cli": "^1.2.0",
|
|
23
|
+
"@alicloud/console-toolkit-preset-component": "^1.2.8",
|
|
24
|
+
"@alicloud/console-toolkit-preset-docs": "^1.0.34",
|
|
25
|
+
"@types/react": "^17.0.0",
|
|
26
|
+
"@types/react-dom": "^17.0.0",
|
|
27
|
+
"@types/styled-components": "^5.1.7",
|
|
28
|
+
"prettier": "^2.2.1",
|
|
29
|
+
"react": "^17.0.1",
|
|
30
|
+
"react-dom": "^17.0.1",
|
|
31
|
+
"serve": "^11.3.2",
|
|
32
|
+
"styled-components": "^5.2.1",
|
|
33
|
+
"typescript": "^4.1.3"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@alicloud/console-logger-sls": "^1.2.31"
|
|
40
|
+
}
|
|
41
|
+
}
|