Skip to content

Commit

Permalink
feat: auto inject the calendar direction
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 16, 2025
1 parent bb2df4d commit 3d80828
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/useCalendar/useCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ export interface CalendarProps {

export function useCalendar(_props: Reactivify<CalendarProps, 'field' | 'schema'>) {
const props = normalizeProps(_props, ['field', 'schema']);
const { weekInfo, locale, calendar, timeZone } = useLocale(props.locale, {
const { weekInfo, locale, calendar, timeZone, direction } = useLocale(props.locale, {
calendar: () => toValue(props.calendar),
timeZone: () => toValue(props.timeZone),
});

const pickerContext = inject(PickerContextKey, null);
const calendarId = useUniqId(FieldTypePrefixes.Calendar);
const gridId = `${calendarId}-g`;
Expand Down Expand Up @@ -260,6 +261,7 @@ export function useCalendar(_props: Reactivify<CalendarProps, 'field' | 'schema'
id: calendarId,
...pickerHandlers,
role: 'application',
dir: direction.value,
},
calendarEl,
);
Expand Down
6 changes: 4 additions & 2 deletions packages/playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import DateField from '@/components/DateField.vue';
import Calendar from './components/Calendar.vue';
// import { createCalendar } from '@internationalized/date';
import { createCalendar } from '@internationalized/date';
const minDate = new Date(2025, 1, 14, 0, 0, 0, 0);
const maxDate = new Date(2025, 1, 18, 0, 0, 0, 0);
const islamic = createCalendar('islamic-umalqura');
</script>

<template>
Expand All @@ -23,6 +25,6 @@ const maxDate = new Date(2025, 1, 18, 0, 0, 0, 0);
}"
/> -->

<Calendar label="Pick a date" :model-value="new Date('2025-09-16')" />
<Calendar label="Pick a date" locale="ar-EG" :calendar="islamic" />
</div>
</template>

0 comments on commit 3d80828

Please sign in to comment.