@base-framework/ui
Version:
This is a UI package that adds components and atoms that use Tailwind CSS and a theme based on Shadcn.
62 lines (61 loc) • 1.81 kB
JavaScript
import { I as u, Button as e } from "@base-framework/atoms";
import { Atom as c } from "@base-framework/base";
import { Icons as r } from "./icons.es.js";
const m = {
xs: "w-4 h-4",
sm: "w-6 h-6",
md: "w-8 h-8",
lg: "w-10 h-10",
xl: "w-12 h-12",
"2xl": "w-14 h-14",
"3xl": "w-16 h-16"
}, s = c((n, t) => {
const a = m[n.size || "sm"];
return u({
...n,
class: `stroke-current icon-size ${a} ${n.class || ""}`,
html: t[0]?.textContent
});
}), i = (n) => c((t, a) => e({
...n,
...t,
class: `bttn ${n.class} ${t.class || ""}`
}, a)), h = c(
(n, t) => e({
...n,
class: n.class
}, [
n.icon && n.position !== "right" ? s({ size: "sm", class: n.animation ?? null }, n.icon) : null,
...t || [],
n.icon && n.position === "right" ? s({ size: "sm", class: n.animation ?? null }, n.icon) : null
])
), l = (n) => c((t, a) => h({
...n,
...t,
class: `bttn ${n.class} ${t.class || ""}`
}, a)), g = (n) => () => {
if (n.allowHistory === !0 && globalThis.history.length > 2) {
globalThis.history.back();
return;
}
n.backUrl && app.navigate(n.backUrl);
}, w = (n) => c((t, a) => (t.icon = t.icon || r.chevron.single.left, t.click = t.click || g(t), h({
...n,
...t
}, a))), o = {
primary: i({ class: "primary" }),
secondary: i({ class: "secondary" }),
destructive: i({ class: "destructive" }),
warning: i({ class: "warning" }),
outline: i({ class: "outline" }),
ghost: i({ class: "ghost" }),
link: i({ class: "link" }),
icon: l({ class: "icon" }),
withIcon: l({ class: "with-icon" }),
back: w({ class: "with-icon back-button" })
}, k = c((n, t) => (o[n.variant] || o.primary)(n, t)), y = c((n, t) => k({ ...n, variant: "withIcon", icon: r.loading, animation: "animate-spin" }, t));
export {
k as B,
s as I,
y as L
};