@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.53 kB
JavaScript
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useMemo as a,useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import l from"../../../_virtual/index.js";import o from"../../../utils/uuid.js";const s=({label:s,labelPosition:c="after",ariaLabel:n,description:i,checked:d,disabled:r=!1,readonly:g=!1,onChange:h})=>{const p=a(()=>i?`toggle-description-${o()}`:null,[i]),u=a(()=>n||("string"==typeof s?s:null),[n,s]),m=l({"adyen-checkout-toggle--label-first":"before"===c,"adyen-checkout-toggle--disabled":r,"adyen-checkout-toggle--readonly":g}),k=t(e=>{h(e.target.checked)},[h]);return e("label",{className:`adyen-checkout-toggle ${m}`},e("input",{disabled:r,checked:d,onChange:k,"aria-label":u,"aria-readonly":g,"aria-describedby":p,role:"switch",type:"checkbox",className:"adyen-checkout-toggle__input"}),e("span",{"aria-hidden":!0,className:"adyen-checkout-toggle__track"},e("span",{className:"adyen-checkout-toggle__handle"},d&&e("svg",{role:"img",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none"},e("path",{fill:"#00112C",d:"M12.0608 6.00011L11.0001 4.93945L7.00011 8.93945L5.00011 6.93945L3.93945 8.00011L7.00011 11.0608L12.0608 6.00011Z"})))),s&&e("span",{className:"adyen-checkout-toggle__label-container"},e("span",{className:"adyen-checkout-toggle__label-text","data-testid":"inner-label"},s),i&&e("span",{"data-testid":"description",className:"adyen-checkout-toggle__description",id:p},i)))};export{s as default};
//# sourceMappingURL=Toggle.js.map