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)

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