@base-framework/ui
Version:
This is a UI package that adds components and atoms that use Tailwind CSS and a theme based on Shadcn.
47 lines (46 loc) • 1.43 kB
JavaScript
import { Div as s, H4 as l, P as d } from "@base-framework/atoms";
import { Atom as r, Jot as o, Component as c } from "@base-framework/base";
const u = r((t, a) => {
const e = t.margin ?? "my-5 mx-5", n = t.padding ?? "p-4";
return t.hover && (t.class += " hover:shadow-lg hover:bg-muted/50"), s({
...t,
class: `rounded-lg border bg-card text-card-foreground shadow-md min-w-[120px] min-h-[80px] ${e} ${n} ${t.class || ""}`
}, a);
}), x = r((t, a) => {
const e = t.border === !0 ? "border-t" : "";
return s({
...t,
class: `grid grid-cols-1 gap-y-4 sm:grid-cols-[1fr,2fr] sm:gap-x-6 pt-8 ${e} ${t.class || ""}`
}, [
t.label && s({
...t.labelProps,
class: `space-y-1 ${t.labelProps?.class || ""}`
}, [
l({ class: "text-base" }, t.label),
t.description && d({ class: "text-sm text-muted-foreground" }, t.description)
]),
// Controls container: grows to fill remaining space, spacing between items
s({ class: "flex flex-col space-y-4" }, a)
]);
});
class i extends c {
/**
* This will set the component context.
*
* @param {object|null} context
* @returns {object|null}
*/
setContext(a) {
if (this.data)
return null;
const e = this?.parent?.data ?? this?.parent?.context?.data ?? this?.parent?.state ?? null;
return e ? { data: e } : null;
}
}
const b = (t) => o(t, i);
export {
u as C,
x as F,
i as V,
b as a
};