@stenajs-webui/calendar 21.13.0 → 21.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,9 @@ import { HeadingVariant } from "@stenajs-webui/core";
3
3
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
4
4
  import { TravelCalendarSizeVariant } from "../../../features/travel-calendar/components/TravelCalendar";
5
5
  import { DateTextInputVariant } from "../../../features/travel-calendar/types";
6
+ import { SupportedLocaleCode } from "../../../features/localize-date-format/LocaleMapper";
6
7
  export interface TravelDateCalendarProps extends ValueAndOnValueChangeProps<string> {
7
- localeCode?: string;
8
+ localeCode?: SupportedLocaleCode;
8
9
  initialMonthInFocus?: Date;
9
10
  label?: string;
10
11
  previousMonthButtonAriaLabel?: string;
@@ -3,8 +3,9 @@ import { HeadingVariant } from "@stenajs-webui/core";
3
3
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
4
4
  import { TravelCalendarSizeVariant } from "../../../features/travel-calendar/components/TravelCalendar";
5
5
  import { DateTextInputVariant, TravelDateRangeInputValue } from "../../../features/travel-calendar/types";
6
+ import { SupportedLocaleCode } from "../../../features/localize-date-format/LocaleMapper";
6
7
  export interface TravelDateRangeCalendarProps extends ValueAndOnValueChangeProps<TravelDateRangeInputValue> {
7
- localeCode?: string;
8
+ localeCode?: SupportedLocaleCode;
8
9
  initialMonthInFocus?: Date;
9
10
  startDateLabel?: string;
10
11
  endDateLabel?: string;
@@ -4,11 +4,12 @@ import { HeadingVariant } from "@stenajs-webui/core";
4
4
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
5
5
  import { TravelCalendarSizeVariant } from "../../../features/travel-calendar/components/TravelCalendar";
6
6
  import { DateTextInputVariant } from "../../../features/travel-calendar/types";
7
+ import { SupportedLocaleCode } from "../../../features/localize-date-format/LocaleMapper";
7
8
  export interface RenderBelowSingleDateCalendarArgs {
8
9
  hideCalendar: () => void;
9
10
  }
10
11
  export interface TravelDateInputProps extends ValueAndOnValueChangeProps<string> {
11
- localeCode?: string;
12
+ localeCode?: SupportedLocaleCode;
12
13
  initialMonthInFocus?: Date;
13
14
  label?: string;
14
15
  previousMonthButtonAriaLabel?: string;
@@ -4,11 +4,12 @@ import { HeadingVariant } from "@stenajs-webui/core";
4
4
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
5
5
  import { TravelCalendarSizeVariant } from "../../../features/travel-calendar/components/TravelCalendar";
6
6
  import { DateTextInputVariant, TravelDateRangeInputValue } from "../../../features/travel-calendar/types";
7
+ import { SupportedLocaleCode } from "../../../features/localize-date-format/LocaleMapper";
7
8
  export interface RenderBelowCalendarArgs {
8
9
  hideCalendar: () => void;
9
10
  }
10
11
  export interface TravelDateRangeInputProps extends ValueAndOnValueChangeProps<TravelDateRangeInputValue> {
11
- localeCode?: string;
12
+ localeCode?: SupportedLocaleCode;
12
13
  initialMonthInFocus?: Date;
13
14
  startDateLabel?: string;
14
15
  endDateLabel?: string;
@@ -1 +1,2 @@
1
- export declare const getDateFormatForLocaleCode: (locale: string) => string;
1
+ import { SupportedLocaleCode } from "./LocaleMapper";
2
+ export declare const getDateFormatForLocaleCode: (localeCode: SupportedLocaleCode) => string;
@@ -1,9 +1,14 @@
1
1
  import { Locale } from "date-fns";
2
- export declare const getLocaleForLocaleCode: (localeCode: string) => Locale | undefined;
2
+ export type SupportedLocaleCode = "en-US" | "en-IE" | "en-GB" | "de-AT" | "de-DE" | "sv-SE" | "da-DK" | "nl-BE" | "lv-LV" | "fr" | "de" | "es" | "sv" | "pl" | "lv" | "da" | "nl" | "nb";
3
+ export declare const fallbackLocaleCode: SupportedLocaleCode;
4
+ export declare const fallbackLocaleCodeForFormatting: SupportedLocaleCode;
5
+ export declare const getSupportedLocaleCode: (localeCode: string, matchLanguage: boolean, fallback: SupportedLocaleCode) => SupportedLocaleCode;
6
+ export declare const getLocaleForLocaleCode: (localeCode: SupportedLocaleCode) => Locale;
7
+ export declare const getSupportedLocaleCodeMatchingLanguage: (localeCode: string) => SupportedLocaleCode | undefined;
3
8
  export declare const getDefaultLocaleForFormatting: () => Locale;
4
9
  /**
5
10
  * This is only used by old calendar components, to pass localeCode to updated components.
6
11
  * All updated calendar components just take localeCode, for example "en-GB", since that is what the browser provides,
7
12
  * and is not library dependent.
8
13
  */
9
- export declare const getLocaleCodeForLocale: (locale: Locale) => string | undefined;
14
+ export declare const getLocaleCodeForLocale: (locale: Locale) => SupportedLocaleCode | undefined;
@@ -1 +1,6 @@
1
- export declare const formatLocalizedDate: (date: Date, localeCode: string) => string;
1
+ import { SupportedLocaleCode } from "./LocaleMapper";
2
+ export interface FormatLocalizedDateOptions {
3
+ matchLanguage?: boolean;
4
+ fallbackLocaleCode?: SupportedLocaleCode;
5
+ }
6
+ export declare const formatLocalizedDate: (date: Date, localeCode: string, options?: FormatLocalizedDateOptions) => string;
@@ -1 +1,8 @@
1
- export declare const parseLocalizedDateString: (dateString: string, localeCode: string, referenceDate?: Date) => Date | undefined;
1
+ import { SupportedLocaleCode } from "./LocaleMapper";
2
+ interface ParseLocalizedDateStringOptions {
3
+ matchLanguage?: boolean;
4
+ fallbackLocaleCode?: SupportedLocaleCode;
5
+ referenceDate?: Date;
6
+ }
7
+ export declare const parseLocalizedDateString: (dateString: string, localeCode: string, options?: ParseLocalizedDateStringOptions) => Date | undefined;
8
+ export {};
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
3
+ import { SupportedLocaleCode } from "../localize-date-format/LocaleMapper";
3
4
  export type MonthPickerSizeVariant = "small" | "medium" | "large";
4
5
  export interface MonthPickerProps extends ValueAndOnValueChangeProps<Date> {
5
- localeCode: string;
6
+ localeCode: SupportedLocaleCode;
6
7
  firstMonth: Date;
7
8
  numMonths: number;
8
9
  onCancel?: () => void;
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { Position } from "./Position";
3
3
  import { MonthPickerSizeVariant } from "./MonthPicker";
4
+ import { SupportedLocaleCode } from "../localize-date-format/LocaleMapper";
4
5
  interface MonthPickerCellProps {
5
6
  month: Date;
6
7
  onClick: () => void;
7
8
  selected: boolean;
8
- localeCode: string;
9
+ localeCode: SupportedLocaleCode;
9
10
  autoFocus: boolean;
10
11
  monthPickerId: string;
11
12
  firstAvailableMonth: Date;
@@ -1,10 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { DateTextInputVariant, TravelDateRangeInputValue } from "../types";
3
3
  import { TravelCalendarSizeVariant } from "./TravelCalendar";
4
+ import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
4
5
  export interface TravelDateRangeTextInputFieldsProps {
5
6
  value: TravelDateRangeInputValue | undefined;
6
7
  onValueChange: ((value: Partial<TravelDateRangeInputValue>) => void) | undefined;
7
- localeCode: string;
8
+ localeCode: SupportedLocaleCode;
8
9
  startDateLabel?: string;
9
10
  endDateLabel?: string;
10
11
  onFocus?: () => void;
@@ -1,10 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { TravelCalendarSizeVariant } from "./TravelCalendar";
3
3
  import { DateTextInputVariant } from "../types";
4
+ import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
4
5
  export interface TravelDateTextInputFieldProps {
5
6
  value: string | undefined;
6
7
  onValueChange: ((value: string) => void) | undefined;
7
- localeCode: string;
8
+ localeCode: SupportedLocaleCode;
8
9
  label?: string;
9
10
  onFocus?: () => void;
10
11
  calendarSize: TravelCalendarSizeVariant;
@@ -1,5 +1,6 @@
1
+ import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
1
2
  import { VisiblePanel } from "../types";
2
- export declare const useTravelDateInput: (value: string | undefined, onValueChange: ((value: string) => void) | undefined, localeCode: string, initialMonthInFocus: Date | undefined) => {
3
+ export declare const useTravelDateInput: (value: string | undefined, onValueChange: ((value: string) => void) | undefined, localeCode: SupportedLocaleCode, initialMonthInFocus: Date | undefined) => {
3
4
  isDateDisabled: (date: Date) => boolean;
4
5
  onClickDate: (date: Date) => void;
5
6
  onValueChangeByInputs: (value: string) => void;
@@ -1,5 +1,6 @@
1
+ import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
1
2
  import { TravelDateRangeInputValue, VisiblePanel } from "../types";
2
- export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue | undefined, onValueChange: ((value: TravelDateRangeInputValue) => void) | undefined, localeCode: string, initialMonthInFocus: Date | undefined) => {
3
+ export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue | undefined, onValueChange: ((value: TravelDateRangeInputValue) => void) | undefined, localeCode: SupportedLocaleCode, initialMonthInFocus: Date | undefined) => {
3
4
  isDateDisabled: (date: Date) => boolean;
4
5
  onClickDate: (date: Date) => void;
5
6
  onValueChangeByInputs: (value: TravelDateRangeInputValue) => void;