willba-component-library 0.1.75 → 0.1.76

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/index.js CHANGED
@@ -3947,10 +3947,6 @@ var FilterSections;
3947
3947
  FilterSections["GUESTS"] = "guests";
3948
3948
  FilterSections["CATEGORIES"] = "categories";
3949
3949
  })(FilterSections || (FilterSections = {}));
3950
- var ViewApply;
3951
- (function (ViewApply) {
3952
- ViewApply["ROOMS"] = "roomFilters";
3953
- })(ViewApply || (ViewApply = {}));
3954
3950
  var Pages;
3955
3951
  (function (Pages) {
3956
3952
  Pages["ROOMS"] = "/rooms";
@@ -3958,7 +3954,7 @@ var Pages;
3958
3954
  })(Pages || (Pages = {}));
3959
3955
 
3960
3956
  var useFilterBar = function (_a) {
3961
- var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit, defaultTab = _a.defaultTab;
3957
+ var redirectUrl = _a.redirectUrl, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit, tabs = _a.tabs;
3962
3958
  var _b = __read(React__default.useState(Pages.EVENTS), 2), selectedPath = _b[0], setSelectedPath = _b[1];
3963
3959
  var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
3964
3960
  var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
@@ -3993,10 +3989,11 @@ var useFilterBar = function (_a) {
3993
3989
  // Handle default selected tab
3994
3990
  if (typeof window === 'undefined')
3995
3991
  return;
3996
- var currentPath = defaultTab === Pages.EVENTS ||
3992
+ var defaultTab = (tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1 ? tabs[0] : tabs === null || tabs === void 0 ? void 0 : tabs.find(function (tab) { return tab.default; });
3993
+ var currentPath = (defaultTab === null || defaultTab === void 0 ? void 0 : defaultTab.path) === Pages.EVENTS ||
3997
3994
  window.location.pathname.includes(Pages.EVENTS)
3998
3995
  ? Pages.EVENTS
3999
- : defaultTab === Pages.ROOMS ||
3996
+ : (defaultTab === null || defaultTab === void 0 ? void 0 : defaultTab.path) === Pages.ROOMS ||
4000
3997
  window.location.pathname.includes(Pages.ROOMS)
4001
3998
  ? Pages.ROOMS
4002
3999
  : Pages.EVENTS;
@@ -4024,7 +4021,7 @@ var useFilterBar = function (_a) {
4024
4021
  ageCategories: ageCategories,
4025
4022
  }),
4026
4023
  };
4027
- if (currentViewApply) {
4024
+ if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
4028
4025
  var currentSearchParams = new URLSearchParams(window.location.search);
4029
4026
  var updatedParams = new URLSearchParams();
4030
4027
  try {
@@ -11129,7 +11126,7 @@ var css_248z = ".will-root {\n z-index: 999;\n width: fit-content;\n min-widt
11129
11126
  styleInject(css_248z);
11130
11127
 
11131
11128
  function FilterBar(_a) {
11132
- 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, fullWidth = _a.fullWidth, calendarOffset = _a.calendarOffset, mode = _a.mode, defaultTab = _a.defaultTab;
11129
+ 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, onSubmit = _a.onSubmit, fullWidth = _a.fullWidth, calendarOffset = _a.calendarOffset, mode = _a.mode, tabs = _a.tabs;
11133
11130
  var themePalette = useTheme({ palette: palette });
11134
11131
  // Translations
11135
11132
  useUpdateTranslations({ language: language });
@@ -11137,17 +11134,10 @@ function FilterBar(_a) {
11137
11134
  // Filters
11138
11135
  var _d = useFilterBar({
11139
11136
  redirectUrl: redirectUrl,
11140
- currentViewApply: currentViewApply,
11141
11137
  ageCategories: ageCategories,
11142
11138
  onSubmit: onSubmit,
11143
- defaultTab: defaultTab,
11139
+ tabs: tabs,
11144
11140
  }), 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, handleResetFilters = _d.handleResetFilters;
11145
- // Default selected tab when tabs are hidden
11146
- React__default.useEffect(function () {
11147
- if (currentViewApply === ViewApply.ROOMS) {
11148
- setSelectedPath(Pages.ROOMS);
11149
- }
11150
- }, []);
11151
11141
  // Scroll in to view
11152
11142
  var _e = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _e.isMobile, targetFilterBarRef = _e.targetFilterBarRef;
11153
11143
  // Handle close filter section
@@ -11170,14 +11160,14 @@ function FilterBar(_a) {
11170
11160
  guestsLabel: t('guests.guestsLabel'),
11171
11161
  });
11172
11162
  return (React__default.createElement("div", { className: "will-root ".concat(fullWidth ? 'is-full-width' : ''), style: themePalette },
11173
- !currentViewApply && (React__default.createElement("div", { className: "will-filter-bar-tabs", ref: !currentViewApply ? targetFilterBarRef : null },
11174
- React__default.createElement(TabButton, { label: t('tabs.events'), onClick: function () {
11175
- setSelectedPath(Pages.EVENTS), handleResetFilters();
11176
- }, active: selectedPath === Pages.EVENTS, mode: mode }),
11177
- React__default.createElement(TabButton, { label: t('tabs.rooms'), onClick: function () {
11178
- setSelectedPath(Pages.ROOMS), handleResetFilters();
11179
- }, active: selectedPath === Pages.ROOMS, mode: mode }))),
11180
- React__default.createElement("div", { className: "will-filter-bar-header ".concat(mode || 'dark'), ref: currentViewApply ? targetFilterBarRef : null },
11163
+ tabs && tabs.length > 1 && (React__default.createElement("div", { className: "will-filter-bar-tabs", ref: targetFilterBarRef }, tabs
11164
+ .sort(function (a, b) { return a.order - b.order; })
11165
+ .map(function (tab, idx) { return (React__default.createElement(TabButton, { key: "tab-".concat(idx), label: tab.label && language
11166
+ ? tab.label[language]
11167
+ : t("tabs.".concat(tab.path.substring(1))), onClick: function () {
11168
+ setSelectedPath(tab.path), handleResetFilters();
11169
+ }, active: selectedPath === tab.path, mode: mode })); }))),
11170
+ React__default.createElement("div", { className: "will-filter-bar-header ".concat(mode || 'dark'), ref: (tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1 ? targetFilterBarRef : null },
11181
11171
  React__default.createElement(SelectButton, { label: t('calendar.label'), description: parsedDates
11182
11172
  ? parsedDates
11183
11173
  : selectedPath === Pages.ROOMS
@@ -11187,7 +11177,7 @@ function FilterBar(_a) {
11187
11177
  React__default.createElement(Divider, null),
11188
11178
  React__default.createElement(SelectButton, { label: t('guests.label'), description: parsedGuests.content, onClick: function () { return handleSelectedFilter(FilterSections.GUESTS); }, active: !!parsedGuests.data.total }))),
11189
11179
  React__default.createElement(SubmitButton, { onClick: handleSubmit })),
11190
- selectedFilter && (React__default.createElement("div", { className: "will-filter-bar-container ".concat(mode || 'dark'), style: currentViewApply && !isMobile ? { top: 66 } : {} },
11180
+ selectedFilter && (React__default.createElement("div", { className: "will-filter-bar-container ".concat(mode || 'dark'), style: tabs && tabs.length === 1 && !isMobile ? { top: 66 } : {} },
11191
11181
  React__default.createElement(CloseButton, { handleClose: function () { return handleSelectedFilter(false); } }),
11192
11182
  selectedFilter === FilterSections.CALENDAR && (React__default.createElement(Calendar, { calendarRange: calendarRange, setCalendarRange: setCalendarRange, ref: filtersRef, calendarOffset: calendarOffset, selectedPath: selectedPath, locale: language })),
11193
11183
  selectedFilter === FilterSections.GUESTS && (React__default.createElement(Guests, { updateGuestsCount: updateGuestsCount, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, ref: filtersRef })),