@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
43 lines (42 loc) • 1.67 kB
JavaScript
import { createContext as A, createElement as c, forwardRef as C, useContext as b } from "react";
var h = (...t) => t.filter((e, r, o) => !!e && e.trim() !== "" && o.indexOf(e) === r).join(" ").trim(), L = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), W = (t) => t.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, r, o) => o ? o.toUpperCase() : r.toLowerCase()), d = (t) => {
const e = W(t);
return e.charAt(0).toUpperCase() + e.slice(1);
}, n = {
xmlns: "http://www.w3.org/2000/svg",
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round"
}, S = (t) => {
for (const e in t) if (e.startsWith("aria-") || e === "role" || e === "title") return !0;
return !1;
}, y = A({}), $ = () => b(y), j = C(({ color: t, size: e, strokeWidth: r, absoluteStrokeWidth: o, className: s = "", children: a, iconNode: m, ...l }, p) => {
const { size: i = 24, strokeWidth: u = 2, absoluteStrokeWidth: v = !1, color: x = "currentColor", className: w = "" } = $() ?? {}, f = o ?? v ? Number(r ?? u) * 24 / Number(e ?? i) : r ?? u;
return c("svg", {
ref: p,
...n,
width: e ?? i ?? n.width,
height: e ?? i ?? n.height,
stroke: t ?? x,
strokeWidth: f,
className: h("lucide", w, s),
...!a && !S(l) && { "aria-hidden": "true" },
...l
}, [...m.map(([k, g]) => c(k, g)), ...Array.isArray(a) ? a : [a]]);
}), N = (t, e) => {
const r = C(({ className: o, ...s }, a) => c(j, {
ref: a,
iconNode: e,
className: h(`lucide-${L(d(t))}`, `lucide-${t}`, o),
...s
}));
return r.displayName = d(t), r;
};
export {
N as t
};