carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 1.1 kB
JavaScript
import{jsx as e}from"react/jsx-runtime";import{createContext as t,useContext as n,useState as i,useRef as r}from"react";import o from"../../../__internal__/utils/logger/index.js";const s=t(null),u=()=>{const e=n(s);if(null===e)throw new Error("useResponsiveVerticalMenu must be used within a ResponsiveVerticalMenuProvider");return e};let l=!1;const c=({children:t,width:u,height:c})=>{const d=n(s);!l&&null!==d&&(l=!0,o.deprecate("`ResponsiveVerticalMenuProvider` is deprecated and no longer needed for `ResponsiveVerticalMenu`. You can use `ResponsiveVerticalMenu` directly without wrapping it in a provider."));const[a,p]=i(!1),[v,h]=i(null),m=r(null),M=r(null),f=r(null),[R,w]=i(!1),[g,V]=i(!1),[_,x]=i("auto"),[P,b]=i("auto");return e(s.Provider,{value:{active:a,activeMenuItem:v,buttonRef:m,containerRef:M,menuRef:f,reducedMotion:g,responsiveMode:R,left:_,top:P,width:u,height:c,setActive:p,setActiveMenuItem:h,setReducedMotion:V,setResponsiveMode:w,setLeft:x,setTop:b},children:t})};export{s as ResponsiveVerticalMenuContext,c as ResponsiveVerticalMenuProvider,u as useResponsiveVerticalMenu};