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.
Files changed (159) hide show
  1. package/README.md +75 -113
  2. package/lib/components/FilterBar/FilterBar.d.ts +1 -1
  3. package/lib/components/FilterCalendar/FilterCalendar.d.ts +1 -1
  4. package/lib/core/i18n/I18nProvider.d.ts +6 -0
  5. package/lib/core/i18n/index.d.ts +1 -0
  6. package/lib/embed.d.ts +18 -0
  7. package/lib/embed.esm.js +74 -0
  8. package/lib/embed.esm.js.map +1 -0
  9. package/lib/embed.umd.js +74 -0
  10. package/lib/embed.umd.js.map +1 -0
  11. package/lib/i18n.d.ts +2 -2
  12. package/lib/index.d.ts +2 -2
  13. package/lib/index.esm.js +1112 -931
  14. package/lib/index.esm.js.map +1 -1
  15. package/lib/index.js +1111 -930
  16. package/lib/index.js.map +1 -1
  17. package/package.json +9 -1
  18. package/.nvmrc +0 -1
  19. package/.storybook/main.ts +0 -17
  20. package/.storybook/preview.ts +0 -15
  21. package/lib/components/FilterBar/components/buttons/index.d.ts +0 -4
  22. package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +0 -13
  23. package/lib/components/FilterBar/components/buttons/tab-button/TabButton.d.ts +0 -10
  24. package/lib/components/FilterBar/components/cards/image-card/ImageCard.d.ts +0 -11
  25. package/lib/components/FilterBar/components/cards/index.d.ts +0 -1
  26. package/lib/components/FilterBar/components/categories/Categories.d.ts +0 -8
  27. package/lib/components/FilterBar/components/common/FilterSectionHeader.d.ts +0 -8
  28. package/lib/components/FilterBar/components/dates/Dates.d.ts +0 -17
  29. package/lib/components/FilterBar/components/dates/index.d.ts +0 -1
  30. package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +0 -4
  31. package/lib/components/FilterBar/components/guests/Guests.d.ts +0 -12
  32. package/lib/components/FilterBar/components/locations/Locations.d.ts +0 -14
  33. package/lib/components/FilterBar/hooks/useFilterBar.d.ts +0 -32
  34. package/lib/components/FilterBar/hooks/useFilterUi.d.ts +0 -8
  35. package/lib/components/FilterBar/utils/calculateDropdownPosition.d.ts +0 -12
  36. package/lib/components/FilterBar/utils/getLocalizedContent.d.ts +0 -8
  37. package/lib/core/components/buttons/close-button/CloseButton.d.ts +0 -7
  38. package/lib/core/components/buttons/submit-button/SubmitButton.d.ts +0 -14
  39. package/lib/index.umd.js +0 -12489
  40. package/lib/index.umd.js.map +0 -1
  41. package/prettier.config.js +0 -6
  42. package/rollup.config.mjs +0 -63
  43. package/src/assets/IconsSvg.tsx +0 -69
  44. package/src/components/Button/Button.stories.tsx +0 -34
  45. package/src/components/Button/Button.tsx +0 -56
  46. package/src/components/Button/button.css +0 -30
  47. package/src/components/Button/index.ts +0 -1
  48. package/src/components/FilterBar/FilterBar.css +0 -35
  49. package/src/components/FilterBar/FilterBar.stories.tsx +0 -116
  50. package/src/components/FilterBar/FilterBar.tsx +0 -64
  51. package/src/components/FilterBar/FilterBarTypes.ts +0 -71
  52. package/src/components/FilterBar/components/Divider/Divider.css +0 -14
  53. package/src/components/FilterBar/components/Divider/Divider.tsx +0 -7
  54. package/src/components/FilterBar/components/FilterControls/FilterControls.css +0 -22
  55. package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +0 -139
  56. package/src/components/FilterBar/components/FilterPanels/Categories/Categories.css +0 -21
  57. package/src/components/FilterBar/components/FilterPanels/Categories/Categories.tsx +0 -49
  58. package/src/components/FilterBar/components/FilterPanels/Dates/Dates.css +0 -9
  59. package/src/components/FilterBar/components/FilterPanels/Dates/Dates.tsx +0 -60
  60. package/src/components/FilterBar/components/FilterPanels/FilterPanels.css +0 -22
  61. package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +0 -111
  62. package/src/components/FilterBar/components/FilterPanels/Guests/GuestCount/GuestCount.css +0 -58
  63. package/src/components/FilterBar/components/FilterPanels/Guests/GuestCount/GuestCount.tsx +0 -85
  64. package/src/components/FilterBar/components/FilterPanels/Guests/Guests.css +0 -24
  65. package/src/components/FilterBar/components/FilterPanels/Guests/Guests.tsx +0 -59
  66. package/src/components/FilterBar/components/FilterPanels/Locations/Locations.css +0 -16
  67. package/src/components/FilterBar/components/FilterPanels/Locations/Locations.tsx +0 -94
  68. package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.css +0 -34
  69. package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.tsx +0 -17
  70. package/src/components/FilterBar/components/FilterTabs/FilterTabs.css +0 -10
  71. package/src/components/FilterBar/components/FilterTabs/FilterTabs.tsx +0 -50
  72. package/src/components/FilterBar/components/ImageCard/ImageCard.css +0 -30
  73. package/src/components/FilterBar/components/ImageCard/ImageCard.tsx +0 -45
  74. package/src/components/FilterBar/components/SelectButton/SelectButton.css +0 -76
  75. package/src/components/FilterBar/components/SelectButton/SelectButton.tsx +0 -54
  76. package/src/components/FilterBar/components/TabButton/TabButton.css +0 -36
  77. package/src/components/FilterBar/components/TabButton/TabButton.tsx +0 -23
  78. package/src/components/FilterBar/components/index.ts +0 -6
  79. package/src/components/FilterBar/hooks/index.ts +0 -5
  80. package/src/components/FilterBar/hooks/useFilterActions.tsx +0 -126
  81. package/src/components/FilterBar/hooks/useFilterRefs.tsx +0 -21
  82. package/src/components/FilterBar/hooks/useFilterState.tsx +0 -86
  83. package/src/components/FilterBar/hooks/usePanelPosition.tsx +0 -52
  84. package/src/components/FilterBar/hooks/useScrollInToView.tsx +0 -29
  85. package/src/components/FilterBar/index.ts +0 -3
  86. package/src/components/FilterBar/providers/FilterBarProvider.tsx +0 -172
  87. package/src/components/FilterBar/providers/index.ts +0 -1
  88. package/src/components/FilterBar/utils/ageCategoriesRules.ts +0 -27
  89. package/src/components/FilterBar/utils/index.tsx +0 -3
  90. package/src/components/FilterBar/utils/parseGuests.tsx +0 -65
  91. package/src/components/FilterBar/utils/parseLocations.ts +0 -28
  92. package/src/components/FilterCalendar/FilterCalendar.css +0 -109
  93. package/src/components/FilterCalendar/FilterCalendar.stories.tsx +0 -554
  94. package/src/components/FilterCalendar/FilterCalendar.tsx +0 -115
  95. package/src/components/FilterCalendar/FilterCalendarTypes.ts +0 -11
  96. package/src/components/FilterCalendar/components/Footer.tsx +0 -96
  97. package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +0 -163
  98. package/src/components/FilterCalendar/index.ts +0 -3
  99. package/src/core/components/buttons/CloseButton/CloseButton.css +0 -33
  100. package/src/core/components/buttons/CloseButton/CloseButton.tsx +0 -16
  101. package/src/core/components/buttons/SubmitButton/SubmitButton.css +0 -54
  102. package/src/core/components/buttons/SubmitButton/SubmitButton.tsx +0 -42
  103. package/src/core/components/calendar/Calendar.css +0 -280
  104. package/src/core/components/calendar/Calendar.tsx +0 -253
  105. package/src/core/components/calendar/CalendarTypes.ts +0 -48
  106. package/src/core/components/calendar/hooks/index.ts +0 -3
  107. package/src/core/components/calendar/hooks/useCalendarLoadingSpinner.tsx +0 -19
  108. package/src/core/components/calendar/hooks/useCalendarTooltips.tsx +0 -125
  109. package/src/core/components/calendar/hooks/useUpdateDisabledDates.tsx +0 -105
  110. package/src/core/components/calendar/utils/calendarSelectionRules.tsx +0 -180
  111. package/src/core/components/calendar/utils/checkForContinuousSelection.tsx +0 -86
  112. package/src/core/components/calendar/utils/disabledDatesByPage.tsx +0 -31
  113. package/src/core/components/calendar/utils/handleCalendarModifiers.tsx +0 -118
  114. package/src/core/components/calendar/utils/handleRangeContextDisabledDates.tsx +0 -75
  115. package/src/core/components/calendar/utils/index.ts +0 -8
  116. package/src/core/components/calendar/utils/nightsCount.tsx +0 -19
  117. package/src/core/components/calendar/utils/parseDate.tsx +0 -17
  118. package/src/core/components/calendar/utils/parseDates.tsx +0 -12
  119. package/src/core/components/index.ts +0 -7
  120. package/src/core/hooks/index.ts +0 -4
  121. package/src/core/hooks/useAutoFocus.tsx +0 -27
  122. package/src/core/hooks/useAwaitRender.tsx +0 -12
  123. package/src/core/hooks/useCloseFilterSection.tsx +0 -29
  124. package/src/core/hooks/useUpdateTranslations.tsx +0 -14
  125. package/src/i18n.ts +0 -27
  126. package/src/index.ts +0 -8
  127. package/src/locales/en/common.json +0 -18
  128. package/src/locales/en/filterBar.json +0 -33
  129. package/src/locales/fi/common.json +0 -19
  130. package/src/locales/fi/filterBar.json +0 -33
  131. package/src/themes/Default.css +0 -69
  132. package/src/themes/useTheme.tsx +0 -27
  133. package/stories/Button.stories.ts +0 -50
  134. package/stories/Button.tsx +0 -53
  135. package/stories/Configure.mdx +0 -364
  136. package/stories/Header.stories.ts +0 -27
  137. package/stories/Header.tsx +0 -70
  138. package/stories/Page.stories.ts +0 -29
  139. package/stories/Page.tsx +0 -91
  140. package/stories/assets/accessibility.png +0 -0
  141. package/stories/assets/accessibility.svg +0 -5
  142. package/stories/assets/addon-library.png +0 -0
  143. package/stories/assets/assets.png +0 -0
  144. package/stories/assets/context.png +0 -0
  145. package/stories/assets/discord.svg +0 -15
  146. package/stories/assets/docs.png +0 -0
  147. package/stories/assets/figma-plugin.png +0 -0
  148. package/stories/assets/github.svg +0 -3
  149. package/stories/assets/share.png +0 -0
  150. package/stories/assets/styling.png +0 -0
  151. package/stories/assets/testing.png +0 -0
  152. package/stories/assets/theming.png +0 -0
  153. package/stories/assets/tutorials.svg +0 -12
  154. package/stories/assets/youtube.svg +0 -4
  155. package/stories/button.css +0 -30
  156. package/stories/header.css +0 -32
  157. package/stories/page.css +0 -69
  158. package/tsconfig.json +0 -29
  159. /package/lib/components/FilterBar/components/{divider → Divider}/Divider.d.ts +0 -0
@@ -1,86 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { DateRange } from 'react-day-picker'
3
-
4
- import { AgeCategoryCount, FilterBarTypes, Pages } from '../FilterBarTypes'
5
-
6
- type Props = {
7
- locations: FilterBarTypes['locations']
8
- }
9
-
10
- export const useFilterState = ({ locations }: Props) => {
11
- const [selectedPath, setSelectedPath] = useState<string>(Pages.EVENTS)
12
- const [selectedFilter, setSelectedFilter] = useState<string | boolean>(false)
13
- const [calendarRange, setCalendarRange] = useState<DateRange | undefined>()
14
- const [innerLoading, setInnerLoading] = useState<boolean>(false)
15
- const [categories, setCategories] = useState<number>(0)
16
- const [ageCategoryCounts, setAgeCategoryCounts] = useState<AgeCategoryCount>(
17
- {}
18
- )
19
- const [selectedLocations, setSelectedLocations] = useState<
20
- NonNullable<FilterBarTypes['locations']>['data']
21
- >([])
22
-
23
- useEffect(() => {
24
- if (typeof window === 'undefined') return
25
-
26
- const urlSearchParams = new URLSearchParams(window.location.search)
27
-
28
- const startDateParam = urlSearchParams.get('startDate')
29
- const endDateParam = urlSearchParams.get('endDate')
30
- const locationIdParams = urlSearchParams.getAll('locationId')
31
-
32
- let ageCategoryCountsParam: AgeCategoryCount = {}
33
- const ageCategoryCountsQuery = urlSearchParams.get('ageCategoryCounts')
34
-
35
- if (ageCategoryCountsQuery) {
36
- try {
37
- ageCategoryCountsParam = JSON.parse(ageCategoryCountsQuery)
38
- } catch (error) {
39
- console.warn('Invalid ageCategoryCounts query param, ignoring', error)
40
- ageCategoryCountsParam = {}
41
- }
42
- }
43
-
44
- const categoriesParam = urlSearchParams.get('categories')
45
- let parsedCategories = 0
46
-
47
- if (categoriesParam) {
48
- const parsed = parseInt(categoriesParam, 10)
49
- parsedCategories = Number.isNaN(parsed) ? 0 : parsed
50
- }
51
-
52
- if (startDateParam && endDateParam) {
53
- setCalendarRange({
54
- from: new Date(startDateParam),
55
- to: new Date(endDateParam),
56
- })
57
- }
58
-
59
- setAgeCategoryCounts(ageCategoryCountsParam)
60
- setCategories(parsedCategories)
61
-
62
- if (locations?.data?.length && locationIdParams.length) {
63
- const matchedLocations = locations.data.filter((location) =>
64
- locationIdParams.includes(location.id.toString())
65
- )
66
- setSelectedLocations(matchedLocations)
67
- }
68
- }, [locations])
69
-
70
- return {
71
- selectedPath,
72
- selectedFilter,
73
- calendarRange,
74
- innerLoading,
75
- categories,
76
- ageCategoryCounts,
77
- selectedLocations,
78
- setSelectedLocations,
79
- setCalendarRange,
80
- setAgeCategoryCounts,
81
- setCategories,
82
- setSelectedPath,
83
- setSelectedFilter,
84
- setInnerLoading,
85
- }
86
- }
@@ -1,52 +0,0 @@
1
- import { MutableRefObject, RefObject, useLayoutEffect, useState } from 'react'
2
-
3
- type Props = {
4
- selectedFilter: string | boolean
5
- panelRef: RefObject<HTMLDivElement | null>
6
- filtersRef: RefObject<HTMLDivElement | null>
7
- buttonRefs: MutableRefObject<Record<string, HTMLButtonElement | null>>
8
- isMobile: boolean
9
- tabs?: unknown[]
10
- }
11
-
12
- export const usePanelPosition = ({
13
- selectedFilter,
14
- panelRef,
15
- filtersRef,
16
- buttonRefs,
17
- isMobile,
18
- tabs,
19
- }: Props) => {
20
- const [left, setLeft] = useState<number | undefined>()
21
-
22
- const hasMultipleTabs = tabs && tabs.length > 1
23
- const top = isMobile ? (hasMultipleTabs ? 60 : 0) : hasMultipleTabs ? 125 : 66
24
-
25
- useLayoutEffect(() => {
26
- if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
27
- setLeft(undefined)
28
- return
29
- }
30
-
31
- const panel = panelRef.current
32
- const container = filtersRef.current
33
- const button = buttonRefs.current[selectedFilter]
34
-
35
- if (!panel || !container || !button) return
36
-
37
- const panelRect = panel.getBoundingClientRect()
38
- const containerRect = container.getBoundingClientRect()
39
- const buttonRect = button.getBoundingClientRect()
40
-
41
- const buttonLeft = buttonRect.left - containerRect.left - 10
42
-
43
- const newLeft = Math.max(
44
- 0,
45
- Math.min(buttonLeft, containerRect.width - panelRect.width)
46
- )
47
-
48
- setLeft(newLeft)
49
- }, [selectedFilter, isMobile])
50
-
51
- return { top, left }
52
- }
@@ -1,29 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react'
2
-
3
- type Props = {
4
- selectedFilter: string | boolean
5
- }
6
-
7
- export const useScrollInToView = ({ selectedFilter }: Props) => {
8
- const [isMobile, setIsMobile] = useState(true)
9
- const tabsRef = useRef<HTMLDivElement | null>(null)
10
-
11
- useEffect(() => {
12
- if (typeof window !== 'undefined' && window.innerWidth > 960) {
13
- setIsMobile(false)
14
- return
15
- }
16
-
17
- if (tabsRef.current && selectedFilter) {
18
- window.scrollTo({
19
- behavior: 'smooth',
20
- top:
21
- tabsRef.current.getBoundingClientRect().top -
22
- document.body.getBoundingClientRect().top -
23
- 30,
24
- })
25
- }
26
- }, [selectedFilter])
27
-
28
- return { isMobile, tabsRef }
29
- }
@@ -1,3 +0,0 @@
1
- export { FilterBar } from './FilterBar'
2
-
3
- export * from './FilterBarTypes'
@@ -1,172 +0,0 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- PropsWithChildren,
5
- RefObject,
6
- MutableRefObject,
7
- useMemo,
8
- } from 'react'
9
- import { DateRange } from 'react-day-picker'
10
-
11
- import { AgeCategoryCount, Location, FilterBarTypes } from '../FilterBarTypes'
12
- import { useFilterActions, useFilterState, useFilterRefs } from '../hooks'
13
-
14
- type FilterBarProviderProps = PropsWithChildren<FilterBarTypes>
15
-
16
- type FilterBarContextType = FilterBarTypes & {
17
- selectedFilter: string | boolean
18
- ageCategoryCounts: AgeCategoryCount
19
- categories: number
20
- calendarRange?: DateRange
21
- selectedPath: string
22
- innerLoading: boolean
23
- selectedLocations: Location[]
24
-
25
- setSelectedLocations: (val: Location[]) => void
26
- setCalendarRange: (val: DateRange | undefined) => void
27
- setSelectedFilter: (val: string | boolean) => void
28
- setAgeCategoryCounts: (val: AgeCategoryCount) => void
29
- setCategories: (val: number) => void
30
- setSelectedPath: (val: string) => void
31
-
32
- handleSelectedFilter: (id: string | boolean) => void
33
- handleSubmit: () => void
34
- updateGuestsCount: (id: string, newCount: number) => void
35
- handleResetFilters: () => void
36
-
37
- // Refs
38
- previouslyFocusedButtonRef: MutableRefObject<HTMLButtonElement | null>
39
- panelRef: MutableRefObject<HTMLDivElement | null>
40
- buttonRefs: MutableRefObject<Record<string, HTMLButtonElement | null>>
41
- filtersRef: MutableRefObject<HTMLDivElement | null>
42
-
43
- // Mobile
44
- isMobile: boolean
45
- tabsRef: MutableRefObject<HTMLDivElement | null>
46
- }
47
-
48
- const FilterBarContext = createContext<FilterBarContextType | undefined>(
49
- undefined
50
- )
51
-
52
- export const FilterBarProvider = ({
53
- children,
54
- language,
55
- ageCategories,
56
- redirectUrl,
57
- palette,
58
- onSubmit,
59
- fullWidth,
60
- disableCalendarDates,
61
- mode,
62
- tabs,
63
- outerLoading,
64
- locations,
65
- }: FilterBarProviderProps) => {
66
- const {
67
- selectedPath,
68
- selectedFilter,
69
- calendarRange,
70
- innerLoading,
71
- categories,
72
- ageCategoryCounts,
73
- selectedLocations,
74
- setSelectedLocations,
75
- setCalendarRange,
76
- setAgeCategoryCounts,
77
- setCategories,
78
- setSelectedPath,
79
- setSelectedFilter,
80
- setInnerLoading,
81
- } = useFilterState({ locations })
82
-
83
- const filterActions = useFilterActions({
84
- tabs,
85
- ageCategoryCounts,
86
- ageCategories,
87
- selectedLocations,
88
- selectedPath,
89
- redirectUrl,
90
- calendarRange,
91
- setSelectedPath,
92
- setAgeCategoryCounts,
93
- setSelectedFilter,
94
- setCalendarRange,
95
- onSubmit,
96
- setInnerLoading,
97
- })
98
-
99
- const filterRefs = useFilterRefs(selectedFilter)
100
-
101
- const contextValue = useMemo(
102
- () => ({
103
- selectedFilter,
104
- ageCategoryCounts,
105
- categories,
106
- calendarRange,
107
- selectedPath,
108
- innerLoading,
109
- selectedLocations,
110
-
111
- setSelectedLocations,
112
- setCalendarRange,
113
- setSelectedFilter,
114
- setAgeCategoryCounts,
115
- setCategories,
116
- setSelectedPath,
117
-
118
- ...filterActions,
119
-
120
- language,
121
- ageCategories,
122
- redirectUrl,
123
- palette,
124
- onSubmit,
125
- fullWidth,
126
- disableCalendarDates,
127
- mode,
128
- tabs,
129
- outerLoading,
130
- locations,
131
-
132
- ...filterRefs,
133
- }),
134
- [
135
- selectedFilter,
136
- ageCategoryCounts,
137
- categories,
138
- calendarRange,
139
- selectedPath,
140
- innerLoading,
141
- selectedLocations,
142
- language,
143
- ageCategories,
144
- redirectUrl,
145
- palette,
146
- onSubmit,
147
- fullWidth,
148
- disableCalendarDates,
149
- mode,
150
- tabs,
151
- outerLoading,
152
- locations,
153
- filterRefs.isMobile,
154
- filterRefs.tabsRef,
155
- filterRefs.filtersRef,
156
- ]
157
- )
158
-
159
- return (
160
- <FilterBarContext.Provider value={contextValue}>
161
- {children}
162
- </FilterBarContext.Provider>
163
- )
164
- }
165
-
166
- export const useFilterBar = () => {
167
- const context = useContext(FilterBarContext)
168
- if (!context) {
169
- throw new Error('useFilterBar must be used within FilterBarProvider')
170
- }
171
- return context
172
- }
@@ -1 +0,0 @@
1
- export { FilterBarProvider, useFilterBar } from './FilterBarProvider'
@@ -1,27 +0,0 @@
1
- import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes'
2
-
3
- type Props = {
4
- ageCategoryCounts: AgeCategoryCount
5
- ageCategories?: AgeCategoryType[]
6
- }
7
-
8
- export const ageCategoryRules = ({
9
- ageCategoryCounts,
10
- ageCategories,
11
- }: Props): string => {
12
- if (ageCategories?.length) {
13
- ageCategories?.map((a) => {
14
- if (a.minVal) {
15
- const ageCategory = ageCategoryCounts[`guests-${a.id}`]
16
-
17
- if (!ageCategory) {
18
- ageCategoryCounts[`guests-${a.id}`] = a.minVal
19
- }
20
- }
21
- })
22
- }
23
-
24
- return Object.entries(ageCategoryCounts).length
25
- ? JSON.stringify(ageCategoryCounts)
26
- : ''
27
- }
@@ -1,3 +0,0 @@
1
- export { parseGuests } from './parseGuests'
2
- export { parseLocations } from './parseLocations'
3
- export { ageCategoryRules } from './ageCategoriesRules'
@@ -1,65 +0,0 @@
1
- import React from 'react'
2
-
3
- import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes'
4
-
5
- type Props = {
6
- ageCategoryCounts: AgeCategoryCount
7
- ageCategories?: AgeCategoryType[]
8
- guestLabel: string
9
- guestsLabel: string
10
- guestsPlaceholder: string
11
- }
12
-
13
- type AccType = {
14
- total: number
15
- html: string[]
16
- }
17
-
18
- export const parseGuests = ({
19
- guestLabel,
20
- guestsLabel,
21
- guestsPlaceholder,
22
- ageCategoryCounts,
23
- ageCategories,
24
- }: Props) => {
25
- const parsedData = Object.entries(ageCategoryCounts).reduce(
26
- (acc: AccType, [key, value]) => {
27
- const parts = key.split('-')
28
- if (parts.length < 2) return acc
29
-
30
- const ageCategoryId = parts[1]
31
- const ageCategory = ageCategories?.find((c) => c.id === ageCategoryId)
32
-
33
- if (ageCategory && value) {
34
- return {
35
- total: acc.total + value,
36
- html: [...acc.html, `${value}`],
37
- }
38
- }
39
-
40
- return acc
41
- },
42
- { total: 0, html: [] }
43
- )
44
-
45
- if (!parsedData.total) {
46
- return {
47
- content: guestsPlaceholder,
48
- data: parsedData,
49
- }
50
- }
51
-
52
- const breakdown =
53
- parsedData.html.length > 1 ? parsedData.html.join(' + ') : null
54
-
55
- return {
56
- content: (
57
- <>
58
- <span className="will-guest-count">{parsedData.total}</span>{' '}
59
- {parsedData.total > 1 ? guestsLabel : guestLabel}
60
- {breakdown && <> &nbsp; ( {breakdown} )</>}
61
- </>
62
- ),
63
- data: parsedData,
64
- }
65
- }
@@ -1,28 +0,0 @@
1
- import { Location } from '../FilterBarTypes'
2
-
3
- type Props = {
4
- selectedLocations: Location[]
5
- locationsPlaceholder: string
6
- locationsSelectedLabel?: string
7
- }
8
-
9
- export const parseLocations = ({
10
- selectedLocations,
11
- locationsPlaceholder,
12
- locationsSelectedLabel = 'locations',
13
- }: Props) => {
14
- if (!selectedLocations.length) {
15
- return locationsPlaceholder
16
- }
17
-
18
- if (selectedLocations.length === 1) {
19
- const singleSelection = selectedLocations[0].label
20
-
21
- if (!singleSelection) {
22
- return locationsPlaceholder
23
- }
24
- return singleSelection
25
- }
26
-
27
- return `${selectedLocations.length} ${locationsSelectedLabel}`
28
- }
@@ -1,109 +0,0 @@
1
- .will-root .will-calendar-wrapper {
2
- box-shadow: var(--will-box-shadow-dark);
3
- border-radius: 20px;
4
- background-color: var(--will-white);
5
- position: absolute;
6
- top: 0;
7
- left: 0;
8
-
9
- }
10
-
11
- .will-root .will-calendar-wrapper .will-calendar-header,
12
- .will-root .will-calendar-wrapper .will-calendar-main,
13
- .will-root .will-calendar-wrapper .will-calendar-footer {
14
- padding: 20px;
15
- }
16
-
17
- /* Header */
18
-
19
- .will-root .will-calendar-wrapper .will-calendar-header {
20
- display: flex;
21
- justify-content: space-between;
22
- border-bottom: 1px solid var(--will-grey);
23
- align-items: center;
24
- }
25
-
26
- /* Footer */
27
-
28
- .will-root .will-calendar-wrapper .will-calendar-footer {
29
- border-top: 1px solid var(--will-grey);
30
- }
31
-
32
- /* Footer actions */
33
-
34
- .will-root .will-calendar-wrapper .will-calendar-footer-actions-wrapper {
35
- display: flex;
36
- justify-content: space-between;
37
- }
38
-
39
- .will-root .will-calendar-wrapper .will-calendar-footer-dates > div {
40
- margin-bottom: 5px;
41
- }
42
-
43
- .will-root .will-calendar-wrapper .will-calendar-footer-dates-separator {
44
- margin: 0 15px;
45
- }
46
-
47
- .will-root .will-calendar-wrapper .will-calendar-footer-dates .will-calendar-footer-booked {
48
- display: flex;
49
- min-height: 20.5px;
50
- margin-top: 10px;
51
- }
52
-
53
- .will-root .will-calendar-wrapper .will-calendar-footer-error {
54
- display: flex;
55
- max-width: 80%;
56
- }
57
-
58
- .will-root .will-calendar-wrapper .will-calendar-footer-error span {
59
- display: inline-block;
60
- margin-left: 10px;
61
- }
62
-
63
- @media (max-width: 960px) {
64
- .will-root .will-calendar-wrapper {
65
- width: -webkit-fill-available;
66
- margin: 0 -6%;
67
- }
68
-
69
- .will-root .will-calendar-wrapper .will-calendar-header,
70
- .will-root .will-calendar-wrapper .will-calendar-main,
71
- .will-root .will-calendar-wrapper .will-calendar-footer {
72
- padding: 20px 10px;
73
- }
74
-
75
- .will-root .will-calendar-wrapper .will-calendar-footer-actions-wrapper {
76
- flex-direction: column;
77
- }
78
-
79
- .will-root .will-calendar-wrapper .will-calendar-footer-dates {
80
- text-align: center;
81
- }
82
-
83
- .will-root .will-calendar-wrapper .will-calendar-footer-dates .will-calendar-footer-booked {
84
- justify-content: center;
85
- }
86
-
87
- .will-root .will-calendar-wrapper .will-calendar-footer-actions {
88
- flex-direction: column;
89
- width: 100%;
90
- }
91
-
92
- .will-root .will-calendar-wrapper .will-calendar-footer-actions button{
93
- width: 100%;
94
- margin-top: 10px;
95
- }
96
-
97
- .will-root .will-calendar-wrapper .will-calendar-footer-error {
98
- max-width: 100%;
99
- }
100
-
101
- .will-root .will-calendar-wrapper .will-calendar-footer-error span {
102
- text-align: center;
103
- margin-left: 5px;
104
- }
105
- }
106
-
107
- .will-root .will-calendar-wrapper .will-calendar-header .will-filter-bar-close-button {
108
- position: initial;
109
- }