willba-component-library 0.3.19 → 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;
@@ -6910,7 +6912,8 @@
6910
6912
  outerLoading,
6911
6913
  locations,
6912
6914
  filterUi.isMobile,
6913
- filterUi.targetFilterBarRef,
6915
+ filterUi.tabsRef,
6916
+ filterUi.filtersRef,
6914
6917
  ]);
6915
6918
  return (React.createElement(FilterBarContext.Provider, { value: contextValue }, children));
6916
6919
  };
@@ -12166,33 +12169,31 @@
12166
12169
  styleInject(css_248z$5);
12167
12170
 
12168
12171
  var FilterPanels = function () {
12169
- 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;
12170
12173
  // Handle close filter section
12171
- var filtersRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filtersRef;
12174
+ var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
12172
12175
  var localStyles = usePanelPosition({
12173
12176
  selectedFilter: selectedFilter,
12174
12177
  panelRef: panelRef,
12175
- targetFilterBarRef: targetFilterBarRef,
12178
+ filtersRef: filtersRef,
12176
12179
  buttonRefs: buttonRefs,
12177
12180
  isMobile: isMobile,
12178
12181
  }).localStyles;
12179
12182
  var renderContent = function () {
12180
12183
  switch (selectedFilter) {
12181
12184
  case FilterSections.CALENDAR:
12182
- 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 }));
12183
12186
  case FilterSections.GUESTS:
12184
- 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); } }));
12185
12188
  case FilterSections.CATEGORIES:
12186
12189
  return (React.createElement(Categories, { categories: categories, setCategories: setCategories }));
12187
12190
  case FilterSections.LOCATIONS:
12188
- 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); } }));
12189
12192
  default:
12190
12193
  return null;
12191
12194
  }
12192
12195
  };
12193
- return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: (!tabs || tabs.length < 2) && !isMobile
12194
- ? { top: 66 }
12195
- : __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())));
12196
12197
  };
12197
12198
 
12198
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";
@@ -12201,11 +12202,7 @@
12201
12202
  var FilterControls = function () {
12202
12203
  var _a;
12203
12204
  var t = useTranslation('filterBar').t;
12204
- 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,
12205
- // Refs
12206
- previouslyFocusedButtonRef = _b.previouslyFocusedButtonRef, buttonRefs = _b.buttonRefs,
12207
- //
12208
- 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;
12209
12206
  // Store previously focused button and restore focus when closing
12210
12207
  React.useEffect(function () {
12211
12208
  if (!selectedFilter && previouslyFocusedButtonRef.current) {
@@ -12227,7 +12224,12 @@
12227
12224
  locationsPlaceholder: t('locations.placeholder'),
12228
12225
  locationsSelectedLabel: t('locations.selected'),
12229
12226
  });
12230
- 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
+ } },
12231
12233
  !!((_a = locations === null || locations === void 0 ? void 0 : locations.data) === null || _a === void 0 ? void 0 : _a.length) && (React.createElement(React.Fragment, null,
12232
12234
  React.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
12233
12235
  previouslyFocusedButtonRef.current = e.currentTarget;
@@ -12258,9 +12260,9 @@
12258
12260
  var t = useTranslation('filterBar').t;
12259
12261
  var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters,
12260
12262
  //
12261
- targetFilterBarRef = _a.targetFilterBarRef;
12263
+ tabsRef = _a.tabsRef;
12262
12264
  return (tabs &&
12263
- 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
12264
12266
  .sort(function (a, b) { return a.order - b.order; })
12265
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 () {
12266
12268
  setSelectedPath(tab.path);
@@ -12465,10 +12467,10 @@
12465
12467
  // Display component after fully loaded
12466
12468
  useAwaitRender();
12467
12469
  // Handle close filter section
12468
- var filtersRef = useCloseFilterSection({
12470
+ var filterSectionRef = useCloseFilterSection({
12469
12471
  handleSelectedFilter: setToggleCalendar,
12470
- }).filtersRef;
12471
- 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 },
12472
12474
  React.createElement("div", { className: "will-calendar-header" },
12473
12475
  React.createElement("h2", null, t('filterBar:calendar.title')),
12474
12476
  React.createElement(CloseButton, { handleClose: function () { return setToggleCalendar(false); } })),