willba-component-library 0.2.101 → 0.3.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 (60) hide show
  1. package/.nvmrc +1 -1
  2. package/.storybook/main.ts +4 -6
  3. package/.storybook/preview.ts +1 -1
  4. package/README.md +21 -1
  5. package/lib/components/FilterBar/FilterBar.d.ts +1 -1
  6. package/lib/components/FilterBar/FilterBarTypes.d.ts +12 -2
  7. package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +3 -1
  8. package/lib/components/FilterBar/components/cards/image-card/ImageCard.d.ts +11 -0
  9. package/lib/components/FilterBar/components/cards/index.d.ts +1 -0
  10. package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +2 -2
  11. package/lib/components/FilterBar/components/guests/Guests.d.ts +1 -0
  12. package/lib/components/FilterBar/components/index.d.ts +1 -0
  13. package/lib/components/FilterBar/components/locations/Locations.d.ts +14 -0
  14. package/lib/components/FilterBar/hooks/useFilterBar.d.ts +8 -4
  15. package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +0 -1
  16. package/lib/components/FilterBar/utils/index.d.ts +1 -0
  17. package/lib/components/FilterBar/utils/parseLocations.d.ts +9 -0
  18. package/lib/components/FilterCalendar/components/Footer.d.ts +2 -2
  19. package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +0 -1
  20. package/lib/core/components/calendar/CalendarTypes.d.ts +1 -0
  21. package/lib/core/components/calendar/utils/disabledDatesByPage.d.ts +2 -2
  22. package/lib/core/hooks/index.d.ts +1 -0
  23. package/lib/core/hooks/useAutoFocus.d.ts +1 -0
  24. package/lib/core/hooks/useCloseFilterSection.d.ts +0 -1
  25. package/lib/index.d.ts +12 -2
  26. package/lib/index.esm.js +3890 -3481
  27. package/lib/index.esm.js.map +1 -1
  28. package/lib/index.js +3958 -3567
  29. package/lib/index.js.map +1 -1
  30. package/lib/index.umd.js +3960 -3570
  31. package/lib/index.umd.js.map +1 -1
  32. package/package.json +22 -22
  33. package/rollup.config.mjs +1 -0
  34. package/src/components/FilterBar/FilterBar.css +11 -10
  35. package/src/components/FilterBar/FilterBar.stories.tsx +66 -9
  36. package/src/components/FilterBar/FilterBar.tsx +101 -25
  37. package/src/components/FilterBar/FilterBarTypes.ts +12 -1
  38. package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +28 -21
  39. package/src/components/FilterBar/components/cards/image-card/ImageCard.css +25 -0
  40. package/src/components/FilterBar/components/cards/image-card/ImageCard.tsx +45 -0
  41. package/src/components/FilterBar/components/cards/index.ts +1 -0
  42. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +3 -3
  43. package/src/components/FilterBar/components/guests/Guests.tsx +9 -3
  44. package/src/components/FilterBar/components/index.ts +1 -0
  45. package/src/components/FilterBar/components/locations/Locations.css +32 -0
  46. package/src/components/FilterBar/components/locations/Locations.tsx +86 -0
  47. package/src/components/FilterBar/hooks/useFilterBar.tsx +25 -8
  48. package/src/components/FilterBar/utils/index.tsx +1 -0
  49. package/src/components/FilterBar/utils/parseGuests.tsx +7 -6
  50. package/src/components/FilterBar/utils/parseLocations.tsx +29 -0
  51. package/src/core/components/calendar/Calendar.tsx +5 -1
  52. package/src/core/components/calendar/CalendarTypes.ts +1 -0
  53. package/src/core/hooks/index.ts +1 -0
  54. package/src/core/hooks/useAutoFocus.tsx +27 -0
  55. package/src/locales/en/filterBar.json +6 -0
  56. package/src/locales/fi/filterBar.json +6 -0
  57. package/tsconfig.json +1 -1
  58. package/lib/components/Button/Button.stories.d.ts +0 -7
  59. package/lib/components/FilterBar/FilterBar.stories.d.ts +0 -6
  60. package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +0 -8
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 18.17.0
1
+ 24.13.0
@@ -2,18 +2,16 @@ import type { StorybookConfig } from "@storybook/react-vite";
2
2
 
3
3
  const config: StorybookConfig = {
4
4
  stories: ["../src/**/*.stories.tsx"],
5
+
5
6
  addons: [
6
7
  "@storybook/addon-links",
7
- "@storybook/addon-essentials",
8
8
  "@storybook/addon-onboarding",
9
- "@storybook/addon-interactions",
9
+ "@storybook/addon-docs"
10
10
  ],
11
+
11
12
  framework: {
12
13
  name: "@storybook/react-vite",
13
14
  options: {},
14
- },
15
- docs: {
16
- autodocs: "tag",
17
- },
15
+ }
18
16
  };
19
17
  export default config;
@@ -1,4 +1,4 @@
1
- import type { Preview } from "@storybook/react";
1
+ import type { Preview } from "@storybook/react-vite";
2
2
 
3
3
  const preview: Preview = {
4
4
  parameters: {
package/README.md CHANGED
@@ -84,6 +84,16 @@ function App() {
84
84
  order: 1,
85
85
  },
86
86
  ]}
87
+ locations={{
88
+ multiSelect: false,
89
+ data: [
90
+ {
91
+ id: '1',
92
+ label: { en: 'Helsinki', fi: 'Helsinki' },
93
+ imageUrl: 'https://example.com/helsinki.jpg',
94
+ },
95
+ ],
96
+ }}
87
97
  />
88
98
  )
89
99
  }
@@ -171,6 +181,16 @@ ReactDOM.render(<App />, document.querySelector('#app'))
171
181
  order: 1,
172
182
  },
173
183
  ],
184
+ locations: {
185
+ multiSelect: false,
186
+ data: [
187
+ {
188
+ id: '1',
189
+ label: { en: 'Helsinki', fi: 'Helsinki' },
190
+ imageUrl: 'https://example.com/helsinki.jpg',
191
+ },
192
+ ],
193
+ },
174
194
  })
175
195
  )
176
196
  </script>
@@ -188,4 +208,4 @@ ReactDOM.render(<App />, document.querySelector('#app'))
188
208
  | ageCategories | `[{}]` | The ageCategories prop will determine the types of guests that can be selected. Specify the age categories for guests using the following format: `[{ id: string, name: string, minVal: number, sortOrder: number }]`. For example: `[{ id: '1', name: 'Aikuiset', minVal: 1, sortOrder: 1 }]` |
189
209
  | fullWidth | `true` | Specify whether the filter bar width should be dynamic or fixed. |
190
210
  | tabs | `[{}]` | Manage the filter bar tabs using the following format: `[{path: string, default: boolean, order: number, label: { en: string, fi: string }}]`. For example: `[{ path: '/rooms', default: true, order: 2, label: { en: 'Rooms', fi: 'Hilat' }}]` |
191
- | locationIds | `string[]` | Specifies an array of location identifiers to be included as query parameters in the redirect URL after filter submission. Each ID will be appended as a separate `locationId` parameter. Default is `undefined`. For example: `['1', '2']` results in `?locationId=1&locationId=2` |
211
+ | locations | `{}` | Configures location filter. Format: `{ multiSelect: boolean, data: Location[] }` where Location = `{ id: string, label: { en: string, fi: string }, description?: { en: string, fi: string }, imageUrl?: string }`. `multiSelect` enables multi-selection, `description` shows under title, `imageUrl` displays location image. Example: `{ multiSelect: false, data: [{ id: '1', label: { en: 'Helsinki', fi: 'Helsinki' }, description: { en: 'Capital', fi: 'Pääkaupunki' }, imageUrl: 'https://example.com/helsinki.jpg' }] }` |
@@ -2,4 +2,4 @@ import React from 'react';
2
2
  import '../../themes/Default.css';
3
3
  import { FilterBarTypes } from './FilterBarTypes';
4
4
  import './FilterBar.css';
5
- export default function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, disableCalendarDates, mode, tabs, outerLoading, locationIds, }: FilterBarTypes): React.JSX.Element;
5
+ export default function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, disableCalendarDates, mode, tabs, outerLoading, locations, }: FilterBarTypes): React.JSX.Element;
@@ -11,7 +11,10 @@ export type FilterBarTypes = {
11
11
  mode?: string;
12
12
  tabs?: Tab[];
13
13
  outerLoading?: boolean;
14
- locationIds?: string[];
14
+ locations?: {
15
+ multiSelect: boolean;
16
+ data: Location[];
17
+ };
15
18
  };
16
19
  export type AgeCategoryCount = {
17
20
  [categoryId: string]: number;
@@ -33,7 +36,8 @@ export type GuestsCountPropsType = {
33
36
  export declare enum FilterSections {
34
37
  CALENDAR = "calendar",
35
38
  GUESTS = "guests",
36
- CATEGORIES = "categories"
39
+ CATEGORIES = "categories",
40
+ LOCATIONS = "locations"
37
41
  }
38
42
  export type Filters = {
39
43
  [key: string]: string;
@@ -54,4 +58,10 @@ export type Tab = {
54
58
  order: number;
55
59
  label?: Translations;
56
60
  };
61
+ export type Location = {
62
+ id: string;
63
+ label: Translations;
64
+ description?: Translations;
65
+ imageUrl?: string;
66
+ };
57
67
  export {};
@@ -5,6 +5,8 @@ type Props = {
5
5
  onClick: () => void;
6
6
  description: string;
7
7
  active?: boolean;
8
+ ariaExpanded?: boolean;
9
+ ariaControls?: string;
8
10
  };
9
- export declare const SelectButton: ({ active, label, onClick, description, }: Props) => React.JSX.Element;
11
+ export declare const SelectButton: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLButtonElement>>;
10
12
  export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import './ImageCard.css';
3
+ type Props = {
4
+ title?: string;
5
+ description?: string;
6
+ imageUrl?: string;
7
+ isSelected: boolean;
8
+ onClick?: () => void;
9
+ };
10
+ export declare const ImageCard: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
11
+ export {};
@@ -0,0 +1 @@
1
+ export { ImageCard } from './image-card/ImageCard';
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { FC } from 'react';
2
2
  import { GuestsCountPropsType } from '../../../FilterBarTypes';
3
3
  import './GuestCount.css';
4
- export default function GuestCount({ label, sortOrder, id, updateGuestsCount, count, minVal, }: GuestsCountPropsType): React.JSX.Element;
4
+ export declare const GuestCount: FC<GuestsCountPropsType>;
@@ -5,6 +5,7 @@ type Props = {
5
5
  ageCategories: AgeCategoryType[];
6
6
  updateGuestsCount: (arg1: string, arg2: number) => void;
7
7
  ageCategoryCounts: AgeCategoryCount;
8
+ autoFocus?: boolean;
8
9
  };
9
10
  export declare const Guests: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
10
11
  export {};
@@ -2,3 +2,4 @@ export { CloseButton, SelectButton, SubmitButton, TabButton } from './buttons';
2
2
  export { Guests } from './guests/Guests';
3
3
  export { Divider } from './divider/Divider';
4
4
  export { Categories } from './categories/Categories';
5
+ export { Locations } from './locations/Locations';
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import './Locations.css';
3
+ import { Location } from '../../FilterBarTypes';
4
+ type Props = {
5
+ locations?: Location[];
6
+ language?: string;
7
+ selectedLocations: Location[];
8
+ setSelectedLocations: (locations: Location[]) => void;
9
+ autoFocus?: boolean;
10
+ multiSelect?: boolean;
11
+ onClose?: () => void;
12
+ };
13
+ export declare const Locations: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
14
+ export {};
@@ -1,20 +1,24 @@
1
- /// <reference types="react" />
2
1
  import { DateRange } from 'react-day-picker';
3
- import { AgeCategoryCount, AgeCategoryType, Filters, Tab } from '../FilterBarTypes';
2
+ import { AgeCategoryCount, AgeCategoryType, Filters, Tab, Location } from '../FilterBarTypes';
4
3
  type Props = {
5
4
  redirectUrl?: string;
6
5
  ageCategories?: AgeCategoryType[];
7
6
  onSubmit?: ((val: Filters) => void) | null;
8
7
  tabs?: Tab[];
9
- locationIds?: string[];
8
+ locations?: {
9
+ multiSelect: boolean;
10
+ data: Location[];
11
+ };
10
12
  };
11
- export declare const useFilterBar: ({ redirectUrl, ageCategories, onSubmit, tabs, locationIds, }: Props) => {
13
+ export declare const useFilterBar: ({ redirectUrl, ageCategories, onSubmit, tabs, locations, }: Props) => {
12
14
  selectedFilter: string | boolean;
13
15
  ageCategoryCounts: AgeCategoryCount;
14
16
  categories: number;
15
17
  calendarRange: DateRange | undefined;
16
18
  selectedPath: string;
17
19
  innerLoading: boolean;
20
+ selectedLocations: Location[];
21
+ setSelectedLocations: import("react").Dispatch<import("react").SetStateAction<Location[]>>;
18
22
  setCalendarRange: import("react").Dispatch<import("react").SetStateAction<DateRange | undefined>>;
19
23
  setSelectedFilter: import("react").Dispatch<import("react").SetStateAction<string | boolean>>;
20
24
  setAgeCategoryCounts: import("react").Dispatch<import("react").SetStateAction<AgeCategoryCount>>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  selectedFilter: string | boolean;
4
3
  };
@@ -1 +1,2 @@
1
1
  export { parseGuests } from './parseGuests';
2
+ export { parseLocations } from './parseLocations';
@@ -0,0 +1,9 @@
1
+ import { Location } from '../FilterBarTypes';
2
+ type Props = {
3
+ selectedLocations: Location[];
4
+ language: string;
5
+ locationsPlaceholder: string;
6
+ locationsSelectedLabel?: string;
7
+ };
8
+ export declare const parseLocations: ({ selectedLocations, language, locationsPlaceholder, locationsSelectedLabel, }: Props) => string;
9
+ export {};
@@ -3,8 +3,8 @@ import { DateRange } from 'react-day-picker';
3
3
  import { Palette } from '../../../themes/useTheme';
4
4
  export declare const Footer: ({ calendarHasError, calendarRange, handleClearDates, language, palette, }: {
5
5
  calendarHasError: boolean;
6
- calendarRange?: DateRange | undefined;
6
+ calendarRange?: DateRange;
7
7
  handleClearDates: () => void;
8
- language?: string | undefined;
8
+ language?: string;
9
9
  palette: Palette;
10
10
  }) => React.JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { DateRange, Matcher } from 'react-day-picker';
3
2
  import { DisableCalendarDates, RangeContext } from 'src/core/components/calendar/CalendarTypes';
4
3
  type Props = {
@@ -43,4 +43,5 @@ export type CalendarTypes = {
43
43
  setUpdatedForSubmit?: (arg: boolean) => void;
44
44
  rangeContext?: RangeContext;
45
45
  calendarHasError?: boolean;
46
+ autoFocus?: boolean;
46
47
  };
@@ -1,7 +1,7 @@
1
1
  import { DisableCalendarDates } from '../CalendarTypes';
2
2
  export declare const disabledDatesByPage: ({ newDisableCalendarDates, selectedPath, today, }: {
3
- newDisableCalendarDates?: DisableCalendarDates | undefined;
4
- selectedPath?: string | undefined;
3
+ newDisableCalendarDates?: DisableCalendarDates;
4
+ selectedPath?: string;
5
5
  today: Date;
6
6
  }) => {
7
7
  from: Date;
@@ -1,3 +1,4 @@
1
1
  export { useAwaitRender } from './useAwaitRender';
2
2
  export { useUpdateTranslations } from './useUpdateTranslations';
3
3
  export { useCloseFilterSection } from './useCloseFilterSection';
4
+ export { useAutoFocus } from './useAutoFocus';
@@ -0,0 +1 @@
1
+ export declare const useAutoFocus: <T extends HTMLElement>(autoFocus?: boolean) => import("react").RefObject<T>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  handleSelectedFilter: (arg: boolean) => void;
4
3
  };
package/lib/index.d.ts CHANGED
@@ -77,6 +77,7 @@ type CalendarTypes = {
77
77
  setUpdatedForSubmit?: (arg: boolean) => void;
78
78
  rangeContext?: RangeContext;
79
79
  calendarHasError?: boolean;
80
+ autoFocus?: boolean;
80
81
  };
81
82
 
82
83
  type FilterBarTypes = {
@@ -90,7 +91,10 @@ type FilterBarTypes = {
90
91
  mode?: string;
91
92
  tabs?: Tab[];
92
93
  outerLoading?: boolean;
93
- locationIds?: string[];
94
+ locations?: {
95
+ multiSelect: boolean;
96
+ data: Location[];
97
+ };
94
98
  };
95
99
  type AgeCategoryType = {
96
100
  id: string;
@@ -112,8 +116,14 @@ type Tab = {
112
116
  order: number;
113
117
  label?: Translations;
114
118
  };
119
+ type Location = {
120
+ id: string;
121
+ label: Translations;
122
+ description?: Translations;
123
+ imageUrl?: string;
124
+ };
115
125
 
116
- declare function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, disableCalendarDates, mode, tabs, outerLoading, locationIds, }: FilterBarTypes): React.JSX.Element;
126
+ declare function FilterBar({ language, ageCategories, redirectUrl, palette, onSubmit, fullWidth, disableCalendarDates, mode, tabs, outerLoading, locations, }: FilterBarTypes): React.JSX.Element;
117
127
 
118
128
  interface FilterCalendarTypes extends Partial<CalendarTypes> {
119
129
  palette: Palette;