@tplc/wot 1.0.12 → 1.0.13
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 +2 -0
- package/components/wd-calendar/index.scss +145 -58
- package/components/wd-calendar/types.ts +41 -23
- package/components/wd-calendar/wd-calendar.vue +130 -123
- package/components/wd-calendar-view/month/index.scss +65 -33
- package/components/wd-calendar-view/month/month.vue +113 -80
- package/components/wd-calendar-view/month/types.ts +1 -2
- package/components/wd-calendar-view/monthPanel/index.scss +15 -15
- package/components/wd-calendar-view/monthPanel/month-panel.vue +78 -64
- package/components/wd-calendar-view/monthPanel/types.ts +10 -58
- package/components/wd-calendar-view/types.ts +36 -12
- package/components/wd-calendar-view/utils.ts +36 -14
- package/components/wd-calendar-view/wd-calendar-view.vue +7 -7
- package/components/wd-calendar-view/year/index.scss +13 -18
- package/components/wd-calendar-view/year/types.ts +1 -2
- package/components/wd-calendar-view/year/year.vue +43 -25
- package/components/wd-calendar-view/yearPanel/index.scss +4 -4
- package/components/wd-calendar-view/yearPanel/types.ts +2 -2
- package/components/wd-calendar-view/yearPanel/year-panel.vue +41 -36
- package/components/wd-drop-menu/index.scss +45 -17
- package/components/wd-drop-menu/types.ts +3 -3
- package/components/wd-drop-menu/wd-drop-menu.vue +25 -61
- package/components/wd-drop-menu-item/index.scss +15 -15
- package/components/wd-drop-menu-item/types.ts +15 -18
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +54 -33
- package/package.json +1 -1
- package/types/components/common/dayjs.d.ts +26 -0
- package/types/components/wd-calendar/types.d.ts +18 -24
- package/types/components/wd-calendar/wd-calendar.vue.d.ts +24 -40
- package/types/components/wd-calendar-view/month/month.vue.d.ts +3 -11
- package/types/components/wd-calendar-view/month/types.d.ts +0 -4
- package/types/components/wd-calendar-view/monthPanel/month-panel.vue.d.ts +12 -18
- package/types/components/wd-calendar-view/monthPanel/types.d.ts +6 -48
- package/types/components/wd-calendar-view/types.d.ts +4 -11
- package/types/components/wd-calendar-view/utils.d.ts +12 -3
- package/types/components/wd-calendar-view/year/types.d.ts +0 -4
- package/types/components/wd-calendar-view/year/year.vue.d.ts +3 -11
- package/types/components/wd-cell/wd-cell.vue.d.ts +5 -5
- package/types/components/wd-col-picker/wd-col-picker.vue.d.ts +9 -9
- package/types/components/wd-datetime-picker/wd-datetime-picker.vue.d.ts +10 -10
- package/types/components/wd-datetime-picker-view/wd-datetime-picker-view.vue.d.ts +1 -1
- package/types/components/wd-drop-menu/types.d.ts +3 -3
- package/types/components/wd-drop-menu/wd-drop-menu.vue.d.ts +5 -5
- package/types/components/wd-drop-menu-item/types.d.ts +15 -27
- package/types/components/wd-drop-menu-item/wd-drop-menu-item.vue.d.ts +35 -46
- package/types/components/wd-floating-panel/wd-floating-panel.vue.d.ts +1 -1
- package/types/components/wd-form/wd-form.vue.d.ts +1 -1
- package/types/components/wd-form-item/wd-form-item.vue.d.ts +1 -1
- package/types/components/wd-grid-item/wd-grid-item.vue.d.ts +1 -1
- package/types/components/wd-input/wd-input.vue.d.ts +4 -4
- package/types/components/wd-keyboard/wd-keyboard.vue.d.ts +1 -1
- package/types/components/wd-notify/wd-notify.vue.d.ts +1 -1
- package/types/components/wd-number-keyboard/wd-number-keyboard.vue.d.ts +1 -1
- package/types/components/wd-picker/wd-picker.vue.d.ts +12 -12
- package/types/components/wd-picker-view/wd-picker-view.vue.d.ts +2 -2
- package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +12 -12
- package/types/components/wd-signature/wd-signature.vue.d.ts +2 -2
- package/types/components/wd-steps/wd-steps.vue.d.ts +1 -1
- package/types/components/wd-swiper/wd-swiper.vue.d.ts +1 -1
- package/types/components/wd-tabs/wd-tabs.vue.d.ts +1 -1
- package/types/components/wd-textarea/wd-textarea.vue.d.ts +3 -3
- /package/components/wd-input/{placeholder.scss → placeholder.css} +0 -0
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
@include e(month) {
|
|
15
|
-
|
|
16
15
|
@include when(disabled) {
|
|
17
16
|
.wd-year__month-text {
|
|
18
17
|
color: $-dark-color-gray;
|
|
@@ -45,7 +44,6 @@
|
|
|
45
44
|
height: $-calendar-day-height;
|
|
46
45
|
line-height: $-calendar-day-height;
|
|
47
46
|
text-align: center;
|
|
48
|
-
margin-bottom: $-calendar-item-margin-bottom;
|
|
49
47
|
|
|
50
48
|
@include when(disabled) {
|
|
51
49
|
.wd-year__month-text {
|
|
@@ -61,8 +59,8 @@
|
|
|
61
59
|
color: #fff;
|
|
62
60
|
|
|
63
61
|
.wd-year__month-text {
|
|
64
|
-
border-radius: $-calendar-active-border;
|
|
65
62
|
background: $-calendar-active-color;
|
|
63
|
+
border-radius: $-calendar-active-border;
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
|
|
@@ -71,21 +69,21 @@
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
@include when(start) {
|
|
74
|
-
color:
|
|
72
|
+
color: #fff;
|
|
75
73
|
|
|
76
74
|
&::after {
|
|
77
75
|
position: absolute;
|
|
78
76
|
top: 0;
|
|
79
77
|
right: 0;
|
|
80
|
-
left: 50%;
|
|
81
78
|
bottom: 0;
|
|
79
|
+
left: 50%;
|
|
82
80
|
content: '';
|
|
83
81
|
background: $-calendar-range-color;
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
.wd-year__month-text {
|
|
87
85
|
background: $-calendar-active-color;
|
|
88
|
-
border-radius: $-calendar-active-border
|
|
86
|
+
border-radius: $-calendar-active-border;
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
&.is-without-end::after {
|
|
@@ -94,35 +92,32 @@
|
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
@include when(end) {
|
|
97
|
-
color:
|
|
95
|
+
color: #fff;
|
|
98
96
|
|
|
99
97
|
&::after {
|
|
100
98
|
position: absolute;
|
|
101
99
|
top: 0;
|
|
102
|
-
left: 0;
|
|
103
100
|
right: 50%;
|
|
104
101
|
bottom: 0;
|
|
102
|
+
left: 0;
|
|
105
103
|
content: '';
|
|
106
104
|
background: $-calendar-range-color;
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
.wd-year__month-text {
|
|
110
108
|
background: $-calendar-active-color;
|
|
111
|
-
border-radius:
|
|
109
|
+
border-radius: $-calendar-active-border;
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
@include when(same) {
|
|
116
|
-
color:
|
|
114
|
+
color: #fff;
|
|
117
115
|
|
|
118
116
|
.wd-year__month-text {
|
|
119
117
|
background: $-calendar-active-color;
|
|
120
118
|
border-radius: $-calendar-active-border;
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
|
-
@include when(last-row){
|
|
124
|
-
margin-bottom: 0;
|
|
125
|
-
}
|
|
126
121
|
}
|
|
127
122
|
|
|
128
123
|
@include e(month-text) {
|
|
@@ -134,20 +129,20 @@
|
|
|
134
129
|
@include e(month-top) {
|
|
135
130
|
position: absolute;
|
|
136
131
|
top: 10px;
|
|
137
|
-
left: 0;
|
|
138
132
|
right: 0;
|
|
139
|
-
|
|
133
|
+
left: 0;
|
|
140
134
|
font-size: $-calendar-info-fs;
|
|
135
|
+
line-height: 1.1;
|
|
141
136
|
text-align: center;
|
|
142
137
|
}
|
|
143
138
|
|
|
144
139
|
@include e(month-bottom) {
|
|
145
140
|
position: absolute;
|
|
141
|
+
right: 0;
|
|
146
142
|
bottom: 10px;
|
|
147
143
|
left: 0;
|
|
148
|
-
right: 0;
|
|
149
|
-
line-height: 1.1;
|
|
150
144
|
font-size: $-calendar-info-fs;
|
|
145
|
+
line-height: 1.1;
|
|
151
146
|
text-align: center;
|
|
152
147
|
}
|
|
153
|
-
}
|
|
148
|
+
}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
<wd-toast selector="wd-year" />
|
|
3
3
|
|
|
4
4
|
<view class="wd-year year">
|
|
5
|
-
<view class="wd-year__title"
|
|
5
|
+
<view class="wd-year__title">{{ yearTitle(date) }}</view>
|
|
6
6
|
<view class="wd-year__months">
|
|
7
7
|
<view
|
|
8
8
|
v-for="(item, index) in months"
|
|
9
9
|
:key="index"
|
|
10
|
-
:class="`wd-year__month ${item.disabled ? 'is-disabled' : ''} ${item.
|
|
11
|
-
item.type ? monthTypeClass(item.type) : ''
|
|
12
|
-
}`"
|
|
10
|
+
:class="`wd-year__month ${item.disabled ? 'is-disabled' : ''} ${item.type ? itemClass(item.type, value!, type) : ''}`"
|
|
13
11
|
@click="handleDateClick(index)"
|
|
14
12
|
>
|
|
15
13
|
<view class="wd-year__month-top">{{ item.topInfo }}</view>
|
|
@@ -24,21 +22,27 @@ export default {
|
|
|
24
22
|
options: {
|
|
25
23
|
addGlobalClass: true,
|
|
26
24
|
virtualHost: true,
|
|
27
|
-
styleIsolation: 'shared'
|
|
28
|
-
}
|
|
25
|
+
styleIsolation: 'shared',
|
|
26
|
+
},
|
|
29
27
|
}
|
|
30
28
|
</script>
|
|
31
29
|
|
|
32
30
|
<script lang="ts" setup>
|
|
33
|
-
import wdToast from '../../wd-toast/wd-toast.vue'
|
|
34
31
|
import { computed, ref, watch } from 'vue'
|
|
35
32
|
import { deepClone, isArray, isFunction } from '../../common/util'
|
|
36
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
compareMonth,
|
|
35
|
+
formatYearTitle,
|
|
36
|
+
getDateByDefaultTime,
|
|
37
|
+
getItemClass,
|
|
38
|
+
getMonthByOffset,
|
|
39
|
+
getMonthOffset,
|
|
40
|
+
} from '../utils'
|
|
37
41
|
import { useToast } from '../../wd-toast'
|
|
38
42
|
import { useTranslate } from '../../composables/useTranslate'
|
|
39
|
-
import dayjs from '
|
|
43
|
+
import { dayjs } from '../../common/dayjs'
|
|
40
44
|
import { yearProps } from './types'
|
|
41
|
-
import type { CalendarDayItem, CalendarDayType } from '../types'
|
|
45
|
+
import type { CalendarDayItem, CalendarDayType, CalendarType } from '../types'
|
|
42
46
|
|
|
43
47
|
const props = defineProps(yearProps)
|
|
44
48
|
const emit = defineEmits(['change'])
|
|
@@ -48,9 +52,9 @@ const { translate } = useTranslate('calendar-view')
|
|
|
48
52
|
|
|
49
53
|
const months = ref<CalendarDayItem[]>([])
|
|
50
54
|
|
|
51
|
-
const
|
|
52
|
-
return (monthType: CalendarDayType) => {
|
|
53
|
-
return getItemClass(monthType,
|
|
55
|
+
const itemClass = computed(() => {
|
|
56
|
+
return (monthType: CalendarDayType, value: number | (number | null)[], type: CalendarType) => {
|
|
57
|
+
return getItemClass(monthType, value, type)
|
|
54
58
|
}
|
|
55
59
|
})
|
|
56
60
|
|
|
@@ -61,14 +65,21 @@ const yearTitle = computed(() => {
|
|
|
61
65
|
})
|
|
62
66
|
|
|
63
67
|
watch(
|
|
64
|
-
[
|
|
68
|
+
[
|
|
69
|
+
() => props.type,
|
|
70
|
+
() => props.date,
|
|
71
|
+
() => props.value,
|
|
72
|
+
() => props.minDate,
|
|
73
|
+
() => props.maxDate,
|
|
74
|
+
() => props.formatter,
|
|
75
|
+
],
|
|
65
76
|
() => {
|
|
66
77
|
setMonths()
|
|
67
78
|
},
|
|
68
79
|
{
|
|
69
80
|
deep: true,
|
|
70
|
-
immediate: true
|
|
71
|
-
}
|
|
81
|
+
immediate: true,
|
|
82
|
+
},
|
|
72
83
|
)
|
|
73
84
|
|
|
74
85
|
function getMonthLabel(date: number) {
|
|
@@ -109,7 +120,12 @@ function getMonthType(date: number) {
|
|
|
109
120
|
return 'start'
|
|
110
121
|
} else if (endDate && compareMonth(date, endDate) === 0) {
|
|
111
122
|
return 'end'
|
|
112
|
-
} else if (
|
|
123
|
+
} else if (
|
|
124
|
+
startDate &&
|
|
125
|
+
endDate &&
|
|
126
|
+
compareMonth(date, startDate) === 1 &&
|
|
127
|
+
compareMonth(date, endDate) === -1
|
|
128
|
+
) {
|
|
113
129
|
return 'middle'
|
|
114
130
|
} else {
|
|
115
131
|
return ''
|
|
@@ -139,12 +155,14 @@ function handleDateClick(index: number) {
|
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
157
|
function getDate(date: number) {
|
|
142
|
-
return props.defaultTime && props.defaultTime.length > 0
|
|
158
|
+
return props.defaultTime && props.defaultTime.length > 0
|
|
159
|
+
? getDateByDefaultTime(date, props.defaultTime[0])
|
|
160
|
+
: date
|
|
143
161
|
}
|
|
144
162
|
function handleMonthChange(date: CalendarDayItem) {
|
|
145
163
|
if (date.type !== 'selected') {
|
|
146
164
|
emit('change', {
|
|
147
|
-
value: getDate(date.date)
|
|
165
|
+
value: getDate(date.date),
|
|
148
166
|
})
|
|
149
167
|
}
|
|
150
168
|
}
|
|
@@ -161,7 +179,7 @@ function handleMonthRangeChange(date: CalendarDayItem) {
|
|
|
161
179
|
const maxEndDate = getMonthByOffset(startDate, props.maxRange - 1)
|
|
162
180
|
value = [startDate, getDate(maxEndDate)]
|
|
163
181
|
toast.show({
|
|
164
|
-
msg: props.rangePrompt || translate('rangePromptMonth', props.maxRange)
|
|
182
|
+
msg: props.rangePrompt || translate('rangePromptMonth', props.maxRange),
|
|
165
183
|
})
|
|
166
184
|
} else {
|
|
167
185
|
value = [startDate, getDate(date.date)]
|
|
@@ -170,26 +188,26 @@ function handleMonthRangeChange(date: CalendarDayItem) {
|
|
|
170
188
|
value = [getDate(date.date), null]
|
|
171
189
|
}
|
|
172
190
|
emit('change', {
|
|
173
|
-
value
|
|
191
|
+
value,
|
|
174
192
|
})
|
|
175
193
|
}
|
|
176
194
|
|
|
177
195
|
function getFormatterDate(date: number, month: number, type?: CalendarDayType) {
|
|
178
196
|
let monthObj: CalendarDayItem = {
|
|
179
|
-
date
|
|
197
|
+
date,
|
|
180
198
|
text: month + 1,
|
|
181
199
|
topInfo: '',
|
|
182
200
|
bottomInfo: '',
|
|
183
201
|
type,
|
|
184
202
|
disabled: compareMonth(date, props.minDate) === -1 || compareMonth(date, props.maxDate) === 1,
|
|
185
|
-
isLastRow: month >= 8
|
|
186
203
|
}
|
|
187
|
-
|
|
188
204
|
if (props.formatter) {
|
|
189
205
|
if (isFunction(props.formatter)) {
|
|
190
206
|
monthObj = props.formatter(monthObj)
|
|
191
207
|
} else {
|
|
192
|
-
console.error(
|
|
208
|
+
console.error(
|
|
209
|
+
'[wot-design] error(wd-calendar-view): the formatter prop of wd-calendar-view should be a function',
|
|
210
|
+
)
|
|
193
211
|
}
|
|
194
212
|
}
|
|
195
213
|
|
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
@include b(year-panel) {
|
|
6
6
|
@include e(title) {
|
|
7
7
|
color: $-dark-color;
|
|
8
|
-
box-shadow: 0px 4px 8px 0 rgba(255, 255,255, 0.02);
|
|
8
|
+
box-shadow: 0px 4px 8px 0 rgba(255, 255, 255, 0.02);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@include b(year-panel) {
|
|
14
|
-
font-size: $-calendar-fs;
|
|
15
14
|
padding: $-calendar-panel-padding;
|
|
15
|
+
font-size: $-calendar-fs;
|
|
16
16
|
|
|
17
17
|
@include e(title) {
|
|
18
18
|
padding: 5px 0;
|
|
19
|
-
text-align: center;
|
|
20
19
|
font-size: $-calendar-panel-title-fs;
|
|
21
20
|
color: $-calendar-panel-title-color;
|
|
21
|
+
text-align: center;
|
|
22
22
|
box-shadow: 0px 4px 8px 0 rgba(0, 0, 0, 0.02);
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -21,9 +21,9 @@ export const yearPanelProps = {
|
|
|
21
21
|
allowSameDay: makeBooleanProp(false),
|
|
22
22
|
showPanelTitle: makeBooleanProp(false),
|
|
23
23
|
defaultTime: {
|
|
24
|
-
type: [Array] as PropType<Array<number[]
|
|
24
|
+
type: [Array] as PropType<Array<number[]>>,
|
|
25
25
|
},
|
|
26
|
-
panelHeight: makeRequiredProp(Number)
|
|
26
|
+
panelHeight: makeRequiredProp(Number),
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export type YearPanelProps = ExtractPropTypes<typeof yearPanelProps>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="wd-year-panel">
|
|
3
3
|
<view v-if="showPanelTitle" class="wd-year-panel__title">{{ title }}</view>
|
|
4
|
-
<scroll-view
|
|
4
|
+
<scroll-view
|
|
5
|
+
class="wd-year-panel__container"
|
|
6
|
+
:style="`height: ${scrollHeight}px`"
|
|
7
|
+
scroll-y
|
|
8
|
+
@scroll="yearScroll"
|
|
9
|
+
:scroll-top="scrollTop"
|
|
10
|
+
>
|
|
5
11
|
<view v-for="(item, index) in years" :key="index" :id="`year${index}`">
|
|
6
12
|
<year
|
|
7
13
|
:type="type"
|
|
@@ -14,7 +20,6 @@
|
|
|
14
20
|
:range-prompt="rangePrompt"
|
|
15
21
|
:allow-same-day="allowSameDay"
|
|
16
22
|
:default-time="defaultTime"
|
|
17
|
-
:showTitle="index !== 0"
|
|
18
23
|
@change="handleDateChange"
|
|
19
24
|
/>
|
|
20
25
|
</view>
|
|
@@ -26,15 +31,15 @@ export default {
|
|
|
26
31
|
options: {
|
|
27
32
|
addGlobalClass: true,
|
|
28
33
|
virtualHost: true,
|
|
29
|
-
styleIsolation: 'shared'
|
|
30
|
-
}
|
|
34
|
+
styleIsolation: 'shared',
|
|
35
|
+
},
|
|
31
36
|
}
|
|
32
37
|
</script>
|
|
33
38
|
|
|
34
39
|
<script lang="ts" setup>
|
|
35
40
|
import { computed, ref, onMounted } from 'vue'
|
|
36
41
|
import { compareYear, formatYearTitle, getYears } from '../utils'
|
|
37
|
-
import { isArray, isNumber,
|
|
42
|
+
import { isArray, isNumber, requestAnimationFrame } from '../../common/util'
|
|
38
43
|
import Year from '../year/year.vue'
|
|
39
44
|
import { yearPanelProps, type YearInfo, type YearPanelExpose } from './types'
|
|
40
45
|
|
|
@@ -46,16 +51,16 @@ const scrollIndex = ref<number>(0) // 当前显示的年份索引
|
|
|
46
51
|
|
|
47
52
|
// 滚动区域的高度
|
|
48
53
|
const scrollHeight = computed(() => {
|
|
49
|
-
const scrollHeight: number = props.panelHeight + (props.showPanelTitle ? 26 : 16)
|
|
54
|
+
const scrollHeight: number = (props.panelHeight || 378) + (props.showPanelTitle ? 26 : 16)
|
|
50
55
|
return scrollHeight
|
|
51
56
|
})
|
|
52
57
|
|
|
53
58
|
// 年份信息
|
|
54
59
|
const years = computed<YearInfo[]>(() => {
|
|
55
|
-
return getYears(props.minDate, props.maxDate).map((year
|
|
60
|
+
return getYears(props.minDate, props.maxDate).map((year) => {
|
|
56
61
|
return {
|
|
57
62
|
date: year,
|
|
58
|
-
height:
|
|
63
|
+
height: 237,
|
|
59
64
|
}
|
|
60
65
|
})
|
|
61
66
|
})
|
|
@@ -69,38 +74,38 @@ onMounted(() => {
|
|
|
69
74
|
scrollIntoView()
|
|
70
75
|
})
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
function scrollIntoView() {
|
|
78
|
+
requestAnimationFrame(() => {
|
|
79
|
+
let activeDate: number | null = null
|
|
80
|
+
if (isArray(props.value)) {
|
|
81
|
+
activeDate = props.value![0]
|
|
82
|
+
} else if (isNumber(props.value)) {
|
|
83
|
+
activeDate = props.value
|
|
84
|
+
}
|
|
80
85
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
if (!activeDate) {
|
|
87
|
+
activeDate = Date.now()
|
|
88
|
+
}
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
let top: number = 0
|
|
91
|
+
for (let index = 0; index < years.value.length; index++) {
|
|
92
|
+
if (compareYear(years.value[index].date, activeDate) === 0) {
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
top += years.value[index] ? Number(years.value[index].height) : 0
|
|
89
96
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
scrollTop.value = top + 45
|
|
96
|
-
}
|
|
97
|
+
scrollTop.value = 0
|
|
98
|
+
requestAnimationFrame(() => {
|
|
99
|
+
scrollTop.value = top
|
|
100
|
+
})
|
|
101
|
+
})
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
const yearScroll = (
|
|
104
|
+
const yearScroll = (e: Event) => {
|
|
100
105
|
if (years.value.length <= 1) {
|
|
101
106
|
return
|
|
102
107
|
}
|
|
103
|
-
const scrollTop = Math.max(0,
|
|
108
|
+
const scrollTop = Math.max(0, (e.target as Element).scrollTop)
|
|
104
109
|
doSetSubtitle(scrollTop)
|
|
105
110
|
}
|
|
106
111
|
|
|
@@ -112,7 +117,7 @@ function doSetSubtitle(scrollTop: number) {
|
|
|
112
117
|
let height: number = 0 // 月份高度和
|
|
113
118
|
for (let index = 0; index < years.value.length; index++) {
|
|
114
119
|
height = height + years.value[index].height
|
|
115
|
-
if (scrollTop < height) {
|
|
120
|
+
if (scrollTop < height + 45) {
|
|
116
121
|
scrollIndex.value = index
|
|
117
122
|
return
|
|
118
123
|
}
|
|
@@ -121,15 +126,15 @@ function doSetSubtitle(scrollTop: number) {
|
|
|
121
126
|
|
|
122
127
|
function handleDateChange({ value }: { value: number[] }) {
|
|
123
128
|
emit('change', {
|
|
124
|
-
value
|
|
129
|
+
value,
|
|
125
130
|
})
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
defineExpose<YearPanelExpose>({
|
|
129
|
-
scrollIntoView
|
|
134
|
+
scrollIntoView,
|
|
130
135
|
})
|
|
131
136
|
</script>
|
|
132
137
|
|
|
133
138
|
<style lang="scss" scoped>
|
|
134
|
-
@import './index
|
|
139
|
+
@import './index';
|
|
135
140
|
</style>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
.wot-theme-dark {
|
|
5
5
|
@include b(drop-menu) {
|
|
6
6
|
color: $-dark-color;
|
|
7
|
+
|
|
7
8
|
@include e(list) {
|
|
8
9
|
background-color: $-dark-background2;
|
|
9
10
|
}
|
|
@@ -17,16 +18,17 @@
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
@include b(drop-menu) {
|
|
21
|
+
position: relative;
|
|
20
22
|
box-sizing: border-box;
|
|
21
|
-
color: $-drop-menu-color;
|
|
22
23
|
font-size: $-drop-menu-fs;
|
|
23
|
-
|
|
24
|
+
color: $-drop-menu-color;
|
|
24
25
|
|
|
25
26
|
@include e(list) {
|
|
26
27
|
display: flex;
|
|
27
28
|
text-align: center;
|
|
28
29
|
background-color: #fff;
|
|
29
30
|
}
|
|
31
|
+
|
|
30
32
|
@include e(item) {
|
|
31
33
|
flex: 1;
|
|
32
34
|
min-width: 0;
|
|
@@ -35,16 +37,24 @@
|
|
|
35
37
|
text-align: center;
|
|
36
38
|
|
|
37
39
|
@include when(active) {
|
|
38
|
-
font-weight: $-fw-medium;
|
|
40
|
+
// font-weight: $-fw-medium;
|
|
41
|
+
|
|
42
|
+
// .wd-drop-menu__item-title::after {
|
|
43
|
+
// opacity: 1;
|
|
44
|
+
// }
|
|
45
|
+
color: $-color-theme;
|
|
39
46
|
|
|
40
|
-
.wd-drop-menu__item-title::after {
|
|
41
|
-
opacity: 1;
|
|
42
|
-
}
|
|
43
47
|
:deep(.wd-drop-menu__arrow) {
|
|
48
|
+
// scale(0.6)
|
|
44
49
|
transform: rotate(-180deg);
|
|
45
50
|
transform-origin: center center;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
53
|
+
|
|
54
|
+
@include when(checked) {
|
|
55
|
+
color: $-color-theme;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
@include when(disabled) {
|
|
49
59
|
color: $-drop-menu-disabled-color;
|
|
50
60
|
}
|
|
@@ -52,25 +62,25 @@
|
|
|
52
62
|
|
|
53
63
|
@include e(item-title) {
|
|
54
64
|
position: relative;
|
|
65
|
+
box-sizing: border-box;
|
|
55
66
|
display: inline-flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
justify-content: center;
|
|
58
67
|
max-width: 100%;
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
justify-content: center;
|
|
69
|
+
align-items: center;
|
|
70
|
+
padding: 0 8rpx 0 14rpx;
|
|
61
71
|
|
|
62
72
|
&::after {
|
|
63
73
|
position: absolute;
|
|
64
|
-
content: '';
|
|
65
|
-
width: 19px;
|
|
66
|
-
height: $-drop-menu-line-height;
|
|
67
74
|
bottom: 6px;
|
|
68
75
|
left: 50%;
|
|
69
|
-
|
|
76
|
+
width: 19px;
|
|
77
|
+
height: $-drop-menu-line-height;
|
|
78
|
+
content: '';
|
|
70
79
|
background: $-drop-menu-line-color;
|
|
71
80
|
border-radius: $-drop-menu-line-height;
|
|
72
|
-
transition: opacity .15s;
|
|
73
81
|
opacity: 0;
|
|
82
|
+
transition: opacity 0.15s;
|
|
83
|
+
transform: translate(-50%, 0);
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
|
|
@@ -79,8 +89,26 @@
|
|
|
79
89
|
@include lineEllipsis;
|
|
80
90
|
}
|
|
81
91
|
|
|
92
|
+
@include e(item-title-dot) {
|
|
93
|
+
height: 24rpx;
|
|
94
|
+
width: 24rpx;
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
background-color: $-color-theme;
|
|
97
|
+
color: #fff;
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
margin-left: 4rpx;
|
|
102
|
+
font-size: 14rpx;
|
|
103
|
+
line-height: 24rpx;
|
|
104
|
+
}
|
|
105
|
+
|
|
82
106
|
@include edeep(arrow) {
|
|
107
|
+
// position: absolute;
|
|
108
|
+
// top: 0;
|
|
109
|
+
// right: -4px;
|
|
83
110
|
font-size: $-drop-menu-arrow-fs;
|
|
84
|
-
|
|
111
|
+
transition: transform 0.3s;
|
|
112
|
+
// transform: scale(0.6);
|
|
85
113
|
}
|
|
86
|
-
}
|
|
114
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type InjectionKey, type Ref } from 'vue'
|
|
2
2
|
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../common/props'
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type DropDirction = 'up' | 'down'
|
|
5
5
|
|
|
6
6
|
export type DropMenuProvide = {
|
|
7
7
|
props: Partial<DropMenuProps>
|
|
@@ -20,7 +20,7 @@ export const dropMenuProps = {
|
|
|
20
20
|
/**
|
|
21
21
|
* 菜单展开方向,可选值为up 或 down
|
|
22
22
|
*/
|
|
23
|
-
direction: makeStringProp<
|
|
23
|
+
direction: makeStringProp<DropDirction>('down'),
|
|
24
24
|
/**
|
|
25
25
|
* 是否展示蒙层
|
|
26
26
|
*/
|
|
@@ -32,7 +32,7 @@ export const dropMenuProps = {
|
|
|
32
32
|
/**
|
|
33
33
|
* 菜单展开收起动画时间,单位 ms
|
|
34
34
|
*/
|
|
35
|
-
duration: makeNumberProp(200)
|
|
35
|
+
duration: makeNumberProp(200),
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export type DropMenuProps = ExtractPropTypes<typeof dropMenuProps>
|