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,94 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useRef } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
|
|
4
|
-
import { CloseButton } from '../../../../../core/components'
|
|
5
|
-
import { Location } from '../../../FilterBarTypes'
|
|
6
|
-
import { ImageCard } from '../../ImageCard/ImageCard'
|
|
7
|
-
import { SectionHeader } from '../SectionHeader/SectionHeader'
|
|
8
|
-
|
|
9
|
-
import './Locations.css'
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
locations?: Location[]
|
|
13
|
-
selectedLocations: Location[]
|
|
14
|
-
setSelectedLocations: (locations: Location[]) => void
|
|
15
|
-
autoFocus?: boolean
|
|
16
|
-
multiSelect?: boolean
|
|
17
|
-
onClose?: () => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Locations = forwardRef<HTMLDivElement, Props>(
|
|
21
|
-
(
|
|
22
|
-
{
|
|
23
|
-
locations,
|
|
24
|
-
selectedLocations,
|
|
25
|
-
setSelectedLocations,
|
|
26
|
-
autoFocus,
|
|
27
|
-
multiSelect = false,
|
|
28
|
-
onClose,
|
|
29
|
-
},
|
|
30
|
-
ref
|
|
31
|
-
) => {
|
|
32
|
-
const { t } = useTranslation('filterBar')
|
|
33
|
-
const firstCardRef = useRef<HTMLDivElement>(null)
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (autoFocus && firstCardRef.current) {
|
|
37
|
-
firstCardRef.current.focus()
|
|
38
|
-
}
|
|
39
|
-
}, [autoFocus])
|
|
40
|
-
|
|
41
|
-
const handleLocationClick = (location: Location) => {
|
|
42
|
-
if (multiSelect) {
|
|
43
|
-
// Multi-select: toggle location in array
|
|
44
|
-
const isSelected = selectedLocations.some(
|
|
45
|
-
(loc) => loc.id === location.id
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
if (isSelected) {
|
|
49
|
-
// Remove location if already selected
|
|
50
|
-
setSelectedLocations(
|
|
51
|
-
selectedLocations.filter((loc) => loc.id !== location.id)
|
|
52
|
-
)
|
|
53
|
-
} else {
|
|
54
|
-
// Add location to selection
|
|
55
|
-
setSelectedLocations([...selectedLocations, location])
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
// Single-select: replace selection with clicked location and close modal
|
|
59
|
-
setSelectedLocations([location])
|
|
60
|
-
onClose?.()
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div id="will-filter-bar-locations" ref={ref}>
|
|
66
|
-
<SectionHeader
|
|
67
|
-
title={t('locations.title')}
|
|
68
|
-
action={onClose && <CloseButton handleClose={onClose} />}
|
|
69
|
-
/>
|
|
70
|
-
|
|
71
|
-
<div className="will-locations-filter-container">
|
|
72
|
-
{!!locations?.length &&
|
|
73
|
-
locations.map((location, index) => {
|
|
74
|
-
return (
|
|
75
|
-
<ImageCard
|
|
76
|
-
key={location.id}
|
|
77
|
-
ref={index === 0 ? firstCardRef : null}
|
|
78
|
-
title={location.label}
|
|
79
|
-
description={location.description}
|
|
80
|
-
imageUrl={location.imageUrl}
|
|
81
|
-
isSelected={selectedLocations.some(
|
|
82
|
-
(loc) => loc.id === location.id
|
|
83
|
-
)}
|
|
84
|
-
onClick={() => handleLocationClick(location)}
|
|
85
|
-
/>
|
|
86
|
-
)
|
|
87
|
-
})}
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
Locations.displayName = 'Locations'
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
.will-filter-section-header {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: space-between;
|
|
4
|
-
align-items: center;
|
|
5
|
-
padding: 16px 30px;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.will-filter-section-title {
|
|
9
|
-
font-size: 22px;
|
|
10
|
-
margin: 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.will-filter-section-action {
|
|
14
|
-
display: flex;
|
|
15
|
-
gap: 8px;
|
|
16
|
-
align-items: center;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.will-filter-section-action .will-filter-bar-close-button {
|
|
20
|
-
position: relative;
|
|
21
|
-
top: auto;
|
|
22
|
-
right: auto;
|
|
23
|
-
margin: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media (max-width: 960px) {
|
|
27
|
-
.will-filter-section-header {
|
|
28
|
-
padding: 16px 20px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.will-filter-section-title {
|
|
32
|
-
font-size: 18px;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
import './SectionHeader.css'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
title: string
|
|
7
|
-
action?: ReactNode
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const SectionHeader = ({ title, action }: Props) => {
|
|
11
|
-
return (
|
|
12
|
-
<div className="will-filter-section-header">
|
|
13
|
-
<h3 className="will-filter-section-title">{title}</h3>
|
|
14
|
-
{action && <div className="will-filter-section-action">{action}</div>}
|
|
15
|
-
</div>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useTranslation } from 'react-i18next'
|
|
4
|
-
|
|
5
|
-
import { useFilterBar } from '../../providers'
|
|
6
|
-
|
|
7
|
-
import { TabButton } from '../TabButton/TabButton'
|
|
8
|
-
|
|
9
|
-
import './FilterTabs.css'
|
|
10
|
-
|
|
11
|
-
export const FilterTabs = () => {
|
|
12
|
-
const { t } = useTranslation('filterBar')
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
selectedPath,
|
|
16
|
-
mode,
|
|
17
|
-
tabs,
|
|
18
|
-
tabsRef,
|
|
19
|
-
handleSelectedFilter,
|
|
20
|
-
setSelectedPath,
|
|
21
|
-
handleResetFilters,
|
|
22
|
-
} = useFilterBar()
|
|
23
|
-
|
|
24
|
-
const sortedTabs = useMemo(
|
|
25
|
-
() => [...(tabs ?? [])].sort((a, b) => a.order - b.order),
|
|
26
|
-
[tabs]
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
const handleTabClick = (path: string) => {
|
|
30
|
-
setSelectedPath(path)
|
|
31
|
-
handleResetFilters()
|
|
32
|
-
handleSelectedFilter(false)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (sortedTabs.length <= 1) return null
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className="will-filter-bar-tabs" ref={tabsRef}>
|
|
39
|
-
{sortedTabs.map((tab) => (
|
|
40
|
-
<TabButton
|
|
41
|
-
key={tab.path}
|
|
42
|
-
label={tab.label || t(`tabs.${tab.path.slice(1)}`)}
|
|
43
|
-
onClick={() => handleTabClick(tab.path)}
|
|
44
|
-
active={selectedPath === tab.path}
|
|
45
|
-
mode={mode}
|
|
46
|
-
/>
|
|
47
|
-
))}
|
|
48
|
-
</div>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.will-image-card {
|
|
2
|
-
display: flex;
|
|
3
|
-
gap: 20px;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
align-items: center;
|
|
6
|
-
padding: 8px 30px;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
user-select: none;
|
|
9
|
-
min-height: 40px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.will-image-card.is-selected {
|
|
13
|
-
background-color: var(--will-transparent-lavender);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.will-image-card:hover {
|
|
17
|
-
background-color: var(--will-transparent-lavender);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.will-image-card-image img {
|
|
21
|
-
width: 120px;
|
|
22
|
-
height: 68px;
|
|
23
|
-
object-fit: cover;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media (max-width: 960px) {
|
|
27
|
-
.will-image-card {
|
|
28
|
-
padding: 8px 20px;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react'
|
|
2
|
-
|
|
3
|
-
import './ImageCard.css'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
title?: string
|
|
7
|
-
description?: string | null
|
|
8
|
-
imageUrl?: string | null
|
|
9
|
-
isSelected: boolean
|
|
10
|
-
onClick?: () => void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const ImageCard = forwardRef<HTMLDivElement, Props>(
|
|
14
|
-
({ title, description, imageUrl, isSelected, onClick }, ref) => {
|
|
15
|
-
const ariaLabel = `${title}${description ? `, ${description}` : ''}`
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div
|
|
19
|
-
ref={ref}
|
|
20
|
-
className={`will-image-card ${isSelected ? 'is-selected' : ''}`}
|
|
21
|
-
onClick={onClick}
|
|
22
|
-
onKeyDown={(e) => {
|
|
23
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
24
|
-
e.preventDefault()
|
|
25
|
-
onClick?.()
|
|
26
|
-
}
|
|
27
|
-
}}
|
|
28
|
-
role="button"
|
|
29
|
-
tabIndex={0}
|
|
30
|
-
aria-pressed={isSelected}
|
|
31
|
-
aria-label={ariaLabel}
|
|
32
|
-
>
|
|
33
|
-
<div className="will-image-card-content">
|
|
34
|
-
<h3>{title}</h3>
|
|
35
|
-
{description && <p>{description}</p>}
|
|
36
|
-
</div>
|
|
37
|
-
<div className="will-image-card-image">
|
|
38
|
-
{imageUrl && <img src={imageUrl} alt={title || 'Location image'} />}
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
ImageCard.displayName = 'ImageCard'
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
.will-filter-bar-select-button {
|
|
2
|
-
width: 100%;
|
|
3
|
-
height: auto;
|
|
4
|
-
background-color: transparent;
|
|
5
|
-
border: none;
|
|
6
|
-
padding: 0 20px;
|
|
7
|
-
border-radius: 20px;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
font-size: 14px;
|
|
10
|
-
text-align: initial;
|
|
11
|
-
user-select: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.will-filter-bar-select-button.disabled {
|
|
15
|
-
cursor: not-allowed;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.will-filter-bar-select-button .select-button-wrapper {
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
flex-wrap: wrap;
|
|
22
|
-
gap: 10px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.will-filter-bar-select-button .select-button-wrapper > div {
|
|
26
|
-
display: grid;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.will-filter-bar-select-button .select-button-label {
|
|
30
|
-
color: var(--will-black);
|
|
31
|
-
font-weight: 600;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.will-filter-bar-select-button .select-button-description {
|
|
35
|
-
color: var(--will-black);
|
|
36
|
-
font-weight: 400;
|
|
37
|
-
opacity: 0.5;
|
|
38
|
-
white-space: nowrap;
|
|
39
|
-
min-height: 19px;
|
|
40
|
-
overflow: hidden;
|
|
41
|
-
text-overflow: ellipsis;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.will-filter-bar-select-button .select-button-description span {
|
|
45
|
-
font: inherit;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.will-filter-bar-select-button .select-button-label.active,
|
|
49
|
-
.will-filter-bar-select-button .select-button-description.active {
|
|
50
|
-
font-weight: 700;
|
|
51
|
-
font-size: 15px;
|
|
52
|
-
opacity: 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@media (max-width: 960px) {
|
|
56
|
-
.will-filter-bar-select-button {
|
|
57
|
-
padding: 15px 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.will-filter-bar-select-button:first-child {
|
|
61
|
-
padding: 0 0 15px 0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.will-filter-bar-select-button .select-button-wrapper {
|
|
65
|
-
justify-content: center;
|
|
66
|
-
text-align: center;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.will-filter-bar-select-button .select-button-description {
|
|
70
|
-
white-space: wrap;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.will-filter-bar-select-button .select-button-divider {
|
|
74
|
-
display: none;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, ReactNode, MouseEvent } from 'react'
|
|
2
|
-
|
|
3
|
-
import './SelectButton.css'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
label: string
|
|
7
|
-
onClick: (e: MouseEvent<HTMLButtonElement>) => void
|
|
8
|
-
description: ReactNode
|
|
9
|
-
active?: boolean
|
|
10
|
-
disabled?: boolean
|
|
11
|
-
ariaExpanded?: boolean
|
|
12
|
-
ariaControls?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const SelectButton = forwardRef<HTMLButtonElement, Props>(
|
|
16
|
-
(
|
|
17
|
-
{
|
|
18
|
-
active,
|
|
19
|
-
label,
|
|
20
|
-
onClick,
|
|
21
|
-
description,
|
|
22
|
-
disabled,
|
|
23
|
-
ariaExpanded,
|
|
24
|
-
ariaControls,
|
|
25
|
-
},
|
|
26
|
-
ref
|
|
27
|
-
) => {
|
|
28
|
-
return (
|
|
29
|
-
<button
|
|
30
|
-
ref={ref}
|
|
31
|
-
className={`will-filter-bar-select-button ${disabled ? 'disabled' : ''}`}
|
|
32
|
-
onClick={(e) => (disabled ? undefined : onClick(e))}
|
|
33
|
-
disabled={disabled}
|
|
34
|
-
aria-expanded={ariaExpanded}
|
|
35
|
-
aria-controls={ariaControls}
|
|
36
|
-
aria-haspopup="true"
|
|
37
|
-
aria-disabled={disabled}
|
|
38
|
-
>
|
|
39
|
-
<span className="select-button-wrapper">
|
|
40
|
-
<div>
|
|
41
|
-
<p className={`select-button-label`}>{label}</p>
|
|
42
|
-
<p
|
|
43
|
-
className={`select-button-description ${active ? 'active' : ''}`}
|
|
44
|
-
>
|
|
45
|
-
{description}
|
|
46
|
-
</p>
|
|
47
|
-
</div>
|
|
48
|
-
</span>
|
|
49
|
-
</button>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
SelectButton.displayName = 'SelectButton'
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
.will-filter-bar-tab-button {
|
|
2
|
-
width: auto;
|
|
3
|
-
height: auto;
|
|
4
|
-
padding: 10px 20px;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
border: none;
|
|
7
|
-
white-space: nowrap;
|
|
8
|
-
font-size: 16px;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
background-color: transparent;
|
|
12
|
-
user-select: none;
|
|
13
|
-
font-weight: 600;
|
|
14
|
-
border-radius: 50px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.will-filter-bar-tab-button.light {
|
|
18
|
-
color: var(--will-white)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.will-filter-bar-tab-button.dark {
|
|
22
|
-
color: var(--will-black)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.will-filter-bar-tab-button.light.active,
|
|
26
|
-
.will-filter-bar-tab-button:hover {
|
|
27
|
-
background-color: var(--will-transparent-white);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.will-filter-bar-tab-button.dark.active,
|
|
31
|
-
.will-filter-bar-tab-button:hover {
|
|
32
|
-
background-color: var(--will-transparent-lavender);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import './TabButton.css'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
onClick?: () => void
|
|
7
|
-
label: string
|
|
8
|
-
active?: boolean
|
|
9
|
-
mode?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const TabButton = ({ onClick, label, active, mode }: Props) => {
|
|
13
|
-
return (
|
|
14
|
-
<button
|
|
15
|
-
className={`will-filter-bar-tab-button ${mode || 'light'} ${
|
|
16
|
-
active && 'active'
|
|
17
|
-
} `}
|
|
18
|
-
onClick={onClick}
|
|
19
|
-
>
|
|
20
|
-
{label}
|
|
21
|
-
</button>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { SelectButton } from './SelectButton/SelectButton'
|
|
2
|
-
export { TabButton } from './TabButton/TabButton'
|
|
3
|
-
export { Divider } from './Divider/Divider'
|
|
4
|
-
export { FilterPanels } from './FilterPanels/FilterPanels'
|
|
5
|
-
export { FilterControls } from './FilterControls/FilterControls'
|
|
6
|
-
export { FilterTabs } from './FilterTabs/FilterTabs'
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, useEffect } from 'react'
|
|
2
|
-
import { DateRange } from 'react-day-picker'
|
|
3
|
-
import { format } from 'date-fns'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AgeCategoryCount,
|
|
7
|
-
FilterBarTypes,
|
|
8
|
-
Locations,
|
|
9
|
-
Pages,
|
|
10
|
-
} from '../FilterBarTypes'
|
|
11
|
-
import { ageCategoryRules } from '../utils'
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
tabs: FilterBarTypes['tabs']
|
|
15
|
-
ageCategories: FilterBarTypes['ageCategories']
|
|
16
|
-
redirectUrl: FilterBarTypes['redirectUrl']
|
|
17
|
-
ageCategoryCounts: AgeCategoryCount
|
|
18
|
-
selectedLocations: Locations['data']
|
|
19
|
-
calendarRange?: DateRange
|
|
20
|
-
selectedPath: string
|
|
21
|
-
setSelectedPath: (val: string) => void
|
|
22
|
-
setAgeCategoryCounts: Dispatch<SetStateAction<AgeCategoryCount>>
|
|
23
|
-
setSelectedFilter: (val: string | boolean) => void
|
|
24
|
-
setCalendarRange: (val: DateRange | undefined) => void
|
|
25
|
-
onSubmit: FilterBarTypes['onSubmit']
|
|
26
|
-
setInnerLoading: (val: boolean) => void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const useFilterActions = ({
|
|
30
|
-
tabs,
|
|
31
|
-
calendarRange,
|
|
32
|
-
ageCategoryCounts,
|
|
33
|
-
ageCategories,
|
|
34
|
-
selectedLocations,
|
|
35
|
-
selectedPath,
|
|
36
|
-
redirectUrl,
|
|
37
|
-
setSelectedPath,
|
|
38
|
-
setAgeCategoryCounts,
|
|
39
|
-
setSelectedFilter,
|
|
40
|
-
setCalendarRange,
|
|
41
|
-
onSubmit,
|
|
42
|
-
setInnerLoading,
|
|
43
|
-
}: Props) => {
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (typeof window === 'undefined') return
|
|
46
|
-
|
|
47
|
-
const defaultTab =
|
|
48
|
-
tabs?.length === 1 ? tabs[0] : tabs?.find((tab) => tab.default)
|
|
49
|
-
|
|
50
|
-
const paths = [Pages.EVENTS, Pages.ROOMS, Pages.SALES]
|
|
51
|
-
|
|
52
|
-
const currentPath =
|
|
53
|
-
paths.find((path) => window.location.pathname.includes(path)) ||
|
|
54
|
-
defaultTab?.path ||
|
|
55
|
-
Pages.EVENTS
|
|
56
|
-
|
|
57
|
-
setSelectedPath(currentPath)
|
|
58
|
-
}, [tabs])
|
|
59
|
-
|
|
60
|
-
const updateGuestsCount = (id: string, newCount: number) => {
|
|
61
|
-
setAgeCategoryCounts((prev) => ({
|
|
62
|
-
...prev,
|
|
63
|
-
[id]: newCount,
|
|
64
|
-
}))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const handleSelectedFilter = (id: string | boolean) => {
|
|
68
|
-
setSelectedFilter(id)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const handleSubmit = () => {
|
|
72
|
-
if (typeof window === 'undefined') return
|
|
73
|
-
|
|
74
|
-
const newParams = {
|
|
75
|
-
startDate: calendarRange?.from
|
|
76
|
-
? format(calendarRange.from, 'yyyy-MM-dd')
|
|
77
|
-
: '',
|
|
78
|
-
endDate: calendarRange?.to ? format(calendarRange.to, 'yyyy-MM-dd') : '',
|
|
79
|
-
ageCategoryCounts: ageCategoryRules({
|
|
80
|
-
ageCategoryCounts,
|
|
81
|
-
ageCategories,
|
|
82
|
-
}),
|
|
83
|
-
selectedLocations: selectedLocations
|
|
84
|
-
.map((l) => l.id.toString())
|
|
85
|
-
.join(','),
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const querySearchParams = new URLSearchParams()
|
|
89
|
-
|
|
90
|
-
for (const [key, value] of Object.entries(newParams)) {
|
|
91
|
-
if (!value) continue
|
|
92
|
-
|
|
93
|
-
if (key === 'selectedLocations' && selectedLocations.length) {
|
|
94
|
-
selectedLocations.forEach((location) =>
|
|
95
|
-
querySearchParams.append('locationId', location.id.toString())
|
|
96
|
-
)
|
|
97
|
-
} else {
|
|
98
|
-
querySearchParams.append(key, value.toString())
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
setSelectedFilter(false)
|
|
103
|
-
|
|
104
|
-
if (onSubmit && window.location.href.includes(selectedPath)) {
|
|
105
|
-
onSubmit(newParams)
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const paramString = querySearchParams.toString()
|
|
110
|
-
const path = `${redirectUrl}${selectedPath}`
|
|
111
|
-
|
|
112
|
-
setInnerLoading(true)
|
|
113
|
-
window.location.href = paramString ? `${path}?${paramString}` : path
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const handleResetFilters = () => {
|
|
117
|
-
setAgeCategoryCounts({})
|
|
118
|
-
setCalendarRange(undefined)
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
updateGuestsCount,
|
|
122
|
-
handleSelectedFilter,
|
|
123
|
-
handleSubmit,
|
|
124
|
-
handleResetFilters,
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useScrollInToView } from './useScrollInToView'
|
|
4
|
-
|
|
5
|
-
export const useFilterRefs = (selectedFilter: string | boolean) => {
|
|
6
|
-
const buttonRefs = useRef<Record<string, HTMLButtonElement | null>>({})
|
|
7
|
-
const panelRef = useRef<HTMLDivElement | null>(null)
|
|
8
|
-
const previouslyFocusedButtonRef = useRef<HTMLButtonElement | null>(null)
|
|
9
|
-
const filtersRef = useRef<HTMLDivElement | null>(null)
|
|
10
|
-
|
|
11
|
-
const { isMobile, tabsRef } = useScrollInToView({ selectedFilter })
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
previouslyFocusedButtonRef,
|
|
15
|
-
isMobile,
|
|
16
|
-
tabsRef,
|
|
17
|
-
panelRef,
|
|
18
|
-
buttonRefs,
|
|
19
|
-
filtersRef,
|
|
20
|
-
}
|
|
21
|
-
}
|