UNPKG

dgz-ui

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript

3 lines (2 loc) 2.87 kB
"use strict";const A=require("react"),c=require("./index-D9zW9Tk7.cjs.js"),S=require("./index-BruMW80s.cjs.js"),I=require("./index-pQxT4IlV.cjs.js"),q=require("./index-jFOWwfD3.cjs.js"),d=require("react/jsx-runtime");function M(e){if(e&&e.__esModule)return e;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return i.default=e,Object.freeze(i)}const r=M(A);var b="Collapsible",[D,$]=c.createContextScope(b),[k,v]=D(b),w=r.forwardRef((e,i)=>{const{__scopeCollapsible:t,open:n,defaultOpen:o,disabled:l,onOpenChange:a,...C}=e,[u,p]=S.useControllableState({prop:n,defaultProp:o??!1,onChange:a,caller:b});return d.jsx(k,{scope:t,disabled:l,contentId:S.useId(),open:u,onOpenToggle:r.useCallback(()=>p(g=>!g),[p]),children:d.jsx(c.Primitive.div,{"data-state":y(u),"data-disabled":l?"":void 0,...C,ref:i})})});w.displayName=b;var E="CollapsibleTrigger",x=r.forwardRef((e,i)=>{const{__scopeCollapsible:t,...n}=e,o=v(E,t);return d.jsx(c.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":y(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:i,onClick:c.composeEventHandlers(e.onClick,o.onOpenToggle)})});x.displayName=E;var R="CollapsibleContent",h=r.forwardRef((e,i)=>{const{forceMount:t,...n}=e,o=v(R,e.__scopeCollapsible);return d.jsx(c.Presence,{present:t||o.open,children:({present:l})=>d.jsx(L,{...n,ref:i,present:l})})});h.displayName=R;var L=r.forwardRef((e,i)=>{const{__scopeCollapsible:t,present:n,children:o,...l}=e,a=v(R,t),[C,u]=r.useState(n),p=r.useRef(null),g=q.useComposedRefs(i,p),P=r.useRef(0),_=P.current,N=r.useRef(0),O=N.current,m=a.open||C,j=r.useRef(m),f=r.useRef(void 0);return r.useEffect(()=>{const s=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(s)},[]),I.useLayoutEffect2(()=>{const s=p.current;if(s){f.current=f.current||{transitionDuration:s.style.transitionDuration,animationName:s.style.animationName},s.style.transitionDuration="0s",s.style.animationName="none";const T=s.getBoundingClientRect();P.current=T.height,N.current=T.width,j.current||(s.style.transitionDuration=f.current.transitionDuration,s.style.animationName=f.current.animationName),u(n)}},[a.open,n]),d.jsx(c.Primitive.div,{"data-state":y(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!m,...l,ref:g,style:{"--radix-collapsible-content-height":_?`${_}px`:void 0,"--radix-collapsible-content-width":O?`${O}px`:void 0,...e.style},children:m&&o})});function y(e){return e?"open":"closed"}var F=w,B=x,G=h;exports.CollapsibleContent=h;exports.CollapsibleTrigger=x;exports.Content=G;exports.Root=F;exports.Trigger=B;exports.createCollapsibleScope=$; //# sourceMappingURL=index-CJ0fGifh.cjs.js.map