willba-component-library 0.1.38 → 0.1.40
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/lib/components/FilterBar/FilterBar.d.ts +3 -3
- package/lib/components/FilterBar/FilterBarTypes.d.ts +0 -5
- package/lib/components/FilterBar/components/buttons/close-button/CloseButton.d.ts +1 -1
- package/lib/components/FilterBar/components/buttons/index.d.ts +4 -0
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +1 -1
- package/lib/components/FilterBar/components/buttons/submit-button/SubmitButton.d.ts +1 -1
- package/lib/components/FilterBar/components/buttons/tab-button/TabButton.d.ts +1 -1
- package/lib/components/FilterBar/components/calendar/Calendar.d.ts +3 -3
- package/lib/components/FilterBar/components/categories/Categories.d.ts +6 -1
- package/lib/components/FilterBar/components/divider/Divider.d.ts +1 -1
- package/lib/components/FilterBar/components/guests/Guests.d.ts +8 -2
- package/lib/components/FilterBar/components/index.d.ts +5 -0
- package/lib/components/FilterBar/hooks/index.d.ts +4 -0
- package/lib/components/FilterBar/hooks/useCloseFilterSection.d.ts +8 -0
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +3 -3
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +9 -0
- package/lib/components/FilterBar/hooks/useUpdateTranslations.d.ts +5 -0
- package/lib/components/FilterBar/utils/index.d.ts +2 -0
- package/lib/components/FilterBar/utils/parseDates.d.ts +6 -0
- package/lib/components/FilterBar/utils/parseGuests.d.ts +7 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +6435 -6403
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +6435 -6403
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +6435 -6403
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.css +1 -22
- package/src/components/FilterBar/FilterBar.tsx +104 -149
- package/src/components/FilterBar/FilterBarTypes.ts +0 -6
- package/src/components/FilterBar/components/buttons/close-button/CloseButton.tsx +1 -1
- package/src/components/FilterBar/components/buttons/index.ts +4 -0
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +1 -6
- package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.tsx +1 -1
- package/src/components/FilterBar/components/buttons/tab-button/TabButton.tsx +1 -1
- package/src/components/FilterBar/components/calendar/Calendar.tsx +42 -43
- package/src/components/FilterBar/components/categories/Categories.tsx +6 -1
- package/src/components/FilterBar/components/divider/Divider.tsx +1 -1
- package/src/components/FilterBar/components/guests/Guests.tsx +34 -30
- package/src/components/FilterBar/components/index.ts +6 -0
- package/src/components/FilterBar/hooks/index.ts +4 -0
- package/src/components/FilterBar/hooks/useCloseFilterSection.tsx +28 -0
- package/src/components/FilterBar/hooks/useFilterBar.tsx +2 -15
- package/src/components/FilterBar/hooks/useScrollInToView.tsx +29 -0
- package/src/components/FilterBar/hooks/useUpdateTranslations.tsx +14 -0
- package/src/components/FilterBar/utils/index.tsx +2 -0
- package/src/components/FilterBar/utils/parseDates.tsx +12 -0
- package/src/components/FilterBar/utils/parseGuests.tsx +17 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.will-root {
|
|
2
|
-
z-index:
|
|
2
|
+
z-index: 999;
|
|
3
3
|
width: 100%;
|
|
4
4
|
max-height: 100vh;
|
|
5
5
|
position: relative;
|
|
@@ -10,22 +10,6 @@
|
|
|
10
10
|
position: relative;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.will-filter-bar-underlay {
|
|
14
|
-
position: absolute;
|
|
15
|
-
top: 0;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
left: 0;
|
|
18
|
-
right:0;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
z-index: 88888;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@media (max-width: 960px) {
|
|
24
|
-
.will-filter-bar-underlay {
|
|
25
|
-
height: 500vh;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
13
|
/* Tabs */
|
|
30
14
|
|
|
31
15
|
.will-filter-bar-tabs {
|
|
@@ -85,10 +69,5 @@
|
|
|
85
69
|
padding: 30px 20px;
|
|
86
70
|
position: relative;
|
|
87
71
|
}
|
|
88
|
-
|
|
89
|
-
.will-root.isMobileAbsolute {
|
|
90
|
-
position: relative;
|
|
91
|
-
z-index: 99999;
|
|
92
|
-
}
|
|
93
72
|
}
|
|
94
73
|
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import React, { useEffect
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
import { format } from 'date-fns'
|
|
4
4
|
|
|
5
|
-
import Divider from './components/divider/Divider'
|
|
6
|
-
import SelectButton from './components/buttons/select-button/SelectButton'
|
|
7
|
-
import SubmitButton from './components/buttons/submit-button/SubmitButton'
|
|
8
|
-
import Calendar from './components/calendar/Calendar'
|
|
9
|
-
import Guests from './components/guests/Guests'
|
|
10
|
-
import Categories from './components/categories/Categories'
|
|
11
|
-
|
|
12
5
|
import useTheme, { Palette } from '../../themes/useTheme'
|
|
13
|
-
import useFilterBar from './hooks/useFilterBar'
|
|
14
|
-
|
|
15
|
-
import './FilterBar.css'
|
|
16
6
|
import '../../themes/Default.css'
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
import TabButton from './components/buttons/tab-button/TabButton'
|
|
7
|
+
|
|
8
|
+
import { parseDates, parseGuests } from './utils'
|
|
20
9
|
import { AgeCategoryType } from './FilterBarTypes'
|
|
10
|
+
import {
|
|
11
|
+
useCloseFilterSection,
|
|
12
|
+
useFilterBar,
|
|
13
|
+
useScrollInToView,
|
|
14
|
+
useUpdateTranslations,
|
|
15
|
+
} from './hooks'
|
|
16
|
+
import {
|
|
17
|
+
TabButton,
|
|
18
|
+
SelectButton,
|
|
19
|
+
SubmitButton,
|
|
20
|
+
CloseButton,
|
|
21
|
+
Calendar,
|
|
22
|
+
Guests,
|
|
23
|
+
Divider,
|
|
24
|
+
Categories,
|
|
25
|
+
} from './components'
|
|
26
|
+
|
|
27
|
+
import './FilterBar.css'
|
|
21
28
|
|
|
22
|
-
export
|
|
29
|
+
export type FilterBarProps = {
|
|
23
30
|
vendor?: string
|
|
24
31
|
language?: string
|
|
25
32
|
ageCategories?: AgeCategoryType[]
|
|
@@ -38,15 +45,7 @@ export default function FilterBar({
|
|
|
38
45
|
const themePalette = useTheme({ palette })
|
|
39
46
|
|
|
40
47
|
// Translations
|
|
41
|
-
|
|
42
|
-
const [isMobile, setIsMobile] = useState(true)
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
i18n.changeLanguage(language)
|
|
46
|
-
|
|
47
|
-
setRerenderKey((prevKey) => prevKey + 1)
|
|
48
|
-
}, [language])
|
|
49
|
-
|
|
48
|
+
useUpdateTranslations({ language })
|
|
50
49
|
const { t } = useTranslation('filterBar')
|
|
51
50
|
|
|
52
51
|
// Filters
|
|
@@ -64,152 +63,108 @@ export default function FilterBar({
|
|
|
64
63
|
setSelectedPath,
|
|
65
64
|
} = useFilterBar({ redirectUrl, currentViewApply })
|
|
66
65
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
const targetFilterBarRef = useRef<HTMLDivElement | null>(null)
|
|
66
|
+
// Default selected tab
|
|
70
67
|
useEffect(() => {
|
|
71
68
|
if (currentViewApply === 'roomFilters') {
|
|
72
69
|
setSelectedPath('/rooms')
|
|
73
70
|
}
|
|
71
|
+
}, [])
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
}
|
|
73
|
+
// Scroll in to view
|
|
74
|
+
const { isMobile, targetFilterBarRef } = useScrollInToView({ selectedFilter })
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
document.body.getBoundingClientRect().top -
|
|
86
|
-
30,
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
}, [selectedFilter])
|
|
90
|
-
|
|
91
|
-
const renderDates =
|
|
92
|
-
calendarRange?.to && calendarRange?.from
|
|
93
|
-
? `${format(calendarRange.from, 'dd.MM.yyyy')} -
|
|
94
|
-
${format(calendarRange.to, 'dd.MM.yyyy')}`
|
|
95
|
-
: null
|
|
96
|
-
|
|
97
|
-
const renderGuests = Object.entries(ageCategoryCounts).reduce(
|
|
98
|
-
(acc, [key, value]) => {
|
|
99
|
-
const ageCategory = ageCategories.find(
|
|
100
|
-
(c) => c.id === key[key.length - 1]
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
if (ageCategory && value) {
|
|
104
|
-
acc += `${acc ? ' -' : ''} ${ageCategory.name}: ${value}`
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return acc
|
|
108
|
-
},
|
|
109
|
-
''
|
|
110
|
-
)
|
|
76
|
+
// Handle close filter section
|
|
77
|
+
const { filtersRef } = useCloseFilterSection({ handleSelectedFilter })
|
|
78
|
+
|
|
79
|
+
const parsedDates = parseDates({ calendarRange })
|
|
80
|
+
const parsedGuests = parseGuests({ ageCategoryCounts, ageCategories })
|
|
111
81
|
|
|
112
82
|
return (
|
|
113
|
-
|
|
114
|
-
{
|
|
83
|
+
<div className={`will-root`} style={themePalette}>
|
|
84
|
+
{!currentViewApply && (
|
|
115
85
|
<div
|
|
116
|
-
className=
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
86
|
+
className="will-filter-bar-tabs"
|
|
87
|
+
ref={!currentViewApply ? targetFilterBarRef : null}
|
|
88
|
+
>
|
|
89
|
+
<TabButton
|
|
90
|
+
label={t('tabs.events')}
|
|
91
|
+
onClick={() => setSelectedPath('/events')}
|
|
92
|
+
active={selectedPath === '/events'}
|
|
93
|
+
/>
|
|
94
|
+
<TabButton
|
|
95
|
+
label={t('tabs.rooms')}
|
|
96
|
+
onClick={() => setSelectedPath('/rooms')}
|
|
97
|
+
active={selectedPath === '/rooms'}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
121
100
|
)}
|
|
122
101
|
|
|
123
102
|
<div
|
|
124
|
-
className=
|
|
125
|
-
|
|
103
|
+
className="will-filter-bar-header"
|
|
104
|
+
ref={currentViewApply ? targetFilterBarRef : null}
|
|
126
105
|
>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
106
|
+
<SelectButton
|
|
107
|
+
label={t('calendar.label')}
|
|
108
|
+
description={
|
|
109
|
+
parsedDates
|
|
110
|
+
? parsedDates
|
|
111
|
+
: selectedPath === '/rooms'
|
|
112
|
+
? t('calendar.roomsLabelPlaceholder')
|
|
113
|
+
: t('calendar.eventsLabelPlaceholder')
|
|
114
|
+
}
|
|
115
|
+
onClick={() => handleSelectedFilter(1)}
|
|
116
|
+
style={fontWeightBold(selectedFilter === 1)}
|
|
117
|
+
date={
|
|
118
|
+
calendarRange?.to ? format(calendarRange.to, 'dd.MM.yyyy') : null
|
|
119
|
+
}
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
{selectedPath === '/rooms' && (
|
|
123
|
+
<>
|
|
124
|
+
<Divider />
|
|
125
|
+
|
|
126
|
+
<SelectButton
|
|
127
|
+
label={t('guests.label')}
|
|
128
|
+
description={
|
|
129
|
+
parsedGuests ? parsedGuests : t('guests.labelPlaceholder')
|
|
130
|
+
}
|
|
131
|
+
onClick={() => handleSelectedFilter(2)}
|
|
132
|
+
style={fontWeightBold(selectedFilter === 2)}
|
|
141
133
|
/>
|
|
142
|
-
|
|
134
|
+
</>
|
|
143
135
|
)}
|
|
144
136
|
|
|
137
|
+
<SubmitButton onClick={handleSubmit} />
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
{selectedFilter && (
|
|
145
141
|
<div
|
|
146
|
-
className="will-filter-bar-
|
|
147
|
-
|
|
142
|
+
className="will-filter-bar-container"
|
|
143
|
+
style={currentViewApply && !isMobile ? { top: 66 } : {}}
|
|
148
144
|
>
|
|
149
|
-
<
|
|
150
|
-
label={t('calendar.label')}
|
|
151
|
-
description={
|
|
152
|
-
renderDates
|
|
153
|
-
? renderDates
|
|
154
|
-
: selectedPath === '/rooms'
|
|
155
|
-
? t('calendar.roomsLabelPlaceholder')
|
|
156
|
-
: t('calendar.eventsLabelPlaceholder')
|
|
157
|
-
}
|
|
158
|
-
onClick={() => handleSelectedFilter(1)}
|
|
159
|
-
style={fontWeightBold(selectedFilter === 1)}
|
|
160
|
-
date={
|
|
161
|
-
calendarRange?.to ? format(calendarRange.to, 'dd.MM.yyyy') : null
|
|
162
|
-
}
|
|
163
|
-
/>
|
|
145
|
+
<CloseButton handleClose={() => handleSelectedFilter(false)} />
|
|
164
146
|
|
|
165
|
-
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
147
|
+
{selectedFilter === 1 && (
|
|
148
|
+
<Calendar
|
|
149
|
+
calendarRange={calendarRange}
|
|
150
|
+
setCalendarRange={setCalendarRange}
|
|
151
|
+
ref={filtersRef}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
{selectedFilter === 2 && (
|
|
155
|
+
<Guests
|
|
156
|
+
updateGuestsCount={updateGuestsCount}
|
|
157
|
+
ageCategories={ageCategories}
|
|
158
|
+
ageCategoryCounts={ageCategoryCounts}
|
|
159
|
+
ref={filtersRef}
|
|
160
|
+
/>
|
|
161
|
+
)}
|
|
162
|
+
{selectedFilter === 3 && (
|
|
163
|
+
<Categories categories={categories} setCategories={setCategories} />
|
|
178
164
|
)}
|
|
179
|
-
|
|
180
|
-
<SubmitButton onClick={handleSubmit} />
|
|
181
165
|
</div>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<div
|
|
185
|
-
className="will-filter-bar-container"
|
|
186
|
-
style={currentViewApply && !isMobile ? { top: 66 } : {}}
|
|
187
|
-
>
|
|
188
|
-
<CloseButton handleClose={() => handleSelectedFilter(false)} />
|
|
189
|
-
|
|
190
|
-
{selectedFilter === 1 && (
|
|
191
|
-
<Calendar
|
|
192
|
-
calendarRange={calendarRange}
|
|
193
|
-
setCalendarRange={setCalendarRange}
|
|
194
|
-
/>
|
|
195
|
-
)}
|
|
196
|
-
{selectedFilter === 2 && (
|
|
197
|
-
<Guests
|
|
198
|
-
updateGuestsCount={updateGuestsCount}
|
|
199
|
-
ageCategories={ageCategories}
|
|
200
|
-
ageCategoryCounts={ageCategoryCounts}
|
|
201
|
-
/>
|
|
202
|
-
)}
|
|
203
|
-
{selectedFilter === 3 && (
|
|
204
|
-
<Categories
|
|
205
|
-
categories={categories}
|
|
206
|
-
setCategories={setCategories}
|
|
207
|
-
/>
|
|
208
|
-
)}
|
|
209
|
-
</div>
|
|
210
|
-
)}
|
|
211
|
-
</div>
|
|
212
|
-
</>
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
213
168
|
)
|
|
214
169
|
}
|
|
215
170
|
|
|
@@ -9,12 +9,6 @@ export interface AgeCategoryType {
|
|
|
9
9
|
sortOrder: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export interface GuestsPropsType {
|
|
13
|
-
ageCategories: AgeCategoryType[]
|
|
14
|
-
updateGuestsCount: (arg1: string, arg2: number) => void
|
|
15
|
-
ageCategoryCounts: AgeCategoryCount | {}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
12
|
export interface GuestsCountPropsType {
|
|
19
13
|
label: string
|
|
20
14
|
id: number
|
|
@@ -7,7 +7,7 @@ interface CloseButtonPropsType {
|
|
|
7
7
|
handleClose: () => void
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export const CloseButton = ({ handleClose }: CloseButtonPropsType) => {
|
|
11
11
|
return (
|
|
12
12
|
<button className="will-filter-bar-close-button" onClick={handleClose}>
|
|
13
13
|
<IoIosCloseCircleOutline />
|
|
@@ -9,12 +9,7 @@ type Props = {
|
|
|
9
9
|
description: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
label,
|
|
14
|
-
onClick,
|
|
15
|
-
style,
|
|
16
|
-
description,
|
|
17
|
-
}: any) {
|
|
12
|
+
export const SelectButton = ({ label, onClick, style, description }: any) => {
|
|
18
13
|
return (
|
|
19
14
|
<button
|
|
20
15
|
className="will-filter-bar-select-button"
|
|
@@ -8,7 +8,7 @@ type Props = {
|
|
|
8
8
|
active?: boolean
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export const TabButton = ({ onClick, label, active }: Props) => {
|
|
12
12
|
return (
|
|
13
13
|
<button
|
|
14
14
|
className={`will-filter-bar-tab-button ${active && 'active'}`}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
1
|
+
import React, { forwardRef, useEffect } from 'react'
|
|
2
2
|
import { DateRange, DayPicker } from 'react-day-picker'
|
|
3
3
|
import { addDays, startOfDay, addMonths } from 'date-fns'
|
|
4
4
|
import { useMediaQuery } from 'react-responsive'
|
|
@@ -6,56 +6,55 @@ import { useMediaQuery } from 'react-responsive'
|
|
|
6
6
|
import 'react-day-picker/dist/style.css'
|
|
7
7
|
import './Calendar.css'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
type Props = {
|
|
10
10
|
calendarRange: DateRange | undefined
|
|
11
11
|
setCalendarRange: (range: DateRange | undefined) => void
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
calendarRange,
|
|
16
|
-
|
|
17
|
-
}: CalendarPropsType) {
|
|
18
|
-
const isTablet = useMediaQuery({ maxWidth: 960 })
|
|
14
|
+
export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
15
|
+
({ calendarRange, setCalendarRange }: Props, ref) => {
|
|
16
|
+
const isTablet = useMediaQuery({ maxWidth: 960 })
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
const today = startOfDay(new Date())
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const disabledDays = [
|
|
21
|
+
{
|
|
22
|
+
from: addDays(today, -2),
|
|
23
|
+
to: addDays(today, -50),
|
|
24
|
+
},
|
|
25
|
+
]
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!calendarRange) setCalendarRange(undefined)
|
|
29
|
+
}, [])
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
return (
|
|
32
|
+
<div className="will-filter-bar-calendar" ref={ref}>
|
|
33
|
+
{/* <div className="will-calendar-filter-header">
|
|
36
34
|
<h3 className="will-calendar-filter-title">{t('calendar.title')}</h3>
|
|
37
35
|
</div> */}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
<div className="will-calendar-filter-container">
|
|
37
|
+
<DayPicker
|
|
38
|
+
id="will-calendar"
|
|
39
|
+
mode="range"
|
|
40
|
+
showOutsideDays
|
|
41
|
+
numberOfMonths={!isTablet ? 2 : 1}
|
|
42
|
+
weekStartsOn={1}
|
|
43
|
+
selected={calendarRange}
|
|
44
|
+
onSelect={setCalendarRange}
|
|
45
|
+
modifiersClassNames={{
|
|
46
|
+
today: 'my-today',
|
|
47
|
+
}}
|
|
48
|
+
modifiersStyles={{
|
|
49
|
+
disabled: { opacity: '0.2' },
|
|
50
|
+
}}
|
|
51
|
+
captionLayout="dropdown-buttons"
|
|
52
|
+
defaultMonth={today}
|
|
53
|
+
disabled={disabledDays}
|
|
54
|
+
fromMonth={today}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
58
57
|
</div>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
@@ -3,7 +3,12 @@ import { useTranslation } from 'react-i18next'
|
|
|
3
3
|
|
|
4
4
|
import './Categories.css'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type Props = {
|
|
7
|
+
categories: any
|
|
8
|
+
setCategories: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Categories = ({ categories, setCategories }: Props) => {
|
|
7
12
|
const { t } = useTranslation('filterBar')
|
|
8
13
|
|
|
9
14
|
const categoriesPlaceholder = [
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
|
|
4
4
|
import GuestCount from './GuestCount/GuestCount'
|
|
5
|
-
import { AgeCategoryCount,
|
|
5
|
+
import { AgeCategoryCount, AgeCategoryType } from '../../FilterBarTypes'
|
|
6
6
|
|
|
7
7
|
import './Guests.css'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
ageCategories
|
|
11
|
-
updateGuestsCount,
|
|
12
|
-
ageCategoryCounts
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
type Props = {
|
|
10
|
+
ageCategories: AgeCategoryType[]
|
|
11
|
+
updateGuestsCount: (arg1: string, arg2: number) => void
|
|
12
|
+
ageCategoryCounts: AgeCategoryCount | {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Guests = forwardRef<HTMLDivElement, Props>(
|
|
16
|
+
({ ageCategories, updateGuestsCount, ageCategoryCounts }: Props, ref) => {
|
|
17
|
+
const { t } = useTranslation('filterBar')
|
|
18
|
+
return (
|
|
19
|
+
<div className="will-filter-bar-guests" ref={ref}>
|
|
20
|
+
<h3 className="will-guests-filter-title">{t('guests.title')}</h3>
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
<div className="will-guests-filter-container">
|
|
23
|
+
{ageCategories?.map((category) => (
|
|
24
|
+
<GuestCount
|
|
25
|
+
key={category.id}
|
|
26
|
+
id={parseInt(category.id)}
|
|
27
|
+
label={category.name}
|
|
28
|
+
minVal={category.minVal}
|
|
29
|
+
sortOrder={category.sortOrder}
|
|
30
|
+
updateGuestsCount={updateGuestsCount}
|
|
31
|
+
count={
|
|
32
|
+
(ageCategoryCounts as AgeCategoryCount)[
|
|
33
|
+
`guests-${category.id}`
|
|
34
|
+
] || category.minVal
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
35
39
|
</div>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CloseButton, SelectButton, SubmitButton, TabButton } from './buttons'
|
|
2
|
+
|
|
3
|
+
export { Guests } from './guests/Guests'
|
|
4
|
+
export { Calendar } from './calendar/Calendar'
|
|
5
|
+
export { Divider } from './divider/Divider'
|
|
6
|
+
export { Categories } from './categories/Categories'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
handleSelectedFilter: (arg: boolean) => void
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const useCloseFilterSection = ({ handleSelectedFilter }: Props) => {
|
|
8
|
+
const filtersRef = useRef<HTMLDivElement | null>(null)
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
12
|
+
if (
|
|
13
|
+
filtersRef.current &&
|
|
14
|
+
!filtersRef.current.contains(event.target as Node)
|
|
15
|
+
) {
|
|
16
|
+
handleSelectedFilter(false)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener('mousedown', handleClickOutside)
|
|
24
|
+
}
|
|
25
|
+
}, [filtersRef])
|
|
26
|
+
|
|
27
|
+
return { filtersRef }
|
|
28
|
+
}
|