1 | import React from 'react';
|
2 | import { ProcessedMessages, UserProvidedMessages } from './messages';
|
3 | export declare type DateTimePartType = 'day' | 'dayPeriod' | 'era' | 'hour' | 'literal' | 'minute' | 'month' | 'second' | 'weekday' | 'year' | 'millisecond';
|
4 | export declare type DateTimePart = {
|
5 | type: DateTimePartType;
|
6 | value: string;
|
7 | };
|
8 | export declare type RequiredDateMethods = 'date' | 'time' | 'datetime' | 'header' | 'weekday' | 'dayOfMonth' | 'month' | 'year' | 'decade' | 'century';
|
9 | export declare type DateLocalizer<TD> = {
|
10 | parse(dateString: string, format?: TD): Date | null;
|
11 | firstOfWeek(): number;
|
12 | } & {
|
13 | [Key in RequiredDateMethods]: (date: Date, format?: TD) => string;
|
14 | };
|
15 | export interface NumberLocalizer<TN> {
|
16 | parse(numberString: string, format?: TN): number | null;
|
17 | decimalCharacter(): string;
|
18 | format(value: number, format?: TN): string;
|
19 | }
|
20 | export interface Localizer<TD = unknown, TN = unknown> {
|
21 | formatOverrides: FormatterOverrides<TD, TN>;
|
22 | messages: ProcessedMessages;
|
23 | formatDate(value: Date, formatter: RequiredDateMethods, userFormat?: TD): string;
|
24 | formatNumber(value: number, userFormat?: TN): string;
|
25 | parseDate(dateString: string, format?: TD): Date | null;
|
26 | parseNumber(numberString: string, format?: TN): number | null;
|
27 | firstOfWeek(): number;
|
28 | decimalCharacter(): string;
|
29 | }
|
30 | export declare type DateFormats<TFormat> = {
|
31 | [Key in RequiredDateMethods]?: TFormat;
|
32 | };
|
33 | export declare type FormatterOverrides<TD, TN> = DateFormats<TD> & {
|
34 | number?: TN;
|
35 | };
|
36 | declare type ProviderProps = {
|
37 | date?: DateLocalizer<any>;
|
38 | number?: NumberLocalizer<any>;
|
39 | messages?: UserProvidedMessages;
|
40 | children?: React.ReactNode;
|
41 | };
|
42 | declare const Localization: {
|
43 | ({ date, number, messages, children, }: ProviderProps): JSX.Element;
|
44 | useLocalizer: (messages?: Partial<import("./messages").Messages> | undefined, formats?: FormatterOverrides<any, any> | undefined) => Localizer<unknown, unknown>;
|
45 | };
|
46 | export declare const useLocalizer: (messages?: Partial<import("./messages").Messages> | undefined, formats?: FormatterOverrides<any, any> | undefined) => Localizer<unknown, unknown>;
|
47 | export default Localization;
|
48 |
|
\ | No newline at end of file |