UNPKG

dgz-ui

Version:

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

2 lines (1 loc) 3.13 kB
"use strict";const a=require("./jsx-runtime-DUiatUiq.cjs"),A=require("react"),O=require("./index-Ch6ABCiC.cjs"),T=require("./index-DcWZbXs6.cjs"),_=require("./index-C1ZpNc2P.cjs"),I=require("./index-t1JFNXJ1.cjs"),C=require("./index-CMmIsz5H.cjs");function D(e){const r=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(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const s=D(A);var f="Collapsible",[M,H]=T.createContextScope(f),[k,g]=M(f),w=s.forwardRef((e,r)=>{const{__scopeCollapsible:t,open:n,defaultOpen:o,disabled:c,onOpenChange:l,...b}=e,[u,p]=_.useControllableState({prop:n,defaultProp:o??!1,onChange:l,caller:f});return a.jsxRuntimeExports.jsx(k,{scope:t,disabled:c,contentId:_.useId(),open:u,onOpenToggle:s.useCallback(()=>p(x=>!x),[p]),children:a.jsxRuntimeExports.jsx(C.Primitive.div,{"data-state":v(u),"data-disabled":c?"":void 0,...b,ref:r})})});w.displayName=f;var S="CollapsibleTrigger",$=s.forwardRef((e,r)=>{const{__scopeCollapsible:t,...n}=e,o=g(S,t);return a.jsxRuntimeExports.jsx(C.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":v(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:r,onClick:O.composeEventHandlers(e.onClick,o.onOpenToggle)})});$.displayName=S;var R="CollapsibleContent",q=s.forwardRef((e,r)=>{const{forceMount:t,...n}=e,o=g(R,e.__scopeCollapsible);return a.jsxRuntimeExports.jsx(O.Presence,{present:t||o.open,children:({present:c})=>a.jsxRuntimeExports.jsx(L,{...n,ref:r,present:c})})});q.displayName=R;var L=s.forwardRef((e,r)=>{const{__scopeCollapsible:t,present:n,children:o,...c}=e,l=g(R,t),[b,u]=s.useState(n),p=s.useRef(null),x=I.useComposedRefs(r,p),j=s.useRef(0),h=j.current,E=s.useRef(0),y=E.current,m=l.open||b,P=s.useRef(m),d=s.useRef(void 0);return s.useEffect(()=>{const i=requestAnimationFrame(()=>P.current=!1);return()=>cancelAnimationFrame(i)},[]),T.useLayoutEffect2(()=>{const i=p.current;if(i){d.current=d.current||{transitionDuration:i.style.transitionDuration,animationName:i.style.animationName},i.style.transitionDuration="0s",i.style.animationName="none";const N=i.getBoundingClientRect();j.current=N.height,E.current=N.width,P.current||(i.style.transitionDuration=d.current.transitionDuration,i.style.animationName=d.current.animationName),u(n)}},[l.open,n]),a.jsxRuntimeExports.jsx(C.Primitive.div,{"data-state":v(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!m,...c,ref:x,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:m&&o})});function v(e){return e?"open":"closed"}var F=w;function B({...e}){return a.jsxRuntimeExports.jsx(F,{"data-slot":"collapsible",...e})}function G({...e}){return a.jsxRuntimeExports.jsx($,{"data-slot":"collapsible-trigger",...e})}function z({...e}){return a.jsxRuntimeExports.jsx(q,{"data-slot":"collapsible-content",...e})}exports.Collapsible=B;exports.CollapsibleContent=z;exports.CollapsibleTrigger=G;