@anoki/fse-ui
Version:
FSE UI components library
60 lines (59 loc) • 2.34 kB
JavaScript
import * as l from "react";
import { composeRefs as y } from "./index.es471.js";
import { j as f } from "./index.es244.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), p = s.find(E);
if (p) {
const c = p.props.children, m = s.map((u) => u === p ? l.Children.count(c) > 1 ? l.Children.only(null) : l.isValidElement(c) ? c.props.children : null : u);
return /* @__PURE__ */ f.jsx(t, { ...a, ref: r, children: l.isValidElement(c) ? l.cloneElement(c, void 0, m) : null });
}
return /* @__PURE__ */ f.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__ */ f.jsx(f.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) => {
i(...s), r(...s);
} : 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.es481.js.map