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.
Files changed (49) hide show
  1. package/lib/components/FilterBar/FilterBar.d.ts +3 -3
  2. package/lib/components/FilterBar/FilterBarTypes.d.ts +0 -5
  3. package/lib/components/FilterBar/components/buttons/close-button/CloseButton.d.ts +1 -1
  4. package/lib/components/FilterBar/components/buttons/index.d.ts +4 -0
  5. package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +1 -1
  6. package/lib/components/FilterBar/components/buttons/submit-button/SubmitButton.d.ts +1 -1
  7. package/lib/components/FilterBar/components/buttons/tab-button/TabButton.d.ts +1 -1
  8. package/lib/components/FilterBar/components/calendar/Calendar.d.ts +3 -3
  9. package/lib/components/FilterBar/components/categories/Categories.d.ts +6 -1
  10. package/lib/components/FilterBar/components/divider/Divider.d.ts +1 -1
  11. package/lib/components/FilterBar/components/guests/Guests.d.ts +8 -2
  12. package/lib/components/FilterBar/components/index.d.ts +5 -0
  13. package/lib/components/FilterBar/hooks/index.d.ts +4 -0
  14. package/lib/components/FilterBar/hooks/useCloseFilterSection.d.ts +8 -0
  15. package/lib/components/FilterBar/hooks/useFilterBar.d.ts +3 -3
  16. package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +9 -0
  17. package/lib/components/FilterBar/hooks/useUpdateTranslations.d.ts +5 -0
  18. package/lib/components/FilterBar/utils/index.d.ts +2 -0
  19. package/lib/components/FilterBar/utils/parseDates.d.ts +6 -0
  20. package/lib/components/FilterBar/utils/parseGuests.d.ts +7 -0
  21. package/lib/index.d.ts +2 -2
  22. package/lib/index.esm.js +6435 -6403
  23. package/lib/index.esm.js.map +1 -1
  24. package/lib/index.js +6435 -6403
  25. package/lib/index.js.map +1 -1
  26. package/lib/index.umd.js +6435 -6403
  27. package/lib/index.umd.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/components/FilterBar/FilterBar.css +1 -22
  30. package/src/components/FilterBar/FilterBar.tsx +104 -149
  31. package/src/components/FilterBar/FilterBarTypes.ts +0 -6
  32. package/src/components/FilterBar/components/buttons/close-button/CloseButton.tsx +1 -1
  33. package/src/components/FilterBar/components/buttons/index.ts +4 -0
  34. package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +1 -6
  35. package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.tsx +1 -1
  36. package/src/components/FilterBar/components/buttons/tab-button/TabButton.tsx +1 -1
  37. package/src/components/FilterBar/components/calendar/Calendar.tsx +42 -43
  38. package/src/components/FilterBar/components/categories/Categories.tsx +6 -1
  39. package/src/components/FilterBar/components/divider/Divider.tsx +1 -1
  40. package/src/components/FilterBar/components/guests/Guests.tsx +34 -30
  41. package/src/components/FilterBar/components/index.ts +6 -0
  42. package/src/components/FilterBar/hooks/index.ts +4 -0
  43. package/src/components/FilterBar/hooks/useCloseFilterSection.tsx +28 -0
  44. package/src/components/FilterBar/hooks/useFilterBar.tsx +2 -15
  45. package/src/components/FilterBar/hooks/useScrollInToView.tsx +29 -0
  46. package/src/components/FilterBar/hooks/useUpdateTranslations.tsx +14 -0
  47. package/src/components/FilterBar/utils/index.tsx +2 -0
  48. package/src/components/FilterBar/utils/parseDates.tsx +12 -0
  49. package/src/components/FilterBar/utils/parseGuests.tsx +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -1,5 +1,5 @@
1
1
  .will-root {
2
- z-index: 99999;
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, useState, useRef } from 'react'
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
- import i18n from '../../i18n'
18
- import CloseButton from './components/buttons/close-button/CloseButton'
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 interface FilterBarProps {
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
- const [rerenderKey, setRerenderKey] = useState(0)
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
- // Scroll in to view
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
- if (window !== undefined && window.innerWidth > 960) {
76
- setIsMobile(false)
77
- return
78
- }
73
+ // Scroll in to view
74
+ const { isMobile, targetFilterBarRef } = useScrollInToView({ selectedFilter })
79
75
 
80
- if (targetFilterBarRef.current && selectedFilter) {
81
- window.scrollTo({
82
- behavior: 'smooth',
83
- top:
84
- targetFilterBarRef.current.getBoundingClientRect().top -
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
- {selectedFilter && (
83
+ <div className={`will-root`} style={themePalette}>
84
+ {!currentViewApply && (
115
85
  <div
116
- className={`will-filter-bar will-filter-bar-underlay`}
117
- onClick={() => {
118
- handleSelectedFilter(false)
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={`will-root ${selectedFilter ? 'isMobileAbsolute' : ''}`}
125
- style={themePalette}
103
+ className="will-filter-bar-header"
104
+ ref={currentViewApply ? targetFilterBarRef : null}
126
105
  >
127
- {!currentViewApply && (
128
- <div
129
- className="will-filter-bar-tabs"
130
- ref={!currentViewApply ? targetFilterBarRef : null}
131
- >
132
- <TabButton
133
- label={t('tabs.events')}
134
- onClick={() => setSelectedPath('/events')}
135
- active={selectedPath === '/events'}
136
- />
137
- <TabButton
138
- label={t('tabs.rooms')}
139
- onClick={() => setSelectedPath('/rooms')}
140
- active={selectedPath === '/rooms'}
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
- </div>
134
+ </>
143
135
  )}
144
136
 
137
+ <SubmitButton onClick={handleSubmit} />
138
+ </div>
139
+
140
+ {selectedFilter && (
145
141
  <div
146
- className="will-filter-bar-header"
147
- ref={currentViewApply ? targetFilterBarRef : null}
142
+ className="will-filter-bar-container"
143
+ style={currentViewApply && !isMobile ? { top: 66 } : {}}
148
144
  >
149
- <SelectButton
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
- {selectedPath === '/rooms' && (
166
- <>
167
- <Divider />
168
-
169
- <SelectButton
170
- label={t('guests.label')}
171
- description={
172
- renderGuests ? renderGuests : t('guests.labelPlaceholder')
173
- }
174
- onClick={() => handleSelectedFilter(2)}
175
- style={fontWeightBold(selectedFilter === 2)}
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
- {selectedFilter && (
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 default function CloseButton({ handleClose }: CloseButtonPropsType) {
10
+ export const CloseButton = ({ handleClose }: CloseButtonPropsType) => {
11
11
  return (
12
12
  <button className="will-filter-bar-close-button" onClick={handleClose}>
13
13
  <IoIosCloseCircleOutline />
@@ -0,0 +1,4 @@
1
+ export { CloseButton } from './close-button/CloseButton'
2
+ export { SelectButton } from './select-button/SelectButton'
3
+ export { SubmitButton } from './submit-button/SubmitButton'
4
+ export { TabButton } from './tab-button/TabButton'
@@ -9,12 +9,7 @@ type Props = {
9
9
  description: string
10
10
  }
11
11
 
12
- export default function SelectButton({
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"
@@ -4,7 +4,7 @@ import { FaSearch } from 'react-icons/fa'
4
4
 
5
5
  import './SubmitButton.css'
6
6
 
7
- export default function SubmitButton({ onClick }: any) {
7
+ export const SubmitButton = ({ onClick }: any) => {
8
8
  const { t } = useTranslation('filterBar')
9
9
 
10
10
  return (
@@ -8,7 +8,7 @@ type Props = {
8
8
  active?: boolean
9
9
  }
10
10
 
11
- export default function SubmitButton({ onClick, label, active }: Props) {
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
- interface CalendarPropsType {
9
+ type Props = {
10
10
  calendarRange: DateRange | undefined
11
11
  setCalendarRange: (range: DateRange | undefined) => void
12
12
  }
13
13
 
14
- export default function Calendar({
15
- calendarRange,
16
- setCalendarRange,
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
- const today = startOfDay(new Date())
18
+ const today = startOfDay(new Date())
21
19
 
22
- const disabledDays = [
23
- {
24
- from: addDays(today, -2),
25
- to: addDays(today, -50),
26
- },
27
- ]
20
+ const disabledDays = [
21
+ {
22
+ from: addDays(today, -2),
23
+ to: addDays(today, -50),
24
+ },
25
+ ]
28
26
 
29
- useEffect(() => {
30
- if (!calendarRange) setCalendarRange(undefined)
31
- }, [])
27
+ useEffect(() => {
28
+ if (!calendarRange) setCalendarRange(undefined)
29
+ }, [])
32
30
 
33
- return (
34
- <div className="will-filter-bar-calendar">
35
- {/* <div className="will-calendar-filter-header">
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
- <div className="will-calendar-filter-container">
39
- <DayPicker
40
- id="will-calendar"
41
- mode="range"
42
- showOutsideDays
43
- numberOfMonths={!isTablet ? 2 : 1}
44
- weekStartsOn={1}
45
- selected={calendarRange}
46
- onSelect={setCalendarRange}
47
- modifiersClassNames={{
48
- today: 'my-today',
49
- }}
50
- modifiersStyles={{
51
- disabled: { opacity: '0.2' },
52
- }}
53
- captionLayout="dropdown-buttons"
54
- defaultMonth={today}
55
- disabled={disabledDays}
56
- fromMonth={today}
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
- </div>
60
- )
61
- }
58
+ )
59
+ }
60
+ )
@@ -3,7 +3,12 @@ import { useTranslation } from 'react-i18next'
3
3
 
4
4
  import './Categories.css'
5
5
 
6
- export default function Categories({ categories, setCategories }: any) {
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 = [
@@ -2,6 +2,6 @@ import React from 'react'
2
2
 
3
3
  import './Divider.css'
4
4
 
5
- export default function Divider() {
5
+ export const Divider = () => {
6
6
  return <div className="will-filter-bar-divider" />
7
7
  }
@@ -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, GuestsPropsType } from '../../FilterBarTypes'
5
+ import { AgeCategoryCount, AgeCategoryType } from '../../FilterBarTypes'
6
6
 
7
7
  import './Guests.css'
8
8
 
9
- export default function Guests({
10
- ageCategories,
11
- updateGuestsCount,
12
- ageCategoryCounts,
13
- }: GuestsPropsType) {
14
- const { t } = useTranslation('filterBar')
15
- return (
16
- <div className="will-filter-bar-guests">
17
- <h3 className="will-guests-filter-title">{t('guests.title')}</h3>
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
- <div className="will-guests-filter-container">
20
- {ageCategories?.map((category) => (
21
- <GuestCount
22
- key={category.id}
23
- id={parseInt(category.id)}
24
- label={category.name}
25
- minVal={category.minVal}
26
- sortOrder={category.sortOrder}
27
- updateGuestsCount={updateGuestsCount}
28
- count={
29
- (ageCategoryCounts as AgeCategoryCount)[
30
- `guests-${category.id}`
31
- ] || category.minVal
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
- </div>
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,4 @@
1
+ export { useFilterBar } from './useFilterBar'
2
+ export { useScrollInToView } from './useScrollInToView'
3
+ export { useUpdateTranslations } from './useUpdateTranslations'
4
+ export { useCloseFilterSection } from './useCloseFilterSection'
@@ -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
+ }