willba-component-library 0.3.18 → 0.3.20

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
@@ -2901,11 +2901,11 @@
2901
2901
  // TODO - Refactor and rename this hook
2902
2902
  var useCloseFilterSection = function (_a) {
2903
2903
  var handleSelectedFilter = _a.handleSelectedFilter;
2904
- var filtersRef = React.useRef(null);
2904
+ var filterSectionRef = React.useRef(null);
2905
2905
  React.useEffect(function () {
2906
2906
  var handleClickOutside = function (event) {
2907
- if (filtersRef.current &&
2908
- !filtersRef.current.contains(event.target)) {
2907
+ if (filterSectionRef.current &&
2908
+ !filterSectionRef.current.contains(event.target)) {
2909
2909
  handleSelectedFilter(false);
2910
2910
  }
2911
2911
  };
@@ -2913,8 +2913,8 @@
2913
2913
  return function () {
2914
2914
  document.removeEventListener('mousedown', handleClickOutside);
2915
2915
  };
2916
- }, [filtersRef]);
2917
- return { filtersRef: filtersRef };
2916
+ }, [filterSectionRef]);
2917
+ return { filterSectionRef: filterSectionRef };
2918
2918
  };
2919
2919
 
2920
2920
  var useAutoFocus = function (autoFocus) {
@@ -2984,22 +2984,22 @@
2984
2984
  var useScrollInToView = function (_a) {
2985
2985
  var selectedFilter = _a.selectedFilter;
2986
2986
  var _b = __read(React.useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
2987
- var targetFilterBarRef = React.useRef(null);
2987
+ var tabsRef = React.useRef(null);
2988
2988
  React.useEffect(function () {
2989
2989
  if (typeof window !== 'undefined' && window.innerWidth > 960) {
2990
2990
  setIsMobile(false);
2991
2991
  return;
2992
2992
  }
2993
- if (targetFilterBarRef.current && selectedFilter) {
2993
+ if (tabsRef.current && selectedFilter) {
2994
2994
  window.scrollTo({
2995
2995
  behavior: 'smooth',
2996
- top: targetFilterBarRef.current.getBoundingClientRect().top -
2996
+ top: tabsRef.current.getBoundingClientRect().top -
2997
2997
  document.body.getBoundingClientRect().top -
2998
2998
  30,
2999
2999
  });
3000
3000
  }
3001
3001
  }, [selectedFilter]);
3002
- return { isMobile: isMobile, targetFilterBarRef: targetFilterBarRef };
3002
+ return { isMobile: isMobile, tabsRef: tabsRef };
3003
3003
  };
3004
3004
 
3005
3005
  var useFilterState = function (_a) {
@@ -6837,18 +6837,20 @@
6837
6837
  var buttonRefs = React.useRef({});
6838
6838
  var panelRef = React.useRef(null);
6839
6839
  var previouslyFocusedButtonRef = React.useRef(null);
6840
- var _a = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _a.isMobile, targetFilterBarRef = _a.targetFilterBarRef;
6840
+ var filtersRef = React.useRef(null);
6841
+ var _a = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _a.isMobile, tabsRef = _a.tabsRef;
6841
6842
  return {
6842
6843
  previouslyFocusedButtonRef: previouslyFocusedButtonRef,
6843
6844
  isMobile: isMobile,
6844
- targetFilterBarRef: targetFilterBarRef,
6845
+ tabsRef: tabsRef,
6845
6846
  panelRef: panelRef,
6846
6847
  buttonRefs: buttonRefs,
6848
+ filtersRef: filtersRef,
6847
6849
  };
6848
6850
  };
6849
6851
 
6850
6852
  var usePanelPosition = function (_a) {
6851
- var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, targetFilterBarRef = _a.targetFilterBarRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile;
6853
+ var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile;
6852
6854
  var _b = __read(React.useState({}), 2), localStyles = _b[0], setLocalStyles = _b[1];
6853
6855
  React.useLayoutEffect(function () {
6854
6856
  if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
@@ -6856,7 +6858,7 @@
6856
6858
  return;
6857
6859
  }
6858
6860
  var panel = panelRef.current;
6859
- var container = targetFilterBarRef.current;
6861
+ var container = filtersRef.current;
6860
6862
  var button = buttonRefs.current[selectedFilter];
6861
6863
  if (!panel || !container || !button)
6862
6864
  return;
@@ -6881,6 +6883,7 @@
6881
6883
  selectedLocations: selectedLocations,
6882
6884
  selectedPath: selectedPath,
6883
6885
  redirectUrl: redirectUrl,
6886
+ calendarRange: calendarRange,
6884
6887
  setSelectedPath: setSelectedPath,
6885
6888
  setAgeCategoryCounts: setAgeCategoryCounts,
6886
6889
  setSelectedFilter: setSelectedFilter,
@@ -6909,7 +6912,8 @@
6909
6912
  outerLoading,
6910
6913
  locations,
6911
6914
  filterUi.isMobile,
6912
- filterUi.targetFilterBarRef,
6915
+ filterUi.tabsRef,
6916
+ filterUi.filtersRef,
6913
6917
  ]);
6914
6918
  return (React.createElement(FilterBarContext.Provider, { value: contextValue }, children));
6915
6919
  };
@@ -12165,33 +12169,31 @@
12165
12169
  styleInject(css_248z$5);
12166
12170
 
12167
12171
  var FilterPanels = function () {
12168
- var _a = useFilterBar(), categories = _a.categories, calendarRange = _a.calendarRange, selectedFilter = _a.selectedFilter, selectedPath = _a.selectedPath, ageCategoryCounts = _a.ageCategoryCounts, selectedLocations = _a.selectedLocations, mode = _a.mode, tabs = _a.tabs, disableCalendarDates = _a.disableCalendarDates, ageCategories = _a.ageCategories, locations = _a.locations, language = _a.language, isMobile = _a.isMobile, panelRef = _a.panelRef, buttonRefs = _a.buttonRefs, targetFilterBarRef = _a.targetFilterBarRef, setSelectedLocations = _a.setSelectedLocations, setCalendarRange = _a.setCalendarRange, handleSelectedFilter = _a.handleSelectedFilter, updateGuestsCount = _a.updateGuestsCount, setCategories = _a.setCategories;
12172
+ var _a = useFilterBar(), categories = _a.categories, calendarRange = _a.calendarRange, selectedFilter = _a.selectedFilter, selectedPath = _a.selectedPath, ageCategoryCounts = _a.ageCategoryCounts, selectedLocations = _a.selectedLocations, mode = _a.mode, tabs = _a.tabs, disableCalendarDates = _a.disableCalendarDates, ageCategories = _a.ageCategories, locations = _a.locations, language = _a.language, isMobile = _a.isMobile, panelRef = _a.panelRef, buttonRefs = _a.buttonRefs, filtersRef = _a.filtersRef, setSelectedLocations = _a.setSelectedLocations, setCalendarRange = _a.setCalendarRange, handleSelectedFilter = _a.handleSelectedFilter, updateGuestsCount = _a.updateGuestsCount, setCategories = _a.setCategories;
12169
12173
  // Handle close filter section
12170
- var filtersRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filtersRef;
12174
+ var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
12171
12175
  var localStyles = usePanelPosition({
12172
12176
  selectedFilter: selectedFilter,
12173
12177
  panelRef: panelRef,
12174
- targetFilterBarRef: targetFilterBarRef,
12178
+ filtersRef: filtersRef,
12175
12179
  buttonRefs: buttonRefs,
12176
12180
  isMobile: isMobile,
12177
12181
  }).localStyles;
12178
12182
  var renderContent = function () {
12179
12183
  switch (selectedFilter) {
12180
12184
  case FilterSections.CALENDAR:
12181
- return (React.createElement(Dates, { autoFocus: true, ref: filtersRef, onClose: function () { return handleSelectedFilter(false); }, calendarRange: calendarRange, setCalendarRange: setCalendarRange, disableCalendarDates: disableCalendarDates, selectedPath: selectedPath, language: language }));
12185
+ return (React.createElement(Dates, { autoFocus: true, ref: filterSectionRef, onClose: function () { return handleSelectedFilter(false); }, calendarRange: calendarRange, setCalendarRange: setCalendarRange, disableCalendarDates: disableCalendarDates, selectedPath: selectedPath, language: language }));
12182
12186
  case FilterSections.GUESTS:
12183
- return (React.createElement(Guests, { autoFocus: true, ref: filtersRef, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, updateGuestsCount: updateGuestsCount, onClose: function () { return handleSelectedFilter(false); } }));
12187
+ return (React.createElement(Guests, { autoFocus: true, ref: filterSectionRef, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, updateGuestsCount: updateGuestsCount, onClose: function () { return handleSelectedFilter(false); } }));
12184
12188
  case FilterSections.CATEGORIES:
12185
12189
  return (React.createElement(Categories, { categories: categories, setCategories: setCategories }));
12186
12190
  case FilterSections.LOCATIONS:
12187
- return (React.createElement(Locations, { autoFocus: true, ref: filtersRef, locations: locations === null || locations === void 0 ? void 0 : locations.data, language: language, selectedLocations: selectedLocations, setSelectedLocations: setSelectedLocations, multiSelect: locations === null || locations === void 0 ? void 0 : locations.multiSelect, onClose: function () { return handleSelectedFilter(false); } }));
12191
+ return (React.createElement(Locations, { autoFocus: true, ref: filterSectionRef, locations: locations === null || locations === void 0 ? void 0 : locations.data, language: language, selectedLocations: selectedLocations, setSelectedLocations: setSelectedLocations, multiSelect: locations === null || locations === void 0 ? void 0 : locations.multiSelect, onClose: function () { return handleSelectedFilter(false); } }));
12188
12192
  default:
12189
12193
  return null;
12190
12194
  }
12191
12195
  };
12192
- return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: (!tabs || tabs.length < 2) && !isMobile
12193
- ? { top: 66 }
12194
- : __assign$2({}, localStyles) }, renderContent())));
12196
+ return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: __assign$2(__assign$2({}, localStyles), ((!tabs || tabs.length < 2) && !isMobile ? { top: 66 } : {})) }, renderContent())));
12195
12197
  };
12196
12198
 
12197
12199
  var css_248z$4 = ".will-filter-bar-controls {\n display: flex;\n justify-content: space-between;\n padding: 10px;\n position: relative;\n z-index: 222;\n border-radius: 40px;\n background-color: var(--will-white);\n}\n\n@media (max-width: 960px) {\n .will-filter-bar-controls {\n flex-direction: column;\n padding: 20px;\n border-radius: 25px;\n overflow: hidden;\n }\n}\n";
@@ -12200,11 +12202,7 @@
12200
12202
  var FilterControls = function () {
12201
12203
  var _a;
12202
12204
  var t = useTranslation('filterBar').t;
12203
- var _b = useFilterBar(), calendarRange = _b.calendarRange, selectedFilter = _b.selectedFilter, selectedPath = _b.selectedPath, ageCategoryCounts = _b.ageCategoryCounts, selectedLocations = _b.selectedLocations, mode = _b.mode, tabs = _b.tabs, ageCategories = _b.ageCategories, locations = _b.locations, innerLoading = _b.innerLoading, outerLoading = _b.outerLoading, handleSubmit = _b.handleSubmit, handleSelectedFilter = _b.handleSelectedFilter,
12204
- // Refs
12205
- previouslyFocusedButtonRef = _b.previouslyFocusedButtonRef, buttonRefs = _b.buttonRefs,
12206
- //
12207
- targetFilterBarRef = _b.targetFilterBarRef;
12205
+ var _b = useFilterBar(), calendarRange = _b.calendarRange, selectedFilter = _b.selectedFilter, selectedPath = _b.selectedPath, ageCategoryCounts = _b.ageCategoryCounts, selectedLocations = _b.selectedLocations, mode = _b.mode, tabs = _b.tabs, ageCategories = _b.ageCategories, locations = _b.locations, innerLoading = _b.innerLoading, outerLoading = _b.outerLoading, handleSubmit = _b.handleSubmit, handleSelectedFilter = _b.handleSelectedFilter, previouslyFocusedButtonRef = _b.previouslyFocusedButtonRef, buttonRefs = _b.buttonRefs, tabsRef = _b.tabsRef, filtersRef = _b.filtersRef;
12208
12206
  // Store previously focused button and restore focus when closing
12209
12207
  React.useEffect(function () {
12210
12208
  if (!selectedFilter && previouslyFocusedButtonRef.current) {
@@ -12226,7 +12224,12 @@
12226
12224
  locationsPlaceholder: t('locations.placeholder'),
12227
12225
  locationsSelectedLabel: t('locations.selected'),
12228
12226
  });
12229
- return (React.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light'), ref: (tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1 ? targetFilterBarRef : null },
12227
+ return (React.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light'), ref: function (el) {
12228
+ filtersRef.current = el;
12229
+ if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
12230
+ tabsRef.current = el;
12231
+ }
12232
+ } },
12230
12233
  !!((_a = locations === null || locations === void 0 ? void 0 : locations.data) === null || _a === void 0 ? void 0 : _a.length) && (React.createElement(React.Fragment, null,
12231
12234
  React.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
12232
12235
  previouslyFocusedButtonRef.current = e.currentTarget;
@@ -12257,9 +12260,9 @@
12257
12260
  var t = useTranslation('filterBar').t;
12258
12261
  var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters,
12259
12262
  //
12260
- targetFilterBarRef = _a.targetFilterBarRef;
12263
+ tabsRef = _a.tabsRef;
12261
12264
  return (tabs &&
12262
- tabs.length > 1 && (React.createElement("div", { className: "will-filter-bar-tabs", ref: targetFilterBarRef }, tabs
12265
+ tabs.length > 1 && (React.createElement("div", { className: "will-filter-bar-tabs", ref: tabsRef }, tabs
12263
12266
  .sort(function (a, b) { return a.order - b.order; })
12264
12267
  .map(function (tab, idx) { return (React.createElement(TabButton, { key: "tab-".concat(idx), label: tab.label || t("tabs.".concat(tab.path.substring(1))), onClick: function () {
12265
12268
  setSelectedPath(tab.path);
@@ -12464,10 +12467,10 @@
12464
12467
  // Display component after fully loaded
12465
12468
  useAwaitRender();
12466
12469
  // Handle close filter section
12467
- var filtersRef = useCloseFilterSection({
12470
+ var filterSectionRef = useCloseFilterSection({
12468
12471
  handleSelectedFilter: setToggleCalendar,
12469
- }).filtersRef;
12470
- return (React.createElement("div", { className: "will-root", style: themePalette }, toggleCalendar && (React.createElement("div", { className: "will-calendar-wrapper", ref: filtersRef },
12472
+ }).filterSectionRef;
12473
+ return (React.createElement("div", { className: "will-root", style: themePalette }, toggleCalendar && (React.createElement("div", { className: "will-calendar-wrapper", ref: filterSectionRef },
12471
12474
  React.createElement("div", { className: "will-calendar-header" },
12472
12475
  React.createElement("h2", null, t('filterBar:calendar.title')),
12473
12476
  React.createElement(CloseButton, { handleClose: function () { return setToggleCalendar(false); } })),