willba-component-library 0.2.9 → 0.2.12

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 (69) hide show
  1. package/lib/components/FilterBar/FilterBar.d.ts +2 -15
  2. package/lib/components/FilterBar/FilterBarTypes.d.ts +14 -3
  3. package/lib/components/FilterBar/components/buttons/index.d.ts +2 -2
  4. package/lib/components/FilterBar/components/index.d.ts +0 -1
  5. package/lib/components/FilterBar/hooks/index.d.ts +0 -2
  6. package/lib/components/FilterBar/utils/index.d.ts +0 -1
  7. package/lib/components/FilterCalendar/FilterCalendar.d.ts +5 -0
  8. package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +6 -0
  9. package/lib/components/FilterCalendar/FilterCalendarTypes.d.ts +9 -0
  10. package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +13 -0
  11. package/lib/components/FilterCalendar/index.d.ts +2 -0
  12. package/lib/core/components/buttons/close-button/CloseButton.d.ts +7 -0
  13. package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +10 -0
  14. package/lib/core/components/calendar/Calendar.d.ts +5 -0
  15. package/lib/core/components/calendar/CalendarTypes.d.ts +15 -0
  16. package/lib/core/components/index.d.ts +3 -0
  17. package/lib/core/hooks/index.d.ts +3 -0
  18. package/lib/core/hooks/useAwaitRender.d.ts +1 -0
  19. package/lib/core/hooks/useCloseFilterSection.d.ts +8 -0
  20. package/lib/core/hooks/useUpdateTranslations.d.ts +5 -0
  21. package/lib/core/utils/index.d.ts +3 -0
  22. package/lib/core/utils/nightsCount.d.ts +6 -0
  23. package/lib/core/utils/parseDate.d.ts +6 -0
  24. package/lib/core/utils/parseDates.d.ts +6 -0
  25. package/lib/index.d.ts +41 -19
  26. package/lib/index.esm.js +6144 -6051
  27. package/lib/index.esm.js.map +1 -1
  28. package/lib/index.js +6141 -6047
  29. package/lib/index.js.map +1 -1
  30. package/lib/index.umd.js +6141 -6047
  31. package/lib/index.umd.js.map +1 -1
  32. package/lib/themes/useTheme.d.ts +4 -4
  33. package/package.json +1 -1
  34. package/src/components/FilterBar/FilterBar.tsx +18 -42
  35. package/src/components/FilterBar/FilterBarTypes.ts +16 -4
  36. package/src/components/FilterBar/components/buttons/index.ts +3 -2
  37. package/src/components/FilterBar/components/index.ts +0 -1
  38. package/src/components/FilterBar/hooks/index.ts +0 -2
  39. package/src/components/FilterBar/utils/index.tsx +0 -1
  40. package/src/components/FilterCalendar/FilterCalendar.css +71 -0
  41. package/src/components/FilterCalendar/FilterCalendar.stories.tsx +49 -0
  42. package/src/components/FilterCalendar/FilterCalendar.tsx +103 -0
  43. package/src/components/FilterCalendar/FilterCalendarTypes.ts +12 -0
  44. package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +28 -0
  45. package/src/components/FilterCalendar/index.ts +3 -0
  46. package/src/{components/FilterBar → core}/components/buttons/submit-button/SubmitButton.css +6 -0
  47. package/src/core/components/buttons/submit-button/SubmitButton.tsx +28 -0
  48. package/src/{components/FilterBar → core}/components/calendar/Calendar.css +1 -12
  49. package/src/{components/FilterBar → core}/components/calendar/Calendar.tsx +15 -21
  50. package/src/core/components/calendar/CalendarTypes.ts +17 -0
  51. package/src/core/components/index.ts +4 -0
  52. package/src/core/hooks/index.ts +3 -0
  53. package/src/core/hooks/useAwaitRender.tsx +12 -0
  54. package/src/{components/FilterBar → core}/hooks/useCloseFilterSection.tsx +1 -0
  55. package/src/{components/FilterBar → core}/hooks/useUpdateTranslations.tsx +1 -1
  56. package/src/core/utils/index.ts +3 -0
  57. package/src/core/utils/nightsCount.tsx +19 -0
  58. package/src/core/utils/parseDate.tsx +9 -0
  59. package/src/i18n.ts +4 -2
  60. package/src/index.ts +4 -1
  61. package/src/locales/en/common.json +7 -0
  62. package/src/locales/en/filterBar.json +0 -3
  63. package/src/locales/fi/common.json +8 -0
  64. package/src/locales/fi/filterBar.json +0 -3
  65. package/src/themes/useTheme.tsx +2 -2
  66. package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.tsx +0 -18
  67. /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.css +0 -0
  68. /package/src/{components/FilterBar → core}/components/buttons/close-button/CloseButton.tsx +0 -0
  69. /package/src/{components/FilterBar → core}/utils/parseDates.tsx +0 -0
@@ -1,18 +1,5 @@
1
1
  import React from 'react';
2
- import { Palette } from '../../themes/useTheme';
3
2
  import '../../themes/Default.css';
4
- import { AgeCategoryType, CalendarOffset, Filters, Tab } from './FilterBarTypes';
3
+ import { FilterBarProps } from './FilterBarTypes';
5
4
  import './FilterBar.css';
6
- export type FilterBarProps = {
7
- language?: string;
8
- ageCategories?: AgeCategoryType[];
9
- redirectUrl?: string;
10
- palette?: Palette;
11
- onSubmit?: ((val: Filters) => void) | null;
12
- fullWidth?: boolean;
13
- calendarOffset?: CalendarOffset;
14
- mode?: string;
15
- defaultTab?: string;
16
- tabs?: Tab[];
17
- };
18
- export default function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, calendarOffset, mode, tabs, }: FilterBarProps): React.JSX.Element | null;
5
+ export default function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, calendarOffset, mode, tabs, }: FilterBarProps): React.JSX.Element;
@@ -1,3 +1,17 @@
1
+ import { Palette } from '../../themes/useTheme';
2
+ import { CalendarOffset } from '../../core/components/calendar/CalendarTypes';
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
+ calendarOffset?: CalendarOffset;
11
+ mode?: string;
12
+ defaultTab?: string;
13
+ tabs?: Tab[];
14
+ };
1
15
  export type AgeCategoryCount = {
2
16
  [categoryId: string]: number;
3
17
  };
@@ -27,9 +41,6 @@ export declare enum Pages {
27
41
  ROOMS = "/rooms",
28
42
  EVENTS = "/events"
29
43
  }
30
- export type CalendarOffset = {
31
- [key: string]: number;
32
- };
33
44
  type Translations = {
34
45
  en: string;
35
46
  fi: string;
@@ -1,4 +1,4 @@
1
- export { CloseButton } from './close-button/CloseButton';
1
+ export { CloseButton } from '../../../../core/components/buttons/close-button/CloseButton';
2
+ export { SubmitButton } from '../../../../core/components/buttons/submit-button/SubmitButton';
2
3
  export { SelectButton } from './select-button/SelectButton';
3
- export { SubmitButton } from './submit-button/SubmitButton';
4
4
  export { TabButton } from './tab-button/TabButton';
@@ -1,5 +1,4 @@
1
1
  export { CloseButton, SelectButton, SubmitButton, TabButton } from './buttons';
2
2
  export { Guests } from './guests/Guests';
3
- export { Calendar } from './calendar/Calendar';
4
3
  export { Divider } from './divider/Divider';
5
4
  export { Categories } from './categories/Categories';
@@ -1,4 +1,2 @@
1
1
  export { useFilterBar } from './useFilterBar';
2
2
  export { useScrollInToView } from './useScrollInToView';
3
- export { useUpdateTranslations } from './useUpdateTranslations';
4
- export { useCloseFilterSection } from './useCloseFilterSection';
@@ -1,2 +1 @@
1
- export { parseDates } from './parseDates';
2
1
  export { parseGuests } from './parseGuests';
@@ -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, calendarOffsetGroup, toggleCalendar, setToggleCalendar, }: FilterCalendarTypes): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import FilterCalendar from './FilterCalendar';
3
+ declare const meta: Meta<typeof FilterCalendar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof FilterCalendar>;
6
+ export declare const Primary: Story;
@@ -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,13 @@
1
+ /// <reference types="react" />
2
+ import { DateRange } from 'react-day-picker';
3
+ type Props = {
4
+ onSubmit: (val: any) => void;
5
+ setToggleCalendar: (val: boolean) => void;
6
+ };
7
+ export declare const useFilterCalendar: ({ onSubmit, setToggleCalendar }: Props) => {
8
+ handleSubmit: () => void;
9
+ handleClearDates: () => void;
10
+ setCalendarRange: import("react").Dispatch<import("react").SetStateAction<DateRange | undefined>>;
11
+ calendarRange: DateRange | undefined;
12
+ };
13
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './FilterCalendar';
2
+ export * from './FilterCalendarTypes';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import './CloseButton.css';
3
+ interface CloseButtonPropsType {
4
+ handleClose: () => void;
5
+ }
6
+ export declare const CloseButton: ({ handleClose }: CloseButtonPropsType) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,10 @@
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
+ };
9
+ export declare const SubmitButton: ({ onClick, startIcon, label, disabled, }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import 'react-day-picker/dist/style.css';
3
+ import './Calendar.css';
4
+ import { CalendarTypes } from './CalendarTypes';
5
+ export declare const Calendar: React.ForwardRefExoticComponent<CalendarTypes & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,15 @@
1
+ import { DateRange } from 'react-day-picker';
2
+ export type CalendarOffset = {
3
+ [key: string]: number;
4
+ };
5
+ export type CalendarTypes = {
6
+ calendarRange?: DateRange | undefined;
7
+ setCalendarRange: (range: DateRange | undefined) => void;
8
+ calendarOffset?: CalendarOffset;
9
+ selectedPath?: string;
10
+ language?: string;
11
+ calendarOffsetGroup?: {
12
+ from: Date;
13
+ to: Date;
14
+ }[];
15
+ };
@@ -0,0 +1,3 @@
1
+ export { SubmitButton } from './buttons/submit-button/SubmitButton';
2
+ export { CloseButton } from './buttons/close-button/CloseButton';
3
+ export { Calendar } from './calendar/Calendar';
@@ -0,0 +1,3 @@
1
+ export { useAwaitRender } from './useAwaitRender';
2
+ export { useUpdateTranslations } from './useUpdateTranslations';
3
+ export { useCloseFilterSection } from './useCloseFilterSection';
@@ -0,0 +1 @@
1
+ export declare const useAwaitRender: () => null | undefined;
@@ -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,5 @@
1
+ type Props = {
2
+ language?: string;
3
+ };
4
+ export declare const useUpdateTranslations: ({ language }: Props) => void;
5
+ export {};
@@ -0,0 +1,3 @@
1
+ export { parseDates } from './parseDates';
2
+ export { parseDate } from './parseDate';
3
+ export { nightsCount } from './nightsCount';
@@ -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,6 @@
1
+ type Props = {
2
+ date?: Date;
3
+ dateFormat?: string;
4
+ };
5
+ export declare const parseDate: ({ date, dateFormat }: Props) => string | null;
6
+ 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
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { DateRange } from 'react-day-picker';
2
3
 
3
4
  interface ButtonProps {
4
5
  /**
@@ -27,11 +28,38 @@ interface ButtonProps {
27
28
  */
28
29
  declare const Button: ({ type, textColor, size, onClick, label, }: ButtonProps) => React.JSX.Element;
29
30
 
30
- interface Palette {
31
+ type Palette = {
31
32
  primary: string;
32
33
  secondary: string;
33
- }
34
+ };
35
+
36
+ type CalendarOffset = {
37
+ [key: string]: number;
38
+ };
39
+ type CalendarTypes = {
40
+ calendarRange?: DateRange | undefined;
41
+ setCalendarRange: (range: DateRange | undefined) => void;
42
+ calendarOffset?: CalendarOffset;
43
+ selectedPath?: string;
44
+ language?: string;
45
+ calendarOffsetGroup?: {
46
+ from: Date;
47
+ to: Date;
48
+ }[];
49
+ };
34
50
 
51
+ type FilterBarProps = {
52
+ language?: string;
53
+ ageCategories?: AgeCategoryType[];
54
+ redirectUrl?: string;
55
+ palette?: Palette;
56
+ onSubmit?: ((val: Filters) => void) | null;
57
+ fullWidth?: boolean;
58
+ calendarOffset?: CalendarOffset;
59
+ mode?: string;
60
+ defaultTab?: string;
61
+ tabs?: Tab[];
62
+ };
35
63
  type AgeCategoryType = {
36
64
  id: string;
37
65
  name: string;
@@ -41,9 +69,6 @@ type AgeCategoryType = {
41
69
  type Filters = {
42
70
  [key: string]: string;
43
71
  };
44
- type CalendarOffset = {
45
- [key: string]: number;
46
- };
47
72
  type Translations = {
48
73
  en: string;
49
74
  fi: string;
@@ -56,18 +81,15 @@ type Tab = {
56
81
  label?: Translations;
57
82
  };
58
83
 
59
- type FilterBarProps = {
60
- language?: string;
61
- ageCategories?: AgeCategoryType[];
62
- redirectUrl?: string;
63
- palette?: Palette;
64
- onSubmit?: ((val: Filters) => void) | null;
65
- fullWidth?: boolean;
66
- calendarOffset?: CalendarOffset;
67
- mode?: string;
68
- defaultTab?: string;
69
- tabs?: Tab[];
70
- };
71
- declare function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, calendarOffset, mode, tabs, }: FilterBarProps): React.JSX.Element | null;
84
+ declare function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, calendarOffset, mode, tabs, }: FilterBarProps): React.JSX.Element;
85
+
86
+ interface FilterCalendarTypes extends Partial<CalendarTypes> {
87
+ palette: Palette;
88
+ onSubmit: (val: DateRange) => void;
89
+ toggleCalendar: boolean;
90
+ setToggleCalendar: (val: boolean) => void;
91
+ }
92
+
93
+ declare function FilterCalendar({ calendarOffset, language, palette, onSubmit, calendarOffsetGroup, toggleCalendar, setToggleCalendar, }: FilterCalendarTypes): React.JSX.Element;
72
94
 
73
- export { Button, FilterBar, Tab };
95
+ export { Button, FilterBar, FilterCalendar, FilterCalendarTypes, Tab };