willba-component-library 0.2.78 → 0.2.80
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/lib/assets/IconsSvg.d.ts +9 -0
- package/lib/assets/SpinnerSvg.d.ts +5 -0
- package/lib/components/Button/Button.d.ts +29 -0
- package/lib/components/Button/Button.stories.d.ts +7 -0
- package/lib/components/Button/index.d.ts +1 -0
- package/lib/components/FilterBar/FilterBar.d.ts +5 -0
- package/lib/components/FilterBar/FilterBar.stories.d.ts +6 -0
- package/lib/components/FilterBar/FilterBarTypes.d.ts +56 -0
- package/lib/components/FilterBar/components/buttons/close-button/CloseButton.d.ts +7 -0
- package/lib/components/FilterBar/components/buttons/index.d.ts +4 -0
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +10 -0
- package/lib/components/FilterBar/components/buttons/submit-button/SubmitButton.d.ts +3 -0
- package/lib/components/FilterBar/components/buttons/tab-button/TabButton.d.ts +10 -0
- package/lib/components/FilterBar/components/calendar/Calendar.d.ts +14 -0
- package/lib/components/FilterBar/components/categories/Categories.d.ts +8 -0
- package/lib/components/FilterBar/components/divider/Divider.d.ts +3 -0
- package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +4 -0
- package/lib/components/FilterBar/components/guests/Guests.d.ts +10 -0
- package/lib/components/FilterBar/components/index.d.ts +4 -0
- package/lib/components/FilterBar/hooks/index.d.ts +2 -0
- package/lib/components/FilterBar/hooks/useCloseFilterSection.d.ts +8 -0
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +27 -0
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +9 -0
- package/lib/components/FilterBar/hooks/useUpdateTranslations.d.ts +5 -0
- package/lib/components/FilterBar/index.d.ts +2 -0
- package/lib/components/FilterBar/utils/index.d.ts +1 -0
- package/lib/components/FilterBar/utils/parseDates.d.ts +6 -0
- package/lib/components/FilterBar/utils/parseGuests.d.ts +17 -0
- package/lib/components/FilterCalendar/FilterCalendar.d.ts +5 -0
- package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +6 -0
- package/lib/components/FilterCalendar/FilterCalendarTypes.d.ts +9 -0
- package/lib/components/FilterCalendar/components/Footer.d.ts +10 -0
- package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +21 -0
- package/lib/components/FilterCalendar/index.d.ts +2 -0
- package/lib/core/components/buttons/close-button/CloseButton.d.ts +7 -0
- package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +11 -0
- package/lib/core/components/calendar/Calendar.d.ts +5 -0
- package/lib/core/components/calendar/CalendarTypes.d.ts +39 -0
- package/{src/core/components/calendar/hooks/index.ts → lib/core/components/calendar/hooks/index.d.ts} +3 -3
- package/lib/core/components/calendar/hooks/useCalendarLoadingSpinner.d.ts +5 -0
- package/lib/core/components/calendar/hooks/useCalendarTooltips.d.ts +5 -0
- package/lib/core/components/calendar/hooks/useUpdateDisabledDates.d.ts +14 -0
- package/lib/core/components/calendar/utils/calendarSelectionRules.d.ts +15 -0
- package/lib/core/components/calendar/utils/checkForContinuousSelection.d.ts +11 -0
- package/lib/core/components/calendar/utils/disabledDatesByPage.d.ts +9 -0
- package/lib/core/components/calendar/utils/handleCalendarModifiers.d.ts +47 -0
- package/lib/core/components/calendar/utils/handleRangeContextDisabledDates.d.ts +27 -0
- package/{src/core/components/calendar/utils/index.ts → lib/core/components/calendar/utils/index.d.ts} +8 -8
- package/lib/core/components/calendar/utils/nightsCount.d.ts +6 -0
- package/lib/core/components/calendar/utils/parseDate.d.ts +7 -0
- package/lib/core/components/calendar/utils/parseDates.d.ts +6 -0
- package/lib/core/components/index.d.ts +3 -0
- package/lib/core/hooks/index.d.ts +3 -0
- package/lib/core/hooks/useAwaitRender.d.ts +1 -0
- package/lib/core/hooks/useCloseFilterSection.d.ts +8 -0
- package/lib/core/hooks/useUpdateTranslations.d.ts +5 -0
- package/lib/core/utils/handleOverlappingDates.d.ts +1 -0
- package/lib/core/utils/index.d.ts +3 -0
- package/lib/core/utils/nightsCount.d.ts +6 -0
- package/lib/core/utils/parseDate.d.ts +7 -0
- package/lib/core/utils/parseDates.d.ts +6 -0
- package/lib/i18n.d.ts +2 -0
- package/lib/index.d.ts +119 -0
- package/lib/index.esm.js +11576 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +11598 -0
- package/lib/index.js.map +1 -0
- package/lib/index.umd.js +11602 -0
- package/lib/index.umd.js.map +1 -0
- package/lib/themes/useTheme.d.ts +13 -0
- package/package.json +1 -1
- package/src/assets/SpinnerSvg.tsx +40 -0
- package/src/components/FilterBar/FilterBar.stories.tsx +1 -2
- package/src/components/FilterBar/FilterBar.tsx +1 -1
- package/src/components/FilterBar/components/buttons/tab-button/TabButton.css +1 -1
- package/src/components/FilterBar/hooks/useFilterBar.tsx +1 -1
- package/src/components/FilterCalendar/FilterCalendar.css +10 -26
- package/src/components/FilterCalendar/FilterCalendar.stories.tsx +153 -522
- package/src/components/FilterCalendar/FilterCalendar.tsx +54 -25
- package/src/components/FilterCalendar/FilterCalendarTypes.ts +1 -0
- package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +4 -94
- package/src/core/components/buttons/submit-button/SubmitButton.css +2 -16
- package/src/core/components/buttons/submit-button/SubmitButton.tsx +5 -6
- package/src/core/components/calendar/Calendar.css +18 -71
- package/src/core/components/calendar/Calendar.tsx +342 -132
- package/src/core/components/calendar/CalendarTypes.ts +3 -10
- package/src/core/utils/index.ts +3 -0
- package/src/locales/en/common.json +1 -7
- package/src/locales/en/filterBar.json +1 -2
- package/src/locales/fi/common.json +1 -7
- package/src/locales/fi/filterBar.json +1 -2
- package/src/themes/Default.css +3 -12
- package/src/themes/useTheme.tsx +0 -3
- package/src/assets/IconsSvg.tsx +0 -68
- package/src/components/FilterCalendar/components/Footer.tsx +0 -96
- package/src/core/components/calendar/hooks/useCalendarLoadingSpinner.tsx +0 -19
- package/src/core/components/calendar/hooks/useCalendarTooltips.tsx +0 -125
- package/src/core/components/calendar/hooks/useUpdateDisabledDates.tsx +0 -107
- package/src/core/components/calendar/utils/calendarSelectionRules.tsx +0 -228
- package/src/core/components/calendar/utils/checkForContinuousSelection.tsx +0 -86
- package/src/core/components/calendar/utils/disabledDatesByPage.tsx +0 -36
- package/src/core/components/calendar/utils/handleCalendarModifiers.tsx +0 -147
- package/src/core/components/calendar/utils/handleRangeContextDisabledDates.tsx +0 -75
- package/willba-component-library-0.2.77.tgz +0 -0
- /package/src/core/{components/calendar/utils → utils}/nightsCount.tsx +0 -0
- /package/src/core/{components/calendar/utils → utils}/parseDate.tsx +0 -0
- /package/src/core/{components/calendar/utils → utils}/parseDates.tsx +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./button.css";
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Is this the principal call to action on the page?
|
|
6
|
+
*/
|
|
7
|
+
type?: "primary" | "secondary";
|
|
8
|
+
/**
|
|
9
|
+
* What background color to use
|
|
10
|
+
*/
|
|
11
|
+
textColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How large should the button be?
|
|
14
|
+
*/
|
|
15
|
+
size?: "small" | "medium" | "large";
|
|
16
|
+
/**
|
|
17
|
+
* Button contents
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional click handler
|
|
22
|
+
*/
|
|
23
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Primary UI component for user interaction
|
|
27
|
+
*/
|
|
28
|
+
declare const Button: ({ type, textColor, size, onClick, label, }: ButtonProps) => React.JSX.Element;
|
|
29
|
+
export default Button;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Button from "./Button";
|
|
3
|
+
declare const meta: Meta<typeof Button>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Button>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Button";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../../themes/Default.css';
|
|
3
|
+
import { FilterBarProps } from './FilterBarTypes';
|
|
4
|
+
import './FilterBar.css';
|
|
5
|
+
export default function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, disableCalendarDates, mode, tabs, outerLoading, }: FilterBarProps): React.JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DisableCalendarDates } from '../../core/components/calendar/CalendarTypes';
|
|
2
|
+
import { Palette } from '../../themes/useTheme';
|
|
3
|
+
export type FilterBarProps = {
|
|
4
|
+
language?: string;
|
|
5
|
+
ageCategories?: AgeCategoryType[];
|
|
6
|
+
redirectUrl?: string;
|
|
7
|
+
palette?: Palette;
|
|
8
|
+
onSubmit?: ((val: Filters) => void) | null;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
disableCalendarDates?: DisableCalendarDates;
|
|
11
|
+
mode?: string;
|
|
12
|
+
defaultTab?: string;
|
|
13
|
+
tabs?: Tab[];
|
|
14
|
+
outerLoading?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type AgeCategoryCount = {
|
|
17
|
+
[categoryId: string]: number;
|
|
18
|
+
};
|
|
19
|
+
export type AgeCategoryType = {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
minVal: number;
|
|
23
|
+
sortOrder: number;
|
|
24
|
+
};
|
|
25
|
+
export type GuestsCountPropsType = {
|
|
26
|
+
label: string;
|
|
27
|
+
id: number;
|
|
28
|
+
updateGuestsCount: (arg1: string, arg2: number) => void;
|
|
29
|
+
count: number;
|
|
30
|
+
minVal: number;
|
|
31
|
+
sortOrder: number;
|
|
32
|
+
};
|
|
33
|
+
export declare enum FilterSections {
|
|
34
|
+
CALENDAR = "calendar",
|
|
35
|
+
GUESTS = "guests",
|
|
36
|
+
CATEGORIES = "categories"
|
|
37
|
+
}
|
|
38
|
+
export type Filters = {
|
|
39
|
+
[key: string]: string;
|
|
40
|
+
};
|
|
41
|
+
export declare enum Pages {
|
|
42
|
+
ROOMS = "/rooms",
|
|
43
|
+
EVENTS = "/events"
|
|
44
|
+
}
|
|
45
|
+
type Translations = {
|
|
46
|
+
en: string;
|
|
47
|
+
fi: string;
|
|
48
|
+
[key: string]: string;
|
|
49
|
+
};
|
|
50
|
+
export type Tab = {
|
|
51
|
+
path: string;
|
|
52
|
+
default?: boolean;
|
|
53
|
+
order: number;
|
|
54
|
+
label?: Translations;
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CloseButton } from '../../../../core/components/buttons/close-button/CloseButton';
|
|
2
|
+
export { SubmitButton } from '../../../../core/components/buttons/submit-button/SubmitButton';
|
|
3
|
+
export { SelectButton } from './select-button/SelectButton';
|
|
4
|
+
export { TabButton } from './tab-button/TabButton';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './SelectButton.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
description: string;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const SelectButton: ({ active, label, onClick, description, }: Props) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './TabButton.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
label: string;
|
|
6
|
+
active?: boolean;
|
|
7
|
+
mode?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const TabButton: ({ onClick, label, active, mode }: Props) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateRange } from 'react-day-picker';
|
|
3
|
+
import { CalendarOffset } from '../../FilterBarTypes';
|
|
4
|
+
import 'react-day-picker/dist/style.css';
|
|
5
|
+
import './Calendar.css';
|
|
6
|
+
type Props = {
|
|
7
|
+
calendarRange: DateRange | undefined;
|
|
8
|
+
setCalendarRange: (range: DateRange | undefined) => void;
|
|
9
|
+
calendarOffset?: CalendarOffset;
|
|
10
|
+
selectedPath: string;
|
|
11
|
+
locale?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const Calendar: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AgeCategoryCount, AgeCategoryType } from '../../FilterBarTypes';
|
|
3
|
+
import './Guests.css';
|
|
4
|
+
type Props = {
|
|
5
|
+
ageCategories: AgeCategoryType[];
|
|
6
|
+
updateGuestsCount: (arg1: string, arg2: number) => void;
|
|
7
|
+
ageCategoryCounts: AgeCategoryCount | {};
|
|
8
|
+
};
|
|
9
|
+
export declare const Guests: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
handleSelectedFilter: (arg: boolean) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const useCloseFilterSection: ({ handleSelectedFilter }: Props) => {
|
|
6
|
+
filtersRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateRange } from 'react-day-picker';
|
|
3
|
+
import { AgeCategoryCount, AgeCategoryType, Filters, Tab } from '../FilterBarTypes';
|
|
4
|
+
type Props = {
|
|
5
|
+
redirectUrl?: string;
|
|
6
|
+
ageCategories?: AgeCategoryType[];
|
|
7
|
+
onSubmit?: ((val: Filters) => void) | null;
|
|
8
|
+
tabs?: Tab[];
|
|
9
|
+
};
|
|
10
|
+
export declare const useFilterBar: ({ redirectUrl, ageCategories, onSubmit, tabs, }: Props) => {
|
|
11
|
+
selectedFilter: string | boolean;
|
|
12
|
+
ageCategoryCounts: AgeCategoryCount;
|
|
13
|
+
categories: number;
|
|
14
|
+
calendarRange: DateRange | undefined;
|
|
15
|
+
selectedPath: string;
|
|
16
|
+
innerLoading: boolean;
|
|
17
|
+
setCalendarRange: import("react").Dispatch<import("react").SetStateAction<DateRange | undefined>>;
|
|
18
|
+
setSelectedFilter: import("react").Dispatch<import("react").SetStateAction<string | boolean>>;
|
|
19
|
+
setAgeCategoryCounts: import("react").Dispatch<import("react").SetStateAction<AgeCategoryCount>>;
|
|
20
|
+
setCategories: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
21
|
+
handleSelectedFilter: (id: string | boolean) => void;
|
|
22
|
+
handleSubmit: () => void;
|
|
23
|
+
updateGuestsCount: (id: string, newCount: number) => void;
|
|
24
|
+
handleResetFilters: () => void;
|
|
25
|
+
setSelectedPath: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
selectedFilter: string | boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const useScrollInToView: ({ selectedFilter }: Props) => {
|
|
6
|
+
isMobile: boolean;
|
|
7
|
+
targetFilterBarRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseGuests } from './parseGuests';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes';
|
|
2
|
+
type Props = {
|
|
3
|
+
ageCategoryCounts: AgeCategoryCount;
|
|
4
|
+
ageCategories: AgeCategoryType[];
|
|
5
|
+
guestLabel: string;
|
|
6
|
+
guestsLabel: string;
|
|
7
|
+
guestsPlaceholder: string;
|
|
8
|
+
};
|
|
9
|
+
type AccType = {
|
|
10
|
+
total: number;
|
|
11
|
+
html: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const parseGuests: ({ guestLabel, guestsLabel, guestsPlaceholder, ageCategoryCounts, ageCategories, }: Props) => {
|
|
14
|
+
content: string;
|
|
15
|
+
data: AccType;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../../themes/Default.css';
|
|
3
|
+
import { FilterCalendarTypes } from './FilterCalendarTypes';
|
|
4
|
+
import './FilterCalendar.css';
|
|
5
|
+
export default function FilterCalendar({ calendarOffset, language, palette, onSubmit, disableCalendarDates, toggleCalendar, loadingData, setToggleCalendar, requestDates, showFeedback, noActiveSelection, }: FilterCalendarTypes): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DateRange } from 'react-day-picker';
|
|
2
|
+
import { Palette } from '../../themes/useTheme';
|
|
3
|
+
import { CalendarTypes } from '../../core/components/calendar/CalendarTypes';
|
|
4
|
+
export interface FilterCalendarTypes extends Partial<CalendarTypes> {
|
|
5
|
+
palette: Palette;
|
|
6
|
+
onSubmit: (val: DateRange) => void;
|
|
7
|
+
toggleCalendar: boolean;
|
|
8
|
+
setToggleCalendar: (val: boolean) => void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateRange } from 'react-day-picker';
|
|
3
|
+
import { Palette } from '../../../themes/useTheme';
|
|
4
|
+
export declare const Footer: ({ calendarHasError, calendarRange, handleClearDates, language, palette, }: {
|
|
5
|
+
calendarHasError: boolean;
|
|
6
|
+
calendarRange?: DateRange | undefined;
|
|
7
|
+
handleClearDates: () => void;
|
|
8
|
+
language?: string | undefined;
|
|
9
|
+
palette: Palette;
|
|
10
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
3
|
+
type Props = {
|
|
4
|
+
onSubmit: (val: any) => void;
|
|
5
|
+
setToggleCalendar: (val: boolean) => void;
|
|
6
|
+
noActiveSelection?: boolean;
|
|
7
|
+
toggleCalendar?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const useFilterCalendar: ({ onSubmit, setToggleCalendar, noActiveSelection, toggleCalendar, }: Props) => {
|
|
10
|
+
handleSubmit: () => void;
|
|
11
|
+
handleClearDates: () => void;
|
|
12
|
+
setCalendarRange: import("react").Dispatch<import("react").SetStateAction<DateRange | undefined>>;
|
|
13
|
+
setDisabledDates: import("react").Dispatch<import("react").SetStateAction<Matcher[]>>;
|
|
14
|
+
setUpdateCalendarMonthNavigation: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
15
|
+
calendarRange: DateRange | undefined;
|
|
16
|
+
disabledDates: Matcher[];
|
|
17
|
+
updateCalendarMonthNavigation: boolean;
|
|
18
|
+
updateCalendarDefaultMoth: number;
|
|
19
|
+
initialCalendarRange: DateRange | undefined;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import './SubmitButton.css';
|
|
3
|
+
type Props = {
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
startIcon?: ReactNode;
|
|
6
|
+
label?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const SubmitButton: ({ onClick, startIcon, label, disabled, isLoading, }: Props) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
import { Palette } from '../../../themes/useTheme';
|
|
3
|
+
export type CalendarOffset = {
|
|
4
|
+
[key: string]: number;
|
|
5
|
+
};
|
|
6
|
+
export type DisableCalendarDates = {
|
|
7
|
+
availableDates?: {
|
|
8
|
+
checkIn: Date;
|
|
9
|
+
firstCheckOut: Date;
|
|
10
|
+
lastCheckOut: Date;
|
|
11
|
+
}[];
|
|
12
|
+
disabledDates?: {
|
|
13
|
+
to: Date;
|
|
14
|
+
from: Date;
|
|
15
|
+
}[];
|
|
16
|
+
disabledDatesByPage?: {
|
|
17
|
+
page: string;
|
|
18
|
+
offset: number;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export type CalendarTypes = {
|
|
22
|
+
calendarRange?: DateRange | undefined;
|
|
23
|
+
setCalendarRange: (range: DateRange | undefined) => void;
|
|
24
|
+
calendarOffset?: CalendarOffset;
|
|
25
|
+
selectedPath?: string;
|
|
26
|
+
language?: string;
|
|
27
|
+
disableCalendarDates?: DisableCalendarDates;
|
|
28
|
+
requestDates?: (val: Date) => void;
|
|
29
|
+
disabledDates?: Matcher[];
|
|
30
|
+
setDisabledDates?: (arg: Matcher[]) => void;
|
|
31
|
+
loadingData?: boolean;
|
|
32
|
+
initialCalendarRange?: DateRange | undefined;
|
|
33
|
+
showFeedback?: boolean;
|
|
34
|
+
noActiveSelection?: boolean;
|
|
35
|
+
palette?: Palette;
|
|
36
|
+
updateCalendarMonthNavigation?: boolean;
|
|
37
|
+
setUpdateCalendarMonthNavigation?: (arg: (prev: boolean) => boolean) => void;
|
|
38
|
+
updateCalendarDefaultMoth?: number;
|
|
39
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { useCalendarTooltips } from './useCalendarTooltips'
|
|
2
|
-
export { useCalendarLoadingSpinner } from './useCalendarLoadingSpinner'
|
|
3
|
-
export { useUpdateDisabledDates } from './useUpdateDisabledDates'
|
|
1
|
+
export { useCalendarTooltips } from './useCalendarTooltips';
|
|
2
|
+
export { useCalendarLoadingSpinner } from './useCalendarLoadingSpinner';
|
|
3
|
+
export { useUpdateDisabledDates } from './useUpdateDisabledDates';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
import { DisableCalendarDates } from '../CalendarTypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
disableCalendarDates?: DisableCalendarDates;
|
|
5
|
+
calendarRange?: DateRange;
|
|
6
|
+
updateCalendarMonthNavigation?: boolean;
|
|
7
|
+
updateCalendarDefaultMonth?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const useUpdateDisabledDates: ({ disableCalendarDates, calendarRange, updateCalendarMonthNavigation, updateCalendarDefaultMonth, }: Props) => {
|
|
10
|
+
newDisableCalendarDates: DisableCalendarDates | undefined;
|
|
11
|
+
overlappingDate: DateRange[] | undefined;
|
|
12
|
+
lastPossibleCheckout: Matcher;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
import { DisableCalendarDates, RangeContext } from '../CalendarTypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
range: DateRange | undefined;
|
|
5
|
+
newDisableCalendarDates?: DisableCalendarDates;
|
|
6
|
+
setCalendarRange: (range: DateRange | undefined) => void;
|
|
7
|
+
setDisabledDates?: (arg: Matcher[]) => void;
|
|
8
|
+
setCalendarHasError?: (arg: boolean) => void;
|
|
9
|
+
calendarRange?: DateRange;
|
|
10
|
+
overlappingDate?: DateRange[];
|
|
11
|
+
calendarHasError?: boolean;
|
|
12
|
+
rangeContext?: RangeContext;
|
|
13
|
+
};
|
|
14
|
+
export declare const calendarSelectionRules: ({ range, newDisableCalendarDates, setCalendarRange, setDisabledDates, calendarRange, overlappingDate, setCalendarHasError, rangeContext, }: Props) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DateRange } from 'react-day-picker';
|
|
2
|
+
import { DisableCalendarDates, RangeContext } from '../CalendarTypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
setCalendarHasError?: (arg: boolean) => void;
|
|
5
|
+
rangeContext?: RangeContext;
|
|
6
|
+
calendarRange?: DateRange;
|
|
7
|
+
calendarHasError?: boolean;
|
|
8
|
+
disabledDates?: DisableCalendarDates['disabledDates'];
|
|
9
|
+
};
|
|
10
|
+
export declare const checkForContinuousSelection: ({ setCalendarHasError, rangeContext, calendarRange, calendarHasError, disabledDates, }: Props) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DisableCalendarDates } from '../CalendarTypes';
|
|
2
|
+
export declare const disabledDatesByPage: ({ newDisableCalendarDates, selectedPath, today, }: {
|
|
3
|
+
newDisableCalendarDates?: DisableCalendarDates | undefined;
|
|
4
|
+
selectedPath?: string | undefined;
|
|
5
|
+
today: Date;
|
|
6
|
+
}) => {
|
|
7
|
+
from: Date;
|
|
8
|
+
to: Date;
|
|
9
|
+
}[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
import { DisableCalendarDates, RangeContext } from '../CalendarTypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
newDisableCalendarDates?: DisableCalendarDates;
|
|
5
|
+
calendarRange?: DateRange;
|
|
6
|
+
disabledDatesByPage: {
|
|
7
|
+
from: Date;
|
|
8
|
+
to: Date;
|
|
9
|
+
}[];
|
|
10
|
+
disabledDates?: Matcher[];
|
|
11
|
+
lastPossibleCheckout?: Matcher;
|
|
12
|
+
overlappingDate?: DateRange[];
|
|
13
|
+
rangeContext?: RangeContext;
|
|
14
|
+
findFirstPossibleRangeContextCheckIn?: NonNullable<DisableCalendarDates['availableDates']>['0'];
|
|
15
|
+
findLastPossibleRangeContextCheckOut?: NonNullable<DisableCalendarDates['availableDates']>['0'];
|
|
16
|
+
firstPossibleRangeContextCheckIn: Matcher[];
|
|
17
|
+
lastPossibleRangeContextCheckOut: Matcher[];
|
|
18
|
+
currentSelectionLastCheckoutDate?: NonNullable<DisableCalendarDates['availableDates']>['0'];
|
|
19
|
+
};
|
|
20
|
+
export declare const handleCalendarModifiers: ({ newDisableCalendarDates, calendarRange, disabledDatesByPage, disabledDates, overlappingDate, rangeContext, firstPossibleRangeContextCheckIn, lastPossibleRangeContextCheckOut, findFirstPossibleRangeContextCheckIn, findLastPossibleRangeContextCheckOut, currentSelectionLastCheckoutDate, lastPossibleCheckout, }: Props) => {
|
|
21
|
+
booked: Matcher[];
|
|
22
|
+
disabledAfterCheckIn: {
|
|
23
|
+
after: Date;
|
|
24
|
+
}[];
|
|
25
|
+
overlappingDate: {
|
|
26
|
+
from: Date | undefined;
|
|
27
|
+
}[];
|
|
28
|
+
noActiveSelectionStart: never[] | Date;
|
|
29
|
+
noActiveSelectionMid: (never[] | {
|
|
30
|
+
after: Date;
|
|
31
|
+
before: Date;
|
|
32
|
+
})[];
|
|
33
|
+
noActiveSelectionEnd: never[] | Date;
|
|
34
|
+
checkoutOptionsMid: {
|
|
35
|
+
after: Date;
|
|
36
|
+
before: Date;
|
|
37
|
+
}[];
|
|
38
|
+
checkInOnly: {
|
|
39
|
+
from: Date;
|
|
40
|
+
to: Date;
|
|
41
|
+
}[];
|
|
42
|
+
checkOutOnly: {
|
|
43
|
+
from: Date;
|
|
44
|
+
to: Date;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DateRange, Matcher } from 'react-day-picker';
|
|
2
|
+
import { DisableCalendarDates, RangeContext } from '../CalendarTypes';
|
|
3
|
+
type Props = {
|
|
4
|
+
rangeContext?: RangeContext;
|
|
5
|
+
availableDates?: DisableCalendarDates['availableDates'];
|
|
6
|
+
calendarRange?: DateRange;
|
|
7
|
+
};
|
|
8
|
+
export declare const handleRangeContextDisabledDates: ({ rangeContext, availableDates, calendarRange, }: Props) => {
|
|
9
|
+
findFirstPossibleRangeContextCheckIn: {
|
|
10
|
+
checkIn: Date;
|
|
11
|
+
firstCheckOut: Date;
|
|
12
|
+
lastCheckOut: Date;
|
|
13
|
+
} | undefined;
|
|
14
|
+
findLastPossibleRangeContextCheckOut: {
|
|
15
|
+
checkIn: Date;
|
|
16
|
+
firstCheckOut: Date;
|
|
17
|
+
lastCheckOut: Date;
|
|
18
|
+
} | undefined;
|
|
19
|
+
firstPossibleRangeContextCheckIn: Matcher[];
|
|
20
|
+
lastPossibleRangeContextCheckOut: Matcher[];
|
|
21
|
+
currentSelectionLastCheckoutDate: {
|
|
22
|
+
checkIn: Date;
|
|
23
|
+
firstCheckOut: Date;
|
|
24
|
+
lastCheckOut: Date;
|
|
25
|
+
} | undefined;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { parseDates } from './parseDates'
|
|
2
|
-
export { parseDate } from './parseDate'
|
|
3
|
-
export { nightsCount } from './nightsCount'
|
|
4
|
-
export { calendarSelectionRules } from './calendarSelectionRules'
|
|
5
|
-
export { disabledDatesByPage } from './disabledDatesByPage'
|
|
6
|
-
export { handleCalendarModifiers } from './handleCalendarModifiers'
|
|
7
|
-
export { handleRangeContextDisabledDates } from './handleRangeContextDisabledDates'
|
|
8
|
-
export { checkForContinuousSelection } from './checkForContinuousSelection'
|
|
1
|
+
export { parseDates } from './parseDates';
|
|
2
|
+
export { parseDate } from './parseDate';
|
|
3
|
+
export { nightsCount } from './nightsCount';
|
|
4
|
+
export { calendarSelectionRules } from './calendarSelectionRules';
|
|
5
|
+
export { disabledDatesByPage } from './disabledDatesByPage';
|
|
6
|
+
export { handleCalendarModifiers } from './handleCalendarModifiers';
|
|
7
|
+
export { handleRangeContextDisabledDates } from './handleRangeContextDisabledDates';
|
|
8
|
+
export { checkForContinuousSelection } from './checkForContinuousSelection';
|