@adyen/adyen-web 6.12.1 → 6.13.0

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.
Files changed (160) hide show
  1. package/dist/cjs/adyen.css +9 -4
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +681 -406
  6. package/dist/es/adyen.css +9 -4
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ApplePay/utils/payment-request.js +1 -1
  9. package/dist/es/components/ApplePay/utils/payment-request.js.map +1 -1
  10. package/dist/es/components/Card/Card.js +1 -1
  11. package/dist/es/components/Card/Card.js.map +1 -1
  12. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  13. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  15. package/dist/es/components/Card/components/Fastlane/FastlaneSignup.js +2 -0
  16. package/dist/es/components/Card/components/Fastlane/FastlaneSignup.js.map +1 -0
  17. package/dist/es/components/Card/components/Fastlane/InfoButton.js +2 -0
  18. package/dist/es/components/Card/components/Fastlane/InfoButton.js.map +1 -0
  19. package/dist/es/components/Card/components/Fastlane/InfoModal.js +2 -0
  20. package/dist/es/components/Card/components/Fastlane/InfoModal.js.map +1 -0
  21. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js +2 -0
  22. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -0
  23. package/dist/es/components/Card/components/Fastlane/utils/mobile-number-formatter.js +2 -0
  24. package/dist/es/components/Card/components/Fastlane/utils/mobile-number-formatter.js.map +1 -0
  25. package/dist/es/components/Card/components/Fastlane/utils/validate-configuration.js +2 -0
  26. package/dist/es/components/Card/components/Fastlane/utils/validate-configuration.js.map +1 -0
  27. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  28. package/dist/es/components/Dropin/Dropin.js +1 -1
  29. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  30. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  31. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  32. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  33. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  34. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  35. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  36. package/dist/es/components/Dropin/elements/splitPaymentMethods.js +1 -1
  37. package/dist/es/components/Dropin/elements/splitPaymentMethods.js.map +1 -1
  38. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  39. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  40. package/dist/es/components/PayPalFastlane/Fastlane.js +2 -0
  41. package/dist/es/components/PayPalFastlane/Fastlane.js.map +1 -0
  42. package/dist/es/components/PayPalFastlane/FastlaneSDK.js +2 -0
  43. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -0
  44. package/dist/es/components/PayPalFastlane/components/FaslaneCardBrandIcon.js +2 -0
  45. package/dist/es/components/PayPalFastlane/components/FaslaneCardBrandIcon.js.map +1 -0
  46. package/dist/es/components/PayPalFastlane/components/FastlaneComponent.js +2 -0
  47. package/dist/es/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -0
  48. package/dist/es/components/PayPalFastlane/initializeFastlane.js +2 -0
  49. package/dist/es/components/PayPalFastlane/initializeFastlane.js.map +1 -0
  50. package/dist/es/components/PayPalFastlane/services/request-fastlane-token.js +2 -0
  51. package/dist/es/components/PayPalFastlane/services/request-fastlane-token.js.map +1 -0
  52. package/dist/es/components/PayPalFastlane/utils/convert-locale.js +2 -0
  53. package/dist/es/components/PayPalFastlane/utils/convert-locale.js.map +1 -0
  54. package/dist/es/components/components-name-map.js +1 -1
  55. package/dist/es/components/components-name-map.js.map +1 -1
  56. package/dist/es/components/index.js +1 -1
  57. package/dist/es/components/internal/Button/Button.js +1 -1
  58. package/dist/es/components/internal/Button/Button.js.map +1 -1
  59. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  60. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  61. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  62. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  63. package/dist/es/components/internal/Link/Link.js +2 -0
  64. package/dist/es/components/internal/Link/Link.js.map +1 -0
  65. package/dist/es/components/internal/Modal/Modal.js +1 -1
  66. package/dist/es/components/internal/Modal/Modal.js.map +1 -1
  67. package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
  68. package/dist/es/components/internal/Toggle/Toggle.js +2 -0
  69. package/dist/es/components/internal/Toggle/Toggle.js.map +1 -0
  70. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  71. package/dist/es/components/tx-variants.js +1 -1
  72. package/dist/es/components/tx-variants.js.map +1 -1
  73. package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
  74. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
  75. package/dist/es/core/Analytics/constants.js +1 -1
  76. package/dist/es/core/Analytics/constants.js.map +1 -1
  77. package/dist/es/core/Analytics/utils.js +1 -1
  78. package/dist/es/core/Analytics/utils.js.map +1 -1
  79. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  80. package/dist/es/core/core.js +1 -1
  81. package/dist/es/index.d.ts +681 -406
  82. package/dist/es/index.js +1 -1
  83. package/dist/es-legacy/adyen.css +9 -4
  84. package/dist/es-legacy/adyen.css.map +1 -1
  85. package/dist/es-legacy/components/ApplePay/utils/payment-request.js +1 -1
  86. package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -1
  87. package/dist/es-legacy/components/Card/Card.js +1 -1
  88. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  89. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  90. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  91. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  92. package/dist/es-legacy/components/Card/components/Fastlane/FastlaneSignup.js +2 -0
  93. package/dist/es-legacy/components/Card/components/Fastlane/FastlaneSignup.js.map +1 -0
  94. package/dist/es-legacy/components/Card/components/Fastlane/InfoButton.js +2 -0
  95. package/dist/es-legacy/components/Card/components/Fastlane/InfoButton.js.map +1 -0
  96. package/dist/es-legacy/components/Card/components/Fastlane/InfoModal.js +2 -0
  97. package/dist/es-legacy/components/Card/components/Fastlane/InfoModal.js.map +1 -0
  98. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js +2 -0
  99. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -0
  100. package/dist/es-legacy/components/Card/components/Fastlane/utils/mobile-number-formatter.js +2 -0
  101. package/dist/es-legacy/components/Card/components/Fastlane/utils/mobile-number-formatter.js.map +1 -0
  102. package/dist/es-legacy/components/Card/components/Fastlane/utils/validate-configuration.js +2 -0
  103. package/dist/es-legacy/components/Card/components/Fastlane/utils/validate-configuration.js.map +1 -0
  104. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  105. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  106. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  107. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  108. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  109. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  110. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  111. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  112. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  113. package/dist/es-legacy/components/Dropin/elements/splitPaymentMethods.js +1 -1
  114. package/dist/es-legacy/components/Dropin/elements/splitPaymentMethods.js.map +1 -1
  115. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  116. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  117. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js +2 -0
  118. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js.map +1 -0
  119. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js +2 -0
  120. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -0
  121. package/dist/es-legacy/components/PayPalFastlane/components/FaslaneCardBrandIcon.js +2 -0
  122. package/dist/es-legacy/components/PayPalFastlane/components/FaslaneCardBrandIcon.js.map +1 -0
  123. package/dist/es-legacy/components/PayPalFastlane/components/FastlaneComponent.js +2 -0
  124. package/dist/es-legacy/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -0
  125. package/dist/es-legacy/components/PayPalFastlane/initializeFastlane.js +2 -0
  126. package/dist/es-legacy/components/PayPalFastlane/initializeFastlane.js.map +1 -0
  127. package/dist/es-legacy/components/PayPalFastlane/services/request-fastlane-token.js +2 -0
  128. package/dist/es-legacy/components/PayPalFastlane/services/request-fastlane-token.js.map +1 -0
  129. package/dist/es-legacy/components/PayPalFastlane/utils/convert-locale.js +2 -0
  130. package/dist/es-legacy/components/PayPalFastlane/utils/convert-locale.js.map +1 -0
  131. package/dist/es-legacy/components/components-name-map.js +1 -1
  132. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  133. package/dist/es-legacy/components/index.js +1 -1
  134. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  135. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  136. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  137. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  138. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  139. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  140. package/dist/es-legacy/components/internal/Link/Link.js +2 -0
  141. package/dist/es-legacy/components/internal/Link/Link.js.map +1 -0
  142. package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
  143. package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
  144. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
  145. package/dist/es-legacy/components/internal/Toggle/Toggle.js +2 -0
  146. package/dist/es-legacy/components/internal/Toggle/Toggle.js.map +1 -0
  147. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  148. package/dist/es-legacy/components/tx-variants.js +1 -1
  149. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  150. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
  151. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
  152. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  153. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  154. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  155. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  156. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  157. package/dist/es-legacy/core/core.js +1 -1
  158. package/dist/es-legacy/index.js +1 -1
  159. package/package.json +3 -3
  160. package/styles/adyen.css +9 -4
@@ -1,2 +1,2 @@
1
- import{getDecimalAmount as t}from"../../../utils/amount-util.js";const e=e=>{const{countryCode:i,companyName:n,amount:o,...r}=e,a=(e=>String(t(e.value,e.currency)))(o);return i||console.warn("Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation"),{countryCode:i,currencyCode:o.currency,total:{label:r.totalPriceLabel,amount:a,type:r.totalPriceStatus},lineItems:r.lineItems,shippingMethods:r.shippingMethods,shippingType:r.shippingType,recurringPaymentRequest:r.recurringPaymentRequest,merchantCapabilities:r.merchantCapabilities,supportedCountries:r.supportedCountries,supportedNetworks:r.supportedNetworks,requiredShippingContactFields:r.requiredShippingContactFields,requiredBillingContactFields:r.requiredBillingContactFields,billingContact:r.billingContact,shippingContact:r.shippingContact,applicationData:r.applicationData}};export{e as default,e as preparePaymentRequest};
1
+ import{getDecimalAmount as t}from"../../../utils/amount-util.js";const e=e=>{const{countryCode:i,companyName:n,amount:o,...r}=e,a=(e=>String(t(e.value,e.currency)))(o);return i||console.warn("Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation"),{countryCode:i,currencyCode:o.currency,total:{label:r.totalPriceLabel,amount:a,type:r.totalPriceStatus},lineItems:r.lineItems,shippingContactEditingMode:r.shippingContactEditingMode,shippingMethods:r.shippingMethods,shippingType:r.shippingType,recurringPaymentRequest:r.recurringPaymentRequest,merchantCapabilities:r.merchantCapabilities,supportedCountries:r.supportedCountries,supportedNetworks:r.supportedNetworks,requiredShippingContactFields:r.requiredShippingContactFields,requiredBillingContactFields:r.requiredBillingContactFields,billingContact:r.billingContact,shippingContact:r.shippingContact,applicationData:r.applicationData}};export{e as default,e as preparePaymentRequest};
2
2
  //# sourceMappingURL=payment-request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-request.js","sources":["../../../../../src/components/ApplePay/utils/payment-request.ts"],"sourcesContent":["import { getDecimalAmount } from '../../../utils/amount-util';\nimport { PaymentAmount } from '../../../types/global-types';\n\nconst formatAmount = (amount: PaymentAmount) => String(getDecimalAmount(amount.value, amount.currency));\n\nexport const preparePaymentRequest = (paymentRequest): ApplePayJS.ApplePayPaymentRequest => {\n const { countryCode, companyName, amount, ...props } = paymentRequest;\n const formattedAmount = formatAmount(amount);\n\n if (!countryCode) {\n console.warn('Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation');\n }\n\n return {\n countryCode,\n currencyCode: amount.currency,\n\n total: {\n label: props.totalPriceLabel,\n amount: formattedAmount,\n type: props.totalPriceStatus\n },\n\n lineItems: props.lineItems,\n shippingMethods: props.shippingMethods,\n shippingType: props.shippingType,\n\n recurringPaymentRequest: props.recurringPaymentRequest,\n\n merchantCapabilities: props.merchantCapabilities,\n supportedCountries: props.supportedCountries,\n supportedNetworks: props.supportedNetworks,\n\n requiredShippingContactFields: props.requiredShippingContactFields,\n requiredBillingContactFields: props.requiredBillingContactFields,\n\n billingContact: props.billingContact,\n shippingContact: props.shippingContact,\n\n applicationData: props.applicationData\n };\n};\n\nexport default preparePaymentRequest;\n"],"names":["preparePaymentRequest","paymentRequest","countryCode","companyName","amount","props","formattedAmount","String","getDecimalAmount","value","currency","formatAmount","console","warn","currencyCode","total","label","totalPriceLabel","type","totalPriceStatus","lineItems","shippingMethods","shippingType","recurringPaymentRequest","merchantCapabilities","supportedCountries","supportedNetworks","requiredShippingContactFields","requiredBillingContactFields","billingContact","shippingContact","applicationData"],"mappings":"iEAGA,MAEaA,EAAyBC,IAClC,MAAMC,YAAEA,EAAWC,YAAEA,EAAWC,OAAEA,KAAWC,GAAUJ,EACjDK,EAJW,CAACF,GAA0BG,OAAOC,EAAiBJ,EAAOK,MAAOL,EAAOM,WAIjEC,CAAaP,GAMrC,OAJKF,GACDU,QAAQC,KAAK,uHAGV,CACHX,cACAY,aAAcV,EAAOM,SAErBK,MAAO,CACHC,MAAOX,EAAMY,gBACbb,OAAQE,EACRY,KAAMb,EAAMc,kBAGhBC,UAAWf,EAAMe,UACjBC,gBAAiBhB,EAAMgB,gBACvBC,aAAcjB,EAAMiB,aAEpBC,wBAAyBlB,EAAMkB,wBAE/BC,qBAAsBnB,EAAMmB,qBAC5BC,mBAAoBpB,EAAMoB,mBAC1BC,kBAAmBrB,EAAMqB,kBAEzBC,8BAA+BtB,EAAMsB,8BACrCC,6BAA8BvB,EAAMuB,6BAEpCC,eAAgBxB,EAAMwB,eACtBC,gBAAiBzB,EAAMyB,gBAEvBC,gBAAiB1B,EAAM0B,gBAC3B"}
1
+ {"version":3,"file":"payment-request.js","sources":["../../../../../src/components/ApplePay/utils/payment-request.ts"],"sourcesContent":["import { getDecimalAmount } from '../../../utils/amount-util';\nimport { PaymentAmount } from '../../../types/global-types';\n\nconst formatAmount = (amount: PaymentAmount) => String(getDecimalAmount(amount.value, amount.currency));\n\nexport const preparePaymentRequest = (paymentRequest): ApplePayJS.ApplePayPaymentRequest => {\n const { countryCode, companyName, amount, ...props } = paymentRequest;\n const formattedAmount = formatAmount(amount);\n\n if (!countryCode) {\n console.warn('Apple Pay - Make sure to set the countryCode in the AdyenCheckout configuration or in the Checkout Session creation');\n }\n\n return {\n countryCode,\n currencyCode: amount.currency,\n\n total: {\n label: props.totalPriceLabel,\n amount: formattedAmount,\n type: props.totalPriceStatus\n },\n\n lineItems: props.lineItems,\n shippingContactEditingMode: props.shippingContactEditingMode,\n shippingMethods: props.shippingMethods,\n shippingType: props.shippingType,\n\n recurringPaymentRequest: props.recurringPaymentRequest,\n\n merchantCapabilities: props.merchantCapabilities,\n supportedCountries: props.supportedCountries,\n supportedNetworks: props.supportedNetworks,\n\n requiredShippingContactFields: props.requiredShippingContactFields,\n requiredBillingContactFields: props.requiredBillingContactFields,\n\n billingContact: props.billingContact,\n shippingContact: props.shippingContact,\n\n applicationData: props.applicationData\n };\n};\n\nexport default preparePaymentRequest;\n"],"names":["preparePaymentRequest","paymentRequest","countryCode","companyName","amount","props","formattedAmount","String","getDecimalAmount","value","currency","formatAmount","console","warn","currencyCode","total","label","totalPriceLabel","type","totalPriceStatus","lineItems","shippingContactEditingMode","shippingMethods","shippingType","recurringPaymentRequest","merchantCapabilities","supportedCountries","supportedNetworks","requiredShippingContactFields","requiredBillingContactFields","billingContact","shippingContact","applicationData"],"mappings":"iEAGA,MAEaA,EAAyBC,IAClC,MAAMC,YAAEA,EAAWC,YAAEA,EAAWC,OAAEA,KAAWC,GAAUJ,EACjDK,EAJW,CAACF,GAA0BG,OAAOC,EAAiBJ,EAAOK,MAAOL,EAAOM,WAIjEC,CAAaP,GAMrC,OAJKF,GACDU,QAAQC,KAAK,uHAGV,CACHX,cACAY,aAAcV,EAAOM,SAErBK,MAAO,CACHC,MAAOX,EAAMY,gBACbb,OAAQE,EACRY,KAAMb,EAAMc,kBAGhBC,UAAWf,EAAMe,UACjBC,2BAA4BhB,EAAMgB,2BAClCC,gBAAiBjB,EAAMiB,gBACvBC,aAAclB,EAAMkB,aAEpBC,wBAAyBnB,EAAMmB,wBAE/BC,qBAAsBpB,EAAMoB,qBAC5BC,mBAAoBrB,EAAMqB,mBAC1BC,kBAAmBtB,EAAMsB,kBAEzBC,8BAA+BvB,EAAMuB,8BACrCC,6BAA8BxB,EAAMwB,6BAEpCC,eAAgBzB,EAAMyB,eACtBC,gBAAiB1B,EAAM0B,gBAEvBC,gBAAiB3B,EAAM2B,gBAC3B"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../external/preact/dist/preact.js";import o from"./components/CardInput/CardInput.js";import{CoreProvider as e}from"../../core/Context/CoreProvider.js";import s from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import p from"../internal/ClickToPay/services/create-clicktopay-service.js";import c from"./components/ClickToPayWrapper.js";import l from"../../core/Errors/SRPanelProvider.js";import{TxVariants as d}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import{ANALYTICS_RENDERED_STR as m,ANALYTICS_CONFIGURED_STR as y,ANALYTICS_FOCUS_STR as f,ANALYTICS_UNFOCUS_STR as b,ANALYTICS_VALIDATION_ERROR_STR as g}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as P}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as C}from"../../utils/hasOwnProperty.js";import S,{IMPLEMENTATION_ERROR as k}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as T}from"../../core/Errors/utils.js";import{SF_ErrorCodes as R}from"../../core/Errors/constants.js";import B from"./components/CardInput/defaultProps.js";function I(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}class M extends u{setStatus(t,o){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,o),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,o),this}formatProps(t){const o=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,e=!(0===t.amount?.value)&&o,s=t.storedPaymentMethodId||t.id,r=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!r)throw new S(k,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?B.billingAddressMode:t.billingAddressMode,brand:t.brand??d.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:o,showStoreDetailsCheckbox:e,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:M.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...a(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,o=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,o),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const o=n("supportedBrandsRaw").from(t);this.props.onBinLookup?.(o)}}submitAnalytics(t){const{type:o}=t;o!==m&&o!==y||"scheme"===this.constructor.type&&C(this.props,"supportedShopperInteractions")&&(t.isStoredPaymentMethod=!0,t.brand=this.props.brand),super.submitAnalytics(t,this.props)}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:o}=this.props;return t?t.map((t=>({icon:o[t]?.icon??this.props.modules.resources.getImage()(t),name:t}))):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||M.type}get accessibleName(){return(this.props.name||M.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return s()}renderCardInput(e=!0){return t(o,{setComponentRef:this.setComponentRef,...this.props,...this.state,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:e,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onValidationErrorAnalytics:this.onValidationErrorAnalytics,onConfigSuccess:this.onConfigSuccess})}render(){return t(e,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(l,{srPanel:this.props.modules.srPanel},t(c,{amount:this.props.amount,configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},(t=>this.renderCardInput(t)))))}constructor(o,e){super(o,e),I(this,"clickToPayService",void 0),I(this,"clickToPayRef",null),I(this,"setClickToPayRef",(t=>{this.clickToPayRef=t})),I(this,"onBrand",(t=>{this.props.onBrand?.(t)})),I(this,"handleClickToPaySubmit",(t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()})),I(this,"onConfigSuccess",(t=>{this.submitAnalytics({type:y}),this.props.onConfigSuccess?.(t)})),I(this,"onFocus",(t=>{this.submitAnalytics({type:f,target:i(t.fieldType)}),P.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)})),I(this,"onBlur",(t=>{this.submitAnalytics({type:b,target:i(t.fieldType)}),P.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)})),I(this,"onValidationErrorAnalytics",(t=>{this.submitAnalytics({type:g,target:i(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:T(t.errorCode,R)})})),I(this,"onBinValue",r(this)),I(this,"payButton",(o=>{const e=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...o,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:e&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})})),e&&!e._disableClickToPay&&(this.clickToPayService=p(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),this.clickToPayService?.initialize())}}I(M,"type",d.scheme),I(M,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...n(["type","setComponentRef"]).from(B)});export{M as CardElement,M as default};
1
+ import{createElement as t}from"../../external/preact/dist/preact.js";import e from"./components/CardInput/CardInput.js";import{CoreProvider as o}from"../../core/Context/CoreProvider.js";import s from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{reject as n}from"../../utils/commonUtils.js";import{hasValidInstallmentsObject as a}from"./components/CardInput/utils.js";import p from"../internal/ClickToPay/services/create-clicktopay-service.js";import l from"./components/ClickToPayWrapper.js";import c from"../../core/Errors/SRPanelProvider.js";import{TxVariants as d}from"../tx-variants.js";import{UIElement as u}from"../internal/UIElement/UIElement.js";import h from"../internal/PayButton/PayButton.js";import{ANALYTICS_RENDERED_STR as m,ANALYTICS_CONFIGURED_STR as y,ANALYTICS_FOCUS_STR as f,ANALYTICS_UNFOCUS_STR as b,ANALYTICS_VALIDATION_ERROR_STR as g}from"../../core/Analytics/constants.js";import{ALL_SECURED_FIELDS as P}from"../internal/SecuredFields/lib/constants.js";import{hasOwnProperty as C}from"../../utils/hasOwnProperty.js";import S,{IMPLEMENTATION_ERROR as k}from"../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as T}from"../../core/Errors/utils.js";import{SF_ErrorCodes as R}from"../../core/Errors/constants.js";import B from"./components/CardInput/defaultProps.js";function I(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class A extends u{setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this.clickToPayRef?.setStatus&&this.clickToPayRef.setStatus(t,e),this}formatProps(t){const e=t.session?.configuration?.enableStoreDetails??t.enableStoreDetails,o=!(0===t.amount?.value)&&e,s=t.storedPaymentMethodId||t.id,r=s&&t?.supportedShopperInteractions?.includes("Ecommerce");if(s&&!r)throw new S(k,"You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions");return{...t,holderNameRequired:!!t.hasHolderName&&t.holderNameRequired,hasCVC:!(t.brand&&"bcmc"===t.brand||t.hideCVC),billingAddressRequired:!t.storedPaymentMethodId&&t.billingAddressRequired,billingAddressMode:t.onAddressLookup?B.billingAddressMode:t.billingAddressMode,brand:t.brand??d.card,countryCode:t.countryCode?t.countryCode.toLowerCase():null,configuration:{...t.configuration,socialSecurityNumberMode:t.configuration?.socialSecurityNumberMode??"auto"},brandsConfiguration:t.brandsConfiguration||t.configuration?.brandsConfiguration||{},icon:t.icon||t.configuration?.icon,installmentOptions:t.session?.configuration?.installmentOptions||t.installmentOptions,enableStoreDetails:e,showStoreDetailsCheckbox:o,clickToPayConfiguration:{...t.clickToPayConfiguration,disableOtpAutoFocus:t.clickToPayConfiguration?.disableOtpAutoFocus||!1,shopperEmail:t.clickToPayConfiguration?.shopperEmail||this.core.options?.session?.shopperEmail,telephoneNumber:t.clickToPayConfiguration?.telephoneNumber||this.core.options?.session?.telephoneNumber,locale:t.clickToPayConfiguration?.locale||t.i18n?.locale?.replace("-","_")},...s&&{storedPaymentMethodId:s}}}formatData(){const t=this.state.selectedBrandValue;return{paymentMethod:{type:A.type,...this.state.data,...this.props.storedPaymentMethodId&&{storedPaymentMethodId:this.props.storedPaymentMethodId,holderName:this.props.holderName??""},...t&&{brand:t},...this.props.fundingSource&&{fundingSource:this.props.fundingSource},...this.state.fastlaneData&&{fastlaneData:btoa(JSON.stringify(this.state.fastlaneData))}},...this.state.billingAddress&&{billingAddress:this.state.billingAddress},...this.state.socialSecurityNumber&&{socialSecurityNumber:this.state.socialSecurityNumber},...this.storePaymentMethodPayload,...a(this.state.installments)&&{installments:this.state.installments},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}updateStyles(t){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(t),this}setFocusOn(t){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(t),this}processBinLookupResponse(t,e=!1){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(t,e),this}handleUnsupportedCard(t){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(t),this}onBinLookup(t){if(!t.isReset){const e=n("supportedBrandsRaw").from(t);this.props.onBinLookup?.(e)}}submitAnalytics(t){const{type:e}=t;e!==m&&e!==y||"scheme"===this.constructor.type&&C(this.props,"supportedShopperInteractions")&&(t.isStoredPaymentMethod=!0,t.brand=this.props.brand),super.submitAnalytics(t,this.props)}get storePaymentMethodPayload(){if(this.props.storedPaymentMethodId?.length>0)return{};if(0===this.props.amount?.value)return this.props.enableStoreDetails?{storePaymentMethod:!0}:{};return this.props.showStoreDetailsCheckbox&&void 0!==this.state.storePaymentMethod?{storePaymentMethod:Boolean(this.state.storePaymentMethod)}:{}}get isValid(){return!!this.state.isValid}get icon(){return this.props.icon??this.resources.getImage()(this.props.brand)}get brands(){const{brands:t,brandsConfiguration:e}=this.props;return t?t.map((t=>({icon:e[t]?.icon??this.props.modules.resources.getImage()(t),name:t}))):[]}get displayName(){return this.props.storedPaymentMethodId?`•••• ${this.props.lastFour}`:this.props.name||A.type}get accessibleName(){return(this.props.name||A.type)+(this.props.storedPaymentMethodId?" "+this.props.i18n.get("creditCard.storedCard.description.ariaLabel").replace("%@",this.props.lastFour):"")}get browserInfo(){return s()}renderCardInput(o=!0){return t(e,{setComponentRef:this.setComponentRef,...this.props,...this.state,onSubmitAnalytics:this.submitAnalytics,onChange:this.setState,onSubmit:this.submit,handleKeyPress:this.handleKeyPress,payButton:this.payButton,onBrand:this.onBrand,onBinValue:this.onBinValue,brand:this.props.brand,brandsIcons:this.brands,isPayButtonPrimaryVariant:o,resources:this.resources,onFocus:this.onFocus,onBlur:this.onBlur,onValidationErrorAnalytics:this.onValidationErrorAnalytics,onConfigSuccess:this.onConfigSuccess})}render(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(c,{srPanel:this.props.modules.srPanel},t(l,{amount:this.props.amount,configuration:this.props.clickToPayConfiguration,clickToPayService:this.clickToPayService,isStandaloneComponent:!1,setClickToPayRef:this.setClickToPayRef,onSetStatus:this.setElementStatus,onSubmit:this.handleClickToPaySubmit,onError:this.handleError},(t=>this.renderCardInput(t)))))}constructor(e,o){super(e,o),I(this,"clickToPayService",void 0),I(this,"clickToPayRef",null),I(this,"setClickToPayRef",(t=>{this.clickToPayRef=t})),I(this,"onBrand",(t=>{this.props.onBrand?.(t)})),I(this,"handleClickToPaySubmit",(t=>{this.setState({data:{...t},valid:{},errors:{},isValid:!0}),this.submit()})),I(this,"onConfigSuccess",(t=>{this.submitAnalytics({type:y}),this.props.onConfigSuccess?.(t)})),I(this,"onFocus",(t=>{this.submitAnalytics({type:f,target:i(t.fieldType)}),P.includes(t.fieldType)?this.props.onFocus?.(t.event):this.props.onFocus?.(t)})),I(this,"onBlur",(t=>{this.submitAnalytics({type:b,target:i(t.fieldType)}),P.includes(t.fieldType)?this.props.onBlur?.(t.event):this.props.onBlur?.(t)})),I(this,"onValidationErrorAnalytics",(t=>{this.submitAnalytics({type:g,target:i(t.fieldType),validationErrorCode:t.errorCode,validationErrorMessage:T(t.errorCode,R)})})),I(this,"onBinValue",r(this)),I(this,"payButton",(e=>{const o=0===this.props.amount?.value,s=this.props.storedPaymentMethodId?.length>0;return t(h,{...e,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,label:o&&!s?this.props.i18n.get("payButton.saveDetails"):"",onClick:this.submit})})),o&&!o._disableClickToPay&&(this.clickToPayService=p(this.props.configuration,this.props.clickToPayConfiguration,this.props.environment),this.clickToPayService?.initialize())}}I(A,"type",d.scheme),I(A,"defaultProps",{showFormInstruction:!0,_disableClickToPay:!1,doBinLookup:!0,...n(["type","setComponentRef"]).from(B)});export{A as CardElement,A as default};
2
2
  //# sourceMappingURL=Card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardConfigSuccessData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject } from '../../types/global-types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport {\n ANALYTICS_FOCUS_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_RENDERED_STR\n} from '../../core/Analytics/constants';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../core/Analytics/types';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { getErrorMessageFromCode } from '../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../core/Errors/constants';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(this.props.configuration, this.props.clickToPayConfiguration, this.props.environment);\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\n };\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n // installmentOptions of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = event => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n const { type } = analyticsObj;\n\n if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) {\n // Check if it's a storedCard\n if (this.constructor['type'] === 'scheme') {\n if (hasOwnProperty(this.props, 'supportedShopperInteractions')) {\n analyticsObj.isStoredPaymentMethod = true;\n analyticsObj.brand = this.props.brand;\n }\n }\n }\n\n super.submitAnalytics(analyticsObj, this.props);\n }\n\n private onConfigSuccess = (obj: CardConfigSuccessData) => {\n this.submitAnalytics({\n type: ANALYTICS_CONFIGURED_STR\n });\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_FOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_UNFOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n private onValidationErrorAnalytics = (obj: FieldErrorAnalyticsObject) => {\n this.submitAnalytics({\n type: ANALYTICS_VALIDATION_ERROR_STR,\n target: fieldTypeToSnakeCase(obj.fieldType),\n validationErrorCode: obj.errorCode,\n validationErrorMessage: getErrorMessageFromCode(obj.errorCode, SF_ErrorCodes)\n });\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): { icon: any; name: string }[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onValidationErrorAnalytics={this.onValidationErrorAnalytics}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <ClickToPayWrapper\n amount={this.props.amount}\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","props","this","componentRef","clickToPayRef","formatProps","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","holderName","fundingSource","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","constructor","hasOwnProperty","isStoredPaymentMethod","super","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onValidationErrorAnalytics","onConfigSuccess","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","checkout","_define_property","ref","event","payload","valid","errors","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","ANALYTICS_UNFOCUS_STR","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"2hDAmCO,MAAMA,UAAoBC,EA2BtBC,SAAAA,CAAUC,EAAyBC,GAOtC,OANIC,KAAKC,cAAcJ,WACnBG,KAAKC,aAAaJ,UAAUC,EAAQC,GAEpCC,KAAKE,eAAeL,WACpBG,KAAKE,cAAcL,UAAUC,EAAQC,GAElCC,IACX,CAMAG,WAAAA,CAAYJ,GAER,MAAMK,EAAqBL,EAAMM,SAASC,eAAeF,oBAAsBL,EAAMK,mBAG/EG,IADqC,IAAxBR,EAAMS,QAAQC,QACqBL,EAEhDM,EAAeX,EAAMY,uBAAyBZ,EAAMa,GACpDC,EAAwBH,GAAgBX,GAAOe,8BAA8BC,SAAS,aAG5F,GAAIL,IAAiBG,EAEjB,MAAM,IAAIG,EACNC,EACA,uGAIR,MA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B,EACpBO,aAAa,KAEV3F,EAAO,CAAC,OAAQ,oBAAoBC,KAAKjD"}
1
+ {"version":3,"file":"Card.js","sources":["../../../../src/components/Card/Card.tsx"],"sourcesContent":["import { h } from 'preact';\nimport CardInput from './components/CardInput';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport { BinLookupResponse, CardElementData, CardConfiguration } from './types';\nimport triggerBinLookUp from '../internal/SecuredFields/binLookup/triggerBinLookUp';\nimport { CardBinLookupData, CardConfigSuccessData, CardFocusData } from '../internal/SecuredFields/lib/types';\nimport { fieldTypeToSnakeCase } from '../internal/SecuredFields/utils';\nimport { reject } from '../../utils/commonUtils';\nimport { hasValidInstallmentsObject } from './components/CardInput/utils';\nimport createClickToPayService from '../internal/ClickToPay/services/create-clicktopay-service';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../internal/ClickToPay/services/types';\nimport ClickToPayWrapper from './components/ClickToPayWrapper';\nimport { ComponentFocusObject } from '../../types/global-types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport type { PayButtonFunctionProps, UIElementStatus } from '../internal/UIElement/types';\nimport UIElement from '../internal/UIElement';\nimport PayButton from '../internal/PayButton';\nimport type { ICore } from '../../core/types';\nimport {\n ANALYTICS_FOCUS_STR,\n ANALYTICS_CONFIGURED_STR,\n ANALYTICS_UNFOCUS_STR,\n ANALYTICS_VALIDATION_ERROR_STR,\n ANALYTICS_RENDERED_STR\n} from '../../core/Analytics/constants';\nimport { ALL_SECURED_FIELDS } from '../internal/SecuredFields/lib/constants';\nimport { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../core/Analytics/types';\nimport { hasOwnProperty } from '../../utils/hasOwnProperty';\nimport AdyenCheckoutError, { IMPLEMENTATION_ERROR } from '../../core/Errors/AdyenCheckoutError';\nimport { getErrorMessageFromCode } from '../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../core/Errors/constants';\nimport CardInputDefaultProps from './components/CardInput/defaultProps';\n\nexport class CardElement extends UIElement<CardConfiguration> {\n public static type = TxVariants.scheme;\n\n private readonly clickToPayService: IClickToPayService | null;\n\n /**\n * Reference to the 'ClickToPayComponent'\n */\n private clickToPayRef = null;\n\n constructor(checkout: ICore, props?: CardConfiguration) {\n super(checkout, props);\n\n if (props && !props._disableClickToPay) {\n this.clickToPayService = createClickToPayService(this.props.configuration, this.props.clickToPayConfiguration, this.props.environment);\n void this.clickToPayService?.initialize();\n }\n }\n\n protected static defaultProps = {\n showFormInstruction: true,\n _disableClickToPay: false,\n doBinLookup: true,\n // Merge most of CardInput's defaultProps\n ...reject(['type', 'setComponentRef']).from(CardInputDefaultProps)\n };\n\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n if (this.clickToPayRef?.setStatus) {\n this.clickToPayRef.setStatus(status, props);\n }\n return this;\n }\n\n private setClickToPayRef = ref => {\n this.clickToPayRef = ref;\n };\n\n formatProps(props: CardConfiguration): CardConfiguration {\n // The value from a session should be used, before falling back to the merchant configuration\n const enableStoreDetails = props.session?.configuration?.enableStoreDetails ?? props.enableStoreDetails;\n\n const isZeroAuth = props.amount?.value === 0;\n const showStoreDetailsCheckbox = isZeroAuth ? false : enableStoreDetails;\n\n const storedCardID = props.storedPaymentMethodId || props.id; // check if we've been passed a (checkout) processed storedCard or one that merchant has pulled from the PMs response\n const isEcommerceStoredCard = storedCardID && props?.supportedShopperInteractions?.includes('Ecommerce'); // If we have a storedCard does it support Ecommerce (it might not if the merchant has pulled it from the PMs response)\n\n // If we have a storedPM but it doesn't support Ecommerce - we can't make a storedCard component from it\n if (storedCardID && !isEcommerceStoredCard) {\n // TODO - Decide if an error is too severe? Would a console.warning suffice?\n throw new AdyenCheckoutError(\n IMPLEMENTATION_ERROR,\n 'You are trying to create a storedCard from a stored PM that does not support Ecommerce interactions'\n );\n }\n\n return {\n ...props,\n // Mismatch between hasHolderName & holderNameRequired which can mean card can never be valid\n holderNameRequired: !props.hasHolderName ? false : props.holderNameRequired,\n // False for *stored* BCMC cards & if merchant explicitly wants to hide the CVC field\n hasCVC: !((props.brand && props.brand === 'bcmc') || props.hideCVC),\n // billingAddressRequired only available for non-stored cards\n billingAddressRequired: props.storedPaymentMethodId ? false : props.billingAddressRequired,\n // edge case where merchant has defined both an onAddressLookup callback AND set billingAddressMode: 'partial' - which leads to some strange behaviour in the address UI\n billingAddressMode: props.onAddressLookup ? CardInputDefaultProps.billingAddressMode : props.billingAddressMode,\n /** props.brand will be specified in the case of a StoredCard or a Bancontact component, for a regular Card we default it to 'card' */\n brand: props.brand ?? TxVariants.card,\n countryCode: props.countryCode ? props.countryCode.toLowerCase() : null,\n // Required for transition period (until configuration object becomes the norm)\n // - if merchant has defined value directly in props, use this instead\n configuration: {\n ...props.configuration,\n socialSecurityNumberMode: props.configuration?.socialSecurityNumberMode ?? 'auto'\n },\n brandsConfiguration: props.brandsConfiguration || props.configuration?.brandsConfiguration || {},\n icon: props.icon || props.configuration?.icon,\n // installmentOptions of a session should be used before falling back to the merchant configuration\n installmentOptions: props.session?.configuration?.installmentOptions || props.installmentOptions,\n enableStoreDetails,\n showStoreDetailsCheckbox,\n /**\n * Click to Pay configuration\n * - If email is set explicitly in the configuration, then it can override the one used in the session creation\n */\n clickToPayConfiguration: {\n ...props.clickToPayConfiguration,\n disableOtpAutoFocus: props.clickToPayConfiguration?.disableOtpAutoFocus || false,\n shopperEmail: props.clickToPayConfiguration?.shopperEmail || this.core.options?.session?.shopperEmail,\n telephoneNumber: props.clickToPayConfiguration?.telephoneNumber || this.core.options?.session?.telephoneNumber,\n locale: props.clickToPayConfiguration?.locale || props.i18n?.locale?.replace('-', '_')\n },\n ...(storedCardID && { storedPaymentMethodId: storedCardID })\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): CardElementData {\n /**\n * this.state.selectedBrandValue will be set when:\n * - /binLookup detects a single brand,\n * - when /binLookup detects a dual-branded card and the shopper makes a brand selection\n * - or, in the case of a storedCard\n */\n const cardBrand = this.state.selectedBrandValue;\n\n return {\n paymentMethod: {\n type: CardElement.type,\n ...this.state.data,\n ...(this.props.storedPaymentMethodId && {\n storedPaymentMethodId: this.props.storedPaymentMethodId,\n holderName: this.props.holderName ?? ''\n }),\n ...(cardBrand && { brand: cardBrand }),\n ...(this.props.fundingSource && { fundingSource: this.props.fundingSource }),\n ...(this.state.fastlaneData && { fastlaneData: btoa(JSON.stringify(this.state.fastlaneData)) })\n },\n ...(this.state.billingAddress && { billingAddress: this.state.billingAddress }),\n ...(this.state.socialSecurityNumber && { socialSecurityNumber: this.state.socialSecurityNumber }),\n ...this.storePaymentMethodPayload,\n ...(hasValidInstallmentsObject(this.state.installments) && { installments: this.state.installments }),\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin\n };\n }\n\n updateStyles(stylesObj) {\n if (this.componentRef?.updateStyles) this.componentRef.updateStyles(stylesObj);\n return this;\n }\n\n setFocusOn(fieldName) {\n if (this.componentRef?.setFocusOn) this.componentRef.setFocusOn(fieldName);\n return this;\n }\n\n public onBrand = event => {\n this.props.onBrand?.(event);\n };\n\n processBinLookupResponse(binLookupResponse: BinLookupResponse, isReset = false) {\n if (this.componentRef?.processBinLookupResponse) this.componentRef.processBinLookupResponse(binLookupResponse, isReset);\n return this;\n }\n\n handleUnsupportedCard(errObj) {\n if (this.componentRef?.handleUnsupportedCard) this.componentRef.handleUnsupportedCard(errObj);\n return this;\n }\n\n private handleClickToPaySubmit = (payload: ClickToPayCheckoutPayload) => {\n this.setState({ data: { ...payload }, valid: {}, errors: {}, isValid: true });\n this.submit();\n };\n\n onBinLookup(obj: CardBinLookupData) {\n // Handler for regular card comp doesn't need this 'raw' data or to know about 'resets'\n if (!obj.isReset) {\n const nuObj = reject('supportedBrandsRaw').from(obj);\n this.props.onBinLookup?.(nuObj);\n }\n }\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject) {\n const { type } = analyticsObj;\n\n if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) {\n // Check if it's a storedCard\n if (this.constructor['type'] === 'scheme') {\n if (hasOwnProperty(this.props, 'supportedShopperInteractions')) {\n analyticsObj.isStoredPaymentMethod = true;\n analyticsObj.brand = this.props.brand;\n }\n }\n }\n\n super.submitAnalytics(analyticsObj, this.props);\n }\n\n private onConfigSuccess = (obj: CardConfigSuccessData) => {\n this.submitAnalytics({\n type: ANALYTICS_CONFIGURED_STR\n });\n\n this.props.onConfigSuccess?.(obj);\n };\n\n private onFocus = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_FOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onFocus?.(obj.event as CardFocusData);\n } else {\n this.props.onFocus?.(obj);\n }\n };\n\n private onBlur = (obj: ComponentFocusObject) => {\n this.submitAnalytics({\n type: ANALYTICS_UNFOCUS_STR,\n target: fieldTypeToSnakeCase(obj.fieldType)\n });\n\n // Call merchant defined callback\n if (ALL_SECURED_FIELDS.includes(obj.fieldType)) {\n this.props.onBlur?.(obj.event as CardFocusData);\n } else {\n this.props.onBlur?.(obj);\n }\n };\n\n private onValidationErrorAnalytics = (obj: FieldErrorAnalyticsObject) => {\n this.submitAnalytics({\n type: ANALYTICS_VALIDATION_ERROR_STR,\n target: fieldTypeToSnakeCase(obj.fieldType),\n validationErrorCode: obj.errorCode,\n validationErrorMessage: getErrorMessageFromCode(obj.errorCode, SF_ErrorCodes)\n });\n };\n\n public onBinValue = triggerBinLookUp(this);\n\n get storePaymentMethodPayload() {\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n if (isStoredCard) {\n return {};\n }\n\n /**\n * For regular card, zero auth payments, we store the payment method, *if* the configuration says we should:\n * - For sessions, this means if the session has been created with storePaymentMethodMode: 'askForConsent'\n * - For the advanced flow, this means if the merchant has still set enableStoreDetails: true\n *\n * What we are doing is.. if for a normal payment we would show the \"Save for my next payment\" checkbox,\n * for a zero-auth payment we effectively click the checkbox on behalf of the shopper.\n */\n const isZeroAuth = this.props.amount?.value === 0;\n if (isZeroAuth) {\n return this.props.enableStoreDetails ? { storePaymentMethod: true } : {};\n }\n\n // For regular card, non-zero auth payments, we store the payment method based on the checkbox value.\n const includeStorePaymentMethod = this.props.showStoreDetailsCheckbox && typeof this.state.storePaymentMethod !== 'undefined';\n return includeStorePaymentMethod ? { storePaymentMethod: Boolean(this.state.storePaymentMethod) } : {};\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.icon ?? this.resources.getImage()(this.props.brand);\n }\n\n get brands(): { icon: any; name: string }[] {\n const { brands, brandsConfiguration } = this.props;\n if (brands) {\n return brands.map(brand => {\n const brandIcon = brandsConfiguration[brand]?.icon ?? this.props.modules.resources.getImage()(brand);\n return { icon: brandIcon, name: brand };\n });\n }\n\n return [];\n }\n\n get displayName(): string {\n if (this.props.storedPaymentMethodId) {\n return `•••• ${this.props.lastFour}`;\n }\n\n return this.props.name || CardElement.type;\n }\n\n get accessibleName(): string {\n // Use display name, unless it's a stored payment method, there inform user\n return (\n (this.props.name || CardElement.type) +\n (this.props.storedPaymentMethodId\n ? ' ' + this.props.i18n.get('creditCard.storedCard.description.ariaLabel').replace('%@', this.props.lastFour)\n : '')\n );\n }\n\n get browserInfo() {\n return collectBrowserInfo();\n }\n\n protected override payButton = (props: PayButtonFunctionProps) => {\n const isZeroAuth = this.props.amount?.value === 0;\n const isStoredCard = this.props.storedPaymentMethodId?.length > 0;\n return (\n <PayButton\n {...props}\n amount={this.props.amount}\n secondaryAmount={this.props.secondaryAmount}\n label={isZeroAuth && !isStoredCard ? this.props.i18n.get('payButton.saveDetails') : ''}\n onClick={this.submit}\n />\n );\n };\n\n private renderCardInput(isCardPrimaryInput = true): h.JSX.Element {\n return (\n <CardInput\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onSubmitAnalytics={this.submitAnalytics}\n onChange={this.setState}\n onSubmit={this.submit}\n handleKeyPress={this.handleKeyPress}\n payButton={this.payButton}\n onBrand={this.onBrand}\n onBinValue={this.onBinValue}\n brand={this.props.brand}\n brandsIcons={this.brands}\n isPayButtonPrimaryVariant={isCardPrimaryInput}\n resources={this.resources}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n onValidationErrorAnalytics={this.onValidationErrorAnalytics}\n onConfigSuccess={this.onConfigSuccess}\n />\n );\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <ClickToPayWrapper\n amount={this.props.amount}\n configuration={this.props.clickToPayConfiguration}\n clickToPayService={this.clickToPayService}\n isStandaloneComponent={false}\n setClickToPayRef={this.setClickToPayRef}\n onSetStatus={this.setElementStatus}\n onSubmit={this.handleClickToPaySubmit}\n onError={this.handleError}\n >\n {isCardPrimaryInput => this.renderCardInput(isCardPrimaryInput)}\n </ClickToPayWrapper>\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default CardElement;\n"],"names":["CardElement","UIElement","setStatus","status","props","this","componentRef","clickToPayRef","formatProps","enableStoreDetails","session","configuration","showStoreDetailsCheckbox","amount","value","storedCardID","storedPaymentMethodId","id","isEcommerceStoredCard","supportedShopperInteractions","includes","AdyenCheckoutError","IMPLEMENTATION_ERROR","holderNameRequired","hasHolderName","hasCVC","brand","hideCVC","billingAddressRequired","billingAddressMode","onAddressLookup","CardInputDefaultProps","TxVariants","card","countryCode","toLowerCase","socialSecurityNumberMode","brandsConfiguration","icon","installmentOptions","clickToPayConfiguration","disableOtpAutoFocus","shopperEmail","core","options","telephoneNumber","locale","i18n","replace","formatData","cardBrand","state","selectedBrandValue","paymentMethod","type","data","holderName","fundingSource","fastlaneData","btoa","JSON","stringify","billingAddress","socialSecurityNumber","storePaymentMethodPayload","hasValidInstallmentsObject","installments","browserInfo","origin","window","location","updateStyles","stylesObj","setFocusOn","fieldName","processBinLookupResponse","binLookupResponse","isReset","handleUnsupportedCard","errObj","onBinLookup","obj","nuObj","reject","from","submitAnalytics","analyticsObj","ANALYTICS_RENDERED_STR","ANALYTICS_CONFIGURED_STR","constructor","hasOwnProperty","isStoredPaymentMethod","super","length","storePaymentMethod","Boolean","isValid","resources","getImage","brands","map","modules","name","displayName","lastFour","accessibleName","get","collectBrowserInfo","renderCardInput","isCardPrimaryInput","h","CardInput","setComponentRef","onSubmitAnalytics","onChange","setState","onSubmit","submit","handleKeyPress","payButton","onBrand","onBinValue","brandsIcons","isPayButtonPrimaryVariant","onFocus","onBlur","onValidationErrorAnalytics","onConfigSuccess","render","CoreProvider","loadingContext","SRPanelProvider","srPanel","ClickToPayWrapper","clickToPayService","isStandaloneComponent","setClickToPayRef","onSetStatus","setElementStatus","handleClickToPaySubmit","onError","handleError","checkout","_define_property","ref","event","payload","valid","errors","ANALYTICS_FOCUS_STR","target","fieldTypeToSnakeCase","fieldType","ALL_SECURED_FIELDS","ANALYTICS_UNFOCUS_STR","ANALYTICS_VALIDATION_ERROR_STR","validationErrorCode","errorCode","validationErrorMessage","getErrorMessageFromCode","SF_ErrorCodes","triggerBinLookUp","isZeroAuth","isStoredCard","PayButton","secondaryAmount","label","onClick","_disableClickToPay","createClickToPayService","environment","initialize","scheme","defaultProps","showFormInstruction","doBinLookup"],"mappings":"2hDAmCO,MAAMA,UAAoBC,EA2BtBC,SAAAA,CAAUC,EAAyBC,GAOtC,OANIC,KAAKC,cAAcJ,WACnBG,KAAKC,aAAaJ,UAAUC,EAAQC,GAEpCC,KAAKE,eAAeL,WACpBG,KAAKE,cAAcL,UAAUC,EAAQC,GAElCC,IACX,CAMAG,WAAAA,CAAYJ,GAER,MAAMK,EAAqBL,EAAMM,SAASC,eAAeF,oBAAsBL,EAAMK,mBAG/EG,IADqC,IAAxBR,EAAMS,QAAQC,QACqBL,EAEhDM,EAAeX,EAAMY,uBAAyBZ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,KAAKiI,kBAAoBmC,EAAwBpK,KAAKD,MAAMO,cAAeN,KAAKD,MAAMoC,wBAAyBnC,KAAKD,MAAMsK,aACrHrK,KAAKiI,mBAAmBqC,aAErC,EAhBA5B,EADS/I,EACKsD,OAAOtB,EAAW4I,QAkBhC7B,EAnBS/I,EAmBQ6K,eAAe,CAC5BC,qBAAqB,EACrBN,oBAAoB,EACpBO,aAAa,KAEV5F,EAAO,CAAC,OAAQ,oBAAoBC,KAAKrD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as r}from"../../../../external/preact/dist/preact.js";import{useRef as s,useMemo as t,useState as o,useCallback as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import l from"./defaultProps.js";import{AddressModeOptions as d}from"./types.js";import{ENCRYPTED_CARD_NUMBER as u,DATE_POLICY_REQUIRED as c,CVC_POLICY_REQUIRED as m}from"../../../internal/SecuredFields/lib/constants.js";import{cardInputValidationRules as p,getRuleByNameAndMode as h,cardInputFormatters as b}from"./validate.js";import f from"../../../internal/SecuredFields/binLookup/extensions.js";import y from"../../../../utils/useForm/useForm.js";import{handlePartialAddressMode as N,extractPropsForSFP as S,extractPropsForCardFields as g,getLayout as A}from"./utils.js";import F from"../../../internal/Address/Specifications.js";import{StoredCardFieldsWrapper as C}from"./components/StoredCardFieldsWrapper.js";import{CardFieldsWrapper as j}from"./components/CardFieldsWrapper.js";import{getAutoJumpHandler as k,getFocusHandler as R,getAddressHandler as x}from"./handlers.js";import v from"../../../../_virtual/index.js";import{getPartialAddressValidationRules as P}from"../../../internal/Address/validate.js";import w from"../../../../core/Context/useImage.js";import{getArrayDifferences as I}from"../../../../utils/arrayUtils.js";import B from"../../../internal/FormInstruction/FormInstruction.js";import{PREFIX as V}from"../../../internal/Icon/constants.js";import E from"./useSRPanelForCardInputErrors.js";const O=l=>{const O=s(null),q=s(!1),M=w(),D=s(null),_=e=>{D.current=e},L=s({});Object.keys(L.current).length||l.setComponentRef(L.current);const T=s(0),K=s(!1),H=t((()=>new F(l.specifications)),[l.specifications]);L.current.sfp=O;const[U,z]=o("ready"),[W,$]=o({}),[G,J]=o({...l.holderNameRequired&&{holderName:!1}}),[Q,X]=o({...l.hasHolderName&&{holderName:l.data.holderName??""}}),[Y,Z]=o(""),[ee,re]=o(!1),[se,te]=o(c),[oe,ne]=o(m),[ae,ie]=o(null),[le,de]=o([]),[ue,ce]=o(l.storedPaymentMethodId?l.brand:""),me=l.billingAddressMode!==d.none&&l.billingAddressRequired,pe=N(l.billingAddressMode),he=s(pe&&l.data?.billingAddress?.country),[be,fe]=o(!1),[ye,Ne]=o(me?l.data.billingAddress:null),[Se,ge]=o(!1),[Ae,Fe]=o(""),[Ce,je]=o({value:null}),[ke,Re]=o(null),[xe,ve]=o("card"),{handleChangeFor:Pe,triggerValidation:we,data:Ie,valid:Be,errors:Ve,setSchema:Ee,setData:Oe,setValid:qe,setErrors:Me}=y({schema:[],defaultData:l.data,formatters:b,rules:p}),De=!!Object.keys(l.installmentOptions).length&&"debit"!==l.fundingSource,_e=l.showInstallmentAmounts??!0,Le="kr"===(ae??l.countryCode),Te=l.configuration.koreanAuthenticationRequired&&Le,Ke=Se&&"auto"===l.configuration.socialSecurityNumberMode||"show"===l.configuration.socialSecurityNumberMode,He=(e,r)=>{l.onFocus({fieldType:e,event:r})},Ue=(e,r)=>{l.onBlur({fieldType:e,event:r})},ze=n((e=>{ve(e.brand),l.onBrand(e)}),[]),We=R(Z,He,Ue),$e=()=>A({props:l,showKCP:Te,showBrazilianSSN:Ke,...l.billingAddressRequired&&{countrySpecificSchemas:H.getAddressSchemaForCountry(ye?.country),billingAddressRequiredFields:l.billingAddressRequiredFields}}),Ge=n((e=>{const r="webInternalElement"!==e.fieldType?e.fieldType:e.name;Re(r)}),[]),Je=x(Oe,qe,Me),Qe=k(K,O,$e()),Xe=t((()=>f(l,{sfp:O},{dualBrandSelectElements:le,setDualBrandSelectElements:de,setSelectedBrandValue:ce,issuingCountryCode:ae,setIssuingCountryCode:ie},T)),[le,ae]);L.current.showValidation=()=>{q.current=!0,er?.(),O.current.showValidation(),we(["holderName","socialSecurityNumber","taxNumber"]),D?.current&&D.current.showValidation()},L.current.processBinLookupResponse=(e,r)=>{Xe.processBinLookup(e,r)},L.current.setStatus=z,a((()=>(L.current.setFocusOn=O.current.setFocusOn,L.current.updateStyles=O.current.updateStyles,L.current.handleUnsupportedCard=O.current.handleUnsupportedCard,()=>{O.current.destroy()})),[]),a((()=>{const e=[...l.hasHolderName?["holderName"]:[],...Ke?["socialSecurityNumber"]:[],...Te?["taxNumber"]:[],...me?["billingAddress"]:[]];Ee(e)}),[l.hasHolderName,Ke,Te]),a((()=>{X({...Q,holderName:Ie.holderName??"",taxNumber:Ie.taxNumber}),Fe(Ie.socialSecurityNumber),me&&Ne({...Ie.billingAddress}),J({...G,holderName:!l.holderNameRequired||Be.holderName,socialSecurityNumber:!!Be.socialSecurityNumber&&Be.socialSecurityNumber,taxNumber:!!Be.taxNumber&&Be.taxNumber,billingAddress:!!Be.billingAddress&&Be.billingAddress});const e=!!Ve.billingAddress&&Object.entries(Ve.billingAddress).reduce(((e,[,r])=>e||null!=r),!1);$({...W,holderName:l.holderNameRequired&&Ve.holderName?Ve.holderName:null,socialSecurityNumber:Ke&&Ve.socialSecurityNumber?Ve.socialSecurityNumber:null,taxNumber:Te&&Ve.taxNumber?Ve.taxNumber:null,billingAddress:me&&e?Ve.billingAddress:null})}),[Ie,Be,Ve]);const{sortedErrorList:Ye,previousSortedErrors:Ze,clearSRPanel:er}=E({errors:W,props:l,isValidating:q,retrieveLayout:$e,specifications:H,billingAddress:ye,sfp:O});if(Ye){const e=I(Ye,Ze,"field");e?.forEach((e=>{const r={fieldType:e.field,errorCode:e.errorCode};l.onValidationErrorAnalytics(r)}))}a((()=>{const e=G.holderName,r=ee,s=!me||G.billingAddress,t=!Te||!!G.taxNumber&&!!G.encryptedPassword,o=!Ke||!!G.socialSecurityNumber,n=r&&e&&s&&t&&o,a=O.current.mapErrorsToValidationRuleResult(),i={...W,...a};l.onChange({data:Q,valid:G,errors:i,isValid:n,billingAddress:ye,selectedBrandValue:ue,storePaymentMethod:be,socialSecurityNumber:Ae,installments:Ce})}),[Q,G,W,ue,be,Ce]);const rr=l.storedPaymentMethodId?C:j;return e(r,null,e(i,{ref:O,...S(l),styles:{...l.styles},koreanAuthenticationRequired:l.configuration.koreanAuthenticationRequired,hasKoreanFields:!(!l.configuration.koreanAuthenticationRequired||"kr"!==l.countryCode),onChange:(e,r)=>{if(e.autoCompleteName){if(!l.hasHolderName)return;const r=h("holderName","blur")(e.autoCompleteName)?e.autoCompleteName:null;r&&(Oe("holderName",r),qe("holderName",!0),Me("holderName",null))}else l.autoFocus&&T.current>0&&"handleOnFieldValid"===r?.event&&r?.fieldType===u&&e.valid.encryptedCardNumber&&Qe(),X({...Q,...e.data}),$({...W,...e.errors}),J({...G,...e.valid}),re(e.isSfpValid),ne(e.cvcPolicy),ge(e.showSocialSecurityNumber),te(e.expiryDatePolicy)},onBrand:ze,onFocus:We,type:l.brand,disableIOSArrowKeys:l.disableIOSArrowKeys?Ge:null,render:({setRootNode:r,setFocusOn:s},t)=>e("div",{ref:r,className:v({"adyen-checkout__card-input":!0,"adyen-checkout-card-input__wrapper":!0,[`adyen-checkout__card-input--${l.fundingSource??"credit"}`]:!0,"adyen-checkout__card-input--loading":"loading"===U}),role:"form"},e(B,null),e(rr,{...g(l),data:Q,valid:G,errors:W,handleChangeFor:Pe,focusedElement:Y,setFocusOn:s,sfpState:t,cvcPolicy:oe,hasInstallments:De,showAmountsInInstallments:_e,handleInstallments:je,brandsIcons:l.brandsIcons,formData:Ie,formErrors:Ve,formValid:Be,expiryDatePolicy:se,dualBrandSelectElements:le,extensions:Xe,selectedBrandValue:ue,showKCP:Te,showBrazilianSSN:Ke,socialSecurityNumber:Ae,handleOnStoreDetails:fe,setAddressRef:_,billingAddress:ye,billingAddressValidationRules:pe&&P(he.current),partialAddressSchema:pe,handleAddress:Je,onAddressLookup:l.onAddressLookup,onAddressSelected:l.onAddressSelected,addressSearchDebounceMs:l.addressSearchDebounceMs,iOSFocusedField:ke,onFieldFocusAnalytics:He,onFieldBlurAnalytics:Ue}))}),l.showPayButton&&l.payButton({status:U,variant:l.isPayButtonPrimaryVariant?"primary":"secondary",icon:M({imageFolder:"components/"})(`${V}lock`)}))};O.defaultProps=l;export{O as default};
1
+ import{createElement as e,Fragment as r}from"../../../../external/preact/dist/preact.js";import{useRef as t,useMemo as s,useState as o,useCallback as n,useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import l from"./defaultProps.js";import{AddressModeOptions as d}from"./types.js";import{ENCRYPTED_CARD_NUMBER as u,DATE_POLICY_REQUIRED as c,CVC_POLICY_REQUIRED as m}from"../../../internal/SecuredFields/lib/constants.js";import{cardInputValidationRules as p,getRuleByNameAndMode as h,cardInputFormatters as f}from"./validate.js";import b from"../../../internal/SecuredFields/binLookup/extensions.js";import y from"../../../../utils/useForm/useForm.js";import{handlePartialAddressMode as N,extractPropsForSFP as S,extractPropsForCardFields as g,getLayout as A}from"./utils.js";import F from"../../../internal/Address/Specifications.js";import{StoredCardFieldsWrapper as C}from"./components/StoredCardFieldsWrapper.js";import{CardFieldsWrapper as j}from"./components/CardFieldsWrapper.js";import{getAutoJumpHandler as k,getFocusHandler as R,getAddressHandler as x}from"./handlers.js";import v from"../../../../_virtual/index.js";import{getPartialAddressValidationRules as P}from"../../../internal/Address/validate.js";import w from"../../../../core/Context/useImage.js";import{getArrayDifferences as B}from"../../../../utils/arrayUtils.js";import I from"../../../internal/FormInstruction/FormInstruction.js";import{PREFIX as V}from"../../../internal/Icon/constants.js";import E from"./useSRPanelForCardInputErrors.js";import O from"../Fastlane/FastlaneSignup.js";const q=l=>{const q=t(null),D=t(!1),M=w(),_=t(null),L=e=>{_.current=e},T=t({});Object.keys(T.current).length||l.setComponentRef(T.current);const K=t(0),H=t(!1),U=s((()=>new F(l.specifications)),[l.specifications]);T.current.sfp=q;const[z,W]=o("ready"),[$,G]=o({}),[J,Q]=o({...l.holderNameRequired&&{holderName:!1}}),[X,Y]=o({...l.hasHolderName&&{holderName:l.data.holderName??""}}),[Z,ee]=o(""),[re,te]=o(!1),[se,oe]=o(c),[ne,ae]=o(m),[ie,le]=o(null),[de,ue]=o([]),[ce,me]=o(l.storedPaymentMethodId?l.brand:""),pe=l.billingAddressMode!==d.none&&l.billingAddressRequired,he=N(l.billingAddressMode),fe=t(he&&l.data?.billingAddress?.country),[be,ye]=o(!1),[Ne,Se]=o(pe?l.data.billingAddress:null),[ge,Ae]=o(!1),[Fe,Ce]=o(""),[je,ke]=o({value:null}),[Re,xe]=o(null),[ve,Pe]=o("card"),{handleChangeFor:we,triggerValidation:Be,data:Ie,valid:Ve,errors:Ee,setSchema:Oe,setData:qe,setValid:De,setErrors:Me}=y({schema:[],defaultData:l.data,formatters:f,rules:p}),_e=!!Object.keys(l.installmentOptions).length&&"debit"!==l.fundingSource,Le=l.showInstallmentAmounts??!0,Te="kr"===(ie??l.countryCode),Ke=l.configuration.koreanAuthenticationRequired&&Te,He=ge&&"auto"===l.configuration.socialSecurityNumberMode||"show"===l.configuration.socialSecurityNumberMode,Ue=(e,r)=>{l.onFocus({fieldType:e,event:r})},ze=(e,r)=>{l.onBlur({fieldType:e,event:r})},We=n((e=>{Pe(e.brand),l.onBrand(e)}),[]),$e=R(ee,Ue,ze),Ge=()=>A({props:l,showKCP:Ke,showBrazilianSSN:He,...l.billingAddressRequired&&{countrySpecificSchemas:U.getAddressSchemaForCountry(Ne?.country),billingAddressRequiredFields:l.billingAddressRequiredFields}}),Je=n((e=>{const r="webInternalElement"!==e.fieldType?e.fieldType:e.name;xe(r)}),[]),Qe=x(qe,De,Me),Xe=k(H,q,Ge()),Ye=s((()=>b(l,{sfp:q},{dualBrandSelectElements:de,setDualBrandSelectElements:ue,setSelectedBrandValue:me,issuingCountryCode:ie,setIssuingCountryCode:le},K)),[de,ie]);T.current.showValidation=()=>{D.current=!0,rr?.(),q.current.showValidation(),Be(["holderName","socialSecurityNumber","taxNumber"]),_?.current&&_.current.showValidation()},T.current.processBinLookupResponse=(e,r)=>{Ye.processBinLookup(e,r)},T.current.setStatus=W,a((()=>(T.current.setFocusOn=q.current.setFocusOn,T.current.updateStyles=q.current.updateStyles,T.current.handleUnsupportedCard=q.current.handleUnsupportedCard,()=>{q.current.destroy()})),[]),a((()=>{const e=[...l.hasHolderName?["holderName"]:[],...He?["socialSecurityNumber"]:[],...Ke?["taxNumber"]:[],...pe?["billingAddress"]:[]];Oe(e)}),[l.hasHolderName,He,Ke]),a((()=>{Y({...X,holderName:Ie.holderName??"",taxNumber:Ie.taxNumber}),Ce(Ie.socialSecurityNumber),pe&&Se({...Ie.billingAddress}),Q({...J,holderName:!l.holderNameRequired||Ve.holderName,socialSecurityNumber:!!Ve.socialSecurityNumber&&Ve.socialSecurityNumber,taxNumber:!!Ve.taxNumber&&Ve.taxNumber,billingAddress:!!Ve.billingAddress&&Ve.billingAddress});const e=!!Ee.billingAddress&&Object.entries(Ee.billingAddress).reduce(((e,[,r])=>e||null!=r),!1);G({...$,holderName:l.holderNameRequired&&Ee.holderName?Ee.holderName:null,socialSecurityNumber:He&&Ee.socialSecurityNumber?Ee.socialSecurityNumber:null,taxNumber:Ke&&Ee.taxNumber?Ee.taxNumber:null,billingAddress:pe&&e?Ee.billingAddress:null})}),[Ie,Ve,Ee]);const{sortedErrorList:Ze,previousSortedErrors:er,clearSRPanel:rr}=E({errors:$,props:l,isValidating:D,retrieveLayout:Ge,specifications:U,billingAddress:Ne,sfp:q});if(Ze){const e=B(Ze,er,"field");e?.forEach((e=>{const r={fieldType:e.field,errorCode:e.errorCode};l.onValidationErrorAnalytics(r)}))}a((()=>{const e=J.holderName,r=re,t=!pe||J.billingAddress,s=!Ke||!!J.taxNumber&&!!J.encryptedPassword,o=!He||!!J.socialSecurityNumber,n=r&&e&&t&&s&&o,a=q.current.mapErrorsToValidationRuleResult(),i={...$,...a};l.onChange({data:X,valid:J,errors:i,isValid:n,billingAddress:Ne,selectedBrandValue:ce,storePaymentMethod:be,socialSecurityNumber:Fe,installments:je})}),[X,J,$,ce,be,je]);const tr=l.storedPaymentMethodId?C:j;return e(r,null,e(i,{ref:q,...S(l),styles:{...l.styles},koreanAuthenticationRequired:l.configuration.koreanAuthenticationRequired,hasKoreanFields:!(!l.configuration.koreanAuthenticationRequired||"kr"!==l.countryCode),onChange:(e,r)=>{if(e.autoCompleteName){if(!l.hasHolderName)return;const r=h("holderName","blur")(e.autoCompleteName)?e.autoCompleteName:null;r&&(qe("holderName",r),De("holderName",!0),Me("holderName",null))}else l.autoFocus&&K.current>0&&"handleOnFieldValid"===r?.event&&r?.fieldType===u&&e.valid.encryptedCardNumber&&Xe(),Y({...X,...e.data}),G({...$,...e.errors}),Q({...J,...e.valid}),te(e.isSfpValid),ae(e.cvcPolicy),Ae(e.showSocialSecurityNumber),oe(e.expiryDatePolicy)},onBrand:We,onFocus:$e,type:l.brand,disableIOSArrowKeys:l.disableIOSArrowKeys?Je:null,render:({setRootNode:r,setFocusOn:t},s)=>e("div",{ref:r,className:v({"adyen-checkout__card-input":!0,"adyen-checkout-card-input__wrapper":!0,[`adyen-checkout__card-input--${l.fundingSource??"credit"}`]:!0,"adyen-checkout__card-input--loading":"loading"===z}),role:"form"},e(I,null),e(tr,{...g(l),data:X,valid:J,errors:$,handleChangeFor:we,focusedElement:Z,setFocusOn:t,sfpState:s,cvcPolicy:ne,hasInstallments:_e,showAmountsInInstallments:Le,handleInstallments:ke,brandsIcons:l.brandsIcons,formData:Ie,formErrors:Ee,formValid:Ve,expiryDatePolicy:se,dualBrandSelectElements:de,extensions:Ye,selectedBrandValue:ce,showKCP:Ke,showBrazilianSSN:He,socialSecurityNumber:Fe,handleOnStoreDetails:ye,setAddressRef:L,billingAddress:Ne,billingAddressValidationRules:he&&P(fe.current),partialAddressSchema:he,handleAddress:Qe,onAddressLookup:l.onAddressLookup,onAddressSelected:l.onAddressSelected,addressSearchDebounceMs:l.addressSearchDebounceMs,iOSFocusedField:Re,onFieldFocusAnalytics:Ue,onFieldBlurAnalytics:ze}))}),l.fastlaneConfiguration&&e(O,{...l.fastlaneConfiguration,currentDetectedBrand:ve,onChange:l.onChange,onSubmitAnalytics:l.onSubmitAnalytics}),l.showPayButton&&l.payButton({status:z,variant:l.isPayButtonPrimaryVariant?"primary":"secondary",icon:M({imageFolder:"components/"})(`${V}lock`)}))};q.defaultProps=l;export{q as default};
2
2
  //# sourceMappingURL=CardInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CardInput.js","sources":["../../../../../../src/components/Card/components/CardInput/CardInput.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useMemo, useCallback } from 'preact/hooks';\nimport SecuredFieldsProvider from '../../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { OnChangeEventDetails, SFPState } from '../../../internal/SecuredFields/SFP/types';\nimport defaultProps from './defaultProps';\nimport './CardInput.scss';\nimport { AddressModeOptions, CardInputDataState, CardInputErrorState, CardInputProps, CardInputRef, CardInputValidState } from './types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, ENCRYPTED_CARD_NUMBER } from '../../../internal/SecuredFields/lib/constants';\nimport { BinLookupResponse } from '../../types';\nimport { cardInputFormatters, cardInputValidationRules, getRuleByNameAndMode } from './validate';\nimport CIExtensions from '../../../internal/SecuredFields/binLookup/extensions';\nimport useForm from '../../../../utils/useForm';\nimport { SortedErrorObject } from '../../../../core/Errors/types';\nimport { handlePartialAddressMode, extractPropsForCardFields, extractPropsForSFP, getLayout } from './utils';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { StoredCardFieldsWrapper } from './components/StoredCardFieldsWrapper';\nimport { CardFieldsWrapper } from './components/CardFieldsWrapper';\nimport { getAddressHandler, getAutoJumpHandler, getFocusHandler } from './handlers';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { TouchStartEventObj } from './components/types';\nimport classNames from 'classnames';\nimport { getPartialAddressValidationRules } from '../../../internal/Address/validate';\nimport useImage from '../../../../core/Context/useImage';\nimport { getArrayDifferences } from '../../../../utils/arrayUtils';\nimport FormInstruction from '../../../internal/FormInstruction';\nimport { AddressData } from '../../../../types/global-types';\nimport { CardBrandData, CardFocusData } from '../../../internal/SecuredFields/lib/types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/types';\nimport { PREFIX } from '../../../internal/Icon/constants';\nimport useSRPanelForCardInputErrors from './useSRPanelForCardInputErrors';\n\nconst CardInput = (props: CardInputProps) => {\n const sfp = useRef(null);\n const isValidating = useRef(false);\n const getImage = useImage();\n\n const billingAddressRef = useRef(null);\n const setAddressRef = ref => {\n billingAddressRef.current = ref;\n };\n\n const cardInputRef = useRef<CardInputRef>({});\n // Just call once to create the object by which we expose the members expected by the parent Card comp\n if (!Object.keys(cardInputRef.current).length) {\n props.setComponentRef(cardInputRef.current);\n }\n\n const hasPanLengthRef = useRef(0);\n const isAutoJumping = useRef(false);\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n // Store ref to sfp (useful for 'deep' debugging)\n cardInputRef.current.sfp = sfp;\n\n /**\n * STATE HOOKS\n */\n const [status, setStatus] = useState('ready');\n\n const [errors, setErrors] = useState<CardInputErrorState>({});\n const [valid, setValid] = useState<CardInputValidState>({\n ...(props.holderNameRequired && { holderName: false })\n });\n const [data, setData] = useState<CardInputDataState>({\n ...(props.hasHolderName && { holderName: props.data.holderName ?? '' })\n });\n\n const [focusedElement, setFocusedElement] = useState('');\n const [isSfpValid, setIsSfpValid] = useState(false);\n const [expiryDatePolicy, setExpiryDatePolicy] = useState(DATE_POLICY_REQUIRED);\n const [cvcPolicy, setCvcPolicy] = useState(CVC_POLICY_REQUIRED);\n const [issuingCountryCode, setIssuingCountryCode] = useState<string>(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState(props.storedPaymentMethodId ? props.brand : ''); // If this is a storedCard comp initialise state with the storedCard's brand\n\n const showBillingAddress = props.billingAddressMode !== AddressModeOptions.none && props.billingAddressRequired;\n\n const partialAddressSchema = handlePartialAddressMode(props.billingAddressMode);\n // Keeps the value of the country set initially by the merchant, before the Address Component mutates it\n const partialAddressCountry = useRef<string>(partialAddressSchema && props.data?.billingAddress?.country);\n\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n const [billingAddress, setBillingAddress] = useState<AddressData>(showBillingAddress ? props.data.billingAddress : null);\n const [showSocialSecurityNumber, setShowSocialSecurityNumber] = useState(false);\n const [socialSecurityNumber, setSocialSecurityNumber] = useState('');\n const [installments, setInstallments] = useState<InstallmentsObj>({ value: null });\n\n // re. Disable arrows for iOS: The name of the element calling for other elements to be disabled\n // - either a securedField type (like 'encryptedCardNumber') when call is coming from SF\n // or else the name of an internal, Adyen-web, element (like 'holderName')\n const [iOSFocusedField, setIOSFocusedField] = useState(null);\n\n /**\n * This stores the brand as detected by the internal regEx.\n * It eventually gets overwritten by the brand as detected by the /binLookup, but will revert back to the regEx detection\n * if the PAN length drops below the /binLookup digit threshold.\n * Default value, 'card', indicates no brand detected\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [internallyDetectedBrand, setInternallyDetectedBrand] = useState('card');\n\n /**\n * LOCAL VARS\n */\n const {\n handleChangeFor,\n triggerValidation,\n data: formData,\n valid: formValid,\n errors: formErrors,\n setSchema,\n setData: setFormData,\n setValid: setFormValid,\n setErrors: setFormErrors\n } = useForm<CardInputDataState>({\n schema: [],\n defaultData: props.data,\n formatters: cardInputFormatters,\n rules: cardInputValidationRules\n });\n\n const hasInstallments = !!Object.keys(props.installmentOptions).length && props.fundingSource !== 'debit';\n const showAmountsInInstallments = props.showInstallmentAmounts ?? true;\n\n const cardCountryCode: string = issuingCountryCode ?? props.countryCode;\n const isKorea = cardCountryCode === 'kr'; // If issuingCountryCode or the merchant defined countryCode is set to 'kr'\n const showKCP = props.configuration.koreanAuthenticationRequired && isKorea;\n\n const showBrazilianSSN: boolean =\n (showSocialSecurityNumber && props.configuration.socialSecurityNumberMode === 'auto') ||\n props.configuration.socialSecurityNumberMode === 'show';\n\n /**\n * HANDLERS\n */\n // Handlers for focus & blur on all fields. Can be renamed to onFieldFocus once the onFocusField is renamed in Field.tsx\n const onFieldFocusAnalytics = (who: string, e: Event | CardFocusData) => {\n props.onFocus({ fieldType: who, event: e });\n };\n const onFieldBlurAnalytics = (who: string, e: Event | CardFocusData) => {\n props.onBlur({ fieldType: who, event: e });\n };\n\n const onBrand = useCallback((obj: CardBrandData) => {\n setInternallyDetectedBrand(obj.brand);\n props.onBrand(obj);\n }, []);\n\n // Make SecuredFields aware of the focus & blur handlers\n const handleFocus = getFocusHandler(setFocusedElement, onFieldFocusAnalytics, onFieldBlurAnalytics);\n\n const retrieveLayout = (): string[] => {\n return getLayout({\n props,\n showKCP,\n showBrazilianSSN,\n ...(props.billingAddressRequired && {\n countrySpecificSchemas: specifications.getAddressSchemaForCountry(billingAddress?.country),\n billingAddressRequiredFields: props.billingAddressRequiredFields\n })\n });\n };\n\n /**\n * re. Disabling arrow keys in iOS:\n * Only by disabling all fields in the Card PM except for the active securedField input can we force the iOS soft keyboard arrow keys to disable\n *\n * NOTE: only called if ua.__IS_IOS = true && this.config.disableIOSArrowKeys = true (as referenced in CSF)\n *\n * @param obj - has fieldType prop saying whether this function is being called in response to an securedFields click ('encryptedCardNumber' etc)\n * - in which case we should disable all non-SF fields\n * or,\n * due to an internal action ('webInternalElement') - in which case we can enable all non-SF fields\n */\n const handleTouchstartIOS = useCallback((obj: TouchStartEventObj) => {\n const elementType = obj.fieldType !== 'webInternalElement' ? obj.fieldType : obj.name;\n setIOSFocusedField(elementType);\n }, []);\n\n const handleAddress = getAddressHandler(setFormData, setFormValid, setFormErrors);\n\n const doPanAutoJump = getAutoJumpHandler(isAutoJumping, sfp, retrieveLayout());\n\n const handleSecuredFieldsChange = (sfState: SFPState, eventDetails?: OnChangeEventDetails): void => {\n /**\n * Handling auto complete value for holderName (but only if the component is using a holderName field)\n */\n if (sfState.autoCompleteName) {\n if (!props.hasHolderName) return;\n const holderNameValidationFn = getRuleByNameAndMode('holderName', 'blur');\n const acHolderName = holderNameValidationFn(sfState.autoCompleteName) ? sfState.autoCompleteName : null;\n if (acHolderName) {\n setFormData('holderName', acHolderName);\n setFormValid('holderName', true); // only if holderName is valid does this fny get called - so we know it's valid and w/o error\n setFormErrors('holderName', null);\n }\n return;\n }\n\n /**\n * Decide if we can shift focus to the expiryDate field.\n *\n * We can if... the config prop, autoFocus, is true AND we have a panLength value from binLookup\n * AND we are responding to a handleOnFieldValid message about the PAN that says it is valid\n */\n if (\n props.autoFocus &&\n hasPanLengthRef.current > 0 &&\n eventDetails?.event === 'handleOnFieldValid' &&\n eventDetails?.fieldType === ENCRYPTED_CARD_NUMBER &&\n sfState.valid.encryptedCardNumber\n ) {\n doPanAutoJump();\n }\n\n /**\n * Process SFP state\n */\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n\n // Values relating to /binLookup response\n setCvcPolicy(sfState.cvcPolicy);\n setShowSocialSecurityNumber(sfState.showSocialSecurityNumber);\n setExpiryDatePolicy(sfState.expiryDatePolicy);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n CIExtensions(\n props,\n { sfp },\n {\n dualBrandSelectElements,\n setDualBrandSelectElements,\n setSelectedBrandValue,\n issuingCountryCode,\n setIssuingCountryCode\n },\n hasPanLengthRef\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPOSE METHODS expected by Card.tsx\n */\n cardInputRef.current.showValidation = () => {\n // set flag\n isValidating.current = true;\n\n /**\n * Clear errors prior to validating so that the screenreader will read them *all* again, and in the right order\n * - only using aria-atomic on the error panel will read them in the wrong order\n */\n clearSRPanel?.(); // TODO - recheck if this is still true\n\n // Validate SecuredFields\n sfp.current.showValidation();\n\n // Validate holderName & SSN & KCP (taxNumber) but *not* billingAddress\n triggerValidation(['holderName', 'socialSecurityNumber', 'taxNumber']);\n\n // Validate Address\n if (billingAddressRef?.current) billingAddressRef.current.showValidation();\n };\n\n cardInputRef.current.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n cardInputRef.current.setStatus = setStatus;\n\n /**\n * EFFECT HOOKS\n */\n useEffect(() => {\n // componentDidMount - expose more methods expected by Card.tsx\n cardInputRef.current.setFocusOn = sfp.current.setFocusOn;\n cardInputRef.current.updateStyles = sfp.current.updateStyles;\n cardInputRef.current.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n // componentWillUnmount\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n /**\n * Handle form schema updates\n */\n useEffect(() => {\n const newSchema = [\n ...(props.hasHolderName ? ['holderName'] : []),\n ...(showBrazilianSSN ? ['socialSecurityNumber'] : []),\n ...(showKCP ? ['taxNumber'] : []),\n ...(showBillingAddress ? ['billingAddress'] : [])\n ];\n setSchema(newSchema);\n }, [props.hasHolderName, showBrazilianSSN, showKCP]);\n\n /**\n * Handle updates from useForm\n */\n useEffect(() => {\n setData({ ...data, holderName: formData.holderName ?? '', taxNumber: formData.taxNumber });\n\n setSocialSecurityNumber(formData.socialSecurityNumber);\n\n if (showBillingAddress) setBillingAddress({ ...formData.billingAddress });\n\n setValid({\n ...valid,\n holderName: props.holderNameRequired ? formValid.holderName : true,\n // Setting value to false if it's falsy keeps in line with existing, expected behaviour\n // - but there is an argument to allow 'undefined' as a value to indicate the non-presence of the field\n socialSecurityNumber: formValid.socialSecurityNumber ? formValid.socialSecurityNumber : false,\n taxNumber: formValid.taxNumber ? formValid.taxNumber : false,\n billingAddress: formValid.billingAddress ? formValid.billingAddress : false\n });\n\n // Check if billingAddress errors object has any properties that aren't null or undefined\n const addressHasErrors = formErrors.billingAddress\n ? Object.entries(formErrors.billingAddress).reduce((acc, [, error]) => acc || error != null, false)\n : false;\n\n // Errors\n setErrors({\n ...errors,\n holderName: props.holderNameRequired && !!formErrors.holderName ? formErrors.holderName : null,\n socialSecurityNumber: showBrazilianSSN && !!formErrors.socialSecurityNumber ? formErrors.socialSecurityNumber : null,\n taxNumber: showKCP && !!formErrors.taxNumber ? formErrors.taxNumber : null,\n billingAddress: showBillingAddress && addressHasErrors ? formErrors.billingAddress : null\n });\n }, [formData, formValid, formErrors]);\n\n // Use the custom hook to set (or clear) errors in the SRPanel\n const {\n sortedErrorList: currentErrorsSortedByLayout,\n previousSortedErrors,\n clearSRPanel\n } = useSRPanelForCardInputErrors({\n errors,\n props,\n isValidating,\n retrieveLayout,\n specifications,\n billingAddress,\n sfp\n });\n\n // Analytics: ValidationErrors\n if (currentErrorsSortedByLayout) {\n const newErrors = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n newErrors?.forEach(errorItem => {\n const aObj: FieldErrorAnalyticsObject = {\n fieldType: errorItem.field,\n errorCode: errorItem.errorCode\n };\n\n props.onValidationErrorAnalytics(aObj);\n });\n }\n\n /**\n * Main 'componentDidUpdate' handler\n */\n useEffect(() => {\n const holderNameValid: boolean = valid.holderName;\n\n const sfpValid: boolean = isSfpValid;\n const addressValid: boolean = showBillingAddress ? valid.billingAddress : true;\n\n const koreanAuthentication: boolean = showKCP ? !!valid.taxNumber && !!valid.encryptedPassword : true;\n\n const socialSecurityNumberValid: boolean = showBrazilianSSN ? !!valid.socialSecurityNumber : true;\n\n const isValid: boolean = sfpValid && holderNameValid && addressValid && koreanAuthentication && socialSecurityNumberValid;\n\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n const mergedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors AND solves race condition problems for sfp from showValidation\n\n props.onChange({\n data,\n valid,\n errors: mergedErrors,\n isValid,\n billingAddress,\n selectedBrandValue,\n storePaymentMethod,\n socialSecurityNumber,\n installments\n });\n }, [data, valid, errors, selectedBrandValue, storePaymentMethod, installments]);\n\n /**\n * RENDER\n */\n const FieldToRender = props.storedPaymentMethodId ? StoredCardFieldsWrapper : CardFieldsWrapper;\n\n return (\n <Fragment>\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n styles={{ ...props.styles }}\n koreanAuthenticationRequired={props.configuration.koreanAuthenticationRequired}\n hasKoreanFields={!!(props.configuration.koreanAuthenticationRequired && props.countryCode === 'kr')}\n onChange={handleSecuredFieldsChange}\n onBrand={onBrand}\n onFocus={handleFocus}\n type={props.brand}\n disableIOSArrowKeys={props.disableIOSArrowKeys ? handleTouchstartIOS : null}\n render={({ setRootNode, setFocusOn }, sfpState) => (\n <div\n ref={setRootNode}\n className={classNames({\n 'adyen-checkout__card-input': true,\n 'adyen-checkout-card-input__wrapper': true,\n [`adyen-checkout__card-input--${props.fundingSource ?? 'credit'}`]: true,\n 'adyen-checkout__card-input--loading': status === 'loading'\n })}\n role={'form'}\n >\n <FormInstruction />\n\n <FieldToRender\n // Extract exact props that we need to pass down\n {...extractPropsForCardFields(props)}\n // Pass on vars created in CardInput:\n // Base (shared w. StoredCard)\n data={data}\n valid={valid}\n errors={errors}\n handleChangeFor={handleChangeFor}\n focusedElement={focusedElement}\n setFocusOn={setFocusOn}\n sfpState={sfpState}\n cvcPolicy={cvcPolicy}\n hasInstallments={hasInstallments}\n showAmountsInInstallments={showAmountsInInstallments}\n handleInstallments={setInstallments}\n // For Card\n brandsIcons={props.brandsIcons}\n formData={formData}\n formErrors={formErrors}\n formValid={formValid}\n expiryDatePolicy={expiryDatePolicy}\n dualBrandSelectElements={dualBrandSelectElements}\n extensions={extensions}\n selectedBrandValue={selectedBrandValue}\n // For KCP\n showKCP={showKCP}\n // For SSN\n showBrazilianSSN={showBrazilianSSN}\n socialSecurityNumber={socialSecurityNumber}\n // For Store details\n handleOnStoreDetails={setStorePaymentMethod}\n // For Address\n setAddressRef={setAddressRef}\n billingAddress={billingAddress}\n billingAddressValidationRules={partialAddressSchema && getPartialAddressValidationRules(partialAddressCountry.current)}\n partialAddressSchema={partialAddressSchema}\n handleAddress={handleAddress}\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n //\n iOSFocusedField={iOSFocusedField}\n //\n onFieldFocusAnalytics={onFieldFocusAnalytics}\n onFieldBlurAnalytics={onFieldBlurAnalytics}\n />\n </div>\n )}\n />\n {props.showPayButton &&\n props.payButton({\n status,\n variant: props.isPayButtonPrimaryVariant ? 'primary' : 'secondary',\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </Fragment>\n );\n};\n\nCardInput.defaultProps = defaultProps;\n\nexport default CardInput;\n"],"names":["CardInput","props","sfp","useRef","isValidating","getImage","useImage","billingAddressRef","setAddressRef","ref","current","cardInputRef","Object","keys","length","setComponentRef","hasPanLengthRef","isAutoJumping","specifications","useMemo","Specifications","status","setStatus","useState","errors","setErrors","valid","setValid","holderNameRequired","holderName","data","setData","hasHolderName","focusedElement","setFocusedElement","isSfpValid","setIsSfpValid","expiryDatePolicy","setExpiryDatePolicy","DATE_POLICY_REQUIRED","cvcPolicy","setCvcPolicy","CVC_POLICY_REQUIRED","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","storedPaymentMethodId","brand","showBillingAddress","billingAddressMode","AddressModeOptions","none","billingAddressRequired","partialAddressSchema","handlePartialAddressMode","partialAddressCountry","billingAddress","country","storePaymentMethod","setStorePaymentMethod","setBillingAddress","showSocialSecurityNumber","setShowSocialSecurityNumber","socialSecurityNumber","setSocialSecurityNumber","installments","setInstallments","value","iOSFocusedField","setIOSFocusedField","internallyDetectedBrand","setInternallyDetectedBrand","handleChangeFor","triggerValidation","formData","formValid","formErrors","setSchema","setFormData","setFormValid","setFormErrors","useForm","schema","defaultData","formatters","cardInputFormatters","rules","cardInputValidationRules","hasInstallments","installmentOptions","fundingSource","showAmountsInInstallments","showInstallmentAmounts","isKorea","countryCode","showKCP","configuration","koreanAuthenticationRequired","showBrazilianSSN","socialSecurityNumberMode","onFieldFocusAnalytics","who","e","onFocus","fieldType","event","onFieldBlurAnalytics","onBlur","onBrand","useCallback","obj","handleFocus","getFocusHandler","retrieveLayout","getLayout","countrySpecificSchemas","getAddressSchemaForCountry","billingAddressRequiredFields","handleTouchstartIOS","elementType","name","handleAddress","getAddressHandler","doPanAutoJump","getAutoJumpHandler","extensions","CIExtensions","showValidation","clearSRPanel","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","useEffect","setFocusOn","updateStyles","handleUnsupportedCard","destroy","newSchema","taxNumber","addressHasErrors","entries","reduce","acc","error","sortedErrorList","currentErrorsSortedByLayout","previousSortedErrors","useSRPanelForCardInputErrors","newErrors","getArrayDifferences","forEach","errorItem","aObj","field","errorCode","onValidationErrorAnalytics","holderNameValid","sfpValid","addressValid","koreanAuthentication","encryptedPassword","socialSecurityNumberValid","isValid","sfStateErrorsObj","mapErrorsToValidationRuleResult","mergedErrors","onChange","FieldToRender","StoredCardFieldsWrapper","CardFieldsWrapper","h","Fragment","SecuredFieldsProvider","extractPropsForSFP","styles","hasKoreanFields","sfState","eventDetails","autoCompleteName","acHolderName","getRuleByNameAndMode","holderNameValidationFn","autoFocus","ENCRYPTED_CARD_NUMBER","encryptedCardNumber","type","disableIOSArrowKeys","render","setRootNode","sfpState","div","className","classNames","role","FormInstruction","extractPropsForCardFields","handleInstallments","brandsIcons","handleOnStoreDetails","billingAddressValidationRules","getPartialAddressValidationRules","onAddressLookup","onAddressSelected","addressSearchDebounceMs","showPayButton","payButton","variant","isPayButtonPrimaryVariant","icon","imageFolder","PREFIX","defaultProps"],"mappings":"6kDA+BA,MAAMA,EAAaC,IACf,MAAMC,EAAMC,EAAO,MACbC,EAAeD,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ACZwD,SAAUA,EACVzJ,UAAWA,GACXmD,gBAAiBA,GACjBG,0BAA2BA,GAC3B0G,mBAAoBnI,GAEpBoI,YAAaxM,EAAMwM,YACnB5H,SAAUA,GACVE,WAAYA,GACZD,UAAWA,GACXzC,iBAAkBA,GAClBQ,wBAAyBA,GACzBmF,WAAYA,GACZjF,mBAAoBA,GAEpBmD,QAASA,GAETG,iBAAkBA,GAClBnC,qBAAsBA,GAEtBwI,qBAAsB5I,GAEtBtD,cAAeA,EACfmD,eAAgBA,GAChBgJ,8BAA+BnJ,IAAwBoJ,EAAiClJ,GAAsBhD,SAC9G8C,qBAAsBA,GACtBoE,cAAeA,GACfiF,gBAAiB5M,EAAM4M,gBACvBC,kBAAmB7M,EAAM6M,kBACzBC,wBAAyB9M,EAAM8M,wBAE/BxI,gBAAiBA,GAEjBgC,sBAAuBA,GACvBM,qBAAsBA,QAKrC5G,EAAM+M,eACH/M,EAAMgN,UAAU,CACZ5L,SACA6L,QAASjN,EAAMkN,0BAA4B,UAAY,YACvDC,KAAM/M,EAAS,CAAEgN,YAAa,eAAxBhN,CAAyC,GAAGiN,WACtD,EAKhBtN,EAAUuN,aAAeA"}
1
+ {"version":3,"file":"CardInput.js","sources":["../../../../../../src/components/Card/components/CardInput/CardInput.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useState, useEffect, useRef, useMemo, useCallback } from 'preact/hooks';\nimport SecuredFieldsProvider from '../../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport { OnChangeEventDetails, SFPState } from '../../../internal/SecuredFields/SFP/types';\nimport defaultProps from './defaultProps';\nimport './CardInput.scss';\nimport { AddressModeOptions, CardInputDataState, CardInputErrorState, CardInputProps, CardInputRef, CardInputValidState } from './types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, ENCRYPTED_CARD_NUMBER } from '../../../internal/SecuredFields/lib/constants';\nimport { BinLookupResponse } from '../../types';\nimport { cardInputFormatters, cardInputValidationRules, getRuleByNameAndMode } from './validate';\nimport CIExtensions from '../../../internal/SecuredFields/binLookup/extensions';\nimport useForm from '../../../../utils/useForm';\nimport { SortedErrorObject } from '../../../../core/Errors/types';\nimport { handlePartialAddressMode, extractPropsForCardFields, extractPropsForSFP, getLayout } from './utils';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { StoredCardFieldsWrapper } from './components/StoredCardFieldsWrapper';\nimport { CardFieldsWrapper } from './components/CardFieldsWrapper';\nimport { getAddressHandler, getAutoJumpHandler, getFocusHandler } from './handlers';\nimport { InstallmentsObj } from './components/Installments/Installments';\nimport { TouchStartEventObj } from './components/types';\nimport classNames from 'classnames';\nimport { getPartialAddressValidationRules } from '../../../internal/Address/validate';\nimport useImage from '../../../../core/Context/useImage';\nimport { getArrayDifferences } from '../../../../utils/arrayUtils';\nimport FormInstruction from '../../../internal/FormInstruction';\nimport { AddressData } from '../../../../types/global-types';\nimport { CardBrandData, CardFocusData } from '../../../internal/SecuredFields/lib/types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/types';\nimport { PREFIX } from '../../../internal/Icon/constants';\nimport useSRPanelForCardInputErrors from './useSRPanelForCardInputErrors';\nimport FastlaneSignup from '../Fastlane/FastlaneSignup';\n\nconst CardInput = (props: CardInputProps) => {\n const sfp = useRef(null);\n const isValidating = useRef(false);\n const getImage = useImage();\n\n const billingAddressRef = useRef(null);\n const setAddressRef = ref => {\n billingAddressRef.current = ref;\n };\n\n const cardInputRef = useRef<CardInputRef>({});\n // Just call once to create the object by which we expose the members expected by the parent Card comp\n if (!Object.keys(cardInputRef.current).length) {\n props.setComponentRef(cardInputRef.current);\n }\n\n const hasPanLengthRef = useRef(0);\n const isAutoJumping = useRef(false);\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n // Store ref to sfp (useful for 'deep' debugging)\n cardInputRef.current.sfp = sfp;\n\n /**\n * STATE HOOKS\n */\n const [status, setStatus] = useState('ready');\n\n const [errors, setErrors] = useState<CardInputErrorState>({});\n const [valid, setValid] = useState<CardInputValidState>({\n ...(props.holderNameRequired && { holderName: false })\n });\n const [data, setData] = useState<CardInputDataState>({\n ...(props.hasHolderName && { holderName: props.data.holderName ?? '' })\n });\n\n const [focusedElement, setFocusedElement] = useState('');\n const [isSfpValid, setIsSfpValid] = useState(false);\n const [expiryDatePolicy, setExpiryDatePolicy] = useState(DATE_POLICY_REQUIRED);\n const [cvcPolicy, setCvcPolicy] = useState(CVC_POLICY_REQUIRED);\n const [issuingCountryCode, setIssuingCountryCode] = useState<string>(null);\n\n const [dualBrandSelectElements, setDualBrandSelectElements] = useState([]);\n const [selectedBrandValue, setSelectedBrandValue] = useState(props.storedPaymentMethodId ? props.brand : ''); // If this is a storedCard comp initialise state with the storedCard's brand\n\n const showBillingAddress = props.billingAddressMode !== AddressModeOptions.none && props.billingAddressRequired;\n\n const partialAddressSchema = handlePartialAddressMode(props.billingAddressMode);\n // Keeps the value of the country set initially by the merchant, before the Address Component mutates it\n const partialAddressCountry = useRef<string>(partialAddressSchema && props.data?.billingAddress?.country);\n\n const [storePaymentMethod, setStorePaymentMethod] = useState(false);\n const [billingAddress, setBillingAddress] = useState<AddressData>(showBillingAddress ? props.data.billingAddress : null);\n const [showSocialSecurityNumber, setShowSocialSecurityNumber] = useState(false);\n const [socialSecurityNumber, setSocialSecurityNumber] = useState('');\n const [installments, setInstallments] = useState<InstallmentsObj>({ value: null });\n\n // re. Disable arrows for iOS: The name of the element calling for other elements to be disabled\n // - either a securedField type (like 'encryptedCardNumber') when call is coming from SF\n // or else the name of an internal, Adyen-web, element (like 'holderName')\n const [iOSFocusedField, setIOSFocusedField] = useState(null);\n\n /**\n * This stores the brand as detected by the internal regEx.\n * It eventually gets overwritten by the brand as detected by the /binLookup, but will revert back to the regEx detection\n * if the PAN length drops below the /binLookup digit threshold.\n * Default value, 'card', indicates no brand detected\n */\n const [internallyDetectedBrand, setInternallyDetectedBrand] = useState('card');\n\n /**\n * LOCAL VARS\n */\n const {\n handleChangeFor,\n triggerValidation,\n data: formData,\n valid: formValid,\n errors: formErrors,\n setSchema,\n setData: setFormData,\n setValid: setFormValid,\n setErrors: setFormErrors\n } = useForm<CardInputDataState>({\n schema: [],\n defaultData: props.data,\n formatters: cardInputFormatters,\n rules: cardInputValidationRules\n });\n\n const hasInstallments = !!Object.keys(props.installmentOptions).length && props.fundingSource !== 'debit';\n const showAmountsInInstallments = props.showInstallmentAmounts ?? true;\n\n const cardCountryCode: string = issuingCountryCode ?? props.countryCode;\n const isKorea = cardCountryCode === 'kr'; // If issuingCountryCode or the merchant defined countryCode is set to 'kr'\n const showKCP = props.configuration.koreanAuthenticationRequired && isKorea;\n\n const showBrazilianSSN: boolean =\n (showSocialSecurityNumber && props.configuration.socialSecurityNumberMode === 'auto') ||\n props.configuration.socialSecurityNumberMode === 'show';\n\n /**\n * HANDLERS\n */\n // Handlers for focus & blur on all fields. Can be renamed to onFieldFocus once the onFocusField is renamed in Field.tsx\n const onFieldFocusAnalytics = (who: string, e: Event | CardFocusData) => {\n props.onFocus({ fieldType: who, event: e });\n };\n const onFieldBlurAnalytics = (who: string, e: Event | CardFocusData) => {\n props.onBlur({ fieldType: who, event: e });\n };\n\n const onBrand = useCallback((obj: CardBrandData) => {\n setInternallyDetectedBrand(obj.brand);\n props.onBrand(obj);\n }, []);\n\n // Make SecuredFields aware of the focus & blur handlers\n const handleFocus = getFocusHandler(setFocusedElement, onFieldFocusAnalytics, onFieldBlurAnalytics);\n\n const retrieveLayout = (): string[] => {\n return getLayout({\n props,\n showKCP,\n showBrazilianSSN,\n ...(props.billingAddressRequired && {\n countrySpecificSchemas: specifications.getAddressSchemaForCountry(billingAddress?.country),\n billingAddressRequiredFields: props.billingAddressRequiredFields\n })\n });\n };\n\n /**\n * re. Disabling arrow keys in iOS:\n * Only by disabling all fields in the Card PM except for the active securedField input can we force the iOS soft keyboard arrow keys to disable\n *\n * NOTE: only called if ua.__IS_IOS = true && this.config.disableIOSArrowKeys = true (as referenced in CSF)\n *\n * @param obj - has fieldType prop saying whether this function is being called in response to an securedFields click ('encryptedCardNumber' etc)\n * - in which case we should disable all non-SF fields\n * or,\n * due to an internal action ('webInternalElement') - in which case we can enable all non-SF fields\n */\n const handleTouchstartIOS = useCallback((obj: TouchStartEventObj) => {\n const elementType = obj.fieldType !== 'webInternalElement' ? obj.fieldType : obj.name;\n setIOSFocusedField(elementType);\n }, []);\n\n const handleAddress = getAddressHandler(setFormData, setFormValid, setFormErrors);\n\n const doPanAutoJump = getAutoJumpHandler(isAutoJumping, sfp, retrieveLayout());\n\n const handleSecuredFieldsChange = (sfState: SFPState, eventDetails?: OnChangeEventDetails): void => {\n /**\n * Handling auto complete value for holderName (but only if the component is using a holderName field)\n */\n if (sfState.autoCompleteName) {\n if (!props.hasHolderName) return;\n const holderNameValidationFn = getRuleByNameAndMode('holderName', 'blur');\n const acHolderName = holderNameValidationFn(sfState.autoCompleteName) ? sfState.autoCompleteName : null;\n if (acHolderName) {\n setFormData('holderName', acHolderName);\n setFormValid('holderName', true); // only if holderName is valid does this fny get called - so we know it's valid and w/o error\n setFormErrors('holderName', null);\n }\n return;\n }\n\n /**\n * Decide if we can shift focus to the expiryDate field.\n *\n * We can if... the config prop, autoFocus, is true AND we have a panLength value from binLookup\n * AND we are responding to a handleOnFieldValid message about the PAN that says it is valid\n */\n if (\n props.autoFocus &&\n hasPanLengthRef.current > 0 &&\n eventDetails?.event === 'handleOnFieldValid' &&\n eventDetails?.fieldType === ENCRYPTED_CARD_NUMBER &&\n sfState.valid.encryptedCardNumber\n ) {\n doPanAutoJump();\n }\n\n /**\n * Process SFP state\n */\n setData({ ...data, ...sfState.data });\n setErrors({ ...errors, ...sfState.errors });\n setValid({ ...valid, ...sfState.valid });\n\n setIsSfpValid(sfState.isSfpValid);\n\n // Values relating to /binLookup response\n setCvcPolicy(sfState.cvcPolicy);\n setShowSocialSecurityNumber(sfState.showSocialSecurityNumber);\n setExpiryDatePolicy(sfState.expiryDatePolicy);\n };\n\n // Farm the handlers for binLookup related functionality out to another 'extensions' file\n const extensions = useMemo(\n () =>\n CIExtensions(\n props,\n { sfp },\n {\n dualBrandSelectElements,\n setDualBrandSelectElements,\n setSelectedBrandValue,\n issuingCountryCode,\n setIssuingCountryCode\n },\n hasPanLengthRef\n ),\n [dualBrandSelectElements, issuingCountryCode]\n );\n\n /**\n * EXPOSE METHODS expected by Card.tsx\n */\n cardInputRef.current.showValidation = () => {\n // set flag\n isValidating.current = true;\n\n /**\n * Clear errors prior to validating so that the screenreader will read them *all* again, and in the right order\n * - only using aria-atomic on the error panel will read them in the wrong order\n */\n clearSRPanel?.(); // TODO - recheck if this is still true\n\n // Validate SecuredFields\n sfp.current.showValidation();\n\n // Validate holderName & SSN & KCP (taxNumber) but *not* billingAddress\n triggerValidation(['holderName', 'socialSecurityNumber', 'taxNumber']);\n\n // Validate Address\n if (billingAddressRef?.current) billingAddressRef.current.showValidation();\n };\n\n cardInputRef.current.processBinLookupResponse = (binLookupResponse: BinLookupResponse, isReset: boolean) => {\n extensions.processBinLookup(binLookupResponse, isReset);\n };\n\n cardInputRef.current.setStatus = setStatus;\n\n /**\n * EFFECT HOOKS\n */\n useEffect(() => {\n // componentDidMount - expose more methods expected by Card.tsx\n cardInputRef.current.setFocusOn = sfp.current.setFocusOn;\n cardInputRef.current.updateStyles = sfp.current.updateStyles;\n cardInputRef.current.handleUnsupportedCard = sfp.current.handleUnsupportedCard;\n\n // componentWillUnmount\n return () => {\n sfp.current.destroy();\n };\n }, []);\n\n /**\n * Handle form schema updates\n */\n useEffect(() => {\n const newSchema = [\n ...(props.hasHolderName ? ['holderName'] : []),\n ...(showBrazilianSSN ? ['socialSecurityNumber'] : []),\n ...(showKCP ? ['taxNumber'] : []),\n ...(showBillingAddress ? ['billingAddress'] : [])\n ];\n setSchema(newSchema);\n }, [props.hasHolderName, showBrazilianSSN, showKCP]);\n\n /**\n * Handle updates from useForm\n */\n useEffect(() => {\n setData({ ...data, holderName: formData.holderName ?? '', taxNumber: formData.taxNumber });\n\n setSocialSecurityNumber(formData.socialSecurityNumber);\n\n if (showBillingAddress) setBillingAddress({ ...formData.billingAddress });\n\n setValid({\n ...valid,\n holderName: props.holderNameRequired ? formValid.holderName : true,\n // Setting value to false if it's falsy keeps in line with existing, expected behaviour\n // - but there is an argument to allow 'undefined' as a value to indicate the non-presence of the field\n socialSecurityNumber: formValid.socialSecurityNumber ? formValid.socialSecurityNumber : false,\n taxNumber: formValid.taxNumber ? formValid.taxNumber : false,\n billingAddress: formValid.billingAddress ? formValid.billingAddress : false\n });\n\n // Check if billingAddress errors object has any properties that aren't null or undefined\n const addressHasErrors = formErrors.billingAddress\n ? Object.entries(formErrors.billingAddress).reduce((acc, [, error]) => acc || error != null, false)\n : false;\n\n // Errors\n setErrors({\n ...errors,\n holderName: props.holderNameRequired && !!formErrors.holderName ? formErrors.holderName : null,\n socialSecurityNumber: showBrazilianSSN && !!formErrors.socialSecurityNumber ? formErrors.socialSecurityNumber : null,\n taxNumber: showKCP && !!formErrors.taxNumber ? formErrors.taxNumber : null,\n billingAddress: showBillingAddress && addressHasErrors ? formErrors.billingAddress : null\n });\n }, [formData, formValid, formErrors]);\n\n // Use the custom hook to set (or clear) errors in the SRPanel\n const {\n sortedErrorList: currentErrorsSortedByLayout,\n previousSortedErrors,\n clearSRPanel\n } = useSRPanelForCardInputErrors({\n errors,\n props,\n isValidating,\n retrieveLayout,\n specifications,\n billingAddress,\n sfp\n });\n\n // Analytics: ValidationErrors\n if (currentErrorsSortedByLayout) {\n const newErrors = getArrayDifferences<SortedErrorObject, string>(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n newErrors?.forEach(errorItem => {\n const aObj: FieldErrorAnalyticsObject = {\n fieldType: errorItem.field,\n errorCode: errorItem.errorCode\n };\n\n props.onValidationErrorAnalytics(aObj);\n });\n }\n\n /**\n * Main 'componentDidUpdate' handler\n */\n useEffect(() => {\n const holderNameValid: boolean = valid.holderName;\n\n const sfpValid: boolean = isSfpValid;\n const addressValid: boolean = showBillingAddress ? valid.billingAddress : true;\n\n const koreanAuthentication: boolean = showKCP ? !!valid.taxNumber && !!valid.encryptedPassword : true;\n\n const socialSecurityNumberValid: boolean = showBrazilianSSN ? !!valid.socialSecurityNumber : true;\n\n const isValid: boolean = sfpValid && holderNameValid && addressValid && koreanAuthentication && socialSecurityNumberValid;\n\n const sfStateErrorsObj = sfp.current.mapErrorsToValidationRuleResult();\n const mergedErrors = { ...errors, ...sfStateErrorsObj }; // maps sfErrors AND solves race condition problems for sfp from showValidation\n\n props.onChange({\n data,\n valid,\n errors: mergedErrors,\n isValid,\n billingAddress,\n selectedBrandValue,\n storePaymentMethod,\n socialSecurityNumber,\n installments\n });\n }, [data, valid, errors, selectedBrandValue, storePaymentMethod, installments]);\n\n /**\n * RENDER\n */\n const FieldToRender = props.storedPaymentMethodId ? StoredCardFieldsWrapper : CardFieldsWrapper;\n\n return (\n <Fragment>\n <SecuredFieldsProvider\n ref={sfp}\n {...extractPropsForSFP(props)}\n styles={{ ...props.styles }}\n koreanAuthenticationRequired={props.configuration.koreanAuthenticationRequired}\n hasKoreanFields={!!(props.configuration.koreanAuthenticationRequired && props.countryCode === 'kr')}\n onChange={handleSecuredFieldsChange}\n onBrand={onBrand}\n onFocus={handleFocus}\n type={props.brand}\n disableIOSArrowKeys={props.disableIOSArrowKeys ? handleTouchstartIOS : null}\n render={({ setRootNode, setFocusOn }, sfpState) => (\n <div\n ref={setRootNode}\n className={classNames({\n 'adyen-checkout__card-input': true,\n 'adyen-checkout-card-input__wrapper': true,\n [`adyen-checkout__card-input--${props.fundingSource ?? 'credit'}`]: true,\n 'adyen-checkout__card-input--loading': status === 'loading'\n })}\n role={'form'}\n >\n <FormInstruction />\n\n <FieldToRender\n // Extract exact props that we need to pass down\n {...extractPropsForCardFields(props)}\n // Pass on vars created in CardInput:\n // Base (shared w. StoredCard)\n data={data}\n valid={valid}\n errors={errors}\n handleChangeFor={handleChangeFor}\n focusedElement={focusedElement}\n setFocusOn={setFocusOn}\n sfpState={sfpState}\n cvcPolicy={cvcPolicy}\n hasInstallments={hasInstallments}\n showAmountsInInstallments={showAmountsInInstallments}\n handleInstallments={setInstallments}\n // For Card\n brandsIcons={props.brandsIcons}\n formData={formData}\n formErrors={formErrors}\n formValid={formValid}\n expiryDatePolicy={expiryDatePolicy}\n dualBrandSelectElements={dualBrandSelectElements}\n extensions={extensions}\n selectedBrandValue={selectedBrandValue}\n // For KCP\n showKCP={showKCP}\n // For SSN\n showBrazilianSSN={showBrazilianSSN}\n socialSecurityNumber={socialSecurityNumber}\n // For Store details\n handleOnStoreDetails={setStorePaymentMethod}\n // For Address\n setAddressRef={setAddressRef}\n billingAddress={billingAddress}\n billingAddressValidationRules={partialAddressSchema && getPartialAddressValidationRules(partialAddressCountry.current)}\n partialAddressSchema={partialAddressSchema}\n handleAddress={handleAddress}\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n //\n iOSFocusedField={iOSFocusedField}\n //\n onFieldFocusAnalytics={onFieldFocusAnalytics}\n onFieldBlurAnalytics={onFieldBlurAnalytics}\n />\n </div>\n )}\n />\n\n {props.fastlaneConfiguration && (\n <FastlaneSignup\n {...props.fastlaneConfiguration}\n currentDetectedBrand={internallyDetectedBrand}\n onChange={props.onChange}\n onSubmitAnalytics={props.onSubmitAnalytics}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n variant: props.isPayButtonPrimaryVariant ? 'primary' : 'secondary',\n icon: getImage({ imageFolder: 'components/' })(`${PREFIX}lock`)\n })}\n </Fragment>\n );\n};\n\nCardInput.defaultProps = defaultProps;\n\nexport default CardInput;\n"],"names":["CardInput","props","sfp","useRef","isValidating","getImage","useImage","billingAddressRef","setAddressRef","ref","current","cardInputRef","Object","keys","length","setComponentRef","hasPanLengthRef","isAutoJumping","specifications","useMemo","Specifications","status","setStatus","useState","errors","setErrors","valid","setValid","holderNameRequired","holderName","data","setData","hasHolderName","focusedElement","setFocusedElement","isSfpValid","setIsSfpValid","expiryDatePolicy","setExpiryDatePolicy","DATE_POLICY_REQUIRED","cvcPolicy","setCvcPolicy","CVC_POLICY_REQUIRED","issuingCountryCode","setIssuingCountryCode","dualBrandSelectElements","setDualBrandSelectElements","selectedBrandValue","setSelectedBrandValue","storedPaymentMethodId","brand","showBillingAddress","billingAddressMode","AddressModeOptions","none","billingAddressRequired","partialAddressSchema","handlePartialAddressMode","partialAddressCountry","billingAddress","country","storePaymentMethod","setStorePaymentMethod","setBillingAddress","showSocialSecurityNumber","setShowSocialSecurityNumber","socialSecurityNumber","setSocialSecurityNumber","installments","setInstallments","value","iOSFocusedField","setIOSFocusedField","internallyDetectedBrand","setInternallyDetectedBrand","handleChangeFor","triggerValidation","formData","formValid","formErrors","setSchema","setFormData","setFormValid","setFormErrors","useForm","schema","defaultData","formatters","cardInputFormatters","rules","cardInputValidationRules","hasInstallments","installmentOptions","fundingSource","showAmountsInInstallments","showInstallmentAmounts","isKorea","countryCode","showKCP","configuration","koreanAuthenticationRequired","showBrazilianSSN","socialSecurityNumberMode","onFieldFocusAnalytics","who","e","onFocus","fieldType","event","onFieldBlurAnalytics","onBlur","onBrand","useCallback","obj","handleFocus","getFocusHandler","retrieveLayout","getLayout","countrySpecificSchemas","getAddressSchemaForCountry","billingAddressRequiredFields","handleTouchstartIOS","elementType","name","handleAddress","getAddressHandler","doPanAutoJump","getAutoJumpHandler","extensions","CIExtensions","showValidation","clearSRPanel","processBinLookupResponse","binLookupResponse","isReset","processBinLookup","useEffect","setFocusOn","updateStyles","handleUnsupportedCard","destroy","newSchema","taxNumber","addressHasErrors","entries","reduce","acc","error","sortedErrorList","currentErrorsSortedByLayout","previousSortedErrors","useSRPanelForCardInputErrors","newErrors","getArrayDifferences","forEach","errorItem","aObj","field","errorCode","onValidationErrorAnalytics","holderNameValid","sfpValid","addressValid","koreanAuthentication","encryptedPassword","socialSecurityNumberValid","isValid","sfStateErrorsObj","mapErrorsToValidationRuleResult","mergedErrors","onChange","FieldToRender","StoredCardFieldsWrapper","CardFieldsWrapper","h","Fragment","SecuredFieldsProvider","extractPropsForSFP","styles","hasKoreanFields","sfState","eventDetails","autoCompleteName","acHolderName","getRuleByNameAndMode","holderNameValidationFn","autoFocus","ENCRYPTED_CARD_NUMBER","encryptedCardNumber","type","disableIOSArrowKeys","render","setRootNode","sfpState","div","className","classNames","role","FormInstruction","extractPropsForCardFields","handleInstallments","brandsIcons","handleOnStoreDetails","billingAddressValidationRules","getPartialAddressValidationRules","onAddressLookup","onAddressSelected","addressSearchDebounceMs","fastlaneConfiguration","FastlaneSignup","currentDetectedBrand","onSubmitAnalytics","showPayButton","payButton","variant","isPayButtonPrimaryVariant","icon","imageFolder","PREFIX","defaultProps"],"mappings":"0nDAgCA,MAAMA,EAAaC,IACf,MAAMC,EAAMC,EAAO,MACbC,EAAeD,GAAO,GACtBE,EAAWC,IAEXC,EAAoBJ,EAAO,MAC3BK,EAAgBC,IAClBF,EAAkBG,QAAUD,CAAAA,EAG1BE,EAAeR,EAAqB,IAErCS,OAAOC,KAAKF,EAAaD,SAASI,QACnCb,EAAMc,gBAAgBJ,EAAaD,SAGvC,MAAMM,EAAkBb,EAAO,GACzBc,EAAgBd,GAAO,GAEvBe,EAAiBC,GAAQ,IAAM,IAAIC,EAAenB,EAAMiB,iBAAiB,CAACjB,EAAMiB,iBAGtFP,EAAaD,QAAQR,IAAMA,EAK3B,MAAOmB,EAAQC,GAAaC,EAAS,UAE9BC,EAAQC,GAAaF,EAA8B,CAAA,IACnDG,EAAOC,GAAYJ,EAA8B,IAChDtB,EAAM2B,oBAAsB,CAAEC,YAAY,MAE3CC,EAAMC,GAAWR,EAA6B,IAC7CtB,EAAM+B,eAAiB,CAAEH,WAAY5B,EAAM6B,KAAKD,YAAc,OAG/DI,EAAgBC,IAAqBX,EAAS,KAC9CY,GAAYC,IAAiBb,GAAS,IACtCc,GAAkBC,IAAuBf,EAASgB,IAClDC,GAAWC,IAAgBlB,EAASmB,IACpCC,GAAoB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AU,CACZhM,SACAiM,QAASrN,EAAMsN,0BAA4B,UAAY,YACvDC,KAAMnN,EAAS,CAAEoN,YAAa,eAAxBpN,CAAyC,GAAGqN,WACtD,EAKhB1N,EAAU2N,aAAeA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport { BinLookupResponse, BrandConfiguration, CardBrandsConfiguration, CardBackendConfiguration, DualBrandSelectElement } from '../../types';\nimport { InstallmentOptions } from './components/types';\nimport { ValidationResult } from '../../../internal/PersonalDetails/types';\nimport {\n CardAllValidData,\n CardAutoCompleteData,\n CardBinValueData,\n CardBrandData,\n CardConfigSuccessData,\n CardFieldValidData,\n CardLoadData,\n CVCPolicyType,\n DatePolicyType\n} from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CardErrorData, StylesObject } from '../../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../../core/Context/Resources';\nimport { SRPanel } from '../../../../core/Errors/SRPanel';\nimport RiskElement from '../../../../core/RiskModule';\nimport { DisclaimerMsgObject } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { OnAddressLookupType, OnAddressSelectedType } from '../../../internal/Address/components/AddressSearch';\nimport { ComponentMethodsRef } from '../../../internal/UIElement/types';\nimport { AddressData, PaymentAmount } from '../../../../types/global-types';\nimport { AnalyticsModule } from '../../../../types/global-types';\nimport { FieldErrorAnalyticsObject } from '../../../../core/Analytics/types';\n\nexport interface CardInputValidState {\n holderName?: boolean;\n billingAddress?: boolean;\n socialSecurityNumber?: boolean;\n encryptedCardNumber?: boolean;\n encryptedExpiryMonth?: boolean;\n encryptedExpiryYear?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: boolean;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputErrorState {\n holderName?: ValidationResult;\n billingAddress?: ValidationResult;\n socialSecurityNumber?: ValidationResult;\n encryptedCardNumber?: boolean;\n encryptedExpiryDate?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: ValidationResult;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputDataState {\n holderName?: string;\n billingAddress?: AddressData;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\ntype PlaceholderKeys =\n | 'holderName'\n | 'cardNumber'\n | 'expiryDate'\n | 'expiryMonth'\n | 'expiryYear'\n | 'securityCodeThreeDigits'\n | 'securityCodeFourDigits'\n | 'password';\nexport type Placeholders = Partial<Record<PlaceholderKeys, string>>;\n\n/**\n * Should be the subset of the props sent to CardInput that are *actually* used by CardInput\n * - either in the comp itself or are passed on to its children\n */\nexport interface CardInputProps {\n amount?: PaymentAmount;\n isPayButtonPrimaryVariant?: boolean;\n autoFocus?: boolean;\n billingAddressAllowedCountries?: string[];\n billingAddressRequired?: boolean;\n billingAddressRequiredFields?: string[];\n billingAddressMode?: AddressModeOptions;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n brandsIcons: Array<BrandConfiguration>;\n clientKey: string;\n configuration?: CardBackendConfiguration;\n countryCode?: string;\n cvcPolicy?: CVCPolicyType;\n data?: CardInputDataState;\n disableIOSArrowKeys?: boolean;\n enableStoreDetails?: boolean;\n expiryMonth?: string;\n expiryYear?: string;\n forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderName?: string;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: string;\n installmentOptions?: InstallmentOptions;\n keypadFix?: boolean;\n lastFour?: string;\n loadingContext: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n modules?: {\n srPanel: SRPanel;\n analytics: AnalyticsModule;\n risk: RiskElement;\n resources: Resources;\n };\n onAdditionalSFConfig?: () => {};\n onAdditionalSFRemoved?: () => {};\n onAllValid?: (o: CardAllValidData) => {};\n onAutoComplete?: (o: CardAutoCompleteData) => {};\n onBinValue?: (o: CardBinValueData) => {};\n onBlur?: (e) => {};\n onBrand?: (o: CardBrandData) => {};\n onConfigSuccess?: (O: CardConfigSuccessData) => {};\n onChange?: (state) => {};\n onError?: () => {};\n onFieldValid?: (o: CardFieldValidData) => {};\n onFocus?: (e) => {};\n onLoad?: (o: CardLoadData) => {};\n handleKeyPress?: (obj: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n addressSearchDebounceMs?: number;\n payButton?: (obj) => {};\n placeholders?: Placeholders;\n positionHolderNameOnTop?: boolean;\n resources: Resources;\n setComponentRef?: (ref) => void;\n showBrandIcon?: boolean;\n showInstallmentAmounts?: boolean;\n showPayButton: boolean;\n showStoreDetailsCheckbox?: boolean;\n showWarnings?: boolean;\n showContextualElement?: boolean;\n specifications?: Specifications;\n storedPaymentMethodId?: string;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type?: string;\n maskSecurityCode?: boolean;\n exposeExpiryDate?: boolean;\n disclaimerMessage?: DisclaimerMsgObject;\n onValidationErrorAnalytics?: (obj: FieldErrorAnalyticsObject) => {};\n}\n\nexport interface CardInputState {\n dualBrandSelectElements: DualBrandSelectElement[];\n selectedBrandValue: string;\n billingAddress: object;\n brand?: string;\n data?: object;\n errors?: object;\n focusedElement: string;\n cvcPolicy: CVCPolicyType;\n expiryDatePolicy: DatePolicyType;\n isValid: boolean;\n status: string;\n valid?: object;\n issuingCountryCode: string;\n showSocialSecurityNumber?: boolean;\n}\n\n// An interface for the members exposed by CardInput to its parent Card/UIElement\nexport interface CardInputRef extends ComponentMethodsRef {\n sfp?: any;\n setFocusOn?: (who) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CardErrorData) => boolean;\n}\n\nexport interface FieldError {\n errorMessage?: string;\n errorI18n?: string;\n}\n\nexport interface SFError {\n isValid?: boolean;\n errorMessage?: string;\n errorI18n?: string;\n error: string;\n rootNode: HTMLElement;\n detectedBrands?: string[];\n}\n\nexport interface SFStateErrorObj {\n [key: string]: SFError;\n}\n\nexport interface LayoutObj {\n props: CardInputProps;\n showKCP: boolean;\n showBrazilianSSN: boolean;\n countrySpecificSchemas: AddressSchema;\n billingAddressRequiredFields?: string[];\n}\n\nexport enum AddressModeOptions {\n full = 'full',\n partial = 'partial',\n none = 'none'\n}\n"],"names":["AddressModeOptions"],"mappings":"AA6MO,IAAAA,EAAKA,SAAAA,GAAAA,uDAAAA,CAIX,CAJWA,CAIX,CAAA"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../src/components/Card/components/CardInput/types.ts"],"sourcesContent":["import Language from '../../../../language/Language';\nimport type {\n BinLookupResponse,\n BrandConfiguration,\n CardBrandsConfiguration,\n CardBackendConfiguration,\n DualBrandSelectElement,\n CardPlaceholders\n} from '../../types';\nimport { InstallmentOptions } from './components/types';\nimport { ValidationResult } from '../../../internal/PersonalDetails/types';\nimport {\n CardAllValidData,\n CardAutoCompleteData,\n CardBinValueData,\n CardBrandData,\n CardConfigSuccessData,\n CardFieldValidData,\n CardLoadData,\n CVCPolicyType,\n DatePolicyType\n} from '../../../internal/SecuredFields/lib/types';\nimport Specifications from '../../../internal/Address/Specifications';\nimport { AddressSchema } from '../../../internal/Address/types';\nimport { CardErrorData, StylesObject } from '../../../internal/SecuredFields/lib/types';\nimport { Resources } from '../../../../core/Context/Resources';\nimport { SRPanel } from '../../../../core/Errors/SRPanel';\nimport RiskElement from '../../../../core/RiskModule';\nimport { DisclaimerMsgObject } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { OnAddressLookupType, OnAddressSelectedType } from '../../../internal/Address/components/AddressSearch';\nimport { ComponentMethodsRef } from '../../../internal/UIElement/types';\nimport { AddressData, PaymentAmount } from '../../../../types/global-types';\nimport { AnalyticsModule } from '../../../../types/global-types';\nimport { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport type { FastlaneSignupConfiguration } from '../../../PayPalFastlane/types';\n\nexport interface CardInputValidState {\n holderName?: boolean;\n billingAddress?: boolean;\n socialSecurityNumber?: boolean;\n encryptedCardNumber?: boolean;\n encryptedExpiryMonth?: boolean;\n encryptedExpiryYear?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: boolean;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputErrorState {\n holderName?: ValidationResult;\n billingAddress?: ValidationResult;\n socialSecurityNumber?: ValidationResult;\n encryptedCardNumber?: boolean;\n encryptedExpiryDate?: boolean;\n encryptedSecurityCode?: boolean;\n taxNumber?: ValidationResult;\n encryptedPassword?: boolean;\n}\n\nexport interface CardInputDataState {\n holderName?: string;\n billingAddress?: AddressData;\n socialSecurityNumber?: string;\n taxNumber?: string;\n}\n\n/**\n * Should be the subset of the props sent to CardInput that are *actually* used by CardInput\n * - either in the comp itself or are passed on to its children\n */\nexport interface CardInputProps {\n amount?: PaymentAmount;\n isPayButtonPrimaryVariant?: boolean;\n autoFocus?: boolean;\n billingAddressAllowedCountries?: string[];\n billingAddressRequired?: boolean;\n billingAddressRequiredFields?: string[];\n billingAddressMode?: AddressModeOptions;\n brand?: string;\n brands?: string[];\n brandsConfiguration?: CardBrandsConfiguration;\n brandsIcons: Array<BrandConfiguration>;\n clientKey: string;\n configuration?: CardBackendConfiguration;\n countryCode?: string;\n cvcPolicy?: CVCPolicyType;\n data?: CardInputDataState;\n disableIOSArrowKeys?: boolean;\n enableStoreDetails?: boolean;\n expiryMonth?: string;\n expiryYear?: string;\n fastlaneConfiguration?: FastlaneSignupConfiguration;\n forceCompat?: boolean;\n fundingSource?: 'debit' | 'credit';\n hasCVC?: boolean;\n hasHolderName?: boolean;\n holderName?: string;\n holderNameRequired?: boolean;\n i18n?: Language;\n implementationType?: string;\n installmentOptions?: InstallmentOptions;\n keypadFix?: boolean;\n lastFour?: string;\n loadingContext: string;\n legacyInputMode?: boolean;\n minimumExpiryDate?: string;\n modules?: {\n srPanel: SRPanel;\n analytics: AnalyticsModule;\n risk: RiskElement;\n resources: Resources;\n };\n onAdditionalSFConfig?: () => {};\n onAdditionalSFRemoved?: () => {};\n onAllValid?: (o: CardAllValidData) => {};\n onAutoComplete?: (o: CardAutoCompleteData) => {};\n onBinValue?: (o: CardBinValueData) => {};\n onBlur?: (e) => {};\n onBrand?: (o: CardBrandData) => {};\n onConfigSuccess?: (O: CardConfigSuccessData) => {};\n onChange?: (state) => {};\n onError?: () => {};\n onFieldValid?: (o: CardFieldValidData) => {};\n onFocus?: (e) => {};\n onLoad?: (o: CardLoadData) => {};\n onSubmitAnalytics(event: SendAnalyticsObject): void;\n handleKeyPress?: (obj: KeyboardEvent) => void;\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n addressSearchDebounceMs?: number;\n payButton?: (obj) => {};\n placeholders?: CardPlaceholders;\n positionHolderNameOnTop?: boolean;\n resources: Resources;\n setComponentRef?: (ref) => void;\n showBrandIcon?: boolean;\n showInstallmentAmounts?: boolean;\n showPayButton: boolean;\n showStoreDetailsCheckbox?: boolean;\n showWarnings?: boolean;\n showContextualElement?: boolean;\n specifications?: Specifications;\n storedPaymentMethodId?: string;\n styles?: StylesObject;\n trimTrailingSeparator?: boolean;\n type?: string;\n maskSecurityCode?: boolean;\n exposeExpiryDate?: boolean;\n disclaimerMessage?: DisclaimerMsgObject;\n onValidationErrorAnalytics?: (obj: FieldErrorAnalyticsObject) => {};\n}\n\nexport interface CardInputState {\n dualBrandSelectElements: DualBrandSelectElement[];\n selectedBrandValue: string;\n billingAddress: object;\n brand?: string;\n data?: object;\n errors?: object;\n focusedElement: string;\n cvcPolicy: CVCPolicyType;\n expiryDatePolicy: DatePolicyType;\n isValid: boolean;\n status: string;\n valid?: object;\n issuingCountryCode: string;\n showSocialSecurityNumber?: boolean;\n}\n\n// An interface for the members exposed by CardInput to its parent Card/UIElement\nexport interface CardInputRef extends ComponentMethodsRef {\n sfp?: any;\n setFocusOn?: (who) => void;\n processBinLookupResponse?: (binLookupResponse: BinLookupResponse, isReset: boolean) => void;\n updateStyles?: (stylesObj: StylesObject) => void;\n handleUnsupportedCard?: (errObj: CardErrorData) => boolean;\n}\n\nexport interface FieldError {\n errorMessage?: string;\n errorI18n?: string;\n}\n\nexport interface SFError {\n isValid?: boolean;\n errorMessage?: string;\n errorI18n?: string;\n error: string;\n rootNode: HTMLElement;\n detectedBrands?: string[];\n}\n\nexport interface SFStateErrorObj {\n [key: string]: SFError;\n}\n\nexport interface LayoutObj {\n props: CardInputProps;\n showKCP: boolean;\n showBrazilianSSN: boolean;\n countrySpecificSchemas: AddressSchema;\n billingAddressRequiredFields?: string[];\n}\n\nexport enum AddressModeOptions {\n full = 'full',\n partial = 'partial',\n none = 'none'\n}\n"],"names":["AddressModeOptions"],"mappings":"AA4MO,IAAAA,EAAKA,SAAAA,GAAAA,uDAAAA,CAIX,CAJWA,CAIX,CAAA"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e,Fragment as n}from"../../../../external/preact/dist/preact.js";import{useMemo as t,useState as a,useCallback as o,useEffect as s}from"../../../../external/preact/hooks/dist/hooks.js";import r from"../../../../_virtual/index.js";import i from"../../../internal/Toggle/Toggle.js";import l from"../../../internal/Img/Img.js";import c from"../../../../core/Context/useImage.js";import m from"./USOnlyPhoneInput.js";import{InfoButton as d}from"./InfoButton.js";import{useCoreContext as f}from"../../../../core/Context/CoreProvider.js";import{LabelOnlyDisclaimerMessage as g}from"../../../internal/DisclaimerMessage/DisclaimerMessage.js";import{isConfigurationValid as u}from"./utils/validate-configuration.js";import p from"./utils/mobile-number-formatter.js";import{InfoEventTypes as y,ANALYTICS_EVENT as h}from"../../../../core/Analytics/constants.js";const _=["mc","visa"],k=({showConsent:k,defaultToggleState:j,termsAndConditionsLink:C,privacyPolicyLink:v,termsAndConditionsVersion:b,fastlaneSessionId:S,currentDetectedBrand:T,telephoneNumber:x,onChange:I,onSubmitAnalytics:A})=>{const D=t((()=>k&&_.includes(T)),[k,T]),[N,L]=a(D),[P,V]=a(j),w=c(),[F,M]=a(""),{i18n:B}=f(),E=t((()=>u({showConsent:k,defaultToggleState:j,termsAndConditionsLink:C,privacyPolicyLink:v,termsAndConditionsVersion:b,fastlaneSessionId:S})),[k,j,C,v,b,S]),O=o((()=>{const e=!P;V(e),A({type:h.info,infoType:y.clicked,target:"fastlane_signup_consent_toggle",configData:{isToggleOn:e}})}),[P,A]);return s((()=>{E&&I({fastlaneData:{consentShown:N,fastlaneSessionId:S,consentGiven:!!D&&P,...b&&{consentVersion:b},...F&&{telephoneNumber:F}}})}),[D,N,b,P,S,F,I,E]),s((()=>{D&&L(!0)}),[D]),s((()=>{E&&A({type:h.info,infoType:y.rendered,configData:{isFastlaneSignupRendered:D}})}),[D,E,A]),D&&E?e("div",{className:"adyen-checkout-card__fastlane","data-testid":"fastlane-signup-component"},e("div",{className:r("adyen-checkout-card__fastlane-consent-toggle",{"adyen-checkout-card__fastlane-consent-toggle--active":P})},e(i,{checked:P,onChange:O,ariaLabel:B.get("card.fastlane.consentToggle"),label:e("span",null,B.get("card.fastlane.consentToggle"))}),e(d,null)),P&&e(n,null,e(m,{initialValue:p(x),onChange:M}),e("div",{className:"adyen-checkout-card__fastlane-consent-text"},e(g,{message:B.get("card.fastlane.consentText"),urls:[C,v]})),e(l,{className:"adyen-checkout-card__fastlane-brand",src:w({imageFolder:"components/"})("paypal_fastlane_black"),alt:B.get("card.fastlane.a11y.logo")}))):null};export{k as default};
2
+ //# sourceMappingURL=FastlaneSignup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FastlaneSignup.js","sources":["../../../../../../src/components/Card/components/Fastlane/FastlaneSignup.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport Toggle from '../../../internal/Toggle';\nimport Img from '../../../internal/Img';\nimport useImage from '../../../../core/Context/useImage';\nimport USOnlyPhoneInput from './USOnlyPhoneInput';\nimport { InfoButton } from './InfoButton';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { LabelOnlyDisclaimerMessage } from '../../../internal/DisclaimerMessage/DisclaimerMessage';\nimport { isConfigurationValid } from './utils/validate-configuration';\nimport mobileNumberFormatter from './utils/mobile-number-formatter';\nimport { ANALYTICS_EVENT, InfoEventTypes } from '../../../../core/Analytics/constants';\nimport type { FastlaneSignupConfiguration } from '../../../PayPalFastlane/types';\nimport type { SendAnalyticsObject } from '../../../../core/Analytics/types';\n\nimport './FastlaneSignup.scss';\n\ntype FastlaneSignupProps = FastlaneSignupConfiguration & {\n currentDetectedBrand: string;\n onChange(state: any): void;\n onSubmitAnalytics(event: SendAnalyticsObject): void;\n};\n\nconst SUPPORTED_BRANDS = ['mc', 'visa'];\n\nconst FastlaneSignup = ({\n showConsent,\n defaultToggleState,\n termsAndConditionsLink,\n privacyPolicyLink,\n termsAndConditionsVersion,\n fastlaneSessionId,\n currentDetectedBrand,\n telephoneNumber: telephoneNumberFromProps,\n onChange,\n onSubmitAnalytics\n}: FastlaneSignupProps) => {\n const shouldDisplaySignup = useMemo(() => showConsent && SUPPORTED_BRANDS.includes(currentDetectedBrand), [showConsent, currentDetectedBrand]);\n const [hasConsentFormBeenShown, setHasConsentFormBeenShown] = useState<boolean>(shouldDisplaySignup);\n const [isChecked, setIsChecked] = useState<boolean>(defaultToggleState);\n const getImage = useImage();\n const [telephoneNumber, setTelephoneNumber] = useState<string>('');\n const { i18n } = useCoreContext();\n const isFastlaneConfigurationValid = useMemo(() => {\n return isConfigurationValid({\n showConsent,\n defaultToggleState,\n termsAndConditionsLink,\n privacyPolicyLink,\n termsAndConditionsVersion,\n fastlaneSessionId\n });\n }, [showConsent, defaultToggleState, termsAndConditionsLink, privacyPolicyLink, termsAndConditionsVersion, fastlaneSessionId]);\n\n const handleToggleChange = useCallback(() => {\n const newValue = !isChecked;\n setIsChecked(newValue);\n\n onSubmitAnalytics({\n type: ANALYTICS_EVENT.info,\n infoType: InfoEventTypes.clicked,\n target: 'fastlane_signup_consent_toggle',\n configData: {\n isToggleOn: newValue\n }\n });\n }, [isChecked, onSubmitAnalytics]);\n\n /**\n * If the configuration is valid, the Component propagates fastlaneData to the Card component state\n *\n * 'telephoneNumber' is optional since the shopper can check out without passing it\n * 'termsAndConditionsVersion' is optional since the signup flow may not be available for the shopper, although we still add fastlaneData to the /payments request for analytics purposes\n */\n useEffect(() => {\n if (!isFastlaneConfigurationValid) {\n return;\n }\n\n onChange({\n fastlaneData: {\n consentShown: hasConsentFormBeenShown,\n fastlaneSessionId: fastlaneSessionId,\n consentGiven: shouldDisplaySignup ? isChecked : false,\n ...(termsAndConditionsVersion && { consentVersion: termsAndConditionsVersion }),\n ...(telephoneNumber && { telephoneNumber })\n }\n });\n }, [\n shouldDisplaySignup,\n hasConsentFormBeenShown,\n termsAndConditionsVersion,\n isChecked,\n fastlaneSessionId,\n telephoneNumber,\n onChange,\n isFastlaneConfigurationValid\n ]);\n\n /**\n * If the sign-up has been displayed at least once, we set hasConsentFormBeenShown: true\n */\n useEffect(() => {\n if (shouldDisplaySignup) {\n setHasConsentFormBeenShown(true);\n }\n }, [shouldDisplaySignup]);\n\n useEffect(() => {\n if (!isFastlaneConfigurationValid) {\n return;\n }\n\n onSubmitAnalytics({\n type: ANALYTICS_EVENT.info,\n infoType: InfoEventTypes.rendered,\n configData: {\n isFastlaneSignupRendered: shouldDisplaySignup\n }\n });\n }, [shouldDisplaySignup, isFastlaneConfigurationValid, onSubmitAnalytics]);\n\n if (!shouldDisplaySignup || !isFastlaneConfigurationValid) {\n return null;\n }\n\n return (\n <div className=\"adyen-checkout-card__fastlane\" data-testid=\"fastlane-signup-component\">\n <div\n className={cx('adyen-checkout-card__fastlane-consent-toggle', {\n 'adyen-checkout-card__fastlane-consent-toggle--active': isChecked\n })}\n >\n <Toggle\n checked={isChecked}\n onChange={handleToggleChange}\n ariaLabel={i18n.get('card.fastlane.consentToggle')}\n label={<span>{i18n.get('card.fastlane.consentToggle')}</span>}\n />\n <InfoButton />\n </div>\n\n {isChecked && (\n <Fragment>\n <USOnlyPhoneInput initialValue={mobileNumberFormatter(telephoneNumberFromProps)} onChange={setTelephoneNumber} />\n <div className=\"adyen-checkout-card__fastlane-consent-text\">\n <LabelOnlyDisclaimerMessage\n message={i18n.get('card.fastlane.consentText')}\n urls={[termsAndConditionsLink, privacyPolicyLink]}\n />\n </div>\n <Img\n className=\"adyen-checkout-card__fastlane-brand\"\n src={getImage({ imageFolder: 'components/' })(`paypal_fastlane_black`)}\n alt={i18n.get('card.fastlane.a11y.logo')}\n />\n </Fragment>\n )}\n </div>\n );\n};\n\nexport default FastlaneSignup;\n"],"names":["SUPPORTED_BRANDS","FastlaneSignup","showConsent","defaultToggleState","termsAndConditionsLink","privacyPolicyLink","termsAndConditionsVersion","fastlaneSessionId","currentDetectedBrand","telephoneNumber","telephoneNumberFromProps","onChange","onSubmitAnalytics","shouldDisplaySignup","useMemo","includes","hasConsentFormBeenShown","setHasConsentFormBeenShown","useState","isChecked","setIsChecked","getImage","useImage","setTelephoneNumber","i18n","useCoreContext","isFastlaneConfigurationValid","isConfigurationValid","handleToggleChange","useCallback","newValue","type","ANALYTICS_EVENT","info","infoType","InfoEventTypes","clicked","target","configData","isToggleOn","useEffect","fastlaneData","consentShown","consentGiven","consentVersion","rendered","isFastlaneSignupRendered","h","div","className","data-testid","cx","Toggle","checked","ariaLabel","get","label","span","InfoButton","Fragment","USOnlyPhoneInput","initialValue","mobileNumberFormatter","LabelOnlyDisclaimerMessage","message","urls","Img","src","imageFolder","alt"],"mappings":"22BAwBA,MAAMA,EAAmB,CAAC,KAAM,QAE1BC,EAAiB,EACnBC,cACAC,qBACAC,yBACAC,oBACAC,4BACAC,oBACAC,uBACAC,gBAAiBC,EACjBC,WACAC,wBAEA,MAAMC,EAAsBC,GAAQ,IAAMZ,GAAeF,EAAiBe,SAASP,IAAuB,CAACN,EAAaM,KACjHQ,EAAyBC,GAA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UY,IAC3FwB,EAACC,MAAAA,CAAIC,UAAU,8CACXF,EAACgB,EAAAA,CACGC,QAASxC,EAAK+B,IAAI,6BAClBU,KAAM,CAAC7D,EAAwBC,MAGvC0C,EAACmB,EAAAA,CACGjB,UAAU,sCACVkB,IAAK9C,EAAS,CAAE+C,YAAa,eAAxB/C,CAAyC,yBAC9CgD,IAAK7C,EAAK+B,IAAI,+BA/BvB"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e,Fragment as o}from"../../../../external/preact/dist/preact.js";import{useState as t,useRef as a,useCallback as r}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import s from"../../../../core/Context/useImage.js";import{InfoModal as i}from"./InfoModal.js";import l from"../../../internal/Img/Img.js";import m from"../../../internal/Button/Button.js";const f=()=>{const[f,c]=t(!1),{i18n:p}=n(),d=s(),u=a(),g=r((()=>{c(!1)}),[]),j=r((()=>{c(!0)}),[]);return e(o,null,e(m,{buttonRef:u,onClick:j,classNameModifiers:["fastlane-info-modal"],variant:"link",ariaLabel:p.get("card.fastlane.a11y.openDialog"),label:e(l,{height:"14",width:"14",src:d({imageFolder:"components/"})("fastlane_info"),alt:"",ariaHidden:!0})}),e(i,{isOpen:f,onClose:g,focusAfterClose:u.current}))};export{f as InfoButton};
2
+ //# sourceMappingURL=InfoButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoButton.js","sources":["../../../../../../src/components/Card/components/Fastlane/InfoButton.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport useImage from '../../../../core/Context/useImage';\nimport { InfoModal } from './InfoModal';\nimport Img from '../../../internal/Img';\nimport Button from '../../../internal/Button';\n\nconst InfoButton = () => {\n const [isInfoModalOpen, setIsInfoModalOpen] = useState<boolean>(false);\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const buttonRef = useRef();\n\n const handleOnClose = useCallback(() => {\n setIsInfoModalOpen(false);\n }, []);\n\n const handleOnIconClick = useCallback(() => {\n setIsInfoModalOpen(true);\n }, []);\n\n return (\n <Fragment>\n <Button\n buttonRef={buttonRef}\n onClick={handleOnIconClick}\n classNameModifiers={['fastlane-info-modal']}\n variant=\"link\"\n ariaLabel={i18n.get('card.fastlane.a11y.openDialog')}\n label={<Img height=\"14\" width=\"14\" src={getImage({ imageFolder: 'components/' })('fastlane_info')} alt=\"\" ariaHidden={true} />}\n />\n\n <InfoModal isOpen={isInfoModalOpen} onClose={handleOnClose} focusAfterClose={buttonRef.current} />\n </Fragment>\n );\n};\n\nexport { InfoButton };\n"],"names":["InfoButton","isInfoModalOpen","setIsInfoModalOpen","useState","i18n","useCoreContext","getImage","useImage","buttonRef","useRef","handleOnClose","useCallback","handleOnIconClick","h","Fragment","Button","onClick","classNameModifiers","variant","ariaLabel","get","label","Img","height","width","src","imageFolder","alt","ariaHidden","InfoModal","isOpen","onClose","focusAfterClose","current"],"mappings":"wcAQA,MAAMA,EAAa,KACf,MAAOC,EAAiBC,GAAsBC,GAAkB,IAC1DC,KAAEA,GAASC,IACXC,EAAWC,IACXC,EAAYC,IAEZC,EAAgBC,GAAY,KAC9BT,GAAmB,EAAA,GACpB,IAEGU,EAAoBD,GAAY,KAClCT,GAAmB,EAAA,GACpB,IAEH,OACIW,EAACC,OACGD,EAACE,EAAAA,CACGP,UAAWA,EACXQ,QAASJ,EACTK,mBAAoB,CAAC,uBACrBC,QAAQ,OACRC,UAAWf,EAAKgB,IAAI,iCACpBC,MAAOR,EAACS,EAAAA,CAAIC,OAAO,KAAKC,MAAM,KAAKC,IAAKnB,EAAS,CAAEoB,YAAa,eAAxBpB,CAAyC,iBAAkBqB,IAAI,GAAGC,YAAY,MAG1Hf,EAACgB,EAAAA,CAAUC,OAAQ7B,EAAiB8B,QAASrB,EAAesB,gBAAiBxB,EAAUyB"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useRef as a}from"../../../../external/preact/hooks/dist/hooks.js";import t from"../../../../core/Context/useImage.js";import{Modal as l}from"../../../internal/Modal/Modal.js";import d from"../../../internal/Img/Img.js";import o from"../../../internal/Button/Button.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import n from"../../../../utils/uuid.js";const r=[{headerKey:"card.fastlane.modal.benefit1.header",labelById:`adyen-fastlane-modal-label-${n()}`,descriptionTextKey:"card.fastlane.modal.benefit1.text",describedById:`adyen-fastlane-modal-describedBy-${n()}`,image:"fastlane_autofill",altImage:""},{headerKey:"card.fastlane.modal.benefit2.header",labelById:`adyen-fastlane-modal-label-${n()}`,descriptionTextKey:"card.fastlane.modal.benefit2.text",describedById:`adyen-fastlane-modal-describedBy-${n()}`,image:"fastlane_protection",altImage:""},{headerKey:"card.fastlane.modal.benefit3.header",labelById:`adyen-fastlane-modal-label-${n()}`,descriptionTextKey:"card.fastlane.modal.benefit3.text",describedById:`adyen-fastlane-modal-describedBy-${n()}`,image:"fastlane_ubiquity",altImage:""}],i=({isOpen:n,onClose:i,focusAfterClose:c})=>{const{i18n:m}=s(),f=a(),y=t(),b=r.map((e=>e.labelById)).join(" "),p=r.map((e=>e.describedById)).join(" ");return e(l,{onClose:i,isOpen:n,labelledBy:b,describedBy:p,focusFirst:f.current,focusAfterClose:c},(({onCloseModal:a})=>e("div",{className:"adyen-checkout-card-fastlane__modal"},e("div",{className:"adyen-checkout-card-fastlane__modal-button-container"},e(o,{onClick:a,inline:!0,variant:"link",ariaLabel:m.get("card.fastlane.a11y.closeDialog"),label:e(d,{height:"10",width:"10",src:y({imageFolder:"components/"})("cross_black"),ariaHidden:!0,alt:""})})),r.map((a=>e("div",{key:a.labelById,className:"adyen-checkout-card-fastlane__modal-section"},e(d,{className:"adyen-checkout-card-fastlane__modal-section-image",src:y({imageFolder:"components/"})(a.image),alt:a.altImage}),e("h1",{id:a.labelById,className:"adyen-checkout-card-fastlane__modal-section-header"},m.get(a.headerKey)),e("div",{id:a.describedById,className:"adyen-checkout-card-fastlane__modal-section-text"},m.get(a.descriptionTextKey))))),e(d,{className:"adyen-checkout-card-fastlane__modal-brand",src:y({imageFolder:"components/"})("paypal_fastlane_black"),alt:m.get("card.fastlane.a11y.logo")}))))};export{i as InfoModal};
2
+ //# sourceMappingURL=InfoModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoModal.js","sources":["../../../../../../src/components/Card/components/Fastlane/InfoModal.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useRef } from 'preact/hooks';\nimport useImage from '../../../../core/Context/useImage';\nimport { Modal } from '../../../internal/Modal';\nimport Img from '../../../internal/Img';\nimport Button from '../../../internal/Button';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport uuid from '../../../../utils/uuid';\n\nimport './InfoModal.scss';\n\ninterface InfoModalProps {\n isOpen: boolean;\n focusAfterClose: HTMLElement;\n onClose(): void;\n}\n\nconst FASTLANE_BENEFITS = [\n {\n headerKey: 'card.fastlane.modal.benefit1.header',\n labelById: `adyen-fastlane-modal-label-${uuid()}`,\n descriptionTextKey: 'card.fastlane.modal.benefit1.text',\n describedById: `adyen-fastlane-modal-describedBy-${uuid()}`,\n image: 'fastlane_autofill',\n altImage: ''\n },\n {\n headerKey: 'card.fastlane.modal.benefit2.header',\n labelById: `adyen-fastlane-modal-label-${uuid()}`,\n descriptionTextKey: 'card.fastlane.modal.benefit2.text',\n describedById: `adyen-fastlane-modal-describedBy-${uuid()}`,\n image: 'fastlane_protection',\n altImage: ''\n },\n {\n headerKey: 'card.fastlane.modal.benefit3.header',\n labelById: `adyen-fastlane-modal-label-${uuid()}`,\n descriptionTextKey: 'card.fastlane.modal.benefit3.text',\n describedById: `adyen-fastlane-modal-describedBy-${uuid()}`,\n image: 'fastlane_ubiquity',\n altImage: ''\n }\n];\n\nconst InfoModal = ({ isOpen, onClose, focusAfterClose }: InfoModalProps) => {\n const { i18n } = useCoreContext();\n const focusFirstElement = useRef<HTMLParagraphElement>();\n const getImage = useImage();\n\n const labelledBy = FASTLANE_BENEFITS.map(benefit => benefit.labelById).join(' ');\n const describedBy = FASTLANE_BENEFITS.map(benefit => benefit.describedById).join(' ');\n\n return (\n <Modal\n onClose={onClose}\n isOpen={isOpen}\n labelledBy={labelledBy}\n describedBy={describedBy}\n focusFirst={focusFirstElement.current}\n focusAfterClose={focusAfterClose}\n >\n {({ onCloseModal }) => (\n <div className=\"adyen-checkout-card-fastlane__modal\">\n <div className=\"adyen-checkout-card-fastlane__modal-button-container\">\n <Button\n onClick={onCloseModal}\n inline\n variant=\"link\"\n ariaLabel={i18n.get('card.fastlane.a11y.closeDialog')}\n label={\n <Img height=\"10\" width=\"10\" src={getImage({ imageFolder: 'components/' })('cross_black')} ariaHidden={true} alt=\"\" />\n }\n />\n </div>\n\n {FASTLANE_BENEFITS.map(benefit => (\n <div key={benefit.labelById} className=\"adyen-checkout-card-fastlane__modal-section\">\n <Img\n className=\"adyen-checkout-card-fastlane__modal-section-image\"\n src={getImage({ imageFolder: 'components/' })(benefit.image)}\n alt={benefit.altImage}\n />\n <h1 id={benefit.labelById} className=\"adyen-checkout-card-fastlane__modal-section-header\">\n {i18n.get(benefit.headerKey)}\n </h1>\n <div id={benefit.describedById} className=\"adyen-checkout-card-fastlane__modal-section-text\">\n {i18n.get(benefit.descriptionTextKey)}\n </div>\n </div>\n ))}\n\n <Img\n className=\"adyen-checkout-card-fastlane__modal-brand\"\n src={getImage({ imageFolder: 'components/' })(`paypal_fastlane_black`)}\n alt={i18n.get('card.fastlane.a11y.logo')}\n />\n </div>\n )}\n </Modal>\n );\n};\n\nexport { InfoModal };\n"],"names":["FASTLANE_BENEFITS","headerKey","labelById","uuid","descriptionTextKey","describedById","image","altImage","InfoModal","isOpen","onClose","focusAfterClose","i18n","useCoreContext","focusFirstElement","useRef","getImage","useImage","labelledBy","map","benefit","join","describedBy","h","Modal","focusFirst","current","onCloseModal","div","className","Button","onClick","inline","variant","ariaLabel","get","label","Img","height","width","src","imageFolder","ariaHidden","alt","key","h1","id"],"mappings":"kdAiBA,MAAMA,EAAoB,CACtB,CACIC,UAAW,sCACXC,UAAW,8BAA8BC,MACzCC,mBAAoB,oCACpBC,cAAe,oCAAoCF,MACnDG,MAAO,oBACPC,SAAU,IAEd,CACIN,UAAW,sCACXC,UAAW,8BAA8BC,MACzCC,mBAAoB,oCACpBC,cAAe,oCAAoCF,MACnDG,MAAO,sBACPC,SAAU,IAEd,CACIN,UAAW,sCACXC,UAAW,8BAA8BC,MACzCC,mBAAoB,oCACpBC,cAAe,oCAAoCF,MACnDG,MAAO,oBACPC,SAAU,KAIZC,EAAY,EAAGC,SAAQC,UAASC,sBAClC,MAAMC,KAAEA,GAASC,IACXC,EAAoBC,IACpBC,EAAWC,IAEXC,EAAalB,EAAkBmB,KAAIC,GAAWA,EAAQlB,YAAWmB,KAAK,KACtEC,EAActB,EAAkBmB,KAAIC,GAAWA,EAAQf,gBAAegB,KAAK,KAEjF,OACIE,EAACC,EAAAA,CACGd,QAASA,EACTD,OAAQA,EACRS,WAAYA,EACZI,YAAaA,EACbG,WAAYX,EAAkBY,QAC9Bf,gBAAiBA,IAEhB,EAAGgB,kBACAJ,EAACK,MAAAA,CAAIC,UAAU,uCACXN,EAACK,MAAAA,CAAIC,UAAU,wDACXN,EAACO,EAAAA,CACGC,QAASJ,EACTK,QAAAA,EACAC,QAAQ,OACRC,UAAWtB,EAAKuB,IAAI,kCACpBC,MACIb,EAACc,EAAAA,CAAIC,OAAO,KAAKC,MAAM,KAAKC,IAAKxB,EAAS,CAAEyB,YAAa,eAAxBzB,CAAyC,eAAgB0B,YAAY,EAAMC,IAAI,QAK3H3C,EAAkBmB,KAAIC,GACnBG,EAACK,MAAAA,CAAIgB,IAAKxB,EAAQlB,UAAW2B,UAAU,+CACnCN,EAACc,EAAAA,CACGR,UAAU,oDACVW,IAAKxB,EAAS,CAAEyB,YAAa,eAAxBzB,CAAyCI,EAAQd,OACtDqC,IAAKvB,EAAQb,WAEjBgB,EAACsB,KAAAA,CAAGC,GAAI1B,EAAQlB,UAAW2B,UAAU,sDAChCjB,EAAKuB,IAAIf,EAAQnB,YAEtBsB,EAACK,MAAAA,CAAIkB,GAAI1B,EAAQf,cAAewB,UAAU,oDACrCjB,EAAKuB,IAAIf,EAAQhB,wBAK9BmB,EAACc,EAAAA,CACGR,UAAU,4CACVW,IAAKxB,EAAS,CAAEyB,YAAa,eAAxBzB,CAAyC,yBAC9C2B,IAAK/B,EAAKuB,IAAI"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useRef as r,useCallback as o,useEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import l from"../../../internal/FormFields/Field/Field.js";import m from"../../../../utils/useForm/useForm.js";import a from"../../../internal/FormFields/InputTelephone.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import n from"./utils/mobile-number-formatter.js";const u=({initialValue:u,onChange:s})=>{const{i18n:b}=i(),{handleChangeFor:c,data:f}=m({schema:["mobileNumber"],defaultData:{mobileNumber:u},formatters:{mobileNumber:n}}),p=r(null),d=o((()=>{p.current?.focus()}),[p.current]);return t((()=>{s(f.mobileNumber?.replaceAll(" ",""))}),[f.mobileNumber,s]),e(l,{name:"mobile-number",label:b.get("card.fastlane.mobileInputLabel"),staticValue:"+1",onInputContainerClick:d},e(a,{name:"mobile-number",autocorrect:"off",spellcheck:!1,maxlength:12,value:f.mobileNumber,onInput:c("mobileNumber","input"),onBlur:c("mobileNumber","blur"),setRef:p}))};export{u as default};
2
+ //# sourceMappingURL=USOnlyPhoneInput.js.map