@cloudbase/weda-ui 0.2.10 → 0.2.14
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/CHANGELOG.md +240 -0
- package/package.json +61 -40
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/configs/components/button.json +7 -3
- package/src/configs/components/form/richText.json +1 -1
- package/src/configs/components/form/uploader.json +29 -1
- package/src/configs/components/form/uploaderFile.json +158 -0
- package/src/configs/components/image.json +12 -3
- package/src/configs/components/link.json +3 -3
- package/src/configs/components/richtextview.json +2 -2
- package/src/configs/components/scrollVeiw.json +5 -5
- package/src/configs/components/swiper.json +6 -6
- package/src/configs/components/tabs.json +3 -3
- package/src/configs/components/text.json +39 -4
- package/src/configs/index.js +5 -3
- package/src/mp/.gitignore +10 -0
- package/src/mp/components/button/index.js +1 -0
- package/src/mp/components/button/index.wxss +8 -0
- package/src/mp/components/form/select/index.js +18 -0
- package/src/mp/components/form/uploader/index.js +26 -29
- package/src/mp/components/form/uploaderFile/index.js +233 -0
- package/src/mp/components/form/uploaderFile/index.json +9 -0
- package/src/mp/components/form/uploaderFile/index.wxml +46 -0
- package/src/mp/components/form/uploaderFile/index.wxss +105 -0
- package/src/mp/components/text/index.js +33 -0
- package/src/mp/components/text/index.wxml +1 -1
- package/src/mp/components/text/index.wxss +18 -0
- package/src/mp/index.json +1 -0
- package/src/mp/utils/platform.js +20 -0
- package/src/mp/utils/tcb.js +11 -0
- package/src/web/.DS_Store +0 -0
- package/src/web/actions/showModal/{index.jsx → index.tsx} +53 -3
- package/src/web/components/auth/index.js +2 -2
- package/src/web/components/button/index.css +9 -0
- package/src/web/components/button/{index.jsx → index.tsx} +27 -41
- package/src/web/components/container/{index.jsx → index.tsx} +6 -10
- package/src/web/components/drawer/index.tsx +57 -0
- package/src/web/components/form/checkbox/{index.jsx → index.tsx} +24 -48
- package/src/web/components/form/enumSelect/MultipleSelect.jsx +1 -6
- package/src/web/components/form/enumSelect/{NormalSelect.jsx → NormalSelect.tsx} +3 -14
- package/src/web/components/form/form/index.tsx +48 -0
- package/src/web/components/form/formcell/{index.jsx → index.tsx} +6 -13
- package/src/web/components/form/input/index.css +39 -0
- package/src/web/components/form/input/{index.jsx → index.tsx} +33 -67
- package/src/web/components/form/radio/{index.jsx → index.tsx} +19 -42
- package/src/web/components/form/{renderDecorator.jsx → renderDecorator.tsx} +1 -3
- package/src/web/components/form/select/{h5.jsx → h5.tsx} +18 -62
- package/src/web/components/form/select/{index.jsx → index.tsx} +51 -94
- package/src/web/components/form/select/region/{cities.js → cities.ts} +1 -1
- package/src/web/components/form/select/region/{index.js → index.ts} +3 -3
- package/src/web/components/form/select/region/{provinces.js → provinces.ts} +1 -1
- package/src/web/components/form/select/region/{regions.js → regions.ts} +1 -1
- package/src/web/components/form/select/time.jsx +2 -2
- package/src/web/components/form/switch/{index.jsx → index.tsx} +30 -47
- package/src/web/components/form/textarea/{index.jsx → index.tsx} +22 -55
- package/src/web/components/form/tips/{index.jsx → index.tsx} +8 -22
- package/src/web/components/form/types.d.ts +12 -0
- package/src/web/components/form/uploader/{index.jsx → index.tsx} +16 -14
- package/src/web/components/form/uploader/{uploader.h5.jsx → uploader.h5.tsx} +67 -57
- package/src/web/components/form/uploader/{uploader.pc.jsx → uploader.pc.tsx} +26 -43
- package/src/web/components/form/uploaderFile/fail.svg +12 -0
- package/src/web/components/form/uploaderFile/index.css +423 -0
- package/src/web/components/form/uploaderFile/index.jsx +30 -0
- package/src/web/components/form/uploaderFile/pending.svg +18 -0
- package/src/web/components/form/uploaderFile/success.svg +12 -0
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +578 -0
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +507 -0
- package/src/web/components/image/{image.jsx → image.tsx} +8 -21
- package/src/web/components/image/{index.jsx → index.tsx} +22 -37
- package/src/web/components/index.js +36 -1
- package/src/web/components/link/{index.jsx → index.tsx} +19 -36
- package/src/web/components/modal/{index.jsx → index.tsx} +22 -9
- package/src/web/components/picker/{datePicker.jsx → datePicker.tsx} +11 -12
- package/src/web/components/picker/{picker.jsx → picker.tsx} +7 -10
- package/src/web/components/picker/{timePicker.jsx → timePicker.tsx} +8 -16
- package/src/web/components/richText/{const.js → const.ts} +0 -0
- package/src/web/components/richText/index.jsx +5 -2
- package/src/web/components/richTextView/index.tsx +67 -0
- package/src/web/components/scrollView/{index.jsx → index.tsx} +18 -33
- package/src/web/components/slot/{index.jsx → index.tsx} +8 -9
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/{index.jsx → index.tsx} +73 -78
- package/src/web/components/tabs/index.tsx +33 -0
- package/src/web/components/tabs/{tabs.h5.jsx → tabs.h5.tsx} +4 -33
- package/src/web/components/tabs/{tabs.pc.jsx → tabs.pc.tsx} +5 -39
- package/src/web/components/text/index.css +18 -0
- package/src/web/components/text/index.tsx +69 -0
- package/src/web/components/uploaderFileView/index.css +11 -0
- package/src/web/components/uploaderFileView/index.jsx +75 -0
- package/src/web/components/uploaderView/{index.jsx → index.tsx} +12 -15
- package/src/web/types.d.ts +20 -0
- package/src/web/utils/constant.js +2 -0
- package/src/web/utils/loading-fallback.tsx +2 -0
- package/src/web/utils/platform.js +77 -6
- package/src/web/utils/tcb.js +0 -8
- package/src/web/utils/useSetState.ts +14 -0
- package/src/web/utils/useSyncValue.ts +17 -0
- package/src/web/wedatheme/.git +1 -0
- package/src/web/wedatheme/.gitignore +5 -0
- package/src/web/wedatheme/.npmrc +1 -0
- package/src/web/wedatheme/package-lock.json +14335 -0
- package/src/configs/components/button.svg +0 -18
- package/src/web/components/drawer/index.jsx +0 -64
- package/src/web/components/form/enumSelect/hooks/index.js +0 -49
- package/src/web/components/form/form/index.jsx +0 -76
- package/src/web/components/link/test/__snapshots__/storybook.test.js.snap +0 -754
- package/src/web/components/richTextView/index.jsx +0 -89
- package/src/web/components/tabs/index.jsx +0 -10
- package/src/web/components/text/index.jsx +0 -71
- package/src/web/utils/useSyncValue.js +0 -14
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<view class="weda-uploader-files {{extClass}}">
|
|
2
|
+
<view class="weda-uploader-files__hd">
|
|
3
|
+
<view class="weda-uploader-files__title" wx:if="{{labelVisible}}">{{label}}</view>
|
|
4
|
+
<view>
|
|
5
|
+
<button class="weui-btn weda-uploader-files__btn" bindtap="uploadFile">上传文件</button>
|
|
6
|
+
<view wx:if="{{maxCount!=1}}" class="weda-uploader-files__tips">支持批量上传</view>
|
|
7
|
+
<view wx:else><slot name="tips"></slot></view>
|
|
8
|
+
</view>
|
|
9
|
+
</view>
|
|
10
|
+
<view class="weda-uploader-files__bd">
|
|
11
|
+
<view class="weda-uploader-files__files" wx-if="{{files.length > 0}}">
|
|
12
|
+
<block wx:for="{{files}}" wx:key="index">
|
|
13
|
+
<view class="weda-uploader-files__item">
|
|
14
|
+
<view class="weda-uploader-files__item-left">
|
|
15
|
+
<view class="weda-uploader-files__file-detail">
|
|
16
|
+
<text class="weda-uploader-files__file-name">{{item.name}}</text>
|
|
17
|
+
<view wx:if="{{item.status === 'success' || item.status === 'fail'}}" class="weda-uploader-files__file-status">
|
|
18
|
+
<mp-icon wx:if="{{item.status === 'success' }}" icon="done2" size="{{16}}" color="#00A870" type="field"></mp-icon>
|
|
19
|
+
<mp-icon wx:if="{{item.status === 'fail' }}" icon="close2" size="{{16}}" color="#E34D59" type="field"></mp-icon>
|
|
20
|
+
<text class="weda-uploader-files__file-status--msg">{{item.status === 'success' ? '上传成功' : '上传失败'}}</text>
|
|
21
|
+
</view>
|
|
22
|
+
</view>
|
|
23
|
+
<view class="weda-uploader-files__progress weui-progress" wx-if="{{item.status === 'pending' || item.status === 'uploading'}}">
|
|
24
|
+
<view class="weui-progress__bar">
|
|
25
|
+
<progress percent="{{item.percent}}" stroke-width="3" activeColor="#0052D9" backgroundColor="#E7E7E7" stroke-width="3"/>
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
<view class="weda-uploader-files__file-foot">
|
|
29
|
+
<div>
|
|
30
|
+
<text wx-if="{{item.status === 'uploading' || item.status === 'pending'}}">{{item.status === 'uploading' ? item.uploaded : '0K' }}/</text>
|
|
31
|
+
<text>{{item.size}}</text>
|
|
32
|
+
</div>
|
|
33
|
+
<div wx-if="{{item.status === 'uploading' || item.status === 'pending'}}">{{item.status === 'pending' ? '等待上传' : '上传中'}}</div>
|
|
34
|
+
|
|
35
|
+
</view>
|
|
36
|
+
</view>
|
|
37
|
+
<view class="weda-uploader-files__btn-group">
|
|
38
|
+
<image wx-if="{{item.status === 'success'&&downloadVisible}}" data-item="{{item}}" bindtap="downloadFile" class="weda-uploader-files__icon" src="https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/4cba5da1-cde4-40c6-a075-86eff22858a4.svg"></image>
|
|
39
|
+
<image wx-if="{{item.status === 'fail'}}" data-item="{{item}}" bindtap="reload" class="weda-uploader-files__icon" src="https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/af5486eb-65e0-4536-8e51-6c68a17b71ac.svg"></image>
|
|
40
|
+
<image class="weda-uploader-files__icon" data-item="{{item}}" bindtap="onDelete" src="https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/2372f6a8-2f6a-4f30-92bf-73c62a5c0ae7.svg"></image>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</block>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@import '../../../style/weda-ui.wxss';
|
|
2
|
+
.weda-uploader-files {
|
|
3
|
+
width: 100%;
|
|
4
|
+
background-color: #f6f6f6;
|
|
5
|
+
}
|
|
6
|
+
.weda-uploader-files__hd {
|
|
7
|
+
width: 100%;
|
|
8
|
+
padding: 24px 20px 8px 20px;
|
|
9
|
+
display: flex;
|
|
10
|
+
background-color: #ffffff;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weda-uploader-files__btn::after {
|
|
14
|
+
border: 1px solid #dcdcdc;
|
|
15
|
+
border-radius: 3px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
transform: none;
|
|
19
|
+
}
|
|
20
|
+
.weda-uploader-files__title {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
line-height: 20px;
|
|
23
|
+
color: #000;
|
|
24
|
+
margin-right: 20px;
|
|
25
|
+
padding-top: 6px;
|
|
26
|
+
}
|
|
27
|
+
.weda-uploader-files__btn {
|
|
28
|
+
margin: 0;
|
|
29
|
+
width: 88px;
|
|
30
|
+
height: 32px;
|
|
31
|
+
padding: 0;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
line-height: 22px;
|
|
37
|
+
color: #000;
|
|
38
|
+
border: 1px solid #dcdcdc;
|
|
39
|
+
border-radius: 3px;
|
|
40
|
+
font-weight: normal;
|
|
41
|
+
background-color: transparent;
|
|
42
|
+
}
|
|
43
|
+
.weda-uploader-files__tips {
|
|
44
|
+
margin-top: 8px;
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
line-height: 20px;
|
|
47
|
+
color: rgba(0, 0, 0, 0.4);
|
|
48
|
+
}
|
|
49
|
+
.weda-uploader-files__item {
|
|
50
|
+
width: 100%;
|
|
51
|
+
margin-top: 8px;
|
|
52
|
+
padding: 16px;
|
|
53
|
+
background-color: #fff;
|
|
54
|
+
display: flex;
|
|
55
|
+
justify-content: space-between;
|
|
56
|
+
align-items: center;
|
|
57
|
+
}
|
|
58
|
+
.weda-uploader-files__item-left {
|
|
59
|
+
flex: 1;
|
|
60
|
+
margin-right: 16px;
|
|
61
|
+
}
|
|
62
|
+
.weda-uploader-files__file-detail {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
}
|
|
66
|
+
.weda-uploader-files__file-name {
|
|
67
|
+
font-size: 14px;
|
|
68
|
+
line-height: 22px;
|
|
69
|
+
color: rgba(0, 0, 0, 0.9);
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
max-width: 200px;
|
|
74
|
+
}
|
|
75
|
+
.weda-uploader-files__file-status {
|
|
76
|
+
margin-left: 24px;
|
|
77
|
+
width: 28%;
|
|
78
|
+
}
|
|
79
|
+
.weda-uploader-files__file-status--msg {
|
|
80
|
+
margin-left: 4px;
|
|
81
|
+
font-size: 12px;
|
|
82
|
+
line-height: 20px;
|
|
83
|
+
color: rgba(0, 0, 0, 0.9);
|
|
84
|
+
}
|
|
85
|
+
.weda-uploader-files__file-foot {
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
line-height: 20px;
|
|
88
|
+
color: rgba(0, 0, 0, 0.4);
|
|
89
|
+
margin-top: 8px;
|
|
90
|
+
display: flex;
|
|
91
|
+
justify-content: space-between;
|
|
92
|
+
}
|
|
93
|
+
.weda-uploader-files__btn-group {
|
|
94
|
+
display: flex;
|
|
95
|
+
}
|
|
96
|
+
.weda-uploader-files__icon {
|
|
97
|
+
width: 24px;
|
|
98
|
+
height: 24px;
|
|
99
|
+
}
|
|
100
|
+
.weda-uploader-files__icon + .weda-uploader-files__icon {
|
|
101
|
+
margin-left: 16px;
|
|
102
|
+
}
|
|
103
|
+
.weda-uploader-files__progress {
|
|
104
|
+
margin-top: 4px;
|
|
105
|
+
}
|
|
@@ -7,6 +7,10 @@ Component({
|
|
|
7
7
|
type: String,
|
|
8
8
|
value: '',
|
|
9
9
|
},
|
|
10
|
+
level: {
|
|
11
|
+
type: String,
|
|
12
|
+
value: '0',
|
|
13
|
+
},
|
|
10
14
|
maxLines: {
|
|
11
15
|
type: Number,
|
|
12
16
|
value: 2,
|
|
@@ -23,10 +27,39 @@ Component({
|
|
|
23
27
|
type: String,
|
|
24
28
|
value: '',
|
|
25
29
|
},
|
|
30
|
+
textAlign: {
|
|
31
|
+
type: String,
|
|
32
|
+
value: '',
|
|
33
|
+
},
|
|
34
|
+
textColor: {
|
|
35
|
+
type: String,
|
|
36
|
+
value: '',
|
|
37
|
+
},
|
|
26
38
|
style: {
|
|
27
39
|
type: String,
|
|
28
40
|
value: '',
|
|
29
41
|
},
|
|
30
42
|
},
|
|
31
43
|
methods: {},
|
|
44
|
+
observers: {
|
|
45
|
+
level: function (level) {
|
|
46
|
+
const levelName = `level_${level}`;
|
|
47
|
+
if (level !== '0') {
|
|
48
|
+
this.setData({ levelName });
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
'textAlign,textColor': function (textAlign, textColor) {
|
|
52
|
+
let style = this.properties.style;
|
|
53
|
+
// 添加文本颜色属性
|
|
54
|
+
if (textColor !== '') {
|
|
55
|
+
style = `${style};color:${textColor}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 添加对齐属性
|
|
59
|
+
if (textAlign !== '') {
|
|
60
|
+
style = `${style};text-align: ${textAlign}`;
|
|
61
|
+
}
|
|
62
|
+
this.setData({ style });
|
|
63
|
+
},
|
|
64
|
+
},
|
|
32
65
|
});
|
|
@@ -6,3 +6,21 @@
|
|
|
6
6
|
/* -webkit-line-clamp: 1; */
|
|
7
7
|
/* white-space: pre-line; */
|
|
8
8
|
}
|
|
9
|
+
.weda-text.level_1 {
|
|
10
|
+
font-size: 64rpx !important;
|
|
11
|
+
}
|
|
12
|
+
.weda-text.level_2 {
|
|
13
|
+
font-size: 56rpx !important;
|
|
14
|
+
}
|
|
15
|
+
.weda-text.level_3 {
|
|
16
|
+
font-size: 48rpx !important;
|
|
17
|
+
}
|
|
18
|
+
.weda-text.level_4 {
|
|
19
|
+
font-size: 40rpx !important;
|
|
20
|
+
}
|
|
21
|
+
.weda-text.level_5 {
|
|
22
|
+
font-size: 32rpx !important;
|
|
23
|
+
}
|
|
24
|
+
.weda-text.level_6 {
|
|
25
|
+
font-size: 24rpx !important;
|
|
26
|
+
}
|
package/src/mp/index.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"Textarea": "components/form/textarea/index",
|
|
13
13
|
"Select": "components/form/select/index",
|
|
14
14
|
"Uploader": "components/form/uploader/index",
|
|
15
|
+
"UploaderFile": "components/form/uploaderFile/index",
|
|
15
16
|
"Container": "components/container/index",
|
|
16
17
|
"Slot": {
|
|
17
18
|
"type": "native",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件字节转换
|
|
3
|
+
*/
|
|
4
|
+
export const transSize = (size) => {
|
|
5
|
+
const b = parseInt(size) || 0;
|
|
6
|
+
const getBig = (d) => Math.ceil(d / 1024) || 0;
|
|
7
|
+
if (b < 1024) {
|
|
8
|
+
return `${size}B`;
|
|
9
|
+
}
|
|
10
|
+
const k = getBig(size);
|
|
11
|
+
if (k < 1024) {
|
|
12
|
+
return `${k}K`;
|
|
13
|
+
}
|
|
14
|
+
const m = getBig(k);
|
|
15
|
+
if (m < 1024) {
|
|
16
|
+
return `${m}M`;
|
|
17
|
+
}
|
|
18
|
+
const g = getBig(m);
|
|
19
|
+
return `${g}G`;
|
|
20
|
+
};
|
package/src/mp/utils/tcb.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export async function getCloudInstance() {
|
|
2
2
|
return await getApp().app.cloud.getCloudInstance();
|
|
3
3
|
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取单个临时链接
|
|
7
|
+
* 单个cos文件,返回字符串
|
|
8
|
+
* 多个cos文件,返回 {fileID: src} 这样的对象
|
|
9
|
+
*/
|
|
10
|
+
export async function getTempFileURL(data) {
|
|
11
|
+
if (getApp().app.cloud.getTempFileURL) {
|
|
12
|
+
return await getApp().app.cloud.getTempFileURL(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
Binary file
|
|
@@ -1,6 +1,56 @@
|
|
|
1
|
+
import * as ReactDOM from 'react-dom';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import 'tea-component
|
|
3
|
+
import { forwardRef, useState, useEffect, useImperativeHandle } from 'react';
|
|
4
|
+
import { Modal, Button, Text, ModalProps, ConfigProvider } from 'tea-component';
|
|
5
|
+
import type { ModalShowHandle, ModalShowOptions } from 'tea-component/lib/modal/ModalShow';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
interface ModalShowInstance {
|
|
9
|
+
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ModalShow = forwardRef(function ModalShow(
|
|
13
|
+
props: ModalProps,
|
|
14
|
+
ref: React.Ref<ModalShowInstance>
|
|
15
|
+
) {
|
|
16
|
+
const [visible, setVisible] = useState(false);
|
|
17
|
+
|
|
18
|
+
// 渲染之后,马上显示
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setVisible(true);
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
// 实例 ref 到外部
|
|
24
|
+
useImperativeHandle(ref, () => ({ setVisible }));
|
|
25
|
+
|
|
26
|
+
return <Modal {...props} visible={visible} />;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
function show(options: ModalShowOptions): ModalShowHandle {
|
|
31
|
+
const el = document.createElement("div");
|
|
32
|
+
|
|
33
|
+
const instanceRef = React.createRef<ModalShowInstance>();
|
|
34
|
+
|
|
35
|
+
ReactDOM.render(
|
|
36
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
37
|
+
<ModalShow
|
|
38
|
+
{...options}
|
|
39
|
+
ref={instanceRef}
|
|
40
|
+
onExited={() => ReactDOM.unmountComponentAtNode(el)}
|
|
41
|
+
/>
|
|
42
|
+
</ConfigProvider>,
|
|
43
|
+
el
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
destroy: () => {
|
|
48
|
+
if (instanceRef.current) {
|
|
49
|
+
instanceRef.current.setVisible(false);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
4
54
|
|
|
5
55
|
export default async function showModal({ data }) {
|
|
6
56
|
const {
|
|
@@ -19,7 +69,7 @@ export default async function showModal({ data }) {
|
|
|
19
69
|
return new Promise((resolve) => {
|
|
20
70
|
const base = { cancel: false, confirm: false, content: null };
|
|
21
71
|
|
|
22
|
-
const modal =
|
|
72
|
+
const modal = show({
|
|
23
73
|
caption: title,
|
|
24
74
|
children: (
|
|
25
75
|
<>
|
|
@@ -17,7 +17,7 @@ export default function Auth({ className }) {
|
|
|
17
17
|
[className]: className,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const [authState, setAuthState] = React.useState(AUTHSTATE.
|
|
20
|
+
const [authState, setAuthState] = React.useState(AUTHSTATE.SIGNIN);
|
|
21
21
|
const [user, setUser] = React.useState({});
|
|
22
22
|
const [tcb, setTcb] = React.useState(undefined);
|
|
23
23
|
|
|
@@ -42,7 +42,7 @@ export default function Auth({ className }) {
|
|
|
42
42
|
// console.log('<<<<<<<wedaaaa', tcb);
|
|
43
43
|
|
|
44
44
|
return tcb ? (
|
|
45
|
-
authState === AUTHSTATE.
|
|
45
|
+
authState === AUTHSTATE.SIGNEDIN && user ? (
|
|
46
46
|
<div className={cls}>
|
|
47
47
|
<header className="tcb-header">
|
|
48
48
|
{/* Hello, {user.uid} */}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { Button as TeaButton, ConfigProvider } from 'tea-component';
|
|
2
|
+
import { Button as TeaButton, ButtonProps, ConfigProvider } from 'tea-component';
|
|
4
3
|
import classNames from '../../utils/classnames';
|
|
4
|
+
import { usePlatform } from '../../utils/platform';
|
|
5
|
+
import { CommonPropsType, unknownFunction } from '../../types';
|
|
5
6
|
|
|
6
7
|
import './index.css';
|
|
7
8
|
|
|
8
|
-
import { usePlatform } from '../../utils/platform';
|
|
9
|
-
|
|
10
9
|
// 不用 react-weui 而直接用底层实现的原因是 react-weui 不能支持表单类型
|
|
11
|
-
|
|
10
|
+
const Button = ({
|
|
12
11
|
text = '按钮',
|
|
13
12
|
size = 'default',
|
|
14
13
|
type = 'primary',
|
|
@@ -16,16 +15,17 @@ export default function Button({
|
|
|
16
15
|
formType,
|
|
17
16
|
loading = false,
|
|
18
17
|
disabled = false,
|
|
19
|
-
events = {},
|
|
18
|
+
events = ({} as Record<string, unknownFunction>),
|
|
20
19
|
className,
|
|
21
20
|
style,
|
|
22
21
|
id,
|
|
23
|
-
}) {
|
|
24
|
-
const platform = usePlatform();
|
|
25
|
-
const isH5 = platform === 'h5';
|
|
22
|
+
}: PropsType) => {
|
|
23
|
+
const platform: string = usePlatform();
|
|
24
|
+
const isH5: boolean = platform === 'h5';
|
|
26
25
|
const cls = classNames({
|
|
27
26
|
'weda-ui': true,
|
|
28
27
|
'weda-button': true,
|
|
28
|
+
'weda-button-large': size === 'large',
|
|
29
29
|
'weda-button-mini': size === 'mini',
|
|
30
30
|
'weui-btn': isH5,
|
|
31
31
|
'weui-btn_mini': isH5 && size === 'mini',
|
|
@@ -57,8 +57,6 @@ export default function Button({
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
let teaType = type;
|
|
61
|
-
if(teaType === 'warn') teaType = 'error';
|
|
62
60
|
return (
|
|
63
61
|
<ConfigProvider classPrefix="wedatea2td">
|
|
64
62
|
<TeaButton
|
|
@@ -66,7 +64,7 @@ return (
|
|
|
66
64
|
onClick={onClick}
|
|
67
65
|
disabled={disabled}
|
|
68
66
|
htmlType={formType}
|
|
69
|
-
type={
|
|
67
|
+
type={toTeaButtonType(type)}
|
|
70
68
|
style={style}
|
|
71
69
|
className={cls}
|
|
72
70
|
id={id}
|
|
@@ -77,52 +75,40 @@ return (
|
|
|
77
75
|
);
|
|
78
76
|
}
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
function toTeaButtonType(type: PropsType['type'] ): ButtonProps['type'] {
|
|
79
|
+
if(type === 'primary') return type;
|
|
80
|
+
if(type === 'warn') return 'error';
|
|
81
|
+
if(type === 'default') return 'primary';
|
|
82
|
+
return 'primary';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface PropsType extends CommonPropsType {
|
|
81
86
|
/**
|
|
82
87
|
* 内容
|
|
83
88
|
*/
|
|
84
|
-
text
|
|
85
|
-
|
|
89
|
+
text?: string;
|
|
86
90
|
/**
|
|
87
91
|
* 样式类型
|
|
88
92
|
*/
|
|
89
|
-
type
|
|
90
|
-
|
|
93
|
+
type?: "primary" | "warn" | "default";
|
|
91
94
|
/**
|
|
92
95
|
* 大小
|
|
93
96
|
*/
|
|
94
|
-
size
|
|
95
|
-
|
|
97
|
+
size?: "default" | "mini" | "large";
|
|
96
98
|
/**
|
|
97
99
|
* 是否禁用
|
|
98
100
|
*/
|
|
99
|
-
disabled
|
|
100
|
-
|
|
101
|
+
disabled?: boolean;
|
|
101
102
|
/**
|
|
102
103
|
* 加载中
|
|
103
104
|
*/
|
|
104
|
-
loading
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 组件事件
|
|
108
|
-
*/
|
|
109
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
105
|
+
loading?: boolean;
|
|
110
106
|
|
|
111
107
|
/**
|
|
112
108
|
* 用于 form 类型
|
|
113
109
|
*/
|
|
114
|
-
formType
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
contentSlot: PropTypes.string,
|
|
118
|
-
style: PropTypes.object,
|
|
119
|
-
id: PropTypes.string,
|
|
120
|
-
};
|
|
110
|
+
formType?: "button" | "submit" | "reset";
|
|
111
|
+
contentSlot?: string;
|
|
112
|
+
}
|
|
121
113
|
|
|
122
|
-
|
|
123
|
-
* 默认属性
|
|
124
|
-
*/
|
|
125
|
-
Button.defaultProps = {
|
|
126
|
-
type: 'primary',
|
|
127
|
-
size: 'default',
|
|
128
|
-
};
|
|
114
|
+
export default Button;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { CommonPropsType } from '../../types';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
|
|
5
5
|
export default function Container({
|
|
@@ -9,7 +9,7 @@ export default function Container({
|
|
|
9
9
|
className,
|
|
10
10
|
style,
|
|
11
11
|
id
|
|
12
|
-
}) {
|
|
12
|
+
}: PropsType) {
|
|
13
13
|
return (
|
|
14
14
|
<div
|
|
15
15
|
role="container"
|
|
@@ -29,11 +29,7 @@ export default function Container({
|
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
events: PropTypes.objectOf(PropTypes.func),
|
|
37
|
-
id: PropTypes.string,
|
|
38
|
-
style: PropTypes.object
|
|
39
|
-
};
|
|
32
|
+
export interface PropsType extends CommonPropsType {
|
|
33
|
+
title?: string;
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConfigProvider, Drawer, DrawerProps } from 'tea-component';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const TeaDrawer = ({
|
|
6
|
+
size,
|
|
7
|
+
title,
|
|
8
|
+
style,
|
|
9
|
+
events,
|
|
10
|
+
visible,
|
|
11
|
+
subtitle,
|
|
12
|
+
showMask,
|
|
13
|
+
className,
|
|
14
|
+
placement,
|
|
15
|
+
extraSlot,
|
|
16
|
+
footerSlot,
|
|
17
|
+
childrenSlot,
|
|
18
|
+
disableCloseIcon,
|
|
19
|
+
outerClickClosable,
|
|
20
|
+
}: PropsType) => {
|
|
21
|
+
const eventsList = {
|
|
22
|
+
onClose: () => events?.onClose && events.onClose({}),
|
|
23
|
+
onExited: () => events?.onExited && events.onExited({}),
|
|
24
|
+
};
|
|
25
|
+
return (
|
|
26
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
27
|
+
<Drawer
|
|
28
|
+
size={size}
|
|
29
|
+
title={title}
|
|
30
|
+
style={style}
|
|
31
|
+
visible={visible}
|
|
32
|
+
extra={extraSlot}
|
|
33
|
+
footer={footerSlot}
|
|
34
|
+
subtitle={subtitle}
|
|
35
|
+
showMask={showMask}
|
|
36
|
+
className={className}
|
|
37
|
+
placement={placement}
|
|
38
|
+
disableCloseIcon={disableCloseIcon}
|
|
39
|
+
outerClickClosable={outerClickClosable}
|
|
40
|
+
{...eventsList}
|
|
41
|
+
>
|
|
42
|
+
{childrenSlot}
|
|
43
|
+
</Drawer>
|
|
44
|
+
</ConfigProvider>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface PropsType extends CommonPropsType, Pick<DrawerProps, 'size'|'title'|'showMask'|'placement'|'disableCloseIcon'|'outerClickClosable'|'subtitle'> {
|
|
49
|
+
visible: boolean;
|
|
50
|
+
title?: string;
|
|
51
|
+
extraSlot?: React.ReactNode;
|
|
52
|
+
footerSlot?: React.ReactNode;
|
|
53
|
+
childrenSlot?: React.ReactNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default TeaDrawer;
|
|
57
|
+
export { TeaDrawer };
|