@cloudbase/weda-ui 0.2.16 → 1.0.24
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 +41 -169
- package/package.json +23 -11
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +65 -18
- package/src/configs/components/lottery.json +151 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +4 -1
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +20 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.wxml +1 -2
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/form/index.wxml +1 -2
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +348 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +76 -44
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +61 -29
- package/src/mp/components/graphicCard/index.js +26 -28
- package/src/mp/components/listView/index.js +52 -64
- package/src/mp/components/listView/index.wxml +2 -2
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/lottery/index.json +4 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/navLayout/index.js +3 -3
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +10 -1
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +61 -23
- package/src/web/components/form/formcell/index.tsx +10 -5
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +371 -72
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +392 -145
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
- package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
- package/src/web/components/graphicCard/index.css +1 -5
- package/src/web/components/graphicCard/index.tsx +4 -3
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +13 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +10 -18
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
- package/src/web/utils/platform.js +10 -1
- package/src/web/utils/tcb.js +20 -6
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
package/src/mp/index.json
CHANGED
|
@@ -29,11 +29,20 @@
|
|
|
29
29
|
"RichTextView": "components/richText/index",
|
|
30
30
|
"Tabs": "components/tabs/index",
|
|
31
31
|
"ListView": "components/listView/index",
|
|
32
|
+
"NavigationBar": "components/navigationBar/index",
|
|
32
33
|
"DataView": "components/dataView/index",
|
|
33
34
|
"Calendar": "components/calendar/index",
|
|
34
35
|
"NavLayout": "components/navLayout/index",
|
|
36
|
+
"Line": "components/chart/line/index",
|
|
37
|
+
"Bar": "components/chart/bar/index",
|
|
38
|
+
"Pie": "components/chart/pie/index",
|
|
35
39
|
"StatisticsCard": "components/chart/statisticsCard/index",
|
|
36
|
-
"GraphicCard": "components/graphicCard/index"
|
|
40
|
+
"GraphicCard": "components/graphicCard/index",
|
|
41
|
+
"UserInfo": "components/wxOpenApi/userInfo/index",
|
|
42
|
+
"Phone": "components/wxOpenApi/phone/index",
|
|
43
|
+
"Share": "components/wxOpenApi/share/index",
|
|
44
|
+
"Lottery": "components/lottery/index",
|
|
45
|
+
"PhoneCode": "components/wxOpenApi/phoneCode/index"
|
|
37
46
|
},
|
|
38
47
|
"actions": {
|
|
39
48
|
"showToast": "actions/showToast/index",
|
package/src/mp/utils/constant.js
CHANGED
|
@@ -3,3 +3,18 @@ export const TitleType = {
|
|
|
3
3
|
TOP: 'top',
|
|
4
4
|
NONE: 'none',
|
|
5
5
|
};
|
|
6
|
+
|
|
7
|
+
export const REL_DICT = {
|
|
8
|
+
equal: 'eq', // 等于
|
|
9
|
+
unequal: 'neq', // 不等于
|
|
10
|
+
include: 'search', // 包含
|
|
11
|
+
exclude: '_exclude', // 不包含
|
|
12
|
+
begin_with: '_begin_with', // 开头是
|
|
13
|
+
greater: 'gt', // 大于
|
|
14
|
+
greater_or_equal: 'gte', // 大于等于
|
|
15
|
+
bigger_or_equal: 'gte', //大于等于
|
|
16
|
+
less: 'lt', // 小于
|
|
17
|
+
less_or_equal: 'lte', // 小于等于
|
|
18
|
+
in: 'in', // 多选值
|
|
19
|
+
not_in: 'nin', // 不在多选值
|
|
20
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// https://github.com/unjs/destr/blob/2f6612533dd798d2ff5786274f2244558f86d09c/src/index.ts
|
|
2
|
+
// https://github.com/fastify/secure-json-parse
|
|
3
|
+
// https://github.com/hapijs/bourne
|
|
4
|
+
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
5
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
6
|
+
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/;
|
|
7
|
+
function jsonParseTransform(key, value) {
|
|
8
|
+
if (key === '__proto__' || key === 'constructor') {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export default function destr(val) {
|
|
14
|
+
if (typeof val !== 'string') {
|
|
15
|
+
return val;
|
|
16
|
+
}
|
|
17
|
+
const _lval = val.toLowerCase();
|
|
18
|
+
if (_lval === 'true') {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (_lval === 'false') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (_lval === 'null') {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (_lval === 'nan') {
|
|
28
|
+
return NaN;
|
|
29
|
+
}
|
|
30
|
+
if (_lval === 'infinity') {
|
|
31
|
+
return Infinity;
|
|
32
|
+
}
|
|
33
|
+
if (_lval === 'undefined') {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (!JsonSigRx.test(val)) {
|
|
37
|
+
return val;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) {
|
|
41
|
+
return JSON.parse(val, jsonParseTransform);
|
|
42
|
+
}
|
|
43
|
+
return JSON.parse(val);
|
|
44
|
+
}
|
|
45
|
+
catch (_e) {
|
|
46
|
+
return val;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/mp/utils/platform.js
CHANGED
|
@@ -18,3 +18,28 @@ export const transSize = (size) => {
|
|
|
18
18
|
const g = getBig(m);
|
|
19
19
|
return `${g}G`;
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 判断是否是url
|
|
24
|
+
*/
|
|
25
|
+
const reg =
|
|
26
|
+
// eslint-disable-next-line no-useless-escape
|
|
27
|
+
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
|
28
|
+
|
|
29
|
+
export const isUrl = (path) => reg.test(path);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 生成随机数
|
|
33
|
+
*/
|
|
34
|
+
export const uuid = () => {
|
|
35
|
+
var s = [];
|
|
36
|
+
var hexDigits = '0123456789abcdef';
|
|
37
|
+
for (var i = 0; i < 36; i++) {
|
|
38
|
+
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
|
39
|
+
}
|
|
40
|
+
s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
|
|
41
|
+
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
|
42
|
+
s[8] = s[13] = s[18] = s[23] = '-';
|
|
43
|
+
var uuid = s.join('');
|
|
44
|
+
return uuid;
|
|
45
|
+
};
|
package/src/mp/utils/tcb.js
CHANGED
|
@@ -13,6 +13,32 @@ export async function getTempFileURL(data) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* 云API:获取用户自定义导航内容
|
|
18
|
+
* param
|
|
19
|
+
* WeAppId: string,
|
|
20
|
+
* EnvId: string,
|
|
21
|
+
* PublishType?: string,
|
|
22
|
+
*/
|
|
23
|
+
export async function getAppCustomNav() {
|
|
24
|
+
try {
|
|
25
|
+
const PublishType = getApp().app.cloud?.IS_WEDA_IDE ? 'preview' : '';
|
|
26
|
+
const WeAppId = getApp().app?.id;
|
|
27
|
+
const res = await callWedaApi({
|
|
28
|
+
action: 'DescribeAppCustomNav',
|
|
29
|
+
serviceType: 'lowcode',
|
|
30
|
+
data: {
|
|
31
|
+
WeAppId,
|
|
32
|
+
PublishType,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return res;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('错误', error);
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
/**
|
|
17
43
|
* 调用微搭后端API服务
|
|
18
44
|
*/
|
|
@@ -30,3 +56,21 @@ export async function callDataSource(param) {
|
|
|
30
56
|
return await getApp().app.cloud.callDataSource(param);
|
|
31
57
|
}
|
|
32
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 云函数获取数据
|
|
62
|
+
*/
|
|
63
|
+
export async function callDataSourceApi(param) {
|
|
64
|
+
const { params, dataSourceName, methodName } = param;
|
|
65
|
+
try {
|
|
66
|
+
const res = await getApp()?.app?.cloud?.callDataSource?.({
|
|
67
|
+
params,
|
|
68
|
+
dataSourceName,
|
|
69
|
+
methodName,
|
|
70
|
+
});
|
|
71
|
+
return res;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('错误', error);
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/setupTests.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require("regenerator-runtime");
|
|
1
2
|
Object.defineProperty(window, 'matchMedia', {
|
|
2
3
|
writable: true,
|
|
3
4
|
value: jest.fn().mockImplementation(query => ({
|
|
@@ -10,4 +11,4 @@ Object.defineProperty(window, 'matchMedia', {
|
|
|
10
11
|
removeEventListener: jest.fn(),
|
|
11
12
|
dispatchEvent: jest.fn(),
|
|
12
13
|
})),
|
|
13
|
-
});
|
|
14
|
+
});
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
background-color: var(--weui-BRAND);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.weda-button.weui-btn.weui-btn_primary.weui-btn_wechat:not(.weui-btn_disabled):active {
|
|
10
|
+
background-color: var(--weui-TAG-TEXT-GREEN);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weda-button.weui-btn_primary.weui-btn_wechat {
|
|
14
|
+
background-color: var(--weui-WECHAT);
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
.weda-button.weda-button-mini {
|
|
10
18
|
font-size: smaller;
|
|
11
19
|
}
|
|
@@ -17,4 +25,3 @@
|
|
|
17
25
|
text-align: center;
|
|
18
26
|
width: 100%;
|
|
19
27
|
}
|
|
20
|
-
|
|
@@ -29,9 +29,10 @@ const Button = ({
|
|
|
29
29
|
'weda-button-mini': size === 'mini',
|
|
30
30
|
'weui-btn': isH5,
|
|
31
31
|
'weui-btn_mini': isH5 && size === 'mini',
|
|
32
|
-
'weui-btn_primary': isH5 && type === 'primary',
|
|
32
|
+
'weui-btn_primary': isH5 && (type === 'primary' || type === 'wechat'),
|
|
33
33
|
'weui-btn_default': isH5 && type === 'default',
|
|
34
34
|
'weui-btn_warn': isH5 && type === 'warn',
|
|
35
|
+
'weui-btn_wechat': isH5 && type === 'wechat',
|
|
35
36
|
'weui-btn_disabled': isH5 && disabled,
|
|
36
37
|
[className]: className,
|
|
37
38
|
});
|
|
@@ -90,7 +91,7 @@ export interface PropsType extends CommonPropsType {
|
|
|
90
91
|
/**
|
|
91
92
|
* 样式类型
|
|
92
93
|
*/
|
|
93
|
-
type?:
|
|
94
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
94
95
|
/**
|
|
95
96
|
* 大小
|
|
96
97
|
*/
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { CommonPropsType } from '../../../types';
|
|
3
|
+
import { DataSource, Xfield, Yfield } from '../common/core/type';
|
|
4
|
+
import EchartBar from '../common/core/eChartBar';
|
|
5
|
+
import { useWedaChart } from '../common/useChart';
|
|
6
|
+
import classNames from '../../../utils/classnames';
|
|
7
|
+
interface PropsType extends CommonPropsType {
|
|
8
|
+
directionType?: string;
|
|
9
|
+
isPile?: boolean;
|
|
10
|
+
isTitle?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
titleLocation?: string;
|
|
13
|
+
dataSource?: DataSource;
|
|
14
|
+
filterData?: string;
|
|
15
|
+
setColor?: Array<string>;
|
|
16
|
+
xField?: Xfield;
|
|
17
|
+
xStatistics?: string;
|
|
18
|
+
groupKey?: Xfield;
|
|
19
|
+
groupKeyTimeSpan?: string;
|
|
20
|
+
xIsCountEmpty?: boolean;
|
|
21
|
+
yField?: Yfield;
|
|
22
|
+
isLegend?: boolean;
|
|
23
|
+
legend?: string;
|
|
24
|
+
legend2?: string;
|
|
25
|
+
isXaxisName?: boolean;
|
|
26
|
+
xAxisName?: string;
|
|
27
|
+
isXaxisAxisLabelShow?: boolean;
|
|
28
|
+
isXaxisAxisTickShow?: boolean;
|
|
29
|
+
isXaxisAxisLabelRotate?: boolean;
|
|
30
|
+
isYAxisSplitlineLinestyleWidth?: boolean;
|
|
31
|
+
yAxisSplitlineLinestyleType?: string;
|
|
32
|
+
yAxisMax?: number;
|
|
33
|
+
yAxisMin?: number;
|
|
34
|
+
isYAxisName?: boolean;
|
|
35
|
+
yAxisName?: string;
|
|
36
|
+
isSeriesShowSymbol?: boolean;
|
|
37
|
+
isYAxisShow?: boolean;
|
|
38
|
+
isUnit?: boolean;
|
|
39
|
+
unit?: string;
|
|
40
|
+
decimalDigits?: number;
|
|
41
|
+
suffix?: string;
|
|
42
|
+
}
|
|
43
|
+
export default function Bar(opts: PropsType) {
|
|
44
|
+
const {
|
|
45
|
+
directionType,
|
|
46
|
+
isPile,
|
|
47
|
+
id,
|
|
48
|
+
style,
|
|
49
|
+
className,
|
|
50
|
+
isTitle,
|
|
51
|
+
title,
|
|
52
|
+
titleLocation,
|
|
53
|
+
dataSource,
|
|
54
|
+
setColor,
|
|
55
|
+
filterData,
|
|
56
|
+
xField,
|
|
57
|
+
xStatistics,
|
|
58
|
+
groupKey,
|
|
59
|
+
groupKeyTimeSpan,
|
|
60
|
+
xIsCountEmpty,
|
|
61
|
+
yField,
|
|
62
|
+
isLegend,
|
|
63
|
+
legend,
|
|
64
|
+
legend2,
|
|
65
|
+
isXaxisName,
|
|
66
|
+
xAxisName,
|
|
67
|
+
isXaxisAxisLabelShow,
|
|
68
|
+
isXaxisAxisTickShow,
|
|
69
|
+
isXaxisAxisLabelRotate,
|
|
70
|
+
isYAxisSplitlineLinestyleWidth,
|
|
71
|
+
yAxisSplitlineLinestyleType,
|
|
72
|
+
yAxisMax,
|
|
73
|
+
yAxisMin,
|
|
74
|
+
isYAxisName,
|
|
75
|
+
yAxisName,
|
|
76
|
+
isSeriesShowSymbol,
|
|
77
|
+
isYAxisShow,
|
|
78
|
+
isUnit,
|
|
79
|
+
unit,
|
|
80
|
+
decimalDigits,
|
|
81
|
+
suffix,
|
|
82
|
+
} = opts;
|
|
83
|
+
const domRef = useRef<HTMLDivElement>();
|
|
84
|
+
useWedaChart(domRef, EchartBar, {
|
|
85
|
+
directionType,
|
|
86
|
+
isPile,
|
|
87
|
+
setColor,
|
|
88
|
+
isTitle,
|
|
89
|
+
title,
|
|
90
|
+
titleLocation,
|
|
91
|
+
dataSource,
|
|
92
|
+
filterData,
|
|
93
|
+
xField,
|
|
94
|
+
xStatistics,
|
|
95
|
+
groupKey,
|
|
96
|
+
groupKeyTimeSpan,
|
|
97
|
+
xIsCountEmpty,
|
|
98
|
+
yField,
|
|
99
|
+
isLegend,
|
|
100
|
+
legend,
|
|
101
|
+
legend2,
|
|
102
|
+
isXaxisName,
|
|
103
|
+
xAxisName,
|
|
104
|
+
isXaxisAxisLabelShow,
|
|
105
|
+
isXaxisAxisTickShow,
|
|
106
|
+
isXaxisAxisLabelRotate,
|
|
107
|
+
isYAxisSplitlineLinestyleWidth,
|
|
108
|
+
yAxisSplitlineLinestyleType,
|
|
109
|
+
yAxisMax,
|
|
110
|
+
yAxisMin,
|
|
111
|
+
isYAxisName,
|
|
112
|
+
yAxisName,
|
|
113
|
+
isSeriesShowSymbol,
|
|
114
|
+
isYAxisShow,
|
|
115
|
+
isUnit,
|
|
116
|
+
unit,
|
|
117
|
+
decimalDigits,
|
|
118
|
+
suffix,
|
|
119
|
+
});
|
|
120
|
+
const inlineStyle = {
|
|
121
|
+
height: '380px',
|
|
122
|
+
width: '100%',
|
|
123
|
+
backgroundColor: '#ffffff',
|
|
124
|
+
...style,
|
|
125
|
+
};
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
id={id}
|
|
129
|
+
data-testid="bar"
|
|
130
|
+
ref={domRef}
|
|
131
|
+
style={inlineStyle}
|
|
132
|
+
className={classNames({
|
|
133
|
+
'weda-ui-chart-bar': true,
|
|
134
|
+
'echart-wrapper-canvas': true,
|
|
135
|
+
'echart-dark-body': true,
|
|
136
|
+
[className]: className,
|
|
137
|
+
})}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
|
|
2
|
+
const getConfig = () => {
|
|
3
|
+
const barH5 = {
|
|
4
|
+
xAxis: {
|
|
5
|
+
name: 'X轴名',
|
|
6
|
+
nameTextStyle: { align: 'center' },
|
|
7
|
+
axisLabel: {
|
|
8
|
+
show: true, // 刻度标签显示
|
|
9
|
+
rotate: 0, // 字体倾斜
|
|
10
|
+
},
|
|
11
|
+
axisTick: {
|
|
12
|
+
show: true, // 刻度显示
|
|
13
|
+
},
|
|
14
|
+
inverse:false,
|
|
15
|
+
type: 'category',
|
|
16
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
17
|
+
},
|
|
18
|
+
yAxis: {
|
|
19
|
+
type: 'value',
|
|
20
|
+
show: true, // y轴刻度线
|
|
21
|
+
name: 'Y轴名',
|
|
22
|
+
splitLine: {
|
|
23
|
+
lineStyle: {
|
|
24
|
+
width: 1, // 网格线宽度,为0则不显示
|
|
25
|
+
type: 'dashed', //solid,dashed,dotted
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
axisLabel: { padding: [0, -10, 0, 0] },
|
|
29
|
+
min: null,
|
|
30
|
+
max: null,
|
|
31
|
+
},
|
|
32
|
+
series: [
|
|
33
|
+
{
|
|
34
|
+
name: 'demo',
|
|
35
|
+
data: [0, 932, 901, 934, 1290, 1330, 1320],
|
|
36
|
+
type: 'bar',
|
|
37
|
+
itemStyle: {
|
|
38
|
+
color: 'green',
|
|
39
|
+
},
|
|
40
|
+
showSymbol: true, //是否显示线条上数据标签
|
|
41
|
+
label: {
|
|
42
|
+
show: true, // 显示线条上的数据
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
return barH5;
|
|
48
|
+
};
|
|
49
|
+
export default getConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
|
|
2
|
+
const getConfig = () => {
|
|
3
|
+
const globalH5 = {
|
|
4
|
+
title: {
|
|
5
|
+
text: 'demo实例',
|
|
6
|
+
show: true,
|
|
7
|
+
left: '50%',
|
|
8
|
+
},
|
|
9
|
+
legend: {
|
|
10
|
+
top: '88%',
|
|
11
|
+
},
|
|
12
|
+
tooltip: {},
|
|
13
|
+
};
|
|
14
|
+
return globalH5;
|
|
15
|
+
};
|
|
16
|
+
export default getConfig;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
|
|
2
|
+
const getConfig = () => {
|
|
3
|
+
const lineH5 = {
|
|
4
|
+
xAxis: {
|
|
5
|
+
name: 'X轴名',
|
|
6
|
+
nameTextStyle: { align: 'center' },
|
|
7
|
+
axisLabel: {
|
|
8
|
+
show: true, // 刻度标签显示
|
|
9
|
+
rotate: 0, // 字体倾斜
|
|
10
|
+
},
|
|
11
|
+
axisTick: {
|
|
12
|
+
show: true, // 刻度显示
|
|
13
|
+
},
|
|
14
|
+
type: 'category',
|
|
15
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
16
|
+
},
|
|
17
|
+
yAxis: {
|
|
18
|
+
type: 'value',
|
|
19
|
+
show: true, // y轴刻度线
|
|
20
|
+
name: 'Y轴名',
|
|
21
|
+
splitLine: {
|
|
22
|
+
lineStyle: {
|
|
23
|
+
width: 1, // 网格线宽度,为0则不显示
|
|
24
|
+
type: 'dashed', //solid,dashed,dotted
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
axisLabel: {
|
|
28
|
+
padding: [0, -10, 0, 0],
|
|
29
|
+
},
|
|
30
|
+
min: null,
|
|
31
|
+
max: null,
|
|
32
|
+
},
|
|
33
|
+
series: [
|
|
34
|
+
{
|
|
35
|
+
name: 'demo',
|
|
36
|
+
connectNulls: true,
|
|
37
|
+
data: [820, 932, 901, 934, 1290, 1330, 1320],
|
|
38
|
+
type: 'line',
|
|
39
|
+
smooth: true,
|
|
40
|
+
showSymbol: true, //是否显示线条上数据标签
|
|
41
|
+
label: {
|
|
42
|
+
show: true, // 显示线条上的数据
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
return lineH5;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default getConfig;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** 根据当前环境获取 pc 上配置,还是 H5上的配置 */
|
|
2
|
+
const getConfig = () => {
|
|
3
|
+
const pieH5 = {
|
|
4
|
+
series: [
|
|
5
|
+
{
|
|
6
|
+
// name: 'demo',
|
|
7
|
+
data: [
|
|
8
|
+
{ value: 820, name: '实例数据1', tooltip: {}, itemStyle: {} },
|
|
9
|
+
{ value: 932, name: '实例数据2', tooltip: {}, itemStyle: {} },
|
|
10
|
+
{ value: 901, name: '实例数据3', tooltip: {}, itemStyle: {} },
|
|
11
|
+
{ value: 934, name: '实例数据4', tooltip: {}, itemStyle: {} },
|
|
12
|
+
{ value: 1290, name: '实例数据5', tooltip: {}, itemStyle: {} },
|
|
13
|
+
],
|
|
14
|
+
label: {
|
|
15
|
+
show: true,
|
|
16
|
+
position: 'inner',
|
|
17
|
+
normal: {
|
|
18
|
+
formatter: null,
|
|
19
|
+
position: 'inner',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
type: 'pie',
|
|
23
|
+
radius: '70%',
|
|
24
|
+
emphasis: {
|
|
25
|
+
itemStyle: {
|
|
26
|
+
shadowBlur: 10,
|
|
27
|
+
shadowOffsetX: 0,
|
|
28
|
+
shadowColor: 'rgba(0, 0, 0, 0.5)',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return pieH5;
|
|
36
|
+
};
|
|
37
|
+
export default getConfig;
|