UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

55 lines (54 loc) 2.11 kB
import { jsx as t } from "../../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { useCallback as p, useMemo as _ } from "../../../../external/preact/hooks/dist/hooks.module.js"; import L from "classnames"; import { BUTTON_LOADING_CLASSNAME as C, BUTTON_FULL_WIDTH_CLASSNAME as g, BUTTON_CONDENSED_CLASSNAME as h, ICON_BUTTON_CLASSNAME as M, ICON_BUTTON_CONTENT_CLASSNAME as U, BUTTON_ICON_LEFT_CLASSNAME as u, BUTTON_LABEL_CLASSNAME as d, BUTTON_LABEL_CENTERED_CLASSNAME as D, BUTTON_ICON_RIGHT_CLASSNAME as I } from "../constants.js"; import y from "../../Typography/Typography.js"; import { TypographyVariant as x, TypographyElement as v } from "../../Typography/types.js"; import { getModifierClasses as F } from "../../../../utils/preact/className.js"; import R from "../../Spinner/Spinner.js"; import { Fragment as G } from "../../../../external/preact/dist/preact.module.js"; const w = (A, l, e, o, r, N) => { const { children: T, iconLeft: i, iconRight: s, iconButton: n = !1, fullWidth: S, condensed: E, state: a = "default" } = r, O = p( (c) => { c.preventDefault(), o || N == null || N(c); }, [o, N] ), m = _( () => F(e, l, [e, A]), [e, l, A] ), f = _( () => ({ ...r, className: L(m, { [M]: n, [h]: E, [g]: S, [C]: a === "loading" }), disabled: o || a === "loading" }), [m, E, o, S, n, r, a] ), B = _( () => n ? /* @__PURE__ */ t("div", { className: `${U}`, children: T }) : /* @__PURE__ */ t(G, { children: [ a === "loading" && /* @__PURE__ */ t(R, { size: "x-small" }), i && /* @__PURE__ */ t("span", { className: u, children: i }), /* @__PURE__ */ t( y, { className: L(d, { [D]: r.align === "center" }), el: v.SPAN, variant: x.BODY, children: T } ), s && /* @__PURE__ */ t("span", { className: I, children: s }) ] }), [T, n, i, s, r.align, a] ); return { classes: m, click: O, allChildren: B, allProps: f }; }; export { w as default };