@stenajs-webui/calendar 23.8.0 → 23.9.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.
- package/dist/features/travel-calendar/components/TravelCalendar.d.ts +11 -1
- package/dist/features/travel-calendar/components/TravelDateCell.d.ts +7 -0
- package/dist/features/travel-calendar/components/TravelDateRangeTextInputFields.d.ts +7 -1
- package/dist/features/travel-calendar/components/TravelDateTextInput.d.ts +3 -1
- package/dist/features/travel-calendar/components/TravelDateTextInputField.d.ts +1 -0
- package/dist/features/travel-calendar/hooks/UseTravelDateInput.d.ts +1 -0
- package/dist/features/travel-calendar/hooks/UseTravelDateRangeInput.d.ts +3 -1
- package/dist/features/travel-calendar/util/CellBgColors.d.ts +9 -1
- package/dist/features/travel-calendar/util/DateRangeNormalizer.d.ts +18 -0
- package/dist/index.es.js +2759 -2523
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { MonthData } from "../../../util/calendar/CalendarDataFactory";
|
|
3
2
|
import { Dispatch, SetStateAction } from "react";
|
|
3
|
+
import { MonthData } from "../../../util/calendar/CalendarDataFactory";
|
|
4
4
|
export type TravelCalendarSizeVariant = "smaller" | "small" | "medium" | "large";
|
|
5
5
|
export interface TravelCalendarProps {
|
|
6
6
|
visibleMonthData: MonthData;
|
|
@@ -11,7 +11,13 @@ export interface TravelCalendarProps {
|
|
|
11
11
|
setHoverDate: Dispatch<SetStateAction<Date | undefined>>;
|
|
12
12
|
selectedStartDate: Date | undefined;
|
|
13
13
|
selectedEndDate: Date | undefined;
|
|
14
|
+
/** The date that the mouse is hovering over. */
|
|
14
15
|
hoverDate: Date | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The other date to show range highlight between, when the user hovers the mouse.
|
|
18
|
+
* If not set, only hovered date will be highlighted, not range.
|
|
19
|
+
* */
|
|
20
|
+
hoverAnchor: Date | undefined;
|
|
15
21
|
today: Date;
|
|
16
22
|
isDateDisabled?: (date: Date) => boolean;
|
|
17
23
|
dateTestId?: (date: Date) => string | undefined;
|
|
@@ -19,5 +25,9 @@ export interface TravelCalendarProps {
|
|
|
19
25
|
todayIsInVisibleMonth: boolean;
|
|
20
26
|
size?: TravelCalendarSizeVariant;
|
|
21
27
|
multiSelectable: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* If "left", only hovering on earlier dates will create a highlight. If undefined, no range will be highlighted.
|
|
30
|
+
*/
|
|
31
|
+
hoverHighlightDirection: "left" | "right" | undefined;
|
|
22
32
|
}
|
|
23
33
|
export declare const TravelCalendar: React.FC<TravelCalendarProps>;
|
|
@@ -11,12 +11,19 @@ export interface TravelDateCellProps {
|
|
|
11
11
|
onChangeVisibleMonth: (visibleMonth: Date) => void;
|
|
12
12
|
onStartHover: (date: Date) => void;
|
|
13
13
|
onEndHover: (date: Date) => void;
|
|
14
|
+
/** Current date that the mouse is hovering over. */
|
|
14
15
|
hoverDate: Date | undefined;
|
|
16
|
+
/** The other date to show range highlight between, when user hovers the mouse. */
|
|
17
|
+
hoverAnchor: Date | undefined;
|
|
15
18
|
today: Date;
|
|
16
19
|
todayIsInVisibleMonth: boolean;
|
|
17
20
|
calendarId: string;
|
|
18
21
|
isDateDisabled?: (date: Date) => boolean;
|
|
19
22
|
dateTestId?: (date: Date) => string | undefined;
|
|
20
23
|
size: TravelCalendarSizeVariant;
|
|
24
|
+
/**
|
|
25
|
+
* If "left", only hovering on earlier dates will create a highlight. If undefined, no range will be highlighted.
|
|
26
|
+
*/
|
|
27
|
+
hoverHighlightDirection: "left" | "right" | undefined;
|
|
21
28
|
}
|
|
22
29
|
export declare const TravelDateCell: React.FC<TravelDateCellProps>;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { RefObject } from "react";
|
|
2
3
|
import { DateTextInputVariant, TravelDateRangeInputValue } from "../types";
|
|
3
4
|
import { TravelCalendarSizeVariant } from "./TravelCalendar";
|
|
4
5
|
import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
|
|
6
|
+
export type TravelDateRangeTextInputField = "startDate" | "endDate";
|
|
5
7
|
export interface TravelDateRangeTextInputFieldsProps {
|
|
6
8
|
value: TravelDateRangeInputValue | undefined;
|
|
7
9
|
onValueChange: ((value: Partial<TravelDateRangeInputValue>) => void) | undefined;
|
|
8
10
|
localeCode: SupportedLocaleCode;
|
|
9
11
|
startDateLabel?: string;
|
|
10
12
|
endDateLabel?: string;
|
|
11
|
-
onFocus?: () => void;
|
|
13
|
+
onFocus?: (field: TravelDateRangeTextInputField) => void;
|
|
14
|
+
onBlur?: () => void;
|
|
15
|
+
startDateRef?: RefObject<HTMLInputElement | null>;
|
|
16
|
+
endDateRef?: RefObject<HTMLInputElement | null>;
|
|
12
17
|
calendarSize: TravelCalendarSizeVariant;
|
|
13
18
|
placeholderWhenBlurredStartDate: string | undefined;
|
|
14
19
|
placeholderWhenBlurredEndDate: string | undefined;
|
|
15
20
|
valueWhenBlurredStartDate: string | undefined;
|
|
16
21
|
valueWhenBlurredEndDate: string | undefined;
|
|
17
22
|
variant: DateTextInputVariant;
|
|
23
|
+
readOnlyOnMobile: boolean;
|
|
18
24
|
}
|
|
19
25
|
export declare const TravelDateRangeTextInputFields: React.FC<TravelDateRangeTextInputFieldsProps>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { RefObject } from "react";
|
|
2
3
|
import { LabelledTextInputProps } from "@stenajs-webui/forms";
|
|
3
4
|
import { InputMask, InputMaskPipe, InputMaskProvider } from "@stenajs-webui/input-mask";
|
|
4
5
|
import { TravelCalendarSizeVariant } from "./TravelCalendar";
|
|
5
6
|
import { DateTextInputVariant } from "../types";
|
|
6
|
-
export interface TravelDateTextInputProps extends Pick<LabelledTextInputProps, "onChange" | "onValueChange" | "value" | "onFocus" | "onBlur" | "placeholder" | "label" | "borderRadiusVariant"> {
|
|
7
|
+
export interface TravelDateTextInputProps extends Pick<LabelledTextInputProps, "readOnly" | "onChange" | "onValueChange" | "value" | "onFocus" | "onBlur" | "placeholder" | "label" | "borderRadiusVariant"> {
|
|
8
|
+
ref?: RefObject<HTMLInputElement | null>;
|
|
7
9
|
mask: InputMask | InputMaskProvider;
|
|
8
10
|
pipe?: InputMaskPipe;
|
|
9
11
|
guide?: boolean;
|
|
@@ -12,5 +12,6 @@ export interface TravelDateTextInputFieldProps {
|
|
|
12
12
|
placeholderWhenBlurred: string | undefined;
|
|
13
13
|
valueWhenBlurred: string | undefined;
|
|
14
14
|
variant: DateTextInputVariant;
|
|
15
|
+
readOnlyOnMobile: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const TravelDateTextInputField: React.FC<TravelDateTextInputFieldProps>;
|
|
@@ -12,6 +12,7 @@ export declare const useTravelDateInput: (value: string | undefined, onValueChan
|
|
|
12
12
|
visibleMonthData: import("../../../util/calendar/CalendarDataFactory").MonthData;
|
|
13
13
|
todayIsInVisibleMonth: boolean;
|
|
14
14
|
hoverDate: Date | undefined;
|
|
15
|
+
hoverAnchor: undefined;
|
|
15
16
|
setHoverDate: import("react").Dispatch<import("react").SetStateAction<Date | undefined>>;
|
|
16
17
|
selectedDate: Date | undefined;
|
|
17
18
|
today: Date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SupportedLocaleCode } from "../../localize-date-format/LocaleMapper";
|
|
2
2
|
import { TravelDateRangeInputValue, VisiblePanel } from "../types";
|
|
3
|
-
export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue | undefined, onValueChange: ((value: TravelDateRangeInputValue) => void) | undefined, localeCode: SupportedLocaleCode, languageLocaleCode: SupportedLocaleCode, initialMonthInFocus: Date | undefined) => {
|
|
3
|
+
export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue | undefined, onValueChange: ((value: TravelDateRangeInputValue) => void) | undefined, localeCode: SupportedLocaleCode, languageLocaleCode: SupportedLocaleCode, initialMonthInFocus: Date | undefined, fieldLastInFocus: "startDate" | "endDate" | undefined, setFieldLastInFocus: (field: "startDate" | "endDate" | undefined) => void, moveFocusToField: (field: "startDate" | "endDate") => void, hideCalendar: undefined | (() => void)) => {
|
|
4
4
|
onClickDate: (date: Date) => void;
|
|
5
5
|
onValueChangeByInputs: (value: TravelDateRangeInputValue) => void;
|
|
6
6
|
isValidDateRange: boolean;
|
|
@@ -14,6 +14,8 @@ export declare const useTravelDateRangeInput: (value: TravelDateRangeInputValue
|
|
|
14
14
|
todayIsInVisibleMonth: boolean;
|
|
15
15
|
hoverDate: Date | undefined;
|
|
16
16
|
setHoverDate: import("react").Dispatch<import("react").SetStateAction<Date | undefined>>;
|
|
17
|
+
hoverAnchor: Date | undefined;
|
|
18
|
+
hoverHighlightDirection: "left" | "right" | undefined;
|
|
17
19
|
selectedStartDate: Date | undefined;
|
|
18
20
|
selectedEndDate: Date | undefined;
|
|
19
21
|
today: Date;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export declare const getCellBackgroundColors: (date: Date, selectedStartDate: Date | undefined, selectedEndDate: Date | undefined, hoverDate: Date | undefined, dayIsInMonth: boolean, isValidDateRange: boolean) => {
|
|
1
|
+
export declare const getCellBackgroundColors: (date: Date, selectedStartDate: Date | undefined, selectedEndDate: Date | undefined, hoverHighlightDirection: "left" | "right" | undefined, hoverDate: Date | undefined, hoverAnchor: Date | undefined, dayIsInMonth: boolean, isValidDateRange: boolean) => {
|
|
2
|
+
left: string;
|
|
3
|
+
right: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const getCellBackgroundHighlight: (date: Date, highlightStartDate: Date | undefined, highlightEndDate: Date | undefined, hoverDate: Date | undefined) => {
|
|
6
|
+
left: string;
|
|
7
|
+
right: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getCellBackgroundHoverRangeHighlight: (date: Date, hoverHighlightDirection: "left" | "right", hoverDate: Date, hoverAnchor: Date) => {
|
|
2
10
|
left: string;
|
|
3
11
|
right: string;
|
|
4
12
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type DateParser = (value: string) => Date | null | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Flip `startDate` and `endDate` string fields of an object,
|
|
4
|
+
* based on parsed `Date` values using `parse`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function flipStringDateRange<T extends {
|
|
7
|
+
startDate?: string;
|
|
8
|
+
endDate?: string;
|
|
9
|
+
}>(obj: T, parse: DateParser): T;
|
|
10
|
+
/**
|
|
11
|
+
* If the date range is invalid, it resets startDate or endDate to the same value.
|
|
12
|
+
* based on parsed `Date` values using `parse`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resetDateRangeIfInvalid<T extends {
|
|
15
|
+
startDate?: string;
|
|
16
|
+
endDate?: string;
|
|
17
|
+
}>(obj: T, parse: DateParser, master: "startDate" | "endDate"): T;
|
|
18
|
+
export {};
|