@tuya-miniapp/smart-ui 1.3.0-beta-2 → 1.3.1-beta-1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/action-sheet/index.js +3 -7
- package/dist/battery/index.js +3 -5
- package/dist/bottom-sheet/index.css +1 -0
- package/dist/bottom-sheet/index.d.ts +1 -0
- package/dist/bottom-sheet/index.js +70 -0
- package/dist/bottom-sheet/index.json +8 -0
- package/dist/bottom-sheet/index.wxml +26 -0
- package/dist/bottom-sheet/index.wxss +1 -0
- package/dist/button/index.js +1 -0
- package/dist/button/index.wxml +1 -1
- package/dist/calendar/calendar.wxml +53 -53
- package/dist/calendar/components/header/index.css +1 -1
- package/dist/calendar/components/header/index.js +18 -0
- package/dist/calendar/components/header/index.json +4 -1
- package/dist/calendar/components/header/index.wxml +15 -4
- package/dist/calendar/components/header/index.wxss +1 -1
- package/dist/calendar/components/month/index.css +1 -1
- package/dist/calendar/components/month/index.d.ts +0 -1
- package/dist/calendar/components/month/index.js +4 -7
- package/dist/calendar/components/month/index.wxml +0 -13
- package/dist/calendar/components/month/index.wxs +13 -7
- package/dist/calendar/components/month/index.wxss +1 -1
- package/dist/calendar/components/month-list/index.css +1 -0
- package/dist/calendar/components/month-list/index.d.ts +1 -0
- package/dist/calendar/components/month-list/index.js +112 -0
- package/dist/calendar/components/month-list/index.json +7 -0
- package/dist/calendar/components/month-list/index.wxml +9 -0
- package/dist/calendar/components/month-list/index.wxss +1 -0
- package/dist/calendar/components/year-list/index.css +1 -0
- package/dist/calendar/components/year-list/index.d.ts +1 -0
- package/dist/calendar/components/year-list/index.js +100 -0
- package/dist/calendar/components/year-list/index.json +7 -0
- package/dist/calendar/components/year-list/index.wxml +9 -0
- package/dist/calendar/components/year-list/index.wxss +1 -0
- package/dist/calendar/index.css +1 -1
- package/dist/calendar/index.js +100 -51
- package/dist/calendar/index.json +3 -1
- package/dist/calendar/index.wxml +1 -1
- package/dist/calendar/index.wxs +21 -3
- package/dist/calendar/index.wxss +1 -1
- package/dist/calendar/utils.d.ts +7 -2
- package/dist/calendar/utils.js +44 -8
- package/dist/checkbox/index.css +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/checkbox/index.wxml +2 -2
- package/dist/checkbox/index.wxss +1 -1
- package/dist/config-provider/index.wxs +2 -7
- package/dist/dropdown-item/index.css +1 -1
- package/dist/dropdown-item/index.js +10 -0
- package/dist/dropdown-item/index.wxml +9 -4
- package/dist/dropdown-item/index.wxss +1 -1
- package/dist/dropdown-menu/index.css +1 -1
- package/dist/dropdown-menu/index.js +15 -0
- package/dist/dropdown-menu/index.json +4 -1
- package/dist/dropdown-menu/index.wxml +2 -1
- package/dist/dropdown-menu/index.wxss +1 -1
- package/dist/empty/index.css +1 -1
- package/dist/empty/index.js +20 -1
- package/dist/empty/index.wxml +7 -7
- package/dist/empty/index.wxs +3 -16
- package/dist/empty/index.wxss +1 -1
- package/dist/field/index.css +1 -1
- package/dist/field/index.wxss +1 -1
- package/dist/loading/index.css +1 -1
- package/dist/loading/index.js +4 -4
- package/dist/loading/index.wxml +4 -6
- package/dist/loading/index.wxs +39 -8
- package/dist/loading/index.wxss +1 -1
- package/dist/nav-bar/index.css +1 -1
- package/dist/nav-bar/index.js +19 -1
- package/dist/nav-bar/index.wxml +16 -6
- package/dist/nav-bar/index.wxss +1 -1
- package/dist/normal-slider/index.css +1 -1
- package/dist/normal-slider/index.wxss +1 -1
- package/dist/notice-bar/index.css +1 -1
- package/dist/notice-bar/index.js +55 -2
- package/dist/notice-bar/index.wxml +28 -10
- package/dist/notice-bar/index.wxs +1 -5
- package/dist/notice-bar/index.wxss +1 -1
- package/dist/picker-column/index.js +8 -1
- package/dist/radio/index.css +1 -1
- package/dist/radio/index.js +1 -1
- package/dist/radio/index.wxml +2 -1
- package/dist/radio/index.wxss +1 -1
- package/dist/search/index.css +1 -1
- package/dist/search/index.js +14 -9
- package/dist/search/index.json +2 -1
- package/dist/search/index.wxml +7 -4
- package/dist/search/index.wxss +1 -1
- package/dist/switch/index.css +1 -1
- package/dist/switch/index.wxml +1 -0
- package/dist/switch/index.wxss +1 -1
- package/dist/tabs/index.css +1 -1
- package/dist/tabs/index.js +10 -7
- package/dist/tabs/index.wxml +1 -0
- package/dist/tabs/index.wxs +17 -0
- package/dist/tabs/index.wxss +1 -1
- package/dist/tag/index.css +1 -1
- package/dist/tag/index.wxss +1 -1
- package/dist/toast/icons.d.ts +3 -0
- package/dist/toast/icons.js +6 -0
- package/dist/toast/index.js +8 -4
- package/dist/toast/index.wxml +3 -7
- package/dist/toast/toast.d.ts +2 -0
- package/dist/toast/toast.js +2 -0
- package/dist/wxs/style.wxs +11 -5
- package/dist/wxs/utils.wxs +1 -3
- package/lib/action-sheet/index.js +3 -7
- package/lib/battery/index.js +3 -5
- package/lib/bottom-sheet/index.css +1 -0
- package/lib/bottom-sheet/index.d.ts +1 -0
- package/lib/bottom-sheet/index.js +75 -0
- package/lib/bottom-sheet/index.json +8 -0
- package/lib/bottom-sheet/index.wxml +26 -0
- package/lib/bottom-sheet/index.wxss +1 -0
- package/lib/button/index.js +1 -0
- package/lib/button/index.wxml +1 -1
- package/lib/calendar/calendar.wxml +53 -53
- package/lib/calendar/components/header/index.css +1 -1
- package/lib/calendar/components/header/index.js +21 -0
- package/lib/calendar/components/header/index.json +4 -1
- package/lib/calendar/components/header/index.wxml +15 -4
- package/lib/calendar/components/header/index.wxss +1 -1
- package/lib/calendar/components/month/index.css +1 -1
- package/lib/calendar/components/month/index.d.ts +0 -1
- package/lib/calendar/components/month/index.js +3 -6
- package/lib/calendar/components/month/index.wxml +0 -13
- package/lib/calendar/components/month/index.wxs +13 -7
- package/lib/calendar/components/month/index.wxss +1 -1
- package/lib/calendar/components/month-list/index.css +1 -0
- package/lib/calendar/components/month-list/index.d.ts +1 -0
- package/lib/calendar/components/month-list/index.js +114 -0
- package/lib/calendar/components/month-list/index.json +7 -0
- package/lib/calendar/components/month-list/index.wxml +9 -0
- package/lib/calendar/components/month-list/index.wxss +1 -0
- package/lib/calendar/components/year-list/index.css +1 -0
- package/lib/calendar/components/year-list/index.d.ts +1 -0
- package/lib/calendar/components/year-list/index.js +102 -0
- package/lib/calendar/components/year-list/index.json +7 -0
- package/lib/calendar/components/year-list/index.wxml +9 -0
- package/lib/calendar/components/year-list/index.wxss +1 -0
- package/lib/calendar/index.css +1 -1
- package/lib/calendar/index.js +99 -52
- package/lib/calendar/index.json +3 -1
- package/lib/calendar/index.wxml +1 -1
- package/lib/calendar/index.wxs +21 -3
- package/lib/calendar/index.wxss +1 -1
- package/lib/calendar/utils.d.ts +7 -2
- package/lib/calendar/utils.js +48 -10
- package/lib/checkbox/index.css +1 -1
- package/lib/checkbox/index.js +1 -1
- package/lib/checkbox/index.wxml +2 -2
- package/lib/checkbox/index.wxss +1 -1
- package/lib/config-provider/index.wxs +2 -7
- package/lib/dropdown-item/index.css +1 -1
- package/lib/dropdown-item/index.js +13 -0
- package/lib/dropdown-item/index.wxml +9 -4
- package/lib/dropdown-item/index.wxss +1 -1
- package/lib/dropdown-menu/index.css +1 -1
- package/lib/dropdown-menu/index.js +18 -0
- package/lib/dropdown-menu/index.json +4 -1
- package/lib/dropdown-menu/index.wxml +2 -1
- package/lib/dropdown-menu/index.wxss +1 -1
- package/lib/empty/index.css +1 -1
- package/lib/empty/index.js +20 -1
- package/lib/empty/index.wxml +7 -7
- package/lib/empty/index.wxs +3 -16
- package/lib/empty/index.wxss +1 -1
- package/lib/field/index.css +1 -1
- package/lib/field/index.wxss +1 -1
- package/lib/loading/index.css +1 -1
- package/lib/loading/index.js +4 -4
- package/lib/loading/index.wxml +4 -6
- package/lib/loading/index.wxs +39 -8
- package/lib/loading/index.wxss +1 -1
- package/lib/nav-bar/index.css +1 -1
- package/lib/nav-bar/index.js +19 -1
- package/lib/nav-bar/index.wxml +16 -6
- package/lib/nav-bar/index.wxss +1 -1
- package/lib/normal-slider/index.css +1 -1
- package/lib/normal-slider/index.wxss +1 -1
- package/lib/notice-bar/index.css +1 -1
- package/lib/notice-bar/index.js +58 -2
- package/lib/notice-bar/index.wxml +28 -10
- package/lib/notice-bar/index.wxs +1 -5
- package/lib/notice-bar/index.wxss +1 -1
- package/lib/picker-column/index.js +8 -1
- package/lib/radio/index.css +1 -1
- package/lib/radio/index.js +1 -1
- package/lib/radio/index.wxml +2 -1
- package/lib/radio/index.wxss +1 -1
- package/lib/search/index.css +1 -1
- package/lib/search/index.js +17 -9
- package/lib/search/index.json +2 -1
- package/lib/search/index.wxml +7 -4
- package/lib/search/index.wxss +1 -1
- package/lib/switch/index.css +1 -1
- package/lib/switch/index.wxml +1 -0
- package/lib/switch/index.wxss +1 -1
- package/lib/tabs/index.css +1 -1
- package/lib/tabs/index.js +10 -7
- package/lib/tabs/index.wxml +1 -0
- package/lib/tabs/index.wxs +17 -0
- package/lib/tabs/index.wxss +1 -1
- package/lib/tag/index.css +1 -1
- package/lib/tag/index.wxss +1 -1
- package/lib/toast/icons.d.ts +3 -0
- package/lib/toast/icons.js +12 -0
- package/lib/toast/index.js +8 -7
- package/lib/toast/index.wxml +3 -7
- package/lib/toast/toast.d.ts +2 -0
- package/lib/toast/toast.js +2 -0
- package/lib/wxs/style.wxs +11 -5
- package/lib/wxs/utils.wxs +1 -3
- package/package.json +4 -8
- package/dist/common/theme/dark.d.ts +0 -344
- package/dist/common/theme/dark.js +0 -343
- package/dist/common/theme/light.d.ts +0 -344
- package/dist/common/theme/light.js +0 -343
- package/dist/wxs/is-app-theme-var.wxs +0 -8
- package/lib/common/theme/dark.d.ts +0 -344
- package/lib/common/theme/dark.js +0 -345
- package/lib/common/theme/light.d.ts +0 -344
- package/lib/common/theme/light.js +0 -345
- package/lib/wxs/is-app-theme-var.wxs +0 -8
@@ -0,0 +1,112 @@
|
|
1
|
+
// components/month-list.js
|
2
|
+
import { getMonths } from '../../utils';
|
3
|
+
import { SmartComponent } from '../../../common/component';
|
4
|
+
SmartComponent({
|
5
|
+
/**
|
6
|
+
* 组件的属性列表
|
7
|
+
*/
|
8
|
+
props: {
|
9
|
+
date: {
|
10
|
+
type: null,
|
11
|
+
observer(newVal, oldVal) {
|
12
|
+
if (newVal !== oldVal) {
|
13
|
+
this.calcMonth();
|
14
|
+
}
|
15
|
+
},
|
16
|
+
},
|
17
|
+
minDate: {
|
18
|
+
type: null,
|
19
|
+
value: new Date(new Date().getFullYear(), 0, 1).getTime(),
|
20
|
+
},
|
21
|
+
maxDate: {
|
22
|
+
type: null,
|
23
|
+
value: new Date(new Date().getFullYear(), 11, 31).getTime(),
|
24
|
+
},
|
25
|
+
currentYear: {
|
26
|
+
type: null,
|
27
|
+
value: new Date().getFullYear(),
|
28
|
+
},
|
29
|
+
visibleIndex: {
|
30
|
+
type: Number,
|
31
|
+
value: 0,
|
32
|
+
observer(newVal, oldVal) {
|
33
|
+
if (newVal !== oldVal) {
|
34
|
+
this.getMonthList();
|
35
|
+
}
|
36
|
+
},
|
37
|
+
},
|
38
|
+
monthsFormatter: {
|
39
|
+
type: null,
|
40
|
+
value: [
|
41
|
+
'Jan',
|
42
|
+
'Feb',
|
43
|
+
'Mar',
|
44
|
+
'Apr',
|
45
|
+
'May',
|
46
|
+
'Jun',
|
47
|
+
'Jul',
|
48
|
+
'Aug',
|
49
|
+
'Sept',
|
50
|
+
'Oct',
|
51
|
+
'Nov',
|
52
|
+
'Dec',
|
53
|
+
],
|
54
|
+
},
|
55
|
+
},
|
56
|
+
/**
|
57
|
+
* 组件的初始数据
|
58
|
+
*/
|
59
|
+
data: {
|
60
|
+
months: [],
|
61
|
+
currentMonth: null,
|
62
|
+
},
|
63
|
+
created() {
|
64
|
+
this.getMonthList();
|
65
|
+
this.calcMonth();
|
66
|
+
},
|
67
|
+
/**
|
68
|
+
* 组件的方法列表
|
69
|
+
*/
|
70
|
+
methods: {
|
71
|
+
calcMonth() {
|
72
|
+
const date = new Date(this.data.date);
|
73
|
+
const cur = date.getMonth();
|
74
|
+
this.setData({
|
75
|
+
currentMonth: cur,
|
76
|
+
});
|
77
|
+
},
|
78
|
+
getMonthList() {
|
79
|
+
const { minDate, maxDate, visibleIndex, monthsFormatter = [], } = this.data;
|
80
|
+
const cur = new Date().getFullYear() + visibleIndex;
|
81
|
+
const start = new Date(cur, 0, 1).getTime();
|
82
|
+
const end = new Date(cur, 11, 31).getTime();
|
83
|
+
const minDateTime = new Date(minDate).getTime();
|
84
|
+
const maxDateTime = new Date(maxDate).getTime();
|
85
|
+
const months = getMonths(start, end);
|
86
|
+
const monthlist = months.map((date) => {
|
87
|
+
const monthVal = new Date(date).getMonth();
|
88
|
+
const time = new Date(date).getTime();
|
89
|
+
const isDisabled = time < minDateTime || time > maxDateTime;
|
90
|
+
return {
|
91
|
+
value: date,
|
92
|
+
month: monthVal,
|
93
|
+
text: monthsFormatter[monthVal] || monthVal + 1,
|
94
|
+
type: isDisabled ? 'disabled' : '',
|
95
|
+
};
|
96
|
+
});
|
97
|
+
this.setData({
|
98
|
+
months: monthlist,
|
99
|
+
});
|
100
|
+
},
|
101
|
+
onClick(event) {
|
102
|
+
const { index } = event.currentTarget.dataset;
|
103
|
+
const item = this.data.months[index];
|
104
|
+
if (item.type !== 'disabled') {
|
105
|
+
this.$emit('click', item.value);
|
106
|
+
this.setData({
|
107
|
+
date: item.value,
|
108
|
+
});
|
109
|
+
}
|
110
|
+
},
|
111
|
+
},
|
112
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<view class="contain">
|
2
|
+
<smart-row>
|
3
|
+
<smart-col wx:for="{{months}}" span="6">
|
4
|
+
<view class="item {{ currentMonth === item.month ? 'item_active' : '' }} {{ item.type === 'disabled' ? 'item_disabled' : '' }}" data-index="{{index}}" bindtap="onClick">
|
5
|
+
{{item.text}}
|
6
|
+
</view>
|
7
|
+
</smart-col>
|
8
|
+
</smart-row>
|
9
|
+
</view>
|
@@ -0,0 +1 @@
|
|
1
|
+
@import '../../../common/index.wxss';.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
|
@@ -0,0 +1 @@
|
|
1
|
+
@import '../../../common/index.css';.contain{margin:24rpx 0}.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,100 @@
|
|
1
|
+
// components/month-list.js
|
2
|
+
import { getYears } from '../../utils';
|
3
|
+
import { SmartComponent } from '../../../common/component';
|
4
|
+
SmartComponent({
|
5
|
+
/**
|
6
|
+
* 组件的属性列表
|
7
|
+
*/
|
8
|
+
props: {
|
9
|
+
date: {
|
10
|
+
type: null,
|
11
|
+
observer(newVal, oldVal) {
|
12
|
+
if (newVal !== oldVal) {
|
13
|
+
this.calcYear();
|
14
|
+
}
|
15
|
+
},
|
16
|
+
},
|
17
|
+
minDate: {
|
18
|
+
type: null,
|
19
|
+
value: new Date(new Date().getFullYear() - 30, 0, 1).getTime(),
|
20
|
+
},
|
21
|
+
maxDate: {
|
22
|
+
type: null,
|
23
|
+
value: new Date(new Date().getFullYear() + 30, 11, 31).getTime(),
|
24
|
+
},
|
25
|
+
currentYear: {
|
26
|
+
type: null,
|
27
|
+
value: new Date().getFullYear(),
|
28
|
+
},
|
29
|
+
yearFormatter: {
|
30
|
+
type: null,
|
31
|
+
value: 'YYYY',
|
32
|
+
},
|
33
|
+
visibleIndex: {
|
34
|
+
type: Number,
|
35
|
+
value: 0,
|
36
|
+
observer(newVal, oldVal) {
|
37
|
+
if (newVal !== oldVal) {
|
38
|
+
this.getYearList();
|
39
|
+
}
|
40
|
+
},
|
41
|
+
},
|
42
|
+
},
|
43
|
+
/**
|
44
|
+
* 组件的初始数据
|
45
|
+
*/
|
46
|
+
data: {
|
47
|
+
years: [],
|
48
|
+
currentYear: null,
|
49
|
+
},
|
50
|
+
created() {
|
51
|
+
this.getYearList();
|
52
|
+
this.calcYear();
|
53
|
+
},
|
54
|
+
/**
|
55
|
+
* 组件的方法列表
|
56
|
+
*/
|
57
|
+
methods: {
|
58
|
+
calcYear() {
|
59
|
+
const date = new Date(this.data.date);
|
60
|
+
const cur = date.getFullYear();
|
61
|
+
this.setData({
|
62
|
+
currentYear: cur,
|
63
|
+
});
|
64
|
+
},
|
65
|
+
getYearList() {
|
66
|
+
const { minDate, maxDate, yearFormatter = 'YYYY', visibleIndex, date, } = this.data;
|
67
|
+
const cur = new Date(date).getFullYear();
|
68
|
+
const offset = visibleIndex * 12;
|
69
|
+
const start = new Date(cur + offset - 5, 0, 1).getTime();
|
70
|
+
const end = new Date(cur + offset + 6, 11, 31).getTime();
|
71
|
+
const minStart = new Date(minDate).getTime();
|
72
|
+
const maxStart = new Date(maxDate).getTime();
|
73
|
+
const years = getYears(start, end);
|
74
|
+
const yearlist = years.map((date) => {
|
75
|
+
const yearVal = new Date(date).getFullYear();
|
76
|
+
const curTime = new Date(date).getTime();
|
77
|
+
const disabled = curTime <= minStart || curTime >= maxStart;
|
78
|
+
return {
|
79
|
+
value: date,
|
80
|
+
year: yearVal,
|
81
|
+
text: yearFormatter.replace('YYYY', yearVal),
|
82
|
+
type: disabled ? 'disabled' : '',
|
83
|
+
};
|
84
|
+
});
|
85
|
+
this.setData({
|
86
|
+
years: yearlist,
|
87
|
+
});
|
88
|
+
},
|
89
|
+
onClick(event) {
|
90
|
+
const { index } = event.currentTarget.dataset;
|
91
|
+
const item = this.data.years[index];
|
92
|
+
if (item.type !== 'disabled') {
|
93
|
+
this.$emit('click', item.value);
|
94
|
+
this.setData({
|
95
|
+
date: item.value,
|
96
|
+
});
|
97
|
+
}
|
98
|
+
},
|
99
|
+
},
|
100
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<view class="contain">
|
2
|
+
<smart-row>
|
3
|
+
<smart-col wx:for="{{years}}" span="6">
|
4
|
+
<view class="item {{ currentYear === item.year ? 'item_active' : '' }} {{ item.type === 'disabled' ? 'item_disabled' : '' }}" data-index="{{index}}" bindtap="onClick">
|
5
|
+
{{item.text}}
|
6
|
+
</view>
|
7
|
+
</smart-col>
|
8
|
+
</smart-row>
|
9
|
+
</view>
|
@@ -0,0 +1 @@
|
|
1
|
+
@import '../../../common/index.wxss';.contain{margin:24rpx 0}.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
|
package/dist/calendar/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.css';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:
|
1
|
+
@import '../common/index.css';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:auto}.smart-calendar__close-icon{top:11px}.smart-calendar__popup--bottom,.smart-calendar__popup--top{height:848rpx}.smart-calendar__popup--left,.smart-calendar__popup--right{height:100%}.smart-calendar-month{margin-top:44rpx}.smart-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.smart-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.smart-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.smart-calendar__footer+.smart-calendar__footer,.smart-calendar__footer:empty{display:none}.smart-calendar__footer:empty+.smart-calendar__footer{display:block!important}
|
package/dist/calendar/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { SmartComponent } from '../common/component';
|
2
|
-
import { ROW_HEIGHT, getPrevDay, getNextDay, getToday, compareDay, copyDates, calcDateNum,
|
2
|
+
import { ROW_HEIGHT, getPrevDay, getNextDay, getToday, compareDay, copyDates, calcDateNum, getMonths, getDayByOffset, getCurrentIndex, getWeekStartAndEnd, } from './utils';
|
3
3
|
import Toast from '../toast/toast';
|
4
|
-
import { requestAnimationFrame } from '../common/utils';
|
5
4
|
const initialMinDate = getToday().getTime();
|
6
5
|
const initialMaxDate = (() => {
|
7
6
|
const now = getToday();
|
@@ -28,15 +27,26 @@ SmartComponent({
|
|
28
27
|
type: Object,
|
29
28
|
value: {
|
30
29
|
shortWeekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
30
|
+
monthsFormatter: [
|
31
|
+
'Jan',
|
32
|
+
'Feb',
|
33
|
+
'Mar',
|
34
|
+
'Apr',
|
35
|
+
'May',
|
36
|
+
'Jun',
|
37
|
+
'Jul',
|
38
|
+
'Aug',
|
39
|
+
'Sept',
|
40
|
+
'Oct',
|
41
|
+
'Nov',
|
42
|
+
'Dec',
|
43
|
+
],
|
44
|
+
yearFormatter: 'YYYY',
|
31
45
|
subFormatter: 'YYYY-MM',
|
32
46
|
rangeStart: 'Start',
|
33
47
|
rangeEnd: 'End',
|
34
48
|
},
|
35
49
|
},
|
36
|
-
dayClassMap: {
|
37
|
-
type: Object,
|
38
|
-
value: {},
|
39
|
-
},
|
40
50
|
formatter: null,
|
41
51
|
confirmText: {
|
42
52
|
type: String,
|
@@ -46,6 +56,10 @@ SmartComponent({
|
|
46
56
|
type: String,
|
47
57
|
value: '确定',
|
48
58
|
},
|
59
|
+
mode: {
|
60
|
+
type: String,
|
61
|
+
value: 'day',
|
62
|
+
},
|
49
63
|
rangePrompt: String,
|
50
64
|
showRangePrompt: {
|
51
65
|
type: Boolean,
|
@@ -136,6 +150,7 @@ SmartComponent({
|
|
136
150
|
currentDate: null,
|
137
151
|
scrollIntoView: '',
|
138
152
|
visibleIndex: 0,
|
153
|
+
months: [],
|
139
154
|
},
|
140
155
|
watch: {
|
141
156
|
minDate() {
|
@@ -146,9 +161,7 @@ SmartComponent({
|
|
146
161
|
},
|
147
162
|
},
|
148
163
|
created() {
|
149
|
-
this.
|
150
|
-
currentDate: this.getInitialDate(this.data.defaultDate),
|
151
|
-
});
|
164
|
+
this.initData();
|
152
165
|
},
|
153
166
|
mounted() {
|
154
167
|
this.isMounted = true;
|
@@ -158,31 +171,75 @@ SmartComponent({
|
|
158
171
|
}
|
159
172
|
},
|
160
173
|
methods: {
|
174
|
+
onPrev() {
|
175
|
+
const visibleIndex = this.data.visibleIndex - 1;
|
176
|
+
if (this.data.mode === 'year') {
|
177
|
+
this.setData({
|
178
|
+
visibleIndex,
|
179
|
+
});
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
if (this.data.mode === 'month') {
|
183
|
+
this.setData({
|
184
|
+
visibleIndex,
|
185
|
+
});
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
if (this.data.months[visibleIndex]) {
|
189
|
+
this.setData({
|
190
|
+
visibleIndex,
|
191
|
+
});
|
192
|
+
}
|
193
|
+
},
|
194
|
+
onNext() {
|
195
|
+
const visibleIndex = this.data.visibleIndex + 1;
|
196
|
+
if (this.data.mode === 'year') {
|
197
|
+
this.setData({
|
198
|
+
visibleIndex,
|
199
|
+
});
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (this.data.mode === 'month') {
|
203
|
+
this.setData({
|
204
|
+
visibleIndex,
|
205
|
+
});
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
if (this.data.months[visibleIndex]) {
|
209
|
+
this.setData({
|
210
|
+
visibleIndex,
|
211
|
+
});
|
212
|
+
}
|
213
|
+
},
|
161
214
|
reset() {
|
162
215
|
this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) });
|
163
216
|
this.scrollIntoView();
|
164
217
|
},
|
218
|
+
initYearIdx(currentDate) {
|
219
|
+
},
|
220
|
+
initData() {
|
221
|
+
const currentDate = this.getInitialDate(this.data.defaultDate);
|
222
|
+
const months = getMonths(this.data.minDate, this.data.maxDate);
|
223
|
+
const visibleIndex = this.data.defaultDate
|
224
|
+
? getCurrentIndex(currentDate, months)
|
225
|
+
: months.length - 1;
|
226
|
+
const isYear = this.data.mode === 'year';
|
227
|
+
const isMonth = this.data.mode === 'month';
|
228
|
+
const data = {
|
229
|
+
currentDate,
|
230
|
+
months,
|
231
|
+
visibleIndex: visibleIndex,
|
232
|
+
};
|
233
|
+
if (isYear || isMonth) {
|
234
|
+
// @ts-ignore
|
235
|
+
delete data.visibleIndex;
|
236
|
+
}
|
237
|
+
this.setData(data);
|
238
|
+
},
|
165
239
|
initRect() {
|
166
240
|
if (!this.isMounted)
|
167
241
|
return;
|
168
|
-
|
169
|
-
this.contentObserver.disconnect();
|
170
|
-
}
|
171
|
-
const contentObserver = this.createIntersectionObserver({
|
172
|
-
thresholds: [0, 0.1, 0.9, 1],
|
173
|
-
observeAll: true,
|
174
|
-
});
|
175
|
-
this.contentObserver = contentObserver;
|
176
|
-
contentObserver.relativeTo('.smart-calendar__body');
|
177
|
-
contentObserver.observe('.month', (res) => {
|
178
|
-
if (res.boundingClientRect.top <= res.relativeRect.top) {
|
179
|
-
// @ts-ignore
|
180
|
-
this.setData({
|
181
|
-
subtitle: formatMonthTitle(res.dataset.date, this.properties.locale.subFormatter),
|
182
|
-
visibleIndex: res.dataset.index,
|
183
|
-
});
|
184
|
-
}
|
185
|
-
});
|
242
|
+
this.initData();
|
186
243
|
},
|
187
244
|
limitDateRange(date, minDate = null, maxDate = null) {
|
188
245
|
minDate = minDate || this.data.minDate;
|
@@ -200,7 +257,7 @@ SmartComponent({
|
|
200
257
|
if (!defaultDate)
|
201
258
|
return [];
|
202
259
|
const now = getToday().getTime();
|
203
|
-
if (type === 'range') {
|
260
|
+
if (type === 'range' || type === 'week') {
|
204
261
|
if (!Array.isArray(defaultDate)) {
|
205
262
|
defaultDate = [];
|
206
263
|
}
|
@@ -225,28 +282,6 @@ SmartComponent({
|
|
225
282
|
scrollIntoView() {
|
226
283
|
if (!this.isMounted)
|
227
284
|
return;
|
228
|
-
requestAnimationFrame(() => {
|
229
|
-
const { currentDate, type, show, poppable, minDate, maxDate } = this.data;
|
230
|
-
if (!currentDate)
|
231
|
-
return;
|
232
|
-
// @ts-ignore
|
233
|
-
const targetDate = type === 'single' ? currentDate : currentDate[0];
|
234
|
-
const displayed = show || !poppable;
|
235
|
-
if (!targetDate || !displayed) {
|
236
|
-
return;
|
237
|
-
}
|
238
|
-
const months = getMonths(minDate, maxDate);
|
239
|
-
months.some((month, index) => {
|
240
|
-
if (compareMonth(month, targetDate) === 0) {
|
241
|
-
this.setData({
|
242
|
-
scrollIntoView: `month${index}`,
|
243
|
-
visibleIndex: index,
|
244
|
-
});
|
245
|
-
return true;
|
246
|
-
}
|
247
|
-
return false;
|
248
|
-
});
|
249
|
-
});
|
250
285
|
},
|
251
286
|
onOpen() {
|
252
287
|
this.$emit('open');
|
@@ -266,7 +301,14 @@ SmartComponent({
|
|
266
301
|
}
|
267
302
|
let { date } = event.detail;
|
268
303
|
const { type, currentDate, allowSameDay } = this.data;
|
269
|
-
if (type === '
|
304
|
+
if (type === 'week') {
|
305
|
+
const { weekStart, weekEnd } = getWeekStartAndEnd(date);
|
306
|
+
this.select([
|
307
|
+
Math.max(getTime(weekStart), getTime(this.data.minDate)),
|
308
|
+
Math.min(getTime(weekEnd), getTime(this.data.maxDate)),
|
309
|
+
], true);
|
310
|
+
}
|
311
|
+
else if (type === 'range') {
|
270
312
|
// @ts-ignore
|
271
313
|
const [startDay, endDay] = currentDate;
|
272
314
|
if (startDay && !endDay) {
|
@@ -320,6 +362,13 @@ SmartComponent({
|
|
320
362
|
this.select(date, true);
|
321
363
|
}
|
322
364
|
},
|
365
|
+
onClickDate(event) {
|
366
|
+
if (this.data.readonly) {
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
let date = event.detail;
|
370
|
+
this.select(date, true);
|
371
|
+
},
|
323
372
|
unselect(dateArray) {
|
324
373
|
const date = dateArray[0];
|
325
374
|
if (date) {
|
package/dist/calendar/index.json
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
"usingComponents": {
|
4
4
|
"header": "./components/header/index",
|
5
5
|
"month": "./components/month/index",
|
6
|
+
"month-list": "./components/month-list/index",
|
7
|
+
"year-list": "./components/year-list/index",
|
6
8
|
"smart-button": "../button/index",
|
7
9
|
"smart-popup": "../popup/index",
|
8
10
|
"smart-toast": "../toast/index"
|
9
11
|
}
|
10
|
-
}
|
12
|
+
}
|
package/dist/calendar/index.wxml
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
show="{{ show }}"
|
11
11
|
round="{{ round }}"
|
12
12
|
position="{{ position }}"
|
13
|
-
closeable="{{
|
13
|
+
closeable="{{false}}"
|
14
14
|
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
15
15
|
safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
|
16
16
|
root-portal="{{ rootPortal }}"
|
package/dist/calendar/index.wxs
CHANGED
@@ -32,11 +32,29 @@ function getButtonDisabled(type, currentDate, minRange) {
|
|
32
32
|
}
|
33
33
|
|
34
34
|
function getVisible(visibleIndex, curIndex) {
|
35
|
-
return
|
35
|
+
return visibleIndex === curIndex;
|
36
|
+
}
|
37
|
+
|
38
|
+
function formatMonthTitle(date, formatter = 'YYYY-MM') {
|
39
|
+
date = getDate(date);
|
40
|
+
const year = date.getFullYear();
|
41
|
+
const month =
|
42
|
+
date.getMonth() + 1 < 10
|
43
|
+
? `0${date.getMonth() + 1}`
|
44
|
+
: date.getMonth() + 1 + '';
|
45
|
+
return formatter.replace('YYYY', year + '').replace('MM', month);
|
46
|
+
}
|
47
|
+
|
48
|
+
function formatYearTitle(date, offset, formatter = 'YYYY') {
|
49
|
+
date = getDate(date);
|
50
|
+
const year = date.getFullYear() + offset;
|
51
|
+
return formatter.replace('YYYY', year + '');
|
36
52
|
}
|
37
53
|
|
38
54
|
module.exports = {
|
39
55
|
getMonths: getMonths,
|
40
|
-
getVisible
|
41
|
-
getButtonDisabled: getButtonDisabled
|
56
|
+
getVisible,
|
57
|
+
getButtonDisabled: getButtonDisabled,
|
58
|
+
formatMonthTitle,
|
59
|
+
formatYearTitle,
|
42
60
|
};
|
package/dist/calendar/index.wxss
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.wxss';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:
|
1
|
+
@import '../common/index.wxss';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:auto}.smart-calendar__close-icon{top:11px}.smart-calendar__popup--bottom,.smart-calendar__popup--top{height:848rpx}.smart-calendar__popup--left,.smart-calendar__popup--right{height:100%}.smart-calendar-month{margin-top:44rpx}.smart-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.smart-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.smart-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.smart-calendar__footer+.smart-calendar__footer,.smart-calendar__footer:empty{display:none}.smart-calendar__footer:empty+.smart-calendar__footer{display:block!important}
|
package/dist/calendar/utils.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare const ROW_HEIGHT =
|
1
|
+
export declare const ROW_HEIGHT = 34;
|
2
2
|
export declare function formatMonthTitle(date: Date, formatter?: string): string;
|
3
3
|
export declare function compareMonth(date1: Date | number, date2: Date | number): 0 | 1 | -1;
|
4
4
|
export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1;
|
@@ -10,4 +10,9 @@ export declare function calcDateNum(date: [Date, Date]): number;
|
|
10
10
|
export declare function copyDates(dates: Date | Date[]): Date | Date[];
|
11
11
|
export declare function getMonthEndDay(year: number, month: number): number;
|
12
12
|
export declare function getMonths(minDate: number, maxDate: number): number[];
|
13
|
-
export declare function
|
13
|
+
export declare function getYears(minDate: number, maxDate: number): number[];
|
14
|
+
export declare function getCurrentIndex(currentDate: any, months: any): number;
|
15
|
+
export declare function getWeekStartAndEnd(date: Date): {
|
16
|
+
weekStart: Date;
|
17
|
+
weekEnd: Date;
|
18
|
+
};
|
package/dist/calendar/utils.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export const ROW_HEIGHT =
|
1
|
+
export const ROW_HEIGHT = 34;
|
2
2
|
export function formatMonthTitle(date, formatter = 'YYYY-MM') {
|
3
3
|
if (!(date instanceof Date)) {
|
4
4
|
date = new Date(date);
|
@@ -85,11 +85,47 @@ export function getMonths(minDate, maxDate) {
|
|
85
85
|
} while (compareMonth(cursor, maxDate) !== 1);
|
86
86
|
return months;
|
87
87
|
}
|
88
|
-
export function
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
88
|
+
export function getYears(minDate, maxDate) {
|
89
|
+
const years = [];
|
90
|
+
const cursor = new Date(minDate);
|
91
|
+
cursor.setDate(1);
|
92
|
+
do {
|
93
|
+
years.push(cursor.getTime());
|
94
|
+
cursor.setFullYear(cursor.getFullYear() + 1);
|
95
|
+
} while (compareMonth(cursor, maxDate) !== 1);
|
96
|
+
return years;
|
97
|
+
}
|
98
|
+
function findLastGreaterOrEqual(arr, n) {
|
99
|
+
let left = 0;
|
100
|
+
let right = arr.length - 1;
|
101
|
+
let result = -1; // 初始化为 -1,若无符合条件的元素返回 -1
|
102
|
+
while (left <= right) {
|
103
|
+
const mid = Math.floor((left + right) / 2);
|
104
|
+
if (arr[mid] <= n) {
|
105
|
+
result = mid; // 暂存满足条件的索引
|
106
|
+
left = mid + 1; // 继续向右搜索更大的满足条件的元素
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
right = mid - 1;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
return result;
|
113
|
+
}
|
114
|
+
export function getCurrentIndex(currentDate, months) {
|
115
|
+
if (Array.isArray(currentDate)) {
|
116
|
+
currentDate = currentDate[0];
|
117
|
+
}
|
118
|
+
return findLastGreaterOrEqual(months, currentDate);
|
119
|
+
}
|
120
|
+
export function getWeekStartAndEnd(date) {
|
121
|
+
const startOfWeek = new Date(date);
|
122
|
+
const dayOfWeek = startOfWeek.getDay();
|
123
|
+
const diffToMonday = (dayOfWeek + 6) % 7;
|
124
|
+
startOfWeek.setDate(startOfWeek.getDate() - diffToMonday);
|
125
|
+
const endOfWeek = new Date(startOfWeek);
|
126
|
+
endOfWeek.setDate(startOfWeek.getDate() + 6);
|
127
|
+
return {
|
128
|
+
weekStart: startOfWeek,
|
129
|
+
weekEnd: endOfWeek,
|
130
|
+
};
|
95
131
|
}
|
package/dist/checkbox/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
@import '../common/index.css';.smart-checkbox{align-items:center;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.smart-checkbox--horizontal{margin-right:12px}.smart-checkbox__icon-wrap,.smart-checkbox__label{line-height:var(--checkbox-size,
|
1
|
+
@import '../common/index.css';.smart-checkbox{align-items:center;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.smart-checkbox--horizontal{margin-right:12px}.smart-checkbox__icon-wrap,.smart-checkbox__label{line-height:var(--checkbox-size,24px)}.smart-checkbox__icon-wrap{display:flex;flex:none}.smart-checkbox__icon{align-items:center;border:2px solid var(--checkbox-border-color,var(--app-B6-N6,rgba(0,0,0,.2)));border-radius:var(--checkbox-border-radius,4px);box-sizing:border-box;color:transparent;display:flex;font-size:var(--checkbox-size,24px);height:1em;justify-content:center;text-align:center;transition-duration:var(--checkbox-transition-duration,.2s);transition-property:color,border,background-color;width:1em}.smart-checkbox__icon--round{border-radius:100%}.smart-checkbox__icon--checked{background-color:var(--checkbox-checked-icon-color,var(--app-M4,#1989fa));border:none;color:#fff}.smart-checkbox__icon--disabled{opacity:.3}.smart-checkbox__label{word-wrap:break-word;color:var(--checkbox-label-color,var(--app-B6-N1,#000));font-size:var(--checkbox-label-size,12px);padding-left:var(--checkbox-label-margin,10px)}.smart-checkbox__label--left{float:left;margin:0 var(--checkbox-label-margin,10px) 0 0}.smart-checkbox__label--disabled{color:var(--checkbox-disabled-label-color,var(--app-B6-N1,#000))}.smart-checkbox__label:empty{margin:0}
|
package/dist/checkbox/index.js
CHANGED
package/dist/checkbox/index.wxml
CHANGED
@@ -13,8 +13,8 @@
|
|
13
13
|
<slot wx:if="{{ useIconSlot }}" name="icon" />
|
14
14
|
<smart-icon
|
15
15
|
wx:else
|
16
|
-
name="{{icon}}"
|
17
|
-
size="
|
16
|
+
name="{{ icon }}"
|
17
|
+
size="1em"
|
18
18
|
color="{{ value ? '#fff' : 'none'}}"
|
19
19
|
class="{{ utils.bem('checkbox__icon', [shape, { disabled: disabled || parentDisabled, checked: value }]) }}"
|
20
20
|
style="{{ computed.iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) }}"
|