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)

40 lines (39 loc) 1.72 kB
import { jsx as a } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { useCallback as h, useMemo as u } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; import { classes as e } from "./constants.js"; import c from "classnames"; /* empty css */ import { fixedForwardRef as g } from "../../../utils/preact/fixedForwardRef.js"; import { Fragment as d } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js"; import { Icon as k } from "../Icon/Icon.js"; const T = g( ({ className: n, children: o, labelBeforeSwitch: s, onClick: t, readOnly: r, ...i }, p) => { const f = h( (m) => { r ? m.preventDefault() : t?.(m); }, [r, t] ), l = u( () => /* @__PURE__ */ a("div", { className: c(e.label, { [e.labelBefore]: s }), children: o }), [o, s] ); return /* @__PURE__ */ a( "label", { "data-testid": "toggle-switch", className: c(n, e.root, { [e.disabled]: i.disabled, [e.readonly]: r }), children: [ s && /* @__PURE__ */ a(d, { children: l }), /* @__PURE__ */ a("div", { "data-testid": "toggle-switch-control", className: e.switch, children: [ /* @__PURE__ */ a("input", { ...i, ref: p, type: "checkbox", className: "adyen-pe-visually-hidden", "aria-readonly": r, onClick: f }), /* @__PURE__ */ a("span", { className: e.slider, children: /* @__PURE__ */ a(k, { className: e.mark, name: "checkmark" }) }) ] }), !s && /* @__PURE__ */ a(d, { children: l }) ] } ); } ); export { T as default };