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/index.js CHANGED
@@ -449,6 +449,18 @@ function useTranslation(ns) {
449
449
  });
450
450
  }
451
451
 
452
+ function useTheme(_a) {
453
+ var palette = _a.palette;
454
+ var themePalette = {
455
+ '--will-primary': palette === null || palette === void 0 ? void 0 : palette.primary,
456
+ '--will-secondary': palette === null || palette === void 0 ? void 0 : palette.secondary,
457
+ };
458
+ return themePalette;
459
+ }
460
+
461
+ 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}";
462
+ styleInject(css_248z$b);
463
+
452
464
  function _typeof(o) {
453
465
  "@babel/helpers - typeof";
454
466
 
@@ -3889,18 +3901,6 @@ function setYear(dirtyDate, dirtyYear) {
3889
3901
  return date;
3890
3902
  }
3891
3903
 
3892
- function useTheme(_a) {
3893
- var palette = _a.palette;
3894
- var themePalette = {
3895
- '--will-primary': palette === null || palette === void 0 ? void 0 : palette.primary,
3896
- '--will-secondary': palette === null || palette === void 0 ? void 0 : palette.secondary,
3897
- };
3898
- return themePalette;
3899
- }
3900
-
3901
- 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}";
3902
- styleInject(css_248z$b);
3903
-
3904
3904
  var parseDates = function (_a) {
3905
3905
  var calendarRange = _a.calendarRange;
3906
3906
  return (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) && (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.from)
@@ -3920,8 +3920,19 @@ var parseGuests = function (_a) {
3920
3920
  }, '');
3921
3921
  };
3922
3922
 
3923
+ var FilterSections;
3924
+ (function (FilterSections) {
3925
+ FilterSections["CALENDAR"] = "calendar";
3926
+ FilterSections["GUESTS"] = "guests";
3927
+ FilterSections["CATEGORIES"] = "categories";
3928
+ })(FilterSections || (FilterSections = {}));
3929
+ var ViewApply;
3930
+ (function (ViewApply) {
3931
+ ViewApply["ROOMS"] = "roomFilters";
3932
+ })(ViewApply || (ViewApply = {}));
3933
+
3923
3934
  var useFilterBar = function (_a) {
3924
- var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories;
3935
+ var redirectUrl = _a.redirectUrl, currentViewApply = _a.currentViewApply, ageCategories = _a.ageCategories, onSubmit = _a.onSubmit;
3925
3936
  var _b = __read(React__default.useState('/events'), 2), selectedPath = _b[0], setSelectedPath = _b[1];
3926
3937
  var _c = __read(React__default.useState(false), 2), selectedFilter = _c[0], setSelectedFilter = _c[1];
3927
3938
  var _d = __read(React__default.useState(), 2), calendarRange = _d[0], setCalendarRange = _d[1];
@@ -4022,6 +4033,14 @@ var useFilterBar = function (_a) {
4022
4033
  var baseUrl = window.location.origin + window.location.pathname;
4023
4034
  var updatedUrl = "".concat(baseUrl, "?").concat(updatedParams.toString());
4024
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
+ }
4025
4044
  return (window.location.href = updatedUrl);
4026
4045
  }
4027
4046
  else {
@@ -4042,7 +4061,9 @@ var useFilterBar = function (_a) {
4042
4061
  finally { if (e_3) throw e_3.error; }
4043
4062
  }
4044
4063
  handleSelectedFilter(false);
4045
- return (window.location.href = "".concat(redirectUrl, "/").concat(selectedPath).concat(querySearchParams ? "?".concat(querySearchParams.toString()) : ''));
4064
+ return onSubmit
4065
+ ? onSubmit(newParams)
4066
+ : (window.location.href = "".concat(redirectUrl, "/").concat(selectedPath).concat(querySearchParams ? "?".concat(querySearchParams.toString()) : ''));
4046
4067
  }
4047
4068
  };
4048
4069
  var handleResetFilters = function () {
@@ -4091,7 +4112,7 @@ var useScrollInToView = function (_a) {
4091
4112
  var _b = __read(React__default.useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
4092
4113
  var targetFilterBarRef = React__default.useRef(null);
4093
4114
  React__default.useEffect(function () {
4094
- if (window !== undefined && window.innerWidth > 960) {
4115
+ if (typeof window !== 'undefined' && window.innerWidth > 960) {
4095
4116
  setIsMobile(false);
4096
4117
  return;
4097
4118
  }
@@ -6575,16 +6596,16 @@ var CloseButton = function (_a) {
6575
6596
  React__default.createElement(IoIosCloseCircleOutline, null)));
6576
6597
  };
6577
6598
 
6578
- 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\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-description {\n font-weight: 400;\n opacity: 0.4;\n \n \n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\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";
6599
+ 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";
6579
6600
  styleInject(css_248z$9);
6580
6601
 
6581
6602
  var SelectButton = function (_a) {
6582
- var label = _a.label, onClick = _a.onClick, style = _a.style, description = _a.description;
6583
- return (React__default.createElement("button", { className: "will-filter-bar-select-button", onClick: onClick, style: style },
6603
+ var active = _a.active, label = _a.label, onClick = _a.onClick, description = _a.description;
6604
+ return (React__default.createElement("button", { className: "will-filter-bar-select-button", onClick: onClick },
6584
6605
  React__default.createElement("span", { className: "select-button-wrapper" },
6585
6606
  React__default.createElement("div", null,
6586
- React__default.createElement("p", { className: "select-button-label" }, label),
6587
- React__default.createElement("p", { className: "select-button-description" }, description)))));
6607
+ React__default.createElement("p", { className: "select-button-label ".concat(active ? 'active' : '') }, label),
6608
+ React__default.createElement("p", { className: "select-button-description ".concat(active ? 'active' : '') }, description)))));
6588
6609
  };
6589
6610
 
6590
6611
  // THIS FILE IS AUTO GENERATED
@@ -10686,16 +10707,21 @@ var css_248z = ".will-root {\n z-index: 999;\n width: 100%;\n max-height: 100
10686
10707
  styleInject(css_248z);
10687
10708
 
10688
10709
  function FilterBar(_a) {
10689
- 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;
10690
10711
  var themePalette = useTheme({ palette: palette });
10691
10712
  // Translations
10692
10713
  useUpdateTranslations({ language: language });
10693
10714
  var t = useTranslation('filterBar').t;
10694
10715
  // Filters
10695
- 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;
10696
- // Default selected tab
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;
10722
+ // Default selected tab when tabs are hidden
10697
10723
  React__default.useEffect(function () {
10698
- if (currentViewApply === 'roomFilters') {
10724
+ if (currentViewApply === ViewApply.ROOMS) {
10699
10725
  setSelectedPath('/rooms');
10700
10726
  }
10701
10727
  }, []);
@@ -10703,6 +10729,7 @@ function FilterBar(_a) {
10703
10729
  var _e = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _e.isMobile, targetFilterBarRef = _e.targetFilterBarRef;
10704
10730
  // Handle close filter section
10705
10731
  var filtersRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filtersRef;
10732
+ // Parsed data for filter section description
10706
10733
  var parsedDates = parseDates({ calendarRange: calendarRange });
10707
10734
  var parsedGuests = parseGuests({ ageCategoryCounts: ageCategoryCounts, ageCategories: ageCategories });
10708
10735
  return (React__default.createElement("div", { className: "will-root", style: themePalette },
@@ -10714,21 +10741,18 @@ function FilterBar(_a) {
10714
10741
  ? parsedDates
10715
10742
  : selectedPath === '/rooms'
10716
10743
  ? t('calendar.roomsLabelPlaceholder')
10717
- : t('calendar.eventsLabelPlaceholder'), onClick: function () { return handleSelectedFilter(1); }, style: fontWeightBold(selectedFilter === 1), date: (calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.to) ? format(calendarRange.to, 'dd.MM.yyyy') : null }),
10744
+ : t('calendar.eventsLabelPlaceholder'), onClick: function () { return handleSelectedFilter(FilterSections.CALENDAR); }, active: selectedFilter === FilterSections.CALENDAR }),
10718
10745
  selectedPath === '/rooms' && (React__default.createElement(React__default.Fragment, null,
10719
10746
  React__default.createElement(Divider, null),
10720
- React__default.createElement(SelectButton, { label: t('guests.label'), description: parsedGuests ? parsedGuests : t('guests.labelPlaceholder'), onClick: function () { return handleSelectedFilter(2); }, style: fontWeightBold(selectedFilter === 2) }))),
10747
+ React__default.createElement(SelectButton, { label: t('guests.label'), description: parsedGuests ? parsedGuests : t('guests.labelPlaceholder'), onClick: function () { return handleSelectedFilter(FilterSections.GUESTS); }, active: selectedFilter === FilterSections.GUESTS }))),
10721
10748
  React__default.createElement(SubmitButton, { onClick: handleSubmit })),
10722
10749
  selectedFilter && (React__default.createElement("div", { className: "will-filter-bar-container", style: currentViewApply && !isMobile ? { top: 66 } : {} },
10723
10750
  React__default.createElement(CloseButton, { handleClose: function () { return handleSelectedFilter(false); } }),
10724
- selectedFilter === 1 && (React__default.createElement(Calendar, { calendarRange: calendarRange, setCalendarRange: setCalendarRange, ref: filtersRef })),
10725
- selectedFilter === 2 && (React__default.createElement(Guests, { updateGuestsCount: updateGuestsCount, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, ref: filtersRef })),
10726
- selectedFilter === 3 && (React__default.createElement(Categories, { categories: categories, setCategories: setCategories }))))));
10751
+ selectedFilter === FilterSections.CALENDAR && (React__default.createElement(Calendar, { calendarRange: calendarRange, setCalendarRange: setCalendarRange, ref: filtersRef })),
10752
+ selectedFilter === FilterSections.GUESTS && (React__default.createElement(Guests, { updateGuestsCount: updateGuestsCount, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, ref: filtersRef })),
10753
+ selectedFilter === FilterSections.CATEGORIES && (React__default.createElement(Categories, { categories: categories, setCategories: setCategories }))))));
10727
10754
  }
10728
10755
  ////////////
10729
- var fontWeightBold = function (input) {
10730
- return { fontWeight: input ? 'bold' : 'initial' };
10731
- };
10732
10756
  var AGE_CATEGORIES_FALLBACK = [
10733
10757
  {
10734
10758
  id: '1',