@adyen/adyen-web 6.40.1 → 6.41.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 (235) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +54 -61
  4. package/dist/es/components/ANCV/ANCV.js +1 -1
  5. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  6. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  7. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  8. package/dist/es/components/Blik/Blik.js +1 -1
  9. package/dist/es/components/Blik/Blik.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/types.js.map +1 -1
  13. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  14. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  15. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  16. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  17. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  18. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  19. package/dist/es/components/Dropin/Dropin.js +1 -1
  20. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  21. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  22. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  23. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  24. package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  26. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  27. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  28. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  29. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  30. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  31. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  32. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  33. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  34. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  35. package/dist/es/components/Giftcard/components/GiftcardPinField.js +1 -1
  36. package/dist/es/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  37. package/dist/es/components/Iris/Iris.js +1 -1
  38. package/dist/es/components/Iris/Iris.js.map +1 -1
  39. package/dist/es/components/MBWay/MBWay.js +1 -1
  40. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  41. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  42. package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  43. package/dist/es/components/PayTo/PayTo.js +1 -1
  44. package/dist/es/components/PayTo/PayTo.js.map +1 -1
  45. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  46. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  47. package/dist/es/components/PayTo/components/IdentifierSelector.js +1 -1
  48. package/dist/es/components/PayTo/components/IdentifierSelector.js.map +1 -1
  49. package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
  50. package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
  51. package/dist/es/components/PayTo/components/validate.js +1 -1
  52. package/dist/es/components/PayTo/components/validate.js.map +1 -1
  53. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  54. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  55. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  56. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  57. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  58. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  59. package/dist/es/components/UPI/UPI.js +1 -1
  60. package/dist/es/components/UPI/UPI.js.map +1 -1
  61. package/dist/es/components/internal/Await/Await.js +1 -1
  62. package/dist/es/components/internal/Await/Await.js.map +1 -1
  63. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  64. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  65. package/dist/es/components/internal/Button/Button.js +1 -1
  66. package/dist/es/components/internal/Button/Button.js.map +1 -1
  67. package/dist/es/components/internal/Button/CopyButton.js +1 -1
  68. package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
  69. package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
  70. package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
  71. package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  72. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  73. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  74. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  75. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  76. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  77. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  78. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  79. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  80. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  81. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  82. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  83. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  84. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  85. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  86. package/dist/es/components/internal/Modal/Modal.js +1 -1
  87. package/dist/es/components/internal/Modal/Modal.js.map +1 -1
  88. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  89. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  90. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  91. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  92. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  93. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  94. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  95. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  96. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  97. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  98. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  99. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  100. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  101. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  102. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  103. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  104. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  105. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  106. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  107. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  108. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  109. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  110. package/dist/es/core/config.js +1 -1
  111. package/dist/es/index.d.ts +54 -61
  112. package/dist/es/language/utils.js +1 -1
  113. package/dist/es/language/utils.js.map +1 -1
  114. package/dist/es/packages/server/translations/en-US.json.js +1 -1
  115. package/dist/es/utils/commonUtils.js +1 -1
  116. package/dist/es/utils/commonUtils.js.map +1 -1
  117. package/dist/es/utils/get-process-message-handler.js +1 -1
  118. package/dist/es/utils/get-process-message-handler.js.map +1 -1
  119. package/dist/es/utils/promiseTimeout.js.map +1 -1
  120. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  121. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  122. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  123. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  124. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  125. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  126. package/dist/es-legacy/components/Card/Card.js +1 -1
  127. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  128. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  129. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  130. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  131. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  133. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  134. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  135. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  136. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  137. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  138. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  139. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
  140. package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
  141. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  142. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  143. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  144. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  145. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  146. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
  147. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
  148. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  149. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  150. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  151. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js +1 -1
  152. package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js.map +1 -1
  153. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  154. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  155. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  156. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  157. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
  158. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js.map +1 -1
  159. package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
  160. package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
  161. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  162. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  163. package/dist/es-legacy/components/PayTo/components/IdentifierSelector.js +1 -1
  164. package/dist/es-legacy/components/PayTo/components/IdentifierSelector.js.map +1 -1
  165. package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
  166. package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
  167. package/dist/es-legacy/components/PayTo/components/validate.js +1 -1
  168. package/dist/es-legacy/components/PayTo/components/validate.js.map +1 -1
  169. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  170. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  171. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  172. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  173. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  174. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  175. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  176. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  177. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  178. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  179. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  180. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  181. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  182. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  183. package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
  184. package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
  185. package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
  186. package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
  187. package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
  188. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  189. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  190. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  191. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  192. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
  193. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
  194. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  195. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  196. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  197. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  198. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  199. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  200. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  201. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  202. package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
  203. package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
  204. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  205. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  206. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  207. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  208. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
  209. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  210. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  211. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  212. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
  213. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js.map +1 -1
  214. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  215. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  216. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  217. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  218. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  219. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  220. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  221. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  222. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  223. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  224. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
  225. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  226. package/dist/es-legacy/core/config.js +1 -1
  227. package/dist/es-legacy/language/utils.js +1 -1
  228. package/dist/es-legacy/language/utils.js.map +1 -1
  229. package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
  230. package/dist/es-legacy/utils/commonUtils.js +1 -1
  231. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  232. package/dist/es-legacy/utils/get-process-message-handler.js +1 -1
  233. package/dist/es-legacy/utils/get-process-message-handler.js.map +1 -1
  234. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  235. package/package.json +19 -19
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName) ?? '';\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : undefined}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n?.get('upi.qrCodeWaitingMessage') ?? ''}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType ?? ''}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey ?? ''}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n?.get('upi.vpaWaitingMessage') ?? ''}\n awaitText={this.props.i18n?.get('await.waitForConfirmation') ?? ''}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton ?? true}\n mandate={this.props.mandate}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","_object_spread","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","_this_props_i18n","h","QRLoader","qrCodeData","encodeURIComponent","undefined","brandLogo","onComplete","introduction","_ref","i18n","get","countdownTime","onActionHandled","showAmount","_this_props_clientKey","_ref1","_ref2","_this_props_i18n1","_this_props_i18n2","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","_this_props_showPayButton","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","onSubmitAnalytics","submitAnalytics","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","_this_core_modules_resources","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"m9CAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,OAAOC,EAAA,CACHC,0BAA2BC,KACxBH,EAEX,CAEA,WAAWI,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,IAAEA,GAAQH,KAAKC,MAAMG,MAAQ,CAAA,EAEnC,MAAO,CACHC,cAAeT,EAAA,CACXU,KAAMN,KAAKO,aACPP,KAAKO,cAAgBC,EAAWC,aAAcN,aAAAA,EAAAA,EAAKO,KAAM,CAAEC,MAAOR,EAAIO,KAGtF,CAEA,UAAIE,GACA,MAAMC,4BAAEA,GAAgCb,KAAKL,MAE7C,OAAKkB,EAIEb,KAAKc,SAASC,IAAIZ,KAAUa,KAAMb,EAAIa,KAAMC,KAAMd,EAAIc,QAHlD,EAIf,CAEA,eAAIV,GACA,OAAIP,KAAKkB,OAASC,EAASC,QAChBZ,EA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,UAAWjC,KAAKgB,OAG5B,QAQ2B,IAAAuC,EAPvB,OACI3B,EAAC4B,EAAAA,CACGC,gBAAiBzD,KAAKyD,gBACtBC,UAAW1D,KAAK0D,UAChBC,SAAU3D,KAAK4D,SACf9C,SAAUd,KAAKc,SACfI,KAAMlB,KAAKkB,KACX2C,cAAuC,QAAxBN,EAAAvD,KAAKL,MAAMkE,yBAAXN,GAAAA,EACf7B,QAAS1B,KAAKL,MAAM+B,QACpBoC,kBAAmB9D,KAAK+D,kBAI5C,CA1GA,WAAAC,CAAYC,EAAiBtE,GACzBuE,MAAMD,EAAUtE,GATpBwE,EAAAnE,KAAiBkB,YAAjB,GACAiD,EAAAnE,KAAiBc,gBAAjB,GASI,MAAMsD,KAAEA,EAAO,IAAOpE,KAAKL,MACrB0E,EAAgBD,EAAKE,OAAS,EAEpCtE,KAAKkB,KAAOpB,KAAcuE,EAAgBlD,EAASoD,OAASpD,EAASC,QAErEpB,KAAKc,SAAWsD,EAAKrD,IAAIZ,UAEHqE,EADlB,MAAMC,EAAY,OAAOtE,EAAIO,GAAGgE,gBAC1BC,EAAoDF,QAApDE,EAAuC,QAA3BH,EAAAxE,KAAK4E,KAAKC,QAAQC,iBAAlB,IAAAN,OAAA,EAAAA,EAA6BO,UAA7BP,CAAwCC,cAAAA,EAAAA,EAAc,GACxE,MAAO,CAAE/D,GAAIP,EAAIO,GAAIO,KAAMd,EAAIc,KAAMD,KAAM2D,IAEnD,EAtBAR,EADE3E,EACqBc,OAAOE,EAAWwE,KACzCb,EAFE3E,EAEqByF,aAAa,CAACzE,EAAWwE,IAAKxE,EAAWa,OAAQb,EAAWC,aAInF0D,EANE3E,EAMwB0F,eAAe,CACrCrE,6BAA6B,EAC7B0B,cAAe4C"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName) ?? '';\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : undefined}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n brandName={this.displayName}\n onComplete={this.onComplete}\n introduction={this.props.i18n?.get('upi.qrCodeWaitingMessage') ?? ''}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType ?? ''}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey ?? ''}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n?.get('upi.vpaWaitingMessage') ?? ''}\n awaitText={this.props.i18n?.get('await.waitForConfirmation') ?? ''}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n brandName={this.displayName}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton ?? true}\n mandate={this.props.mandate}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","_object_spread","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","_this_props_i18n","h","QRLoader","qrCodeData","encodeURIComponent","undefined","brandLogo","brandName","displayName","onComplete","introduction","_ref","i18n","get","countdownTime","onActionHandled","showAmount","_this_props_clientKey","_ref1","_ref2","_this_props_i18n1","_this_props_i18n2","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","_this_props_showPayButton","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","onSubmitAnalytics","submitAnalytics","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","_this_core_modules_resources","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"m9CAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,OAAOC,EAAA,CACHC,0BAA2BC,KACxBH,EAEX,CAEA,WAAWI,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,IAAEA,GAAQH,KAAKC,MAAMG,MAAQ,CAAA,EAEnC,MAAO,CACHC,cAAeT,EAAA,CACXU,KAAMN,KAAKO,aACPP,KAAKO,cAAgBC,EAAWC,aAAcN,aAAAA,EAAAA,EAAKO,KAAM,CAAEC,MAAOR,EAAIO,KAGtF,CAEA,UAAIE,GACA,MAAMC,4BAAEA,GAAgCb,KAAKL,MAE7C,OAAKkB,EAIEb,KAAKc,SAASC,IAAIZ,KAAUa,KAAMb,EAAIa,KAAMC,KAAMd,EAAIc,QAHlD,EAIf,CAEA,eAAIV,GACA,OAAIP,KAAKkB,OAASC,EAASC,QAChBZ,EAAWa,OAEfb,EAAWC,UACtB,CAEmBa,iBAAAA,GACf,MAAMhB,KAAEA,EAAIiB,IAAEA,EAAGC,kBAAEA,GAAsBxB,KAAKL,MAExC8B,IAAczB,KAAKL,MAAM+B,QAE/B,OAAQpB,GACJ,IAAK,eASqBqB,EARtB,OACIC,EAACC,EAAAA,EAAAA,EAAAA,GACO7B,KAAKL,OAAK,CACdmC,WAAY9B,KAAKL,MAAMmC,WAAaC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KL,MAAMoE,yBAAXN,GAAAA,EACf/B,QAAS1B,KAAKL,MAAM+B,QACpBsC,kBAAmBhE,KAAKiE,kBAI5C,CA5GA,WAAAC,CAAYC,EAAiBxE,GACzByE,MAAMD,EAAUxE,GATpB0E,EAAArE,KAAiBkB,YAAjB,GACAmD,EAAArE,KAAiBc,gBAAjB,GASI,MAAMwD,KAAEA,EAAO,IAAOtE,KAAKL,MACrB4E,EAAgBD,EAAKE,OAAS,EAEpCxE,KAAKkB,KAAOpB,KAAcyE,EAAgBpD,EAASsD,OAAStD,EAASC,QAErEpB,KAAKc,SAAWwD,EAAKvD,IAAIZ,UAEHuE,EADlB,MAAMC,EAAY,OAAOxE,EAAIO,GAAGkE,gBAC1BC,EAAoDF,QAApDE,EAAuC,QAA3BH,EAAA1E,KAAK8E,KAAKC,QAAQC,iBAAlB,IAAAN,OAAA,EAAAA,EAA6BO,UAA7BP,CAAwCC,cAAAA,EAAAA,EAAc,GACxE,MAAO,CAAEjE,GAAIP,EAAIO,GAAIO,KAAMd,EAAIc,KAAMD,KAAM6D,IAEnD,EAtBAR,EADE7E,EACqBc,OAAOE,EAAW0E,KACzCb,EAFE7E,EAEqB2F,aAAa,CAAC3E,EAAW0E,IAAK1E,EAAWa,OAAQb,EAAWC,aAInF4D,EANE7E,EAMwB4F,eAAe,CACrCvE,6BAA6B,EAC7B4B,cAAe4C"}
@@ -1,2 +1,2 @@
1
- import t from"../../../_virtual/index.js";import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{usePaymentStatusTimer as n}from"../../../hooks/usePaymentStatusTimer/usePaymentStatusTimer.js";import{DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS as i,DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS as r,DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS as s,DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN as c}from"../../../hooks/usePaymentStatusTimer/constants.js";import l from"../Spinner/Spinner.js";import m from"../Button/Button.js";import d from"../ContentSeparator/ContentSeparator.js";import u from"../Countdown/index.js";import{AwaitFinalState as _}from"./components/AwaitFinalState.js";import{redirectToApp as p}from"../../../utils/urls.js";import{useAmount as y}from"../../../core/Context/AmountProvider.js";import{useA11yReporter as h}from"../../../core/Errors/useA11yReporter.js";function w(i){var r;const{i18n:s,loadingContext:c}=o();h(i.awaitText);const{state:w,actions:g}=n({loadingContext:c,paymentData:i.paymentData,clientKey:i.clientKey,delay:i.delay,throttleTime:i.throttleTime,throttleInterval:i.throttleInterval,type:i.type,onError:i.onError,onComplete:i.onComplete,pollStatus:i.pollStatus,onActionHandled:i.onActionHandled}),{completed:k,expired:v,loading:f,percentage:N}=w,{onTick:T,onTimeUp:C}=g,{amount:x}=y();if(a(()=>{i.shouldRedirectAutomatically&&i.url&&p(i.url)},[i.shouldRedirectAutomatically,i.url]),v)return e(_,{image:"error",message:s.get("error.subtitle.payment")});if(k)return e(_,{image:"success",message:s.get("creditCard.success")});if(f)return e("div",{className:"adyen-checkout__await"},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),e(l,{inline:!1,size:"large"}));const j=s.get("wechatpay.timetopay").split("%@");return e("div",{className:t("adyen-checkout__await",`adyen-checkout__await--${i.type}`,i.classNameModifiers.map(t=>`adyen-checkout__await--${t}`))},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),!(!i.showAmount||null===(null==x?void 0:x.value)||!(null==x?void 0:x.currency))&&e("div",{className:"adyen-checkout__await__amount"},s.amount(x.value,x.currency)),null!=i.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},i.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(l,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},i.awaitText)),i.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${N}%`}})),e("div",{className:"adyen-checkout__await__countdown"},j[0]," ",e(u,{minutesFromNow:i.countdownTime,onTick:T,onCompleted:C})," ",j[1])),i.url&&!i.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(m,{classNameModifiers:["await"],onClick:()=>p(i.url),label:s.get("openApp")})),i.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof i.instructions?s.get(i.instructions):null===(r=i.instructions)||void 0===r?void 0:r.call(i)),i.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},i.endSlot()))}w.defaultProps={countdownTime:c,delay:s,throttleTime:r,throttleInterval:i,onError:()=>{},onComplete:()=>{},showCountdownTimer:!0,classNameModifiers:[],url:null};export{w as Await};
1
+ import t from"../../../_virtual/index.js";import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{usePaymentStatusTimer as n}from"../../../hooks/usePaymentStatusTimer/usePaymentStatusTimer.js";import{DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS as i,DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS as r,DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS as s,DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN as l}from"../../../hooks/usePaymentStatusTimer/constants.js";import c from"../Spinner/Spinner.js";import m from"../Button/Button.js";import d from"../ContentSeparator/ContentSeparator.js";import u from"../Countdown/index.js";import{AwaitFinalState as _}from"./components/AwaitFinalState.js";import{redirectToApp as p}from"../../../utils/urls.js";import{useAmount as y}from"../../../core/Context/AmountProvider.js";import{useA11yReporter as h}from"../../../core/Errors/useA11yReporter.js";function w(i){var r,s;const{i18n:l,loadingContext:w}=o();h(i.awaitText);const{state:v,actions:g}=n({loadingContext:w,paymentData:i.paymentData,clientKey:i.clientKey,delay:i.delay,throttleTime:i.throttleTime,throttleInterval:i.throttleInterval,type:i.type,onError:i.onError,onComplete:i.onComplete,pollStatus:i.pollStatus,onActionHandled:i.onActionHandled}),{completed:k,expired:f,loading:N,percentage:T}=v,{onTick:C,onTimeUp:x}=g,{amount:j}=y();if(a(()=>{i.shouldRedirectAutomatically&&i.url&&p(i.url)},[i.shouldRedirectAutomatically,i.url]),f)return e(_,{image:"error",message:l.get("error.subtitle.payment")});if(k)return e(_,{image:"success",message:l.get("creditCard.success")});var S;if(N)return e("div",{className:"adyen-checkout__await"},i.brandLogo&&e("img",{src:i.brandLogo,alt:null!==(S=i.brandName)&&void 0!==S?S:i.type,className:"adyen-checkout__await__brand-logo"}),e(c,{inline:!1,size:"large"}));const b=l.get("wechatpay.timetopay").split("%@");return e("div",{className:t("adyen-checkout__await",`adyen-checkout__await--${i.type}`,i.classNameModifiers.map(t=>`adyen-checkout__await--${t}`))},i.brandLogo&&e("img",{src:i.brandLogo,alt:null!==(r=i.brandName)&&void 0!==r?r:i.type,className:"adyen-checkout__await__brand-logo"}),!(!i.showAmount||null===(null==j?void 0:j.value)||!(null==j?void 0:j.currency))&&e("div",{className:"adyen-checkout__await__amount"},l.amount(j.value,j.currency)),null!=i.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},i.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(c,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},i.awaitText)),i.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${T}%`}})),e("div",{className:"adyen-checkout__await__countdown"},b[0]," ",e(u,{minutesFromNow:i.countdownTime,onTick:C,onCompleted:x})," ",b[1])),i.url&&!i.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(m,{classNameModifiers:["await"],onClick:()=>p(i.url),label:l.get("openApp")})),i.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof i.instructions?l.get(i.instructions):null===(s=i.instructions)||void 0===s?void 0:s.call(i)),i.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},i.endSlot()))}w.defaultProps={countdownTime:l,delay:s,throttleTime:r,throttleInterval:i,onError:()=>{},onComplete:()=>{},showCountdownTimer:!0,classNameModifiers:[],url:null};export{w as Await};
2
2
  //# sourceMappingURL=Await.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\n\nexport function Await(props: Readonly<AwaitComponentProps>) {\n const { i18n, loadingContext } = useCoreContext();\n useA11yReporter(props.awaitText);\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n const { amount } = useAmount();\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n if (expired) {\n return <AwaitFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <AwaitFinalState image=\"success\" message={i18n.get('creditCard.success')} />;\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n delay: DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n throttleTime: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS,\n throttleInterval: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n onError: () => {},\n onComplete: () => {},\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","useA11yReporter","awaitText","state","timerState","actions","timerActions","usePaymentStatusTimer","paymentData","clientKey","delay","throttleTime","throttleInterval","type","onError","onComplete","pollStatus","onActionHandled","completed","expired","loading","percentage","onTick","onTimeUp","amount","useAmount","useEffect","shouldRedirectAutomatically","url","redirectToApp","h","AwaitFinalState","image","message","get","div","className","brandLogo","img","src","alt","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps","DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_M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,EAAKoC,IAAIrC,EAAMqE,sBAAgBrE,EAAAA,EAAMqE,oBAANrE,IAAAA,OAAAA,EAAAA,EAAAA,KAAAA,IAIhFA,EAAMsE,SAAWrC,EAACK,MAAAA,CAAIC,UAAU,mCAAmCvC,EAAMsE,WAGtF,CAEAvE,EAAMwE,aAAe,CACjBR,cAAeS,EACf3D,MAAO4D,EACP3D,aAAc4D,EACd3D,iBAAkB4D,EAClB1D,QAAS,OACTC,WAAY,OACZuC,oBAAoB,EACpBP,mBAAoB,GACpBnB,IAAK"}
1
+ {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\n\nexport function Await(props: Readonly<AwaitComponentProps>) {\n const { i18n, loadingContext } = useCoreContext();\n useA11yReporter(props.awaitText);\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n const { amount } = useAmount();\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n if (expired) {\n return <AwaitFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <AwaitFinalState image=\"success\" message={i18n.get('creditCard.success')} />;\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.brandName ?? props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.brandName ?? props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n delay: DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n throttleTime: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS,\n throttleInterval: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n onError: () => {},\n onComplete: () => {},\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","useA11yReporter","awaitText","state","timerState","actions","timerActions","usePaymentStatusTimer","paymentData","clientKey","delay","throttleTime","throttleInterval","type","onError","onComplete","pollStatus","onActionHandled","completed","expired","loading","percentage","onTick","onTimeUp","amount","useAmount","useEffect","shouldRedirectAutomatically","url","redirectToApp","h","AwaitFinalState","image","message","get","div","className","brandLogo","img","src","alt","brandName","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps","DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN","DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS","DEFAUL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AAMsE,cACHrC,EAACK,MAAAA,CAAIC,UAAU,uCACoB,iBAAvBvC,EAAMsE,aAA4BrE,EAAKoC,IAAIrC,EAAMsE,sBAAgBtE,EAAAA,EAAMsE,oBAANtE,IAAAA,OAAAA,EAAAA,EAAAA,KAAAA,IAIhFA,EAAMuE,SAAWtC,EAACK,MAAAA,CAAIC,UAAU,mCAAmCvC,EAAMuE,WAGtF,CAEAxE,EAAMyE,aAAe,CACjBR,cAAeS,EACf5D,MAAO6D,EACP5D,aAAc6D,EACd5D,iBAAkB6D,EAClB3D,QAAS,OACTC,WAAY,OACZwC,oBAAoB,EACpBP,mBAAoB,GACpBpB,IAAK"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import r from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as o}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as c}from"../../../core/config.js";function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),o.forEach(function(e){u(t,e,r[e])})}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class d{buildElementProps(t){this.props=this.formatProps(p({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=p({},this.state,t)}get data(){var t,e;const r=this.state.order||this.props.order,n=this.formatData(),s=Boolean(a(null===(e=n.paymentMethod)||void 0===e?void 0:e.type)),u=this.core.modules.risk.data,d=null!==(t=this.core.modules.analytics.checkoutAttemptId)&&void 0!==t?t:o,m=s?c.NATIVE:c.GENERIC,l=i(d,u,m);return n.paymentMethod&&d&&(n.paymentMethod.checkoutAttemptId=d),n.paymentMethod&&l&&(n.paymentMethod.sdkData=l),h(p({},u&&{riskData:{clientData:u}},r&&{order:{orderData:r.orderData,pspReference:r.pspReference}},n),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=r,n(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),this}update(t){return this.props=this.formatProps(p({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,o){u(this,"_id",`${this.constructor.type}-${e()}`),u(this,"core",void 0),u(this,"props",void 0),u(this,"state",{}),u(this,"_component",void 0),u(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new r("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(o),this.handleKeyPress=this.handleKeyPress.bind(this)}}u(d,"defaultProps",{});export{d as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as c}from"../../../core/config.js";function u(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function p(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){u(t,e,o[e])})}return t}function h(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}class d{buildElementProps(t){this.props=this.formatProps(p({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state=p({},this.state,t)}get data(){var t,e;const o=this.state.order||this.props.order,n=this.formatData(),s=Boolean(a(null===(e=n.paymentMethod)||void 0===e?void 0:e.type)),u=this.core.modules.risk.data,d=null!==(t=this.core.modules.analytics.checkoutAttemptId)&&void 0!==t?t:r,m=s?c.NATIVE:c.GENERIC,l=i(d,u,m);return n.paymentMethod&&d&&(n.paymentMethod.checkoutAttemptId=d),n.paymentMethod&&l&&(n.paymentMethod.sdkData=l),h(p({},u&&{riskData:{clientData:u}},o&&{order:{orderData:o.orderData,pspReference:o.pspReference}},n),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps(p({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){u(this,"_id",`${this.constructor.type}-${e()}`),u(this,"core",void 0),u(this,"props",void 0),u(this,"state",{}),u(this,"_component",void 0),u(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}u(d,"defaultProps",{});export{d as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","_this_core_modules_analytics_checkoutAttemptId","componentData","order","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"owCAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAA,CACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,GAKmB,IAAAC,EAFyDC,EAFnF,MAAMC,EAAQhB,KAAKY,MAAMI,OAAShB,KAAKC,MAAMe,MACvCD,EAAgBf,KAAKK,aACrBY,EAAuCC,QAAQC,EAAyD,QAA3BJ,EAAAA,EAAcK,qBAAdL,IAAAA,OAAAA,EAAAA,EAA6BM,OAC1GC,EAAatB,KAAKuB,KAAKC,QAAQC,KAAKZ,KACpCa,EAAiE,QAA7CZ,EAAAd,KAAKuB,KAAKC,QAAQG,UAAUD,6BAA5BZ,EAAAA,EAAiDc,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARId,EAAcK,e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,KAAUgD,QAAqB,MAK3B,MAAMW,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC/D,KAAKI,YAAY,6DAIhEJ,KAAKuB,KAAOgC,EACZvD,KAAKF,kBAAkBG,GAEvBD,KAAKQ,eAAiBR,KAAKQ,eAAewD,KAAKhE,KACnD,EAhBAwD,EAVW3D,EAUeoE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","setState","newState","state","data","_this_core_modules_analytics_checkoutAttemptId","componentData","order","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"owCAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAA,CACX,CAEUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,aAAAA,CAAcC,GACpB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,GAKmB,IAAAC,EAFyDC,EAFnF,MAAMC,EAAQhB,KAAKY,MAAMI,OAAShB,KAAKC,MAAMe,MACvCD,EAAgBf,KAAKK,aACrBY,EAAuCC,QAAQC,EAAyD,QAA3BJ,EAAAA,EAAcK,qBAAdL,IAAAA,OAAAA,EAAAA,EAA6BM,OAC1GC,EAAatB,KAAKuB,KAAKC,QAAQC,KAAKZ,KACpCa,EAAiE,QAA7CZ,EAAAd,KAAKuB,KAAKC,QAAQG,UAAUD,6BAA5BZ,EAAAA,EAAiDc,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARId,EAAcK,eAAiBM,IAC/BX,EAAcK,cAAcM,kBAAoBA,GAGhDX,EAAcK,eAAiBa,IAC/BlB,EAAcK,cAAca,QAAUA,GAGnCE,OACCb,GAAc,CAAEc,SAAU,CAAEd,eAC5BN,GAAS,CAAEA,MAAO,CAAEqB,UAAWrB,EAA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KAAKI,YAAY,6DAIhEJ,KAAKuB,KAAOgC,EACZvD,KAAKF,kBAAkBG,GAEvBD,KAAKQ,cAAgBR,KAAKQ,cAAcwD,KAAKhE,KACjD,EAhBAwD,EAVW3D,EAUeoE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:i=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S,onKeyPress:L}=this.props,{completed:B}=this.state,{i18n:j}=o(),D=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=c?c:l,alt:"","aria-hidden":"true"}):"",M=[...i,..."primary"===f?[]:[f],...d?["inline"]:[],...B?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],P=a(["adyen-checkout__button",...M.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),j.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},D,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=k?k:u))},K=E[y]||E.default;return s?t("a",{className:P,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},K):t("button",{ref:g,id:e,className:P,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N,onKeyPress:L},K,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},j.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),i(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
1
+ import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";function o(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:o=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S}=this.props,{completed:L}=this.state,{i18n:B}=i(),j=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=c?c:l,alt:"","aria-hidden":"true"}):"",D=[...o,..."primary"===f?[]:[f],...d?["inline"]:[],...L?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],M=a(["adyen-checkout__button",...D.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),B.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},j,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=k?k:u))},w=E[y]||E.default;return s?t("a",{className:M,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},w):t("button",{ref:g,id:e,className:M,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N},w,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},B.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),o(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),o(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),o(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}o(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
2
2
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","_this_props_onClick","_this_props","call","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC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,MAAM4B,IAChBC,gBAAenD,EACfoD,QAAUC,IACFrD,GACAqD,EAAEC,mBAITP,GAMTnB,EAAC2B,SAAAA,CACGC,IAAK3C,EACLf,GAAIA,EACJgC,UAAWK,EACXsB,KAAK,SACLzD,SAAUA,EACVoD,QAAS/B,KAAK+B,QACdM,aAAYpD,EACZqD,kBAAiBpD,EACjBqD,mBAAkBpD,EAClBqD,gBAAepD,EACfqD,gBAAepD,EACfK,aAAcA,EACdC,aAAcA,EACdG,UAAWA,EACXF,QAASA,EACTC,OAAQA,EACRE,WAAYA,GAEX2B,EACW,YAAXpC,GAAmC,aAAXA,GAAyBU,KAAKC,MAAMyC,SAC7DnC,EAACa,OAAAA,CAAKuB,KAAK,SAASC,YAAU,SAASnC,UAAU,yCAC5CL,EAAKoB,IAAIxB,KAAK6C,oBAAoBvD,KAInD,mBAzJJwD,SAAAC,GAUIC,EAAAhD,KAAO+B,UAAWC,QAIViB,EAAAC,GAHJlB,EAAEC,iBAEGjC,KAAKC,MAAMtB,YACM,QAAlBsE,GAAAC,EAAAlD,KAAKC,OAAM8B,eAAX,IAAAkB,GAAAA,EAAAE,KAAAD,EAAqBlB,EAAG,CAAEoB,SAAUpD,KAAKoD,cAIjDJ,EAAAhD,KAAOoD,WAAW,CAACC,EAAQ,OACvBrD,KAAKsD,SAAS,CAAEpD,WAAW,IAC3BqD,WAAW,KACPvD,KAAKsD,SAAS,CAAEpD,WAAW,KAC5BmD,KAGPL,EAAAhD,KAAiB6C,sBAAuBvD,IACK,CACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/B0D,EADE1E,EACqBkF,eAAe,CAClClE,OAAQ,UACRC,QAAS,UACTZ,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR6C,OAAQ"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","_this_props_onClick","_this_props","call","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFvB,GAAwBD,EACpByB,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,WAAanB,QAAAA,EAAgCD,EAC7D6B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXlC,KACa,YAAZa,EAAwB,GAAK,CAACA,MAC9BR,EAAS,CAAC,UAAY,MACtBkB,EAAY,CAAC,aAAe,MACjB,YAAXX,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEuB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,EAAe,CACjBC,QACIZ,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAAStC,QAAAA,KAG/BuC,SACIhB,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAAStC,QAAAA,IACtBoB,EAAKoB,IAAI,0BAGlBC,QACIlB,EAACa,OAAAA,CAAKX,UAAU,mCACXH,EACDC,EAACa,OAAAA,CAAKX,UAAU,gCAAgCT,KAAKG,MAAMD,WAAaR,QAAAA,EA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EACR4C,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import{PREFIX as c}from"../Icon/constants.js";import i from"../../../core/Context/useImage.js";import{stopPropagationForActionKeys as l}from"./stopPropagationForActionKeys.js";function p(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function s(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}const a=a=>{var u,b,m;const{i18n:f}=r(),y=i(),j=t((e,{complete:t})=>{var o;n(a.text),t(),null===(o=a.onClick)||void 0===o||o.call(a,e)},[a.text,a.onClick]);return e(o,s(function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){p(e,t,o[t])})}return e}({},a),{variant:"action",onClick:j,onKeyPress:l,onKeyDown:l,icon:null!==(u=a.icon)&&void 0!==u?u:y({imageFolder:"components/"})(`${c}copy`),label:null!==(b=a.label)&&void 0!==b?b:f.get("button.copy"),onClickCompletedLabel:null!==(m=a.copiedLabel)&&void 0!==m?m:f.get("button.copied")}))};export{a as CopyButton};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import o from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import{PREFIX as c}from"../Icon/constants.js";import i from"../../../core/Context/useImage.js";import{stopPropagationForActionKeys as l}from"./stopPropagationForActionKeys.js";function p(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}const s=s=>{var u,b,m;const{i18n:f}=r(),j=i(),y=t((e,{complete:t})=>{var o;n(s.text),t(),null===(o=s.onClick)||void 0===o||o.call(s,e)},[s.text,s.onClick]);return e(o,a(function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){p(e,t,o[t])})}return e}({},s),{variant:"action",onClick:y,onKeyDown:l,icon:null!==(u=s.icon)&&void 0!==u?u:j({imageFolder:"components/"})(`${c}copy`),label:null!==(b=s.label)&&void 0!==b?b:f.get("button.copy"),onClickCompletedLabel:null!==(m=s.copiedLabel)&&void 0!==m?m:f.get("button.copied")}))};export{s as CopyButton};
2
2
  //# sourceMappingURL=CopyButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyButton.js","sources":["../../../../../src/components/internal/Button/CopyButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { PREFIX } from '../Icon/constants';\nimport useImage from '../../../core/Context/useImage';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\n\nexport interface CopyButtonProps extends Omit<ButtonProps, 'variant' | 'onClickCompletedLabel'> {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n copiedLabel?: string;\n onClick?: (e: h.JSX.TargetedMouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CopyButton = (props: Readonly<CopyButtonProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const onClick = useCallback(\n (e, { complete }) => {\n void copyToClipboard(props.text);\n complete();\n props.onClick?.(e);\n },\n [props.text, props.onClick]\n );\n\n return (\n <Button\n {...props}\n variant=\"action\"\n onClick={onClick}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n icon={props.icon ?? getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={props.label ?? i18n.get('button.copy')}\n onClickCompletedLabel={props.copiedLabel ?? i18n.get('button.copied')}\n />\n );\n};\n\nexport { CopyButton };\n"],"names":["CopyButton","props","i18n","useCoreContext","getImage","useImage","onClick","useCallback","e","complete","copyToClipboard","text","h","Button","variant","onKeyPress","stopPropagationForActionKeys","onKeyDown","icon","imageFolder","PREFIX","label","get","onClickCompletedLabel","copiedLabel"],"mappings":"w8BAmBA,MAAMA,EAAcC,IAqBFA,IAAAA,EACCA,EACgBA,EAtB/B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAUC,EACZ,CAACC,GAAKC,eAGFR,IAAAA,EAFKS,EAAgBT,EAAMU,MAC3BF,IACa,QAAbR,EAAAA,EAAMK,mBAANL,GAAAA,OAAAA,EAAgBO,IAEpB,CAACP,EAAMU,KAAMV,EAAMK,UAGvB,OACIM,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EACOZ,GAAAA,CACJa,QAAQ,SACRR,QAASA,EAETS,WAAYC,EACZC,UAAWD,EACXE,KAAgB,QAAVjB,EAAAA,EAAMiB,YAANjB,IAAAA,EAAAA,EAAcG,EAAS,CAAEe,YAAa,eAAxBf,CAAyC,GAAGgB,SAChEC,cAAOpB,EAAAA,EAAMoB,aAANpB,IAAAA,EAAAA,EAAeC,EAAKoB,IAAI,eAC/BC,8BAAuBtB,EAAAA,EAAMuB,uBAANvB,EAAAA,EAAqBC,EAAKoB,IAAI"}
1
+ {"version":3,"file":"CopyButton.js","sources":["../../../../../src/components/internal/Button/CopyButton.tsx"],"sourcesContent":["import { h, TargetedMouseEvent } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { PREFIX } from '../Icon/constants';\nimport useImage from '../../../core/Context/useImage';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\n\nexport interface CopyButtonProps extends Omit<ButtonProps, 'variant' | 'onClickCompletedLabel'> {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n copiedLabel?: string;\n onClick?: (e: TargetedMouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CopyButton = (props: Readonly<CopyButtonProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const onClick = useCallback(\n (e, { complete }) => {\n void copyToClipboard(props.text);\n complete();\n props.onClick?.(e);\n },\n [props.text, props.onClick]\n );\n\n return (\n <Button\n {...props}\n variant=\"action\"\n onClick={onClick}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyDown={stopPropagationForActionKeys}\n icon={props.icon ?? getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={props.label ?? i18n.get('button.copy')}\n onClickCompletedLabel={props.copiedLabel ?? i18n.get('button.copied')}\n />\n );\n};\n\nexport { CopyButton };\n"],"names":["CopyButton","props","i18n","useCoreContext","getImage","useImage","onClick","useCallback","e","complete","copyToClipboard","text","h","Button","variant","onKeyDown","stopPropagationForActionKeys","icon","imageFolder","PREFIX","label","get","onClickCompletedLabel","copiedLabel"],"mappings":"w8BAmBA,MAAMA,EAAcC,IAoBFA,IAAAA,EACCA,EACgBA,EArB/B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAUC,EACZ,CAACC,GAAKC,eAGFR,IAAAA,EAFKS,EAAgBT,EAAMU,MAC3BF,IACa,QAAbR,EAAAA,EAAMK,mBAANL,GAAAA,OAAAA,EAAgBO,IAEpB,CAACP,EAAMU,KAAMV,EAAMK,UAGvB,OACIM,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EACOZ,GAAAA,CACJa,QAAQ,SACRR,QAASA,EAETS,UAAWC,EACXC,KAAgB,QAAVhB,EAAAA,EAAMgB,YAANhB,IAAAA,EAAAA,EAAcG,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,GAAGe,SAChEC,cAAOnB,EAAAA,EAAMmB,aAANnB,IAAAA,EAAAA,EAAeC,EAAKmB,IAAI,eAC/BC,8BAAuBrB,EAAAA,EAAMsB,uBAANtB,EAAAA,EAAqBC,EAAKmB,IAAI"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../external/preact/dist/preact.js";import{useRef as e,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import r from"./Button.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as c}from"../../../utils/clipboard.js";import{SingletonTooltipProvider as i,useTooltip as s}from"../Tooltip/SingletonTooltipProvider.js";import{stopPropagationForActionKeys as a}from"./stopPropagationForActionKeys.js";function p(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function l(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}const u=i=>{var u;const{i18n:b}=n(),f=e(null),{showTooltip:y,hideTooltip:O}=s(),m=o(()=>{c(i.text),y({anchorRef:f,text:b.get("button.copied")})},[i.text,b,y]),j=o(t=>{a(t),"Escape"!==t.key&&"Escape"!==t.code||(t.stopPropagation(),O())},[O]),g=o(()=>{y({anchorRef:f,text:b.get("button.copy")})},[f,b,y]);return t(r,l(function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){p(t,e,o[e])})}return t}({},i),{variant:"iconOnly",buttonRef:f,ariaLabel:null!==(u=i.ariaLabel)&&void 0!==u?u:b.get("button.copy"),onMouseEnter:g,onMouseLeave:O,onFocus:g,onBlur:O,onClick:m,onKeyPress:a,onKeyDown:j}),t("svg",{className:"adyen-checkout__button--iconOnly__icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{d:"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z"})))},b=e=>t(i,null,t(u,e));export{b as CopyIconButton};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{useRef as e,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import r from"./Button.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as c}from"../../../utils/clipboard.js";import{SingletonTooltipProvider as i,useTooltip as a}from"../Tooltip/SingletonTooltipProvider.js";import{stopPropagationForActionKeys as s}from"./stopPropagationForActionKeys.js";function p(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function l(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}const u=i=>{var u;const{i18n:b}=n(),f=e(null),{showTooltip:y,hideTooltip:O}=a(),m=o(()=>{c(i.text),y({anchorRef:f,text:b.get("button.copied")})},[i.text,b,y]),j=o(t=>{s(t),"Escape"!==t.key&&"Escape"!==t.code||(t.stopPropagation(),O())},[O]),g=o(()=>{y({anchorRef:f,text:b.get("button.copy")})},[f,b,y]);return t(r,l(function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){p(t,e,o[e])})}return t}({},i),{variant:"iconOnly",buttonRef:f,ariaLabel:null!==(u=i.ariaLabel)&&void 0!==u?u:b.get("button.copy"),onMouseEnter:g,onMouseLeave:O,onFocus:g,onBlur:O,onClick:m,onKeyDown:j}),t("svg",{className:"adyen-checkout__button--iconOnly__icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{d:"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z"})))},b=e=>t(i,null,t(u,e));export{b as CopyIconButton};
2
2
  //# sourceMappingURL=CopyIconButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyIconButton.js","sources":["../../../../../src/components/internal/Button/CopyIconButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useRef } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { SingletonTooltipProvider, useTooltip } from '../Tooltip/SingletonTooltipProvider';\nimport './CopyIconButton.scss';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\n\nexport interface CopyIconButtonProps extends ButtonProps {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n}\n\nconst CopyIconButton = (props: Readonly<CopyIconButtonProps>) => {\n const { i18n } = useCoreContext();\n const anchorRef = useRef<HTMLButtonElement>(null);\n const { showTooltip, hideTooltip } = useTooltip();\n\n const onClick = useCallback(() => {\n void copyToClipboard(props.text);\n showTooltip({ anchorRef, text: i18n.get('button.copied') });\n }, [props.text, i18n, showTooltip]);\n\n // We need it because onKeyPress does not trigger for Esc key\n const onKeyDown = useCallback(\n (event: KeyboardEvent) => {\n stopPropagationForActionKeys(event);\n\n if (event.key === 'Escape' || event.code === 'Escape') {\n event.stopPropagation();\n hideTooltip();\n }\n },\n [hideTooltip]\n );\n\n const handleShowTooltip = useCallback(() => {\n showTooltip({ anchorRef, text: i18n.get('button.copy') });\n }, [anchorRef, i18n, showTooltip]);\n\n return (\n <Button\n {...props}\n variant=\"iconOnly\"\n buttonRef={anchorRef}\n ariaLabel={props.ariaLabel ?? i18n.get('button.copy')}\n onMouseEnter={handleShowTooltip}\n onMouseLeave={hideTooltip}\n onFocus={handleShowTooltip}\n onBlur={hideTooltip}\n onClick={onClick}\n // It's ok to have both, browsers will fire only one click event for enter/space key pressed.\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={onKeyDown}\n >\n <svg\n className=\"adyen-checkout__button--iconOnly__icon\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path d=\"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z\" />\n </svg>\n </Button>\n );\n};\n\nconst withTooltip = (props: Readonly<CopyIconButtonProps>) => {\n return (\n <SingletonTooltipProvider>\n <CopyIconButton {...props} />\n </SingletonTooltipProvider>\n );\n};\n\nexport { withTooltip as CopyIconButton };\n"],"names":["CopyIconButton","props","i18n","useCoreContext","anchorRef","useRef","showTooltip","hideTooltip","useTooltip","onClick","useCallback","copyToClipboard","text","get","onKeyDown","event","stopPropagationForActionKeys","key","code","stopPropagation","handleShowTooltip","h","Button","variant","buttonRef","ariaLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyPress","svg","className","xmlns","width","height","viewBox","fill","path","d","withTooltip","SingletonTooltipProvider"],"mappings":"u9BAiBA,MAAMA,EAAkBC,IAgCDA,IAAAA,EA/BnB,MAAMC,KAAEA,GAASC,IACXC,EAAYC,EAA0B,OACtCC,YAAEA,EAAWC,YAAEA,GAAgBC,IAE/BC,EAAUC,EAAY,KACnBC,EAAgBV,EAAMW,MAC3BN,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,oBACzC,CAACZ,EAAMW,KAAMV,EAAMI,IAGhBQ,EAAYJ,EACbK,IACGC,EAA6BD,GAEX,WAAdA,EAAME,KAAmC,WAAfF,EAAMG,OAChCH,EAAMI,kBACNZ,MAGR,CAACA,IAGCa,EAAoBV,EAAY,KAClCJ,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,kBACzC,CAACT,EAAWF,EAAMI,IAErB,OACIe,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EACOrB,GAAAA,CACJsB,QAAQ,WACRC,UAAWpB,EACXqB,kBAAWxB,EAAAA,EAAMwB,iBAANxB,IAAAA,EAAAA,EAAmBC,EAAKW,IAAI,eACvCa,aAAcN,EACdO,aAAcpB,EACdqB,QAASR,EACTS,OAAQtB,EACRE,QAASA,EAETqB,WAAYd,EACZF,UAAWA,IAEXO,EAACU,MAAAA,CACGC,UAAU,yCACVC,MAAM,6BACNC,MAAM,KACNC,OAAO,KACPC,QAAQ,YACRC,KAAK,QAELhB,EAACiB,OAAAA,CAAKC,EAAE,snBAMlBC,EAAevC,GAEboB,EAACoB,EAAAA,KACGpB,EAACrB,EAAmBC"}
1
+ {"version":3,"file":"CopyIconButton.js","sources":["../../../../../src/components/internal/Button/CopyIconButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useRef } from 'preact/hooks';\nimport Button from './Button';\nimport { ButtonProps } from './types';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport copyToClipboard from '../../../utils/clipboard';\nimport { SingletonTooltipProvider, useTooltip } from '../Tooltip/SingletonTooltipProvider';\nimport { stopPropagationForActionKeys } from './stopPropagationForActionKeys';\nimport './CopyIconButton.scss';\n\nexport interface CopyIconButtonProps extends ButtonProps {\n /**\n * String that will get copied to the clipboard\n */\n text: string;\n}\n\nconst CopyIconButton = (props: Readonly<CopyIconButtonProps>) => {\n const { i18n } = useCoreContext();\n const anchorRef = useRef<HTMLButtonElement>(null);\n const { showTooltip, hideTooltip } = useTooltip();\n\n const onClick = useCallback(() => {\n void copyToClipboard(props.text);\n showTooltip({ anchorRef, text: i18n.get('button.copied') });\n }, [props.text, i18n, showTooltip]);\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent) => {\n stopPropagationForActionKeys(event);\n\n if (event.key === 'Escape' || event.code === 'Escape') {\n event.stopPropagation();\n hideTooltip();\n }\n },\n [hideTooltip]\n );\n\n const handleShowTooltip = useCallback(() => {\n showTooltip({ anchorRef, text: i18n.get('button.copy') });\n }, [anchorRef, i18n, showTooltip]);\n\n return (\n <Button\n {...props}\n variant=\"iconOnly\"\n buttonRef={anchorRef}\n ariaLabel={props.ariaLabel ?? i18n.get('button.copy')}\n onMouseEnter={handleShowTooltip}\n onMouseLeave={hideTooltip}\n onFocus={handleShowTooltip}\n onBlur={hideTooltip}\n onClick={onClick}\n onKeyDown={onKeyDown}\n >\n <svg\n className=\"adyen-checkout__button--iconOnly__icon\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path d=\"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z\" />\n </svg>\n </Button>\n );\n};\n\nconst withTooltip = (props: Readonly<CopyIconButtonProps>) => {\n return (\n <SingletonTooltipProvider>\n <CopyIconButton {...props} />\n </SingletonTooltipProvider>\n );\n};\n\nexport { withTooltip as CopyIconButton };\n"],"names":["CopyIconButton","props","i18n","useCoreContext","anchorRef","useRef","showTooltip","hideTooltip","useTooltip","onClick","useCallback","copyToClipboard","text","get","onKeyDown","event","stopPropagationForActionKeys","key","code","stopPropagation","handleShowTooltip","h","Button","variant","buttonRef","ariaLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","svg","className","xmlns","width","height","viewBox","fill","path","d","withTooltip","SingletonTooltipProvider"],"mappings":"u9BAiBA,MAAMA,EAAkBC,IA+BDA,IAAAA,EA9BnB,MAAMC,KAAEA,GAASC,IACXC,EAAYC,EAA0B,OACtCC,YAAEA,EAAWC,YAAEA,GAAgBC,IAE/BC,EAAUC,EAAY,KACnBC,EAAgBV,EAAMW,MAC3BN,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,oBACzC,CAACZ,EAAMW,KAAMV,EAAMI,IAEhBQ,EAAYJ,EACbK,IACGC,EAA6BD,GAEX,WAAdA,EAAME,KAAmC,WAAfF,EAAMG,OAChCH,EAAMI,kBACNZ,MAGR,CAACA,IAGCa,EAAoBV,EAAY,KAClCJ,EAAY,CAAEF,YAAWQ,KAAMV,EAAKW,IAAI,kBACzC,CAACT,EAAWF,EAAMI,IAErB,OACIe,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EACOrB,GAAAA,CACJsB,QAAQ,WACRC,UAAWpB,EACXqB,kBAAWxB,EAAAA,EAAMwB,iBAANxB,IAAAA,EAAAA,EAAmBC,EAAKW,IAAI,eACvCa,aAAcN,EACdO,aAAcpB,EACdqB,QAASR,EACTS,OAAQtB,EACRE,QAASA,EACTK,UAAWA,IAEXO,EAACS,MAAAA,CACGC,UAAU,yCACVC,MAAM,6BACNC,MAAM,KACNC,OAAO,KACPC,QAAQ,YACRC,KAAK,QAELf,EAACgB,OAAAA,CAAKC,EAAE,snBAMlBC,EAAetC,GAEboB,EAACmB,EAAAA,KACGnB,EAACrB,EAAmBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect } from 'preact/hooks';\nimport { CtpState } from './services/ClickToPayService';\nimport useClickToPayContext from './context/useClickToPayContext';\nimport CtPOneTimePassword from './components/CtPOneTimePassword';\nimport CtPCards from './components/CtPCards';\nimport CtPSection from './components/CtPSection';\nimport CtPLoader from './components/CtPLoader';\nimport CtPLogin from './components/CtPLogin';\nimport SrciError from './services/sdks/SrciError';\n\ntype ClickToPayComponentProps = {\n onDisplayCardComponent?(): void;\n};\n\nconst ClickToPayComponent = ({ onDisplayCardComponent }: Readonly<ClickToPayComponentProps>): h.JSX.Element => {\n const { ctpState, onReady, startIdentityValidation, logoutShopper } = useClickToPayContext();\n\n useEffect(() => {\n if ([CtpState.OneTimePassword, CtpState.Login, CtpState.Ready].includes(ctpState)) {\n onReady();\n }\n }, [ctpState, onReady]);\n\n useEffect(() => {\n async function sendOneTimePassword() {\n try {\n await startIdentityValidation();\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Identity Validation error: ${error.toString()}`);\n await logoutShopper();\n }\n }\n if (ctpState === CtpState.ShopperIdentified) {\n void sendOneTimePassword();\n }\n }, [ctpState]);\n\n /**\n * We capture the ENTER keypress within the ClickToPay component because we do not want to propagate the event up to the UIElement\n * UIElement would perform the payment flow (by calling .submit), which is not relevant/supported by Click to Pay\n */\n const handleEnterKeyPress = useCallback((event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n event.stopPropagation(); // Prevent global BaseElement keypress event to be triggered\n }\n }, []);\n\n if (ctpState === CtpState.NotAvailable) {\n return null;\n }\n\n return (\n <CtPSection onEnterKeyPress={handleEnterKeyPress}>\n {[CtpState.Loading, CtpState.ShopperIdentified].includes(ctpState) && <CtPLoader />}\n {ctpState === CtpState.OneTimePassword && <CtPOneTimePassword onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Ready && <CtPCards onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Login && <CtPLogin />}\n </CtPSection>\n );\n};\n\nexport default ClickToPayComponent;\n"],"names":["ClickToPayComponent","onDisplayCardComponent","ctpState","onReady","startIdentityValidation","logoutShopper","useClickToPayContext","useEffect","CtpState","OneTimePassword","Login","Ready","includes","ShopperIdentified","async","error","SrciError","console","warn","toString","sendOneTimePassword","handleEnterKeyPress","useCallback","event","key","preventDefault","stopPropagation","NotAvailable","h","CtPSection","onEnterKeyPress","Loading","CtPLoader","CtPOneTimePassword","CtPCards","CtPLogin"],"mappings":"ykBAeA,MAAMA,EAAsB,EAAGC,6BAC3B,MAAMC,SAAEA,EAAQC,QAAEA,EAAOC,wBAAEA,EAAuBC,cAAEA,GAAkBC,IAEtEC,EAAU,KACF,CAACC,EAASC,gBAAiBD,EAASE,MAAOF,EAASG,OAAOC,SAASV,IACpEC,KAEL,CAACD,EAAUC,IAEdI,EAAU,KASFL,IAAaM,EAASK,mBAR1BC,iBACI,UACUV,GACV,CAAE,MAAOW,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,oCAAoCH,EAAMI,oBACjFd,GACV,CACJ,CAESe,IAEV,CAAClB,IAMJ,MAAMmB,EAAsBC,EAAaC,IACnB,UAAdA,EAAMC,MACND,EAAME,iBACNF,EAAMG,oBAEX,IAEH,OAAIxB,IAAaM,EAASmB,aACf,KAIPC,EAACC,EAAAA,CAAWC,gBAAiBT,GACxB,CAACb,EAASuB,QAASvB,EAASK,mBAAmBD,SAASV,IAAa0B,EAACI,QACtE9B,IAAaM,EAASC,iBAAmBmB,EAACK,EAAAA,CAAmBhC,uBAAwBA,IACrFC,IAAaM,EAASG,OAASiB,EAACM,EAAAA,CAASjC,uBAAwBA,IACjEC,IAAaM,EAASE,OAASkB,EAACO,EAAAA"}
1
+ {"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h, TargetedKeyboardEvent } from 'preact';\nimport { useCallback, useEffect } from 'preact/hooks';\nimport { CtpState } from './services/ClickToPayService';\nimport useClickToPayContext from './context/useClickToPayContext';\nimport CtPOneTimePassword from './components/CtPOneTimePassword';\nimport CtPCards from './components/CtPCards';\nimport CtPSection from './components/CtPSection';\nimport CtPLoader from './components/CtPLoader';\nimport CtPLogin from './components/CtPLogin';\nimport SrciError from './services/sdks/SrciError';\n\ntype ClickToPayComponentProps = {\n onDisplayCardComponent?(): void;\n};\n\nconst ClickToPayComponent = ({ onDisplayCardComponent }: Readonly<ClickToPayComponentProps>): h.JSX.Element => {\n const { ctpState, onReady, startIdentityValidation, logoutShopper } = useClickToPayContext();\n\n useEffect(() => {\n if ([CtpState.OneTimePassword, CtpState.Login, CtpState.Ready].includes(ctpState)) {\n onReady();\n }\n }, [ctpState, onReady]);\n\n useEffect(() => {\n async function sendOneTimePassword() {\n try {\n await startIdentityValidation();\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Identity Validation error: ${error.toString()}`);\n await logoutShopper();\n }\n }\n if (ctpState === CtpState.ShopperIdentified) {\n void sendOneTimePassword();\n }\n }, [ctpState]);\n\n /**\n * We capture the ENTER keydown within the ClickToPay component because we do not want to propagate the event up to the UIElement\n * UIElement would perform the payment flow (by calling .submit), which is not relevant/supported by Click to Pay\n */\n const handleEnterKeyPress = useCallback((event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n event.stopPropagation(); // Prevent global BaseElement keydown event to be triggered\n }\n }, []);\n\n if (ctpState === CtpState.NotAvailable) {\n return null;\n }\n\n return (\n <CtPSection onEnterKeyPress={handleEnterKeyPress}>\n {[CtpState.Loading, CtpState.ShopperIdentified].includes(ctpState) && <CtPLoader />}\n {ctpState === CtpState.OneTimePassword && <CtPOneTimePassword onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Ready && <CtPCards onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Login && <CtPLogin />}\n </CtPSection>\n );\n};\n\nexport default ClickToPayComponent;\n"],"names":["ClickToPayComponent","onDisplayCardComponent","ctpState","onReady","startIdentityValidation","logoutShopper","useClickToPayContext","useEffect","CtpState","OneTimePassword","Login","Ready","includes","ShopperIdentified","async","error","SrciError","console","warn","toString","sendOneTimePassword","handleEnterKeyPress","useCallback","event","key","preventDefault","stopPropagation","NotAvailable","h","CtPSection","onEnterKeyPress","Loading","CtPLoader","CtPOneTimePassword","CtPCards","CtPLogin"],"mappings":"ykBAeA,MAAMA,EAAsB,EAAGC,6BAC3B,MAAMC,SAAEA,EAAQC,QAAEA,EAAOC,wBAAEA,EAAuBC,cAAEA,GAAkBC,IAEtEC,EAAU,KACF,CAACC,EAASC,gBAAiBD,EAASE,MAAOF,EAASG,OAAOC,SAASV,IACpEC,KAEL,CAACD,EAAUC,IAEdI,EAAU,KASFL,IAAaM,EAASK,mBAR1BC,iBACI,UACUV,GACV,CAAE,MAAOW,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,oCAAoCH,EAAMI,oBACjFd,GACV,CACJ,CAESe,IAEV,CAAClB,IAMJ,MAAMmB,EAAsBC,EAAaC,IACnB,UAAdA,EAAMC,MACND,EAAME,iBACNF,EAAMG,oBAEX,IAEH,OAAIxB,IAAaM,EAASmB,aACf,KAIPC,EAACC,EAAAA,CAAWC,gBAAiBT,GACxB,CAACb,EAASuB,QAASvB,EAASK,mBAAmBD,SAASV,IAAa0B,EAACI,QACtE9B,IAAaM,EAASC,iBAAmBmB,EAACK,EAAAA,CAAmBhC,uBAAwBA,IACrFC,IAAaM,EAASG,OAASiB,EAACM,EAAAA,CAASjC,uBAAwBA,IACjEC,IAAaM,EAASE,OAASkB,EAACO,EAAAA"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const m=m=>{const{i18n:d}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&m.errorMessage&&l(c.current,"shopperLogin")},[m.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,m.onSetInputHandlers(j.current)},[E,m.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);return t(()=>{m.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:d.get("ctp.login.inputLabel"),errorMessage:I?m.errorMessage||F.shopperLogin&&d.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:m.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyPress:M,autocomplete:"email"})))};export{m as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const m=m=>{const{i18n:d}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&m.errorMessage&&l(c.current,"shopperLogin")},[m.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,m.onSetInputHandlers(j.current)},[E,m.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);return t(()=>{m.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:d.get("ctp.login.inputLabel"),errorMessage:I?m.errorMessage||F.shopperLogin&&d.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:m.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyDown:M,autocomplete:"email"})))};export{m as default};
2
2
  //# sourceMappingURL=CtPLoginInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || (errors.shopperLogin && i18n.get(errors.shopperLogin.errorMessage)) : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n autocomplete={'email'}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","autocomplete"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,IAEXC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAwC,CACjHC,OAHe,CAAC,gBAIhBC,MAAOC,EACPC,WAAYZ,IAEVa,EAAwBZ,EAA8B,CAAEa,cAAe,KAAMC,WAAY,QACxFC,EAAmBC,GAAwBC,GAAkB,GAE9DJ,EAAgBK,EAAY,KAC9BF,GAAqB,GACrBb,KACD,CAACA,IAEJgB,EAAU,KACFpB,EAAaqB,SAAWxB,EAAMyB,cAC9BC,EAAgBvB,EAAaqB,QAAS,iBAE3C,CAACxB,EAAMyB,eAEVF,EAAU,KACFjB,EAAKqB,cAAcP,GAAqB,IAC7C,CAACd,EAAKqB,eAETJ,EAAU,KACNP,EAAsBQ,QAAQP,cAAgBA,EAC9CjB,EAAM4B,mBAAmBZ,EAAsBQ,UAChD,CAACP,EAAejB,EAAM4B,qBAEzB,MAAMC,EAAmBP,EACpBQ,IACqB,UAAdA,EAAMC,KACD/B,EAAMgC,gBAGnB,CAAChC,EAAMgC,eAOX,OAJAT,EAAU,KACNvB,EAAMiC,SAAS,CAAE3B,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbyB,EAACC,MAAAA,CAAIC,IAAKjC,GACN+B,EAACG,EAAAA,CACGC,KAAK,eACLC,MAAOtC,EAAKuC,IAAI,wBAChBf,aAAcN,EAAoBnB,EAAMyB,cAAiBhB,EAAOkB,cAAgB1B,EAAKuC,IAAI/B,EAAOkB,aAAaF,cAAiB,KAC9HgB,mBAAoB,CAAC,gBACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOxC,EAAKqB,aACZoB,SAAU/C,EAAM+C,SAChBC,QAAS3C,EAAgB,eAAgB,SACzC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB,EACZsB,aAAc"}
1
+ {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h, TargetedKeyboardEvent } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyDown = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || (errors.shopperLogin && i18n.get(errors.shopperLogin.errorMessage)) : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyDown={handleOnKeyDown}\n autocomplete={'email'}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyDown","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyDown","autocomplete"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAA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Ac"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as u}from"../../../../../../utils/setFocus.js";import c from"../../../../FormFields/Field/Field.js";import d from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&u(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(c,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(d,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e},autocomplete:"off"})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as u}from"../../../../../../utils/setFocus.js";import c from"../../../../FormFields/Field/Field.js";import d from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:y}=p({schema:["otp"],rules:a,formHolder:h}),I=t({validateInput:null}),P=t(null),[R,w]=r(!1),L=o(()=>{w(!0),k()},[k]);s(()=>{b.otp&&w(!0)},[b.otp]),s(()=>{!j&&P.current&&P.current.focus()},[P.current,j]),s(()=>{h.current&&f.errorMessage&&u(h.current,"otp")},[f.errorMessage]),s(()=>{I.current.validateInput=L,f.onSetInputHandlers(I.current)},[L,f.onSetInputHandlers]);const V=o(()=>{y("otp",""),F(null),j||P.current.focus(),f.onResendCode()},[f.onResendCode,P.current,j]),_=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(c,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(d,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyDown:H,setRef:e=>{P.current=e},autocomplete:"off"})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:_,onResendCode:V})))};export{f as default};
2
2
  //# sourceMappingURL=CtPOneTimePasswordInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n autocomplete={'off'}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","autocomplete","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAAkD,CACpIC,OAJe,CAAC,OAKhBC,MAAOC,EACPC,WAAYb,IAEVc,EAAsBb,EAAwC,CAAEc,cAAe,OAC/EC,EAAWf,EAAyB,OACnCgB,EAAgBC,GAAsBnB,GAAkB,GAEzDgB,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDzB,GAAuBqB,EAASM,SACjCN,EAASM,QAAQC,SAEtB,CAACP,EAASM,QAAS3B,IAEtByB,EAAU,KACFpB,EAAasB,SAAW/B,EAAMiC,cAC9BC,EAAgBzB,EAAasB,QAAS,QAE3C,CAAC/B,EAAMiC,eAEVJ,EAAU,KACNN,EAAoBQ,QAAQP,cAAgBA,EAC5CxB,EAAMmC,mBAAmBZ,EAAoBQ,UAC9C,CAACP,EAAexB,EAAMmC,qBAEzB,MAAMC,EAAoBR,EAAY,KAClCX,EAAQ,MAAO,IACfV,EAAkB,MACbH,GACDqB,EAASM,QAAQC,QAErBhC,EAAMqC,gBACP,CAACrC,EAAMqC,aAAcZ,EAASM,QAAS3B,IAEpCkC,EAAyBV,EAC1BW,IACG,MAAMC,EAAUvC,EAAKwC,IAAI,cAAcF,KACnCC,GAASjC,EAAkBiC,IAEnC,CAACvC,IAGCyC,EAAmBd,EACpBe,IACqB,UAAdA,EAAMC,KACD5C,EAAM6C,gBAGnB,CAAC7C,EAAM6C,eAGXhB,EAAU,KACN7B,EAAM8C,SAAS,CAAElC,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAEjB,MAAMgC,EAAqBnB,EAAY,IAC9BF,EAEEpB,GAAkBN,EAAMiC,cAAgBe,EAAgB/C,EAAMc,EAAOe,IAAK7B,EAAKwC,IAAI,uBAF9D,KAG7B,CAACf,EAAgBpB,EAAgBN,EAAMiC,aAAclB,EAAOe,IAAK7B,IAEpE,OACIgD,EAACC,MAAAA,CAAIC,IAAK1C,EAAc2C,UAAW,yCAC/BH,EAACI,EAAAA,CACGC,KAAK,kBACLC,MAAOtD,EAAKwC,IAAI,sBAChBR,aAAcc,IACdS,mBAAoB,CAAC,OACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGJ,KAAM,MACNK,YAAa,MACbC,YAAY,EACZC,MAAOjD,EAAKkB,IACZgC,SAAU9D,EAAM8D,SAChBC,QAASpD,EAAgB,MAAO,SAChCqD,OAAQrD,EAAgB,MAAO,QAC/BsD,WAAYvB,EACZwB,OAASf,IACL1B,EAASM,QAAUoB,GAEvBgB,aAAc,SAGtBlB,EAACC,MAAAA,CAAIE,UAAW,+CACZH,EAACmB,EAAAA,CAAiBN,SAAU9D,EAAMqE,gBAAiBC,QAAShC,EAAwBD,aAAcD"}
1
+ {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h, TargetedKeyboardEvent } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyDown = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyDown={handleOnKeyDown}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n autocomplete={'off'}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyDown","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyDown","setRef","autocomplete","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAAkD,CACpIC,OAJe,CAAC,OAKhBC,MAAOC,EACPC,WAAYb,IAEVc,EAAsBb,EAAwC,CAAEc,cAAe,OAC/EC,EAAWf,EAAyB,OACnCgB,EAAgBC,GAAsBnB,GAAkB,GAEzDgB,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDzB,GAAuBqB,EAASM,SACjCN,EAASM,QAAQC,SAEtB,CAACP,EAASM,QAAS3B,IAEtByB,EAAU,KACFpB,EAAasB,SAAW/B,EAAMiC,cAC9BC,EAAg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B,EAAAA,CAAiBN,SAAU9D,EAAMqE,gBAAiBC,QAAShC,EAAwBD,aAAcD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import n from"./CtPLogoutLink.js";import{CtPBrand as c}from"../CtPBrand/CtPBrand.js";import a from"../../context/useClickToPayContext.js";const o=({children:o,onEnterKeyPress:s})=>{const{isStandaloneComponent:r}=a();return e("div",{className:t("adyen-checkout-ctp__section",{"adyen-checkout-ctp__section--standalone":r}),onKeyPress:s},e("div",{className:"adyen-checkout-ctp__section-brand"},e(c,null),e(n,null)),o)};o.Title=({endAdornment:t,children:n})=>e("div",{className:"adyen-checkout-ctp__section-header"},e("h1",{className:"adyen-checkout-ctp__section-header-title"},n),t&&e("span",{className:"adyen-checkout-ctp__section-header-adornment"},t)),o.Text=({children:t})=>e("p",{className:"adyen-checkout-ctp__section-text"},t);export{o as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import n from"./CtPLogoutLink.js";import{CtPBrand as c}from"../CtPBrand/CtPBrand.js";import o from"../../context/useClickToPayContext.js";const a=({children:a,onEnterKeyPress:s})=>{const{isStandaloneComponent:r}=o();return e("div",{className:t("adyen-checkout-ctp__section",{"adyen-checkout-ctp__section--standalone":r}),onKeyDown:s},e("div",{className:"adyen-checkout-ctp__section-brand"},e(c,null),e(n,null)),a)};a.Title=({endAdornment:t,children:n})=>e("div",{className:"adyen-checkout-ctp__section-header"},e("h1",{className:"adyen-checkout-ctp__section-header-title"},n),t&&e("span",{className:"adyen-checkout-ctp__section-header-adornment"},t)),a.Text=({children:t})=>e("p",{className:"adyen-checkout-ctp__section-text"},t);export{a as default};
2
2
  //# sourceMappingURL=CtPSection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classnames from 'classnames';\nimport CtPLogoutLink from './CtPLogoutLink';\nimport { CtPBrand } from '../CtPBrand';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport './CtPSection.scss';\n\ninterface CtPSectionProps {\n onEnterKeyPress: (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => void;\n children?: h.JSX.Element[];\n}\n\nconst CtPSection = ({ children, onEnterKeyPress }: Readonly<CtPSectionProps>): h.JSX.Element => {\n const { isStandaloneComponent } = useClickToPayContext();\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n className={classnames('adyen-checkout-ctp__section', { 'adyen-checkout-ctp__section--standalone': isStandaloneComponent })}\n onKeyPress={onEnterKeyPress}\n >\n <div className=\"adyen-checkout-ctp__section-brand\">\n <CtPBrand />\n <CtPLogoutLink />\n </div>\n\n {children}\n </div>\n );\n};\n\nconst Title = ({ endAdornment, children }: Readonly<{ endAdornment?; children }>) => (\n <div className=\"adyen-checkout-ctp__section-header\">\n <h1 className=\"adyen-checkout-ctp__section-header-title\">{children}</h1>\n {endAdornment && <span className=\"adyen-checkout-ctp__section-header-adornment\">{endAdornment}</span>}\n </div>\n);\nconst Text = ({ children }: Readonly<{ children }>) => <p className=\"adyen-checkout-ctp__section-text\">{children}</p>;\n\nCtPSection.Title = Title;\nCtPSection.Text = Text;\n\nexport default CtPSection;\n"],"names":["CtPSection","children","onEnterKeyPress","isStandaloneComponent","useClickToPayContext","h","div","className","classnames","onKeyPress","CtPBrand","CtPLogoutLink","Title","endAdornment","h1","span","Text","p"],"mappings":"wQAYA,MAAMA,EAAa,EAAGC,WAAUC,sBAC5B,MAAMC,sBAAEA,GAA0BC,IAElC,OAEIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,8BAA+B,CAAE,0CAA2CL,IAClGM,WAAYP,GAEZG,EAACC,MAAAA,CAAIC,UAAU,qCACXF,EAACK,EAAAA,MACDL,EAACM,EAAAA,OAGJV,IAabD,EAAWY,MARG,EAAGC,eAAcZ,cAC3BI,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACS,KAAAA,CAAGP,UAAU,4CAA4CN,GACzDY,GAAgBR,EAACU,OAAAA,CAAKR,UAAU,gDAAgDM,IAMzFb,EAAWgB,KAHE,EAAGf,cAAuCI,EAACY,IAAAA,CAAEV,UAAU,oCAAoCN"}
1
+ {"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h, TargetedKeyboardEvent } from 'preact';\nimport classnames from 'classnames';\nimport CtPLogoutLink from './CtPLogoutLink';\nimport { CtPBrand } from '../CtPBrand';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport './CtPSection.scss';\n\ninterface CtPSectionProps {\n onEnterKeyPress: (event: TargetedKeyboardEvent<HTMLInputElement>) => void;\n children?: h.JSX.Element[];\n}\n\nconst CtPSection = ({ children, onEnterKeyPress }: Readonly<CtPSectionProps>): h.JSX.Element => {\n const { isStandaloneComponent } = useClickToPayContext();\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n className={classnames('adyen-checkout-ctp__section', { 'adyen-checkout-ctp__section--standalone': isStandaloneComponent })}\n onKeyDown={onEnterKeyPress}\n >\n <div className=\"adyen-checkout-ctp__section-brand\">\n <CtPBrand />\n <CtPLogoutLink />\n </div>\n\n {children}\n </div>\n );\n};\n\nconst Title = ({ endAdornment, children }: Readonly<{ endAdornment?; children }>) => (\n <div className=\"adyen-checkout-ctp__section-header\">\n <h1 className=\"adyen-checkout-ctp__section-header-title\">{children}</h1>\n {endAdornment && <span className=\"adyen-checkout-ctp__section-header-adornment\">{endAdornment}</span>}\n </div>\n);\nconst Text = ({ children }: Readonly<{ children }>) => <p className=\"adyen-checkout-ctp__section-text\">{children}</p>;\n\nCtPSection.Title = Title;\nCtPSection.Text = Text;\n\nexport default CtPSection;\n"],"names":["CtPSection","children","onEnterKeyPress","isStandaloneComponent","useClickToPayContext","h","div","className","classnames","onKeyDown","CtPBrand","CtPLogoutLink","Title","endAdornment","h1","span","Text","p"],"mappings":"wQAYA,MAAMA,EAAa,EAAGC,WAAUC,sBAC5B,MAAMC,sBAAEA,GAA0BC,IAElC,OAEIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,8BAA+B,CAAE,0CAA2CL,IAClGM,UAAWP,GAEXG,EAACC,MAAAA,CAAIC,UAAU,qCACXF,EAACK,EAAAA,MACDL,EAACM,EAAAA,OAGJV,IAabD,EAAWY,MARG,EAAGC,eAAcZ,cAC3BI,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACS,KAAAA,CAAGP,UAAU,4CAA4CN,GACzDY,GAAgBR,EAACU,OAAAA,CAAKR,UAAU,gDAAgDM,IAMzFb,EAAWgB,KAHE,EAAGf,cAAuCI,EAACY,IAAAA,CAAEV,UAAU,oCAAoCN"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import{getUniqueId as i}from"../../../../utils/idGenerator.js";import{useMemo as a}from"../../../../external/preact/hooks/dist/hooks.js";function d({children:d,classNameModifiers:o=[],classNamesFields:r=[],label:l,readonly:c=!1,description:n,id:_,renderLabelAsSectionHeading:m=!1}){const{i18n:f}=s(),p=a(()=>i("fieldset-description"),[]);return e("fieldset",{id:_,className:t(["adyen-checkout__fieldset",...o.map(e=>`adyen-checkout__fieldset--${e}`),{"adyen-checkout__fieldset--readonly":c}]),"aria-describedby":n?p:null},l&&e("legend",{className:"adyen-checkout__fieldset__title"},m?e("h2",{className:"adyen-checkout__fieldset__title-heading"},f.get(l)):f.get(l)),n&&e("p",{id:p,className:"adyen-checkout__fieldset__description"},f.get(n)),e("div",{className:t("adyen-checkout__fieldset__fields",r)},d))}export{d as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import{getUniqueId as i}from"../../../../utils/idGenerator.js";import{useMemo as d}from"../../../../external/preact/hooks/dist/hooks.js";function a({children:a,classNameModifiers:o=[],classNamesFields:r=[],label:l,readonly:c=!1,description:n,id:_,renderLabelAsSectionHeading:m=!1,descriptionId:f}){const{i18n:p}=s(),u=d(()=>i("fieldset-description"),[]),h=null!=f?f:u;return e("fieldset",{id:_,className:t(["adyen-checkout__fieldset",...o.map(e=>`adyen-checkout__fieldset--${e}`),{"adyen-checkout__fieldset--readonly":c}])},l&&e("legend",{className:"adyen-checkout__fieldset__title"},m?e("h2",{className:"adyen-checkout__fieldset__title-heading"},p.get(l)):p.get(l)),n&&e("p",{id:h,className:"adyen-checkout__fieldset__description"},p.get(n)),e("div",{className:t("adyen-checkout__fieldset__fields",r)},a))}export{a as default};
2
2
  //# sourceMappingURL=Fieldset.js.map