willba-component-library 0.3.26 → 0.4.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/README.md +75 -113
- package/lib/components/FilterBar/FilterBar.d.ts +1 -1
- package/lib/components/FilterCalendar/FilterCalendar.d.ts +1 -1
- package/lib/core/i18n/I18nProvider.d.ts +6 -0
- package/lib/core/i18n/index.d.ts +1 -0
- package/lib/embed.d.ts +18 -0
- package/lib/embed.esm.js +74 -0
- package/lib/embed.esm.js.map +1 -0
- package/lib/embed.umd.js +74 -0
- package/lib/embed.umd.js.map +1 -0
- package/lib/i18n.d.ts +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +1112 -931
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1111 -930
- package/lib/index.js.map +1 -1
- package/package.json +9 -1
- package/.nvmrc +0 -1
- package/.storybook/main.ts +0 -17
- package/.storybook/preview.ts +0 -15
- package/lib/components/FilterBar/components/buttons/index.d.ts +0 -4
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +0 -13
- package/lib/components/FilterBar/components/buttons/tab-button/TabButton.d.ts +0 -10
- package/lib/components/FilterBar/components/cards/image-card/ImageCard.d.ts +0 -11
- package/lib/components/FilterBar/components/cards/index.d.ts +0 -1
- package/lib/components/FilterBar/components/categories/Categories.d.ts +0 -8
- package/lib/components/FilterBar/components/common/FilterSectionHeader.d.ts +0 -8
- package/lib/components/FilterBar/components/dates/Dates.d.ts +0 -17
- package/lib/components/FilterBar/components/dates/index.d.ts +0 -1
- package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +0 -4
- package/lib/components/FilterBar/components/guests/Guests.d.ts +0 -12
- package/lib/components/FilterBar/components/locations/Locations.d.ts +0 -14
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +0 -32
- package/lib/components/FilterBar/hooks/useFilterUi.d.ts +0 -8
- package/lib/components/FilterBar/utils/calculateDropdownPosition.d.ts +0 -12
- package/lib/components/FilterBar/utils/getLocalizedContent.d.ts +0 -8
- package/lib/core/components/buttons/close-button/CloseButton.d.ts +0 -7
- package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +0 -14
- package/lib/index.umd.js +0 -12489
- package/lib/index.umd.js.map +0 -1
- package/prettier.config.js +0 -6
- package/rollup.config.mjs +0 -63
- package/src/assets/IconsSvg.tsx +0 -69
- package/src/components/Button/Button.stories.tsx +0 -34
- package/src/components/Button/Button.tsx +0 -56
- package/src/components/Button/button.css +0 -30
- package/src/components/Button/index.ts +0 -1
- package/src/components/FilterBar/FilterBar.css +0 -35
- package/src/components/FilterBar/FilterBar.stories.tsx +0 -116
- package/src/components/FilterBar/FilterBar.tsx +0 -64
- package/src/components/FilterBar/FilterBarTypes.ts +0 -71
- package/src/components/FilterBar/components/Divider/Divider.css +0 -14
- package/src/components/FilterBar/components/Divider/Divider.tsx +0 -7
- package/src/components/FilterBar/components/FilterControls/FilterControls.css +0 -22
- package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +0 -139
- package/src/components/FilterBar/components/FilterPanels/Categories/Categories.css +0 -21
- package/src/components/FilterBar/components/FilterPanels/Categories/Categories.tsx +0 -49
- package/src/components/FilterBar/components/FilterPanels/Dates/Dates.css +0 -9
- package/src/components/FilterBar/components/FilterPanels/Dates/Dates.tsx +0 -60
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.css +0 -22
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +0 -111
- package/src/components/FilterBar/components/FilterPanels/Guests/GuestCount/GuestCount.css +0 -58
- package/src/components/FilterBar/components/FilterPanels/Guests/GuestCount/GuestCount.tsx +0 -85
- package/src/components/FilterBar/components/FilterPanels/Guests/Guests.css +0 -24
- package/src/components/FilterBar/components/FilterPanels/Guests/Guests.tsx +0 -59
- package/src/components/FilterBar/components/FilterPanels/Locations/Locations.css +0 -16
- package/src/components/FilterBar/components/FilterPanels/Locations/Locations.tsx +0 -94
- package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.css +0 -34
- package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.tsx +0 -17
- package/src/components/FilterBar/components/FilterTabs/FilterTabs.css +0 -10
- package/src/components/FilterBar/components/FilterTabs/FilterTabs.tsx +0 -50
- package/src/components/FilterBar/components/ImageCard/ImageCard.css +0 -30
- package/src/components/FilterBar/components/ImageCard/ImageCard.tsx +0 -45
- package/src/components/FilterBar/components/SelectButton/SelectButton.css +0 -76
- package/src/components/FilterBar/components/SelectButton/SelectButton.tsx +0 -54
- package/src/components/FilterBar/components/TabButton/TabButton.css +0 -36
- package/src/components/FilterBar/components/TabButton/TabButton.tsx +0 -23
- package/src/components/FilterBar/components/index.ts +0 -6
- package/src/components/FilterBar/hooks/index.ts +0 -5
- package/src/components/FilterBar/hooks/useFilterActions.tsx +0 -126
- package/src/components/FilterBar/hooks/useFilterRefs.tsx +0 -21
- package/src/components/FilterBar/hooks/useFilterState.tsx +0 -86
- package/src/components/FilterBar/hooks/usePanelPosition.tsx +0 -52
- package/src/components/FilterBar/hooks/useScrollInToView.tsx +0 -29
- package/src/components/FilterBar/index.ts +0 -3
- package/src/components/FilterBar/providers/FilterBarProvider.tsx +0 -172
- package/src/components/FilterBar/providers/index.ts +0 -1
- package/src/components/FilterBar/utils/ageCategoriesRules.ts +0 -27
- package/src/components/FilterBar/utils/index.tsx +0 -3
- package/src/components/FilterBar/utils/parseGuests.tsx +0 -65
- package/src/components/FilterBar/utils/parseLocations.ts +0 -28
- package/src/components/FilterCalendar/FilterCalendar.css +0 -109
- package/src/components/FilterCalendar/FilterCalendar.stories.tsx +0 -554
- package/src/components/FilterCalendar/FilterCalendar.tsx +0 -115
- package/src/components/FilterCalendar/FilterCalendarTypes.ts +0 -11
- package/src/components/FilterCalendar/components/Footer.tsx +0 -96
- package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +0 -163
- package/src/components/FilterCalendar/index.ts +0 -3
- package/src/core/components/buttons/CloseButton/CloseButton.css +0 -33
- package/src/core/components/buttons/CloseButton/CloseButton.tsx +0 -16
- package/src/core/components/buttons/SubmitButton/SubmitButton.css +0 -54
- package/src/core/components/buttons/SubmitButton/SubmitButton.tsx +0 -42
- package/src/core/components/calendar/Calendar.css +0 -280
- package/src/core/components/calendar/Calendar.tsx +0 -253
- package/src/core/components/calendar/CalendarTypes.ts +0 -48
- package/src/core/components/calendar/hooks/index.ts +0 -3
- 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 -105
- package/src/core/components/calendar/utils/calendarSelectionRules.tsx +0 -180
- package/src/core/components/calendar/utils/checkForContinuousSelection.tsx +0 -86
- package/src/core/components/calendar/utils/disabledDatesByPage.tsx +0 -31
- package/src/core/components/calendar/utils/handleCalendarModifiers.tsx +0 -118
- package/src/core/components/calendar/utils/handleRangeContextDisabledDates.tsx +0 -75
- package/src/core/components/calendar/utils/index.ts +0 -8
- package/src/core/components/calendar/utils/nightsCount.tsx +0 -19
- package/src/core/components/calendar/utils/parseDate.tsx +0 -17
- package/src/core/components/calendar/utils/parseDates.tsx +0 -12
- package/src/core/components/index.ts +0 -7
- package/src/core/hooks/index.ts +0 -4
- package/src/core/hooks/useAutoFocus.tsx +0 -27
- package/src/core/hooks/useAwaitRender.tsx +0 -12
- package/src/core/hooks/useCloseFilterSection.tsx +0 -29
- package/src/core/hooks/useUpdateTranslations.tsx +0 -14
- package/src/i18n.ts +0 -27
- package/src/index.ts +0 -8
- package/src/locales/en/common.json +0 -18
- package/src/locales/en/filterBar.json +0 -33
- package/src/locales/fi/common.json +0 -19
- package/src/locales/fi/filterBar.json +0 -33
- package/src/themes/Default.css +0 -69
- package/src/themes/useTheme.tsx +0 -27
- package/stories/Button.stories.ts +0 -50
- package/stories/Button.tsx +0 -53
- package/stories/Configure.mdx +0 -364
- package/stories/Header.stories.ts +0 -27
- package/stories/Header.tsx +0 -70
- package/stories/Page.stories.ts +0 -29
- package/stories/Page.tsx +0 -91
- package/stories/assets/accessibility.png +0 -0
- package/stories/assets/accessibility.svg +0 -5
- package/stories/assets/addon-library.png +0 -0
- package/stories/assets/assets.png +0 -0
- package/stories/assets/context.png +0 -0
- package/stories/assets/discord.svg +0 -15
- package/stories/assets/docs.png +0 -0
- package/stories/assets/figma-plugin.png +0 -0
- package/stories/assets/github.svg +0 -3
- package/stories/assets/share.png +0 -0
- package/stories/assets/styling.png +0 -0
- package/stories/assets/testing.png +0 -0
- package/stories/assets/theming.png +0 -0
- package/stories/assets/tutorials.svg +0 -12
- package/stories/assets/youtube.svg +0 -4
- package/stories/button.css +0 -30
- package/stories/header.css +0 -32
- package/stories/page.css +0 -69
- package/tsconfig.json +0 -29
- /package/lib/components/FilterBar/components/{divider → Divider}/Divider.d.ts +0 -0
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { FaSearch } from 'react-icons/fa'
|
|
4
|
-
|
|
5
|
-
import { parseDates, SubmitButton } from '../../../../core/components'
|
|
6
|
-
import { useFilterBar } from '../../providers'
|
|
7
|
-
import { parseGuests, parseLocations } from '../../utils'
|
|
8
|
-
import { FilterSections, Pages } from '../../FilterBarTypes'
|
|
9
|
-
|
|
10
|
-
import { Divider } from '../Divider/Divider'
|
|
11
|
-
import { SelectButton } from '../SelectButton/SelectButton'
|
|
12
|
-
|
|
13
|
-
import './FilterControls.css'
|
|
14
|
-
|
|
15
|
-
export const FilterControls = () => {
|
|
16
|
-
const { t } = useTranslation('filterBar')
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
calendarRange,
|
|
20
|
-
selectedFilter,
|
|
21
|
-
selectedPath,
|
|
22
|
-
ageCategoryCounts,
|
|
23
|
-
selectedLocations,
|
|
24
|
-
mode,
|
|
25
|
-
tabs,
|
|
26
|
-
ageCategories,
|
|
27
|
-
locations,
|
|
28
|
-
innerLoading,
|
|
29
|
-
outerLoading,
|
|
30
|
-
handleSubmit,
|
|
31
|
-
handleSelectedFilter,
|
|
32
|
-
|
|
33
|
-
previouslyFocusedButtonRef,
|
|
34
|
-
buttonRefs,
|
|
35
|
-
tabsRef,
|
|
36
|
-
filtersRef,
|
|
37
|
-
} = useFilterBar()
|
|
38
|
-
|
|
39
|
-
// Store previously focused button and restore focus when closing
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!selectedFilter && previouslyFocusedButtonRef.current) {
|
|
42
|
-
previouslyFocusedButtonRef.current.focus()
|
|
43
|
-
previouslyFocusedButtonRef.current = null
|
|
44
|
-
}
|
|
45
|
-
}, [selectedFilter])
|
|
46
|
-
|
|
47
|
-
// Parsed data for filter section description
|
|
48
|
-
const parsedDates = parseDates({ calendarRange })
|
|
49
|
-
const parsedGuests = parseGuests({
|
|
50
|
-
ageCategoryCounts,
|
|
51
|
-
ageCategories,
|
|
52
|
-
guestsPlaceholder: t('guests.labelPlaceholder'),
|
|
53
|
-
guestLabel: t('guests.guestLabel'),
|
|
54
|
-
guestsLabel: t('guests.guestsLabel'),
|
|
55
|
-
})
|
|
56
|
-
const parsedLocations = parseLocations({
|
|
57
|
-
selectedLocations,
|
|
58
|
-
locationsPlaceholder: t('locations.placeholder'),
|
|
59
|
-
locationsSelectedLabel: t('locations.selected'),
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<div
|
|
64
|
-
className={`will-filter-bar-controls ${mode || 'light'} ${selectedFilter ? 'disabled' : ''}`}
|
|
65
|
-
ref={(el) => {
|
|
66
|
-
filtersRef.current = el
|
|
67
|
-
|
|
68
|
-
if (tabs?.length === 1) {
|
|
69
|
-
tabsRef.current = el
|
|
70
|
-
}
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
{locations?.data?.length && locations.data.length > 1 && (
|
|
74
|
-
<>
|
|
75
|
-
<SelectButton
|
|
76
|
-
ref={(el) => (buttonRefs.current[FilterSections.LOCATIONS] = el)}
|
|
77
|
-
label={t('locations.label')}
|
|
78
|
-
description={parsedLocations}
|
|
79
|
-
onClick={(e) => {
|
|
80
|
-
previouslyFocusedButtonRef.current = e.currentTarget
|
|
81
|
-
handleSelectedFilter(FilterSections.LOCATIONS)
|
|
82
|
-
}}
|
|
83
|
-
active={!!selectedLocations.length}
|
|
84
|
-
disabled={locations?.disabled}
|
|
85
|
-
ariaExpanded={selectedFilter === FilterSections.LOCATIONS}
|
|
86
|
-
ariaControls="will-filter-bar-locations"
|
|
87
|
-
/>
|
|
88
|
-
|
|
89
|
-
<Divider />
|
|
90
|
-
</>
|
|
91
|
-
)}
|
|
92
|
-
|
|
93
|
-
<SelectButton
|
|
94
|
-
ref={(el) => (buttonRefs.current[FilterSections.CALENDAR] = el)}
|
|
95
|
-
label={t('calendar.label')}
|
|
96
|
-
description={
|
|
97
|
-
parsedDates
|
|
98
|
-
? parsedDates
|
|
99
|
-
: selectedPath === Pages.ROOMS
|
|
100
|
-
? t('calendar.roomsLabelPlaceholder')
|
|
101
|
-
: t('calendar.eventsLabelPlaceholder')
|
|
102
|
-
}
|
|
103
|
-
onClick={(e) => {
|
|
104
|
-
previouslyFocusedButtonRef.current = e.currentTarget
|
|
105
|
-
handleSelectedFilter(FilterSections.CALENDAR)
|
|
106
|
-
}}
|
|
107
|
-
active={!!parsedDates}
|
|
108
|
-
ariaExpanded={selectedFilter === FilterSections.CALENDAR}
|
|
109
|
-
ariaControls="will-filter-bar-dates"
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
{selectedPath !== Pages.EVENTS && (
|
|
113
|
-
<>
|
|
114
|
-
<Divider />
|
|
115
|
-
|
|
116
|
-
<SelectButton
|
|
117
|
-
ref={(el) => (buttonRefs.current[FilterSections.GUESTS] = el)}
|
|
118
|
-
label={t('guests.label')}
|
|
119
|
-
description={parsedGuests.content}
|
|
120
|
-
onClick={(e) => {
|
|
121
|
-
previouslyFocusedButtonRef.current = e.currentTarget
|
|
122
|
-
handleSelectedFilter(FilterSections.GUESTS)
|
|
123
|
-
}}
|
|
124
|
-
active={!!parsedGuests.data.total}
|
|
125
|
-
ariaExpanded={selectedFilter === FilterSections.GUESTS}
|
|
126
|
-
ariaControls="will-guests-filter"
|
|
127
|
-
/>
|
|
128
|
-
</>
|
|
129
|
-
)}
|
|
130
|
-
|
|
131
|
-
<SubmitButton
|
|
132
|
-
onClick={handleSubmit}
|
|
133
|
-
startIcon={<FaSearch />}
|
|
134
|
-
label={t('common:search')}
|
|
135
|
-
isLoading={innerLoading || outerLoading}
|
|
136
|
-
/>
|
|
137
|
-
</div>
|
|
138
|
-
)
|
|
139
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#will-filter-bar-categories {
|
|
2
|
-
text-align: center;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.will-categories-filter-title {
|
|
6
|
-
font-size: 16px;
|
|
7
|
-
text-transform: uppercase;
|
|
8
|
-
margin: 10px 0 30px 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.will-categories-filter-inner {
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
gap: 20px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.will-categories-filter-inner input {
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
margin-right: 10px;
|
|
21
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
|
|
4
|
-
import './Categories.css'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
categories: any
|
|
8
|
-
setCategories: any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Categories = ({ categories, setCategories }: Props) => {
|
|
12
|
-
const { t } = useTranslation('filterBar')
|
|
13
|
-
|
|
14
|
-
const categoriesPlaceholder = [
|
|
15
|
-
'Weekend',
|
|
16
|
-
'Week',
|
|
17
|
-
'Summer camp',
|
|
18
|
-
'Winter camp',
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
const [selectedCategory, setSelectedCategory] = useState('')
|
|
22
|
-
|
|
23
|
-
const handleCategoryChange = (selectedCategory: any) => {
|
|
24
|
-
setSelectedCategory(selectedCategory)
|
|
25
|
-
setCategories(selectedCategory)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div id="will-filter-bar-categories">
|
|
30
|
-
<h3 className="will-categories-filter-title">{t('categories.label')}</h3>
|
|
31
|
-
|
|
32
|
-
<div className="will-categories-filter-inner">
|
|
33
|
-
{categoriesPlaceholder.map((itm, idx) => (
|
|
34
|
-
<div key={idx}>
|
|
35
|
-
<input
|
|
36
|
-
type="radio"
|
|
37
|
-
value={itm}
|
|
38
|
-
checked={selectedCategory === itm}
|
|
39
|
-
onChange={() => handleCategoryChange(itm)}
|
|
40
|
-
/>
|
|
41
|
-
<span>{itm}</span>
|
|
42
|
-
</div>
|
|
43
|
-
))}
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
Categories.displayName = 'Categories'
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { RefObject, forwardRef } from 'react'
|
|
2
|
-
import { DateRange } from 'react-day-picker'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
CalendarTypes,
|
|
6
|
-
CloseButton,
|
|
7
|
-
Calendar,
|
|
8
|
-
} from '../../../../../core/components'
|
|
9
|
-
|
|
10
|
-
import { SectionHeader } from '../SectionHeader/SectionHeader'
|
|
11
|
-
|
|
12
|
-
import './Dates.css'
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
ref: RefObject<HTMLDivElement>
|
|
16
|
-
onClose?: () => void
|
|
17
|
-
autoFocus?: boolean
|
|
18
|
-
calendarRange: DateRange | undefined
|
|
19
|
-
setCalendarRange: (range: DateRange | undefined) => void
|
|
20
|
-
disableCalendarDates?: CalendarTypes['disableCalendarDates']
|
|
21
|
-
selectedPath?: string
|
|
22
|
-
language?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const Dates = forwardRef<HTMLDivElement, Props>(
|
|
26
|
-
(
|
|
27
|
-
{
|
|
28
|
-
onClose,
|
|
29
|
-
autoFocus,
|
|
30
|
-
calendarRange,
|
|
31
|
-
setCalendarRange,
|
|
32
|
-
disableCalendarDates,
|
|
33
|
-
selectedPath,
|
|
34
|
-
language,
|
|
35
|
-
},
|
|
36
|
-
ref
|
|
37
|
-
) => {
|
|
38
|
-
return (
|
|
39
|
-
<div id="will-filter-bar-dates" ref={ref}>
|
|
40
|
-
<SectionHeader
|
|
41
|
-
title={''}
|
|
42
|
-
action={onClose && <CloseButton handleClose={onClose} />}
|
|
43
|
-
/>
|
|
44
|
-
|
|
45
|
-
<div className="will-dates-filter-container">
|
|
46
|
-
<Calendar
|
|
47
|
-
autoFocus={autoFocus}
|
|
48
|
-
calendarRange={calendarRange}
|
|
49
|
-
setCalendarRange={setCalendarRange}
|
|
50
|
-
disableCalendarDates={disableCalendarDates}
|
|
51
|
-
selectedPath={selectedPath}
|
|
52
|
-
language={language}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
Dates.displayName = 'Dates'
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
.will-filter-bar-panels {
|
|
2
|
-
background-color: var(--will-white);
|
|
3
|
-
min-height: 100px;
|
|
4
|
-
position: absolute;
|
|
5
|
-
z-index: 111;
|
|
6
|
-
border-radius: 25px;
|
|
7
|
-
box-shadow: var(--will-box-shadow);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@media (max-width: 960px) {
|
|
11
|
-
.will-root {
|
|
12
|
-
width: 100%;
|
|
13
|
-
min-width: auto;
|
|
14
|
-
max-height: 100vh;
|
|
15
|
-
z-index: 3;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.will-filter-bar-panels {
|
|
19
|
-
width: 100%;
|
|
20
|
-
z-index: 999;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useCloseFilterSection } from '../../../../core/hooks'
|
|
4
|
-
import { FilterSections } from '../../FilterBarTypes'
|
|
5
|
-
import { useFilterBar } from '../../providers'
|
|
6
|
-
|
|
7
|
-
import { Dates } from './Dates/Dates'
|
|
8
|
-
import { Guests } from './Guests/Guests'
|
|
9
|
-
import { Locations } from './Locations/Locations'
|
|
10
|
-
import { Categories } from './Categories/Categories'
|
|
11
|
-
|
|
12
|
-
import './FilterPanels.css'
|
|
13
|
-
import { usePanelPosition } from '../../hooks'
|
|
14
|
-
|
|
15
|
-
export const FilterPanels = () => {
|
|
16
|
-
const {
|
|
17
|
-
categories,
|
|
18
|
-
calendarRange,
|
|
19
|
-
selectedFilter,
|
|
20
|
-
selectedPath,
|
|
21
|
-
ageCategoryCounts,
|
|
22
|
-
selectedLocations,
|
|
23
|
-
mode,
|
|
24
|
-
tabs,
|
|
25
|
-
disableCalendarDates,
|
|
26
|
-
ageCategories,
|
|
27
|
-
locations,
|
|
28
|
-
language,
|
|
29
|
-
isMobile,
|
|
30
|
-
panelRef,
|
|
31
|
-
buttonRefs,
|
|
32
|
-
filtersRef,
|
|
33
|
-
setSelectedLocations,
|
|
34
|
-
setCalendarRange,
|
|
35
|
-
handleSelectedFilter,
|
|
36
|
-
updateGuestsCount,
|
|
37
|
-
setCategories,
|
|
38
|
-
} = useFilterBar()
|
|
39
|
-
|
|
40
|
-
// Handle close filter section
|
|
41
|
-
const { filterSectionRef } = useCloseFilterSection({ handleSelectedFilter })
|
|
42
|
-
|
|
43
|
-
const { left, top } = usePanelPosition({
|
|
44
|
-
selectedFilter,
|
|
45
|
-
panelRef,
|
|
46
|
-
filtersRef,
|
|
47
|
-
buttonRefs,
|
|
48
|
-
isMobile,
|
|
49
|
-
tabs,
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
const renderContent = () => {
|
|
53
|
-
switch (selectedFilter) {
|
|
54
|
-
case FilterSections.CALENDAR:
|
|
55
|
-
return (
|
|
56
|
-
<Dates
|
|
57
|
-
autoFocus
|
|
58
|
-
ref={filterSectionRef}
|
|
59
|
-
onClose={() => handleSelectedFilter(false)}
|
|
60
|
-
calendarRange={calendarRange}
|
|
61
|
-
setCalendarRange={setCalendarRange}
|
|
62
|
-
disableCalendarDates={disableCalendarDates}
|
|
63
|
-
selectedPath={selectedPath}
|
|
64
|
-
language={language}
|
|
65
|
-
/>
|
|
66
|
-
)
|
|
67
|
-
case FilterSections.GUESTS:
|
|
68
|
-
return (
|
|
69
|
-
<Guests
|
|
70
|
-
autoFocus
|
|
71
|
-
ref={filterSectionRef}
|
|
72
|
-
ageCategories={ageCategories}
|
|
73
|
-
ageCategoryCounts={ageCategoryCounts}
|
|
74
|
-
updateGuestsCount={updateGuestsCount}
|
|
75
|
-
onClose={() => handleSelectedFilter(false)}
|
|
76
|
-
/>
|
|
77
|
-
)
|
|
78
|
-
case FilterSections.CATEGORIES:
|
|
79
|
-
return (
|
|
80
|
-
<Categories categories={categories} setCategories={setCategories} />
|
|
81
|
-
)
|
|
82
|
-
case FilterSections.LOCATIONS:
|
|
83
|
-
return (
|
|
84
|
-
<Locations
|
|
85
|
-
autoFocus
|
|
86
|
-
ref={filterSectionRef}
|
|
87
|
-
locations={locations?.data}
|
|
88
|
-
selectedLocations={selectedLocations}
|
|
89
|
-
setSelectedLocations={setSelectedLocations}
|
|
90
|
-
multiSelect={locations?.multiSelect}
|
|
91
|
-
onClose={() => handleSelectedFilter(false)}
|
|
92
|
-
/>
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
default:
|
|
96
|
-
return null
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
selectedFilter && (
|
|
102
|
-
<div
|
|
103
|
-
ref={panelRef}
|
|
104
|
-
className={`will-filter-bar-panels ${mode || 'light'}`}
|
|
105
|
-
style={{ left, top }}
|
|
106
|
-
>
|
|
107
|
-
{renderContent()}
|
|
108
|
-
</div>
|
|
109
|
-
)
|
|
110
|
-
)
|
|
111
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
.will-guests-filter-label,
|
|
2
|
-
.will-guests-filter-count {
|
|
3
|
-
font-size: 18px;
|
|
4
|
-
color: var(--will-text);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.will-guests-filter-inner {
|
|
8
|
-
display: flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: space-between;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.will-guests-filter-label {
|
|
14
|
-
display: block;
|
|
15
|
-
font-weight: 600;
|
|
16
|
-
margin-bottom: 10px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.will-guests-filter-inner .will-guests-filter-counter {
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.will-guests-filter-count {
|
|
25
|
-
margin: 0 10px;
|
|
26
|
-
min-width: 30px;
|
|
27
|
-
text-align: center;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.will-guests-filter-counter-button {
|
|
31
|
-
border-radius: 50%;
|
|
32
|
-
background-color: transparent;
|
|
33
|
-
border: 1px solid var(--will-grey);
|
|
34
|
-
width: 30px;
|
|
35
|
-
height: 30px;
|
|
36
|
-
display: flex;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
align-items: center;
|
|
39
|
-
font-size: 20px;
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
color: var(--will-black);
|
|
42
|
-
|
|
43
|
-
padding: 0;
|
|
44
|
-
margin: 0;
|
|
45
|
-
-webkit-appearance: none;
|
|
46
|
-
appearance: none;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.will-guests-filter-counter-button:hover {
|
|
50
|
-
background-color: var(--will-onahau);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@media (max-width: 960px) {
|
|
54
|
-
.will-guests-filter-inner {
|
|
55
|
-
width: 100%;
|
|
56
|
-
justify-content: space-between;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { FC, useEffect } from 'react'
|
|
2
|
-
|
|
3
|
-
import { GuestsCountPropsType } from '../../../../FilterBarTypes'
|
|
4
|
-
|
|
5
|
-
import './GuestCount.css'
|
|
6
|
-
|
|
7
|
-
export const GuestCount: FC<GuestsCountPropsType> = ({
|
|
8
|
-
label,
|
|
9
|
-
sortOrder,
|
|
10
|
-
id,
|
|
11
|
-
updateGuestsCount,
|
|
12
|
-
count,
|
|
13
|
-
minVal,
|
|
14
|
-
}) => {
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (minVal && minVal > count) {
|
|
17
|
-
updateGuestsCount(`guests-${id}`, minVal)
|
|
18
|
-
}
|
|
19
|
-
}, [])
|
|
20
|
-
|
|
21
|
-
const handleDecrement = () => {
|
|
22
|
-
if (count > minVal) {
|
|
23
|
-
updateGuestsCount(`guests-${id}`, count - 1)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const handleIncrement = () => {
|
|
28
|
-
updateGuestsCount(`guests-${id}`, count + 1)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="will-guests-filter-inner" style={{ order: `${sortOrder}` }}>
|
|
33
|
-
<p className="will-guests-filter-label">{label}</p>
|
|
34
|
-
|
|
35
|
-
<div className="will-guests-filter-counter">
|
|
36
|
-
<button
|
|
37
|
-
className="will-guests-filter-counter-button"
|
|
38
|
-
onClick={handleDecrement}
|
|
39
|
-
disabled={(minVal && count <= minVal) || !count}
|
|
40
|
-
style={{
|
|
41
|
-
cursor:
|
|
42
|
-
(minVal && count <= minVal) || !count ? 'initial' : 'pointer',
|
|
43
|
-
paddingBottom: '4px',
|
|
44
|
-
opacity: (minVal && count <= minVal) || !count ? 0.4 : 1,
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
<svg
|
|
48
|
-
width="10"
|
|
49
|
-
height="10"
|
|
50
|
-
viewBox="0 0 15 15"
|
|
51
|
-
fill="none"
|
|
52
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
-
>
|
|
54
|
-
<path
|
|
55
|
-
d="M4 10H16"
|
|
56
|
-
stroke="currentColor"
|
|
57
|
-
strokeWidth="2"
|
|
58
|
-
strokeLinecap="round"
|
|
59
|
-
/>
|
|
60
|
-
</svg>
|
|
61
|
-
</button>
|
|
62
|
-
<span className="will-guests-filter-count">{count}</span>
|
|
63
|
-
<button
|
|
64
|
-
className="will-guests-filter-counter-button"
|
|
65
|
-
onClick={handleIncrement}
|
|
66
|
-
>
|
|
67
|
-
<svg
|
|
68
|
-
width="15"
|
|
69
|
-
height="15"
|
|
70
|
-
viewBox="0 0 20 20"
|
|
71
|
-
fill="none"
|
|
72
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
-
>
|
|
74
|
-
<path
|
|
75
|
-
d="M10 4V16M4 10H16"
|
|
76
|
-
stroke="currentColor"
|
|
77
|
-
strokeWidth="2"
|
|
78
|
-
strokeLinecap="round"
|
|
79
|
-
/>
|
|
80
|
-
</svg>
|
|
81
|
-
</button>
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#will-filter-bar-guests {
|
|
2
|
-
text-align: initial;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.will-guests-filter-container {
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
min-width: 400px;
|
|
9
|
-
gap: 20px;
|
|
10
|
-
padding: 0 30px 16px 30px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@media (max-width: 960px) {
|
|
14
|
-
.will-guests-filter-container {
|
|
15
|
-
min-width: auto;
|
|
16
|
-
padding: 0 20px 16px 20px;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**/
|
|
21
|
-
.will-guest-count {
|
|
22
|
-
display: inline-block;
|
|
23
|
-
min-width: 10px;
|
|
24
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
|
|
4
|
-
import { useAutoFocus } from '../../../../../core/hooks'
|
|
5
|
-
import { CloseButton } from '../../../../../core/components'
|
|
6
|
-
import { GuestCount } from './GuestCount/GuestCount'
|
|
7
|
-
import { AgeCategoryCount, AgeCategoryType } from '../../../FilterBarTypes'
|
|
8
|
-
import { SectionHeader } from '../SectionHeader/SectionHeader'
|
|
9
|
-
|
|
10
|
-
import './Guests.css'
|
|
11
|
-
|
|
12
|
-
type Props = {
|
|
13
|
-
ageCategories?: AgeCategoryType[]
|
|
14
|
-
updateGuestsCount: (arg1: string, arg2: number) => void
|
|
15
|
-
ageCategoryCounts: AgeCategoryCount
|
|
16
|
-
autoFocus?: boolean
|
|
17
|
-
onClose?: () => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Guests = forwardRef<HTMLDivElement, Props>(
|
|
21
|
-
(
|
|
22
|
-
{
|
|
23
|
-
ageCategories,
|
|
24
|
-
updateGuestsCount,
|
|
25
|
-
ageCategoryCounts,
|
|
26
|
-
autoFocus,
|
|
27
|
-
onClose,
|
|
28
|
-
}: Props,
|
|
29
|
-
ref
|
|
30
|
-
) => {
|
|
31
|
-
const { t } = useTranslation('filterBar')
|
|
32
|
-
const containerRef = useAutoFocus<HTMLDivElement>(autoFocus)
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div id="will-filter-bar-guests" ref={ref}>
|
|
36
|
-
<SectionHeader
|
|
37
|
-
title={t('guests.title')}
|
|
38
|
-
action={onClose && <CloseButton handleClose={onClose} />}
|
|
39
|
-
/>
|
|
40
|
-
|
|
41
|
-
<div className="will-guests-filter-container" ref={containerRef}>
|
|
42
|
-
{ageCategories?.map((category) => (
|
|
43
|
-
<GuestCount
|
|
44
|
-
key={category.id}
|
|
45
|
-
id={category.id}
|
|
46
|
-
label={category.name}
|
|
47
|
-
minVal={category.minVal}
|
|
48
|
-
sortOrder={category.sortOrder}
|
|
49
|
-
updateGuestsCount={updateGuestsCount}
|
|
50
|
-
count={ageCategoryCounts[`guests-${category.id}`] || 0}
|
|
51
|
-
/>
|
|
52
|
-
))}
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
Guests.displayName = 'Guests'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#will-filter-bar-locations {
|
|
2
|
-
text-align: initial;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.will-locations-filter-container {
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
min-width: 400px;
|
|
9
|
-
padding-bottom: 16px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@media (max-width: 960px) {
|
|
13
|
-
.will-locations-filter-container {
|
|
14
|
-
min-width: 100%;
|
|
15
|
-
}
|
|
16
|
-
}
|