UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

61 lines (60 loc) 2.41 kB
import * as e from "react"; import { c as S } from "./index-DLcqcWxM.js"; import { jsx as y } from "react/jsx-runtime"; var E = Symbol.for("react.lazy"), p = e[" use ".trim().toString()]; function g(r) { return typeof r == "object" && r !== null && "then" in r; } function d(r) { return r != null && typeof r == "object" && "$$typeof" in r && r.$$typeof === E && "_payload" in r && g(r._payload); } // @__NO_SIDE_EFFECTS__ function C(r) { const n = /* @__PURE__ */ _(r), o = e.forwardRef((i, t) => { let { children: l, ...a } = i; d(l) && typeof p == "function" && (l = p(l._payload)); const s = e.Children.toArray(l), f = s.find(b); if (f) { const c = f.props.children, m = s.map((u) => u === f ? e.Children.count(c) > 1 ? e.Children.only(null) : e.isValidElement(c) ? c.props.children : null : u); return /* @__PURE__ */ y(n, { ...a, ref: t, children: e.isValidElement(c) ? e.cloneElement(c, void 0, m) : null }); } return /* @__PURE__ */ y(n, { ...a, ref: t, children: l }); }); return o.displayName = `${r}.Slot`, o; } var V = /* @__PURE__ */ C("Slot"); // @__NO_SIDE_EFFECTS__ function _(r) { const n = e.forwardRef((o, i) => { let { children: t, ...l } = o; if (d(t) && typeof p == "function" && (t = p(t._payload)), e.isValidElement(t)) { const a = P(t), s = h(l, t.props); return t.type !== e.Fragment && (s.ref = i ? S(i, a) : a), e.cloneElement(t, s); } return e.Children.count(t) > 1 ? e.Children.only(null) : null; }); return n.displayName = `${r}.SlotClone`, n; } var R = Symbol("radix.slottable"); function b(r) { return e.isValidElement(r) && typeof r.type == "function" && "__radixId" in r.type && r.type.__radixId === R; } function h(r, n) { const o = { ...n }; for (const i in n) { const t = r[i], l = n[i]; /^on[A-Z]/.test(i) ? t && l ? o[i] = (...s) => { const f = l(...s); return t(...s), f; } : t && (o[i] = t) : i === "style" ? o[i] = { ...t, ...l } : i === "className" && (o[i] = [t, l].filter(Boolean).join(" ")); } return { ...r, ...o }; } function P(r) { let n = Object.getOwnPropertyDescriptor(r.props, "ref")?.get, o = n && "isReactWarning" in n && n.isReactWarning; return o ? r.ref : (n = Object.getOwnPropertyDescriptor(r, "ref")?.get, o = n && "isReactWarning" in n && n.isReactWarning, o ? r.props.ref : r.props.ref || r.ref); } export { V as S, C as c };