willba-component-library 0.3.19 → 0.3.20
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 +1 -1
- package/lib/components/FilterBar/hooks/useFilterUi.d.ts +2 -1
- package/lib/components/FilterBar/hooks/usePanelPosition.d.ts +2 -2
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +1 -1
- package/lib/components/FilterBar/providers/FilterBarProvider.d.ts +3 -2
- package/lib/core/hooks/useCloseFilterSection.d.ts +1 -1
- package/lib/index.esm.js +36 -34
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +36 -34
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +36 -34
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +9 -5
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +10 -11
- package/src/components/FilterBar/components/FilterTabs/FilterTabs.tsx +2 -2
- package/src/components/FilterBar/hooks/useFilterUi.tsx +4 -2
- package/src/components/FilterBar/hooks/usePanelPosition.tsx +3 -3
- package/src/components/FilterBar/hooks/useScrollInToView.tsx +4 -4
- package/src/components/FilterBar/providers/FilterBarProvider.tsx +4 -2
- package/src/components/FilterCalendar/FilterCalendar.tsx +2 -2
- package/src/core/hooks/useCloseFilterSection.tsx +5 -5
package/lib/index.js
CHANGED
|
@@ -2899,11 +2899,11 @@ var useUpdateTranslations = function (_a) {
|
|
|
2899
2899
|
// TODO - Refactor and rename this hook
|
|
2900
2900
|
var useCloseFilterSection = function (_a) {
|
|
2901
2901
|
var handleSelectedFilter = _a.handleSelectedFilter;
|
|
2902
|
-
var
|
|
2902
|
+
var filterSectionRef = React.useRef(null);
|
|
2903
2903
|
React.useEffect(function () {
|
|
2904
2904
|
var handleClickOutside = function (event) {
|
|
2905
|
-
if (
|
|
2906
|
-
!
|
|
2905
|
+
if (filterSectionRef.current &&
|
|
2906
|
+
!filterSectionRef.current.contains(event.target)) {
|
|
2907
2907
|
handleSelectedFilter(false);
|
|
2908
2908
|
}
|
|
2909
2909
|
};
|
|
@@ -2911,8 +2911,8 @@ var useCloseFilterSection = function (_a) {
|
|
|
2911
2911
|
return function () {
|
|
2912
2912
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
2913
2913
|
};
|
|
2914
|
-
}, [
|
|
2915
|
-
return {
|
|
2914
|
+
}, [filterSectionRef]);
|
|
2915
|
+
return { filterSectionRef: filterSectionRef };
|
|
2916
2916
|
};
|
|
2917
2917
|
|
|
2918
2918
|
var useAutoFocus = function (autoFocus) {
|
|
@@ -2982,22 +2982,22 @@ var Pages;
|
|
|
2982
2982
|
var useScrollInToView = function (_a) {
|
|
2983
2983
|
var selectedFilter = _a.selectedFilter;
|
|
2984
2984
|
var _b = __read(React.useState(true), 2), isMobile = _b[0], setIsMobile = _b[1];
|
|
2985
|
-
var
|
|
2985
|
+
var tabsRef = React.useRef(null);
|
|
2986
2986
|
React.useEffect(function () {
|
|
2987
2987
|
if (typeof window !== 'undefined' && window.innerWidth > 960) {
|
|
2988
2988
|
setIsMobile(false);
|
|
2989
2989
|
return;
|
|
2990
2990
|
}
|
|
2991
|
-
if (
|
|
2991
|
+
if (tabsRef.current && selectedFilter) {
|
|
2992
2992
|
window.scrollTo({
|
|
2993
2993
|
behavior: 'smooth',
|
|
2994
|
-
top:
|
|
2994
|
+
top: tabsRef.current.getBoundingClientRect().top -
|
|
2995
2995
|
document.body.getBoundingClientRect().top -
|
|
2996
2996
|
30,
|
|
2997
2997
|
});
|
|
2998
2998
|
}
|
|
2999
2999
|
}, [selectedFilter]);
|
|
3000
|
-
return { isMobile: isMobile,
|
|
3000
|
+
return { isMobile: isMobile, tabsRef: tabsRef };
|
|
3001
3001
|
};
|
|
3002
3002
|
|
|
3003
3003
|
var useFilterState = function (_a) {
|
|
@@ -6835,18 +6835,20 @@ var useFilterUi = function (selectedFilter) {
|
|
|
6835
6835
|
var buttonRefs = React.useRef({});
|
|
6836
6836
|
var panelRef = React.useRef(null);
|
|
6837
6837
|
var previouslyFocusedButtonRef = React.useRef(null);
|
|
6838
|
-
var
|
|
6838
|
+
var filtersRef = React.useRef(null);
|
|
6839
|
+
var _a = useScrollInToView({ selectedFilter: selectedFilter }), isMobile = _a.isMobile, tabsRef = _a.tabsRef;
|
|
6839
6840
|
return {
|
|
6840
6841
|
previouslyFocusedButtonRef: previouslyFocusedButtonRef,
|
|
6841
6842
|
isMobile: isMobile,
|
|
6842
|
-
|
|
6843
|
+
tabsRef: tabsRef,
|
|
6843
6844
|
panelRef: panelRef,
|
|
6844
6845
|
buttonRefs: buttonRefs,
|
|
6846
|
+
filtersRef: filtersRef,
|
|
6845
6847
|
};
|
|
6846
6848
|
};
|
|
6847
6849
|
|
|
6848
6850
|
var usePanelPosition = function (_a) {
|
|
6849
|
-
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef,
|
|
6851
|
+
var selectedFilter = _a.selectedFilter, panelRef = _a.panelRef, filtersRef = _a.filtersRef, buttonRefs = _a.buttonRefs, isMobile = _a.isMobile;
|
|
6850
6852
|
var _b = __read(React.useState({}), 2), localStyles = _b[0], setLocalStyles = _b[1];
|
|
6851
6853
|
React.useLayoutEffect(function () {
|
|
6852
6854
|
if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
|
|
@@ -6854,7 +6856,7 @@ var usePanelPosition = function (_a) {
|
|
|
6854
6856
|
return;
|
|
6855
6857
|
}
|
|
6856
6858
|
var panel = panelRef.current;
|
|
6857
|
-
var container =
|
|
6859
|
+
var container = filtersRef.current;
|
|
6858
6860
|
var button = buttonRefs.current[selectedFilter];
|
|
6859
6861
|
if (!panel || !container || !button)
|
|
6860
6862
|
return;
|
|
@@ -6908,7 +6910,8 @@ var FilterBarProvider = function (_a) {
|
|
|
6908
6910
|
outerLoading,
|
|
6909
6911
|
locations,
|
|
6910
6912
|
filterUi.isMobile,
|
|
6911
|
-
filterUi.
|
|
6913
|
+
filterUi.tabsRef,
|
|
6914
|
+
filterUi.filtersRef,
|
|
6912
6915
|
]);
|
|
6913
6916
|
return (React.createElement(FilterBarContext.Provider, { value: contextValue }, children));
|
|
6914
6917
|
};
|
|
@@ -12164,33 +12167,31 @@ var css_248z$5 = ".will-filter-bar-panels {\n background-color: var(--will-whit
|
|
|
12164
12167
|
styleInject(css_248z$5);
|
|
12165
12168
|
|
|
12166
12169
|
var FilterPanels = function () {
|
|
12167
|
-
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,
|
|
12170
|
+
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;
|
|
12168
12171
|
// Handle close filter section
|
|
12169
|
-
var
|
|
12172
|
+
var filterSectionRef = useCloseFilterSection({ handleSelectedFilter: handleSelectedFilter }).filterSectionRef;
|
|
12170
12173
|
var localStyles = usePanelPosition({
|
|
12171
12174
|
selectedFilter: selectedFilter,
|
|
12172
12175
|
panelRef: panelRef,
|
|
12173
|
-
|
|
12176
|
+
filtersRef: filtersRef,
|
|
12174
12177
|
buttonRefs: buttonRefs,
|
|
12175
12178
|
isMobile: isMobile,
|
|
12176
12179
|
}).localStyles;
|
|
12177
12180
|
var renderContent = function () {
|
|
12178
12181
|
switch (selectedFilter) {
|
|
12179
12182
|
case FilterSections.CALENDAR:
|
|
12180
|
-
return (React.createElement(Dates, { autoFocus: true, ref:
|
|
12183
|
+
return (React.createElement(Dates, { autoFocus: true, ref: filterSectionRef, onClose: function () { return handleSelectedFilter(false); }, calendarRange: calendarRange, setCalendarRange: setCalendarRange, disableCalendarDates: disableCalendarDates, selectedPath: selectedPath, language: language }));
|
|
12181
12184
|
case FilterSections.GUESTS:
|
|
12182
|
-
return (React.createElement(Guests, { autoFocus: true, ref:
|
|
12185
|
+
return (React.createElement(Guests, { autoFocus: true, ref: filterSectionRef, ageCategories: ageCategories, ageCategoryCounts: ageCategoryCounts, updateGuestsCount: updateGuestsCount, onClose: function () { return handleSelectedFilter(false); } }));
|
|
12183
12186
|
case FilterSections.CATEGORIES:
|
|
12184
12187
|
return (React.createElement(Categories, { categories: categories, setCategories: setCategories }));
|
|
12185
12188
|
case FilterSections.LOCATIONS:
|
|
12186
|
-
return (React.createElement(Locations, { autoFocus: true, ref:
|
|
12189
|
+
return (React.createElement(Locations, { autoFocus: true, ref: filterSectionRef, locations: locations === null || locations === void 0 ? void 0 : locations.data, language: language, selectedLocations: selectedLocations, setSelectedLocations: setSelectedLocations, multiSelect: locations === null || locations === void 0 ? void 0 : locations.multiSelect, onClose: function () { return handleSelectedFilter(false); } }));
|
|
12187
12190
|
default:
|
|
12188
12191
|
return null;
|
|
12189
12192
|
}
|
|
12190
12193
|
};
|
|
12191
|
-
return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: (!tabs || tabs.length < 2) && !isMobile
|
|
12192
|
-
? { top: 66 }
|
|
12193
|
-
: __assign$2({}, localStyles) }, renderContent())));
|
|
12194
|
+
return (selectedFilter && (React.createElement("div", { ref: panelRef, className: "will-filter-bar-panels ".concat(mode || 'light'), style: __assign$2(__assign$2({}, localStyles), ((!tabs || tabs.length < 2) && !isMobile ? { top: 66 } : {})) }, renderContent())));
|
|
12194
12195
|
};
|
|
12195
12196
|
|
|
12196
12197
|
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";
|
|
@@ -12199,11 +12200,7 @@ styleInject(css_248z$4);
|
|
|
12199
12200
|
var FilterControls = function () {
|
|
12200
12201
|
var _a;
|
|
12201
12202
|
var t = useTranslation('filterBar').t;
|
|
12202
|
-
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,
|
|
12203
|
-
// Refs
|
|
12204
|
-
previouslyFocusedButtonRef = _b.previouslyFocusedButtonRef, buttonRefs = _b.buttonRefs,
|
|
12205
|
-
//
|
|
12206
|
-
targetFilterBarRef = _b.targetFilterBarRef;
|
|
12203
|
+
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;
|
|
12207
12204
|
// Store previously focused button and restore focus when closing
|
|
12208
12205
|
React.useEffect(function () {
|
|
12209
12206
|
if (!selectedFilter && previouslyFocusedButtonRef.current) {
|
|
@@ -12225,7 +12222,12 @@ var FilterControls = function () {
|
|
|
12225
12222
|
locationsPlaceholder: t('locations.placeholder'),
|
|
12226
12223
|
locationsSelectedLabel: t('locations.selected'),
|
|
12227
12224
|
});
|
|
12228
|
-
return (React.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light'), ref: (
|
|
12225
|
+
return (React.createElement("div", { className: "will-filter-bar-controls ".concat(mode || 'light'), ref: function (el) {
|
|
12226
|
+
filtersRef.current = el;
|
|
12227
|
+
if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) === 1) {
|
|
12228
|
+
tabsRef.current = el;
|
|
12229
|
+
}
|
|
12230
|
+
} },
|
|
12229
12231
|
!!((_a = locations === null || locations === void 0 ? void 0 : locations.data) === null || _a === void 0 ? void 0 : _a.length) && (React.createElement(React.Fragment, null,
|
|
12230
12232
|
React.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
|
|
12231
12233
|
previouslyFocusedButtonRef.current = e.currentTarget;
|
|
@@ -12256,9 +12258,9 @@ var FilterTabs = function () {
|
|
|
12256
12258
|
var t = useTranslation('filterBar').t;
|
|
12257
12259
|
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters,
|
|
12258
12260
|
//
|
|
12259
|
-
|
|
12261
|
+
tabsRef = _a.tabsRef;
|
|
12260
12262
|
return (tabs &&
|
|
12261
|
-
tabs.length > 1 && (React.createElement("div", { className: "will-filter-bar-tabs", ref:
|
|
12263
|
+
tabs.length > 1 && (React.createElement("div", { className: "will-filter-bar-tabs", ref: tabsRef }, tabs
|
|
12262
12264
|
.sort(function (a, b) { return a.order - b.order; })
|
|
12263
12265
|
.map(function (tab, idx) { return (React.createElement(TabButton, { key: "tab-".concat(idx), label: tab.label || t("tabs.".concat(tab.path.substring(1))), onClick: function () {
|
|
12264
12266
|
setSelectedPath(tab.path);
|
|
@@ -12463,10 +12465,10 @@ function FilterCalendar(_a) {
|
|
|
12463
12465
|
// Display component after fully loaded
|
|
12464
12466
|
useAwaitRender();
|
|
12465
12467
|
// Handle close filter section
|
|
12466
|
-
var
|
|
12468
|
+
var filterSectionRef = useCloseFilterSection({
|
|
12467
12469
|
handleSelectedFilter: setToggleCalendar,
|
|
12468
|
-
}).
|
|
12469
|
-
return (React.createElement("div", { className: "will-root", style: themePalette }, toggleCalendar && (React.createElement("div", { className: "will-calendar-wrapper", ref:
|
|
12470
|
+
}).filterSectionRef;
|
|
12471
|
+
return (React.createElement("div", { className: "will-root", style: themePalette }, toggleCalendar && (React.createElement("div", { className: "will-calendar-wrapper", ref: filterSectionRef },
|
|
12470
12472
|
React.createElement("div", { className: "will-calendar-header" },
|
|
12471
12473
|
React.createElement("h2", null, t('filterBar:calendar.title')),
|
|
12472
12474
|
React.createElement(CloseButton, { handleClose: function () { return setToggleCalendar(false); } })),
|