@tplc/wot 1.0.12 → 1.0.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 +4 -0
- package/components/common/abstracts/variable.scss +682 -183
- 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-checkbox/index.scss +9 -9
- package/components/wd-checkbox/wd-checkbox.vue +19 -10
- package/components/wd-datetime-picker/types.ts +22 -6
- package/components/wd-datetime-picker/wd-datetime-picker.vue +136 -55
- 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/components/wd-picker/wd-picker.vue +29 -18
- package/components/wd-radio/index.scss +9 -9
- 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
|
@@ -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>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
1
|
+
@import './../common/abstracts/_mixin.scss';
|
|
2
|
+
@import './../common/abstracts/variable.scss';
|
|
3
3
|
|
|
4
4
|
.wot-theme-dark {
|
|
5
5
|
@include b(checkbox) {
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@include when(button) {
|
|
41
|
-
|
|
42
41
|
.wd-checkbox__label {
|
|
43
42
|
border-color: #c8c9cc;
|
|
44
43
|
background: #3a3a3c;
|
|
@@ -66,7 +65,6 @@
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -86,7 +84,7 @@
|
|
|
86
84
|
display: inline-block;
|
|
87
85
|
width: $-checkbox-size;
|
|
88
86
|
height: $-checkbox-size;
|
|
89
|
-
border:
|
|
87
|
+
border: 1px solid $-checkbox-border-color;
|
|
90
88
|
border-radius: 50%;
|
|
91
89
|
color: $-checkbox-check-color;
|
|
92
90
|
background: $-checkbox-bg;
|
|
@@ -181,11 +179,13 @@
|
|
|
181
179
|
height: $-checkbox-button-height;
|
|
182
180
|
font-size: $-checkbox-button-font-size;
|
|
183
181
|
margin-left: 0;
|
|
184
|
-
padding:
|
|
182
|
+
padding: 4rpx 12rpx;
|
|
185
183
|
border: 1px solid $-checkbox-button-border;
|
|
186
184
|
background-color: $-checkbox-button-bg;
|
|
187
185
|
border-radius: $-checkbox-button-radius;
|
|
188
|
-
transition:
|
|
186
|
+
transition:
|
|
187
|
+
color 0.2s,
|
|
188
|
+
border 0.2s;
|
|
189
189
|
box-sizing: border-box;
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
&:last-child::after {
|
|
268
|
-
content:
|
|
268
|
+
content: '';
|
|
269
269
|
display: table;
|
|
270
270
|
clear: both;
|
|
271
271
|
}
|
|
@@ -282,4 +282,4 @@
|
|
|
282
282
|
font-size: $-checkbox-large-label-fs;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
}
|
|
285
|
+
}
|
|
@@ -19,10 +19,18 @@
|
|
|
19
19
|
<!--shape为button时只保留wd-checkbox__label-->
|
|
20
20
|
<view
|
|
21
21
|
:class="`wd-checkbox__label ${customLabelClass}`"
|
|
22
|
-
:style="
|
|
22
|
+
:style="
|
|
23
|
+
isChecked && innerShape === 'button' && !innerDisabled && innerCheckedColor
|
|
24
|
+
? 'color:' + innerCheckedColor
|
|
25
|
+
: ''
|
|
26
|
+
"
|
|
23
27
|
>
|
|
24
28
|
<!--button选中时展示的icon-->
|
|
25
|
-
<wd-icon
|
|
29
|
+
<wd-icon
|
|
30
|
+
v-if="innerShape === 'button' && isChecked"
|
|
31
|
+
custom-class="wd-checkbox__btn-check"
|
|
32
|
+
name="check-bold"
|
|
33
|
+
/>
|
|
26
34
|
<!--文案-->
|
|
27
35
|
<view class="wd-checkbox__txt" :style="maxWidth ? 'max-width:' + maxWidth : ''">
|
|
28
36
|
<slot></slot>
|
|
@@ -37,8 +45,8 @@ export default {
|
|
|
37
45
|
options: {
|
|
38
46
|
addGlobalClass: true,
|
|
39
47
|
virtualHost: true,
|
|
40
|
-
styleIsolation: 'shared'
|
|
41
|
-
}
|
|
48
|
+
styleIsolation: 'shared',
|
|
49
|
+
},
|
|
42
50
|
}
|
|
43
51
|
</script>
|
|
44
52
|
|
|
@@ -54,7 +62,7 @@ const props = defineProps(checkboxProps)
|
|
|
54
62
|
const emit = defineEmits(['change', 'update:modelValue'])
|
|
55
63
|
|
|
56
64
|
defineExpose<CheckboxExpose>({
|
|
57
|
-
toggle
|
|
65
|
+
toggle,
|
|
58
66
|
})
|
|
59
67
|
|
|
60
68
|
const { parent: checkboxGroup, index } = useParent(CHECKBOX_GROUP_KEY)
|
|
@@ -84,15 +92,16 @@ watch(
|
|
|
84
92
|
if (checkboxGroup) {
|
|
85
93
|
checkName()
|
|
86
94
|
}
|
|
87
|
-
}
|
|
95
|
+
},
|
|
88
96
|
)
|
|
89
97
|
|
|
90
98
|
watch(
|
|
91
99
|
() => props.shape,
|
|
92
100
|
(newValue) => {
|
|
93
101
|
const type = ['circle', 'square', 'button']
|
|
94
|
-
if (isDef(newValue) && type.indexOf(newValue) === -1)
|
|
95
|
-
|
|
102
|
+
if (isDef(newValue) && type.indexOf(newValue) === -1)
|
|
103
|
+
console.error(`shape must be one of ${type.toString()}`)
|
|
104
|
+
},
|
|
96
105
|
)
|
|
97
106
|
|
|
98
107
|
const innerShape = computed(() => {
|
|
@@ -159,14 +168,14 @@ function toggle() {
|
|
|
159
168
|
// 复选框单独使用时点击反选,并且在checkbox上触发change事件
|
|
160
169
|
if (checkboxGroup) {
|
|
161
170
|
emit('change', {
|
|
162
|
-
value: !isChecked.value
|
|
171
|
+
value: !isChecked.value,
|
|
163
172
|
})
|
|
164
173
|
checkboxGroup.changeSelectState(props.modelValue)
|
|
165
174
|
} else {
|
|
166
175
|
const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue
|
|
167
176
|
emit('update:modelValue', newVal)
|
|
168
177
|
emit('change', {
|
|
169
|
-
value: newVal
|
|
178
|
+
value: newVal,
|
|
170
179
|
})
|
|
171
180
|
}
|
|
172
181
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
baseProps,
|
|
4
|
+
makeArrayProp,
|
|
5
|
+
makeBooleanProp,
|
|
6
|
+
makeNumberProp,
|
|
7
|
+
makeRequiredProp,
|
|
8
|
+
makeStringProp,
|
|
9
|
+
} from '../common/props'
|
|
10
|
+
import type {
|
|
11
|
+
DateTimeType,
|
|
12
|
+
DatetimePickerViewFilter,
|
|
13
|
+
DatetimePickerViewFormatter,
|
|
14
|
+
} from '../wd-datetime-picker-view/types'
|
|
4
15
|
import type { FormItemRule } from '../wd-form/types'
|
|
5
16
|
|
|
6
17
|
const now = new Date()
|
|
@@ -92,7 +103,9 @@ export const datetimePickerProps = {
|
|
|
92
103
|
/**
|
|
93
104
|
* 选中项,当 type 为 time 时,类型为字符串;当 type 为 Array 时,类型为范围选择;否则为 时间戳
|
|
94
105
|
*/
|
|
95
|
-
modelValue: makeRequiredProp([String, Number, Array] as PropType<
|
|
106
|
+
modelValue: makeRequiredProp([String, Number, Array] as PropType<
|
|
107
|
+
string | number | Array<string | number>
|
|
108
|
+
>),
|
|
96
109
|
/**
|
|
97
110
|
* 选择器类型,可选值为:date / year-month / time
|
|
98
111
|
*/
|
|
@@ -200,7 +213,7 @@ export const datetimePickerProps = {
|
|
|
200
213
|
/**
|
|
201
214
|
* 必填标记位置,可选值:before、after
|
|
202
215
|
*/
|
|
203
|
-
markerSide: makeStringProp<'before' | 'after'>('before')
|
|
216
|
+
markerSide: makeStringProp<'before' | 'after'>('before'),
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
export type DatetimePickerDisplayFormat = (items: Record<string, any>[]) => string
|
|
@@ -208,7 +221,7 @@ export type DatetimePickerDisplayFormat = (items: Record<string, any>[]) => stri
|
|
|
208
221
|
export type DatetimePickerBeforeConfirm = (
|
|
209
222
|
value: number | string | (number | string)[],
|
|
210
223
|
resolve: (isPass: boolean) => void,
|
|
211
|
-
picker: DatetimePickerInstance
|
|
224
|
+
picker: DatetimePickerInstance,
|
|
212
225
|
) => void
|
|
213
226
|
|
|
214
227
|
export type DatetimePickerDisplayFormatTabLabel = (items: Record<string, any>[]) => string
|
|
@@ -232,4 +245,7 @@ export type DatetimePickerExpose = {
|
|
|
232
245
|
|
|
233
246
|
export type DatetimePickerProps = ExtractPropTypes<typeof datetimePickerProps>
|
|
234
247
|
|
|
235
|
-
export type DatetimePickerInstance = ComponentPublicInstance<
|
|
248
|
+
export type DatetimePickerInstance = ComponentPublicInstance<
|
|
249
|
+
DatetimePickerProps,
|
|
250
|
+
DatetimePickerExpose
|
|
251
|
+
>
|