willba-component-library 0.1.41 → 0.1.43

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.umd.js CHANGED
@@ -3923,7 +3923,7 @@
3923
3923
  };
3924
3924
 
3925
3925
  var useFilterBar = function (_a) {
3926
- var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply;
3926
+ var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
3927
3927
  var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
3928
3928
  var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
3929
3929
  var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
@@ -3945,6 +3945,7 @@
3945
3945
  setCategories(parsedCategories);
3946
3946
  }, []);
3947
3947
  React__default.useEffect(function () {
3948
+ // Handle hide scroll bar on mobile
3948
3949
  if (typeof window === 'undefined')
3949
3950
  return;
3950
3951
  document.body.style.overflow =
@@ -3954,15 +3955,15 @@
3954
3955
  };
3955
3956
  }, [selectedFilter]);
3956
3957
  React__default.useEffect(function () {
3957
- if (typeof window !== 'undefined') {
3958
- // Handle default selected tab
3959
- var currentPath = window.location.pathname.includes('/events')
3960
- ? '/events'
3961
- : window.location.pathname.includes('/rooms')
3962
- ? '/rooms'
3963
- : '/events';
3964
- setSelectedPath(currentPath);
3965
- }
3958
+ // Handle default selected tab
3959
+ if (typeof window === 'undefined')
3960
+ return;
3961
+ var currentPath = window.location.pathname.includes('/events')
3962
+ ? '/events'
3963
+ : window.location.pathname.includes('/rooms')
3964
+ ? '/rooms'
3965
+ : '/events';
3966
+ setSelectedPath(currentPath);
3966
3967
  }, []);
3967
3968
  var updateGuestsCount = function (id, newCount) {
3968
3969
  setAgeCategoryCounts(function (prevCounts) {
@@ -3981,9 +3982,10 @@
3981
3982
  : '',
3982
3983
  endDate: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) ? format(calendarRange.to, 'yyyy-MM-dd') : '',
3983
3984
  categories: categories,
3984
- ageCategoryCounts: Object.entries(ageCategoryCounts).length
3985
- ? JSON.stringify(ageCategoryCounts)
3986
- : '',
3985
+ ageCategoryCounts: handleAgeCategoryRules({
3986
+ ageCategoryCounts: ageCategoryCounts,
3987
+ ageCategories: ageCategories,
3988
+ }),
3987
3989
  };
3988
3990
  if (currentViewApply) {
3989
3991
  var currentSearchParams = new URLSearchParams(window.location.search);
@@ -4067,6 +4069,27 @@
4067
4069
  setSelectedPath: setSelectedPath,
4068
4070
  };
4069
4071
  };
4072
+ ////////////
4073
+ var handleAgeCategoryRules = function (_a) {
4074
+ var ageCategoryCounts = _a.ageCategoryCounts, ageCategories = _a.ageCategories;
4075
+ if (ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.length) {
4076
+ ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (a) {
4077
+ if (a.minVal) {
4078
+ // Age categories rules
4079
+ Object.entries(ageCategoryCounts).reduce(function (acc, c) {
4080
+ return acc + c[1];
4081
+ }, 0);
4082
+ var ageCategory = ageCategoryCounts["guests-".concat(a.id)];
4083
+ if (!ageCategory) {
4084
+ ageCategoryCounts["guests-".concat(a.id)] = a.minVal;
4085
+ }
4086
+ }
4087
+ });
4088
+ }
4089
+ return Object.entries(ageCategoryCounts).length
4090
+ ? JSON.stringify(ageCategoryCounts)
4091
+ : '';
4092
+ };
4070
4093
 
4071
4094
  var useScrollInToView = function (_a) {
4072
4095
  var selectedFilter = _a.selectedFilter;
@@ -6599,10 +6622,6 @@
6599
6622
 
6600
6623
  function GuestCount(_a) {
6601
6624
  var label = _a.label, sortOrder = _a.sortOrder, id = _a.id, updateGuestsCount = _a.updateGuestsCount, count = _a.count, minVal = _a.minVal;
6602
- React__default.useEffect(function () {
6603
- if (minVal)
6604
- updateGuestsCount("guests-".concat(id), minVal);
6605
- }, []);
6606
6625
  var handleDecrement = function () {
6607
6626
  if (count > minVal) {
6608
6627
  updateGuestsCount("guests-".concat(id), count - 1);
@@ -6614,8 +6633,8 @@
6614
6633
  return (React__default.createElement("div", { className: "will-guests-filter-inner", style: { order: "".concat(sortOrder) } },
6615
6634
  React__default.createElement("p", { className: "will-guests-filter-label" }, label),
6616
6635
  React__default.createElement("div", { className: "will-guests-filter-counter" },
6617
- React__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count < 2 ? true : false, style: {
6618
- cursor: minVal && count < 2
6636
+ React__default.createElement("button", { className: "will-guests-filter-counter-button", onClick: handleDecrement, disabled: minVal && count <= minVal ? true : false, style: {
6637
+ cursor: minVal && count <= minVal
6619
6638
  ? 'initial'
6620
6639
  : !minVal && count < 1
6621
6640
  ? 'initial'
@@ -6634,7 +6653,7 @@
6634
6653
  var t = useTranslation('filterBar').t;
6635
6654
  return (React__default.createElement("div", { className: "will-filter-bar-guests", ref: ref },
6636
6655
  React__default.createElement("h3", { className: "will-guests-filter-title" }, t('guests.title')),
6637
- React__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__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)] || category.minVal })); }))));
6656
+ React__default.createElement("div", { className: "will-guests-filter-container" }, ageCategories === null || ageCategories === void 0 ? void 0 : ageCategories.map(function (category) { return (React__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 })); }))));
6638
6657
  });
6639
6658
 
6640
6659
  /******************************************************************************
@@ -10627,7 +10646,9 @@
10627
10646
  }, []);
10628
10647
  return (React__default.createElement("div", { className: "will-filter-bar-calendar", ref: ref },
10629
10648
  React__default.createElement("div", { className: "will-calendar-filter-container" },
10630
- React__default.createElement(DayPicker, { id: "will-calendar", mode: "range", showOutsideDays: true, numberOfMonths: !isTablet ? 2 : 1, weekStartsOn: 1, selected: calendarRange, onSelect: setCalendarRange, modifiersClassNames: {
10649
+ React__default.createElement(DayPicker, { id: "will-calendar", mode: "range",
10650
+ //showOutsideDays
10651
+ numberOfMonths: !isTablet ? 2 : 1, weekStartsOn: 1, selected: calendarRange, onSelect: setCalendarRange, modifiersClassNames: {
10631
10652
  today: 'my-today',
10632
10653
  }, modifiersStyles: {
10633
10654
  disabled: { opacity: '0.2' },
@@ -10675,7 +10696,7 @@
10675
10696
  useUpdateTranslations({ language: language });
10676
10697
  var t = useTranslation('filterBar').t;
10677
10698
  // Filters
10678
- 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;
10699
+ 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;
10679
10700
  // Default selected tab
10680
10701
  React__default.useEffect(function () {
10681
10702
  if (currentViewApply === 'roomFilters') {