willba-component-library 0.1.47 → 0.1.49
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 +6 -0
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +4 -3
- package/lib/components/FilterBar/index.d.ts +2 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.esm.js +25 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +25 -6
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +25 -6
- 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 +15 -4
- package/src/components/FilterBar/FilterBarTypes.ts +6 -0
- package/src/components/FilterBar/hooks/useFilterBar.tsx +21 -5
- package/src/components/FilterBar/index.ts +3 -1
package/lib/index.umd.js
CHANGED
|
@@ -3928,9 +3928,13 @@
|
|
|
3928
3928
|
FilterSections["GUESTS"] = "guests";
|
|
3929
3929
|
FilterSections["CATEGORIES"] = "categories";
|
|
3930
3930
|
})(FilterSections || (FilterSections = {}));
|
|
3931
|
+
var ViewApply;
|
|
3932
|
+
(function (ViewApply) {
|
|
3933
|
+
ViewApply["ROOMS"] = "roomFilters";
|
|
3934
|
+
})(ViewApply || (ViewApply = {}));
|
|
3931
3935
|
|
|
3932
3936
|
var useFilterBar = function (_a) {
|
|
3933
|
-
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
|
|
3937
|
+
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit;
|
|
3934
3938
|
var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
3935
3939
|
var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
|
|
3936
3940
|
var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
|
|
@@ -3988,7 +3992,7 @@
|
|
|
3988
3992
|
? format(calendarRange.from, 'yyyy-MM-dd')
|
|
3989
3993
|
: '',
|
|
3990
3994
|
endDate: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) ? format(calendarRange.to, 'yyyy-MM-dd') : '',
|
|
3991
|
-
categories: categories,
|
|
3995
|
+
categories: categories.toString(),
|
|
3992
3996
|
ageCategoryCounts: handleAgeCategoryRules({
|
|
3993
3997
|
ageCategoryCounts: ageCategoryCounts,
|
|
3994
3998
|
ageCategories: ageCategories,
|
|
@@ -4031,6 +4035,14 @@
|
|
|
4031
4035
|
var baseUrl = window.location.origin + window.location.pathname;
|
|
4032
4036
|
var updatedUrl = "".concat(baseUrl, "?").concat(updatedParams.toString());
|
|
4033
4037
|
handleSelectedFilter(false);
|
|
4038
|
+
if (onSubmit) {
|
|
4039
|
+
var updatedParamsObject_1 = {};
|
|
4040
|
+
updatedParams.forEach(function (value, key) {
|
|
4041
|
+
if (value)
|
|
4042
|
+
updatedParamsObject_1[key] = value;
|
|
4043
|
+
});
|
|
4044
|
+
return onSubmit(updatedParamsObject_1);
|
|
4045
|
+
}
|
|
4034
4046
|
return (window.location.href = updatedUrl);
|
|
4035
4047
|
}
|
|
4036
4048
|
else {
|
|
@@ -4051,7 +4063,9 @@
|
|
|
4051
4063
|
finally { if (e_3) throw e_3.error; }
|
|
4052
4064
|
}
|
|
4053
4065
|
handleSelectedFilter(false);
|
|
4054
|
-
return
|
|
4066
|
+
return onSubmit
|
|
4067
|
+
? onSubmit(newParams)
|
|
4068
|
+
: (window.location.href = "".concat(redirectUrl, "/").concat(selectedPath).concat(querySearchParams ? "?".concat(querySearchParams.toString()) : ''));
|
|
4055
4069
|
}
|
|
4056
4070
|
};
|
|
4057
4071
|
var handleResetFilters = function () {
|
|
@@ -10695,16 +10709,21 @@
|
|
|
10695
10709
|
styleInject(css_248z);
|
|
10696
10710
|
|
|
10697
10711
|
function FilterBar(_a) {
|
|
10698
|
-
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;
|
|
10699
10713
|
var themePalette = useTheme({ palette: palette });
|
|
10700
10714
|
// Translations
|
|
10701
10715
|
useUpdateTranslations({ language: language });
|
|
10702
10716
|
var t = useTranslation('filterBar').t;
|
|
10703
10717
|
// Filters
|
|
10704
|
-
var _d = useFilterBar({
|
|
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;
|
|
10705
10724
|
// Default selected tab when tabs are hidden
|
|
10706
10725
|
React__default.useEffect(function () {
|
|
10707
|
-
if (currentViewApply ===
|
|
10726
|
+
if (currentViewApply === ViewApply.ROOMS) {
|
|
10708
10727
|
setSelectedPath('/rooms');
|
|
10709
10728
|
}
|
|
10710
10729
|
}, []);
|