willba-component-library 0.4.3 → 0.4.5
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/hooks/index.d.ts +1 -1
- package/lib/components/FilterBar/hooks/useFilterRefs.d.ts +1 -2
- package/lib/components/FilterBar/hooks/useIsMobile.d.ts +1 -0
- package/lib/components/FilterBar/hooks/usePanelPosition.d.ts +2 -3
- 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 +40 -39
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +40 -39
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -3137,25 +3137,21 @@ var Pages;
|
|
|
3137
3137
|
Pages["SALES"] = "/sales";
|
|
3138
3138
|
})(Pages || (Pages = {}));
|
|
3139
3139
|
|
|
3140
|
-
var
|
|
3141
|
-
|
|
3142
|
-
var
|
|
3143
|
-
|
|
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];
|
|
3144
3145
|
useEffect(function () {
|
|
3145
|
-
if (typeof window
|
|
3146
|
-
setIsMobile(false);
|
|
3146
|
+
if (typeof window === 'undefined')
|
|
3147
3147
|
return;
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
});
|
|
3156
|
-
}
|
|
3157
|
-
}, [selectedFilter]);
|
|
3158
|
-
return { isMobile: isMobile, tabsRef: tabsRef };
|
|
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;
|
|
3159
3155
|
};
|
|
3160
3156
|
|
|
3161
3157
|
var useFilterState = function (_a) {
|
|
@@ -6989,43 +6985,53 @@ var useFilterActions = function (_a) {
|
|
|
6989
6985
|
};
|
|
6990
6986
|
};
|
|
6991
6987
|
|
|
6992
|
-
var useFilterRefs = function (
|
|
6988
|
+
var useFilterRefs = function () {
|
|
6993
6989
|
var buttonRefs = useRef({});
|
|
6994
6990
|
var panelRef = useRef(null);
|
|
6995
6991
|
var previouslyFocusedButtonRef = useRef(null);
|
|
6996
6992
|
var filtersRef = useRef(null);
|
|
6997
|
-
var
|
|
6993
|
+
var isMobile = useIsMobile();
|
|
6998
6994
|
return {
|
|
6999
6995
|
previouslyFocusedButtonRef: previouslyFocusedButtonRef,
|
|
7000
6996
|
isMobile: isMobile,
|
|
7001
|
-
tabsRef: tabsRef,
|
|
7002
6997
|
panelRef: panelRef,
|
|
7003
6998
|
buttonRefs: buttonRefs,
|
|
7004
6999
|
filtersRef: filtersRef,
|
|
7005
7000
|
};
|
|
7006
7001
|
};
|
|
7007
7002
|
|
|
7003
|
+
var DESKTOP_PANEL_GAP = 10;
|
|
7008
7004
|
var usePanelPosition = function (_a) {
|
|
7009
|
-
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile
|
|
7005
|
+
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile;
|
|
7010
7006
|
var _b = __read(useState(), 2), left = _b[0], setLeft = _b[1];
|
|
7011
|
-
var
|
|
7012
|
-
var top = isMobile ? (hasMultipleTabs ? 60 : 0) : hasMultipleTabs ? 125 : 66;
|
|
7007
|
+
var _c = __read(useState(), 2), top = _c[0], setTop = _c[1];
|
|
7013
7008
|
useLayoutEffect(function () {
|
|
7014
|
-
if (!selectedFilter || typeof selectedFilter !== 'string'
|
|
7009
|
+
if (!selectedFilter || typeof selectedFilter !== 'string') {
|
|
7015
7010
|
setLeft(undefined);
|
|
7011
|
+
setTop(undefined);
|
|
7016
7012
|
return;
|
|
7017
7013
|
}
|
|
7014
|
+
var filters = filtersRef.current;
|
|
7015
|
+
if (!filters)
|
|
7016
|
+
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);
|
|
7022
|
+
return;
|
|
7023
|
+
}
|
|
7024
|
+
// Desktop: panel sits below the controls with a small breathing room.
|
|
7025
|
+
setTop(filters.offsetTop + filters.offsetHeight + DESKTOP_PANEL_GAP);
|
|
7018
7026
|
var panel = panelRef.current;
|
|
7019
|
-
var container = filtersRef.current;
|
|
7020
7027
|
var button = buttonRefs.current[selectedFilter];
|
|
7021
|
-
if (!panel || !
|
|
7028
|
+
if (!panel || !button)
|
|
7022
7029
|
return;
|
|
7023
7030
|
var panelRect = panel.getBoundingClientRect();
|
|
7024
|
-
var containerRect =
|
|
7031
|
+
var containerRect = filters.getBoundingClientRect();
|
|
7025
7032
|
var buttonRect = button.getBoundingClientRect();
|
|
7026
7033
|
var buttonLeft = buttonRect.left - containerRect.left - 10;
|
|
7027
|
-
|
|
7028
|
-
setLeft(newLeft);
|
|
7034
|
+
setLeft(Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width)));
|
|
7029
7035
|
}, [selectedFilter, isMobile]);
|
|
7030
7036
|
return { top: top, left: left };
|
|
7031
7037
|
};
|
|
@@ -7049,7 +7055,7 @@ var FilterBarProvider = function (_a) {
|
|
|
7049
7055
|
onSubmit: onSubmit,
|
|
7050
7056
|
setInnerLoading: setInnerLoading,
|
|
7051
7057
|
});
|
|
7052
|
-
var filterRefs = useFilterRefs(
|
|
7058
|
+
var filterRefs = useFilterRefs();
|
|
7053
7059
|
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
7060
|
selectedFilter,
|
|
7055
7061
|
ageCategoryCounts,
|
|
@@ -7070,7 +7076,6 @@ var FilterBarProvider = function (_a) {
|
|
|
7070
7076
|
outerLoading,
|
|
7071
7077
|
locations,
|
|
7072
7078
|
filterRefs.isMobile,
|
|
7073
|
-
filterRefs.tabsRef,
|
|
7074
7079
|
filterRefs.filtersRef,
|
|
7075
7080
|
]);
|
|
7076
7081
|
return (React__default.createElement(FilterBarContext.Provider, { value: contextValue }, children));
|
|
@@ -12343,7 +12348,7 @@ var css_248z$5 = ".will-filter-bar-panels {\n background-color: var(--will-whit
|
|
|
12343
12348
|
styleInject(css_248z$5);
|
|
12344
12349
|
|
|
12345
12350
|
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
|
|
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;
|
|
12347
12352
|
// Handle close filter section
|
|
12348
12353
|
var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
|
|
12349
12354
|
var _b = usePanelPosition({
|
|
@@ -12352,7 +12357,6 @@ var FilterPanels = function () {
|
|
|
12352
12357
|
filtersRef: filtersRef,
|
|
12353
12358
|
buttonRefs: buttonRefs,
|
|
12354
12359
|
isMobile: isMobile,
|
|
12355
|
-
tabs: tabs,
|
|
12356
12360
|
}), left = _b.left, top = _b.top;
|
|
12357
12361
|
var renderContent = function () {
|
|
12358
12362
|
switch (selectedFilter) {
|
|
@@ -12377,7 +12381,7 @@ styleInject(css_248z$4);
|
|
|
12377
12381
|
var FilterControls = function () {
|
|
12378
12382
|
var _a;
|
|
12379
12383
|
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,
|
|
12384
|
+
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
12385
|
// Store previously focused button and restore focus when closing
|
|
12382
12386
|
useEffect(function () {
|
|
12383
12387
|
if (!selectedFilter && previouslyFocusedButtonRef.current) {
|
|
@@ -12401,9 +12405,6 @@ var FilterControls = function () {
|
|
|
12401
12405
|
});
|
|
12402
12406
|
return (React__default.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light', " ").concat(selectedFilter ? 'disabled' : ''), ref: function (el) {
|
|
12403
12407
|
filtersRef.current = el;
|
|
12404
|
-
if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
|
|
12405
|
-
tabsRef.current = el;
|
|
12406
|
-
}
|
|
12407
12408
|
} },
|
|
12408
12409
|
!!((_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
12410
|
React__default.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
|
|
@@ -12433,7 +12434,7 @@ styleInject(css_248z$3);
|
|
|
12433
12434
|
|
|
12434
12435
|
var FilterTabs = function () {
|
|
12435
12436
|
var t = useTranslation('filterBar').t;
|
|
12436
|
-
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs,
|
|
12437
|
+
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters;
|
|
12437
12438
|
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
12439
|
var handleTabClick = function (path) {
|
|
12439
12440
|
setSelectedPath(path);
|
|
@@ -12442,7 +12443,7 @@ var FilterTabs = function () {
|
|
|
12442
12443
|
};
|
|
12443
12444
|
if (sortedTabs.length <= 1)
|
|
12444
12445
|
return null;
|
|
12445
|
-
return (React__default.createElement("div", { className: "will-filter-bar-tabs"
|
|
12446
|
+
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
12447
|
};
|
|
12447
12448
|
|
|
12448
12449
|
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";
|