willba-component-library 0.1.42 → 0.1.44
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/index.esm.js +19 -44
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +19 -44
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +19 -44
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/components/calendar/Calendar.tsx +6 -9
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +9 -6
- package/src/components/FilterBar/hooks/useFilterBar.tsx +3 -42
package/package.json
CHANGED
|
@@ -15,6 +15,10 @@ export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
|
15
15
|
({ calendarRange, setCalendarRange }: Props, ref) => {
|
|
16
16
|
const isTablet = useMediaQuery({ maxWidth: 960 })
|
|
17
17
|
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!calendarRange) setCalendarRange(undefined)
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
18
22
|
const today = startOfDay(new Date())
|
|
19
23
|
|
|
20
24
|
const disabledDays = [
|
|
@@ -23,21 +27,14 @@ export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
|
23
27
|
to: addDays(today, -50),
|
|
24
28
|
},
|
|
25
29
|
]
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!calendarRange) setCalendarRange(undefined)
|
|
29
|
-
}, [])
|
|
30
|
+
const selectedStartDate = calendarRange?.from
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<div className="will-filter-bar-calendar" ref={ref}>
|
|
33
|
-
{/* <div className="will-calendar-filter-header">
|
|
34
|
-
<h3 className="will-calendar-filter-title">{t('calendar.title')}</h3>
|
|
35
|
-
</div> */}
|
|
36
34
|
<div className="will-calendar-filter-container">
|
|
37
35
|
<DayPicker
|
|
38
36
|
id="will-calendar"
|
|
39
37
|
mode="range"
|
|
40
|
-
//showOutsideDays
|
|
41
38
|
numberOfMonths={!isTablet ? 2 : 1}
|
|
42
39
|
weekStartsOn={1}
|
|
43
40
|
selected={calendarRange}
|
|
@@ -49,7 +46,7 @@ export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
|
49
46
|
disabled: { opacity: '0.2' },
|
|
50
47
|
}}
|
|
51
48
|
captionLayout="dropdown-buttons"
|
|
52
|
-
defaultMonth={today}
|
|
49
|
+
defaultMonth={selectedStartDate || today}
|
|
53
50
|
disabled={disabledDays}
|
|
54
51
|
fromMonth={today}
|
|
55
52
|
/>
|
|
@@ -12,6 +12,12 @@ export default function GuestCount({
|
|
|
12
12
|
count,
|
|
13
13
|
minVal,
|
|
14
14
|
}: GuestsCountPropsType) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (minVal && minVal > count) {
|
|
17
|
+
updateGuestsCount(`guests-${id}`, minVal)
|
|
18
|
+
}
|
|
19
|
+
}, [])
|
|
20
|
+
|
|
15
21
|
const handleDecrement = () => {
|
|
16
22
|
if (count > minVal) {
|
|
17
23
|
updateGuestsCount(`guests-${id}`, count - 1)
|
|
@@ -30,15 +36,12 @@ export default function GuestCount({
|
|
|
30
36
|
<button
|
|
31
37
|
className="will-guests-filter-counter-button"
|
|
32
38
|
onClick={handleDecrement}
|
|
33
|
-
disabled={minVal && count <= minVal ? true : false}
|
|
39
|
+
disabled={(minVal && count <= minVal) || !count ? true : false}
|
|
34
40
|
style={{
|
|
35
41
|
cursor:
|
|
36
|
-
minVal && count <= minVal
|
|
37
|
-
? 'initial'
|
|
38
|
-
: !minVal && count < 1
|
|
39
|
-
? 'initial'
|
|
40
|
-
: 'pointer',
|
|
42
|
+
(minVal && count <= minVal) || !count ? 'initial' : 'pointer',
|
|
41
43
|
paddingBottom: '4px',
|
|
44
|
+
opacity: (minVal && count <= minVal) || !count ? 0.4 : 1,
|
|
42
45
|
}}
|
|
43
46
|
>
|
|
44
47
|
-
|
|
@@ -91,10 +91,9 @@ export const useFilterBar = ({
|
|
|
91
91
|
: '',
|
|
92
92
|
endDate: calendarRange?.to ? format(calendarRange.to, 'yyyy-MM-dd') : '',
|
|
93
93
|
categories,
|
|
94
|
-
ageCategoryCounts:
|
|
95
|
-
ageCategoryCounts
|
|
96
|
-
|
|
97
|
-
}),
|
|
94
|
+
ageCategoryCounts: Object.entries(ageCategoryCounts).length
|
|
95
|
+
? JSON.stringify(ageCategoryCounts)
|
|
96
|
+
: '',
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
if (currentViewApply) {
|
|
@@ -158,41 +157,3 @@ export const useFilterBar = ({
|
|
|
158
157
|
setSelectedPath,
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
|
-
|
|
162
|
-
////////////
|
|
163
|
-
|
|
164
|
-
const handleAgeCategoryRules = ({
|
|
165
|
-
ageCategoryCounts,
|
|
166
|
-
ageCategories,
|
|
167
|
-
}: {
|
|
168
|
-
ageCategoryCounts: AgeCategoryCount
|
|
169
|
-
ageCategories?: AgeCategoryType[]
|
|
170
|
-
}) => {
|
|
171
|
-
if (ageCategories?.length) {
|
|
172
|
-
ageCategories?.map((a) => {
|
|
173
|
-
if (a.minVal) {
|
|
174
|
-
// Age categories rules
|
|
175
|
-
const totalAgeCategories = Object.entries(ageCategoryCounts).reduce(
|
|
176
|
-
(acc, c) => {
|
|
177
|
-
return acc + c[1]
|
|
178
|
-
},
|
|
179
|
-
0
|
|
180
|
-
)
|
|
181
|
-
const ageCategory = ageCategoryCounts[`guests-${a.id}`]
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
!totalAgeCategories ||
|
|
185
|
-
(totalAgeCategories === 1 && ageCategory === 1)
|
|
186
|
-
) {
|
|
187
|
-
ageCategoryCounts[`guests-${a.id}`] = 2
|
|
188
|
-
} else if (totalAgeCategories > 1 && !ageCategory) {
|
|
189
|
-
ageCategoryCounts[`guests-${a.id}`] = a.minVal
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return Object.entries(ageCategoryCounts).length
|
|
196
|
-
? JSON.stringify(ageCategoryCounts)
|
|
197
|
-
: ''
|
|
198
|
-
}
|