Skip to content

Commit

Permalink
build(types): add missing Locale imports (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl authored Oct 18, 2023
1 parent db260be commit 80aa63e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/contexts/DayPicker/DayPickerContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createContext, ReactNode, useContext } from 'react';

import { Locale } from 'date-fns';
import { DayPickerProps } from 'DayPicker';

import { CaptionLayout } from 'components/Caption';
Expand Down
3 changes: 1 addition & 2 deletions src/contexts/DayPicker/formatters/formatDay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Locale } from 'date-fns';
import { format } from 'date-fns';
import { format, Locale } from 'date-fns';

/**
* The default formatter for the Day button.
Expand Down
3 changes: 1 addition & 2 deletions src/contexts/DayPicker/formatters/formatMonthCaption.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Locale } from 'date-fns';
import { format } from 'date-fns';
import { format, Locale } from 'date-fns';

/**
* The default formatter for the Month caption.
Expand Down
3 changes: 1 addition & 2 deletions src/contexts/DayPicker/formatters/formatWeekdayName.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Locale } from 'date-fns';
import { format } from 'date-fns';
import { format, Locale } from 'date-fns';

/**
* The default formatter for the name of the weekday.
Expand Down
6 changes: 4 additions & 2 deletions src/contexts/DayPicker/formatters/formatYearCaption.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { format } from 'date-fns';
import { format, Locale } from 'date-fns';

/**
* The default formatter for the Year caption.
*/
export function formatYearCaption(
year: Date,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
): string {
return format(year, 'yyyy', options);
}
4 changes: 2 additions & 2 deletions src/types/DayPickerBase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Locale } from 'date-fns';

import { CSSProperties, ReactNode } from 'react';

import { Locale } from 'date-fns';

import { CaptionLayout, CaptionProps } from 'components/Caption';
import { CaptionLabelProps } from 'components/CaptionLabel';
import { DayProps } from 'components/Day';
Expand Down
10 changes: 8 additions & 2 deletions src/types/Formatters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { ReactNode } from 'react';

import { Locale } from 'date-fns';

/** Represents a function to format a date. */
export type DateFormatter = (
date: Date,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
) => ReactNode;

/** Represent a map of formatters used to render localized content. */
Expand All @@ -25,5 +29,7 @@ export type Formatters = {
/** Represent a function to format the week number. */
export type WeekNumberFormatter = (
weekNumber: number,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
) => ReactNode;
21 changes: 16 additions & 5 deletions src/types/Labels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Locale } from 'date-fns';
import { Locale } from 'date-fns';

import { ActiveModifiers } from 'types/Modifiers';

Expand All @@ -18,20 +18,31 @@ export type Labels = {
export type DayLabel = (
day: Date,
activeModifiers: ActiveModifiers,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
) => string;

/** Return the ARIA label for the "next month" / "prev month" buttons in the navigation.*/
export type NavButtonLabel = (
month?: Date,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
) => string;

/** Return the ARIA label for the Head component.*/
export type WeekdayLabel = (day: Date, options?: { locale?: Locale }) => string;
export type WeekdayLabel = (
day: Date,
options?: {
locale?: Locale;
}
) => string;

/** Return the ARIA label of the week number.*/
export type WeekNumberLabel = (
n: number,
options?: { locale?: Locale }
options?: {
locale?: Locale;
}
) => string;

0 comments on commit 80aa63e

Please sign in to comment.