Files
klz-cables.com/.pnpm-store/v10/files/37/a56ed9f3db8c21f3c81ad43f6252435391a6c80d0b6a7f3f6fcb7913efb6851d085cbd2fa603ae260af7595d85b18eaa2b982f65e41ee7c44eaf1b6f1edab1
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

39 lines
1.2 KiB
Plaintext

import { jsx as _jsx } from "react/jsx-runtime";
import React, { createContext, use, useEffect, useRef } from 'react';
const ClickOutsideContext = /*#__PURE__*/createContext(null);
export const ClickOutsideProvider = ({
children
}) => {
const listeners = useRef(new Set());
useEffect(() => {
const handleClick = event => {
listeners.current.forEach(({
handler,
ref
}) => {
if (ref.current && !ref.current.contains(event.target)) {
handler();
}
});
};
document.addEventListener('mousedown', handleClick);
return () => document.removeEventListener('mousedown', handleClick);
}, []);
const register = listener => listeners.current.add(listener);
const unregister = listener => listeners.current.delete(listener);
return /*#__PURE__*/_jsx(ClickOutsideContext, {
value: {
register,
unregister
},
children: children
});
};
export const useClickOutsideContext = () => {
const context = use(ClickOutsideContext);
if (!context) {
throw new Error('useClickOutside must be used within a ClickOutsideProvider');
}
return context;
};
//# sourceMappingURL=index.js.map