willba-component-library 0.1.40 → 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 +48 -23
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +48 -23
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +48 -23
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.css +1 -3
- 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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DateRange } from 'react-day-picker';
|
|
3
|
-
import { AgeCategoryCount } from '../FilterBarTypes';
|
|
3
|
+
import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes';
|
|
4
4
|
type Props = {
|
|
5
5
|
redirectUrl?: string;
|
|
6
6
|
currentViewApply?: string;
|
|
7
|
+
ageCategories?: AgeCategoryType[];
|
|
7
8
|
};
|
|
8
|
-
export declare const useFilterBar: ({ redirectUrl, currentViewApply }: Props) => {
|
|
9
|
+
export declare const useFilterBar: ({ redirectUrl, currentViewApply, ageCategories, }: Props) => {
|
|
9
10
|
selectedFilter: number | boolean;
|
|
10
11
|
ageCategoryCounts: AgeCategoryCount;
|
|
11
12
|
categories: number;
|
package/lib/index.esm.js
CHANGED
|
@@ -3901,7 +3901,7 @@ var parseGuests = function (_a) {
|
|
|
3901
3901
|
};
|
|
3902
3902
|
|
|
3903
3903
|
var useFilterBar = function (_a) {
|
|
3904
|
-
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply;
|
|
3904
|
+
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
|
|
3905
3905
|
var _b = __read(useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
3906
3906
|
var _c = __read(useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
|
|
3907
3907
|
var _d = __read(useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
|
|
@@ -3923,6 +3923,7 @@ var useFilterBar = function (_a) {
|
|
|
3923
3923
|
setCategories(parsedCategories);
|
|
3924
3924
|
}, []);
|
|
3925
3925
|
useEffect(function () {
|
|
3926
|
+
// Handle hide scroll bar on mobile
|
|
3926
3927
|
if (typeof window === 'undefined')
|
|
3927
3928
|
return;
|
|
3928
3929
|
document.body.style.overflow =
|
|
@@ -3932,15 +3933,15 @@ var useFilterBar = function (_a) {
|
|
|
3932
3933
|
};
|
|
3933
3934
|
}, [selectedFilter]);
|
|
3934
3935
|
useEffect(function () {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3936
|
+
// Handle default selected tab
|
|
3937
|
+
if (typeof window === 'undefined')
|
|
3938
|
+
return;
|
|
3939
|
+
var currentPath = window.location.pathname.includes('/events')
|
|
3940
|
+
? '/events'
|
|
3941
|
+
: window.location.pathname.includes('/rooms')
|
|
3942
|
+
? '/rooms'
|
|
3943
|
+
: '/events';
|
|
3944
|
+
setSelectedPath(currentPath);
|
|
3944
3945
|
}, []);
|
|
3945
3946
|
var updateGuestsCount = function (id, newCount) {
|
|
3946
3947
|
setAgeCategoryCounts(function (prevCounts) {
|
|
@@ -3959,9 +3960,10 @@ var useFilterBar = function (_a) {
|
|
|
3959
3960
|
: '',
|
|
3960
3961
|
endDate: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) ? format(calendarRange.to, 'yyyy-MM-dd') : '',
|
|
3961
3962
|
categories: categories,
|
|
3962
|
-
ageCategoryCounts:
|
|
3963
|
-
|
|
3964
|
-
:
|
|
3963
|
+
ageCategoryCounts: handleAgeCategoryRules({
|
|
3964
|
+
ageCategoryCounts: ageCategoryCounts,
|
|
3965
|
+
ageCategories: ageCategories,
|
|
3966
|
+
}),
|
|
3965
3967
|
};
|
|
3966
3968
|
if (currentViewApply) {
|
|
3967
3969
|
var currentSearchParams = new URLSearchParams(window.location.search);
|
|
@@ -4045,6 +4047,31 @@ var useFilterBar = function (_a) {
|
|
|
4045
4047
|
setSelectedPath: setSelectedPath,
|
|
4046
4048
|
};
|
|
4047
4049
|
};
|
|
4050
|
+
////////////
|
|
4051
|
+
var handleAgeCategoryRules = function (_a) {
|
|
4052
|
+
var ageCategoryCounts = _a.ageCategoryCounts, ageCategories = _a.ageCategories;
|
|
4053
|
+
if (ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.length) {
|
|
4054
|
+
ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (a) {
|
|
4055
|
+
if (a.minVal) {
|
|
4056
|
+
// Age categories rules
|
|
4057
|
+
var totalAgeCategories = Object.entries(ageCategoryCounts).reduce(function (acc, c) {
|
|
4058
|
+
return acc + c[1];
|
|
4059
|
+
}, 0);
|
|
4060
|
+
var ageCategory = ageCategoryCounts["guests-".concat(a.id)];
|
|
4061
|
+
if (!totalAgeCategories ||
|
|
4062
|
+
(totalAgeCategories === 1 && ageCategory === 1)) {
|
|
4063
|
+
ageCategoryCounts["guests-".concat(a.id)] = 2;
|
|
4064
|
+
}
|
|
4065
|
+
else if (totalAgeCategories > 1 && !ageCategory) {
|
|
4066
|
+
ageCategoryCounts["guests-".concat(a.id)] = a.minVal;
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
});
|
|
4070
|
+
}
|
|
4071
|
+
return Object.entries(ageCategoryCounts).length
|
|
4072
|
+
? JSON.stringify(ageCategoryCounts)
|
|
4073
|
+
: '';
|
|
4074
|
+
};
|
|
4048
4075
|
|
|
4049
4076
|
var useScrollInToView = function (_a) {
|
|
4050
4077
|
var selectedFilter = _a.selectedFilter;
|
|
@@ -6577,10 +6604,6 @@ styleInject(css_248z$6);
|
|
|
6577
6604
|
|
|
6578
6605
|
function GuestCount(_a) {
|
|
6579
6606
|
var label = _a.label, sortOrder = _a.sortOrder, id = _a.id, updateGuestsCount = _a.updateGuestsCount, count = _a.count, minVal = _a.minVal;
|
|
6580
|
-
useEffect(function () {
|
|
6581
|
-
if (minVal)
|
|
6582
|
-
updateGuestsCount("guests-".concat(id), minVal);
|
|
6583
|
-
}, []);
|
|
6584
6607
|
var handleDecrement = function () {
|
|
6585
6608
|
if (count > minVal) {
|
|
6586
6609
|
updateGuestsCount("guests-".concat(id), count - 1);
|
|
@@ -6592,8 +6615,8 @@ function GuestCount(_a) {
|
|
|
6592
6615
|
return (React__default__default.createElement("div", { className: "will-guests-filter-inner", style: { order: "".concat(sortOrder) } },
|
|
6593
6616
|
React__default__default.createElement("p", { className: "will-guests-filter-label" }, label),
|
|
6594
6617
|
React__default__default.createElement("div", { className: "will-guests-filter-counter" },
|
|
6595
|
-
React__default__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count
|
|
6596
|
-
cursor: minVal && count
|
|
6618
|
+
React__default__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count <= minVal ? true : false, style: {
|
|
6619
|
+
cursor: minVal && count <= minVal
|
|
6597
6620
|
? 'initial'
|
|
6598
6621
|
: !minVal && count < 1
|
|
6599
6622
|
? 'initial'
|
|
@@ -6612,7 +6635,7 @@ var Guests = forwardRef(function (_a, ref) {
|
|
|
6612
6635
|
var t = useTranslation('filterBar').t;
|
|
6613
6636
|
return (React__default__default.createElement("div", { className: "will-filter-bar-guests", ref: ref },
|
|
6614
6637
|
React__default__default.createElement("h3", { className: "will-guests-filter-title" }, t('guests.title')),
|
|
6615
|
-
React__default__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__default__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)] ||
|
|
6638
|
+
React__default__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__default__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 })); }))));
|
|
6616
6639
|
});
|
|
6617
6640
|
|
|
6618
6641
|
/******************************************************************************
|
|
@@ -10605,7 +10628,9 @@ var Calendar = forwardRef(function (_a, ref) {
|
|
|
10605
10628
|
}, []);
|
|
10606
10629
|
return (React__default__default.createElement("div", { className: "will-filter-bar-calendar", ref: ref },
|
|
10607
10630
|
React__default__default.createElement("div", { className: "will-calendar-filter-container" },
|
|
10608
|
-
React__default__default.createElement(DayPicker, { id: "will-calendar", mode: "range",
|
|
10631
|
+
React__default__default.createElement(DayPicker, { id: "will-calendar", mode: "range",
|
|
10632
|
+
//showOutsideDays
|
|
10633
|
+
numberOfMonths: !isTablet ? 2 : 1, weekStartsOn: 1, selected: calendarRange, onSelect: setCalendarRange, modifiersClassNames: {
|
|
10609
10634
|
today: 'my-today',
|
|
10610
10635
|
}, modifiersStyles: {
|
|
10611
10636
|
disabled: { opacity: '0.2' },
|
|
@@ -10643,7 +10668,7 @@ var Categories = function (_a) {
|
|
|
10643
10668
|
React__default__default.createElement("span", null, itm))); }))));
|
|
10644
10669
|
};
|
|
10645
10670
|
|
|
10646
|
-
var css_248z = ".will-root {\n z-index: 999;\n width: 100%;\n max-height: 100vh;\n position: relative;\n}\n\n.will-filter-bar {\n box-sizing: border-box;\n position: relative;\n}\n\n/* Tabs */\n\n.will-filter-bar-tabs {\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n z-index: 222;\n background: transparent;\n padding: 10px;\n gap: 10px\n}\n\n/* Header */\n.will-filter-bar-header {\n display: flex;\n justify-content: space-between;\n padding: 10px;\n position: relative;\n z-index: 222;\n border-radius: 40px;\n background-color: var(--will-white);\n box-shadow: 0px 3px 10px 0px lightgrey; \n}\n\n@media (max-width: 960px) {\n .will-filter-bar-header {\n flex-direction: column;\n padding: 20px;\n border-radius: 25px;\n }\n}\n\n/* Container */\n\n.will-filter-bar-container {\n background-color: var(--will-white);\n min-height: 100px;\n padding: 40px 20px ;\n position: absolute;\n top: 125px;\n z-index: 111;\n border-radius: 25px;\n box-shadow: var(--will-box-shadow);\n}\n\n@media (max-width: 960px) {\n .will-root { \n
|
|
10671
|
+
var css_248z = ".will-root {\n z-index: 999;\n width: 100%;\n max-height: 100vh;\n position: relative;\n}\n\n.will-filter-bar {\n box-sizing: border-box;\n position: relative;\n}\n\n/* Tabs */\n\n.will-filter-bar-tabs {\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n z-index: 222;\n background: transparent;\n padding: 10px;\n gap: 10px\n}\n\n/* Header */\n.will-filter-bar-header {\n display: flex;\n justify-content: space-between;\n padding: 10px;\n position: relative;\n z-index: 222;\n border-radius: 40px;\n background-color: var(--will-white);\n box-shadow: 0px 3px 10px 0px lightgrey; \n}\n\n@media (max-width: 960px) {\n .will-filter-bar-header {\n flex-direction: column;\n padding: 20px;\n border-radius: 25px;\n }\n}\n\n/* Container */\n\n.will-filter-bar-container {\n background-color: var(--will-white);\n min-height: 100px;\n padding: 40px 20px ;\n position: absolute;\n top: 125px;\n z-index: 111;\n border-radius: 25px;\n box-shadow: var(--will-box-shadow);\n}\n\n@media (max-width: 960px) {\n .will-root { \n z-index: 3;\n }\n\n .will-filter-bar-container {\n margin-top: 10px;\n top:0;\n padding: 30px 20px;\n position: relative;\n }\n}\n\n";
|
|
10647
10672
|
styleInject(css_248z);
|
|
10648
10673
|
|
|
10649
10674
|
function FilterBar(_a) {
|
|
@@ -10653,7 +10678,7 @@ function FilterBar(_a) {
|
|
|
10653
10678
|
useUpdateTranslations({ language: language });
|
|
10654
10679
|
var t = useTranslation('filterBar').t;
|
|
10655
10680
|
// Filters
|
|
10656
|
-
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;
|
|
10681
|
+
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;
|
|
10657
10682
|
// Default selected tab
|
|
10658
10683
|
useEffect(function () {
|
|
10659
10684
|
if (currentViewApply === 'roomFilters') {
|