willba-component-library 0.1.46 → 0.1.48
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/FilterBar.d.ts +3 -2
- package/lib/components/FilterBar/FilterBarTypes.d.ts +16 -5
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +8 -1
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +7 -6
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +1 -1
- package/lib/components/FilterBar/index.d.ts +2 -1
- package/lib/index.d.ts +7 -3
- package/lib/index.esm.js +56 -32
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +56 -32
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +56 -32
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.stories.tsx +2 -1
- package/src/components/FilterBar/FilterBar.tsx +25 -20
- package/src/components/FilterBar/FilterBarTypes.ts +15 -3
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.css +11 -5
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +15 -9
- package/src/components/FilterBar/hooks/useFilterBar.tsx +24 -6
- package/src/components/FilterBar/hooks/useScrollInToView.tsx +2 -2
- package/src/components/FilterBar/index.ts +3 -1
package/lib/index.umd.js
CHANGED
|
@@ -451,6 +451,18 @@
|
|
|
451
451
|
});
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
+
function useTheme(_a) {
|
|
455
|
+
var palette = _a.palette;
|
|
456
|
+
var themePalette = {
|
|
457
|
+
'--will-primary': palette === null || palette === void 0 ? void 0 : palette.primary,
|
|
458
|
+
'--will-secondary': palette === null || palette === void 0 ? void 0 : palette.secondary,
|
|
459
|
+
};
|
|
460
|
+
return themePalette;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
var css_248z$b = "@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');\n\n.will-root * {\n font-family: 'Montserrat', sans-serif;\n}\n\n.will-root {\n \n box-sizing: border-box;\n font-size: 14px;\n \n color: #1E1E1E;\n\n /* Palette */\n --will-primary: #374269;\n --will-secondary: #374269;\n --will-grey: #ABA7AF;\n --will-white: #fff;\n --will-black: #000;\n --will-onahau: #CDEEFF;\n --will-text: #5A5959;\n --will-transparent-white: rgba(255, 255, 255, 0.30);\n\n /* Confines */\n --will-box-shadow: 0px 6px 11px 0px #a7a4a480;\n\n /* Breakpoints */\n\n --will-lg: 1140px;\n --will-md: 960px;\n --will-sm: 600px;\n --will-xl: 1280px;\n --will-xs: 0px;\n}\n\n/* Typography */\n\n.will-root h1, h2, h3, h4, h5, h6 {\n font-weight: 700;\n} \n\n.will-root p, h1, h2, h3, h4, h5, h6, span {\n margin: 0;\n padding: 0;\n}";
|
|
464
|
+
styleInject(css_248z$b);
|
|
465
|
+
|
|
454
466
|
function _typeof(o) {
|
|
455
467
|
"@babel/helpers - typeof";
|
|
456
468
|
|
|
@@ -3891,18 +3903,6 @@
|
|
|
3891
3903
|
return date;
|
|
3892
3904
|
}
|
|
3893
3905
|
|
|
3894
|
-
function useTheme(_a) {
|
|
3895
|
-
var palette = _a.palette;
|
|
3896
|
-
var themePalette = {
|
|
3897
|
-
'--will-primary': palette === null || palette === void 0 ? void 0 : palette.primary,
|
|
3898
|
-
'--will-secondary': palette === null || palette === void 0 ? void 0 : palette.secondary,
|
|
3899
|
-
};
|
|
3900
|
-
return themePalette;
|
|
3901
|
-
}
|
|
3902
|
-
|
|
3903
|
-
var css_248z$b = "@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');\n\n.will-root * {\n font-family: 'Montserrat', sans-serif;\n}\n\n.will-root {\n \n box-sizing: border-box;\n font-size: 14px;\n \n color: #1E1E1E;\n\n /* Palette */\n --will-primary: #374269;\n --will-secondary: #374269;\n --will-grey: #ABA7AF;\n --will-white: #fff;\n --will-black: #000;\n --will-onahau: #CDEEFF;\n --will-text: #5A5959;\n --will-transparent-white: rgba(255, 255, 255, 0.30);\n\n /* Confines */\n --will-box-shadow: 0px 6px 11px 0px #a7a4a480;\n\n /* Breakpoints */\n\n --will-lg: 1140px;\n --will-md: 960px;\n --will-sm: 600px;\n --will-xl: 1280px;\n --will-xs: 0px;\n}\n\n/* Typography */\n\n.will-root h1, h2, h3, h4, h5, h6 {\n font-weight: 700;\n} \n\n.will-root p, h1, h2, h3, h4, h5, h6, span {\n margin: 0;\n padding: 0;\n}";
|
|
3904
|
-
styleInject(css_248z$b);
|
|
3905
|
-
|
|
3906
3906
|
var parseDates = function (_a) {
|
|
3907
3907
|
var calendarRange = _a.calendarRange;
|
|
3908
3908
|
return (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) && (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.from)
|
|
@@ -3922,8 +3922,19 @@
|
|
|
3922
3922
|
}, '');
|
|
3923
3923
|
};
|
|
3924
3924
|
|
|
3925
|
+
var FilterSections;
|
|
3926
|
+
(function (FilterSections) {
|
|
3927
|
+
FilterSections["CALENDAR"] = "calendar";
|
|
3928
|
+
FilterSections["GUESTS"] = "guests";
|
|
3929
|
+
FilterSections["CATEGORIES"] = "categories";
|
|
3930
|
+
})(FilterSections || (FilterSections = {}));
|
|
3931
|
+
var ViewApply;
|
|
3932
|
+
(function (ViewApply) {
|
|
3933
|
+
ViewApply["ROOMS"] = "roomFilters";
|
|
3934
|
+
})(ViewApply || (ViewApply = {}));
|
|
3935
|
+
|
|
3925
3936
|
var useFilterBar = function (_a) {
|
|
3926
|
-
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
|
|
3937
|
+
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit;
|
|
3927
3938
|
var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
3928
3939
|
var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
|
|
3929
3940
|
var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
|
|
@@ -4024,6 +4035,14 @@
|
|
|
4024
4035
|
var baseUrl = window.location.origin + window.location.pathname;
|
|
4025
4036
|
var updatedUrl = "".concat(baseUrl, "?").concat(updatedParams.toString());
|
|
4026
4037
|
handleSelectedFilter(false);
|
|
4038
|
+
if (onSubmit) {
|
|
4039
|
+
var updatedParamsObject_1 = {};
|
|
4040
|
+
updatedParams.forEach(function (value, key) {
|
|
4041
|
+
updatedParamsObject_1[key] = value;
|
|
4042
|
+
});
|
|
4043
|
+
console.log('sdasdasdsad', updatedParamsObject_1);
|
|
4044
|
+
return onSubmit(updatedParamsObject_1);
|
|
4045
|
+
}
|
|
4027
4046
|
return (window.location.href = updatedUrl);
|
|
4028
4047
|
}
|
|
4029
4048
|
else {
|
|
@@ -4044,7 +4063,9 @@
|
|
|
4044
4063
|
finally { if (e_3) throw e_3.error; }
|
|
4045
4064
|
}
|
|
4046
4065
|
handleSelectedFilter(false);
|
|
4047
|
-
return
|
|
4066
|
+
return onSubmit
|
|
4067
|
+
? onSubmit(newParams)
|
|
4068
|
+
: (window.location.href = "".concat(redirectUrl, "/").concat(selectedPath).concat(querySearchParams ? "?".concat(querySearchParams.toString()) : ''));
|
|
4048
4069
|
}
|
|
4049
4070
|
};
|
|
4050
4071
|
var handleResetFilters = function () {
|
|
@@ -4093,7 +4114,7 @@
|
|
|
4093
4114
|
var _b = __read(React__default.useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
|
|
4094
4115
|
var targetFilterBarRef = React__default.useRef(null);
|
|
4095
4116
|
React__default.useEffect(function () {
|
|
4096
|
-
if (window !== undefined && window.innerWidth > 960) {
|
|
4117
|
+
if (typeof window !== 'undefined' && window.innerWidth > 960) {
|
|
4097
4118
|
setIsMobile(false);
|
|
4098
4119
|
return;
|
|
4099
4120
|
}
|
|
@@ -6577,16 +6598,16 @@
|
|
|
6577
6598
|
React__default.createElement(IoIosCloseCircleOutline, null)));
|
|
6578
6599
|
};
|
|
6579
6600
|
|
|
6580
|
-
var css_248z$9 = ".will-filter-bar-select-button {\n width: 100%;\n height: auto;\n background-color: transparent;\n border: none;\n padding: 0 20px;\n border-radius: 20px;\n cursor: pointer;\n font-size: 14px;\n text-align: initial;\n}\n\n
|
|
6601
|
+
var css_248z$9 = ".will-filter-bar-select-button {\n width: 100%;\n height: auto;\n background-color: transparent;\n border: none;\n padding: 0 20px;\n border-radius: 20px;\n cursor: pointer;\n font-size: 14px;\n text-align: initial;\n}\n\n.will-filter-bar-select-button .select-button-wrapper {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 10px;\n \n}\n\n.will-filter-bar-select-button .select-button-wrapper > div {\n display: grid\n}\n\n.will-filter-bar-select-button .select-button-label {\n font-weight: 500;\n}\n\n.will-filter-bar-select-button .select-button-description {\n font-weight: 400;\n opacity: 0.8;\n \n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .will-filter-bar-select-button .select-button-label.active,\n .will-filter-bar-select-button .select-button-description.active {\n font-weight: 600;\n }\n\n@media (max-width: 960px) {\n .will-filter-bar-select-button {\n padding: 15px 0;\n }\n\n .will-filter-bar-select-button:first-child {\n padding: 0 0 15px 0;\n }\n\n .will-filter-bar-select-button .select-button-wrapper {\n justify-content: center;\n text-align: center;\n }\n\n .will-filter-bar-select-button .select-button-description {\n white-space: wrap;\n }\n\n .will-filter-bar-select-button .select-button-divider {\n display: none\n }\n}\n\n\n";
|
|
6581
6602
|
styleInject(css_248z$9);
|
|
6582
6603
|
|
|
6583
6604
|
var SelectButton = function (_a) {
|
|
6584
|
-
var
|
|
6585
|
-
return (React__default.createElement("button", { className: "will-filter-bar-select-button", onClick: onClick
|
|
6605
|
+
var active = _a.active, label = _a.label, onClick = _a.onClick, description = _a.description;
|
|
6606
|
+
return (React__default.createElement("button", { className: "will-filter-bar-select-button", onClick: onClick },
|
|
6586
6607
|
React__default.createElement("span", { className: "select-button-wrapper" },
|
|
6587
6608
|
React__default.createElement("div", null,
|
|
6588
|
-
React__default.createElement("p", { className: "select-button-label" }, label),
|
|
6589
|
-
React__default.createElement("p", { className: "select-button-description" }, description)))));
|
|
6609
|
+
React__default.createElement("p", { className: "select-button-label ".concat(active ? 'active' : '') }, label),
|
|
6610
|
+
React__default.createElement("p", { className: "select-button-description ".concat(active ? 'active' : '') }, description)))));
|
|
6590
6611
|
};
|
|
6591
6612
|
|
|
6592
6613
|
// THIS FILE IS AUTO GENERATED
|
|
@@ -10688,16 +10709,21 @@
|
|
|
10688
10709
|
styleInject(css_248z);
|
|
10689
10710
|
|
|
10690
10711
|
function FilterBar(_a) {
|
|
10691
|
-
var language = _a.language, _b = _a.ageCategories, ageCategories = _b === void 0 ? AGE_CATEGORIES_FALLBACK : _b, _c = _a.redirectUrl, redirectUrl = _c === void 0 ? REDIRECT_URL_FALLBACK : _c, palette = _a.palette, currentViewApply = _a.currentViewApply;
|
|
10712
|
+
var language = _a.language, _b = _a.ageCategories, ageCategories = _b === void 0 ? AGE_CATEGORIES_FALLBACK : _b, _c = _a.redirectUrl, redirectUrl = _c === void 0 ? REDIRECT_URL_FALLBACK : _c, palette = _a.palette, currentViewApply = _a.currentViewApply, onSubmit = _a.onSubmit;
|
|
10692
10713
|
var themePalette = useTheme({ palette: palette });
|
|
10693
10714
|
// Translations
|
|
10694
10715
|
useUpdateTranslations({ language: language });
|
|
10695
10716
|
var t = useTranslation('filterBar').t;
|
|
10696
10717
|
// Filters
|
|
10697
|
-
var _d = useFilterBar({
|
|
10698
|
-
|
|
10718
|
+
var _d = useFilterBar({
|
|
10719
|
+
redirectUrl: redirectUrl,
|
|
10720
|
+
currentViewApply: currentViewApply,
|
|
10721
|
+
ageCategories: ageCategories,
|
|
10722
|
+
onSubmit: onSubmit,
|
|
10723
|
+
}), 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;
|
|
10724
|
+
// Default selected tab when tabs are hidden
|
|
10699
10725
|
React__default.useEffect(function () {
|
|
10700
|
-
if (currentViewApply ===
|
|
10726
|
+
if (currentViewApply === ViewApply.ROOMS) {
|
|
10701
10727
|
setSelectedPath('/rooms');
|
|
10702
10728
|
}
|
|
10703
10729
|
}, []);
|
|
@@ -10705,6 +10731,7 @@
|
|
|
10705
10731
|
var _e = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _e.isMobile, targetFilterBarRef = _e.targetFilterBarRef;
|
|
10706
10732
|
// Handle close filter section
|
|
10707
10733
|
var filtersRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filtersRef;
|
|
10734
|
+
// Parsed data for filter section description
|
|
10708
10735
|
var parsedDates = parseDates({ calendarRange: calendarRange });
|
|
10709
10736
|
var parsedGuests = parseGuests({ ageCategoryCounts: ageCategoryCounts, ageCategories: ageCategories });
|
|
10710
10737
|
return (React__default.createElement("div", { className: "will-root", style: themePalette },
|
|
@@ -10716,21 +10743,18 @@
|
|
|
10716
10743
|
? parsedDates
|
|
10717
10744
|
: selectedPath === '/rooms'
|
|
10718
10745
|
? t('calendar.roomsLabelPlaceholder')
|
|
10719
|
-
: t('calendar.eventsLabelPlaceholder'), onClick: function () { return handleSelectedFilter(
|
|
10746
|
+
: t('calendar.eventsLabelPlaceholder'), onClick: function () { return handleSelectedFilter(FilterSections.CALENDAR); }, active: selectedFilter === FilterSections.CALENDAR }),
|
|
10720
10747
|
selectedPath === '/rooms' && (React__default.createElement(React__default.Fragment, null,
|
|
10721
10748
|
React__default.createElement(Divider, null),
|
|
10722
|
-
React__default.createElement(SelectButton, { label: t('guests.label'), description: parsedGuests ? parsedGuests : t('guests.labelPlaceholder'), onClick: function () { return handleSelectedFilter(
|
|
10749
|
+
React__default.createElement(SelectButton, { label: t('guests.label'), description: parsedGuests ? parsedGuests : t('guests.labelPlaceholder'), onClick: function () { return handleSelectedFilter(FilterSections.GUESTS); }, active: selectedFilter === FilterSections.GUESTS }))),
|
|
10723
10750
|
React__default.createElement(SubmitButton, { onClick: handleSubmit })),
|
|
10724
10751
|
selectedFilter && (React__default.createElement("div", { className: "will-filter-bar-container", style: currentViewApply && !isMobile ? { top: 66 } : {} },
|
|
10725
10752
|
React__default.createElement(CloseButton, { handleClose: function () { return handleSelectedFilter(false); } }),
|
|
10726
|
-
selectedFilter ===
|
|
10727
|
-
selectedFilter ===
|
|
10728
|
-
selectedFilter ===
|
|
10753
|
+
selectedFilter === FilterSections.CALENDAR && (React__default.createElement(Calendar, { calendarRange: calendarRange, setCalendarRange: setCalendarRange, ref: filtersRef })),
|
|
10754
|
+
selectedFilter === FilterSections.GUESTS && (React__default.createElement(Guests, { updateGuestsCount: updateGuestsCount, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, ref: filtersRef })),
|
|
10755
|
+
selectedFilter === FilterSections.CATEGORIES && (React__default.createElement(Categories, { categories: categories, setCategories: setCategories }))))));
|
|
10729
10756
|
}
|
|
10730
10757
|
////////////
|
|
10731
|
-
var fontWeightBold = function (input) {
|
|
10732
|
-
return { fontWeight: input ? 'bold' : 'initial' };
|
|
10733
|
-
};
|
|
10734
10758
|
var AGE_CATEGORIES_FALLBACK = [
|
|
10735
10759
|
{
|
|
10736
10760
|
id: '1',
|