Skip to content

Commit f88b25a

Browse files
committed
docs(VCalendar): fix api types
1 parent 3158d0c commit f88b25a

File tree

9 files changed

+99
-192
lines changed

9 files changed

+99
-192
lines changed

packages/api-generator/src/locale/en/VCalendar.json

Lines changed: 20 additions & 143 deletions
Large diffs are not rendered by default.

packages/api-generator/src/locale/en/VCalendarDaily.json

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"props": {
3+
"hideDayHeader": "Determines whether the day header is visible in the calendar day view.",
4+
"intervals": "Specifies the total number of time intervals for the day in the calendar view."
5+
},
6+
"exposed": {
7+
"intervals": "Computed reference containing details about each interval in the day view."
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"props": {
3+
"nextIcon": "The icon to use for the next button.",
4+
"prevIcon": "The icon to use for the prev button.",
5+
"viewMode": "The current view mode of the calendar."
6+
},
7+
"events": {
8+
"click:next": "Event emitted when clicking the next button.",
9+
"click:prev": "Event emitted when clicking the prev button.",
10+
"click:toToday": "Event emitted when clicking the today button."
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"props": {
3+
"day": "Represents the specific day associated with the interval.",
4+
"dayIndex": "Index of the day this interval is a part of, in a week or month view.",
5+
"events": "Array of events specific to this interval.",
6+
"index": "Index or position of the interval in the day view.",
7+
"intervalDivisions": "Number of subdivisions within this interval.",
8+
"intervalDuration": "Duration of this specific interval in minutes.",
9+
"intervalFormat": "Formatting rule for displaying the interval, as a string or function.",
10+
"intervalHeight": "Height of the interval in pixels in the calendar view.",
11+
"intervalStart": "Starting time for this specific interval."
12+
},
13+
"exposed": {
14+
"interval": "Computed reference for the interval, including label, start and end times, and associated events."
15+
}
16+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"props": {
3+
"allDay": "Indicates whether the event spans the entire day.",
4+
"event": "The event object associated with this calendar interval.",
5+
"interval": "The specific time interval this event is associated with.",
6+
"intervalDivisions": "Number of subdivisions within the interval for this event.",
7+
"intervalDuration": "Duration of the interval in which this event occurs, in minutes.",
8+
"intervalHeight": "Height of the interval in the calendar view, in pixels."
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"props": {
3+
"day": "Represents the specific day in the month view of the calendar.",
4+
"events": "Array of events associated with this specific day."
5+
},
6+
"slots": {
7+
"content": "Slot for custom content related to the day in the month view."
8+
}
9+
}

packages/vuetify/src/labs/VCalendar/VCalendar.tsx

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import './VCalendar.sass'
33

44
// Components
55
import { makeVCalendarDayProps, VCalendarDay } from './VCalendarDay'
6-
import { VCalendarHeader } from './VCalendarHeader'
6+
import { makeVCalendarHeaderProps, VCalendarHeader } from './VCalendarHeader'
77
import { VCalendarMonthDay } from './VCalendarMonthDay'
88

99
// Composables
@@ -17,21 +17,14 @@ import { chunkArray, genericComponent, propsFactory, useRender } from '@/util'
1717
export const makeVCalendarProps = propsFactory({
1818
hideHeader: Boolean,
1919
hideWeekNumber: Boolean,
20-
title: String,
21-
type: {
22-
type: String,
23-
default: 'month',
24-
validator (val: string) {
25-
return ['month', 'week', 'day'].includes(val)
26-
},
27-
},
2820
weekdays: {
2921
type: Array<number>,
3022
default: () => [0, 1, 2, 3, 4, 5, 6],
3123
},
3224

3325
...makeCalendarProps(),
3426
...makeVCalendarDayProps(),
27+
...makeVCalendarHeaderProps(),
3528
}, 'VCalender')
3629

3730
export type VCalendarSlots = {
@@ -57,25 +50,25 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
5750
const dayNames = adapter.getWeekdays()
5851

5952
function onClickNext () {
60-
if (props.type === 'month') {
53+
if (props.viewMode === 'month') {
6154
model.value = [adapter.addMonths(model.value[0], 1)]
6255
}
63-
if (props.type === 'week') {
56+
if (props.viewMode === 'week') {
6457
model.value = [adapter.addDays(model.value[0], 7)]
6558
}
66-
if (props.type === 'day') {
59+
if (props.viewMode === 'day') {
6760
model.value = [adapter.addDays(model.value[0], 1)]
6861
}
6962
}
7063

7164
function onClickPrev () {
72-
if (props.type === 'month') {
65+
if (props.viewMode === 'month') {
7366
model.value = [adapter.addMonths(model.value[0], -1)]
7467
}
75-
if (props.type === 'week') {
68+
if (props.viewMode === 'week') {
7669
model.value = [adapter.addDays(model.value[0], -7)]
7770
}
78-
if (props.type === 'day') {
71+
if (props.viewMode === 'day') {
7972
model.value = [adapter.addDays(model.value[0], -1)]
8073
}
8174
}
@@ -90,14 +83,15 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
9083

9184
useRender(() => {
9285
const calendarDayProps = VCalendarDay.filterProps(props)
86+
const calendarHeaderProps = VCalendarHeader.filterProps(props)
9387

9488
return (
9589
<div class={[
9690
'v-calendar',
9791
{
98-
'v-calendar-monthly': props.type === 'month',
99-
'v-calendar-weekly': props.type === 'week',
100-
'v-calendar-day': props.type === 'day',
92+
'v-calendar-monthly': props.viewMode === 'month',
93+
'v-calendar-weekly': props.viewMode === 'week',
94+
'v-calendar-day': props.viewMode === 'day',
10195
},
10296
]}
10397
>
@@ -106,6 +100,7 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
106100
!slots.header ? (
107101
<VCalendarHeader
108102
key="calendar-header"
103+
{ ...calendarHeaderProps }
109104
title={ title.value }
110105
onClick:next={ onClickNext }
111106
onClick:prev={ onClickPrev }
@@ -118,7 +113,7 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
118113
</div>
119114

120115
<div class="v-calendar__container">
121-
{ props.type === 'month' && !props.hideDayHeader && (
116+
{ props.viewMode === 'month' && !props.hideDayHeader && (
122117
<div
123118
class={
124119
[
@@ -140,7 +135,7 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
140135
</div>
141136
)}
142137

143-
{ props.type === 'month' && (
138+
{ props.viewMode === 'month' && (
144139
<div
145140
key="VCalendarMonth"
146141
class={
@@ -169,7 +164,7 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
169164
</div>
170165
)}
171166

172-
{ props.type === 'week' && (
167+
{ props.viewMode === 'week' && (
173168
daysInWeek.value.map((day, i) => (
174169
<VCalendarDay
175170
{ ...calendarDayProps }
@@ -180,7 +175,7 @@ export const VCalendar = genericComponent<VCalendarSlots>()({
180175
))
181176
)}
182177

183-
{ props.type === 'day' && (
178+
{ props.viewMode === 'day' && (
184179
<VCalendarDay
185180
{ ...calendarDayProps }
186181
day={ genDays([model.value[0] as Date], adapter.date() as Date)[0] }

packages/vuetify/src/labs/VCalendar/VCalendarHeader.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import { useLocale } from '@/composables/locale'
1010
// Utilities
1111
import { genericComponent, propsFactory, useRender } from '@/util'
1212

13+
// Types
14+
import type { PropType } from 'vue'
15+
1316
export const makeVCalendarHeaderProps = propsFactory({
1417
nextIcon: {
15-
type: [String],
18+
type: String,
1619
default: '$next',
1720
},
1821
prevIcon: {
19-
type: [String],
22+
type: String,
2023
default: '$prev',
2124
},
2225
title: String,
@@ -25,7 +28,7 @@ export const makeVCalendarHeaderProps = propsFactory({
2528
default: '$vuetify.calendar.today',
2629
},
2730
viewMode: {
28-
type: String,
31+
type: String as PropType<'month' | 'week' | 'day'>,
2932
default: 'month',
3033
},
3134
}, 'VCalendarHeader')

0 commit comments

Comments
 (0)