willba-component-library 0.2.54 → 0.2.56

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 (58) hide show
  1. package/lib/assets/IconsSvg.d.ts +9 -0
  2. package/lib/components/FilterBar/FilterBar.stories.d.ts +1 -1
  3. package/lib/components/FilterCalendar/FilterCalendar.d.ts +1 -1
  4. package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +2 -1
  5. package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +3 -3
  6. package/lib/core/components/calendar/CalendarTypes.d.ts +8 -6
  7. package/lib/core/components/calendar/hooks/index.d.ts +3 -0
  8. package/lib/core/components/calendar/hooks/useCalendarLoadingSpinner.d.ts +7 -0
  9. package/lib/core/components/calendar/hooks/useCalendarTooltips.d.ts +10 -0
  10. package/lib/core/components/calendar/hooks/useUpdateDisabledDates.d.ts +13 -0
  11. package/lib/core/components/calendar/utils/calendarSelectionRules.d.ts +15 -0
  12. package/lib/core/components/calendar/utils/checkForContinuousSelection.d.ts +10 -0
  13. package/lib/core/components/calendar/utils/disabledDatesByPage.d.ts +9 -0
  14. package/lib/core/components/calendar/utils/handleCalendarModifiers.d.ts +46 -0
  15. package/lib/core/components/calendar/utils/handleRangeContextDisabledDates.d.ts +27 -0
  16. package/lib/core/components/calendar/utils/index.d.ts +8 -0
  17. package/lib/core/components/calendar/utils/nightsCount.d.ts +6 -0
  18. package/lib/core/components/calendar/utils/parseDate.d.ts +7 -0
  19. package/lib/core/components/calendar/utils/parseDates.d.ts +6 -0
  20. package/lib/index.d.ts +10 -7
  21. package/lib/index.esm.js +646 -272
  22. package/lib/index.esm.js.map +1 -1
  23. package/lib/index.js +646 -272
  24. package/lib/index.js.map +1 -1
  25. package/lib/index.umd.js +646 -272
  26. package/lib/index.umd.js.map +1 -1
  27. package/lib/themes/useTheme.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/src/assets/IconsSvg.tsx +66 -0
  30. package/src/components/FilterBar/FilterBar.stories.tsx +2 -1
  31. package/src/components/FilterBar/FilterBar.tsx +1 -1
  32. package/src/components/FilterCalendar/FilterCalendar.css +8 -9
  33. package/src/components/FilterCalendar/FilterCalendar.stories.tsx +345 -158
  34. package/src/components/FilterCalendar/FilterCalendar.tsx +69 -52
  35. package/src/components/FilterCalendar/FilterCalendarTypes.ts +0 -1
  36. package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +44 -4
  37. package/src/core/components/buttons/submit-button/SubmitButton.tsx +1 -4
  38. package/src/core/components/calendar/Calendar.css +24 -6
  39. package/src/core/components/calendar/Calendar.tsx +127 -376
  40. package/src/core/components/calendar/CalendarTypes.ts +9 -4
  41. package/src/core/components/calendar/hooks/index.ts +3 -0
  42. package/src/core/components/calendar/hooks/useCalendarLoadingSpinner.tsx +25 -0
  43. package/src/core/components/calendar/hooks/useCalendarTooltips.tsx +139 -0
  44. package/src/core/components/calendar/hooks/useUpdateDisabledDates.tsx +94 -0
  45. package/src/core/components/calendar/utils/calendarSelectionRules.tsx +163 -0
  46. package/src/core/components/calendar/utils/checkForContinuousSelection.tsx +50 -0
  47. package/src/core/components/calendar/utils/disabledDatesByPage.tsx +36 -0
  48. package/src/core/components/calendar/utils/handleCalendarModifiers.tsx +151 -0
  49. package/src/core/components/calendar/utils/handleRangeContextDisabledDates.tsx +70 -0
  50. package/src/core/components/calendar/utils/index.ts +8 -0
  51. package/src/themes/Default.css +6 -0
  52. package/src/themes/useTheme.tsx +3 -0
  53. package/src/assets/SpinnerSvg.tsx +0 -40
  54. package/src/core/utils/handleOverlappingDates.tsx +0 -3
  55. package/src/core/utils/index.ts +0 -3
  56. /package/src/core/{utils → components/calendar/utils}/nightsCount.tsx +0 -0
  57. /package/src/core/{utils → components/calendar/utils}/parseDate.tsx +0 -0
  58. /package/src/core/{utils → components/calendar/utils}/parseDates.tsx +0 -0
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ type Icon = 'spinner' | 'warning';
3
+ type Props = {
4
+ fill?: string;
5
+ size?: number;
6
+ icon: Icon;
7
+ };
8
+ export declare const IconsSvg: ({ fill, size, icon }: Props) => React.JSX.Element | undefined;
9
+ export {};
@@ -3,4 +3,4 @@ import FilterBar from './FilterBar';
3
3
  declare const meta: Meta<typeof FilterBar>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof FilterBar>;
6
- export declare const Primary: Story;
6
+ export declare const Main: Story;
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  import '../../themes/Default.css';
3
3
  import { FilterCalendarTypes } from './FilterCalendarTypes';
4
4
  import './FilterCalendar.css';
5
- export default function FilterCalendar({ calendarOffset, language, palette, onSubmit, disableCalendarDates, toggleCalendar, loadingData, setToggleCalendar, requestDates, showFeedback, noActiveSelection, }: FilterCalendarTypes): React.JSX.Element;
5
+ export default function FilterCalendar({ calendarOffset, language, palette, onSubmit, disableCalendarDates, toggleCalendar, loadingData, setToggleCalendar, requestDates, showFeedback, noActiveSelection, rangeContext, }: FilterCalendarTypes): React.JSX.Element;
@@ -3,4 +3,5 @@ import FilterCalendar from './FilterCalendar';
3
3
  declare const meta: Meta<typeof FilterCalendar>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof FilterCalendar>;
6
- export declare const Primary: Story;
6
+ export declare const Default: Story;
7
+ export declare const RangeContext: Story;
@@ -16,8 +16,8 @@ export declare const useFilterCalendar: ({ onSubmit, setToggleCalendar, noActive
16
16
  disabledDates: Matcher[];
17
17
  updateCalendarMonthNavigation: boolean;
18
18
  updateCalendarDefaultMoth: number;
19
- initialCalendarRange: DateRange | undefined;
20
- overlappingDates: boolean;
21
- setOverlappingDates: import("react").Dispatch<import("react").SetStateAction<boolean>>;
19
+ calendarHasError: boolean;
20
+ setCalendarHasError: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
+ setUpdatedForSubmit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
22
22
  };
23
23
  export {};
@@ -17,10 +17,10 @@ export type DisableCalendarDates = {
17
17
  page: string;
18
18
  offset: number;
19
19
  }[];
20
- selectedDates?: {
21
- to: Date;
22
- from: Date;
23
- };
20
+ };
21
+ export type RangeContext = {
22
+ from: Date;
23
+ to: Date;
24
24
  };
25
25
  export type CalendarTypes = {
26
26
  calendarRange?: DateRange | undefined;
@@ -33,12 +33,14 @@ export type CalendarTypes = {
33
33
  disabledDates?: Matcher[];
34
34
  setDisabledDates?: (arg: Matcher[]) => void;
35
35
  loadingData?: boolean;
36
- initialCalendarRange?: DateRange | undefined;
37
36
  showFeedback?: boolean;
38
37
  noActiveSelection?: boolean;
39
38
  palette?: Palette;
40
39
  updateCalendarMonthNavigation?: boolean;
41
40
  setUpdateCalendarMonthNavigation?: (arg: (prev: boolean) => boolean) => void;
42
41
  updateCalendarDefaultMoth?: number;
43
- setOverlappingDates: (arg: boolean) => void;
42
+ setCalendarHasError?: (arg: boolean) => void;
43
+ setUpdatedForSubmit?: (arg: boolean) => void;
44
+ rangeContext?: RangeContext;
45
+ calendarHasError?: boolean;
44
46
  };
@@ -0,0 +1,3 @@
1
+ export { useCalendarTooltips } from './useCalendarTooltips';
2
+ export { useCalendarLoadingSpinner } from './useCalendarLoadingSpinner';
3
+ export { useUpdateDisabledDates } from './useUpdateDisabledDates';
@@ -0,0 +1,7 @@
1
+ type Props = {
2
+ loadingData?: boolean;
3
+ updateCalendarMonthNavigation?: boolean;
4
+ updateCalendarDefaultMoth?: number;
5
+ };
6
+ export declare const useCalendarLoadingSpinner: ({ loadingData, updateCalendarMonthNavigation, updateCalendarDefaultMoth, }: Props) => void;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ type Props = {
3
+ calendarRange?: DateRange;
4
+ updateCalendarMonthNavigation?: boolean;
5
+ overlappingDate?: DateRange[];
6
+ updateCalendarDefaultMoth?: number;
7
+ showFeedback?: boolean;
8
+ };
9
+ export declare const useCalendarTooltips: ({ calendarRange, updateCalendarMonthNavigation, overlappingDate, updateCalendarDefaultMoth, showFeedback, }: Props) => void;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ import { DisableCalendarDates } from '../CalendarTypes';
3
+ type Props = {
4
+ disableCalendarDates?: DisableCalendarDates;
5
+ calendarRange?: DateRange;
6
+ updateCalendarMonthNavigation?: boolean;
7
+ updateCalendarDefaultMoth?: number;
8
+ };
9
+ export declare const useUpdateDisabledDates: ({ disableCalendarDates, calendarRange, updateCalendarMonthNavigation, updateCalendarDefaultMoth, }: Props) => {
10
+ newDisableCalendarDates: DisableCalendarDates | undefined;
11
+ overlappingDate: DateRange[] | undefined;
12
+ };
13
+ 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,10 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ import { RangeContext } from '../CalendarTypes';
3
+ type Props = {
4
+ setCalendarHasError?: (arg: boolean) => void;
5
+ rangeContext?: RangeContext;
6
+ calendarRange?: DateRange;
7
+ calendarHasError?: boolean;
8
+ };
9
+ export declare const checkForContinuousSelection: ({ setCalendarHasError, rangeContext, calendarRange, calendarHasError, }: Props) => void;
10
+ 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,46 @@
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
+ overlappingDate?: DateRange[];
12
+ rangeContext?: RangeContext;
13
+ findFirstPossibleRangeContextCheckIn?: NonNullable<DisableCalendarDates['availableDates']>['0'];
14
+ findLastPossibleRangeContextCheckOut?: NonNullable<DisableCalendarDates['availableDates']>['0'];
15
+ firstPossibleRangeContextCheckIn: Matcher[];
16
+ lastPossibleRangeContextCheckOut: Matcher[];
17
+ currentSelectionLastCheckoutDate?: NonNullable<DisableCalendarDates['availableDates']>['0'];
18
+ };
19
+ export declare const handleCalendarModifiers: ({ newDisableCalendarDates, calendarRange, disabledDatesByPage, disabledDates, overlappingDate, rangeContext, firstPossibleRangeContextCheckIn, lastPossibleRangeContextCheckOut, findFirstPossibleRangeContextCheckIn, findLastPossibleRangeContextCheckOut, currentSelectionLastCheckoutDate, }: Props) => {
20
+ booked: Matcher[];
21
+ disabledAfterCheckIn: {
22
+ after: Date;
23
+ }[];
24
+ overlappingDate: {
25
+ from: Date | undefined;
26
+ }[];
27
+ noActiveSelectionStart: never[] | Date;
28
+ noActiveSelectionMid: {
29
+ from: Date;
30
+ to: Date;
31
+ }[];
32
+ noActiveSelectionEnd: never[] | Date;
33
+ checkoutOptionsMid: {
34
+ after: Date;
35
+ before: Date;
36
+ }[];
37
+ checkInOnly: {
38
+ from: Date;
39
+ to: Date;
40
+ }[];
41
+ checkOutOnly: {
42
+ from: Date;
43
+ to: Date;
44
+ }[];
45
+ };
46
+ 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 {};
@@ -0,0 +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';
@@ -0,0 +1,6 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ type Props = {
3
+ calendarRange?: DateRange;
4
+ };
5
+ export declare const nightsCount: ({ calendarRange }: Props) => number | undefined;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ type Props = {
2
+ date?: Date;
3
+ dateFormat?: string;
4
+ language?: string;
5
+ };
6
+ export declare const parseDate: ({ date, dateFormat, language, }: Props) => string | null;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ type Props = {
3
+ calendarRange?: DateRange;
4
+ };
5
+ export declare const parseDates: ({ calendarRange }: Props) => string | null;
6
+ export {};
package/lib/index.d.ts CHANGED
@@ -31,6 +31,7 @@ declare const Button: ({ type, textColor, size, onClick, label, }: ButtonProps)
31
31
  type Palette = {
32
32
  primary: string;
33
33
  secondary: string;
34
+ error: string;
34
35
  };
35
36
 
36
37
  type CalendarOffset = {
@@ -50,10 +51,10 @@ type DisableCalendarDates = {
50
51
  page: string;
51
52
  offset: number;
52
53
  }[];
53
- selectedDates?: {
54
- to: Date;
55
- from: Date;
56
- };
54
+ };
55
+ type RangeContext = {
56
+ from: Date;
57
+ to: Date;
57
58
  };
58
59
  type CalendarTypes = {
59
60
  calendarRange?: DateRange | undefined;
@@ -66,14 +67,16 @@ type CalendarTypes = {
66
67
  disabledDates?: Matcher[];
67
68
  setDisabledDates?: (arg: Matcher[]) => void;
68
69
  loadingData?: boolean;
69
- initialCalendarRange?: DateRange | undefined;
70
70
  showFeedback?: boolean;
71
71
  noActiveSelection?: boolean;
72
72
  palette?: Palette;
73
73
  updateCalendarMonthNavigation?: boolean;
74
74
  setUpdateCalendarMonthNavigation?: (arg: (prev: boolean) => boolean) => void;
75
75
  updateCalendarDefaultMoth?: number;
76
- setOverlappingDates: (arg: boolean) => void;
76
+ setCalendarHasError?: (arg: boolean) => void;
77
+ setUpdatedForSubmit?: (arg: boolean) => void;
78
+ rangeContext?: RangeContext;
79
+ calendarHasError?: boolean;
77
80
  };
78
81
 
79
82
  type FilterBarProps = {
@@ -119,6 +122,6 @@ interface FilterCalendarTypes extends Partial<CalendarTypes> {
119
122
  setToggleCalendar: (val: boolean) => void;
120
123
  }
121
124
 
122
- declare function FilterCalendar({ calendarOffset, language, palette, onSubmit, disableCalendarDates, toggleCalendar, loadingData, setToggleCalendar, requestDates, showFeedback, noActiveSelection, }: FilterCalendarTypes): React.JSX.Element;
125
+ declare function FilterCalendar({ calendarOffset, language, palette, onSubmit, disableCalendarDates, toggleCalendar, loadingData, setToggleCalendar, requestDates, showFeedback, noActiveSelection, rangeContext, }: FilterCalendarTypes): React.JSX.Element;
123
126
 
124
127
  export { Button, FilterBar, FilterCalendar, FilterCalendarTypes, Tab };