willba-component-library 0.4.5 → 0.4.7
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/README.md +2 -1
- package/lib/components/FilterBar/components/FilterPanels/Categories/Categories.d.ts +1 -1
- package/lib/components/FilterBar/hooks/index.d.ts +0 -1
- package/lib/components/FilterBar/hooks/useFilterRefs.d.ts +0 -1
- package/lib/components/FilterBar/hooks/usePanelPosition.d.ts +1 -5
- package/lib/components/FilterBar/providers/FilterBarProvider.d.ts +0 -1
- package/lib/embed.esm.js +2 -2
- package/lib/embed.esm.js.map +1 -1
- package/lib/embed.umd.js +2 -2
- package/lib/embed.umd.js.map +1 -1
- package/lib/index.esm.js +28 -56
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +28 -56
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3157,23 +3157,6 @@ var Pages;
|
|
|
3157
3157
|
Pages["SALES"] = "/sales";
|
|
3158
3158
|
})(Pages || (Pages = {}));
|
|
3159
3159
|
|
|
3160
|
-
var MOBILE_BREAKPOINT = 960;
|
|
3161
|
-
var useIsMobile = function () {
|
|
3162
|
-
var _a = __read(React.useState(function () {
|
|
3163
|
-
return typeof window !== 'undefined' && window.innerWidth <= MOBILE_BREAKPOINT;
|
|
3164
|
-
}), 2), isMobile = _a[0], setIsMobile = _a[1];
|
|
3165
|
-
React.useEffect(function () {
|
|
3166
|
-
if (typeof window === 'undefined')
|
|
3167
|
-
return;
|
|
3168
|
-
var handleResize = function () {
|
|
3169
|
-
setIsMobile(window.innerWidth <= MOBILE_BREAKPOINT);
|
|
3170
|
-
};
|
|
3171
|
-
window.addEventListener('resize', handleResize);
|
|
3172
|
-
return function () { return window.removeEventListener('resize', handleResize); };
|
|
3173
|
-
}, []);
|
|
3174
|
-
return isMobile;
|
|
3175
|
-
};
|
|
3176
|
-
|
|
3177
3160
|
var useFilterState = function (_a) {
|
|
3178
3161
|
var locations = _a.locations;
|
|
3179
3162
|
var _b = __read(React.useState(Pages.EVENTS), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
@@ -7010,50 +6993,42 @@ var useFilterRefs = function () {
|
|
|
7010
6993
|
var panelRef = React.useRef(null);
|
|
7011
6994
|
var previouslyFocusedButtonRef = React.useRef(null);
|
|
7012
6995
|
var filtersRef = React.useRef(null);
|
|
7013
|
-
var isMobile = useIsMobile();
|
|
7014
6996
|
return {
|
|
7015
6997
|
previouslyFocusedButtonRef: previouslyFocusedButtonRef,
|
|
7016
|
-
isMobile: isMobile,
|
|
7017
6998
|
panelRef: panelRef,
|
|
7018
6999
|
buttonRefs: buttonRefs,
|
|
7019
7000
|
filtersRef: filtersRef,
|
|
7020
7001
|
};
|
|
7021
7002
|
};
|
|
7022
7003
|
|
|
7023
|
-
|
|
7004
|
+
// Writes panel-position candidates as CSS custom properties on the panel
|
|
7005
|
+
// element. CSS picks which one to use based on its own media query — see
|
|
7006
|
+
// FilterPanels.css. This keeps the breakpoint as a single source of truth
|
|
7007
|
+
// in CSS and avoids any JS-side mobile detection.
|
|
7024
7008
|
var usePanelPosition = function (_a) {
|
|
7025
|
-
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs
|
|
7026
|
-
var _b = __read(React.useState(), 2), left = _b[0], setLeft = _b[1];
|
|
7027
|
-
var _c = __read(React.useState(), 2), top = _c[0], setTop = _c[1];
|
|
7009
|
+
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs;
|
|
7028
7010
|
React.useLayoutEffect(function () {
|
|
7029
|
-
|
|
7030
|
-
setLeft(undefined);
|
|
7031
|
-
setTop(undefined);
|
|
7032
|
-
return;
|
|
7033
|
-
}
|
|
7011
|
+
var panel = panelRef.current;
|
|
7034
7012
|
var filters = filtersRef.current;
|
|
7035
|
-
if (!filters)
|
|
7013
|
+
if (!panel || !filters)
|
|
7036
7014
|
return;
|
|
7037
|
-
if (
|
|
7038
|
-
// Panel overlays the filter controls (which fade to opacity 0.1
|
|
7039
|
-
// via the .disabled rule), so it starts at the top of the controls.
|
|
7040
|
-
setTop(filters.offsetTop);
|
|
7041
|
-
setLeft(undefined);
|
|
7015
|
+
if (!selectedFilter || typeof selectedFilter !== 'string')
|
|
7042
7016
|
return;
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
var panel = panelRef.current;
|
|
7017
|
+
var overlayTop = filters.offsetTop;
|
|
7018
|
+
var belowTop = filters.offsetTop + filters.offsetHeight;
|
|
7019
|
+
var left = 0;
|
|
7047
7020
|
var button = buttonRefs.current[selectedFilter];
|
|
7048
|
-
if (
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7021
|
+
if (button) {
|
|
7022
|
+
var containerRect = filters.getBoundingClientRect();
|
|
7023
|
+
var buttonRect = button.getBoundingClientRect();
|
|
7024
|
+
var panelRect = panel.getBoundingClientRect();
|
|
7025
|
+
var buttonLeft = buttonRect.left - containerRect.left - 10;
|
|
7026
|
+
left = Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width));
|
|
7027
|
+
}
|
|
7028
|
+
panel.style.setProperty('--panel-top-overlay', "".concat(overlayTop, "px"));
|
|
7029
|
+
panel.style.setProperty('--panel-top-below', "".concat(belowTop, "px"));
|
|
7030
|
+
panel.style.setProperty('--panel-left', "".concat(left, "px"));
|
|
7031
|
+
}, [selectedFilter]);
|
|
7057
7032
|
};
|
|
7058
7033
|
|
|
7059
7034
|
var FilterBarContext = React.createContext(undefined);
|
|
@@ -7095,7 +7070,6 @@ var FilterBarProvider = function (_a) {
|
|
|
7095
7070
|
tabs,
|
|
7096
7071
|
outerLoading,
|
|
7097
7072
|
locations,
|
|
7098
|
-
filterRefs.isMobile,
|
|
7099
7073
|
filterRefs.filtersRef,
|
|
7100
7074
|
]);
|
|
7101
7075
|
return (React.createElement(FilterBarContext.Provider, { value: contextValue }, children));
|
|
@@ -12343,7 +12317,7 @@ var css_248z$6 = "#will-filter-bar-categories {\n text-align: center;\n}\n\n.wi
|
|
|
12343
12317
|
styleInject(css_248z$6);
|
|
12344
12318
|
|
|
12345
12319
|
var Categories = function (_a) {
|
|
12346
|
-
|
|
12320
|
+
var setCategories = _a.setCategories;
|
|
12347
12321
|
var t = useTranslation('filterBar').t;
|
|
12348
12322
|
var categoriesPlaceholder = [
|
|
12349
12323
|
'Weekend',
|
|
@@ -12364,20 +12338,19 @@ var Categories = function (_a) {
|
|
|
12364
12338
|
};
|
|
12365
12339
|
Categories.displayName = 'Categories';
|
|
12366
12340
|
|
|
12367
|
-
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";
|
|
12341
|
+
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";
|
|
12368
12342
|
styleInject(css_248z$5);
|
|
12369
12343
|
|
|
12370
12344
|
var FilterPanels = function () {
|
|
12371
|
-
var _a = useFilterBar(), categories = _a.categories, calendarRange = _a.calendarRange, selectedFilter = _a.selectedFilter, selectedPath = _a.selectedPath, ageCategoryCounts = _a.ageCategoryCounts, selectedLocations = _a.selectedLocations, mode = _a.mode
|
|
12345
|
+
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;
|
|
12372
12346
|
// Handle close filter section
|
|
12373
12347
|
var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
|
|
12374
|
-
|
|
12348
|
+
usePanelPosition({
|
|
12375
12349
|
selectedFilter: selectedFilter,
|
|
12376
12350
|
panelRef: panelRef,
|
|
12377
12351
|
filtersRef: filtersRef,
|
|
12378
12352
|
buttonRefs: buttonRefs,
|
|
12379
|
-
|
|
12380
|
-
}), left = _b.left, top = _b.top;
|
|
12353
|
+
});
|
|
12381
12354
|
var renderContent = function () {
|
|
12382
12355
|
switch (selectedFilter) {
|
|
12383
12356
|
case FilterSections.CALENDAR:
|
|
@@ -12392,7 +12365,7 @@ var FilterPanels = function () {
|
|
|
12392
12365
|
return null;
|
|
12393
12366
|
}
|
|
12394
12367
|
};
|
|
12395
|
-
return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light')
|
|
12368
|
+
return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light') }, renderContent())));
|
|
12396
12369
|
};
|
|
12397
12370
|
|
|
12398
12371
|
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";
|
|
@@ -12605,7 +12578,6 @@ var useFilterCalendar = function (_a) {
|
|
|
12605
12578
|
var Footer = function (_a) {
|
|
12606
12579
|
var calendarHasError = _a.calendarHasError, calendarRange = _a.calendarRange, handleClearDates = _a.handleClearDates, language = _a.language, palette = _a.palette;
|
|
12607
12580
|
var t = useTranslation().t;
|
|
12608
|
-
reactResponsiveExports.useMediaQuery({ maxWidth: 600 });
|
|
12609
12581
|
var nights = nightsCount({
|
|
12610
12582
|
calendarRange: calendarRange,
|
|
12611
12583
|
});
|