Skip to content

Commit b13b15c

Browse files
J-SekKaelWD
authored andcommitted
feat(VDatePicker): restore weekday-format (#21290)
1 parent d5779cd commit b13b15c

File tree

8 files changed

+8
-9
lines changed

8 files changed

+8
-9
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"showMonthOnFirst": "Whether the name of the month should be displayed on the first day of the month.",
1414
"showWeek": "Whether week numbers should be displayed when using the `month` view.",
1515
"start": "The starting date on the calendar (inclusive) in the format of `YYYY-MM-DD`. This may be ignored depending on the `type` of the calendar.",
16-
"weekdayFormat": "Formats day of the week string that appears in the header to specified locale.",
1716
"weekdays": "Specifies which days of the week to display. To display Monday through Friday only, a value of `[1, 2, 3, 4, 5]` can be used. To display a week starting on Monday a value of `[1, 2, 3, 4, 5, 6, 0]` can be used."
1817
}
1918
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"showMonthOnFirst": "Whether the name of the month should be displayed on the first day of the month.",
1414
"showWeek": "Whether week numbers should be displayed when using the `month` view.",
1515
"start": "The starting date on the calendar (inclusive) in the format of `YYYY-MM-DD`. This may be ignored depending on the `type` of the calendar.",
16-
"weekdayFormat": "Formats day of the week string that appears in the header to specified locale.",
1716
"weekdays": "Specifies which days of the week to display. To display Monday through Friday only, a value of `[1, 2, 3, 4, 5]` can be used. To display a week starting on Monday a value of `[1, 2, 3, 4, 5, 6, 0]` can be used."
1817
}
1918
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"type": "Determines the type of the picker - `date` for date picker, `month` for month picker.",
4141
"value": "Date picker model (ISO 8601 format, YYYY-mm-dd or YYYY-mm).",
4242
"viewMode": "Determines which picker in the date or month picker is being displayed. Allowed values: `'month'`, `'months'`, `'year'`.",
43-
"weekdayFormat": "Allows you to customize the format of the weekday string that appears in the body of the calendar. Called with date (ISO 8601 **date** string) arguments.",
4443
"width": "Width of the picker.",
4544
"yearFormat": "Allows you to customize the format of the year string that appears in the header of the calendar. Called with date (ISO 8601 **date** string) arguments.",
4645
"yearIcon": "Sets the icon in the year selection button."

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"trueValue": "Sets value for truthy state.",
6363
"valueComparator": "Apply a custom comparison algorithm to compare **model-value** and values contains in the **items** prop.",
6464
"variant": "Applies a distinct style to the component.",
65+
"weekdayFormat": "Allows you to customize the format of the weekday string that appears in the body of the calendar. Uses `'narrow'` by default. (Note: not guaranteed to work when using custom date adapters.)",
6566
"width": "Sets the width for the component."
6667
},
6768
"slots": {

packages/vuetify/src/components/VDatePicker/VDatePickerMonth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const VDatePickerMonth = genericComponent<VDatePickerMonthSlots>()({
175175
key={ daysInMonth.value[0].date?.toString() }
176176
class="v-date-picker-month__days"
177177
>
178-
{ !props.hideWeekdays && adapter.getWeekdays(props.firstDayOfWeek).map(weekDay => (
178+
{ !props.hideWeekdays && adapter.getWeekdays(props.firstDayOfWeek, props.weekdayFormat).map(weekDay => (
179179
<div
180180
class={[
181181
'v-date-picker-month__day',

packages/vuetify/src/composables/calendar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const makeCalendarProps = propsFactory({
7878
type: [Number, String],
7979
default: undefined,
8080
},
81+
weekdayFormat: String as PropType<'long' | 'short' | 'narrow' | undefined>,
8182
}, 'calendar')
8283

8384
export function useCalendar (props: CalendarProps) {

packages/vuetify/src/composables/date/DateAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface DateAdapter<T = unknown> {
3636
setYear (date: T, year: number): T
3737
getDiff (date: T, comparing: T | string, unit?: string): number
3838
getWeekArray (date: T, firstDayOfWeek?: number | string): T[][]
39-
getWeekdays (firstDayOfWeek?: number | string): string[]
39+
getWeekdays (firstDayOfWeek?: number | string, weekdayFormat?: 'long' | 'short' | 'narrow'): string[]
4040
getWeek (date: T, firstDayOfWeek?: number | string, firstWeekMinSize?: number): number
4141
getMonth (date: T): number
4242
setMonth (date: T, month: number): T

packages/vuetify/src/composables/date/adapters/vuetify.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ function date (value?: any): Date | null {
142142

143143
const sundayJanuarySecond2000 = new Date(2000, 0, 2)
144144

145-
function getWeekdays (locale: string, firstDayOfWeek?: number) {
145+
function getWeekdays (locale: string, firstDayOfWeek?: number, weekdayFormat?: 'long' | 'short' | 'narrow') {
146146
const daysFromSunday = firstDayOfWeek ?? weekInfo(locale)?.firstDay ?? 0
147147

148148
return createRange(7).map(i => {
149149
const weekday = new Date(sundayJanuarySecond2000)
150150
weekday.setDate(sundayJanuarySecond2000.getDate() + daysFromSunday + i)
151-
return new Intl.DateTimeFormat(locale, { weekday: 'narrow' }).format(weekday)
151+
return new Intl.DateTimeFormat(locale, { weekday: weekdayFormat ?? 'narrow' }).format(weekday)
152152
})
153153
}
154154

@@ -597,9 +597,9 @@ export class VuetifyDateAdapter implements DateAdapter<Date> {
597597
return getDiff(date, comparing, unit)
598598
}
599599

600-
getWeekdays (firstDayOfWeek?: number | string) {
600+
getWeekdays (firstDayOfWeek?: number | string, weekdayFormat?: 'long' | 'short' | 'narrow') {
601601
const firstDay = firstDayOfWeek !== undefined ? Number(firstDayOfWeek) : undefined
602-
return getWeekdays(this.locale, firstDay)
602+
return getWeekdays(this.locale, firstDay, weekdayFormat)
603603
}
604604

605605
getYear (date: Date) {

0 commit comments

Comments
 (0)