@hoosei/voxweave-react
Version:
A customizable and interactive voice UI component for React applications
54 lines (53 loc) • 2.11 kB
JavaScript
import * as n from "react";
import { useComposedRefs as m } from "./index24.js";
import { jsx as u } from "react/jsx-runtime";
// @__NO_SIDE_EFFECTS__
function y(e) {
const r = /* @__PURE__ */ E(e), o = n.forwardRef((l, t) => {
const { children: i, ...c } = l, a = n.Children.toArray(i), s = a.find(g);
if (s) {
const f = s.props.children, d = a.map((p) => p === s ? n.Children.count(f) > 1 ? n.Children.only(null) : n.isValidElement(f) ? f.props.children : null : p);
return /* @__PURE__ */ u(r, { ...c, ref: t, children: n.isValidElement(f) ? n.cloneElement(f, void 0, d) : null });
}
return /* @__PURE__ */ u(r, { ...c, ref: t, children: i });
});
return o.displayName = `${e}.Slot`, o;
}
var b = /* @__PURE__ */ y("Slot");
// @__NO_SIDE_EFFECTS__
function E(e) {
const r = n.forwardRef((o, l) => {
const { children: t, ...i } = o, c = n.isValidElement(t) ? R(t) : void 0, a = m(c, l);
if (n.isValidElement(t)) {
const s = C(i, t.props);
return t.type !== n.Fragment && (s.ref = a), n.cloneElement(t, s);
}
return n.Children.count(t) > 1 ? n.Children.only(null) : null;
});
return r.displayName = `${e}.SlotClone`, r;
}
var S = Symbol("radix.slottable");
function g(e) {
return n.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === S;
}
function C(e, r) {
const o = { ...r };
for (const l in r) {
const t = e[l], i = r[l];
/^on[A-Z]/.test(l) ? t && i ? o[l] = (...a) => {
const s = i(...a);
return t(...a), s;
} : t && (o[l] = t) : l === "style" ? o[l] = { ...t, ...i } : l === "className" && (o[l] = [t, i].filter(Boolean).join(" "));
}
return { ...e, ...o };
}
function R(e) {
let r = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, o = r && "isReactWarning" in r && r.isReactWarning;
return o ? e.ref : (r = Object.getOwnPropertyDescriptor(e, "ref")?.get, o = r && "isReactWarning" in r && r.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
}
export {
b as Root,
b as Slot,
y as createSlot
};
//# sourceMappingURL=index21.js.map