willba-component-library 0.1.47 → 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 +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 +24 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +24 -5
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +24 -5
- 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 +22 -4
- package/src/components/FilterBar/index.ts +3 -1
package/lib/index.js
CHANGED
|
@@ -3926,9 +3926,13 @@ var FilterSections;
|
|
|
3926
3926
|
FilterSections["GUESTS"] = "guests";
|
|
3927
3927
|
FilterSections["CATEGORIES"] = "categories";
|
|
3928
3928
|
})(FilterSections || (FilterSections = {}));
|
|
3929
|
+
var ViewApply;
|
|
3930
|
+
(function (ViewApply) {
|
|
3931
|
+
ViewApply["ROOMS"] = "roomFilters";
|
|
3932
|
+
})(ViewApply || (ViewApply = {}));
|
|
3929
3933
|
|
|
3930
3934
|
var useFilterBar = function (_a) {
|
|
3931
|
-
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
|
|
3935
|
+
var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit;
|
|
3932
3936
|
var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
3933
3937
|
var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
|
|
3934
3938
|
var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
|
|
@@ -4029,6 +4033,14 @@ var useFilterBar = function (_a) {
|
|
|
4029
4033
|
var baseUrl = window.location.origin + window.location.pathname;
|
|
4030
4034
|
var updatedUrl = "".concat(baseUrl, "?").concat(updatedParams.toString());
|
|
4031
4035
|
handleSelectedFilter(false);
|
|
4036
|
+
if (onSubmit) {
|
|
4037
|
+
var updatedParamsObject_1 = {};
|
|
4038
|
+
updatedParams.forEach(function (value, key) {
|
|
4039
|
+
updatedParamsObject_1[key] = value;
|
|
4040
|
+
});
|
|
4041
|
+
console.log('sdasdasdsad', updatedParamsObject_1);
|
|
4042
|
+
return onSubmit(updatedParamsObject_1);
|
|
4043
|
+
}
|
|
4032
4044
|
return (window.location.href = updatedUrl);
|
|
4033
4045
|
}
|
|
4034
4046
|
else {
|
|
@@ -4049,7 +4061,9 @@ var useFilterBar = function (_a) {
|
|
|
4049
4061
|
finally { if (e_3) throw e_3.error; }
|
|
4050
4062
|
}
|
|
4051
4063
|
handleSelectedFilter(false);
|
|
4052
|
-
return
|
|
4064
|
+
return onSubmit
|
|
4065
|
+
? onSubmit(newParams)
|
|
4066
|
+
: (window.location.href = "".concat(redirectUrl, "/").concat(selectedPath).concat(querySearchParams ? "?".concat(querySearchParams.toString()) : ''));
|
|
4053
4067
|
}
|
|
4054
4068
|
};
|
|
4055
4069
|
var handleResetFilters = function () {
|
|
@@ -10693,16 +10707,21 @@ var css_248z = ".will-root {\n z-index: 999;\n width: 100%;\n max-height: 100
|
|
|
10693
10707
|
styleInject(css_248z);
|
|
10694
10708
|
|
|
10695
10709
|
function FilterBar(_a) {
|
|
10696
|
-
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;
|
|
10710
|
+
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;
|
|
10697
10711
|
var themePalette = useTheme({ palette: palette });
|
|
10698
10712
|
// Translations
|
|
10699
10713
|
useUpdateTranslations({ language: language });
|
|
10700
10714
|
var t = useTranslation('filterBar').t;
|
|
10701
10715
|
// Filters
|
|
10702
|
-
var _d = useFilterBar({
|
|
10716
|
+
var _d = useFilterBar({
|
|
10717
|
+
redirectUrl: redirectUrl,
|
|
10718
|
+
currentViewApply: currentViewApply,
|
|
10719
|
+
ageCategories: ageCategories,
|
|
10720
|
+
onSubmit: onSubmit,
|
|
10721
|
+
}), 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
10722
|
// Default selected tab when tabs are hidden
|
|
10704
10723
|
React__default.useEffect(function () {
|
|
10705
|
-
if (currentViewApply ===
|
|
10724
|
+
if (currentViewApply === ViewApply.ROOMS) {
|
|
10706
10725
|
setSelectedPath('/rooms');
|
|
10707
10726
|
}
|
|
10708
10727
|
}, []);
|