@cloudbase/weda-ui 0.2.17 → 2.0.8
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 +3 -0
- package/package.json +10 -5
- package/src/configs/components/button.json +0 -2
- package/src/configs/components/calendar.json +9 -3
- package/src/configs/components/carousel.json +18 -9
- package/src/configs/components/chart/bar.json +31 -12
- package/src/configs/components/chart/line.json +27 -10
- package/src/configs/components/chart/pie.json +22 -8
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +31 -11
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +123 -4
- package/src/configs/components/form/select.json +247 -13
- package/src/configs/components/graphicCard.json +90 -75
- package/src/configs/components/image.json +19 -8
- package/src/configs/components/link.json +25 -6
- package/src/configs/components/listView.json +83 -27
- package/src/configs/components/lottery.json +153 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +97 -79
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +6 -2
- package/src/configs/components/scrollVeiw.json +98 -34
- package/src/configs/components/swiper.json +22 -10
- package/src/configs/components/tabs.json +54 -9
- package/src/configs/components/text.json +43 -30
- 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 +13 -0
- package/src/docs/common/format.tsx +112 -0
- package/src/docs/common/tableView.css +164 -0
- package/src/docs/common/tableView.tsx +273 -0
- package/src/docs/compsdocs/chart/Bar.mdx +159 -0
- package/src/docs/compsdocs/chart/Line.mdx +100 -0
- package/src/docs/compsdocs/chart/Pie.mdx +83 -0
- package/src/docs/compsdocs/chart/_category_.json +1 -0
- package/src/docs/compsdocs/chart/statisticsCard.mdx +51 -0
- package/src/docs/compsdocs/database/DataView.mdx +33 -0
- package/src/docs/compsdocs/database/ListView.mdx +33 -0
- package/src/docs/compsdocs/database/_category_.json +1 -0
- package/src/docs/compsdocs/form/Form.mdx +35 -0
- package/src/docs/compsdocs/form/FormCheckbox.mdx +35 -0
- package/src/docs/compsdocs/form/FormDate.mdx +30 -0
- package/src/docs/compsdocs/form/FormEmail.mdx +30 -0
- package/src/docs/compsdocs/form/FormImageUploader.mdx +31 -0
- package/src/docs/compsdocs/form/FormInput.mdx +30 -0
- package/src/docs/compsdocs/form/FormLocation.mdx +64 -0
- package/src/docs/compsdocs/form/FormPhone.mdx +30 -0
- package/src/docs/compsdocs/form/FormRadio.mdx +35 -0
- package/src/docs/compsdocs/form/FormRegion.mdx +30 -0
- package/src/docs/compsdocs/form/FormSelect.mdx +36 -0
- package/src/docs/compsdocs/form/FormSwitch.mdx +30 -0
- package/src/docs/compsdocs/form/FormTextarea.mdx +30 -0
- package/src/docs/compsdocs/form/FormTime.mdx +30 -0
- package/src/docs/compsdocs/form/FormUploadFile.mdx +30 -0
- package/src/docs/compsdocs/form/FormUrl.mdx +30 -0
- package/src/docs/compsdocs/form/_category_.json +1 -0
- package/src/docs/compsdocs/grid/Card.mdx +32 -0
- package/src/docs/compsdocs/grid/Container.mdx +42 -0
- package/src/docs/compsdocs/grid/Footer.mdx +31 -0
- package/src/docs/compsdocs/grid/GridLayout.mdx +32 -0
- package/src/docs/compsdocs/grid/Header.mdx +31 -0
- package/src/docs/compsdocs/grid/Layout.mdx +25 -0
- package/src/docs/compsdocs/grid/List.mdx +31 -0
- package/src/docs/compsdocs/grid/ScrollView.mdx +37 -0
- package/src/docs/compsdocs/grid/Swiper.mdx +58 -0
- package/src/docs/compsdocs/grid/_category_.json +1 -0
- package/src/docs/compsdocs/media/Icon.mdx +31 -0
- package/src/docs/compsdocs/media/Image.mdx +55 -0
- package/src/docs/compsdocs/media/_category_.json +1 -0
- package/src/docs/compsdocs/model/ModelCreate.mdx +20 -0
- package/src/docs/compsdocs/model/ModelDetail.mdx +20 -0
- package/src/docs/compsdocs/model/ModelTable.mdx +24 -0
- package/src/docs/compsdocs/model/ModelUpdate.mdx +21 -0
- package/src/docs/compsdocs/model/PageLayout.mdx +21 -0
- package/src/docs/compsdocs/model/_category_.json +1 -0
- package/src/docs/compsdocs/navmenu/Classification.mdx +38 -0
- package/src/docs/compsdocs/navmenu/NavBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +30 -0
- package/src/docs/compsdocs/navmenu/TabBar.mdx +43 -0
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +29 -0
- package/src/docs/compsdocs/navmenu/_category_.json +1 -0
- package/src/docs/compsdocs/senior/Lottery.mdx +48 -0
- package/src/docs/compsdocs/senior/Modal.mdx +58 -0
- package/src/docs/compsdocs/senior/SlotMachine.mdx +52 -0
- package/src/docs/compsdocs/senior/_category_.json +1 -0
- package/src/docs/compsdocs/show/Calendar.mdx +29 -0
- package/src/docs/compsdocs/show/Divider.mdx +31 -0
- package/src/docs/compsdocs/show/GraphicCard.mdx +30 -0
- package/src/docs/compsdocs/show/Item.mdx +32 -0
- package/src/docs/compsdocs/show/ItemList.mdx +47 -0
- package/src/docs/compsdocs/show/Media.mdx +25 -0
- package/src/docs/compsdocs/show/StatusTip.mdx +25 -0
- package/src/docs/compsdocs/show/Swiper.mdx +33 -0
- package/src/docs/compsdocs/show/Tabs.mdx +38 -0
- package/src/docs/compsdocs/show/_category_.json +1 -0
- package/src/docs/compsdocs/show/button.mdx +25 -0
- package/src/docs/compsdocs/text/Link.mdx +43 -0
- package/src/docs/compsdocs/text/RichTextView.mdx +36 -0
- package/src/docs/compsdocs/text/Text.mdx +31 -0
- package/src/docs/compsdocs/text/Title.mdx +32 -0
- package/src/docs/compsdocs/text/_category_.json +1 -0
- package/src/docs/compsdocs/wxOpen/Phone.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/Share.mdx +46 -0
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +60 -0
- package/src/docs/compsdocs/wxOpen/_category_.json +4 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.js +18 -2
- package/src/mp/components/button/index.wxml +7 -4
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- 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/formcell/index.wxml +1 -1
- package/src/mp/components/form/formcell/index.wxss +17 -0
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/input/index.wxss +15 -0
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/location/index.wxss +4 -6
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +351 -41
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/index.wxss +4 -0
- package/src/mp/components/form/select/region/index.js +101 -0
- package/src/mp/components/form/textarea/index.js +1 -1
- package/src/mp/components/form/textarea/index.wxss +4 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploader/index.json +3 -2
- package/src/mp/components/form/uploader/index.wxml +11 -7
- package/src/mp/components/form/uploader/index.wxss +20 -2
- package/src/mp/components/form/uploader/weui-uploader.js +209 -0
- package/src/mp/components/form/uploader/weui-uploader.json +7 -0
- package/src/mp/components/form/uploader/weui-uploader.wxml +45 -0
- package/src/mp/components/form/uploader/weui-uploader.wxss +1 -0
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/form/uploaderFile/index.wxss +4 -4
- package/src/mp/components/image/index.wxss +3 -2
- package/src/mp/components/listView/index.js +38 -43
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/{internals/listView → lottery}/index.json +0 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- 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 +7 -1
- package/src/mp/style/weda-ui.wxss +16 -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 +10 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +10 -9
- package/src/web/components/calendar/index.jsx +1 -1
- package/src/web/components/carousel/index.tsx +8 -8
- package/src/web/components/chart/bar/index.tsx +40 -39
- package/src/web/components/chart/common/config/line.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- 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/form/index.css +5 -1
- package/src/web/components/form/form/index.tsx +3 -1
- package/src/web/components/form/formcell/index.css +22 -1
- package/src/web/components/form/formcell/index.tsx +11 -6
- package/src/web/components/form/input/index.css +7 -12
- package/src/web/components/form/location/components/LocationH5/index.css +4 -7
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +1 -1
- package/src/web/components/form/radio/index.tsx +90 -53
- package/src/web/components/form/select/h5.tsx +370 -73
- package/src/web/components/form/select/index.css +15 -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 +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +2 -2
- 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/index.css +26 -2
- package/src/web/components/form/uploader/uploader.h5.tsx +89 -57
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/index.css +2 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.css +3 -3
- package/src/web/components/image/index.tsx +6 -7
- package/src/web/components/index.js +8 -0
- package/src/web/components/link/index.tsx +7 -4
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +12 -20
- 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/navLayout/index.tsx +2 -2
- 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 +230 -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/picker/timePicker.tsx +2 -2
- 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/slot/index.tsx +1 -1
- 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 +12 -20
- 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 +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +7 -1
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- 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
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { CommonPropsType } from '../../types';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import { ConfigProvider } from 'tea-component';
|
|
5
|
+
import { usePlatform, isInIde } from '../../utils/platform';
|
|
6
|
+
import { getAppCustomNav } from '../../utils/tcb';
|
|
7
|
+
import { IMenuItem, INavigationStyle } from './type';
|
|
8
|
+
import './index.css';
|
|
9
|
+
import VerticalMenu from './verticalMenu';
|
|
10
|
+
import HorizontalMenu from './horizontalMenu';
|
|
11
|
+
import H5Menu from './h5Menu';
|
|
12
|
+
import { expandMenu, findMenuItemByPath } from './common';
|
|
13
|
+
import destr from 'destr';
|
|
14
|
+
/**
|
|
15
|
+
* Web端
|
|
16
|
+
*/
|
|
17
|
+
const CLASS_PREFIX = 'weda-menu';
|
|
18
|
+
|
|
19
|
+
// 默认导航数据
|
|
20
|
+
const defaultNavigationBar: {
|
|
21
|
+
navigationStyle: INavigationStyle;
|
|
22
|
+
menuData: IMenuItem[];
|
|
23
|
+
} = {
|
|
24
|
+
menuData: [],
|
|
25
|
+
navigationStyle: {
|
|
26
|
+
isHorizontal: false,
|
|
27
|
+
showMenuIcon: true,
|
|
28
|
+
menuFontSize: 16,
|
|
29
|
+
menuBackgroundColor: '#fff',
|
|
30
|
+
menuColor: '#000',
|
|
31
|
+
menuHoverColor: '#f3f3f3',
|
|
32
|
+
showTitle: true,
|
|
33
|
+
title: '菜单标题',
|
|
34
|
+
showLogo: true,
|
|
35
|
+
logoUrl:
|
|
36
|
+
'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg',
|
|
37
|
+
titleFontSize: 18,
|
|
38
|
+
titleColor: '#000',
|
|
39
|
+
logoWidth: 32,
|
|
40
|
+
logoHeight: 32,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
// 默认高亮当前路由对应的菜单
|
|
44
|
+
const defaultSelectedMenu = (menu: IMenuItem[]) => {
|
|
45
|
+
try {
|
|
46
|
+
const url = window.location.href;
|
|
47
|
+
let selectedKey = url.substring(url.lastIndexOf('/'));
|
|
48
|
+
const targetMenu = findMenuItemByPath(menu, selectedKey);
|
|
49
|
+
if (targetMenu) {
|
|
50
|
+
selectedKey = targetMenu.key;
|
|
51
|
+
}
|
|
52
|
+
return selectedKey;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 导航菜单
|
|
59
|
+
*/
|
|
60
|
+
export default function NavigationBar({
|
|
61
|
+
navigationbar,
|
|
62
|
+
contentSlot,
|
|
63
|
+
className,
|
|
64
|
+
style,
|
|
65
|
+
callApi = { getAppCustomNav },
|
|
66
|
+
}: PropsType) {
|
|
67
|
+
const platform = usePlatform();
|
|
68
|
+
const [menuData, setMenuData] = useState<IMenuItem[]>([]);
|
|
69
|
+
const [mobileMenuData, setMobileMenuData] = useState<IMenuItem[]>([]);
|
|
70
|
+
// 是否启用多端
|
|
71
|
+
const [isMultiTerminal, setIsMultiTerminal] = useState(false);
|
|
72
|
+
const [navigationStyle, setNavigationStyle] = useState<INavigationStyle>(
|
|
73
|
+
defaultNavigationBar.navigationStyle
|
|
74
|
+
);
|
|
75
|
+
// 菜单选中
|
|
76
|
+
const [selected, setSelected] = useState<string>('');
|
|
77
|
+
// 导航样式
|
|
78
|
+
const { isHorizontal = false } = navigationStyle;
|
|
79
|
+
const cls = classNames({
|
|
80
|
+
[CLASS_PREFIX]: true,
|
|
81
|
+
[className]: className,
|
|
82
|
+
[`${CLASS_PREFIX}-mobile`]: platform === 'h5',
|
|
83
|
+
[`${CLASS_PREFIX}-horizontal`]: isHorizontal,
|
|
84
|
+
});
|
|
85
|
+
// 导航容器样式
|
|
86
|
+
const navigationWrapStyle: React.CSSProperties = {
|
|
87
|
+
display: 'flex',
|
|
88
|
+
height: '100vh',
|
|
89
|
+
flexDirection: isHorizontal || platform === 'h5' ? 'column' : 'row',
|
|
90
|
+
position: 'relative',
|
|
91
|
+
...style,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// 更新导航菜单
|
|
95
|
+
const updateNavigationData = () => {
|
|
96
|
+
callApi
|
|
97
|
+
.getAppCustomNav()
|
|
98
|
+
.then((res) => {
|
|
99
|
+
const { Content } = res;
|
|
100
|
+
const navigationData = destr(Content);
|
|
101
|
+
if (navigationData?.navigationStyle) {
|
|
102
|
+
// 设置默认选中
|
|
103
|
+
let selectedKey = '';
|
|
104
|
+
if (navigationData?.menuData?.length) {
|
|
105
|
+
selectedKey = defaultSelectedMenu(navigationData?.menuData);
|
|
106
|
+
}
|
|
107
|
+
setSelected(selectedKey);
|
|
108
|
+
|
|
109
|
+
// 设置默认展开状态
|
|
110
|
+
let menus = navigationData?.menuData || [];
|
|
111
|
+
menus = expandMenu(menus, { key: selectedKey }, true);
|
|
112
|
+
setMenuData(menus);
|
|
113
|
+
setNavigationStyle({
|
|
114
|
+
...defaultNavigationBar.navigationStyle,
|
|
115
|
+
...navigationData?.navigationStyle,
|
|
116
|
+
});
|
|
117
|
+
// 如果启用多端独立菜单导航,则设置移动端数据
|
|
118
|
+
if (navigationData?.isMultiTerminal) {
|
|
119
|
+
let mobileMenus = navigationData?.mobileMenuData || [];
|
|
120
|
+
mobileMenus = expandMenu(mobileMenus, { key: selectedKey }, true);
|
|
121
|
+
setMobileMenuData(mobileMenus);
|
|
122
|
+
setIsMultiTerminal(true);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
.catch((error) => {
|
|
127
|
+
console.log(error);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* 每次渲染组件通过接口拉取数据
|
|
132
|
+
*/
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
updateNavigationData();
|
|
135
|
+
}, []);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (isInIde()) {
|
|
138
|
+
// setMenuData(navigationbar?.menuData);
|
|
139
|
+
// setNavigationStyle(navigationbar?.navigationStyle);
|
|
140
|
+
updateNavigationData();
|
|
141
|
+
}
|
|
142
|
+
}, [navigationbar]);
|
|
143
|
+
|
|
144
|
+
// 初始化css变量
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (navigationStyle.menuHoverColor) {
|
|
147
|
+
const body = document.getElementsByTagName('body')[0];
|
|
148
|
+
if (body) {
|
|
149
|
+
body.style.setProperty(
|
|
150
|
+
'--weda-navigation-menu-hover-color',
|
|
151
|
+
navigationStyle.menuHoverColor
|
|
152
|
+
);
|
|
153
|
+
body.style.setProperty(
|
|
154
|
+
'--weda-navigation-menu-selected-color',
|
|
155
|
+
navigationStyle.menuHoverColor
|
|
156
|
+
);
|
|
157
|
+
body.style.setProperty(
|
|
158
|
+
'--weda-navigation-menu-background-color',
|
|
159
|
+
navigationStyle.menuBackgroundColor
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, [navigationStyle.menuHoverColor, navigationStyle.menuBackgroundColor]);
|
|
164
|
+
|
|
165
|
+
const renderMenu = () => {
|
|
166
|
+
return (
|
|
167
|
+
<>
|
|
168
|
+
<div
|
|
169
|
+
className={cls}
|
|
170
|
+
style={navigationWrapStyle}
|
|
171
|
+
data-testid="navigationBar"
|
|
172
|
+
>
|
|
173
|
+
<div
|
|
174
|
+
className={`${CLASS_PREFIX}__wrapper`}
|
|
175
|
+
style={{
|
|
176
|
+
background: navigationStyle?.menuBackgroundColor || '#fff',
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{platform !== 'h5' && !isHorizontal && (
|
|
180
|
+
<VerticalMenu
|
|
181
|
+
menuData={menuData}
|
|
182
|
+
navigationStyle={navigationStyle}
|
|
183
|
+
setMenuData={setMenuData}
|
|
184
|
+
selected={selected}
|
|
185
|
+
setSelected={setSelected}
|
|
186
|
+
/>
|
|
187
|
+
)}
|
|
188
|
+
{platform !== 'h5' && isHorizontal && (
|
|
189
|
+
<HorizontalMenu
|
|
190
|
+
menuData={menuData}
|
|
191
|
+
navigationStyle={navigationStyle}
|
|
192
|
+
selected={selected}
|
|
193
|
+
setSelected={setSelected}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
{platform === 'h5' && (
|
|
197
|
+
<H5Menu
|
|
198
|
+
menuData={isMultiTerminal ? mobileMenuData : menuData}
|
|
199
|
+
navigationStyle={navigationStyle}
|
|
200
|
+
setMenuData={setMenuData}
|
|
201
|
+
className={className}
|
|
202
|
+
selected={selected}
|
|
203
|
+
setSelected={setSelected}
|
|
204
|
+
/>
|
|
205
|
+
)}
|
|
206
|
+
</div>
|
|
207
|
+
<div className="menu-solt">{contentSlot}</div>
|
|
208
|
+
</div>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
215
|
+
{!isInIde() &&
|
|
216
|
+
(menuData?.length > 0 || mobileMenuData?.length > 0) &&
|
|
217
|
+
renderMenu()}
|
|
218
|
+
{isInIde() && renderMenu()}
|
|
219
|
+
</ConfigProvider>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface PropsType extends CommonPropsType {
|
|
224
|
+
contentSlot?: string;
|
|
225
|
+
navigationbar: {
|
|
226
|
+
navigationStyle: INavigationStyle;
|
|
227
|
+
menuData: IMenuItem[];
|
|
228
|
+
};
|
|
229
|
+
callApi: any;
|
|
230
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export interface IMenuItem {
|
|
2
|
+
/**
|
|
3
|
+
* 节点的 id
|
|
4
|
+
*/
|
|
5
|
+
key: string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 菜单标题
|
|
9
|
+
*/
|
|
10
|
+
title?: string | any;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 菜单类型
|
|
14
|
+
* group 分组
|
|
15
|
+
* link 外链菜单
|
|
16
|
+
* basemenu 无链接菜单
|
|
17
|
+
* route 内链菜单
|
|
18
|
+
*/
|
|
19
|
+
type?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 是否外跳
|
|
23
|
+
*/
|
|
24
|
+
linkTargetBlank?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 路由路径
|
|
27
|
+
*/
|
|
28
|
+
path?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 外部链接
|
|
31
|
+
*/
|
|
32
|
+
linkUrl?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 图标链接
|
|
35
|
+
*/
|
|
36
|
+
iconUrl?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 子菜单
|
|
40
|
+
*/
|
|
41
|
+
children?: IMenuItem[];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 层级
|
|
45
|
+
*/
|
|
46
|
+
level: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 展开状态
|
|
50
|
+
*/
|
|
51
|
+
opened?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface INavigationStyle {
|
|
55
|
+
/**
|
|
56
|
+
* 是否横向菜单
|
|
57
|
+
*/
|
|
58
|
+
isHorizontal: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 是否展示菜单图标
|
|
61
|
+
*/
|
|
62
|
+
showMenuIcon: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 菜单字号
|
|
65
|
+
*/
|
|
66
|
+
menuFontSize: number;
|
|
67
|
+
/**
|
|
68
|
+
* 菜单背景色
|
|
69
|
+
*/
|
|
70
|
+
menuBackgroundColor: string;
|
|
71
|
+
/**
|
|
72
|
+
* 菜单字体颜色
|
|
73
|
+
*/
|
|
74
|
+
menuColor: string;
|
|
75
|
+
/**
|
|
76
|
+
* 菜单选中颜色
|
|
77
|
+
*/
|
|
78
|
+
menuHoverColor: string;
|
|
79
|
+
/**
|
|
80
|
+
* 标题
|
|
81
|
+
*/
|
|
82
|
+
showTitle: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* 名称
|
|
85
|
+
*/
|
|
86
|
+
title: string;
|
|
87
|
+
/**
|
|
88
|
+
* 是否展示图标
|
|
89
|
+
*/
|
|
90
|
+
showLogo: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 图标地址
|
|
93
|
+
*/
|
|
94
|
+
logoUrl: string;
|
|
95
|
+
/**
|
|
96
|
+
* 标题字号
|
|
97
|
+
*/
|
|
98
|
+
titleFontSize: number;
|
|
99
|
+
/**
|
|
100
|
+
* 标题颜色
|
|
101
|
+
*/
|
|
102
|
+
titleColor: string;
|
|
103
|
+
/**
|
|
104
|
+
* 图标宽度
|
|
105
|
+
*/
|
|
106
|
+
logoWidth: number;
|
|
107
|
+
/**
|
|
108
|
+
* 图标高度
|
|
109
|
+
*/
|
|
110
|
+
logoHeight: number;
|
|
111
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Menu } from 'tea-component';
|
|
3
|
+
import { IMenuItem, INavigationStyle } from './type';
|
|
4
|
+
import {
|
|
5
|
+
renderMenuTitle,
|
|
6
|
+
renderLogo,
|
|
7
|
+
renderTitle,
|
|
8
|
+
navigateTo,
|
|
9
|
+
expandMenu,
|
|
10
|
+
} from './common';
|
|
11
|
+
const CLASS_PREFIX = 'weda-menu';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* pc端纵向导航
|
|
15
|
+
*/
|
|
16
|
+
const VerticalMenu: React.FC<{
|
|
17
|
+
menuData: IMenuItem[];
|
|
18
|
+
navigationStyle: INavigationStyle;
|
|
19
|
+
setMenuData: (menus: IMenuItem[]) => void;
|
|
20
|
+
selected: string;
|
|
21
|
+
setSelected: (selectedKey: string) => void;
|
|
22
|
+
}> = ({ menuData, navigationStyle, setMenuData, selected, setSelected }) => {
|
|
23
|
+
// 菜单背景色
|
|
24
|
+
const menuStyle: React.CSSProperties = {
|
|
25
|
+
background: navigationStyle.menuBackgroundColor || '#fff',
|
|
26
|
+
};
|
|
27
|
+
// 渲染subMenu
|
|
28
|
+
const renderSubMenu = (item: IMenuItem, hasThereNode = false) => {
|
|
29
|
+
const { key, children, opened } = item;
|
|
30
|
+
return children.length > 0 ? (
|
|
31
|
+
<Menu.SubMenu
|
|
32
|
+
className={hasThereNode ? `${CLASS_PREFIX}__submenu` : ''}
|
|
33
|
+
key={key}
|
|
34
|
+
title={renderMenuTitle(navigationStyle, item, true)}
|
|
35
|
+
opened={opened}
|
|
36
|
+
onOpenedChange={(opened) => {
|
|
37
|
+
const menus = expandMenu(menuData, { ...item, opened });
|
|
38
|
+
setMenuData(menus);
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{children?.map((el: any) => renderSubMenu(el, true))}
|
|
42
|
+
</Menu.SubMenu>
|
|
43
|
+
) : (
|
|
44
|
+
renderMenuItem(item)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
// 渲染MenuItem
|
|
48
|
+
const renderMenuItem = (item: IMenuItem) => {
|
|
49
|
+
const { key } = item;
|
|
50
|
+
return (
|
|
51
|
+
<Menu.Item
|
|
52
|
+
key={key}
|
|
53
|
+
title={renderMenuTitle(navigationStyle, item, true)}
|
|
54
|
+
selected={item.key === selected}
|
|
55
|
+
onClick={() => {
|
|
56
|
+
if (item.key !== selected) {
|
|
57
|
+
setSelected(item.key);
|
|
58
|
+
navigateTo(item);
|
|
59
|
+
}
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Menu
|
|
67
|
+
style={menuStyle}
|
|
68
|
+
className={`${CLASS_PREFIX}__menu-content`}
|
|
69
|
+
title={renderTitle(navigationStyle) || ' '}
|
|
70
|
+
icon={renderLogo(navigationStyle, `${CLASS_PREFIX}__main-icon`)}
|
|
71
|
+
>
|
|
72
|
+
{menuData?.map((item: any) => {
|
|
73
|
+
return item?.children?.length > 0
|
|
74
|
+
? renderSubMenu(item)
|
|
75
|
+
: renderMenuItem(item);
|
|
76
|
+
})}
|
|
77
|
+
</Menu>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default VerticalMenu;
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Button from '../../components/button';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const Phone = (props: PropsType) => <Button {...props} />;
|
|
6
|
+
|
|
7
|
+
export interface PropsType extends CommonPropsType {
|
|
8
|
+
/**
|
|
9
|
+
* 按钮标题
|
|
10
|
+
*/
|
|
11
|
+
text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按钮风格
|
|
14
|
+
*/
|
|
15
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
16
|
+
/**
|
|
17
|
+
* 按钮大小
|
|
18
|
+
*/
|
|
19
|
+
size?: 'default' | 'mini' | 'large';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default Phone;
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Button from '../../components/button';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const PhoneCode = (props: PropsType) => <Button {...props} />;
|
|
6
|
+
|
|
7
|
+
export interface PropsType extends CommonPropsType {
|
|
8
|
+
/**
|
|
9
|
+
* 按钮标题
|
|
10
|
+
*/
|
|
11
|
+
text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按钮风格
|
|
14
|
+
*/
|
|
15
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
16
|
+
/**
|
|
17
|
+
* 按钮大小
|
|
18
|
+
*/
|
|
19
|
+
size?: 'default' | 'mini' | 'large';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default PhoneCode;
|
|
@@ -9,7 +9,7 @@ export interface PropsType extends CommonPropsType {
|
|
|
9
9
|
title?: string;
|
|
10
10
|
}
|
|
11
11
|
export default function TimePicker(props: PropsType) {
|
|
12
|
-
const { title
|
|
12
|
+
const { title, defaultValue = '', children, className } = props;
|
|
13
13
|
|
|
14
14
|
const click = function () {
|
|
15
15
|
const hour = [];
|
|
@@ -53,4 +53,4 @@ export default function TimePicker(props: PropsType) {
|
|
|
53
53
|
{children}
|
|
54
54
|
</div>
|
|
55
55
|
);
|
|
56
|
-
}
|
|
56
|
+
}
|
|
@@ -4,6 +4,7 @@ import { getTempFileURL } from '../../utils/tcb';
|
|
|
4
4
|
import './index.css';
|
|
5
5
|
import { LOAD_ERR_IMG_BASE64 } from '../../utils/constant';
|
|
6
6
|
import { CommonPropsType } from '../../types';
|
|
7
|
+
import destr from 'destr';
|
|
7
8
|
|
|
8
9
|
export interface PropsType extends CommonPropsType {
|
|
9
10
|
value: string
|
|
@@ -15,10 +16,7 @@ export default function RichTextView({
|
|
|
15
16
|
style,
|
|
16
17
|
id
|
|
17
18
|
}: PropsType) {
|
|
18
|
-
let parseValue = value;
|
|
19
|
-
try {
|
|
20
|
-
parseValue = JSON.parse(value);
|
|
21
|
-
} catch (e) {}
|
|
19
|
+
let parseValue = destr(value);
|
|
22
20
|
const cls = classNames({
|
|
23
21
|
'weda-ui': true,
|
|
24
22
|
'weda-RichTextView': true,
|
|
@@ -64,4 +62,4 @@ export default function RichTextView({
|
|
|
64
62
|
</div>
|
|
65
63
|
)
|
|
66
64
|
);
|
|
67
|
-
}
|
|
65
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Button from '../../components/button';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const Share = (props: PropsType) => <Button {...props} />;
|
|
6
|
+
|
|
7
|
+
export interface PropsType extends CommonPropsType {
|
|
8
|
+
/**
|
|
9
|
+
* 按钮标题
|
|
10
|
+
*/
|
|
11
|
+
text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按钮风格
|
|
14
|
+
*/
|
|
15
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
16
|
+
/**
|
|
17
|
+
* 按钮大小
|
|
18
|
+
*/
|
|
19
|
+
size?: 'default' | 'mini' | 'large';
|
|
20
|
+
/**
|
|
21
|
+
* 分享标题
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 选择页面
|
|
26
|
+
*/
|
|
27
|
+
path?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 携带参数
|
|
30
|
+
*/
|
|
31
|
+
withParams?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 参数
|
|
34
|
+
*/
|
|
35
|
+
params?: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default Share;
|
|
@@ -12,11 +12,13 @@ import TabsPc from './tabs.pc';
|
|
|
12
12
|
export interface PropsType extends CommonPropsType {
|
|
13
13
|
tabs: {
|
|
14
14
|
title: string;
|
|
15
|
+
value: string;
|
|
15
16
|
|
|
16
17
|
// @deprecated
|
|
17
18
|
name?: string;
|
|
18
19
|
}[];
|
|
19
20
|
selectedIndex: number|string
|
|
21
|
+
isMultipleSlot: boolean
|
|
20
22
|
[key: string]: React.ReactNode
|
|
21
23
|
// [panel: `panel${number}`]: React.ReactNode; // require typescript@4.4
|
|
22
24
|
}
|
|
@@ -4,13 +4,16 @@ import './index.css';
|
|
|
4
4
|
import classNames from '../../utils/classnames';
|
|
5
5
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
6
6
|
import {PropsType} from './index';
|
|
7
|
+
import { useCustomCompareEffect, usePrevious, useSyncedRef } from '@react-hookz/web';
|
|
8
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
7
9
|
|
|
8
10
|
export default function TabsH5({
|
|
9
|
-
tabs,
|
|
11
|
+
tabs = [],
|
|
10
12
|
selectedIndex,
|
|
11
13
|
events,
|
|
12
14
|
className,
|
|
13
15
|
style,
|
|
16
|
+
isMultipleSlot = true,
|
|
14
17
|
...restProps
|
|
15
18
|
}: PropsType) {
|
|
16
19
|
const [currentIndex, setCurrentIndex] = useSyncValue(
|
|
@@ -25,44 +28,51 @@ export default function TabsH5({
|
|
|
25
28
|
};
|
|
26
29
|
}, [tabs, currentIndex]);
|
|
27
30
|
|
|
31
|
+
const eventRef = useSyncedRef(events);
|
|
32
|
+
useCustomCompareEffect(() => {
|
|
33
|
+
eventRef.current.change(
|
|
34
|
+
{
|
|
35
|
+
id: currentIndex,
|
|
36
|
+
label: tabs[currentIndex]?.title,
|
|
37
|
+
value: tabs[currentIndex]?.value,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}, [currentIndex, tabs], isObjectEqual);
|
|
28
41
|
return (
|
|
29
|
-
<div
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
<div
|
|
43
|
+
data-testid="tabs"
|
|
44
|
+
className={classNames('weda-tabs weda-ui', {
|
|
45
|
+
[className]: className,
|
|
46
|
+
})}
|
|
47
|
+
style={style}
|
|
48
|
+
>
|
|
32
49
|
<div className="weda-tabs__nav">
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
key={name || index}
|
|
46
|
-
onClick={(event) => {
|
|
47
|
-
setCurrentIndex(index);
|
|
48
|
-
events && events.change({id: index, label: title}, { event });
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
50
|
+
{tabs?.map(({ name, title }, index) => (
|
|
51
|
+
<div
|
|
52
|
+
className={classNames('weda-tabs__nav-cell', {
|
|
53
|
+
active: currentIndex === index,
|
|
54
|
+
scroll: currentIndex > 5,
|
|
55
|
+
})}
|
|
56
|
+
key={name || index}
|
|
57
|
+
onClick={() => {
|
|
58
|
+
setCurrentIndex(index);
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
51
61
|
{title}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
62
|
+
</div>
|
|
63
|
+
))}
|
|
55
64
|
|
|
56
|
-
<div
|
|
57
|
-
className="weda-tabs__nav-sticky"
|
|
58
|
-
style={stickyStyle}
|
|
59
|
-
></div>
|
|
65
|
+
<div className="weda-tabs__nav-sticky" style={stickyStyle}></div>
|
|
60
66
|
</div>
|
|
61
67
|
|
|
62
|
-
<div
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
<div
|
|
69
|
+
className={classNames({
|
|
70
|
+
'weda-tabs__panel': true,
|
|
71
|
+
})}
|
|
72
|
+
>
|
|
73
|
+
{isMultipleSlot
|
|
74
|
+
? restProps[`panel${currentIndex + 1}`]
|
|
75
|
+
: restProps['panel1']}
|
|
66
76
|
</div>
|
|
67
77
|
</div>
|
|
68
78
|
);
|