UNPKG

dgz-ui

Version:

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

117 lines (116 loc) 3.4 kB
import * as n from "react"; import { P as v, a as O, c as S, b as D } from "./index-BVqmUhu5.es.js"; import { u as M, a as L } from "./index-BdfbDt7y.es.js"; import { u as k } from "./index-Dt3MSLsk.es.js"; import { u as F } from "./index-DLcqcWxM.es.js"; import { jsx as c } from "react/jsx-runtime"; var f = "Collapsible", [B, K] = D(f), [G, g] = B(f), T = n.forwardRef( (e, s) => { const { __scopeCollapsible: r, open: a, defaultOpen: t, disabled: l, onOpenChange: i, ...m } = e, [p, d] = M({ prop: a, defaultProp: t ?? !1, onChange: i, caller: f }); return /* @__PURE__ */ c( G, { scope: r, disabled: l, contentId: L(), open: p, onOpenToggle: n.useCallback(() => d((C) => !C), [d]), children: /* @__PURE__ */ c( v.div, { "data-state": h(p), "data-disabled": l ? "" : void 0, ...m, ref: s } ) } ); } ); T.displayName = f; var w = "CollapsibleTrigger", A = n.forwardRef( (e, s) => { const { __scopeCollapsible: r, ...a } = e, t = g(w, r); return /* @__PURE__ */ c( v.button, { type: "button", "aria-controls": t.contentId, "aria-expanded": t.open || !1, "data-state": h(t.open), "data-disabled": t.disabled ? "" : void 0, disabled: t.disabled, ...a, ref: s, onClick: S(e.onClick, t.onOpenToggle) } ); } ); A.displayName = w; var R = "CollapsibleContent", I = n.forwardRef( (e, s) => { const { forceMount: r, ...a } = e, t = g(R, e.__scopeCollapsible); return /* @__PURE__ */ c(O, { present: r || t.open, children: ({ present: l }) => /* @__PURE__ */ c($, { ...a, ref: s, present: l }) }); } ); I.displayName = R; var $ = n.forwardRef((e, s) => { const { __scopeCollapsible: r, present: a, children: t, ...l } = e, i = g(R, r), [m, p] = n.useState(a), d = n.useRef(null), C = F(s, d), y = n.useRef(0), P = y.current, x = n.useRef(0), N = x.current, b = i.open || m, _ = n.useRef(b), u = n.useRef(void 0); return n.useEffect(() => { const o = requestAnimationFrame(() => _.current = !1); return () => cancelAnimationFrame(o); }, []), k(() => { const o = d.current; if (o) { u.current = u.current || { transitionDuration: o.style.transitionDuration, animationName: o.style.animationName }, o.style.transitionDuration = "0s", o.style.animationName = "none"; const E = o.getBoundingClientRect(); y.current = E.height, x.current = E.width, _.current || (o.style.transitionDuration = u.current.transitionDuration, o.style.animationName = u.current.animationName), p(a); } }, [i.open, a]), /* @__PURE__ */ c( v.div, { "data-state": h(i.open), "data-disabled": i.disabled ? "" : void 0, id: i.contentId, hidden: !b, ...l, ref: C, style: { "--radix-collapsible-content-height": P ? `${P}px` : void 0, "--radix-collapsible-content-width": N ? `${N}px` : void 0, ...e.style }, children: b && t } ); }); function h(e) { return e ? "open" : "closed"; } var Q = T, U = A, V = I; export { I as C, Q as R, U as T, A as a, V as b, K as c }; //# sourceMappingURL=index-CNbacFZ5.es.js.map