willba-component-library 0.4.5 → 0.4.6

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.esm.js CHANGED
@@ -3137,23 +3137,6 @@ var Pages;
3137
3137
  Pages["SALES"] = "/sales";
3138
3138
  })(Pages || (Pages = {}));
3139
3139
 
3140
- var MOBILE_BREAKPOINT = 960;
3141
- var useIsMobile = function () {
3142
- var _a = __read(useState(function () {
3143
- return typeof window !== 'undefined' && window.innerWidth <= MOBILE_BREAKPOINT;
3144
- }), 2), isMobile = _a[0], setIsMobile = _a[1];
3145
- useEffect(function () {
3146
- if (typeof window === 'undefined')
3147
- return;
3148
- var handleResize = function () {
3149
- setIsMobile(window.innerWidth <= MOBILE_BREAKPOINT);
3150
- };
3151
- window.addEventListener('resize', handleResize);
3152
- return function () { return window.removeEventListener('resize', handleResize); };
3153
- }, []);
3154
- return isMobile;
3155
- };
3156
-
3157
3140
  var useFilterState = function (_a) {
3158
3141
  var locations = _a.locations;
3159
3142
  var _b = __read(useState(Pages.EVENTS), 2), selectedPath = _b[0], setSelectedPath = _b[1];
@@ -6990,50 +6973,42 @@ var useFilterRefs = function () {
6990
6973
  var panelRef = useRef(null);
6991
6974
  var previouslyFocusedButtonRef = useRef(null);
6992
6975
  var filtersRef = useRef(null);
6993
- var isMobile = useIsMobile();
6994
6976
  return {
6995
6977
  previouslyFocusedButtonRef: previouslyFocusedButtonRef,
6996
- isMobile: isMobile,
6997
6978
  panelRef: panelRef,
6998
6979
  buttonRefs: buttonRefs,
6999
6980
  filtersRef: filtersRef,
7000
6981
  };
7001
6982
  };
7002
6983
 
7003
- var DESKTOP_PANEL_GAP = 10;
6984
+ // Writes panel-position candidates as CSS custom properties on the panel
6985
+ // element. CSS picks which one to use based on its own media query — see
6986
+ // FilterPanels.css. This keeps the breakpoint as a single source of truth
6987
+ // in CSS and avoids any JS-side mobile detection.
7004
6988
  var usePanelPosition = function (_a) {
7005
- var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile;
7006
- var _b = __read(useState(), 2), left = _b[0], setLeft = _b[1];
7007
- var _c = __read(useState(), 2), top = _c[0], setTop = _c[1];
6989
+ var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs;
7008
6990
  useLayoutEffect(function () {
7009
- if (!selectedFilter || typeof selectedFilter !== 'string') {
7010
- setLeft(undefined);
7011
- setTop(undefined);
7012
- return;
7013
- }
6991
+ var panel = panelRef.current;
7014
6992
  var filters = filtersRef.current;
7015
- if (!filters)
6993
+ if (!panel || !filters)
7016
6994
  return;
7017
- if (isMobile) {
7018
- // Panel overlays the filter controls (which fade to opacity 0.1
7019
- // via the .disabled rule), so it starts at the top of the controls.
7020
- setTop(filters.offsetTop);
7021
- setLeft(undefined);
6995
+ if (!selectedFilter || typeof selectedFilter !== 'string')
7022
6996
  return;
7023
- }
7024
- // Desktop: panel sits below the controls with a small breathing room.
7025
- setTop(filters.offsetTop + filters.offsetHeight + DESKTOP_PANEL_GAP);
7026
- var panel = panelRef.current;
6997
+ var overlayTop = filters.offsetTop;
6998
+ var belowTop = filters.offsetTop + filters.offsetHeight;
6999
+ var left = 0;
7027
7000
  var button = buttonRefs.current[selectedFilter];
7028
- if (!panel || !button)
7029
- return;
7030
- var panelRect = panel.getBoundingClientRect();
7031
- var containerRect = filters.getBoundingClientRect();
7032
- var buttonRect = button.getBoundingClientRect();
7033
- var buttonLeft = buttonRect.left - containerRect.left - 10;
7034
- setLeft(Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width)));
7035
- }, [selectedFilter, isMobile]);
7036
- return { top: top, left: left };
7001
+ if (button) {
7002
+ var containerRect = filters.getBoundingClientRect();
7003
+ var buttonRect = button.getBoundingClientRect();
7004
+ var panelRect = panel.getBoundingClientRect();
7005
+ var buttonLeft = buttonRect.left - containerRect.left - 10;
7006
+ left = Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width));
7007
+ }
7008
+ panel.style.setProperty('--panel-top-overlay', "".concat(overlayTop, "px"));
7009
+ panel.style.setProperty('--panel-top-below', "".concat(belowTop, "px"));
7010
+ panel.style.setProperty('--panel-left', "".concat(left, "px"));
7011
+ }, [selectedFilter]);
7037
7012
  };
7038
7013
 
7039
7014
  var FilterBarContext = createContext(undefined);
@@ -7075,7 +7050,6 @@ var FilterBarProvider = function (_a) {
7075
7050
  tabs,
7076
7051
  outerLoading,
7077
7052
  locations,
7078
- filterRefs.isMobile,
7079
7053
  filterRefs.filtersRef,
7080
7054
  ]);
7081
7055
  return (React__default.createElement(FilterBarContext.Provider, { value: contextValue }, children));
@@ -12323,7 +12297,7 @@ var css_248z$6 = "#will-filter-bar-categories {\n text-align: center;\n}\n\n.wi
12323
12297
  styleInject(css_248z$6);
12324
12298
 
12325
12299
  var Categories = function (_a) {
12326
- _a.categories; var setCategories = _a.setCategories;
12300
+ var setCategories = _a.setCategories;
12327
12301
  var t = useTranslation('filterBar').t;
12328
12302
  var categoriesPlaceholder = [
12329
12303
  'Weekend',
@@ -12344,20 +12318,19 @@ var Categories = function (_a) {
12344
12318
  };
12345
12319
  Categories.displayName = 'Categories';
12346
12320
 
12347
- var css_248z$5 = ".will-filter-bar-panels {\n background-color: var(--will-white);\n min-height: 100px;\n position: absolute;\n z-index: 111;\n border-radius: 25px;\n box-shadow: var(--will-box-shadow);\n}\n\n@media (max-width: 960px) {\n .will-root {\n width: 100%;\n min-width: auto;\n max-height: 100vh;\n z-index: 3;\n }\n\n .will-filter-bar-panels {\n width: 100%;\n z-index: 999;\n }\n}\n";
12321
+ var css_248z$5 = ".will-filter-bar-panels {\n background-color: var(--will-white);\n min-height: 100px;\n position: absolute;\n z-index: 111;\n border-radius: 25px;\n box-shadow: var(--will-box-shadow);\n\n top: calc(var(--panel-top-below, 0px) + 10px);\n left: var(--panel-left, 0px);\n}\n\n@media (max-width: 960px) {\n .will-root {\n width: 100%;\n min-width: auto;\n max-height: 100vh;\n z-index: 3;\n }\n\n .will-filter-bar-panels {\n top: var(--panel-top-overlay, 0px);\n left: 0;\n width: 100%;\n z-index: 999;\n }\n}\n";
12348
12322
  styleInject(css_248z$5);
12349
12323
 
12350
12324
  var FilterPanels = function () {
12351
- var _a = useFilterBar(), categories = _a.categories, calendarRange = _a.calendarRange, selectedFilter = _a.selectedFilter, selectedPath = _a.selectedPath, ageCategoryCounts = _a.ageCategoryCounts, selectedLocations = _a.selectedLocations, mode = _a.mode; _a.tabs; var 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;
12325
+ var _a = useFilterBar(), categories = _a.categories, calendarRange = _a.calendarRange, selectedFilter = _a.selectedFilter, selectedPath = _a.selectedPath, ageCategoryCounts = _a.ageCategoryCounts, selectedLocations = _a.selectedLocations, mode = _a.mode, disableCalendarDates = _a.disableCalendarDates, ageCategories = _a.ageCategories, locations = _a.locations, language = _a.language, panelRef = _a.panelRef, buttonRefs = _a.buttonRefs, filtersRef = _a.filtersRef, setSelectedLocations = _a.setSelectedLocations, setCalendarRange = _a.setCalendarRange, handleSelectedFilter = _a.handleSelectedFilter, updateGuestsCount = _a.updateGuestsCount, setCategories = _a.setCategories;
12352
12326
  // Handle close filter section
12353
12327
  var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
12354
- var _b = usePanelPosition({
12328
+ usePanelPosition({
12355
12329
  selectedFilter: selectedFilter,
12356
12330
  panelRef: panelRef,
12357
12331
  filtersRef: filtersRef,
12358
12332
  buttonRefs: buttonRefs,
12359
- isMobile: isMobile,
12360
- }), left = _b.left, top = _b.top;
12333
+ });
12361
12334
  var renderContent = function () {
12362
12335
  switch (selectedFilter) {
12363
12336
  case FilterSections.CALENDAR:
@@ -12372,7 +12345,7 @@ var FilterPanels = function () {
12372
12345
  return null;
12373
12346
  }
12374
12347
  };
12375
- return (selectedFilter && (React__default.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: { left: left, top: top } }, renderContent())));
12348
+ return (selectedFilter && (React__default.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light') }, renderContent())));
12376
12349
  };
12377
12350
 
12378
12351
  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 .will-filter-bar-controls.disabled {\n opacity: 0.1;\n }\n}\n";
@@ -12585,7 +12558,6 @@ var useFilterCalendar = function (_a) {
12585
12558
  var Footer = function (_a) {
12586
12559
  var calendarHasError = _a.calendarHasError, calendarRange = _a.calendarRange, handleClearDates = _a.handleClearDates, language = _a.language, palette = _a.palette;
12587
12560
  var t = useTranslation().t;
12588
- reactResponsiveExports.useMediaQuery({ maxWidth: 600 });
12589
12561
  var nights = nightsCount({
12590
12562
  calendarRange: calendarRange,
12591
12563
  });