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/README.md +2 -2
- 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 +1 -3
- package/lib/components/FilterBar/hooks/useIsMobile.d.ts +1 -0
- package/lib/components/FilterBar/hooks/usePanelPosition.d.ts +1 -6
- package/lib/components/FilterBar/providers/FilterBarProvider.d.ts +0 -2
- 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 +35 -62
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +35 -62
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3157,27 +3157,6 @@ var Pages;
|
|
|
3157
3157
|
Pages["SALES"] = "/sales";
|
|
3158
3158
|
})(Pages || (Pages = {}));
|
|
3159
3159
|
|
|
3160
|
-
var useScrollInToView = function (_a) {
|
|
3161
|
-
var selectedFilter = _a.selectedFilter;
|
|
3162
|
-
var _b = __read(React.useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
|
|
3163
|
-
var tabsRef = React.useRef(null);
|
|
3164
|
-
React.useEffect(function () {
|
|
3165
|
-
if (typeof window !== 'undefined' && window.innerWidth > 960) {
|
|
3166
|
-
setIsMobile(false);
|
|
3167
|
-
return;
|
|
3168
|
-
}
|
|
3169
|
-
if (tabsRef.current && selectedFilter) {
|
|
3170
|
-
window.scrollTo({
|
|
3171
|
-
behavior: 'smooth',
|
|
3172
|
-
top: tabsRef.current.getBoundingClientRect().top -
|
|
3173
|
-
document.body.getBoundingClientRect().top -
|
|
3174
|
-
30,
|
|
3175
|
-
});
|
|
3176
|
-
}
|
|
3177
|
-
}, [selectedFilter]);
|
|
3178
|
-
return { isMobile: isMobile, tabsRef: tabsRef };
|
|
3179
|
-
};
|
|
3180
|
-
|
|
3181
3160
|
var useFilterState = function (_a) {
|
|
3182
3161
|
var locations = _a.locations;
|
|
3183
3162
|
var _b = __read(React.useState(Pages.EVENTS), 2), selectedPath = _b[0], setSelectedPath = _b[1];
|
|
@@ -7009,45 +6988,47 @@ var useFilterActions = function (_a) {
|
|
|
7009
6988
|
};
|
|
7010
6989
|
};
|
|
7011
6990
|
|
|
7012
|
-
var useFilterRefs = function (
|
|
6991
|
+
var useFilterRefs = function () {
|
|
7013
6992
|
var buttonRefs = React.useRef({});
|
|
7014
6993
|
var panelRef = React.useRef(null);
|
|
7015
6994
|
var previouslyFocusedButtonRef = React.useRef(null);
|
|
7016
6995
|
var filtersRef = React.useRef(null);
|
|
7017
|
-
var _a = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _a.isMobile, tabsRef = _a.tabsRef;
|
|
7018
6996
|
return {
|
|
7019
6997
|
previouslyFocusedButtonRef: previouslyFocusedButtonRef,
|
|
7020
|
-
isMobile: isMobile,
|
|
7021
|
-
tabsRef: tabsRef,
|
|
7022
6998
|
panelRef: panelRef,
|
|
7023
6999
|
buttonRefs: buttonRefs,
|
|
7024
7000
|
filtersRef: filtersRef,
|
|
7025
7001
|
};
|
|
7026
7002
|
};
|
|
7027
7003
|
|
|
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.
|
|
7028
7008
|
var usePanelPosition = function (_a) {
|
|
7029
|
-
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs
|
|
7030
|
-
var _b = __read(React.useState(), 2), left = _b[0], setLeft = _b[1];
|
|
7031
|
-
var hasMultipleTabs = tabs && tabs.length > 1;
|
|
7032
|
-
var top = isMobile ? (hasMultipleTabs ? 60 : 0) : hasMultipleTabs ? 125 : 66;
|
|
7009
|
+
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs;
|
|
7033
7010
|
React.useLayoutEffect(function () {
|
|
7034
|
-
if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
|
|
7035
|
-
setLeft(undefined);
|
|
7036
|
-
return;
|
|
7037
|
-
}
|
|
7038
7011
|
var panel = panelRef.current;
|
|
7039
|
-
var
|
|
7040
|
-
|
|
7041
|
-
|
|
7012
|
+
var filters = filtersRef.current;
|
|
7013
|
+
if (!panel || !filters)
|
|
7014
|
+
return;
|
|
7015
|
+
if (!selectedFilter || typeof selectedFilter !== 'string')
|
|
7042
7016
|
return;
|
|
7043
|
-
var
|
|
7044
|
-
var
|
|
7045
|
-
var
|
|
7046
|
-
var
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7017
|
+
var overlayTop = filters.offsetTop;
|
|
7018
|
+
var belowTop = filters.offsetTop + filters.offsetHeight;
|
|
7019
|
+
var left = 0;
|
|
7020
|
+
var button = buttonRefs.current[selectedFilter];
|
|
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]);
|
|
7051
7032
|
};
|
|
7052
7033
|
|
|
7053
7034
|
var FilterBarContext = React.createContext(undefined);
|
|
@@ -7069,7 +7050,7 @@ var FilterBarProvider = function (_a) {
|
|
|
7069
7050
|
onSubmit: onSubmit,
|
|
7070
7051
|
setInnerLoading: setInnerLoading,
|
|
7071
7052
|
});
|
|
7072
|
-
var filterRefs = useFilterRefs(
|
|
7053
|
+
var filterRefs = useFilterRefs();
|
|
7073
7054
|
var contextValue = React.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)); }, [
|
|
7074
7055
|
selectedFilter,
|
|
7075
7056
|
ageCategoryCounts,
|
|
@@ -7089,8 +7070,6 @@ var FilterBarProvider = function (_a) {
|
|
|
7089
7070
|
tabs,
|
|
7090
7071
|
outerLoading,
|
|
7091
7072
|
locations,
|
|
7092
|
-
filterRefs.isMobile,
|
|
7093
|
-
filterRefs.tabsRef,
|
|
7094
7073
|
filterRefs.filtersRef,
|
|
7095
7074
|
]);
|
|
7096
7075
|
return (React.createElement(FilterBarContext.Provider, { value: contextValue }, children));
|
|
@@ -12338,7 +12317,7 @@ var css_248z$6 = "#will-filter-bar-categories {\n text-align: center;\n}\n\n.wi
|
|
|
12338
12317
|
styleInject(css_248z$6);
|
|
12339
12318
|
|
|
12340
12319
|
var Categories = function (_a) {
|
|
12341
|
-
|
|
12320
|
+
var setCategories = _a.setCategories;
|
|
12342
12321
|
var t = useTranslation('filterBar').t;
|
|
12343
12322
|
var categoriesPlaceholder = [
|
|
12344
12323
|
'Weekend',
|
|
@@ -12359,21 +12338,19 @@ var Categories = function (_a) {
|
|
|
12359
12338
|
};
|
|
12360
12339
|
Categories.displayName = 'Categories';
|
|
12361
12340
|
|
|
12362
|
-
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";
|
|
12363
12342
|
styleInject(css_248z$5);
|
|
12364
12343
|
|
|
12365
12344
|
var FilterPanels = function () {
|
|
12366
|
-
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;
|
|
12367
12346
|
// Handle close filter section
|
|
12368
12347
|
var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
|
|
12369
|
-
|
|
12348
|
+
usePanelPosition({
|
|
12370
12349
|
selectedFilter: selectedFilter,
|
|
12371
12350
|
panelRef: panelRef,
|
|
12372
12351
|
filtersRef: filtersRef,
|
|
12373
12352
|
buttonRefs: buttonRefs,
|
|
12374
|
-
|
|
12375
|
-
tabs: tabs,
|
|
12376
|
-
}), left = _b.left, top = _b.top;
|
|
12353
|
+
});
|
|
12377
12354
|
var renderContent = function () {
|
|
12378
12355
|
switch (selectedFilter) {
|
|
12379
12356
|
case FilterSections.CALENDAR:
|
|
@@ -12388,7 +12365,7 @@ var FilterPanels = function () {
|
|
|
12388
12365
|
return null;
|
|
12389
12366
|
}
|
|
12390
12367
|
};
|
|
12391
|
-
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())));
|
|
12392
12369
|
};
|
|
12393
12370
|
|
|
12394
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";
|
|
@@ -12397,7 +12374,7 @@ styleInject(css_248z$4);
|
|
|
12397
12374
|
var FilterControls = function () {
|
|
12398
12375
|
var _a;
|
|
12399
12376
|
var t = useTranslation('filterBar').t;
|
|
12400
|
-
var _b = useFilterBar(), calendarRange = _b.calendarRange, selectedFilter = _b.selectedFilter, selectedPath = _b.selectedPath, ageCategoryCounts = _b.ageCategoryCounts, selectedLocations = _b.selectedLocations, mode = _b.mode,
|
|
12377
|
+
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;
|
|
12401
12378
|
// Store previously focused button and restore focus when closing
|
|
12402
12379
|
React.useEffect(function () {
|
|
12403
12380
|
if (!selectedFilter && previouslyFocusedButtonRef.current) {
|
|
@@ -12421,9 +12398,6 @@ var FilterControls = function () {
|
|
|
12421
12398
|
});
|
|
12422
12399
|
return (React.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light', " ").concat(selectedFilter ? 'disabled' : ''), ref: function (el) {
|
|
12423
12400
|
filtersRef.current = el;
|
|
12424
|
-
if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
|
|
12425
|
-
tabsRef.current = el;
|
|
12426
|
-
}
|
|
12427
12401
|
} },
|
|
12428
12402
|
!!((_a = locations === null || locations === void 0 ? void 0 : locations.data) === null || _a === void 0 ? void 0 : _a.length) && locations.data.length > 1 && (React.createElement(React.Fragment, null,
|
|
12429
12403
|
React.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
|
|
@@ -12453,7 +12427,7 @@ styleInject(css_248z$3);
|
|
|
12453
12427
|
|
|
12454
12428
|
var FilterTabs = function () {
|
|
12455
12429
|
var t = useTranslation('filterBar').t;
|
|
12456
|
-
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs,
|
|
12430
|
+
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters;
|
|
12457
12431
|
var sortedTabs = React.useMemo(function () { return __spreadArray$1([], __read((tabs !== null && tabs !== void 0 ? tabs : [])), false).sort(function (a, b) { return a.order - b.order; }); }, [tabs]);
|
|
12458
12432
|
var handleTabClick = function (path) {
|
|
12459
12433
|
setSelectedPath(path);
|
|
@@ -12462,7 +12436,7 @@ var FilterTabs = function () {
|
|
|
12462
12436
|
};
|
|
12463
12437
|
if (sortedTabs.length <= 1)
|
|
12464
12438
|
return null;
|
|
12465
|
-
return (React.createElement("div", { className: "will-filter-bar-tabs"
|
|
12439
|
+
return (React.createElement("div", { className: "will-filter-bar-tabs" }, sortedTabs.map(function (tab) { return (React.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 })); })));
|
|
12466
12440
|
};
|
|
12467
12441
|
|
|
12468
12442
|
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";
|
|
@@ -12604,7 +12578,6 @@ var useFilterCalendar = function (_a) {
|
|
|
12604
12578
|
var Footer = function (_a) {
|
|
12605
12579
|
var calendarHasError = _a.calendarHasError, calendarRange = _a.calendarRange, handleClearDates = _a.handleClearDates, language = _a.language, palette = _a.palette;
|
|
12606
12580
|
var t = useTranslation().t;
|
|
12607
|
-
reactResponsiveExports.useMediaQuery({ maxWidth: 600 });
|
|
12608
12581
|
var nights = nightsCount({
|
|
12609
12582
|
calendarRange: calendarRange,
|
|
12610
12583
|
});
|