@stencil/react-output-target
Version:
React output target for @stencil/core components.
41 lines (40 loc) • 1.22 kB
JavaScript
import { createComponent as h } from "@lit/react";
import n from "react";
const p = (s) => s ? s.split(/\s+/).filter(Boolean) : [], w = (s, r, l) => {
const o = new Set(p(r)), f = new Set(p(l)), c = [];
for (const e of s)
o.has(e) ? (c.push(e), o.delete(e)) : f.has(e) || c.push(e);
for (const e of o)
c.push(e);
return c.join(" ");
}, g = typeof window < "u" ? n.useLayoutEffect : n.useEffect, L = ({
defineCustomElement: s,
tagName: r,
transformTag: l,
...o
}) => {
typeof s < "u" && s();
const f = l ? l(r) : r, c = h({ ...o, tagName: f }), e = n.forwardRef((N, a) => {
const {
className: C,
class: d,
...y
} = N, u = C ?? d ?? "", m = n.useRef(null), i = n.useRef("");
g(() => {
const t = m.current;
t === null || u === i.current || (t.className = w(Array.from(t.classList), u, i.current), i.current = u);
});
const R = n.useCallback(
(t) => {
m.current = t, typeof a == "function" ? a(t) : a != null && (a.current = t);
},
[a]
);
return n.createElement(c, { ...y, ref: R });
});
return e.displayName = o.displayName ?? f, e;
};
export {
L as c
};
//# sourceMappingURL=create-component-ICzm58MY.js.map