@stenajs-webui/calendar 20.11.6 → 20.13.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.
Files changed (34) hide show
  1. package/dist/components/calendar-types/travel-date-calendar/TravelDateCalendar.d.ts +15 -0
  2. package/dist/components/calendar-types/travel-date-range-calendar/TravelDateRangeCalendar.d.ts +17 -0
  3. package/dist/components/input-types/travel-date-input/TravelDateInput.d.ts +23 -0
  4. package/dist/components/input-types/travel-date-range-input/TravelDateRangeInput.d.ts +25 -0
  5. package/dist/features/localize-date-format/InputMaskProvider.d.ts +4 -0
  6. package/dist/features/localize-date-format/LocaleMapper.d.ts +1 -0
  7. package/dist/features/localize-date-format/LocalizedDateParser.d.ts +1 -1
  8. package/dist/features/localize-date-format/LocalizedDateReformatter.d.ts +1 -0
  9. package/dist/features/month-picker/MonthPicker.d.ts +2 -7
  10. package/dist/features/month-picker/MonthPickerCell.d.ts +7 -3
  11. package/dist/features/month-picker/MonthPickerDataFactory.d.ts +21 -0
  12. package/dist/features/month-picker/MonthPickerKeyboardNavigation.d.ts +4 -0
  13. package/dist/features/month-picker/Position.d.ts +8 -0
  14. package/dist/features/travel-calendar/components/MonthHeader.d.ts +15 -0
  15. package/dist/features/travel-calendar/components/TravelCalendar.d.ts +19 -0
  16. package/dist/features/travel-calendar/components/TravelDateCell.d.ts +19 -0
  17. package/dist/features/travel-calendar/components/TravelDateSingleTextInputField.d.ts +9 -0
  18. package/dist/features/travel-calendar/components/TravelDateTextInput.d.ts +12 -0
  19. package/dist/features/travel-calendar/components/TravelDateTextInputFields.d.ts +11 -0
  20. package/dist/features/travel-calendar/hooks/UseTravelDateInput.d.ts +21 -0
  21. package/dist/features/travel-calendar/hooks/UseTravelDateRangeInput.d.ts +23 -0
  22. package/dist/features/travel-calendar/types.d.ts +5 -0
  23. package/dist/features/travel-calendar/util/CellBgColors.d.ts +4 -0
  24. package/dist/features/travel-calendar/util/DayIdGenerator.d.ts +1 -0
  25. package/dist/features/travel-calendar/util/KeyboardNavigation.d.ts +1 -0
  26. package/dist/features/travel-calendar/util/UseToday.d.ts +1 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.es.js +2479 -1412
  29. package/dist/index.es.js.map +1 -1
  30. package/dist/index.js +2 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/types/CalendarTypes.d.ts +2 -3
  33. package/dist/util/calendar/CalendarDataFactory.d.ts +1 -0
  34. package/package.json +8 -7
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { HeadingVariant } from "@stenajs-webui/core";
3
+ import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
4
+ export interface TravelDateCalendarProps extends ValueAndOnValueChangeProps<string> {
5
+ localeCode?: string;
6
+ initialMonthInFocus?: Date;
7
+ label?: string;
8
+ previousMonthButtonAriaLabel?: string;
9
+ nextMonthButtonAriaLabel?: string;
10
+ heading?: string;
11
+ headingLevel?: HeadingVariant;
12
+ firstMonthInMonthPicker?: Date;
13
+ numMonthsInMonthPicker?: number;
14
+ }
15
+ export declare const TravelDateCalendar: React.FC<TravelDateCalendarProps>;
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { HeadingVariant } from "@stenajs-webui/core";
3
+ import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
4
+ import { TravelDateRangeInputValue } from "../../../features/travel-calendar/types";
5
+ export interface TravelDateRangeCalendarProps extends ValueAndOnValueChangeProps<TravelDateRangeInputValue> {
6
+ localeCode?: string;
7
+ initialMonthInFocus?: Date;
8
+ startDateLabel?: string;
9
+ endDateLabel?: string;
10
+ previousMonthButtonAriaLabel?: string;
11
+ nextMonthButtonAriaLabel?: string;
12
+ heading?: string;
13
+ headingLevel?: HeadingVariant;
14
+ firstMonthInMonthPicker?: Date;
15
+ numMonthsInMonthPicker?: number;
16
+ }
17
+ export declare const TravelDateRangeCalendar: React.FC<TravelDateRangeCalendarProps>;
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { ReactNode } from "react";
3
+ import { HeadingVariant } from "@stenajs-webui/core";
4
+ import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
5
+ export interface RenderBelowSingleDateCalendarArgs {
6
+ hideCalendar: () => void;
7
+ }
8
+ export interface TravelDateInputProps extends ValueAndOnValueChangeProps<string> {
9
+ localeCode?: string;
10
+ initialMonthInFocus?: Date;
11
+ label?: string;
12
+ previousMonthButtonAriaLabel?: string;
13
+ nextMonthButtonAriaLabel?: string;
14
+ heading?: string;
15
+ headingLevel?: HeadingVariant;
16
+ firstMonthInMonthPicker?: Date;
17
+ numMonthsInMonthPicker?: number;
18
+ zIndex?: number;
19
+ zIndexWhenClosed?: number;
20
+ onHideCalendar?: () => void;
21
+ renderBelowCalendar?: (args: RenderBelowSingleDateCalendarArgs) => ReactNode;
22
+ }
23
+ export declare const TravelDateInput: React.FC<TravelDateInputProps>;
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { ReactNode } from "react";
3
+ import { HeadingVariant } from "@stenajs-webui/core";
4
+ import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
5
+ import { TravelDateRangeInputValue } from "../../../features/travel-calendar/types";
6
+ export interface RenderBelowCalendarArgs {
7
+ hideCalendar: () => void;
8
+ }
9
+ export interface TravelDateRangeInputProps extends ValueAndOnValueChangeProps<TravelDateRangeInputValue> {
10
+ localeCode?: string;
11
+ initialMonthInFocus?: Date;
12
+ startDateLabel?: string;
13
+ endDateLabel?: string;
14
+ previousMonthButtonAriaLabel?: string;
15
+ nextMonthButtonAriaLabel?: string;
16
+ heading?: string;
17
+ headingLevel?: HeadingVariant;
18
+ firstMonthInMonthPicker?: Date;
19
+ numMonthsInMonthPicker?: number;
20
+ zIndex?: number;
21
+ zIndexWhenClosed?: number;
22
+ onHideCalendar?: () => void;
23
+ renderBelowCalendar?: (args: RenderBelowCalendarArgs) => ReactNode;
24
+ }
25
+ export declare const TravelDateRangeInput: React.FC<TravelDateRangeInputProps>;
@@ -0,0 +1,4 @@
1
+ export declare const yearMask: RegExp[];
2
+ export declare const monthMask: RegExp[];
3
+ export declare const dayMask: RegExp[];
4
+ export declare const createInputMaskForDateFormat: (dateFormat: string) => Array<string | RegExp>;
@@ -1,2 +1,3 @@
1
1
  import { Locale } from "date-fns";
2
2
  export declare const getLocaleForLocaleCode: (localeCode: string) => Locale | undefined;
3
+ export declare const getDefaultLocaleForFormatting: () => Locale;
@@ -1 +1 @@
1
- export declare const parseLocalizedDateString: (dateString: string, localeCode: string, referenceDate?: Date) => Date;
1
+ export declare const parseLocalizedDateString: (dateString: string, localeCode: string, referenceDate?: Date) => Date | undefined;
@@ -0,0 +1 @@
1
+ export declare const reformatLocalizedDateString: (dateString: string, locale: string) => string | undefined;
@@ -1,15 +1,10 @@
1
1
  import * as React from "react";
2
- import { Month } from "../../util/calendar/CalendarDataFactory";
3
2
  import { ValueAndOnValueChangeProps } from "@stenajs-webui/forms";
4
3
  import { Locale } from "date-fns";
5
- export interface MonthPickerValue {
6
- month: Month;
7
- year: number;
8
- }
9
- export interface MonthPickerProps extends ValueAndOnValueChangeProps<MonthPickerValue> {
4
+ export interface MonthPickerProps extends ValueAndOnValueChangeProps<Date> {
10
5
  locale?: Locale;
11
6
  firstMonth: Date;
12
7
  numMonths: number;
8
+ onCancel?: () => void;
13
9
  }
14
10
  export declare const MonthPicker: React.FC<MonthPickerProps>;
15
- export declare const createFirstDate: (date: Date) => MonthPickerValue;
@@ -1,12 +1,16 @@
1
1
  import * as React from "react";
2
2
  import { Locale } from "date-fns";
3
- import { Month } from "../../util/calendar/CalendarDataFactory";
3
+ import { Position } from "./Position";
4
4
  interface MonthPickerCellProps {
5
- year: number;
6
- month: Month;
5
+ month: Date;
7
6
  onClick: () => void;
8
7
  selected: boolean;
9
8
  locale: Locale;
9
+ autoFocus: boolean;
10
+ monthPickerId: string;
11
+ firstAvailableMonth: Date;
12
+ lastAvailableMonth: Date;
13
+ position: Position;
10
14
  }
11
15
  export declare const MonthPickerCell: React.FC<MonthPickerCellProps>;
12
16
  export {};
@@ -0,0 +1,21 @@
1
+ import { Position } from "./Position";
2
+ export interface MonthInput {
3
+ yearOrder: Array<number>;
4
+ years: Record<number, YearInput>;
5
+ rows: Array<RowInput>;
6
+ lastMonthRow: number;
7
+ lastMonthColumn: number;
8
+ }
9
+ export interface YearInput {
10
+ year: number;
11
+ rows: Array<number>;
12
+ }
13
+ export interface RowInput {
14
+ rowIndex: number;
15
+ columns: Array<Columns>;
16
+ }
17
+ export interface Columns {
18
+ position: Position;
19
+ month: Date;
20
+ }
21
+ export declare const createMonths: (firstMonth: Date, numMonths: number, numColumnsPerRow: number) => MonthInput;
@@ -0,0 +1,4 @@
1
+ import { Position } from "./Position";
2
+ export declare const getDomIdForMonth: (position: Position, monthPickerId: string) => string;
3
+ export declare const getDomIdForKeyboardKey: (key: string, currentPosition: Position, monthPickerId: string, numColumnsPerRow: number) => string | undefined;
4
+ export declare const movePositionByKey: (currentPosition: Position, key: string, numColumnsPerRow: number) => Position;
@@ -0,0 +1,8 @@
1
+ export interface Position {
2
+ row: number;
3
+ column: number;
4
+ }
5
+ export declare const moveLeft: (position: Position, numColumnsPerRow: number) => Position;
6
+ export declare const moveRight: (position: Position, numColumnsPerRow: number) => Position;
7
+ export declare const moveUp: (position: Position) => Position;
8
+ export declare const moveDown: (position: Position) => Position;
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { Ref } from "react";
3
+ import { VisiblePanel } from "../types";
4
+ export interface MonthHeaderProps {
5
+ monthPickerButtonLabel: string;
6
+ nextMonthButtonAriaLabel: string;
7
+ previousMonthButtonAriaLabel: string;
8
+ visiblePanel: VisiblePanel;
9
+ setVisiblePanel: (panel: VisiblePanel) => void;
10
+ monthPickerButtonRef: Ref<HTMLButtonElement>;
11
+ visibleMonth: Date;
12
+ setVisibleMonth: (date: Date) => void;
13
+ prevMonthDisabled: boolean;
14
+ }
15
+ export declare const MonthHeader: React.FC<MonthHeaderProps>;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { MonthData } from "../../../util/calendar/CalendarDataFactory";
3
+ import { Dispatch, SetStateAction } from "react";
4
+ export interface TravelCalendarProps {
5
+ visibleMonthData: MonthData;
6
+ onClickDate: (date: Date) => void;
7
+ visibleMonth: Date;
8
+ setVisibleMonth: (visibleMonth: Date) => void;
9
+ isValidDateRange: boolean;
10
+ setHoverDate: Dispatch<SetStateAction<Date | undefined>>;
11
+ selectedStartDate: Date | undefined;
12
+ selectedEndDate: Date | undefined;
13
+ hoverDate: Date | undefined;
14
+ today: Date;
15
+ isDateDisabled: (date: Date) => boolean;
16
+ calendarId: string;
17
+ todayIsInVisibleMonth: boolean;
18
+ }
19
+ export declare const TravelCalendar: React.FC<TravelCalendarProps>;
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { DayData } from "../../../util/calendar/CalendarDataFactory";
3
+ export interface TravelDateCellProps {
4
+ onClick: (date: Date) => void;
5
+ day: DayData;
6
+ visibleMonth: Date;
7
+ selectedStartDate: Date | undefined;
8
+ selectedEndDate: Date | undefined;
9
+ isValidDateRange: boolean;
10
+ onChangeVisibleMonth: (visibleMonth: Date) => void;
11
+ onStartHover: (date: Date) => void;
12
+ onEndHover: (date: Date) => void;
13
+ hoverDate: Date | undefined;
14
+ today: Date;
15
+ todayIsInVisibleMonth: boolean;
16
+ calendarId: string;
17
+ isDateDisabled: (date: Date) => boolean;
18
+ }
19
+ export declare const TravelDateCell: React.FC<TravelDateCellProps>;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ export interface TravelDateSingleTextInputFieldProps {
3
+ value: string | undefined;
4
+ onValueChange: ((value: string) => void) | undefined;
5
+ localeCode: string;
6
+ label?: string;
7
+ onFocus?: () => void;
8
+ }
9
+ export declare const TravelDateSingleTextInputField: React.FC<TravelDateSingleTextInputFieldProps>;
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import { LabelledTextInputProps } from "@stenajs-webui/forms";
3
+ import { InputMask, InputMaskPipe, InputMaskProvider } from "@stenajs-webui/input-mask";
4
+ export interface TravelDateTextInputProps extends LabelledTextInputProps {
5
+ mask: InputMask | InputMaskProvider;
6
+ pipe?: InputMaskPipe;
7
+ guide?: boolean;
8
+ keepCharPositions?: boolean;
9
+ placeholderChar?: string;
10
+ showMask?: boolean;
11
+ }
12
+ export declare const TravelDateTextInput: React.FC<TravelDateTextInputProps>;
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { TravelDateRangeInputValue } from "../types";
3
+ export interface TravelDateTextInputFieldsProps {
4
+ value: TravelDateRangeInputValue | undefined;
5
+ onValueChange: ((value: Partial<TravelDateRangeInputValue>) => void) | undefined;
6
+ localeCode: string;
7
+ startDateLabel?: string;
8
+ endDateLabel?: string;
9
+ onFocus?: () => void;
10
+ }
11
+ export declare const TravelDateTextInputFields: React.FC<TravelDateTextInputFieldsProps>;
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { VisiblePanel } from "../types";
3
+ export declare const useTravelDateInput: (value: string | undefined, onValueChange: ((value: string) => void) | undefined, localeCode: string, initialMonthInFocus: Date | undefined) => {
4
+ isDateDisabled: (date: Date) => boolean;
5
+ onClickDate: (date: Date) => void;
6
+ onValueChangeByInputs: (value: string) => void;
7
+ prevMonthDisabled: boolean;
8
+ monthPickerButtonRef: import("react").RefObject<HTMLButtonElement>;
9
+ calendarId: string;
10
+ monthPickerButtonLabel: string;
11
+ visiblePanel: VisiblePanel;
12
+ setVisiblePanel: import("react").Dispatch<import("react").SetStateAction<VisiblePanel>>;
13
+ setVisibleMonth: import("react").Dispatch<import("react").SetStateAction<Date>>;
14
+ visibleMonthData: import("../../../util/calendar/CalendarDataFactory").MonthData;
15
+ todayIsInVisibleMonth: boolean;
16
+ hoverDate: Date | undefined;
17
+ setHoverDate: import("react").Dispatch<import("react").SetStateAction<Date | undefined>>;
18
+ selectedDate: Date | undefined;
19
+ today: Date;
20
+ visibleMonth: Date;
21
+ };
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { TravelDateRangeInputValue, VisiblePanel } from "../types";
3
+ export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue | undefined, onValueChange: ((value: TravelDateRangeInputValue) => void) | undefined, localeCode: string, initialMonthInFocus: Date | undefined) => {
4
+ isDateDisabled: (date: Date) => boolean;
5
+ onClickDate: (date: Date) => void;
6
+ onValueChangeByInputs: (value: TravelDateRangeInputValue) => void;
7
+ isValidDateRange: boolean;
8
+ prevMonthDisabled: boolean;
9
+ monthPickerButtonRef: import("react").RefObject<HTMLButtonElement>;
10
+ calendarId: string;
11
+ monthPickerButtonLabel: string;
12
+ visiblePanel: VisiblePanel;
13
+ setVisiblePanel: import("react").Dispatch<import("react").SetStateAction<VisiblePanel>>;
14
+ setVisibleMonth: import("react").Dispatch<import("react").SetStateAction<Date>>;
15
+ visibleMonthData: import("../../../util/calendar/CalendarDataFactory").MonthData;
16
+ todayIsInVisibleMonth: boolean;
17
+ hoverDate: Date | undefined;
18
+ setHoverDate: import("react").Dispatch<import("react").SetStateAction<Date | undefined>>;
19
+ selectedStartDate: Date | undefined;
20
+ selectedEndDate: Date | undefined;
21
+ today: Date;
22
+ visibleMonth: Date;
23
+ };
@@ -0,0 +1,5 @@
1
+ export interface TravelDateRangeInputValue {
2
+ startDate?: string;
3
+ endDate?: string;
4
+ }
5
+ export type VisiblePanel = "calendar" | "month-picker";
@@ -0,0 +1,4 @@
1
+ export declare const getCellBackgroundColors: (date: Date, selectedStartDate: Date | undefined, selectedEndDate: Date | undefined, hoverDate: Date | undefined, dayIsInMonth: boolean, isValidDateRange: boolean) => {
2
+ left: string;
3
+ right: string;
4
+ };
@@ -0,0 +1 @@
1
+ export declare const createDayId: (date: Date, calendarId: string) => string;
@@ -0,0 +1 @@
1
+ export declare const getDateToFocusOn: (currentDate: Date, key: string) => Date | undefined;
@@ -0,0 +1 @@
1
+ export declare const useToday: () => Date;
package/dist/index.d.ts CHANGED
@@ -28,7 +28,13 @@ export * from "./features/month-picker/MonthPicker";
28
28
  export * from "./features/year-picker/YearPicker";
29
29
  export * from "./features/preset-picker/PresetPicker";
30
30
  export * from "./components/input-types/date-range-dual-text-input/DateRangeDualTextInput";
31
+ export * from "./components/input-types/travel-date-range-input/TravelDateRangeInput";
32
+ export * from "./components/input-types/travel-date-input/TravelDateInput";
33
+ export * from "./components/calendar-types/travel-date-calendar/TravelDateCalendar";
34
+ export * from "./components/calendar-types/travel-date-range-calendar/TravelDateRangeCalendar";
35
+ export * from "./features/travel-calendar/types";
31
36
  export * from "./features/localize-date-format/LocalizedDateFormatter";
32
37
  export * from "./features/localize-date-format/LocalizedDateParser";
38
+ export * from "./features/localize-date-format/LocalizedDateReformatter";
33
39
  export * from "./features/localize-date-format/DateFormatProvider";
34
40
  export * from "./features/localize-date-format/LocaleMapper";