willba-component-library 0.3.20 → 0.3.21
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/components/FilterPanels/Locations/Locations.d.ts +0 -1
- package/lib/components/FilterBar/components/FilterTabs/FilterTabs.d.ts +1 -1
- package/lib/components/FilterBar/hooks/index.d.ts +1 -1
- package/lib/components/FilterBar/hooks/useFilterRefs.d.ts +8 -0
- package/lib/index.esm.js +26 -28
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26 -28
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +26 -28
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +1 -2
- package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +1 -1
- package/src/components/FilterBar/components/FilterPanels/Dates/Dates.css +7 -1
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +0 -1
- package/src/components/FilterBar/components/FilterPanels/Guests/Guests.css +2 -1
- package/src/components/FilterBar/components/FilterPanels/Locations/Locations.tsx +1 -3
- package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.css +5 -1
- package/src/components/FilterBar/components/FilterTabs/FilterTabs.tsx +26 -23
- package/src/components/FilterBar/components/ImageCard/ImageCard.css +7 -1
- package/src/components/FilterBar/hooks/index.ts +1 -1
- package/src/components/FilterBar/hooks/{useFilterUi.tsx → useFilterRefs.tsx} +1 -1
- package/src/components/FilterBar/hooks/usePanelPosition.tsx +1 -1
- package/src/components/FilterBar/providers/FilterBarProvider.tsx +6 -6
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ ReactDOM.render(<App />, document.querySelector('#app'))
|
|
|
107
107
|
|
|
108
108
|
<script src="https://unpkg.com/react@18.3.1/umd/react.production.min.js"></script>
|
|
109
109
|
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js"></script>
|
|
110
|
-
<script src="https://cdn.jsdelivr.net/npm/willba-component-library@0.3.
|
|
110
|
+
<script src="https://cdn.jsdelivr.net/npm/willba-component-library@0.3.21/lib/index.umd.js"></script>
|
|
111
111
|
|
|
112
112
|
<script>
|
|
113
113
|
const renderFilterBar = async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useScrollInToView } from './useScrollInToView';
|
|
2
2
|
export { useFilterState } from './useFilterState';
|
|
3
3
|
export { useFilterActions } from './useFilterActions';
|
|
4
|
-
export {
|
|
4
|
+
export { useFilterRefs } from './useFilterRefs';
|
|
5
5
|
export { usePanelPosition } from './usePanelPosition';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useFilterRefs: (selectedFilter: string | boolean) => {
|
|
2
|
+
previouslyFocusedButtonRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
3
|
+
isMobile: boolean;
|
|
4
|
+
tabsRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
5
|
+
panelRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
6
|
+
buttonRefs: import("react").MutableRefObject<Record<string, HTMLButtonElement | null>>;
|
|
7
|
+
filtersRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
8
|
+
};
|
package/lib/index.esm.js
CHANGED
|
@@ -6811,7 +6811,7 @@ var useFilterActions = function (_a) {
|
|
|
6811
6811
|
};
|
|
6812
6812
|
};
|
|
6813
6813
|
|
|
6814
|
-
var
|
|
6814
|
+
var useFilterRefs = function (selectedFilter) {
|
|
6815
6815
|
var buttonRefs = useRef({});
|
|
6816
6816
|
var panelRef = useRef(null);
|
|
6817
6817
|
var previouslyFocusedButtonRef = useRef(null);
|
|
@@ -6843,7 +6843,7 @@ var usePanelPosition = function (_a) {
|
|
|
6843
6843
|
var panelRect = panel.getBoundingClientRect();
|
|
6844
6844
|
var containerRect = container.getBoundingClientRect();
|
|
6845
6845
|
var buttonRect = button.getBoundingClientRect();
|
|
6846
|
-
var buttonLeft = buttonRect.left - containerRect.left;
|
|
6846
|
+
var buttonLeft = buttonRect.left - containerRect.left - 30; // Offset by 30px to account for controls section spacing
|
|
6847
6847
|
var left = Math.max(0, Math.min(buttonLeft, containerRect.width - panelRect.width));
|
|
6848
6848
|
setLocalStyles({ left: left });
|
|
6849
6849
|
}, [selectedFilter, isMobile]);
|
|
@@ -6869,8 +6869,8 @@ var FilterBarProvider = function (_a) {
|
|
|
6869
6869
|
onSubmit: onSubmit,
|
|
6870
6870
|
setInnerLoading: setInnerLoading,
|
|
6871
6871
|
});
|
|
6872
|
-
var
|
|
6873
|
-
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 }),
|
|
6872
|
+
var filterRefs = useFilterRefs(selectedFilter);
|
|
6873
|
+
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)); }, [
|
|
6874
6874
|
selectedFilter,
|
|
6875
6875
|
ageCategoryCounts,
|
|
6876
6876
|
categories,
|
|
@@ -6889,9 +6889,9 @@ var FilterBarProvider = function (_a) {
|
|
|
6889
6889
|
tabs,
|
|
6890
6890
|
outerLoading,
|
|
6891
6891
|
locations,
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6892
|
+
filterRefs.isMobile,
|
|
6893
|
+
filterRefs.tabsRef,
|
|
6894
|
+
filterRefs.filtersRef,
|
|
6895
6895
|
]);
|
|
6896
6896
|
return (React__default.createElement(FilterBarContext.Provider, { value: contextValue }, children));
|
|
6897
6897
|
};
|
|
@@ -11990,7 +11990,7 @@ var Calendar = forwardRef(function (_a, ref) {
|
|
|
11990
11990
|
React__default.createElement(IconsSvg, { fill: (palette === null || palette === void 0 ? void 0 : palette.primary) || 'inherit', size: 50, icon: "spinner" })))));
|
|
11991
11991
|
});
|
|
11992
11992
|
|
|
11993
|
-
var css_248z$c = ".will-filter-section-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px;\n}\n\n.will-filter-section-title {\n font-size: 22px;\n margin: 0;\n}\n\n.will-filter-section-action {\n display: flex;\n gap: 8px;\n align-items: center;\n}\n\n.will-filter-section-action .will-filter-bar-close-button {\n position: relative;\n top: auto;\n right: auto;\n margin: 0;\n}\n\n@media (max-width: 960px) {\n .will-filter-section-title {\n font-size: 18px;\n }\n}\n";
|
|
11993
|
+
var css_248z$c = ".will-filter-section-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px 30px;\n}\n\n.will-filter-section-title {\n font-size: 22px;\n margin: 0;\n}\n\n.will-filter-section-action {\n display: flex;\n gap: 8px;\n align-items: center;\n}\n\n.will-filter-section-action .will-filter-bar-close-button {\n position: relative;\n top: auto;\n right: auto;\n margin: 0;\n}\n\n@media (max-width: 960px) {\n .will-filter-section-header {\n padding: 16px 20px;\n }\n\n .will-filter-section-title {\n font-size: 18px;\n }\n}\n";
|
|
11994
11994
|
styleInject(css_248z$c);
|
|
11995
11995
|
|
|
11996
11996
|
var SectionHeader = function (_a) {
|
|
@@ -12000,7 +12000,7 @@ var SectionHeader = function (_a) {
|
|
|
12000
12000
|
action && React__default.createElement("div", { className: "will-filter-section-action" }, action)));
|
|
12001
12001
|
};
|
|
12002
12002
|
|
|
12003
|
-
var css_248z$b = ".will-dates-filter-container {\n padding: 0 16px 16px
|
|
12003
|
+
var css_248z$b = ".will-dates-filter-container {\n padding: 0 30px 16px 30px;\n}\n\n@media (max-width: 960px) {\n .will-dates-filter-container {\n padding: 0 20px 16px 20px;\n }\n}\n";
|
|
12004
12004
|
styleInject(css_248z$b);
|
|
12005
12005
|
|
|
12006
12006
|
var Dates = forwardRef(function (_a, ref) {
|
|
@@ -12046,7 +12046,7 @@ var GuestCount = function (_a) {
|
|
|
12046
12046
|
React__default.createElement("path", { d: "M10 4V16M4 10H16", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }))))));
|
|
12047
12047
|
};
|
|
12048
12048
|
|
|
12049
|
-
var css_248z$9 = "#will-filter-bar-guests {\n text-align: initial;\n}\n\n.will-guests-filter-container {\n display: flex;\n flex-direction: column;\n min-width: 400px;\n gap: 20px;\n padding: 0
|
|
12049
|
+
var css_248z$9 = "#will-filter-bar-guests {\n text-align: initial;\n}\n\n.will-guests-filter-container {\n display: flex;\n flex-direction: column;\n min-width: 400px;\n gap: 20px;\n padding: 0 30px 16px 30px;\n}\n\n@media (max-width: 960px) {\n .will-guests-filter-container {\n min-width: auto;\n padding: 0 20px 16px 20px;\n }\n}\n\n/**/\n.will-guest-count {\n display: inline-block;\n min-width: 10px;\n}\n";
|
|
12050
12050
|
styleInject(css_248z$9);
|
|
12051
12051
|
|
|
12052
12052
|
var Guests = forwardRef(function (_a, ref) {
|
|
@@ -12059,7 +12059,7 @@ var Guests = forwardRef(function (_a, ref) {
|
|
|
12059
12059
|
});
|
|
12060
12060
|
Guests.displayName = 'Guests';
|
|
12061
12061
|
|
|
12062
|
-
var css_248z$8 = ".will-image-card {\n display: flex;\n gap: 20px;\n justify-content: space-between;\n align-items: center;\n padding: 8px
|
|
12062
|
+
var css_248z$8 = ".will-image-card {\n display: flex;\n gap: 20px;\n justify-content: space-between;\n align-items: center;\n padding: 8px 30px;\n cursor: pointer;\n user-select: none;\n min-height: 40px;\n}\n\n.will-image-card.is-selected {\n background-color: var(--will-transparent-lavender);\n}\n\n.will-image-card:hover {\n background-color: var(--will-transparent-lavender);\n}\n\n.will-image-card-image img {\n width: 120px;\n height: 68px;\n object-fit: cover;\n}\n\n@media (max-width: 960px) {\n .will-image-card {\n padding: 8px 20px;\n }\n}\n";
|
|
12063
12063
|
styleInject(css_248z$8);
|
|
12064
12064
|
|
|
12065
12065
|
var ImageCard = forwardRef(function (_a, ref) {
|
|
@@ -12082,7 +12082,7 @@ var css_248z$7 = "#will-filter-bar-locations {\n text-align: initial;\n}\n\n.wi
|
|
|
12082
12082
|
styleInject(css_248z$7);
|
|
12083
12083
|
|
|
12084
12084
|
var Locations = forwardRef(function (_a, ref) {
|
|
12085
|
-
var locations = _a.locations,
|
|
12085
|
+
var locations = _a.locations, selectedLocations = _a.selectedLocations, setSelectedLocations = _a.setSelectedLocations, autoFocus = _a.autoFocus, _b = _a.multiSelect, multiSelect = _b === void 0 ? false : _b, onClose = _a.onClose;
|
|
12086
12086
|
var t = useTranslation('filterBar').t;
|
|
12087
12087
|
var firstCardRef = useRef(null);
|
|
12088
12088
|
useEffect(function () {
|
|
@@ -12111,7 +12111,7 @@ var Locations = forwardRef(function (_a, ref) {
|
|
|
12111
12111
|
};
|
|
12112
12112
|
return (React__default.createElement("div", { id: "will-filter-bar-locations", ref: ref },
|
|
12113
12113
|
React__default.createElement(SectionHeader, { title: t('locations.title'), action: onClose && React__default.createElement(CloseButton, { handleClose: onClose }) }),
|
|
12114
|
-
React__default.createElement("div", { className: "will-locations-filter-container" }, !!(
|
|
12114
|
+
React__default.createElement("div", { className: "will-locations-filter-container" }, !!(locations === null || locations === void 0 ? void 0 : locations.length) &&
|
|
12115
12115
|
locations.map(function (location, index) {
|
|
12116
12116
|
return (React__default.createElement(ImageCard, { key: location.id, ref: index === 0 ? firstCardRef : null, title: location.label, description: location.description, imageUrl: location.imageUrl, isSelected: selectedLocations.some(function (loc) { return loc.id === location.id; }), onClick: function () { return handleLocationClick(location); } }));
|
|
12117
12117
|
}))));
|
|
@@ -12166,7 +12166,7 @@ var FilterPanels = function () {
|
|
|
12166
12166
|
case FilterSections.CATEGORIES:
|
|
12167
12167
|
return (React__default.createElement(Categories, { categories: categories, setCategories: setCategories }));
|
|
12168
12168
|
case FilterSections.LOCATIONS:
|
|
12169
|
-
return (React__default.createElement(Locations, { autoFocus: true, ref: filterSectionRef, locations: locations === null || locations === void 0 ? void 0 : locations.data,
|
|
12169
|
+
return (React__default.createElement(Locations, { autoFocus: true, ref: filterSectionRef, locations: locations === null || locations === void 0 ? void 0 : locations.data, selectedLocations: selectedLocations, setSelectedLocations: setSelectedLocations, multiSelect: locations === null || locations === void 0 ? void 0 : locations.multiSelect, onClose: function () { return handleSelectedFilter(false); } }));
|
|
12170
12170
|
default:
|
|
12171
12171
|
return null;
|
|
12172
12172
|
}
|
|
@@ -12208,7 +12208,7 @@ var FilterControls = function () {
|
|
|
12208
12208
|
tabsRef.current = el;
|
|
12209
12209
|
}
|
|
12210
12210
|
} },
|
|
12211
|
-
|
|
12211
|
+
((_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,
|
|
12212
12212
|
React__default.createElement(SelectButton, { ref: function (el) { return (buttonRefs.current[FilterSections.LOCATIONS] = el); }, label: t('locations.label'), description: parsedLocations, onClick: function (e) {
|
|
12213
12213
|
previouslyFocusedButtonRef.current = e.currentTarget;
|
|
12214
12214
|
handleSelectedFilter(FilterSections.LOCATIONS);
|
|
@@ -12236,17 +12236,16 @@ styleInject(css_248z$3);
|
|
|
12236
12236
|
|
|
12237
12237
|
var FilterTabs = function () {
|
|
12238
12238
|
var t = useTranslation('filterBar').t;
|
|
12239
|
-
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
}, active: selectedPath === tab.path, mode: mode })); }))));
|
|
12239
|
+
var _a = useFilterBar(), selectedPath = _a.selectedPath, mode = _a.mode, tabs = _a.tabs, tabsRef = _a.tabsRef, handleSelectedFilter = _a.handleSelectedFilter, setSelectedPath = _a.setSelectedPath, handleResetFilters = _a.handleResetFilters;
|
|
12240
|
+
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]);
|
|
12241
|
+
var handleTabClick = function (path) {
|
|
12242
|
+
setSelectedPath(path);
|
|
12243
|
+
handleResetFilters();
|
|
12244
|
+
handleSelectedFilter(false);
|
|
12245
|
+
};
|
|
12246
|
+
if (sortedTabs.length <= 1)
|
|
12247
|
+
return null;
|
|
12248
|
+
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 })); })));
|
|
12250
12249
|
};
|
|
12251
12250
|
|
|
12252
12251
|
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";
|
|
@@ -12256,7 +12255,7 @@ var css_248z$1 = ".will-root {\n z-index: 999;\n width: fit-content;\n min-wi
|
|
|
12256
12255
|
styleInject(css_248z$1);
|
|
12257
12256
|
|
|
12258
12257
|
var FilterBar = function (_a) {
|
|
12259
|
-
var
|
|
12258
|
+
var language = _a.language, ageCategories = _a.ageCategories, _b = _a.redirectUrl, redirectUrl = _b === void 0 ? REDIRECT_URL_FALLBACK : _b, palette = _a.palette, onSubmit = _a.onSubmit, fullWidth = _a.fullWidth, disableCalendarDates = _a.disableCalendarDates, mode = _a.mode, tabs = _a.tabs, outerLoading = _a.outerLoading, locations = _a.locations;
|
|
12260
12259
|
var themePalette = useTheme({ palette: palette });
|
|
12261
12260
|
// Translations
|
|
12262
12261
|
useUpdateTranslations({ language: language });
|
|
@@ -12270,7 +12269,6 @@ var FilterBar = function (_a) {
|
|
|
12270
12269
|
};
|
|
12271
12270
|
////////////
|
|
12272
12271
|
var REDIRECT_URL_FALLBACK = 'http://localhost:3000/';
|
|
12273
|
-
var LANGUAGE_FALLBACK = 'en';
|
|
12274
12272
|
|
|
12275
12273
|
var useFilterCalendar = function (_a) {
|
|
12276
12274
|
var onSubmit = _a.onSubmit, setToggleCalendar = _a.setToggleCalendar, noActiveSelection = _a.noActiveSelection, toggleCalendar = _a.toggleCalendar, outerRangeContext = _a.outerRangeContext, outerDisableCalendarDates = _a.outerDisableCalendarDates;
|