xtreme-ui
Version:
Collection of reusable components that can be used in web projects
53 lines (52 loc) • 1.35 kB
JavaScript
"use client";
import { jsxs as x, jsx as o } from "react/jsx-runtime";
import { forwardRef as B } from "react";
import N from "clsx";
import { Icon as b } from "../Icon/Icon.js";
import { ProgressBar as g } from "../ProgressBar/ProgressBar.js";
/* empty css */
import { EButtonTypes as h } from "./types.js";
const C = B((a, c) => {
const {
className: m,
style: p = {},
label: e,
type: n = "primary",
size: l = "default",
disabled: u = !1,
loading: i = !1,
icon: t,
iconType: d,
iconPosition: s = "left",
onClick: f
} = a, r = () => t ? /* @__PURE__ */ o(b, { className: "icon", code: t, type: d, size: l }) : null, y = N(
"xtrButton",
"shadowRipple",
`${n}Type`,
`${l}Size`,
!e && "iconOnly",
i && "loading",
m
);
return !e && !t ? null : /* @__PURE__ */ x(
"button",
{
ref: c,
className: y,
style: p,
onClick: f,
disabled: u,
role: "button",
children: [
n.includes(h.link) && /* @__PURE__ */ o(g, { className: "underline", intermediate: i }),
s === "left" && /* @__PURE__ */ o(r, {}),
e && /* @__PURE__ */ o("span", { className: "label", children: e }),
s === "right" && /* @__PURE__ */ o(r, {})
]
}
);
});
C.displayName = "Button";
export {
C as Button
};