UNPKG

koval-ui

Version:

React components collection with minimalistic design. Supports theming, layout, and input validation.

60 lines (59 loc) 1.34 kB
"use client"; import { jsxs as f, jsx as m } from "react/jsx-runtime"; import { useMemo as d, useCallback as k } from "react"; import p from "classnames"; import { IconSuccess as I } from "../Icons/IconSuccess.js"; import { IconDanger as g } from "../Icons/IconDanger.js"; import { IconLink as N } from "../Icons/IconLink.js"; import { ActionTypes as o } from "./ActionTypes.js"; import s from "./ActionButton.module.css.js"; const v = ({ title: n, icon: a, type: c = "default", onClick: r = () => { }, className: t, disabled: i }) => { const e = d( () => a ?? { [o.success]: I, [o.danger]: g, [o.link]: N, [o.default]: void 0 }[c], [a, c] ), l = k( (u) => { r(u); }, [r] ); return /* @__PURE__ */ f( "button", { disabled: i, title: n, onClick: l, className: p( s.actionButton, { [s.default]: c === o.default, [s.link]: c === o.link, [s.success]: c === o.success, [s.danger]: c === o.danger }, t ), children: [ e && /* @__PURE__ */ m(e, { className: s.actionIcon }), n && /* @__PURE__ */ m("span", { className: s.actionLabel, children: n }) ] } ); }; export { v as ActionButton }; //# sourceMappingURL=ActionButton.js.map