UNPKG

dgz-ui

Version:

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

84 lines (83 loc) 2.78 kB
import * as i from "react"; import { j as f } from "./jsx-runtime-C5mzlN2N.js"; function d(e, t) { if (typeof e == "function") return e(t); e != null && (e.current = t); } function m(...e) { return (t) => { let r = !1; const o = e.map((n) => { const l = d(n, t); return !r && typeof l == "function" && (r = !0), l; }); if (r) return () => { for (let n = 0; n < o.length; n++) { const l = o[n]; typeof l == "function" ? l() : d(e[n], null); } }; }; } function x(...e) { return i.useCallback(m(...e), e); } // @__NO_SIDE_EFFECTS__ function g(e) { const t = /* @__PURE__ */ C(e), r = i.forwardRef((o, n) => { const { children: l, ...a } = o, s = i.Children.toArray(l), c = s.find(E); if (c) { const u = c.props.children, S = s.map((p) => p === c ? i.Children.count(u) > 1 ? i.Children.only(null) : i.isValidElement(u) ? u.props.children : null : p); return /* @__PURE__ */ f.jsx(t, { ...a, ref: n, children: i.isValidElement(u) ? i.cloneElement(u, void 0, S) : null }); } return /* @__PURE__ */ f.jsx(t, { ...a, ref: n, children: l }); }); return r.displayName = `${e}.Slot`, r; } var j = /* @__PURE__ */ g("Slot"); // @__NO_SIDE_EFFECTS__ function C(e) { const t = i.forwardRef((r, o) => { const { children: n, ...l } = r; if (i.isValidElement(n)) { const a = R(n), s = b(l, n.props); return n.type !== i.Fragment && (s.ref = o ? m(o, a) : a), i.cloneElement(n, s); } return i.Children.count(n) > 1 ? i.Children.only(null) : null; }); return t.displayName = `${e}.SlotClone`, t; } var y = Symbol("radix.slottable"); // @__NO_SIDE_EFFECTS__ function _(e) { const t = ({ children: r }) => /* @__PURE__ */ f.jsx(f.Fragment, { children: r }); return t.displayName = `${e}.Slottable`, t.__radixId = y, t; } function E(e) { return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === y; } function b(e, t) { const r = { ...t }; for (const o in t) { const n = e[o], l = t[o]; /^on[A-Z]/.test(o) ? n && l ? r[o] = (...s) => { const c = l(...s); return n(...s), c; } : n && (r[o] = n) : o === "style" ? r[o] = { ...n, ...l } : o === "className" && (r[o] = [n, l].filter(Boolean).join(" ")); } return { ...e, ...r }; } function R(e) { var o, n; let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, r = t && "isReactWarning" in t && t.isReactWarning; return r ? e.ref : (t = (n = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : n.get, r = t && "isReactWarning" in t && t.isReactWarning, r ? e.props.ref : e.props.ref || e.ref); } export { j as S, _ as a, m as b, g as c, x as u };