willba-component-library 0.1.41 → 0.1.42
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/hooks/useFilterBar.d.ts +3 -2
- package/lib/index.esm.js +47 -22
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +47 -22
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +47 -22
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.stories.tsx +1 -1
- package/src/components/FilterBar/FilterBar.tsx +1 -1
- package/src/components/FilterBar/components/calendar/Calendar.tsx +1 -1
- package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +2 -6
- package/src/components/FilterBar/components/guests/Guests.tsx +1 -1
- package/src/components/FilterBar/hooks/useFilterBar.tsx +60 -15
package/lib/index.umd.js
CHANGED
|
@@ -3923,7 +3923,7 @@
|
|
|
3923
3923
|
};
|
|
3924
3924
|
|
|
3925
3925
|
var useFilterBar = function (_a) {
|
|
3926
|
-
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply;
|
|
3926
|
+
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
|
|
3927
3927
|
var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
3928
3928
|
var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
|
|
3929
3929
|
var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
|
|
@@ -3945,6 +3945,7 @@
|
|
|
3945
3945
|
setCategories(parsedCategories);
|
|
3946
3946
|
}, []);
|
|
3947
3947
|
React__default.useEffect(function () {
|
|
3948
|
+
// Handle hide scroll bar on mobile
|
|
3948
3949
|
if (typeof window === 'undefined')
|
|
3949
3950
|
return;
|
|
3950
3951
|
document.body.style.overflow =
|
|
@@ -3954,15 +3955,15 @@
|
|
|
3954
3955
|
};
|
|
3955
3956
|
}, [selectedFilter]);
|
|
3956
3957
|
React__default.useEffect(function () {
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3958
|
+
// Handle default selected tab
|
|
3959
|
+
if (typeof window === 'undefined')
|
|
3960
|
+
return;
|
|
3961
|
+
var currentPath = window.location.pathname.includes('/events')
|
|
3962
|
+
? '/events'
|
|
3963
|
+
: window.location.pathname.includes('/rooms')
|
|
3964
|
+
? '/rooms'
|
|
3965
|
+
: '/events';
|
|
3966
|
+
setSelectedPath(currentPath);
|
|
3966
3967
|
}, []);
|
|
3967
3968
|
var updateGuestsCount = function (id, newCount) {
|
|
3968
3969
|
setAgeCategoryCounts(function (prevCounts) {
|
|
@@ -3981,9 +3982,10 @@
|
|
|
3981
3982
|
: '',
|
|
3982
3983
|
endDate: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) ? format(calendarRange.to, 'yyyy-MM-dd') : '',
|
|
3983
3984
|
categories: categories,
|
|
3984
|
-
ageCategoryCounts:
|
|
3985
|
-
|
|
3986
|
-
:
|
|
3985
|
+
ageCategoryCounts: handleAgeCategoryRules({
|
|
3986
|
+
ageCategoryCounts: ageCategoryCounts,
|
|
3987
|
+
ageCategories: ageCategories,
|
|
3988
|
+
}),
|
|
3987
3989
|
};
|
|
3988
3990
|
if (currentViewApply) {
|
|
3989
3991
|
var currentSearchParams = new URLSearchParams(window.location.search);
|
|
@@ -4067,6 +4069,31 @@
|
|
|
4067
4069
|
setSelectedPath: setSelectedPath,
|
|
4068
4070
|
};
|
|
4069
4071
|
};
|
|
4072
|
+
////////////
|
|
4073
|
+
var handleAgeCategoryRules = function (_a) {
|
|
4074
|
+
var ageCategoryCounts = _a.ageCategoryCounts, ageCategories = _a.ageCategories;
|
|
4075
|
+
if (ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.length) {
|
|
4076
|
+
ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (a) {
|
|
4077
|
+
if (a.minVal) {
|
|
4078
|
+
// Age categories rules
|
|
4079
|
+
var totalAgeCategories = Object.entries(ageCategoryCounts).reduce(function (acc, c) {
|
|
4080
|
+
return acc + c[1];
|
|
4081
|
+
}, 0);
|
|
4082
|
+
var ageCategory = ageCategoryCounts["guests-".concat(a.id)];
|
|
4083
|
+
if (!totalAgeCategories ||
|
|
4084
|
+
(totalAgeCategories === 1 && ageCategory === 1)) {
|
|
4085
|
+
ageCategoryCounts["guests-".concat(a.id)] = 2;
|
|
4086
|
+
}
|
|
4087
|
+
else if (totalAgeCategories > 1 && !ageCategory) {
|
|
4088
|
+
ageCategoryCounts["guests-".concat(a.id)] = a.minVal;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
return Object.entries(ageCategoryCounts).length
|
|
4094
|
+
? JSON.stringify(ageCategoryCounts)
|
|
4095
|
+
: '';
|
|
4096
|
+
};
|
|
4070
4097
|
|
|
4071
4098
|
var useScrollInToView = function (_a) {
|
|
4072
4099
|
var selectedFilter = _a.selectedFilter;
|
|
@@ -6599,10 +6626,6 @@
|
|
|
6599
6626
|
|
|
6600
6627
|
function GuestCount(_a) {
|
|
6601
6628
|
var label = _a.label, sortOrder = _a.sortOrder, id = _a.id, updateGuestsCount = _a.updateGuestsCount, count = _a.count, minVal = _a.minVal;
|
|
6602
|
-
React__default.useEffect(function () {
|
|
6603
|
-
if (minVal)
|
|
6604
|
-
updateGuestsCount("guests-".concat(id), minVal);
|
|
6605
|
-
}, []);
|
|
6606
6629
|
var handleDecrement = function () {
|
|
6607
6630
|
if (count > minVal) {
|
|
6608
6631
|
updateGuestsCount("guests-".concat(id), count - 1);
|
|
@@ -6614,8 +6637,8 @@
|
|
|
6614
6637
|
return (React__default.createElement("div", { className: "will-guests-filter-inner", style: { order: "".concat(sortOrder) } },
|
|
6615
6638
|
React__default.createElement("p", { className: "will-guests-filter-label" }, label),
|
|
6616
6639
|
React__default.createElement("div", { className: "will-guests-filter-counter" },
|
|
6617
|
-
React__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count
|
|
6618
|
-
cursor: minVal && count
|
|
6640
|
+
React__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count <= minVal ? true : false, style: {
|
|
6641
|
+
cursor: minVal && count <= minVal
|
|
6619
6642
|
? 'initial'
|
|
6620
6643
|
: !minVal && count < 1
|
|
6621
6644
|
? 'initial'
|
|
@@ -6634,7 +6657,7 @@
|
|
|
6634
6657
|
var t = useTranslation('filterBar').t;
|
|
6635
6658
|
return (React__default.createElement("div", { className: "will-filter-bar-guests", ref: ref },
|
|
6636
6659
|
React__default.createElement("h3", { className: "will-guests-filter-title" }, t('guests.title')),
|
|
6637
|
-
React__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__default.createElement(GuestCount, { key: category.id, id: parseInt(category.id), label: category.name, minVal: category.minVal, sortOrder: category.sortOrder, updateGuestsCount: updateGuestsCount, count: ageCategoryCounts["guests-".concat(category.id)] ||
|
|
6660
|
+
React__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__default.createElement(GuestCount, { key: category.id, id: parseInt(category.id), label: category.name, minVal: category.minVal, sortOrder: category.sortOrder, updateGuestsCount: updateGuestsCount, count: ageCategoryCounts["guests-".concat(category.id)] || 0 })); }))));
|
|
6638
6661
|
});
|
|
6639
6662
|
|
|
6640
6663
|
/******************************************************************************
|
|
@@ -10627,7 +10650,9 @@
|
|
|
10627
10650
|
}, []);
|
|
10628
10651
|
return (React__default.createElement("div", { className: "will-filter-bar-calendar", ref: ref },
|
|
10629
10652
|
React__default.createElement("div", { className: "will-calendar-filter-container" },
|
|
10630
|
-
React__default.createElement(DayPicker, { id: "will-calendar", mode: "range",
|
|
10653
|
+
React__default.createElement(DayPicker, { id: "will-calendar", mode: "range",
|
|
10654
|
+
//showOutsideDays
|
|
10655
|
+
numberOfMonths: !isTablet ? 2 : 1, weekStartsOn: 1, selected: calendarRange, onSelect: setCalendarRange, modifiersClassNames: {
|
|
10631
10656
|
today: 'my-today',
|
|
10632
10657
|
}, modifiersStyles: {
|
|
10633
10658
|
disabled: { opacity: '0.2' },
|
|
@@ -10675,7 +10700,7 @@
|
|
|
10675
10700
|
useUpdateTranslations({ language: language });
|
|
10676
10701
|
var t = useTranslation('filterBar').t;
|
|
10677
10702
|
// Filters
|
|
10678
|
-
var _d = useFilterBar({ redirectUrl: redirectUrl, currentViewApply: currentViewApply }), selectedFilter = _d.selectedFilter, ageCategoryCounts = _d.ageCategoryCounts, categories = _d.categories, calendarRange = _d.calendarRange, selectedPath = _d.selectedPath, setCalendarRange = _d.setCalendarRange, setCategories = _d.setCategories, handleSelectedFilter = _d.handleSelectedFilter, handleSubmit = _d.handleSubmit, updateGuestsCount = _d.updateGuestsCount, setSelectedPath = _d.setSelectedPath;
|
|
10703
|
+
var _d = useFilterBar({ redirectUrl: redirectUrl, currentViewApply: currentViewApply, ageCategories: ageCategories }), selectedFilter = _d.selectedFilter, ageCategoryCounts = _d.ageCategoryCounts, categories = _d.categories, calendarRange = _d.calendarRange, selectedPath = _d.selectedPath, setCalendarRange = _d.setCalendarRange, setCategories = _d.setCategories, handleSelectedFilter = _d.handleSelectedFilter, handleSubmit = _d.handleSubmit, updateGuestsCount = _d.updateGuestsCount, setSelectedPath = _d.setSelectedPath;
|
|
10679
10704
|
// Default selected tab
|
|
10680
10705
|
React__default.useEffect(function () {
|
|
10681
10706
|
if (currentViewApply === 'roomFilters') {
|