willba-component-library 0.2.102 → 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.
- package/.nvmrc +1 -1
- package/.storybook/main.ts +4 -6
- package/.storybook/preview.ts +1 -1
- package/README.md +21 -1
- package/lib/components/FilterBar/FilterBar.d.ts +1 -1
- package/lib/components/FilterBar/FilterBarTypes.d.ts +12 -2
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +3 -1
- package/lib/components/FilterBar/components/cards/image-card/ImageCard.d.ts +11 -0
- package/lib/components/FilterBar/components/cards/index.d.ts +1 -0
- package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +2 -2
- package/lib/components/FilterBar/components/guests/Guests.d.ts +1 -0
- package/lib/components/FilterBar/components/index.d.ts +1 -0
- package/lib/components/FilterBar/components/locations/Locations.d.ts +14 -0
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +8 -4
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +0 -1
- package/lib/components/FilterBar/utils/index.d.ts +1 -0
- package/lib/components/FilterBar/utils/parseLocations.d.ts +9 -0
- package/lib/components/FilterCalendar/components/Footer.d.ts +2 -2
- package/lib/components/FilterCalendar/hooks/useFilterCalendar.d.ts +0 -1
- package/lib/core/components/calendar/CalendarTypes.d.ts +1 -0
- package/lib/core/components/calendar/utils/disabledDatesByPage.d.ts +2 -2
- package/lib/core/hooks/index.d.ts +1 -0
- package/lib/core/hooks/useAutoFocus.d.ts +1 -0
- package/lib/core/hooks/useCloseFilterSection.d.ts +0 -1
- package/lib/index.d.ts +12 -2
- package/lib/index.esm.js +3884 -3478
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +3952 -3564
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +3954 -3567
- package/lib/index.umd.js.map +1 -1
- package/package.json +22 -22
- package/rollup.config.mjs +1 -0
- package/src/components/FilterBar/FilterBar.stories.tsx +61 -4
- package/src/components/FilterBar/FilterBar.tsx +101 -25
- package/src/components/FilterBar/FilterBarTypes.ts +12 -1
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +28 -21
- package/src/components/FilterBar/components/cards/image-card/ImageCard.css +25 -0
- package/src/components/FilterBar/components/cards/image-card/ImageCard.tsx +45 -0
- package/src/components/FilterBar/components/cards/index.ts +1 -0
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +3 -3
- package/src/components/FilterBar/components/guests/Guests.tsx +9 -3
- package/src/components/FilterBar/components/index.ts +1 -0
- package/src/components/FilterBar/components/locations/Locations.css +32 -0
- package/src/components/FilterBar/components/locations/Locations.tsx +86 -0
- package/src/components/FilterBar/hooks/useFilterBar.tsx +25 -8
- package/src/components/FilterBar/utils/index.tsx +1 -0
- package/src/components/FilterBar/utils/parseLocations.tsx +29 -0
- package/src/core/components/calendar/Calendar.tsx +5 -1
- package/src/core/components/calendar/CalendarTypes.ts +1 -0
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/useAutoFocus.tsx +27 -0
- package/src/locales/en/filterBar.json +6 -0
- package/src/locales/fi/filterBar.json +6 -0
- package/tsconfig.json +1 -1
- package/lib/assets/SpinnerSvg.d.ts +0 -5
- package/lib/components/Button/Button.stories.d.ts +0 -7
- package/lib/components/FilterBar/FilterBar.stories.d.ts +0 -6
- package/lib/components/FilterBar/components/buttons/close-button/CloseButton.d.ts +0 -7
- package/lib/components/FilterBar/components/buttons/submit-button/SubmitButton.d.ts +0 -3
- package/lib/components/FilterBar/components/calendar/Calendar.d.ts +0 -14
- package/lib/components/FilterBar/hooks/useCloseFilterSection.d.ts +0 -8
- package/lib/components/FilterBar/hooks/useUpdateTranslations.d.ts +0 -5
- package/lib/components/FilterBar/utils/parseDates.d.ts +0 -6
- package/lib/components/FilterCalendar/FilterCalendar.stories.d.ts +0 -8
- package/lib/core/utils/handleOverlappingDates.d.ts +0 -1
- package/lib/core/utils/index.d.ts +0 -3
- package/lib/core/utils/nightsCount.d.ts +0 -6
- package/lib/core/utils/parseDate.d.ts +0 -7
- package/lib/core/utils/parseDates.d.ts +0 -6
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
24.13.0
|
package/.storybook/main.ts
CHANGED
|
@@ -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-
|
|
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;
|
package/.storybook/preview.ts
CHANGED
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
|
-
|
|
|
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,
|
|
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
|
-
|
|
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:
|
|
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
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { GuestsCountPropsType } from '../../../FilterBarTypes';
|
|
3
3
|
import './GuestCount.css';
|
|
4
|
-
export
|
|
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
|
-
|
|
8
|
+
locations?: {
|
|
9
|
+
multiSelect: boolean;
|
|
10
|
+
data: Location[];
|
|
11
|
+
};
|
|
10
12
|
};
|
|
11
|
-
export declare const useFilterBar: ({ redirectUrl, ageCategories, onSubmit, tabs,
|
|
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>>;
|
|
@@ -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
|
|
6
|
+
calendarRange?: DateRange;
|
|
7
7
|
handleClearDates: () => void;
|
|
8
|
-
language?: string
|
|
8
|
+
language?: string;
|
|
9
9
|
palette: Palette;
|
|
10
10
|
}) => React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DisableCalendarDates } from '../CalendarTypes';
|
|
2
2
|
export declare const disabledDatesByPage: ({ newDisableCalendarDates, selectedPath, today, }: {
|
|
3
|
-
newDisableCalendarDates?: DisableCalendarDates
|
|
4
|
-
selectedPath?: string
|
|
3
|
+
newDisableCalendarDates?: DisableCalendarDates;
|
|
4
|
+
selectedPath?: string;
|
|
5
5
|
today: Date;
|
|
6
6
|
}) => {
|
|
7
7
|
from: Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAutoFocus: <T extends HTMLElement>(autoFocus?: boolean) => import("react").RefObject<T>;
|
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
|
-
|
|
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,
|
|
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;
|