import type { Locale } from "date-fns"; import { vi as viDayPicker } from "react-day-picker/locale"; import type { AppLocale } from "./types.js"; export { getRegisteredLocales, resolveRegisteredLocale, resolveDefaultLocale, resolvePageLocale, } from "../i18n/locale-tags.js"; /** A react-day-picker locale: a date-fns `Locale` plus optional `labels`. */ export type DayPickerLocale = typeof viDayPicker; export type AppLocaleConfig = { code: AppLocale; dateFns: Locale; dayPicker: DayPickerLocale; }; /** * What `registerLocale` takes. Only `code` is required: without `dateFns` the date adapter is built * from `Intl` (month/weekday names, long date patterns, week start), and without `dayPicker` the * calendar uses that same adapter. */ export type RegisterLocaleInput = { /** Any BCP-47 tag — `de`, `pt-BR`, `en-GB`, `ar`. Canonicalised (`pt-br` → `pt-BR`). */ code: string; /** This locale's strings. For a locale the library does not ship, its own namespaces too. */ messages?: Record; /** A date-fns locale (`import { de } from "date-fns/locale"`). */ dateFns?: Locale; /** A react-day-picker locale (`import { de } from "react-day-picker/locale"`). */ dayPicker?: DayPickerLocale; }; /** * First day of the week for `code`, as date-fns counts it (0 = Sunday … 6 = Saturday). * * From `Intl.Locale#getWeekInfo` (or the older `.weekInfo` getter) where the engine has it; else * the pack's own `weekStartsOn`; else the region's CLDR first day, Monday (ISO 8601) by default. */ export declare function getLocaleWeekStart(code: string, pack?: Pick): 0 | 1 | 2 | 3 | 4 | 5 | 6; /** * Every registered locale's date adapters. `vi`, `en` and `ja` are pre-registered with the packs * they always had; `registerLocale` adds the rest. Exported for compatibility — read it through * `getDateFnsLocale` / `getDayPickerLocale`, which also handle an unregistered tag. */ export declare const APP_LOCALE_CONFIG: Record; /** The three locales the library ships packs for. */ export declare const BUILT_IN_LOCALES: readonly ["vi", "en", "ja"]; /** * REGISTER A LOCALE — any BCP-47 tag (v32, gh#1219). * * The locale set used to be a closed union of three, so a German or Brazilian app could not get * German dates or a Monday/Sunday week from this package at all. Register once at startup, before * the first render: * * ```ts * import { de } from "date-fns/locale"; * import { de as deDayPicker } from "react-day-picker/locale"; * registerLocale({ code: "de", messages: deMessages, dateFns: de, dayPicker: deDayPicker }); * ``` * * Registering an already-registered tag updates it (messages merge; adapters given replace). * Returns the canonical tag. */ export declare function registerLocale(input: RegisterLocaleInput): AppLocale; /** Whether `value` is a REGISTERED locale tag (exactly, after canonicalisation). */ export declare function isAppLocale(value: string | null | undefined): value is AppLocale; /** * The registered locale that serves `tag` (`de-AT` → `de`), or — with one development warning — * the default locale (`` if registered, else `en`). */ export declare function normalizeAppLocale(tag: string | null | undefined): AppLocale; export declare function getDateFnsLocale(locale: AppLocale): Locale; export declare function getDayPickerLocale(locale: AppLocale): DayPickerLocale;