willba-component-library 0.4.4 → 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,27 +3137,6 @@ var Pages;
3137
3137
  Pages["SALES"] = "/sales";
3138
3138
  })(Pages || (Pages = {}));
3139
3139
 
3140
- var useScrollInToView = function (_a) {
3141
- var selectedFilter = _a.selectedFilter;
3142
- var _b = __read(useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
3143
- var tabsRef = useRef(null);
3144
- useEffect(function () {
3145
- if (typeof window !== 'undefined' && window.innerWidth > 960) {
3146
- setIsMobile(false);
3147
- return;
3148
- }
3149
- if (tabsRef.current && selectedFilter) {
3150
- window.scrollTo({
3151
- behavior: 'smooth',
3152
- top: tabsRef.current.getBoundingClientRect().top -
3153
- document.body.getBoundingClientRect().top -
3154
- 30,
3155
- });
3156
- }
3157
- }, [selectedFilter]);
3158
- return { isMobile: isMobile, tabsRef: tabsRef };
3159
- };
3160
-
3161
3140
  var useFilterState = function (_a) {
3162
3141
  var locations = _a.locations;
3163
3142
  var _b = __read(useState(Pages.EVENTS), 2), selectedPath = _b[0], setSelectedPath = _b[1];
@@ -6989,45 +6968,47 @@ var useFilterActions = function (_a) {
6989
6968
  };
6990
6969
  };
6991
6970
 
6992
- var useFilterRefs = function (selectedFilter) {
6971
+ var useFilterRefs = function () {
6993
6972
  var buttonRefs = useRef({});
6994
6973
  var panelRef = useRef(null);
6995
6974
  var previouslyFocusedButtonRef = useRef(null);
6996
6975
  var filtersRef = useRef(null);
6997
- var _a = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _a.isMobile, tabsRef = _a.tabsRef;
6998
6976
  return {
6999
6977
  previouslyFocusedButtonRef: previouslyFocusedButtonRef,
7000
- isMobile: isMobile,
7001
- tabsRef: tabsRef,
7002
6978
  panelRef: panelRef,
7003
6979
  buttonRefs: buttonRefs,
7004
6980
  filtersRef: filtersRef,
7005
6981
  };
7006
6982
  };
7007
6983
 
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.
7008
6988
  var usePanelPosition = function (_a) {
7009
- var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile, tabs = _a.tabs;
7010
- var _b = __read(useState(), 2), left = _b[0], setLeft = _b[1];
7011
- var hasMultipleTabs = tabs && tabs.length > 1;
7012
- var top = isMobile ? (hasMultipleTabs ? 60 : 0) : hasMultipleTabs ? 125 : 66;
6989
+ var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs;
7013
6990
  useLayoutEffect(function () {
7014
- if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
7015
- setLeft(undefined);
7016
- return;
7017
- }
7018
6991
  var panel = panelRef.current;
7019
- var container = filtersRef.current;
7020
- var button = buttonRefs.current[selectedFilter];
7021
- if (!panel || !container || !button)
6992
+ var filters = filtersRef.current;
6993
+ if (!panel || !filters)
6994
+ return;
6995
+ if (!selectedFilter || typeof selectedFilter !== 'string')
7022
6996
  return;
7023
- var panelRect = panel.getBoundingClientRect();
7024
- var containerRect = container.getBoundingClientRect();
7025
- var buttonRect = button.getBoundingClientRect();
7026
- var buttonLeft = buttonRect.left - containerRect.left - 10;
7027
- var newLeft = Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width));
7028
- setLeft(newLeft);
7029
- }, [selectedFilter, isMobile]);
7030
- return { top: top, left: left };
6997
+ var overlayTop = filters.offsetTop;
6998
+ var belowTop = filters.offsetTop + filters.offsetHeight;
6999
+ var left = 0;
7000
+ var button = buttonRefs.current[selectedFilter];
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]);
7031
7012
  };
7032
7013
 
7033
7014
  var FilterBarContext = createContext(undefined);
@@ -7049,7 +7030,7 @@ var FilterBarProvider = function (_a) {
7049
7030
  onSubmit: onSubmit,
7050
7031
  setInnerLoading: setInnerLoading,
7051
7032
  });
7052
- var filterRefs = useFilterRefs(selectedFilter);
7033
+ var filterRefs = useFilterRefs();
7053
7034
  var contextValue = useMemo(function () { return (__assign$2(__assign$2(__assign$2({ selectedFilter: selectedFilter, ageCategoryCounts: ageCategoryCounts, categories: categories, calendarRange: calendarRange, selectedPath: selectedPath, innerLoading: innerLoading, selectedLocations: selectedLocations, setSelectedLocations: setSelectedLocations, setCalendarRange: setCalendarRange, setSelectedFilter: setSelectedFilter, setAgeCategoryCounts: setAgeCategoryCounts, setCategories: setCategories, setSelectedPath: setSelectedPath }, filterActions), { language: language, ageCategories: ageCategories, redirectUrl: redirectUrl, palette: palette, onSubmit: onSubmit, fullWidth: fullWidth, disableCalendarDates: disableCalendarDates, mode: mode, tabs: tabs, outerLoading: outerLoading, locations: locations }), filterRefs)); }, [
7054
7035
  selectedFilter,
7055
7036
  ageCategoryCounts,
@@ -7069,8 +7050,6 @@ var FilterBarProvider = function (_a) {
7069
7050
  tabs,
7070
7051
  outerLoading,
7071
7052
  locations,
7072
- filterRefs.isMobile,
7073
- filterRefs.tabsRef,
7074
7053
  filterRefs.filtersRef,
7075
7054
  ]);
7076
7055
  return (React__default.createElement(FilterBarContext.Provider, { value: contextValue }, children));
@@ -12318,7 +12297,7 @@ var css_248z$6 = "#will-filter-bar-categories {\n text-align: center;\n}\n\n.wi
12318
12297
  styleInject(css_248z$6);
12319
12298
 
12320
12299
  var Categories = function (_a) {
12321
- _a.categories; var setCategories = _a.setCategories;
12300
+ var setCategories = _a.setCategories;
12322
12301
  var t = useTranslation('filterBar').t;
12323
12302
  var categoriesPlaceholder = [
12324
12303
  'Weekend',
@@ -12339,21 +12318,19 @@ var Categories = function (_a) {
12339
12318
  };
12340
12319
  Categories.displayName = 'Categories';
12341
12320
 
12342
- 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";
12343
12322
  styleInject(css_248z$5);
12344
12323
 
12345
12324
  var FilterPanels = function () {
12346
- 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;
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;
12347
12326
  // Handle close filter section
12348
12327
  var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
12349
- var _b = usePanelPosition({
12328
+ usePanelPosition({
12350
12329
  selectedFilter: selectedFilter,
12351
12330
  panelRef: panelRef,
12352
12331
  filtersRef: filtersRef,
12353
12332
  buttonRefs: buttonRefs,
12354
- isMobile: isMobile,
12355
- tabs: tabs,
12356
- }), left = _b.left, top = _b.top;
12333
+ });
12357
12334
  var renderContent = function () {
12358
12335
  switch (selectedFilter) {
12359
12336
  case FilterSections.CALENDAR:
@@ -12368,7 +12345,7 @@ var FilterPanels = function () {
12368
12345
  return null;
12369
12346
  }
12370
12347
  };
12371
- 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())));
12372
12349
  };
12373
12350
 
12374
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";
@@ -12377,7 +12354,7 @@ styleInject(css_248z$4);
12377
12354
  var FilterControls = function () {
12378
12355
  var _a;
12379
12356
  var t = useTranslation('filterBar').t;
12380
- 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;
12357
+ var _b = useFilterBar(), calendarRange = _b.calendarRange, selectedFilter = _b.selectedFilter, selectedPath = _b.selectedPath, ageCategoryCounts = _b.ageCategoryCounts, selectedLocations = _b.selectedLocations, mode = _b.mode, ageCategories = _b.ageCategories, locations = _b.locations, innerLoading = _b.innerLoading, outerLoading = _b.outerLoading, handleSubmit = _b.handleSubmit, handleSelectedFilter = _b.handleSelectedFilter, previouslyFocusedButtonRef = _b.previouslyFocusedButtonRef, buttonRefs = _b.buttonRefs, filtersRef = _b.filtersRef;
12381
12358
  // Store previously focused button and restore focus when closing
12382
12359
  useEffect(function () {
12383
12360
  if (!selectedFilter && previouslyFocusedButtonRef.current) {
@@ -12401,9 +12378,6 @@ var FilterControls = function () {
12401
12378
  });
12402
12379
  return (React__default.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light', " ").concat(selectedFilter ? 'disabled' : ''), ref: function (el) {
12403
12380
  filtersRef.current = el;
12404
- if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
12405
- tabsRef.current = el;
12406
- }
12407
12381
  } },
12408
12382
  !!((_a = locations === null || locations === void 0 ? void 0 : locations.data) === null || _a === void 0 ? void 0 : _a.length) && locations.data.length > 1 && (React__default.createElement(React__default.Fragment, null,
12409
12383
  React__default.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
@@ -12433,7 +12407,7 @@ styleInject(css_248z$3);
12433
12407
 
12434
12408
  var FilterTabs = function () {
12435
12409
  var t = useTranslation('filterBar').t;
12436
- var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, tabsRef = _a.tabsRef, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters;
12410
+ var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters;
12437
12411
  var sortedTabs = useMemo(function () { return __spreadArray$1([], __read((tabs !== null && tabs !== void 0 ? tabs : [])), false).sort(function (a, b) { return a.order - b.order; }); }, [tabs]);
12438
12412
  var handleTabClick = function (path) {
12439
12413
  setSelectedPath(path);
@@ -12442,7 +12416,7 @@ var FilterTabs = function () {
12442
12416
  };
12443
12417
  if (sortedTabs.length <= 1)
12444
12418
  return null;
12445
- return (React__default.createElement("div", { className: "will-filter-bar-tabs", ref: tabsRef }, sortedTabs.map(function (tab) { return (React__default.createElement(TabButton, { key: tab.path, label: tab.label || t("tabs.".concat(tab.path.slice(1))), onClick: function () { return handleTabClick(tab.path); }, active: selectedPath === tab.path, mode: mode })); })));
12419
+ return (React__default.createElement("div", { className: "will-filter-bar-tabs" }, sortedTabs.map(function (tab) { return (React__default.createElement(TabButton, { key: tab.path, label: tab.label || t("tabs.".concat(tab.path.slice(1))), onClick: function () { return handleTabClick(tab.path); }, active: selectedPath === tab.path, mode: mode })); })));
12446
12420
  };
12447
12421
 
12448
12422
  var css_248z$2 = "@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-light-grey: #C8C8C8;\n --will-white: #fff;\n --will-white-transparent: #ffffffcf;\n --will-black: #000;\n --will-onahau: #CDEEFF;\n --will-text: #5A5959;\n --will-charcoal-blue: #384265;\n --will-error: #d32f2f;\n\n /* Transparent */\n --will-transparent-black: rgba(0, 0, 0, 0.5);\n --will-transparent-white: rgba(255, 255, 255, 0.30);\n --will-transparent-lavender: rgba(171, 167, 175, 0.30);\n\n /* Color mix */\n --will-primary-lighter: color-mix(in srgb, var(--will-primary), white 50%);\n --will-primary-lightest: color-mix(in srgb, var(--will-primary), white 80%);\n\n\n /* Shadows */\n --will-box-shadow-dark: 0px 2px 12px 2px #a1a1a180;\n --will-box-shadow-light: 0px 2px 12px 2px #bcb9b980;\n\n /* Breakpoints */\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}\n\n\n/* Integration fixes */\n\n.will-root p {\n margin: 0 !important;\n}\n\n.will-root button {\n line-height: normal !important;\n}\n";
@@ -12584,7 +12558,6 @@ var useFilterCalendar = function (_a) {
12584
12558
  var Footer = function (_a) {
12585
12559
  var calendarHasError = _a.calendarHasError, calendarRange = _a.calendarRange, handleClearDates = _a.handleClearDates, language = _a.language, palette = _a.palette;
12586
12560
  var t = useTranslation().t;
12587
- reactResponsiveExports.useMediaQuery({ maxWidth: 600 });
12588
12561
  var nights = nightsCount({
12589
12562
  calendarRange: calendarRange,
12590
12563
  });