willba-component-library 0.1.37 → 0.1.39
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 -17
- package/src/components/FilterBar/FilterBar.tsx +107 -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
|
@@ -4,15 +4,12 @@ import { format } from 'date-fns'
|
|
|
4
4
|
|
|
5
5
|
import { AgeCategoryCount } from '../FilterBarTypes'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
type Props = {
|
|
8
8
|
redirectUrl?: string
|
|
9
9
|
currentViewApply?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
redirectUrl,
|
|
14
|
-
currentViewApply,
|
|
15
|
-
}: UseFilterBarPropsType) {
|
|
12
|
+
export const useFilterBar = ({ redirectUrl, currentViewApply }: Props) => {
|
|
16
13
|
const [selectedPath, setSelectedPath] = useState('/events')
|
|
17
14
|
|
|
18
15
|
const [selectedFilter, setSelectedFilter] = useState<number | boolean>(false)
|
|
@@ -93,16 +90,6 @@ export default function useFilterBar({
|
|
|
93
90
|
: '',
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
// const getQueryParams = () => {
|
|
97
|
-
// const currentSearchParams = new URLSearchParams(window.location.search)
|
|
98
|
-
|
|
99
|
-
// const params: { [key: string]: string } = {}
|
|
100
|
-
// for (const [key, value] of currentSearchParams.entries()) {
|
|
101
|
-
// params[key] = value
|
|
102
|
-
// }
|
|
103
|
-
// return params
|
|
104
|
-
// }
|
|
105
|
-
|
|
106
93
|
if (currentViewApply) {
|
|
107
94
|
const currentSearchParams = new URLSearchParams(window.location.search)
|
|
108
95
|
const updatedParams = new URLSearchParams()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
selectedFilter: number | boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const useScrollInToView = ({ selectedFilter }: Props) => {
|
|
8
|
+
const [isMobile, setIsMobile] = useState(true)
|
|
9
|
+
const targetFilterBarRef = useRef<HTMLDivElement | null>(null)
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (window !== undefined && window.innerWidth > 960) {
|
|
13
|
+
setIsMobile(false)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (targetFilterBarRef.current && selectedFilter) {
|
|
18
|
+
window.scrollTo({
|
|
19
|
+
behavior: 'smooth',
|
|
20
|
+
top:
|
|
21
|
+
targetFilterBarRef.current.getBoundingClientRect().top -
|
|
22
|
+
document.body.getBoundingClientRect().top -
|
|
23
|
+
30,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}, [selectedFilter])
|
|
27
|
+
|
|
28
|
+
return { isMobile, targetFilterBarRef }
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import i18n from '../../../i18n'
|
|
3
|
+
|
|
4
|
+
type Props = { language?: string }
|
|
5
|
+
|
|
6
|
+
export const useUpdateTranslations = ({ language }: Props) => {
|
|
7
|
+
const [rerenderKey, setRerenderKey] = useState(0)
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
i18n.changeLanguage(language)
|
|
11
|
+
|
|
12
|
+
setRerenderKey((prevKey) => prevKey + 1)
|
|
13
|
+
}, [language])
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { format } from 'date-fns'
|
|
2
|
+
import { DateRange } from 'react-day-picker'
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
calendarRange?: DateRange
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const parseDates = ({ calendarRange }: Props) =>
|
|
9
|
+
calendarRange?.to && calendarRange?.from
|
|
10
|
+
? `${format(calendarRange.from, 'dd.MM.yyyy')} -
|
|
11
|
+
${format(calendarRange.to, 'dd.MM.yyyy')}`
|
|
12
|
+
: null
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes'
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
ageCategoryCounts: AgeCategoryCount
|
|
5
|
+
ageCategories: AgeCategoryType[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const parseGuests = ({ ageCategoryCounts, ageCategories }: Props) =>
|
|
9
|
+
Object.entries(ageCategoryCounts).reduce((acc, [key, value]) => {
|
|
10
|
+
const ageCategory = ageCategories.find((c) => c.id === key[key.length - 1])
|
|
11
|
+
|
|
12
|
+
if (ageCategory && value) {
|
|
13
|
+
acc += `${acc ? ' -' : ''} ${ageCategory.name}: ${value}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return acc
|
|
17
|
+
}, '')
|