UNPKG

@anoki/fse-ui

Version:

FSE UI components library

61 lines (60 loc) 2.36 kB
import * as l from "react"; import { composeRefs as y } from "./index.es478.js"; import { j as p } from "./index.es237.js"; // @__NO_SIDE_EFFECTS__ function S(e) { const t = /* @__PURE__ */ g(e), o = l.forwardRef((n, r) => { const { children: i, ...a } = n, s = l.Children.toArray(i), c = s.find(E); if (c) { const f = c.props.children, m = s.map((u) => u === c ? l.Children.count(f) > 1 ? l.Children.only(null) : l.isValidElement(f) ? f.props.children : null : u); return /* @__PURE__ */ p.jsx(t, { ...a, ref: r, children: l.isValidElement(f) ? l.cloneElement(f, void 0, m) : null }); } return /* @__PURE__ */ p.jsx(t, { ...a, ref: r, children: i }); }); return o.displayName = `${e}.Slot`, o; } var h = /* @__PURE__ */ S("Slot"); // @__NO_SIDE_EFFECTS__ function g(e) { const t = l.forwardRef((o, n) => { const { children: r, ...i } = o; if (l.isValidElement(r)) { const a = x(r), s = R(i, r.props); return r.type !== l.Fragment && (s.ref = n ? y(n, a) : a), l.cloneElement(r, s); } return l.Children.count(r) > 1 ? l.Children.only(null) : null; }); return t.displayName = `${e}.SlotClone`, t; } var d = Symbol("radix.slottable"); // @__NO_SIDE_EFFECTS__ function j(e) { const t = ({ children: o }) => /* @__PURE__ */ p.jsx(p.Fragment, { children: o }); return t.displayName = `${e}.Slottable`, t.__radixId = d, t; } function E(e) { return l.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === d; } function R(e, t) { const o = { ...t }; for (const n in t) { const r = e[n], i = t[n]; /^on[A-Z]/.test(n) ? r && i ? o[n] = (...s) => { const c = i(...s); return r(...s), c; } : r && (o[n] = r) : n === "style" ? o[n] = { ...r, ...i } : n === "className" && (o[n] = [r, i].filter(Boolean).join(" ")); } return { ...e, ...o }; } function x(e) { var n, r; let t = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = t && "isReactWarning" in t && t.isReactWarning; return o ? e.ref : (t = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref); } export { h as Root, h as Slot, S as createSlot, j as createSlottable }; //# sourceMappingURL=index.es480.js.map