@adyen/adyen-web 6.41.0 → 6.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +33 -31
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es/components/internal/Address/validate.formats.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/Button/CopyButton.js +1 -1
- package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
- package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +33 -31
- package/dist/es/utils/validator-utils.js +1 -1
- package/dist/es/utils/validator-utils.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js.map +1 -1
- package/package.json +19 -19
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getFormattingRegEx as o,SPECIAL_CHARS as t
|
|
1
|
+
import{getFormattingRegEx as o,SPECIAL_CHARS as t}from"../../../utils/validator-utils.js";const a=t=>({formatterFn:a=>a.replace(o("^\\d","g"),"").substring(0,t),format:new Array(t).fill("9").join(""),maxlength:t}),e=o(t),r=o=>o.replace(e,""),l={postalCode:{formatterFn:(o,t)=>{const a=t.state.data.country,e=s[a]?.postalCode.formatterFn;return e?e(o):o}},street:{formatterFn:r},houseNumberOrName:{formatterFn:r},city:{formatterFn:r}},s={AT:{postalCode:a(4)},AU:{postalCode:a(4)},BE:{postalCode:a(4)},BG:{postalCode:a(4)},BR:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?9:8;return a.substring(0,e)},format:"12345678 or 12345-678",maxlength:9}},CA:{postalCode:{format:"A9A 9A9 or A9A9A9",maxlength:7}},CH:{postalCode:a(4)},CY:{postalCode:a(4)},CZ:{postalCode:{format:"999 99",maxlength:6}},DE:{postalCode:a(5)},DK:{postalCode:{format:"9999",maxlength:7}},EE:{postalCode:a(5)},ES:{postalCode:a(5)},FI:{postalCode:a(5)},FR:{postalCode:a(5)},GB:{postalCode:{formatterFn:a=>a.replace(o(t),"").substring(0,8),format:"AA99 9AA or A99 9AA or A9 9AA",maxlength:8}},GR:{postalCode:{format:"999 99",maxlength:6}},HR:{postalCode:{format:"[1-5]9999",maxlength:5}},HU:{postalCode:a(4)},IE:{postalCode:{format:"A99 A999",maxlength:8}},IS:{postalCode:a(3)},IT:{postalCode:a(5)},LI:{postalCode:a(4)},LT:{postalCode:{format:"9999 or 99999 or LT-99999",maxlength:8}},LU:{postalCode:a(4)},LV:{postalCode:{format:"9999 or LV-9999",maxlength:7}},MC:{postalCode:{format:"980NN",maxlength:5}},MT:{postalCode:{format:"AA99 or AAA99 or AA9999 or AAA9999",maxlength:8}},MY:{postalCode:a(5)},NL:{postalCode:{format:"9999AA",maxlength:7}},NZ:{postalCode:a(4)},NO:{postalCode:a(4)},PL:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?6:5;return a.substring(0,e)},format:"99999 or 99-999",maxlength:6}},PT:{postalCode:{formatterFn:t=>t.replace(o("^\\d-","g"),"").substring(0,8),format:"9999-999",maxlength:8}},RO:{postalCode:a(6)},SI:{postalCode:{format:"9999 or SI-9999",maxlength:7}},SE:{postalCode:a(5)},SG:{postalCode:a(6)},SK:{postalCode:{format:"99999 or SK-99999",maxlength:8}},JP:{postalCode:{format:"999-9999",maxlength:8}},US:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?10:5;return a.substring(0,e)},format:"99999 or 99999-9999"}}};export{l as addressFormatters,s as countrySpecificFormatters};
|
|
2
2
|
//# sourceMappingURL=validate.formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ,GAAKC,QAAQQ,EAAmB,IAEnEI,EAAiC,CAC1CC,WAAY,CACRf,YAAa,CAACC,EAAKe,KACf,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWf,YACpE,OAAIoB,EACOA,EAAanB,GAIjBA,IAGfqB,OAAQ,CACJtB,YAAaY,GAEjBW,kBAAmB,CACfvB,YAAaY,GAEjBY,KAAM,CACFxB,YAAaY,IAORS,EAAiD,CAC1DI,GAAI,CACAV,WAAYjB,EAAqB,IAErC4B,GAAI,CACAX,WAAYjB,EAAqB,IAErC6B,GAAI,CACAZ,WAAYjB,EAAqB,IAErC8B,GAAI,CACAb,WAAYjB,EAAqB,IAErC+B,GAAI,CACAd,WAAY,CAERf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,SAAS,KAAO,EAAI,EAC5C,OAAOD,EAAM1B,UAAU,EAAGK,IAE9BJ,OAAQ,wBACRI,UAAW,IAGnBuB,GAAI,CACAjB,WAAY,CACRV,OAAQ,oBACRI,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B,IAErC6D,GAAI,CACA5C,WAAY,CAERf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,SAAS,KAAO,EAAI,EAC5C,OAAOD,EAAM1B,UAAU,EAAGK,IAE9BJ,OAAQ,kBACRI,UAAW,IAGnBmD,GAAI,CACA7C,WAAY,CACRf,YAAaC,GACKA,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IAC/CC,UAAU,EAAG,GAE9BC,OAAQ,WACRI,UAAW,IAGnBoD,GAAI,CACA9C,WAAYjB,EAAqB,IAErCgE,GAAI,CACA/C,WAAY,CACRV,OAAQ,kBACRI,UAAW,IAGnBsD,GAAI,CACAhD,WAAYjB,EAAqB,IAErCkE,GAAI,CACAjD,WAAYjB,EAAqB,IAErCmE,GAAI,CACAlD,WAAY,CACRV,OAAQ,oBACRI,UAAW,IAGnByD,GAAI,CACAnD,WAAY,CACRV,OAAQ,WACRI,UAAW,IAGnB0D,GAAI,CACApD,WAAY,CACRf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAM1B,UAAU,EAAGK,IAE9BJ,OAAQ"}
|
|
1
|
+
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = (val: string) => val.replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"0FAIA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAgBX,GAAgBA,EAAIC,QAAQQ,EAAmB,IAExDG,EAAiC,CAC1CC,WAAY,CACRd,YAAa,CAACC,EAAKc,KACf,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWd,YACpE,OAAImB,EACOA,EAAalB,GAIjBA,IAGfoB,OAAQ,CACJrB,YAAaY,GAEjBU,kBAAmB,CACftB,YAAaY,GAEjBW,KAAM,CACFvB,YAAaY,I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1,2 @@
|
|
|
1
|
-
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as
|
|
1
|
+
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as s,off as n}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function c(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class u{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),s=this.core.modules.risk.data,n=this.core.modules.analytics.checkoutAttemptId??r,c=o?h.NATIVE:h.GENERIC,u=i(n,s,c);return e.paymentMethod&&n&&(e.paymentMethod.checkoutAttemptId=n),e.paymentMethod&&u&&(e.paymentMethod.sdkData=u),{...s&&{riskData:{clientData:s}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,s(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return n(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){c(this,"_id",`${this.constructor.type}-${e()}`),c(this,"core",void 0),c(this,"props",void 0),c(this,"state",{}),c(this,"_component",void 0),c(this,"_node",null);const s=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!s)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyPress=this.handleKeyPress.bind(this)}}c(u,"defaultProps",{});export{u as default};
|
|
2
2
|
//# sourceMappingURL=BaseElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render
|
|
1
|
+
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","order","componentData","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"mlBAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,gBAAoBJ,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAG,GACI,MAAO,CAAA,CACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfV,KAAKW,MAAQ,IAAKX,KAAKW,SAAUD,EACrC,CAMA,QAAWE,GACP,MAAMC,EAAQb,KAAKW,MAAME,OAASb,KAAKC,MAAMY,MACvCC,EAAgBd,KAAKI,aACrBW,EAAuCC,QAAQC,EAA8BH,EAAcI,eAAeC,OAC1GC,EAAapB,KAAKqB,KAAKC,QAAQC,KAAKX,KACpCY,EAAoBxB,KAAKqB,KAAKC,QAAQG,UAAUD,mBAAqBE,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARIb,EAAcI,eAAiBM,IAC/BV,EAAcI,cAAcM,kBAAoBA,GAGhDV,EAAcI,eAAiBa,IAC/BjB,EAAcI,cAAca,QAAUA,GAGnC,IACCX,GAAc,CAAEa,SAAU,CAAEb,kBAC5BP,GAAS,CAAEA,MAAO,CA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AY,6DAIhEH,KAAKqB,KAAO+B,EACZpD,KAAKF,kBAAkBG,GAEvBD,KAAKO,eAAiBP,KAAKO,eAAesD,KAAK7D,KACnD,EAhBAqD,EAVWxD,EAUeiE,eAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as
|
|
1
|
+
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:i=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S,onKeyPress:L}=this.props,{completed:B}=this.state,{i18n:j}=o(),D=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed?c??l:l,alt:"","aria-hidden":"true"}):"",M=[...i,..."primary"===f?[]:[f],...d?["inline"]:[],...B?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],P=a(["adyen-checkout__button",...M.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),j.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},D,t("span",{className:"adyen-checkout__button__text"},this.state.completed?k??u:u))},K=E[y]||E.default;return s?t("a",{className:P,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},K):t("button",{ref:g,id:e,className:P,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N,onKeyPress:L},K,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},j.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),i(this,"onClick",e=>{e.preventDefault(),this.props.disabled||this.props.onClick?.(e,{complete:this.complete})}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFxB,GAAwBD,EACpB0B,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,UAAapB,GAAwBD,EAAQA,EAC7D8B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXnC,KACa,YAAZa,EAAwB,GAAK,CAACA,MAC9BR,EAAS,CAAC,UAAY,MACtBmB,EAAY,CAAC,aAAe,MACjB,YAAXZ,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEwB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,EAAe,CACjBC,QACIZ,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAASvC,QAAAA,KAG/BwC,SACIhB,EAACa,OAAAA,CAAKR,cAAY,OA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ACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/B0D,EADE1E,EACqB+E,eAAe,CAClC/D,OAAQ,UACRC,QAAS,UACTZ,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR6C,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as o}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import e from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import{PREFIX as i}from"../Icon/constants.js";import c from"../../../core/Context/useImage.js";import{stopPropagationForActionKeys as s}from"./stopPropagationForActionKeys.js";const a=a=>{const{i18n:m}=r(),p=c(),l=t((o,{complete:t})=>{n(a.text),t(),a.onClick?.(o)},[a.text,a.onClick]);return o(e,{...a,variant:"action",onClick:l,onKeyDown:s,icon:a.icon??p({imageFolder:"components/"})(`${i}copy`),label:a.label??m.get("button.copy"),onClickCompletedLabel:a.copiedLabel??m.get("button.copied")})};export{a as CopyButton};
|
|
1
|
+
import{createElement as o}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import e from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import{PREFIX as i}from"../Icon/constants.js";import c from"../../../core/Context/useImage.js";import{stopPropagationForActionKeys as s}from"./stopPropagationForActionKeys.js";const a=a=>{const{i18n:m}=r(),p=c(),l=t((o,{complete:t})=>{n(a.text),t(),a.onClick?.(o)},[a.text,a.onClick]);return o(e,{...a,variant:"action",onClick:l,onKeyPress:s,onKeyDown:s,icon:a.icon??p({imageFolder:"components/"})(`${i}copy`),label:a.label??m.get("button.copy"),onClickCompletedLabel:a.copiedLabel??m.get("button.copied")})};export{a as CopyButton};
|
|
2
2
|
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","sources":["../../../../../src/components/internal/Button/CopyButton.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"CopyButton.js","sources":["../../../../../src/components/internal/Button/CopyButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { PREFIX } from '../Icon/constants';\nimport useImage from '../../../core/Context/useImage';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\n\nexport interface CopyButtonProps extends Omit<ButtonProps, 'variant' | 'onClickCompletedLabel'> {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n copiedLabel?: string;\n onClick?: (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CopyButton = (props: Readonly<CopyButtonProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const onClick = useCallback(\n (e, { complete }) => {\n void copyToClipboard(props.text);\n complete();\n props.onClick?.(e);\n },\n [props.text, props.onClick]\n );\n\n return (\n <Button\n {...props}\n variant=\"action\"\n onClick={onClick}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n icon={props.icon ?? getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={props.label ?? i18n.get('button.copy')}\n onClickCompletedLabel={props.copiedLabel ?? i18n.get('button.copied')}\n />\n );\n};\n\nexport { CopyButton };\n"],"names":["CopyButton","props","i18n","useCoreContext","getImage","useImage","onClick","useCallback","e","complete","copyToClipboard","text","h","Button","variant","onKeyPress","stopPropagationForActionKeys","onKeyDown","icon","imageFolder","PREFIX","label","get","onClickCompletedLabel","copiedLabel"],"mappings":"meAmBA,MAAMA,EAAcC,IAChB,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAUC,EACZ,CAACC,GAAKC,eACGC,EAAgBT,EAAMU,MAC3BF,IACAR,EAAMK,UAAUE,IAEpB,CAACP,EAAMU,KAAMV,EAAMK,UAGvB,OACIM,EAACC,EAAAA,IACOZ,EACJa,QAAQ,SACRR,QAASA,EAETS,WAAYC,EACZC,UAAWD,EACXE,KAAMjB,EAAMiB,MAAQd,EAAS,CAAEe,YAAa,eAAxBf,CAAyC,GAAGgB,SAChEC,MAAOpB,EAAMoB,OAASnB,EAAKoB,IAAI,eAC/BC,sBAAuBtB,EAAMuB,aAAetB,EAAKoB,IAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as o}from"../../../external/preact/dist/preact.js";import{useRef as t,useCallback as e}from"../../../external/preact/hooks/dist/hooks.js";import n from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as
|
|
1
|
+
import{createElement as o}from"../../../external/preact/dist/preact.js";import{useRef as t,useCallback as e}from"../../../external/preact/hooks/dist/hooks.js";import n from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as s}from"../../../utils/clipboard.js";import{SingletonTooltipProvider as i,useTooltip as a}from"../Tooltip/SingletonTooltipProvider.js";import{stopPropagationForActionKeys as p}from"./stopPropagationForActionKeys.js";const c=i=>{const{i18n:c}=r(),l=t(null),{showTooltip:C,hideTooltip:u}=a(),m=e(()=>{s(i.text),C({anchorRef:l,text:c.get("button.copied")})},[i.text,c,C]),f=e(o=>{p(o),"Escape"!==o.key&&"Escape"!==o.code||(o.stopPropagation(),u())},[u]),h=e(()=>{C({anchorRef:l,text:c.get("button.copy")})},[l,c,C]);return o(n,{...i,variant:"iconOnly",buttonRef:l,ariaLabel:i.ariaLabel??c.get("button.copy"),onMouseEnter:h,onMouseLeave:u,onFocus:h,onBlur:u,onClick:m,onKeyPress:p,onKeyDown:f},o("svg",{className:"adyen-checkout__button--iconOnly__icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",{d:"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z"})))},l=t=>o(i,null,o(c,t));export{l as CopyIconButton};
|
|
2
2
|
//# sourceMappingURL=CopyIconButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyIconButton.js","sources":["../../../../../src/components/internal/Button/CopyIconButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useRef } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { SingletonTooltipProvider, useTooltip } from '../Tooltip/SingletonTooltipProvider';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\
|
|
1
|
+
{"version":3,"file":"CopyIconButton.js","sources":["../../../../../src/components/internal/Button/CopyIconButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useRef } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { SingletonTooltipProvider, useTooltip } from '../Tooltip/SingletonTooltipProvider';\nimport './CopyIconButton.scss';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\n\nexport interface CopyIconButtonProps extends ButtonProps {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n}\n\nconst CopyIconButton = (props: Readonly<CopyIconButtonProps>) => {\n const { i18n } = useCoreContext();\n const anchorRef = useRef<HTMLButtonElement>(null);\n const { showTooltip, hideTooltip } = useTooltip();\n\n const onClick = useCallback(() => {\n void copyToClipboard(props.text);\n showTooltip({ anchorRef, text: i18n.get('button.copied') });\n }, [props.text, i18n, showTooltip]);\n\n // We need it because onKeyPress does not trigger for Esc key\n const onKeyDown = useCallback(\n (event: KeyboardEvent) => {\n stopPropagationForActionKeys(event);\n\n if (event.key === 'Escape' || event.code === 'Escape') {\n event.stopPropagation();\n hideTooltip();\n }\n },\n [hideTooltip]\n );\n\n const handleShowTooltip = useCallback(() => {\n showTooltip({ anchorRef, text: i18n.get('button.copy') });\n }, [anchorRef, i18n, showTooltip]);\n\n return (\n <Button\n {...props}\n variant=\"iconOnly\"\n buttonRef={anchorRef}\n ariaLabel={props.ariaLabel ?? i18n.get('button.copy')}\n onMouseEnter={handleShowTooltip}\n onMouseLeave={hideTooltip}\n onFocus={handleShowTooltip}\n onBlur={hideTooltip}\n onClick={onClick}\n // It's ok to have both, browsers will fire only one click event for enter/space key pressed.\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={onKeyDown}\n >\n <svg\n className=\"adyen-checkout__button--iconOnly__icon\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path d=\"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z\" />\n </svg>\n </Button>\n );\n};\n\nconst withTooltip = (props: Readonly<CopyIconButtonProps>) => {\n return (\n <SingletonTooltipProvider>\n <CopyIconButton {...props} />\n </SingletonTooltipProvider>\n );\n};\n\nexport { withTooltip as CopyIconButton };\n"],"names":["CopyIconButton","props","i18n","useCoreContext","anchorRef","useRef","showTooltip","hideTooltip","useTooltip","onClick","useCallback","copyToClipboard","text","get","onKeyDown","event","stopPropagationForActionKeys","key","code","stopPropagation","handleShowTooltip","h","Button","variant","buttonRef","ariaLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyPress","svg","className","xmlns","width","height","viewBox","fill","path","d","withTooltip","SingletonTooltipProvider"],"mappings":"kfAiBA,MAAMA,EAAkBC,IACpB,MAAMC,KAAEA,GAASC,IACXC,EAAYC,EAA0B,OACtCC,YAAEA,EAAWC,YAAEA,GAAgBC,IAE/BC,EAAUC,EAAY,KACnBC,EAAgBV,EAAMW,MAC3BN,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,oBACzC,CAACZ,EAAMW,KAAMV,EAAMI,IAGhBQ,EAAYJ,EACbK,IACGC,EAA6BD,GAEX,WAAdA,EAAME,KAAmC,WAAfF,EAAMG,OAChCH,EAAMI,kBACNZ,MAGR,CAACA,IAGCa,EAAoBV,EAAY,KAClCJ,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,kBACzC,CAACT,EAAWF,EAAMI,IAErB,OACIe,EAACC,EAAAA,IACOrB,EACJsB,QAAQ,WACRC,UAAWpB,EACXqB,UAAWxB,EAAMwB,WAAavB,EAAKW,IAAI,eACvCa,aAAcN,EACdO,aAAcpB,EACdqB,QAASR,EACTS,OAAQtB,EACRE,QAASA,EAETqB,WAAYd,EACZF,UAAWA,GAEXO,EAACU,MAAAA,CACGC,UAAU,yCACVC,MAAM,6BACNC,MAAM,KACNC,OAAO,KACPC,QAAQ,YACRC,KAAK,QAELhB,EAACiB,OAAAA,CAAKC,EAAE,snBAMlBC,EAAevC,GAEboB,EAACoB,EAAAA,KACGpB,EAACrB,EAAmBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect } from 'preact/hooks';\nimport { CtpState } from './services/ClickToPayService';\nimport useClickToPayContext from './context/useClickToPayContext';\nimport CtPOneTimePassword from './components/CtPOneTimePassword';\nimport CtPCards from './components/CtPCards';\nimport CtPSection from './components/CtPSection';\nimport CtPLoader from './components/CtPLoader';\nimport CtPLogin from './components/CtPLogin';\nimport SrciError from './services/sdks/SrciError';\n\ntype ClickToPayComponentProps = {\n onDisplayCardComponent?(): void;\n};\n\nconst ClickToPayComponent = ({ onDisplayCardComponent }: Readonly<ClickToPayComponentProps>): h.JSX.Element => {\n const { ctpState, onReady, startIdentityValidation, logoutShopper } = useClickToPayContext();\n\n useEffect(() => {\n if ([CtpState.OneTimePassword, CtpState.Login, CtpState.Ready].includes(ctpState)) {\n onReady();\n }\n }, [ctpState, onReady]);\n\n useEffect(() => {\n async function sendOneTimePassword() {\n try {\n await startIdentityValidation();\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Identity Validation error: ${error.toString()}`);\n await logoutShopper();\n }\n }\n if (ctpState === CtpState.ShopperIdentified) {\n void sendOneTimePassword();\n }\n }, [ctpState]);\n\n /**\n * We capture the ENTER keypress within the ClickToPay component because we do not want to propagate the event up to the UIElement\n * UIElement would perform the payment flow (by calling .submit), which is not relevant/supported by Click to Pay\n */\n const handleEnterKeyPress = useCallback((event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n event.stopPropagation(); // Prevent global BaseElement keypress event to be triggered\n }\n }, []);\n\n if (ctpState === CtpState.NotAvailable) {\n return null;\n }\n\n return (\n <CtPSection onEnterKeyPress={handleEnterKeyPress}>\n {[CtpState.Loading, CtpState.ShopperIdentified].includes(ctpState) && <CtPLoader />}\n {ctpState === CtpState.OneTimePassword && <CtPOneTimePassword onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Ready && <CtPCards onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Login && <CtPLogin />}\n </CtPSection>\n );\n};\n\nexport default ClickToPayComponent;\n"],"names":["ClickToPayComponent","onDisplayCardComponent","ctpState","onReady","startIdentityValidation","logoutShopper","useClickToPayContext","useEffect","CtpState","OneTimePassword","Login","Ready","includes","ShopperIdentified","async","error","SrciError","console","warn","toString","sendOneTimePassword","handleEnterKeyPress","useCallback","event","key","preventDefault","stopPropagation","NotAvailable","h","CtPSection","onEnterKeyPress","Loading","CtPLoader","CtPOneTimePassword","CtPCards","CtPLogin"],"mappings":"ykBAeA,MAAMA,EAAsB,EAAGC,6BAC3B,MAAMC,SAAEA,EAAQC,QAAEA,EAAOC,wBAAEA,EAAuBC,cAAEA,GAAkBC,IAEtEC,EAAU,KACF,CAACC,EAASC,gBAAiBD,EAASE,MAAOF,EAASG,OAAOC,SAASV,IACpEC,KAEL,CAACD,EAAUC,IAEdI,EAAU,KASFL,IAAaM,EAASK,mBAR1BC,iBACI,UACUV,GACV,CAAE,MAAOW,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,oCAAoCH,EAAMI,oBACjFd,GACV,CACJ,CAESe,IAEV,CAAClB,IAMJ,MAAMmB,EAAsBC,EAAaC,IACnB,UAAdA,EAAMC,MACND,EAAME,iBACNF,EAAMG,oBAEX,IAEH,OAAIxB,IAAaM,EAASmB,aACf,KAIPC,EAACC,EAAAA,CAAWC,gBAAiBT,GACxB,CAACb,EAASuB,QAASvB,EAASK,mBAAmBD,SAASV,IAAa0B,EAACI,QACtE9B,IAAaM,EAASC,iBAAmBmB,EAACK,EAAAA,CAAmBhC,uBAAwBA,IACrFC,IAAaM,EAASG,OAASiB,EAACM,EAAAA,CAASjC,uBAAwBA,IACjEC,IAAaM,EAASE,OAASkB,EAACO,EAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const m=m=>{const{i18n:d}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&m.errorMessage&&l(c.current,"shopperLogin")},[m.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,m.onSetInputHandlers(j.current)},[E,m.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);return t(()=>{m.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:d.get("ctp.login.inputLabel"),errorMessage:I?m.errorMessage||F.shopperLogin&&d.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:m.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const m=m=>{const{i18n:d}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&m.errorMessage&&l(c.current,"shopperLogin")},[m.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,m.onSetInputHandlers(j.current)},[E,m.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);return t(()=>{m.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:d.get("ctp.login.inputLabel"),errorMessage:I?m.errorMessage||F.shopperLogin&&d.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:m.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyPress:M,autocomplete:"email"})))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=CtPLoginInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || (errors.shopperLogin && i18n.get(errors.shopperLogin.errorMessage)) : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n autocomplete={'email'}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","autocomplete"],"mappings":"+iBA4BA,MA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C6C,WAAYrB,EACZsB,aAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as u}from"../../../../../../utils/setFocus.js";import c from"../../../../FormFields/Field/Field.js";import d from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:
|
|
1
|
+
import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as u}from"../../../../../../utils/setFocus.js";import c from"../../../../FormFields/Field/Field.js";import d from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&u(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(c,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(d,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e},autocomplete:"off"})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
|
|
2
2
|
//# sourceMappingURL=CtPOneTimePasswordInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n autocomplete={'off'}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","autocomplete","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAAkD,CACpIC,OAJe,CAAC,OAKhBC,MAAOC,EACPC,WAAYb,IAEVc,EAAsBb,EAAwC,CAAEc,cAAe,OAC/EC,EAAWf,EAAyB,OACnCgB,EAAgBC,GAAsBnB,GAAkB,GAEzDgB,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDzB,GAAuBqB,EAASM,SACjCN,EAASM,Q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,OAASf,IACL1B,EAASM,QAAUoB,GAEvBgB,aAAc,SAGtBlB,EAACC,MAAAA,CAAIE,UAAW,+CACZH,EAACmB,EAAAA,CAAiBN,SAAU9D,EAAMqE,gBAAiBC,QAAShC,EAAwBD,aAAcD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import n from"./CtPLogoutLink.js";import{CtPBrand as c}from"../CtPBrand/CtPBrand.js";import
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import n from"./CtPLogoutLink.js";import{CtPBrand as c}from"../CtPBrand/CtPBrand.js";import a from"../../context/useClickToPayContext.js";const o=({children:o,onEnterKeyPress:s})=>{const{isStandaloneComponent:r}=a();return e("div",{className:t("adyen-checkout-ctp__section",{"adyen-checkout-ctp__section--standalone":r}),onKeyPress:s},e("div",{className:"adyen-checkout-ctp__section-brand"},e(c,null),e(n,null)),o)};o.Title=({endAdornment:t,children:n})=>e("div",{className:"adyen-checkout-ctp__section-header"},e("h1",{className:"adyen-checkout-ctp__section-header-title"},n),t&&e("span",{className:"adyen-checkout-ctp__section-header-adornment"},t)),o.Text=({children:t})=>e("p",{className:"adyen-checkout-ctp__section-text"},t);export{o as default};
|
|
2
2
|
//# sourceMappingURL=CtPSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h
|
|
1
|
+
{"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classnames from 'classnames';\nimport CtPLogoutLink from './CtPLogoutLink';\nimport { CtPBrand } from '../CtPBrand';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport './CtPSection.scss';\n\ninterface CtPSectionProps {\n onEnterKeyPress: (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => void;\n children?: h.JSX.Element[];\n}\n\nconst CtPSection = ({ children, onEnterKeyPress }: Readonly<CtPSectionProps>): h.JSX.Element => {\n const { isStandaloneComponent } = useClickToPayContext();\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n className={classnames('adyen-checkout-ctp__section', { 'adyen-checkout-ctp__section--standalone': isStandaloneComponent })}\n onKeyPress={onEnterKeyPress}\n >\n <div className=\"adyen-checkout-ctp__section-brand\">\n <CtPBrand />\n <CtPLogoutLink />\n </div>\n\n {children}\n </div>\n );\n};\n\nconst Title = ({ endAdornment, children }: Readonly<{ endAdornment?; children }>) => (\n <div className=\"adyen-checkout-ctp__section-header\">\n <h1 className=\"adyen-checkout-ctp__section-header-title\">{children}</h1>\n {endAdornment && <span className=\"adyen-checkout-ctp__section-header-adornment\">{endAdornment}</span>}\n </div>\n);\nconst Text = ({ children }: Readonly<{ children }>) => <p className=\"adyen-checkout-ctp__section-text\">{children}</p>;\n\nCtPSection.Title = Title;\nCtPSection.Text = Text;\n\nexport default CtPSection;\n"],"names":["CtPSection","children","onEnterKeyPress","isStandaloneComponent","useClickToPayContext","h","div","className","classnames","onKeyPress","CtPBrand","CtPLogoutLink","Title","endAdornment","h1","span","Text","p"],"mappings":"wQAYA,MAAMA,EAAa,EAAGC,WAAUC,sBAC5B,MAAMC,sBAAEA,GAA0BC,IAElC,OAEIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,8BAA+B,CAAE,0CAA2CL,IAClGM,WAAYP,GAEZG,EAACC,MAAAA,CAAIC,UAAU,qCACXF,EAACK,EAAAA,MACDL,EAACM,EAAAA,OAGJV,IAabD,EAAWY,MARG,EAAGC,eAAcZ,cAC3BI,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACS,KAAAA,CAAGP,UAAU,4CAA4CN,GACzDY,GAAgBR,EAACU,OAAAA,CAAKR,UAAU,gDAAgDM,IAMzFb,EAAWgB,KAHE,EAAGf,cAAuCI,EAACY,IAAAA,CAAEV,UAAU,oCAAoCN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as s,useEffect as
|
|
1
|
+
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as s,useEffect as i,useCallback as n}from"../../../../external/preact/hooks/dist/hooks.js";const r=({isStandaloneComponent:r=!1,clickToPayService:c,configuration:d,children:l,setClickToPayRef:p,onSubmit:u,onSetStatus:y,onError:S})=>{const[m]=o(c),[C,f]=o(c?.state||e.NotAvailable),[h,k]=o(!0),[I,P]=o("ready"),v=s(!1),w=s({setStatus:P});i(()=>{p(w.current)},[]),i(()=>{m?.subscribeOnStateChange(t=>f(t))},[m]);const b=n(()=>{v.current||(d.onReady?.(),v.current=!0)},[d?.onReady]),g=n(async t=>{await(m?.finishIdentityValidation(t))},[m]),E=n(async()=>await(m?.startIdentityValidation()),[m]),V=n(async t=>await(m?.checkout(t)),[m]),R=n(async t=>await(m?.verifyIfShopperIsEnrolled(t)),[m]),j=n(async()=>{await(m?.logout())},[m]),x=n(t=>{m.updateStoreCookiesConsent(t)},[m]);return t(a.Provider,{value:{status:I,onSubmit:u,onError:S,onSetStatus:y,configuration:d,isStoringCookies:m?.storeCookies,isStandaloneComponent:r,isCtpPrimaryPaymentMethod:h,setIsCtpPrimaryPaymentMethod:k,ctpState:C,verifyIfShopperIsEnrolled:R,cards:m?.shopperCards,schemes:m?.schemes,otpMaskedContact:m?.identityValidationData?.maskedShopperContact,otpNetwork:m?.identityValidationData?.selectedNetwork,checkout:V,logoutShopper:j,startIdentityValidation:E,finishIdentityValidation:g,updateStoreCookiesConsent:x,onReady:b}},l)};export{r as default};
|
|
2
2
|
//# sourceMappingURL=ClickToPayProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { UIElementStatus } from '../../UIElement/types';\n\ntype ClickToPayProviderRef = {\n setStatus?(status: UIElementStatus): void;\n};\n\nexport type ClickToPayProviderProps = {\n isStandaloneComponent: boolean;\n clickToPayService: IClickToPayService | null;\n configuration: ClickToPayProps;\n children: any;\n setClickToPayRef(ref): void;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n};\n\nconst ClickToPayProvider = ({\n isStandaloneComponent = false,\n clickToPayService,\n configuration,\n children,\n setClickToPayRef,\n onSubmit,\n onSetStatus,\n onError\n}: Readonly<ClickToPayProviderProps>) => {\n const [ctpService] = useState<IClickToPayService | null>(clickToPayService);\n const [ctpState, setCtpState] = useState<CtpState>(clickToPayService?.state || CtpState.NotAvailable);\n const [isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod] = useState<boolean>(true);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const
|
|
1
|
+
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { ComponentMethodsRef, UIElementStatus } from '../../UIElement/types';\n\ntype ClickToPayProviderRef = {\n setStatus?(status: UIElementStatus): void;\n};\n\nexport type ClickToPayProviderProps = {\n isStandaloneComponent: boolean;\n clickToPayService: IClickToPayService | null;\n configuration: ClickToPayProps;\n children: any;\n setClickToPayRef(ref: ComponentMethodsRef): void;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n};\n\nconst ClickToPayProvider = ({\n isStandaloneComponent = false,\n clickToPayService,\n configuration,\n children,\n setClickToPayRef,\n onSubmit,\n onSetStatus,\n onError\n}: Readonly<ClickToPayProviderProps>) => {\n const [ctpService] = useState<IClickToPayService | null>(clickToPayService);\n const [ctpState, setCtpState] = useState<CtpState>(clickToPayService?.state || CtpState.NotAvailable);\n const [isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod] = useState<boolean>(true);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const isOnReadyInvoked = useRef<boolean>(false);\n\n const clickToPayRef = useRef<ClickToPayProviderRef>({\n setStatus\n });\n\n useEffect(() => {\n setClickToPayRef(clickToPayRef.current);\n }, []);\n\n useEffect(() => {\n ctpService?.subscribeOnStateChange(status => setCtpState(status));\n }, [ctpService]);\n\n const onReady = useCallback(() => {\n if (isOnReadyInvoked.current) {\n return;\n }\n configuration.onReady?.();\n isOnReadyInvoked.current = true;\n }, [configuration?.onReady]);\n\n const finishIdentityValidation = useCallback(\n async (otpValue: string) => {\n await ctpService?.finishIdentityValidation(otpValue);\n },\n [ctpService]\n );\n\n const startIdentityValidation = useCallback(async () => {\n const data = await ctpService?.startIdentityValidation();\n return data;\n }, [ctpService]);\n\n const checkout = useCallback(\n async (card: ShopperCard) => {\n return await ctpService?.checkout(card);\n },\n [ctpService]\n );\n\n const verifyIfShopperIsEnrolled = useCallback(\n async (shopperIdentity: IdentityLookupParams) => {\n return await ctpService?.verifyIfShopperIsEnrolled(shopperIdentity);\n },\n [ctpService]\n );\n\n const logoutShopper = useCallback(async () => {\n await ctpService?.logout();\n }, [ctpService]);\n\n const updateStoreCookiesConsent = useCallback(\n (shouldStore: boolean) => {\n ctpService.updateStoreCookiesConsent(shouldStore);\n },\n [ctpService]\n );\n\n return (\n <ClickToPayContext.Provider\n value={{\n status,\n onSubmit,\n onError,\n onSetStatus,\n configuration,\n isStoringCookies: ctpService?.storeCookies,\n isStandaloneComponent,\n isCtpPrimaryPaymentMethod,\n setIsCtpPrimaryPaymentMethod,\n ctpState,\n verifyIfShopperIsEnrolled,\n cards: ctpService?.shopperCards,\n schemes: ctpService?.schemes,\n otpMaskedContact: ctpService?.identityValidationData?.maskedShopperContact,\n otpNetwork: ctpService?.identityValidationData?.selectedNetwork,\n checkout,\n logoutShopper,\n startIdentityValidation,\n finishIdentityValidation,\n updateStoreCookiesConsent,\n onReady\n }}\n >\n {children}\n </ClickToPayContext.Provider>\n );\n};\n\nexport default ClickToPayProvider;\n"],"names":["ClickToPayProvider","isStandaloneComponent","clickToPayService","configuration","children","setClickToPayRef","onSubmit","onSetStatus","onError","ctpService","useState","ctpState","setCtpState","state","CtpState","NotAvailable","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","status","setStatus","isOnReadyInvoked","useRef","clickToPayRef","useEffect","current","subscribeOnStateChange","onReady","useCallback","finishIdentityValidation","async","otpValue","startIdentityValidation","checkout","card","verifyIfShopperIsEnrolled","shopperIdentity","logoutShopper","logout","updateStoreCookiesConsent","shouldStore","h","ClickToPayContext","Provider","value","isStoringCookies","storeCookies","cards","shopperCards","schemes","otpMaskedContact","identityValidationData","maskedShopperContact","otpNetwork","selectedNetwork"],"mappings":"yTAyBA,MAAMA,EAAqB,EACvBC,yBAAwB,EACxBC,oBACAC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back as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as r,ARIA_CONTEXT_SUFFIX as a}from"../../../core/Errors/constants.js";import{trimValWithOneSpace as t}from"../../../utils/validator-utils.js";function l({setRef:l,...s}){const{autoCorrect:i,classNameModifiers:u,isInvalid:d,isValid:c,readonly:p=null,spellcheck:y,type:m,uniqueId:f,disabled:h}=s,_=s.className;Object.prototype.hasOwnProperty.call(s,"onChange")&&console.error("Error: Form fields that rely on InputBase may not have an onChange property");const k=o(e=>{s.onInput?.(e)},[s.onInput]),v=o(e=>{s?.onKeyPress&&s.onKeyPress(e)},[s?.onKeyPress]),b=o(e=>{s?.onKeyUp&&s.onKeyUp(e)},[s?.onKeyUp]),B=o(e=>{if(s?.onBlurHandler?.(e),s.trimOnBlur){const o=e.target;o.value=t(o.value)}s?.onBlur?.(e)},[s.onBlur,s.onBlurHandler]),I=o(e=>{s?.onFocusHandler?.(e)},[s.onFocusHandler]),K=n("adyen-checkout__input",[`adyen-checkout__input--${m}`],_,{"adyen-checkout__input--invalid":d,"adyen-checkout__input--valid":c},(u??[]).map(e=>`adyen-checkout__input--${e}`)),{classNameModifiers:j,uniqueId:x,isInvalid:C,isValid:P,addContextualElement:N,"aria-describedby":g,autocomplete:q,...E}=s,F=["string"==typeof g&&g?g:null,f?`${f}${d?r:a}`:null].filter(Boolean).join(" ")||null;return e("input",{id:f,...E,autocomplete:q,"aria-required":E.required,type:m,className:K,readOnly:p,spellcheck:y,autoCorrect:i,"aria-describedby":F,"aria-invalid":d,onInput:k,onBlur:B,onFocus:I,onKeyUp:b,onKeyPress:v,disabled:h,ref:l})}l.defaultProps={type:"text",classNameModifiers:[]};export{l as default};
|
|
2
2
|
//# sourceMappingURL=InputBase.js.map
|