@adyen/adyen-web 6.45.1 → 6.45.2

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 (205) 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 +1846 -1889
  4. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  5. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  6. package/dist/es/components/Ach/Ach.js +1 -1
  7. package/dist/es/components/Ach/Ach.js.map +1 -1
  8. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  9. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  10. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  11. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  12. package/dist/es/components/BacsDD/BacsDD.js +1 -1
  13. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  14. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  15. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  16. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  17. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  18. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  19. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  20. package/dist/es/components/Blik/Blik.js +1 -1
  21. package/dist/es/components/Blik/Blik.js.map +1 -1
  22. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  23. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  24. package/dist/es/components/Card/Card.js +1 -1
  25. package/dist/es/components/Card/Card.js.map +1 -1
  26. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  27. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  28. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  29. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  30. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  31. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  32. package/dist/es/components/Donation/Donation.js +1 -1
  33. package/dist/es/components/Donation/Donation.js.map +1 -1
  34. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  35. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  36. package/dist/es/components/Dropin/Dropin.js +1 -1
  37. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  38. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  39. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  40. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  41. package/dist/es/components/Giropay/Giropay.js +1 -1
  42. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  43. package/dist/es/components/MBWay/MBWay.js +1 -1
  44. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  45. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  46. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  47. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  48. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  49. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  50. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  51. package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
  52. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  53. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  54. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  55. package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
  56. package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
  57. package/dist/es/components/PayTo/components/PayToPhone.js +1 -1
  58. package/dist/es/components/PayTo/components/PayToPhone.js.map +1 -1
  59. package/dist/es/components/Pix/Pix.js +1 -1
  60. package/dist/es/components/Pix/Pix.js.map +1 -1
  61. package/dist/es/components/Pix/components/PixInput/PixInput.js +1 -1
  62. package/dist/es/components/Pix/components/PixInput/PixInput.js.map +1 -1
  63. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  64. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  65. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  66. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  67. package/dist/es/components/Redirect/Redirect.js +1 -1
  68. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  69. package/dist/es/components/Sepa/Sepa.js.map +1 -1
  70. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  71. package/dist/es/components/Trustly/Trustly.js +1 -1
  72. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  73. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  74. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  75. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  76. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  77. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  78. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  79. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  80. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  81. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  82. package/dist/es/components/internal/IbanInput/validate.js +1 -1
  83. package/dist/es/components/internal/IbanInput/validate.js.map +1 -1
  84. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  85. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  86. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  87. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  88. package/dist/es/components/internal/RedirectButton/RedirectButton.js +1 -1
  89. package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  90. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  91. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  92. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  93. package/dist/es/components/internal/UIElement/utils.js +1 -1
  94. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  95. package/dist/es/core/config.js +1 -1
  96. package/dist/es/index.d.ts +1846 -1889
  97. package/dist/es/utils/Validator/Validator.js +1 -1
  98. package/dist/es/utils/Validator/Validator.js.map +1 -1
  99. package/dist/es/utils/useForm/reducer.js +1 -1
  100. package/dist/es/utils/useForm/reducer.js.map +1 -1
  101. package/dist/es/utils/useForm/useForm.js +1 -1
  102. package/dist/es/utils/useForm/useForm.js.map +1 -1
  103. package/dist/es/utils/useForm/useFormWithA11y.js +1 -1
  104. package/dist/es/utils/useForm/useFormWithA11y.js.map +1 -1
  105. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  106. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  107. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  108. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  109. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  110. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  111. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  112. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  113. package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
  114. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  115. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  116. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  117. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  118. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  119. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  120. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  121. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  122. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  123. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  124. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  125. package/dist/es-legacy/components/Card/Card.js +1 -1
  126. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  127. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  128. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  129. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  130. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  131. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  133. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  134. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  135. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  136. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  137. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  138. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  139. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  140. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  141. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  142. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  143. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  144. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  145. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  146. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  147. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  148. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  149. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  150. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  151. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  152. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
  153. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  154. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  155. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  156. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
  157. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
  158. package/dist/es-legacy/components/PayTo/components/PayToPhone.js +1 -1
  159. package/dist/es-legacy/components/PayTo/components/PayToPhone.js.map +1 -1
  160. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  161. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  162. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js +1 -1
  163. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js.map +1 -1
  164. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  165. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  166. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  167. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  168. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  169. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  170. package/dist/es-legacy/components/Sepa/Sepa.js.map +1 -1
  171. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  172. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  173. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  174. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  175. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  176. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  177. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  178. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  179. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  180. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  181. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  182. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  183. package/dist/es-legacy/components/internal/IbanInput/validate.js +1 -1
  184. package/dist/es-legacy/components/internal/IbanInput/validate.js.map +1 -1
  185. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  186. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  187. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  188. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  189. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  190. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  191. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  192. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  193. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  194. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  195. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  196. package/dist/es-legacy/core/config.js +1 -1
  197. package/dist/es-legacy/utils/Validator/Validator.js +1 -1
  198. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  199. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  200. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  201. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  202. package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
  203. package/dist/es-legacy/utils/useForm/useFormWithA11y.js +1 -1
  204. package/dist/es-legacy/utils/useForm/useFormWithA11y.js.map +1 -1
  205. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import{QRLoader as r}from"../../internal/QRLoader/QRLoader.js";import"../../../core/Context/CoreProvider.js";import"../../../external/preact/hooks/dist/hooks.js";import"../../../core/Errors/SRPanelContext.js";import"../../internal/Button/Button.js";import"../../internal/QRLoader/QRLoaderDetailsProvider.js";import o from"../../internal/RedirectButton/RedirectButton.js";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(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){n(t,e,r[e])})}return t}function s(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 a extends e{formatData(){return{paymentMethod:i({type:this.type},this.state.data)}}get isValid(){return!0}renderQRCode(){return t(r,s(i({},this.props),{delay:this.props.delay,countdownTime:this.props.countdownTime,instructions:this.props.instructions,type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,onActionHandled:this.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics}))}componentToRender(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(o,{showPayButton:this.props.showPayButton,name:this.displayName,onSubmit:this.submit,payButton:this.payButton,setComponentRef:this.setComponentRef}):null}}n(a,"defaultProps",{qrCodeImage:"",amount:null,paymentData:null,onError:()=>{}});export{a as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import{QRLoader as r}from"../../internal/QRLoader/QRLoader.js";import"../../../core/Context/CoreProvider.js";import"../../../external/preact/hooks/dist/hooks.js";import"../../../core/Errors/SRPanelContext.js";import"../../internal/Button/Button.js";import"../../internal/QRLoader/QRLoaderDetailsProvider.js";import o from"../../internal/RedirectButton/RedirectButton.js";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(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){n(t,e,r[e])})}return t}function s(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 a extends e{formatData(){return{paymentMethod:i({type:this.type},this.state.data)}}get isValid(){return!0}renderQRCode(){return t(r,s(i({},this.props),{delay:this.props.delay,countdownTime:this.props.countdownTime,instructions:this.props.instructions,type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,onActionHandled:this.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics}))}componentToRender(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(o,{showPayButton:this.props.showPayButton,name:this.displayName,onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}}):null}}n(a,"defaultProps",{qrCodeImage:"",amount:null,paymentData:null,onError:()=>{}});export{a as default};
2
2
  //# sourceMappingURL=QRLoaderContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport { QRLoader } from '../../internal/QRLoader';\nimport RedirectButton from '../../internal/RedirectButton';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static readonly defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <QRLoader\n {...this.props}\n delay={this.props.delay}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n onActionHandled={this.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n setComponentRef={this.setComponentRef}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","_object_spread","type","this","state","data","isValid","renderQRCode","h","QRLoader","props","delay","countdownTime","instructions","constructor","brandLogo","icon","onComplete","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","componentToRender","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","setComponentRef","_define_property","defaultProps","qrCodeImage","amount","onError"],"mappings":"syCAMA,MAAMA,UAAmFC,EASrFC,UAAAA,GACI,MAAO,CACHC,cAAeC,EAAA,CACXC,KAAMC,KAAKD,MACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,EAAAA,EAAAA,GACON,KAAKO,OAAK,CACdC,MAAOR,KAAKO,MAAMC,MAClBC,cAAeT,KAAKO,MAAME,cAC1BC,aAAcV,KAAKO,MAAMG,aACzBX,KAAMC,KAAKW,YAAY,KACvBC,UAAWZ,KAAKO,MAAMK,WAAaZ,KAAKa,KACxCC,WAAYd,KAAKc,WACjBC,gBAAiBf,KAAKe,gBACtBC,UAAWhB,KAAKiB,YAChBC,kBAAmBlB,KAAKmB,kBAGpC,CAEmBC,iBAAAA,GACf,OAAIpB,KAAKO,MAAMc,YACJrB,KAAKI,eAGZJ,KAAKO,MAAMe,cAEPjB,EAACkB,EAAAA,CACGD,cAAetB,KAAKO,MAAMe,cAC1BE,KAAMxB,KAAKiB,YACXQ,SAAUzB,KAAK0B,OACfC,UAAW3B,KAAK2B,UAChBC,gBAAiB5B,KAAK4B,kBAK3B,IACX,EAxDAC,EAFEnC,EAEwBoC,eAAe,CACrCC,YAAa,GACbC,OAAQ,KACRX,YAAa,KACbY,QAAS"}
1
+ {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport { QRLoader } from '../../internal/QRLoader';\nimport RedirectButton from '../../internal/RedirectButton';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static readonly defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <QRLoader\n {...this.props}\n delay={this.props.delay}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n onActionHandled={this.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","_object_spread","type","this","state","data","isValid","renderQRCode","h","QRLoader","props","delay","countdownTime","instructions","constructor","brandLogo","icon","onComplete","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","componentToRender","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","ref","componentRef","_define_property","defaultProps","qrCodeImage","amount","onError"],"mappings":"syCAMA,MAAMA,UAAmFC,EASrFC,UAAAA,GACI,MAAO,CACHC,cAAeC,EAAA,CACXC,KAAMC,KAAKD,MACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,EAAAA,EAAAA,GACON,KAAKO,OAAK,CACdC,MAAOR,KAAKO,MAAMC,MAClBC,cAAeT,KAAKO,MAAME,cAC1BC,aAAcV,KAAKO,MAAMG,aACzBX,KAAMC,KAAKW,YAAY,KACvBC,UAAWZ,KAAKO,MAAMK,WAAaZ,KAAKa,KACxCC,WAAYd,KAAKc,WACjBC,gBAAiBf,KAAKe,gBACtBC,UAAWhB,KAAKiB,YAChBC,kBAAmBlB,KAAKmB,kBAGpC,CAEmBC,iBAAAA,GACf,OAAIpB,KAAKO,MAAMc,YACJrB,KAAKI,eAGZJ,KAAKO,MAAMe,cAEPjB,EAACkB,EAAAA,CACGD,cAAetB,KAAKO,MAAMe,cAC1BE,KAAMxB,KAAKiB,YACXQ,SAAUzB,KAAK0B,OACfC,UAAW3B,KAAK2B,UAChBC,IAAKA,IACD5B,KAAK6B,aAAeD,KAM7B,IACX,EA1DAE,EAFEpC,EAEwBqC,eAAe,CACrCC,YAAa,GACbC,OAAQ,KACRZ,YAAa,KACba,QAAS"}
@@ -1 +1 @@
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, BaseElementState, 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, S extends BaseElementState = BaseElementState> implements IBaseElement<P> {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: S = {} as S;\n public _component: ComponentChild | undefined;\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(): PaymentData {\n return {} as PaymentData;\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: S): 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 down 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 = {} as S;\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,M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KAAKgD,OACLP,EAAO,KAAMzC,KAAKgD,OAGfhD,IACX,CAMA,MAAAsD,GACItD,KAAKiD,UAEDjD,KAAKuB,MACLvB,KAAKuB,KAAK+B,OAAOtD,KAEzB,CA3JA,WAAAI,CAAYmD,EAAiBtD,GAX7BuD,EAAAxD,KAAgByD,MAAM,GAAGzD,KAAKI,YAAY,QAAWsD,OACrDF,EAAAxD,KAAgBuB,eAEhBiC,EAAAxD,KAAOC,gBACPuD,EAAAxD,KAAOY,QAAW,IAClB4C,EAAAxD,KAAOmD,qBAEPK,EAAAxD,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,cAAgBR,KAAKQ,cAAcwD,KAAKhE,KACjD,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 down 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,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,KAAgByD,MAAM,GAAGzD,KAAKI,YAAY,QAAWsD,OACrDF,EAAAxD,KAAgBuB,eAEhBiC,EAAAxD,KAAOC,gBACPuD,EAAAxD,KAAOY,QAAa,IACpB4C,EAAAxD,KAAOmD,qBAEPK,EAAAxD,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,cAAgBR,KAAKQ,cAAcwD,KAAKhE,KACjD,EAhBAwD,EAVW3D,EAUeoE,eAAe"}
@@ -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 d=d=>{var m;const{i18n:g}=a(),c=r(null),{handleChangeFor:h,data:f,triggerValidation:L,valid:v,errors:F,isValid:j}=i({schema:["shopperLogin"],rules:n,formHolder:c}),I=r({validateInput:null,focusInput:null}),[M,b]=o(!1),E=s(()=>{b(!0),L()},[L]);t(()=>{c.current&&d.errorMessage&&l(c.current,"shopperLogin")},[d.errorMessage]),t(()=>{f.shopperLogin&&b(!0)},[f.shopperLogin]),t(()=>{I.current.validateInput=E,d.onSetInputHandlers(I.current)},[E,d.onSetInputHandlers]);const k=s(e=>{"Enter"===e.key&&d.onPressEnter()},[d.onPressEnter]);return t(()=>{d.onChange({data:f,valid:v,errors:F,isValid:j})},[f,v,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:g.get("ctp.login.inputLabel"),errorMessage:M?d.errorMessage||(F.shopperLogin&&"string"==typeof(null===(m=F.shopperLogin)||void 0===m?void 0:m.errorMessage)?g.get(F.shopperLogin.errorMessage):null):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:f.shopperLogin,disabled:d.disabled,onInput:h("shopperLogin","input"),onBlur:h("shopperLogin","blur"),onKeyDown:k,autocomplete:"email"})))};export{d 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, 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={\n isLoginInputDirty\n ? props.errorMessage ||\n (errors.shopperLogin && typeof errors.shopperLogin?.errorMessage === 'string'\n ? i18n.get(errors.shopperLogin.errorMessage)\n : null)\n : null\n }\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","errors","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","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,IAqDkCC,IAAA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QAAS1C,EAAgB,eAAgB,SACzC2C,OAAQ3C,EAAgB,eAAgB,QACxC4C,UAAWrB,EACXsB,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,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,EAAkBP,EACnBQ,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,UAAWrB,EACXsB,aAAc"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as a}from"../../../core/Context/CoreProvider.js";import r from"../FormFields/Field/Field.js";import{isValidHolder as n,checkIbanStatus as s}from"./validate.js";import{electronicFormat as i,formatIban as o,getCountryCode as l,getNextCursorPosition as d}from"./utils.js";import u from"../FormFields/Fieldset/Fieldset.js";import h from"../FormFields/InputText.js";function b(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{},r=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),r.forEach(function(t){b(e,t,a[t])})}return e}function m(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 a=Object.getOwnPropertySymbols(e);t.push.apply(t,a)}return t}(Object(t)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(t,a))}),e}const p={isValid:!1,errorMessage:"ach.accountHolderNameField.invalid",error:"ach.accountHolderNameField.invalid"},N={isValid:!1,errorMessage:"sepaDirectDebit.ibanField.invalid",error:"sepaDirectDebit.ibanField.invalid"};class g extends e{setStatus(e){this.setState({status:e})}onChange(){const e=!this.props.holderName||n(this.state.data.ownerName),t="valid"===s(this.state.data.ibanNumber).status&&e,a={data:this.state.data,isValid:t,errors:this.state.errors};this.props.onChange(a)}showValidation(){const e=s(this.state.data.ibanNumber).status,t=n(this.state.data.ownerName);this.setError("iban","valid"===e?null:N);const a=t?null:p;this.setError("holder",a,this.onChange)}render({placeholders:e},{data:n,errors:s,valid:i}){const{i18n:o}=a();return t(u,{classNameModifiers:["iban-input"],label:this.props.label},this.props.holderName&&t(r,{className:"adyen-checkout__field--owner-name",label:o.get("sepa.ownerName"),filled:n.ownerName&&n.ownerName.length,errorMessage:!!s.holder&&o.get(s.holder.error),dir:"ltr",i18n:o,name:"ownerName"},t(h,{name:"ownerName",className:"adyen-checkout__iban-input__owner-name",placeholder:null==e?void 0:e.ownerName,value:n.ownerName,"aria-invalid":!!this.state.errors.holder,"aria-label":o.get("sepa.ownerName"),onInput:e=>this.handleHolderInput(e.target.value),onBlur:e=>this.handleHolderInput(e.target.value),autocomplete:"name"})),t(r,{className:"adyen-checkout__field--iban-number",label:o.get("sepa.ibanNumber"),errorMessage:!!s.iban&&o.get(s.iban.error),filled:n.ibanNumber&&n.ibanNumber.length,isValid:i.iban,onBlur:this.handleIbanBlur,dir:"ltr",i18n:o,name:"ibanNumber"},t(h,{name:"ibanNumber",className:"adyen-checkout__iban-input__iban-number",classNameModifiers:["large"],placeholder:null==e?void 0:e.ibanNumber,value:n.ibanNumber,onInput:this.handleIbanInput,"aria-invalid":!!this.state.errors.iban,"aria-label":o.get("sepa.ibanNumber"),autocorrect:"off",spellcheck:!1,autocomplete:void 0})),this.props.showPayButton&&this.props.payButton({status:this.state.status}))}constructor(e){var t,a,r;if(super(e),b(this,"setError",(e,t,a)=>{this.setState(a=>({errors:m(c({},a.errors),{[e]:t})}),a)}),b(this,"handleHolderInput",e=>{this.setState(t=>({data:m(c({},t.data),{ownerName:e})}),()=>{const e=n(this.state.data.ownerName),t=e&&!e?p:null;this.setError("holder",t,this.onChange)})}),b(this,"handleIbanInput",e=>{const t=e.target.value,a=i(t),r=o(a),n=s(r).status,u=l(a),h=e.target.selectionStart,b=this.state.data.ibanNumber,p=d(h,r,b);this.setState(e=>({data:m(c({},e.data),{ibanNumber:r,countryCode:u}),errors:m(c({},e.errors),{iban:"invalid"===n?N:null}),valid:m(c({},e.valid),{iban:"valid"===n})}),()=>{e.target.setSelectionRange(p,p),this.onChange()})}),b(this,"handleIbanBlur",e=>{const t=e.target.value;if(t.length>0){const e=s(t).status;this.setError("iban","valid"===e?null:N,this.onChange)}else this.setError("iban",null,this.onChange)}),this.state={status:"ready",data:{ownerName:(null==e||null===(t=e.data)||void 0===t?void 0:t.ownerName)||"",ibanNumber:(null==e||null===(a=e.data)||void 0===a?void 0:a.ibanNumber)||"",countryCode:(null==e||null===(r=e.data)||void 0===r?void 0:r.countryCode)||""},isValid:!1,cursor:0,errors:{},valid:{}},this.state.data.ibanNumber){const e=i(this.state.data.ibanNumber);this.state.data.ibanNumber=o(e)}if(this.state.data.ibanNumber||this.state.data.ownerName){const e=!this.props.holderName||n(this.state.data.ownerName),t=!!this.state.data.ibanNumber&&"valid"===s(this.state.data.ibanNumber).status&&e,a={data:this.state.data,isValid:t};this.props.onChange(a)}}}b(g,"defaultProps",{onChange:()=>{},countryCode:null,holderName:!0,placeholders:{},label:null});export{g as default};
1
+ import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as a}from"../../../core/Context/CoreProvider.js";import r from"../FormFields/Field/Field.js";import{isValidHolder as s,checkIbanStatus as i}from"./validate.js";import{electronicFormat as n,formatIban as o,getCountryCode as l,getNextCursorPosition as d}from"./utils.js";import u from"../FormFields/Fieldset/Fieldset.js";import h from"../FormFields/InputText.js";function b(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{},r=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),r.forEach(function(t){b(e,t,a[t])})}return e}function m(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 a=Object.getOwnPropertySymbols(e);t.push.apply(t,a)}return t}(Object(t)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(t,a))}),e}const p={isValid:!1,errorMessage:"ach.accountHolderNameField.invalid",error:"ach.accountHolderNameField.invalid"},N={isValid:!1,errorMessage:"sepaDirectDebit.ibanField.invalid",error:"sepaDirectDebit.ibanField.invalid"};class v extends e{setStatus(e){this.setState({status:e})}onChange(){const e=!this.props.holderName||s(this.state.data.ownerName),t="valid"===i(this.state.data.ibanNumber).status&&e,a={data:this.state.data,isValid:t,errors:this.state.errors};this.props.onChange(a)}showValidation(){const e=i(this.state.data.ibanNumber).status,t=s(this.state.data.ownerName);this.setError("iban","valid"!==e?N:null);const a=t?null:p;this.setError("holder",a,this.onChange)}render({placeholders:e},{data:s,errors:i,valid:n}){const{i18n:o}=a();return t(u,{classNameModifiers:["iban-input"],label:this.props.label},this.props.holderName&&t(r,{className:"adyen-checkout__field--owner-name",label:o.get("sepa.ownerName"),filled:s.ownerName&&s.ownerName.length,errorMessage:!!i.holder&&o.get(i.holder.error),dir:"ltr",i18n:o,name:"ownerName"},t(h,{name:"ownerName",className:"adyen-checkout__iban-input__owner-name",placeholder:null==e?void 0:e.ownerName,value:s.ownerName,"aria-invalid":!!this.state.errors.holder,"aria-label":o.get("sepa.ownerName"),onInput:e=>this.handleHolderInput(e.target.value),onBlur:e=>this.handleHolderInput(e.target.value),autocomplete:"name"})),t(r,{className:"adyen-checkout__field--iban-number",label:o.get("sepa.ibanNumber"),errorMessage:!!i.iban&&o.get(i.iban.error),filled:s.ibanNumber&&s.ibanNumber.length,isValid:n.iban,onBlur:this.handleIbanBlur,dir:"ltr",i18n:o,name:"ibanNumber"},t(h,{setRef:e=>{this.ibanNumber=e},name:"ibanNumber",className:"adyen-checkout__iban-input__iban-number",classNameModifiers:["large"],placeholder:null==e?void 0:e.ibanNumber,value:s.ibanNumber,onInput:this.handleIbanInput,"aria-invalid":!!this.state.errors.iban,"aria-label":o.get("sepa.ibanNumber"),autocorrect:"off",spellcheck:!1,autocomplete:void 0})),this.props.showPayButton&&this.props.payButton({status:this.state.status}))}constructor(e){var t,a,r;if(super(e),b(this,"ibanNumber",void 0),b(this,"setData",(e,t,a)=>{this.setState(a=>({data:m(c({},a.data),{[e]:t})}),a)}),b(this,"setError",(e,t,a)=>{this.setState(a=>({errors:m(c({},a.errors),{[e]:t})}),a)}),b(this,"setValid",(e,t,a)=>{this.setState(a=>({valid:m(c({},a.valid),{[e]:t})}),a)}),b(this,"handleHolderInput",e=>{this.setState(t=>({data:m(c({},t.data),{ownerName:e})}),()=>{const e=s(this.state.data.ownerName),t=null==e||e?null:p;this.setError("holder",t,this.onChange)})}),b(this,"handleIbanInput",e=>{const t=e.target.value,a=n(t),r=o(a),s=i(r).status,u=l(a),h=e.target.selectionStart,b=this.state.data.ibanNumber,p=d(h,r,b);this.setState(e=>({data:m(c({},e.data),{ibanNumber:r,countryCode:u}),errors:m(c({},e.errors),{iban:"invalid"===s?N:null}),valid:m(c({},e.valid),{iban:"valid"===s})}),()=>{e.target.setSelectionRange(p,p),this.onChange()})}),b(this,"handleIbanBlur",e=>{const t=e.target.value;if(t.length>0){const e=i(t).status;this.setError("iban","valid"!==e?N:null,this.onChange)}else this.setError("iban",null,this.onChange)}),this.state={status:"ready",data:{ownerName:(null==e||null===(t=e.data)||void 0===t?void 0:t.ownerName)||"",ibanNumber:(null==e||null===(a=e.data)||void 0===a?void 0:a.ibanNumber)||"",countryCode:(null==e||null===(r=e.data)||void 0===r?void 0:r.countryCode)||""},isValid:!1,cursor:0,errors:{},valid:{}},this.state.data.ibanNumber){const e=n(this.state.data.ibanNumber);this.state.data.ibanNumber=o(e)}if(this.state.data.ibanNumber||this.state.data.ownerName){const e=this.props.holderName?s(this.state.data.ownerName):"",t=(this.state.data.ibanNumber?"valid"===i(this.state.data.ibanNumber).status:"")&&e,a={data:this.state.data,isValid:t};this.props.onChange(a)}}}b(v,"defaultProps",{onChange:()=>{},countryCode:null,holderName:!0,placeholders:{},label:null});export{v as default};
2
2
  //# sourceMappingURL=IbanInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IbanInput.js","sources":["../../../../../src/components/internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\nimport { UIElementStatus } from '../UIElement/types';\nimport { PayButtonProps } from '../PayButton/PayButton';\n\nexport interface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputOnChangeData {\n data: IbanData;\n isValid: boolean;\n errors?: Record<string, GenericError | null>;\n}\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: (props: PayButtonProps) => h.JSX.Element;\n onChange: (data: IbanInputOnChangeData) => void;\n label: string;\n data?: IbanData;\n}\n\ninterface IbanInputState {\n data: IbanData;\n errors: Record<string, GenericError | null>;\n valid: Record<string, boolean>;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<Readonly<IbanInputProps>, IbanInputState> {\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : false;\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static readonly defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status: UIElementStatus) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr = holderStatus && !holderStatus ? ibanHolderNameErrorObj : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj);\n\n const holderErr = holderStatus ? null : ibanHolderNameErrorObj;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n autocomplete={'name'}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n autocomplete={undefined}\n />\n </Field>\n\n {this.props.showPayButton && this.props.payButton({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","autocomplete","iban","handleIbanBlur","ibanNumber","handleIbanInput","autocorrect","spellcheck","undefined","showPayButton","payButton","constructor","super","_define_property","key","cb","prevState","_object_spread_props","_object_spread","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"+vCA2CA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EAwCpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA1DiB,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,QACpCI,EACvBK,EAAO,CAAEA,KAAMR,KAAKO,MAAMC,KAAMhB,UAASkB,OAAQV,KAAKO,M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KO,MAAMC,gBAEnEhB,IADYQ,KAAKO,MAAMC,iBAA+E,UAA1DC,EAAgBT,KAAKO,MAAMC,iBAAoBT,QACpEI,EACvBK,EAAO,CAAEA,KAAMR,KAAKO,MAAMC,KAAMhB,WAEtCQ,KAAKI,MAAMF,SAASM,EACxB,CACJ,EAEAgD,EAhCE5D,EAgCqB+E,eAAe,CAClCzE,SAAU,OACVgE,YAAa,KACb7D,YAAY,EACZY,aAAc,CAAA,EACdO,MAAO"}
1
+ {"version":3,"file":"IbanInput.js","sources":["../../../../../src/components/internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: any;\n onChange: (data) => void;\n label: string;\n data: IbanData;\n}\n\ninterface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputState {\n data: any;\n errors: any;\n valid: any;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<Readonly<IbanInputProps>, IbanInputState> {\n private ibanNumber: HTMLInputElement;\n\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : '';\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : '';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static readonly defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setData = (key, value, cb?) => {\n this.setState(prevState => ({ data: { ...prevState.data, [key]: value } }), cb);\n };\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public setValid = (key, value, cb?) => {\n this.setState(prevState => ({ valid: { ...prevState.valid, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr =\n holderStatus != null && !holderStatus // *don't* consider null, i.e. a value that has just been deleted, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null);\n\n const holderErr = !holderStatus // *do* consider null, i.e. an empty field, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n autocomplete={'name'}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n setRef={ref => {\n this.ibanNumber = ref;\n }}\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n autocomplete={undefined}\n />\n </Field>\n\n {this.props.showPayButton && this.props.payButton({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","autocomplete","iban","handleIbanBlur","setRef","ref","ibanNumber","handleIbanInput","autocorrect","spellcheck","undefined","showPayButton","payButton","constructor","super","_define_property","setData","key","cb","prevState","_object_spread_props","_object_spread","setValid","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"+vCAmCA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EA0CpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA1DiB,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,QACpCI,EACvBK,EAAO,CAAEA,KAAMR,KAAKO,MAAMC,KAAMhB,UAASkB,OAAQV,KAAKO,MAAMG,QAElEV,KAAKI,MAAMF,SAASM,EACxB,CAsEAG,cAAAA,GACI,MAAMC,EAAmBH,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,OAClEc,EAAeP,EAAcN,KAAKO,MAAMC,KAAK,WACnDR,KAAKc,SAAS,OAA6B,UAArBF,EAA+BjB,EAAe,MAEpE,MAAMoB,EAAaF,EAEb,KADAtB,EAGNS,KAAKc,SAAS,SAAUC,EAAWf,KAAKE,SAC5C,CAEAc,MAAAA,EAAOC,aAAEA,IAAgCT,KAAEA,EAAIE,OAAEA,EAAMQ,MAAEA,IACrD,MAAMC,KAAEA,GAASC,IACjB,OACIC,EAACC,EAAAA,CAASC,mBAAoB,CAAC,cAAeC,MAAOxB,KAAKI,MAAMoB,OAC3DxB,KAAKI,MAAMC,YACRgB,EAACI,EAAAA,CACGC,UAAW,oCACXF,MAAOL,EAAKQ,IAAI,kBAChBC,OAAQpB,EAAK,WAAgBA,EAAK,UAAaqB,OAC/CpC,eAAciB,EAAOoB,QAASX,EAAKQ,IAAIjB,EAAOoB,OAAOpC,OACrDqC,IAAK,MACLZ,KAAMA,EACNa,KAAM,aAENX,EAACY,EAAAA,CACGD,KAAM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2 +1,2 @@
1
- import{electronicFormat as t,getCountryCode as n,getIbanCountrySpecification as e,iso13616Prepare as i,iso7064Mod97_10 as l,regex as s}from"./utils.js";import{isEmpty as o}from"../../../utils/validator-utils.js";function r(t,n=null){this.status=t,this.code=n}const a=n=>{const e=t(n),o=i(e);return 1===l(o)&&(t=>{const n=t.slice(0,2),e=s(t,n);return e.test&&e.test(t.slice(4))||!1})(e)},u=i=>{const l=t(i);if(i.length<2)return new r("no-validate","TOO_SHORT");const s=n(l),o=e(s);return o?l.length>o.length?new r("invalid","TOO_LONG"):l.length===o.length?a(i)?new r("valid","VALID"):new r("invalid","INVALID_IBAN"):new r("no-validate","UNKNOWN"):new r("invalid","INVALID_COUNTRY")},c=t=>!o(t);export{u as checkIbanStatus,c as isValidHolder,a as isValidIBAN};
1
+ import{electronicFormat as t,getCountryCode as n,getIbanCountrySpecification as e,iso13616Prepare as i,iso7064Mod97_10 as l,regex as s}from"./utils.js";import{isEmpty as o}from"../../../utils/validator-utils.js";function r(t,n=null){this.status=t,this.code=n}const a=n=>{const e=t(n),o=i(e);return 1===l(o)&&(t=>{const n=t.slice(0,2),e=s(t,n);return e.test&&e.test(t.slice(4))||!1})(e)},u=i=>{const l=t(i);if(i.length<2)return new r("no-validate","TOO_SHORT");const s=n(l),o=e(s);return o?l.length>o.length?new r("invalid","TOO_LONG"):l.length===o.length?a(i)?new r("valid","VALID"):new r("invalid","INVALID_IBAN"):new r("no-validate","UNKNOWN"):new r("invalid","INVALID_COUNTRY")},c=t=>!o(t)||null;export{u as checkIbanStatus,c as isValidHolder,a as isValidIBAN};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/IbanInput/validate.ts"],"sourcesContent":["import { iso13616Prepare, iso7064Mod97_10, electronicFormat, regex, getIbanCountrySpecification, getCountryCode } from './utils';\nimport { isEmpty } from '../../../utils/validator-utils';\n\n/**\n * Contains a validation status\n * @internal\n * @param status -\n * @param code -\n */\nfunction ValidationStatus(status, code = null) {\n this.status = status;\n this.code = code;\n}\n\n/**\n * Validates the format of an iban\n * @internal\n * @param iban -\n */\nconst checkIbanStructure = iban => {\n const countryCode = iban.slice(0, 2);\n const ibanRegex = regex(iban, countryCode);\n\n return ((ibanRegex as RegExp).test && (ibanRegex as RegExp).test(iban.slice(4))) || false;\n};\n\n/**\n * Checks validity of an IBAN\n * @param iban -\n */\nexport const isValidIBAN = iban => {\n const electronicFormatIban = electronicFormat(iban);\n const preparedIban = iso13616Prepare(electronicFormatIban);\n const isValidISO = iso7064Mod97_10(preparedIban) === 1;\n\n return isValidISO && checkIbanStructure(electronicFormatIban);\n};\n\n/**\n * Checkss the validity status of an IBAN\n * @param iban -\n */\nexport const checkIbanStatus = iban => {\n const electronicFormatIban = electronicFormat(iban);\n\n if (iban.length < 2) {\n return new ValidationStatus('no-validate', 'TOO_SHORT'); // A\n }\n\n const countryCode = getCountryCode(electronicFormatIban);\n const countrySpecification = getIbanCountrySpecification(countryCode);\n\n if (!countrySpecification) {\n return new ValidationStatus('invalid', 'INVALID_COUNTRY'); // AA13TEST0123456789\n }\n\n if (electronicFormatIban.length > countrySpecification.length) {\n return new ValidationStatus('invalid', 'TOO_LONG'); // NL13TEST01234567891\n }\n\n if (electronicFormatIban.length === countrySpecification.length) {\n if (isValidIBAN(iban)) {\n return new ValidationStatus('valid', 'VALID'); // NL13TEST0123456789\n }\n\n return new ValidationStatus('invalid', 'INVALID_IBAN'); // NL13TEST0123456781\n }\n\n return new ValidationStatus('no-validate', 'UNKNOWN'); // NL13TEST012345678\n};\n\n/**\n * Checks validity of a holder name\n */\nexport const isValidHolder = (value: string) => !isEmpty(value);\n"],"names":["ValidationStatus","status","code","this","isValidIBAN","iban","electronicFormatIban","electronicFormat","preparedIban","iso13616Prepare","iso7064Mod97_10","countryCode","slice","ibanRegex","regex","test","checkIbanStructure","checkIbanStatus","length","getCountryCode","countrySpecification","getIbanCountrySpecification","isValidHolder","value","isEmpty"],"mappings":"oNASA,SAASA,EAAiBC,EAAQC,EAAO,MACrCC,KAAKF,OAASA,EACdE,KAAKD,KAAOA,CAChB,CAOA,MAWaE,EAAcC,IACvB,MAAMC,EAAuBC,EAAiBF,GACxCG,EAAeC,EAAgBH,GAGrC,OAFqD,IAAlCI,EAAgBF,IAdZH,CAAAA,IACvB,MAAMM,EAAcN,EAAKO,MAAM,EAAG,GAC5BC,EAAYC,EAAMT,EAAMM,GAE9B,OAASE,EAAqBE,MAASF,EAAqBE,KAAKV,EAAKO,MAAM,MAAQ,GAY/DI,CAAmBV,IAO/BW,EAAkBZ,IAC3B,MAAMC,EAAuBC,EAAiBF,GAE9C,GAAIA,EAAKa,OAAS,EACd,OAAO,IAAIlB,EAAiB,cAAe,aAG/C,MAAMW,EAAcQ,EAAeb,GAC7Bc,EAAuBC,EAA4BV,GAEzD,OAAKS,EAIDd,EAAqBY,OAASE,EAAqBF,OAC5C,IAAIlB,EAAiB,UAAW,YAGvCM,EAAqBY,SAAWE,EAAqBF,OACjDd,EAAYC,GACL,IAAIL,EAAiB,QAAS,SAGlC,IAAIA,EAAiB,UAAW,gBAGpC,IAAIA,EAAiB,cAAe,WAfhC,IAAIA,EAAiB,UAAW,oBAqBlCsB,EAAiBC,IAAmBC,EAAQD"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/IbanInput/validate.ts"],"sourcesContent":["import { iso13616Prepare, iso7064Mod97_10, electronicFormat, regex, getIbanCountrySpecification, getCountryCode } from './utils';\nimport { isEmpty } from '../../../utils/validator-utils';\n\n/**\n * Contains a validation status\n * @internal\n * @param status -\n * @param code -\n */\nfunction ValidationStatus(status, code = null) {\n this.status = status;\n this.code = code;\n}\n\n/**\n * Validates the format of an iban\n * @internal\n * @param iban -\n */\nconst checkIbanStructure = iban => {\n const countryCode = iban.slice(0, 2);\n const ibanRegex = regex(iban, countryCode);\n\n return ((ibanRegex as RegExp).test && (ibanRegex as RegExp).test(iban.slice(4))) || false;\n};\n\n/**\n * Checks validity of an IBAN\n * @param iban -\n */\nexport const isValidIBAN = iban => {\n const electronicFormatIban = electronicFormat(iban);\n const preparedIban = iso13616Prepare(electronicFormatIban);\n const isValidISO = iso7064Mod97_10(preparedIban) === 1;\n\n return isValidISO && checkIbanStructure(electronicFormatIban);\n};\n\n/**\n * Checkss the validity status of an IBAN\n * @param iban -\n */\nexport const checkIbanStatus = iban => {\n const electronicFormatIban = electronicFormat(iban);\n\n if (iban.length < 2) {\n return new ValidationStatus('no-validate', 'TOO_SHORT'); // A\n }\n\n const countryCode = getCountryCode(electronicFormatIban);\n const countrySpecification = getIbanCountrySpecification(countryCode);\n\n if (!countrySpecification) {\n return new ValidationStatus('invalid', 'INVALID_COUNTRY'); // AA13TEST0123456789\n }\n\n if (electronicFormatIban.length > countrySpecification.length) {\n return new ValidationStatus('invalid', 'TOO_LONG'); // NL13TEST01234567891\n }\n\n if (electronicFormatIban.length === countrySpecification.length) {\n if (isValidIBAN(iban)) {\n return new ValidationStatus('valid', 'VALID'); // NL13TEST0123456789\n }\n\n return new ValidationStatus('invalid', 'INVALID_IBAN'); // NL13TEST0123456781\n }\n\n return new ValidationStatus('no-validate', 'UNKNOWN'); // NL13TEST012345678\n};\n\n/**\n * Checks validity of a holder name\n */\nexport const isValidHolder = value => (isEmpty(value) ? null : true); // true, if there are chars other than spaces\n"],"names":["ValidationStatus","status","code","this","isValidIBAN","iban","electronicFormatIban","electronicFormat","preparedIban","iso13616Prepare","iso7064Mod97_10","countryCode","slice","ibanRegex","regex","test","checkIbanStructure","checkIbanStatus","length","getCountryCode","countrySpecification","getIbanCountrySpecification","isValidHolder","value","isEmpty"],"mappings":"oNASA,SAASA,EAAiBC,EAAQC,EAAO,MACrCC,KAAKF,OAASA,EACdE,KAAKD,KAAOA,CAChB,CAOA,MAWaE,EAAcC,IACvB,MAAMC,EAAuBC,EAAiBF,GACxCG,EAAeC,EAAgBH,GAGrC,OAFqD,IAAlCI,EAAgBF,IAdZH,CAAAA,IACvB,MAAMM,EAAcN,EAAKO,MAAM,EAAG,GAC5BC,EAAYC,EAAMT,EAAMM,GAE9B,OAASE,EAAqBE,MAASF,EAAqBE,KAAKV,EAAKO,MAAM,MAAQ,GAY/DI,CAAmBV,IAO/BW,EAAkBZ,IAC3B,MAAMC,EAAuBC,EAAiBF,GAE9C,GAAIA,EAAKa,OAAS,EACd,OAAO,IAAIlB,EAAiB,cAAe,aAG/C,MAAMW,EAAcQ,EAAeb,GAC7Bc,EAAuBC,EAA4BV,GAEzD,OAAKS,EAIDd,EAAqBY,OAASE,EAAqBF,OAC5C,IAAIlB,EAAiB,UAAW,YAGvCM,EAAqBY,SAAWE,EAAqBF,OACjDd,EAAYC,GACL,IAAIL,EAAiB,QAAS,SAGlC,IAAIA,EAAiB,UAAW,gBAGpC,IAAIA,EAAiB,cAAe,WAfhC,IAAIA,EAAiB,UAAW,oBAqBlCsB,EAAgBC,IAAUC,EAAQD,IAAS"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useEffect as s}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import i from"../CompanyDetails/CompanyDetails.js";import a from"../PersonalDetails/PersonalDetails.js";import l from"../Address/Address.js";import d from"../FormFields/Checkbox/Checkbox.js";import c from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as u,fieldsetsSchema as p,getActiveFieldsData as b}from"./utils.js";import m from"../IbanInput/IbanInput.js";import y from"../FormFields/Field/Field.js";import f from"../FormInstruction/FormInstruction.js";import v from"./useSRPanelForOpenInvoiceErrors.js";function h(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function C(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},s=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),s.forEach(function(r){h(e,r,o[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j,D,O;const{countryCode:x,visibility:w}=h,{i18n:F}=t(),P=r(!1),R=r(null),S=u(w,h.data),[E,I]=o(S),{current:V}=r(p.reduce((e,r)=>(e[r]=e=>{V[r].current=e},e),{})),q=!!h.consentCheckboxLabel,M=!q&&Object.keys(E).every(e=>!E[e]),N="editable"===w.deliveryAddress&&"hidden"!==w.billingAddress,[_,L]=o(C({},h.data,q&&{consentCheckbox:!1})),[B,z]=o({}),[G,H]=o({}),[J,K]=o("ready"),Q=r({setStatus:K,showValidation:()=>{}});Q.current.showValidation=()=>{P.current=!0,p.forEach(e=>{V[e].current&&V[e].current.showValidation()}),z(C({},q&&{consentCheckbox:_.consentCheckbox?null:A}))},s(()=>{var e;null===(e=h.setComponentRef)||void 0===e||e.call(h,Q.current)},[h.setComponentRef]),v({errors:B,data:_,props:h,isValidating:P,containerRef:R}),s(()=>{const e=Object.keys(E).every(e=>!E[e]||!!G[e]),r=!q||!!G.consentCheckbox,o=e&&r,s=b(E,_);h.onChange({data:s,errors:B,valid:G,isValid:o})},[_,E]);const T=e=>r=>{L(o=>g(C({},o),{[e]:r.data})),H(o=>g(C({},o),{[e]:r.isValid})),z(o=>g(C({},o),{[e]:r.errors}))};return e("div",{ref:R,className:n({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===J})},e(f,null),E.companyDetails&&e(i,{data:h.data.companyDetails,label:"companyDetails",onChange:T("companyDetails"),setComponentRef:V.companyDetails,visibility:w.companyDetails}),E.personalDetails&&e(a,{data:h.data.personalDetails,requiredFields:h.personalDetailsRequiredFields,label:"personalDetails",onChange:T("personalDetails"),setComponentRef:V.personalDetails,visibility:w.personalDetails}),E.bankAccount&&e(m,{holderName:!0,label:"ach.bankAccount",data:_.bankAccount,onChange:T("bankAccount"),ref:V.bankAccount}),E.billingAddress&&e(l,{allowedCountries:null!==(k=null==h||null===(D=h.billingAddressSpecification)||void 0===D?void 0:D.allowedCountries)&&void 0!==k?k:h.allowedCountries,countryCode:x,requiredFields:h.billingAddressRequiredFields,specifications:h.billingAddressSpecification,data:_.billingAddress,label:"billingAddress",onChange:T("billingAddress"),setComponentRef:V.billingAddress,visibility:w.billingAddress}),N&&e(y,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(d,{label:F.get("separateDeliveryAddress"),checked:E.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{I(e=>g(C({},e),{deliveryAddress:!E.deliveryAddress}))}})),E.deliveryAddress&&e(l,{allowedCountries:null!==(j=null==h||null===(O=h.deliveryAddressSpecification)||void 0===O?void 0:O.allowedCountries)&&void 0!==j?j:h.allowedCountries,countryCode:x,requiredFields:h.deliveryAddressRequiredFields,specifications:h.deliveryAddressSpecification,data:_.deliveryAddress,label:"deliveryAddress",onChange:T("deliveryAddress"),setComponentRef:V.deliveryAddress,visibility:w.deliveryAddress}),q&&e(c,{data:_,errorMessage:!!B.consentCheckbox,label:h.consentCheckboxLabel,onChange:e=>{const{checked:r}=e.target;L(e=>g(C({},e),{consentCheckbox:r})),H(e=>g(C({},e),{consentCheckbox:r})),z(e=>C({},e,{consentCheckbox:r?null:A}))},i18n:F}),h.showPayButton&&h.payButton({status:J,classNameModifiers:[...M?["standalone"]:[]],label:F.get("confirmPurchase")}))}export{k as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as s,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import i from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as u,getActiveFieldsData as b}from"./utils.js";import p from"../IbanInput/IbanInput.js";import m from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import f from"./useSRPanelForOpenInvoiceErrors.js";import v from"../../../_virtual/index.js";function h(e,r,s){return r in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}function C(e){for(var r=1;r<arguments.length;r++){var s=null!=arguments[r]?arguments[r]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.forEach(function(r){h(e,r,s[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);r.push.apply(r,s)}return r}(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j,D,O;const{countryCode:x,visibility:w}=h,{i18n:F}=t(),P=r({});var R;Object.keys(P.current).length||(null===(R=h.setComponentRef)||void 0===R||R.call(h,P.current));const S=r(!1),E=r(null),I=c(w,h.data),[q,V]=s(I),{current:M}=r(u.reduce((e,r)=>(e[r]=e=>{M[r].current=e},e),{})),N=!!h.consentCheckboxLabel,_=!N&&Object.keys(q).every(e=>!q[e]),L="editable"===w.deliveryAddress&&"hidden"!==w.billingAddress,[B,z]=s(C({},h.data,N&&{consentCheckbox:!1})),[G,H]=s({}),[J,K]=s({}),[Q,T]=s("ready");P.current.showValidation=()=>{S.current=!0,u.forEach(e=>{M[e].current&&M[e].current.showValidation()}),H(C({},N&&{consentCheckbox:B.consentCheckbox?null:A}))},P.current.setStatus=T,f({errors:G,data:B,props:h,isValidating:S,containerRef:E}),o(()=>{const e=Object.keys(q).every(e=>!q[e]||!!J[e]),r=!N||!!J.consentCheckbox,s=e&&r,o=b(q,B);h.onChange({data:o,errors:G,valid:J,isValid:s})},[B,q]);const U=e=>r=>{z(s=>g(C({},s),{[e]:r.data})),K(s=>g(C({},s),{[e]:r.isValid})),H(s=>g(C({},s),{[e]:r.errors}))};return e("div",{ref:E,className:v({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===Q})},e(y,null),q.companyDetails&&e(n,{data:h.data.companyDetails,label:"companyDetails",onChange:U("companyDetails"),setComponentRef:M.companyDetails,visibility:w.companyDetails}),q.personalDetails&&e(i,{data:h.data.personalDetails,requiredFields:h.personalDetailsRequiredFields,label:"personalDetails",onChange:U("personalDetails"),setComponentRef:M.personalDetails,visibility:w.personalDetails}),q.bankAccount&&e(p,{holderName:!0,label:"ach.bankAccount",data:B.bankAccount,onChange:U("bankAccount"),ref:M.bankAccount}),q.billingAddress&&e(a,{allowedCountries:null!==(k=null==h||null===(D=h.billingAddressSpecification)||void 0===D?void 0:D.allowedCountries)&&void 0!==k?k:h.allowedCountries,countryCode:x,requiredFields:h.billingAddressRequiredFields,specifications:h.billingAddressSpecification,data:B.billingAddress,label:"billingAddress",onChange:U("billingAddress"),setComponentRef:M.billingAddress,visibility:w.billingAddress}),L&&e(m,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(l,{label:F.get("separateDeliveryAddress"),checked:q.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{V(e=>g(C({},e),{deliveryAddress:!q.deliveryAddress}))}})),q.deliveryAddress&&e(a,{allowedCountries:null!==(j=null==h||null===(O=h.deliveryAddressSpecification)||void 0===O?void 0:O.allowedCountries)&&void 0!==j?j:h.allowedCountries,countryCode:x,requiredFields:h.deliveryAddressRequiredFields,specifications:h.deliveryAddressSpecification,data:B.deliveryAddress,label:"deliveryAddress",onChange:U("deliveryAddress"),setComponentRef:M.deliveryAddress,visibility:w.deliveryAddress}),N&&e(d,{data:B,errorMessage:!!G.consentCheckbox,label:h.consentCheckboxLabel,onChange:e=>{const{checked:r}=e.target;z(e=>g(C({},e),{consentCheckbox:r})),K(e=>g(C({},e),{consentCheckbox:r})),H(e=>C({},e,{consentCheckbox:r?null:A}))},i18n:F}),h.showPayButton&&h.payButton({status:Q,classNameModifiers:[..._?["standalone"]:[]],label:F.get("confirmPurchase")}))}export{k as default};
2
2
  //# sourceMappingURL=OpenInvoice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport './OpenInvoice.scss';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n const isValidating = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n const openInvoiceRef = useRef<ComponentMethodsRef>({\n setStatus,\n showValidation: () => {}\n });\n\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n useEffect(() => {\n props.setComponentRef?.(openInvoiceRef.current);\n }, [props.setComponentRef]);\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating, containerRef });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n ref={containerRef}\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","isValidating","useRef","containerRef","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","current","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","Object","keys","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","openInvoiceRef","showValidation","forEach","useEffect","setComponentRef","useSRPanelForOpenInvoiceErrors","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","_ref","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","_ref1","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,WA4HEA,EA+BAA,EA1JlC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAEXC,EAAeC,GAAO,GACtBC,EAAeD,EAAuB,MAEtCE,EAAqDC,EAA0BP,EAAYF,EAAMU,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EM,QAASC,GAAkBT,EAC/BU,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUL,QAAUM,GAE/BF,GACR,CAAA,IAIDG,IAAuBrB,EAAMsB,qBAC7BC,GAAsBF,GAAsBG,OAAOC,KAAKd,GAAiBe,MAAMC,IAAQhB,EAAgBgB,IACvGC,EAAqE,aAA/B1B,EAAW2B,iB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EAAAtB,EAAA,CAAA,EACjCsD,GAAAA,CACHzD,iBAAkBlB,EAAgBkB,uBAkFjClB,EAAgBkB,iBACb4B,EAACe,EAAAA,CACGC,iBAAuE,QAAvDc,EAAEvF,SAAmC,QAAnCA,EAAAA,EAAOwF,oCAAPxF,IAAAA,SAAAA,EAAqCyE,wBAAgB,IAAAc,EAAAA,EAAIvF,EAAMyE,iBACjFxE,YAAaA,EACbkE,eAAgBnE,EAAMyF,8BACtBZ,eAAgB7E,EAAMwF,6BACtB9E,KAAMA,EAAKmB,gBACXmC,MAAM,kBACNd,SAAUC,EAAe,mBACzBP,gBAAiB7B,EAAcc,gBAC/B3B,WAAYA,EAAW2B,kBAI9BR,GACGoC,EAACiC,EAAAA,CACGhF,KAAMA,EACNb,eAAgBqC,EAAOD,gBACvB+B,MAAOhE,EAAMsB,qBACb4B,SAjGcyC,IAC1B,MAAMN,QAAEA,GAAYM,EAAEC,OACtB7D,EAAQsB,GAAaC,EAAAtB,EAAA,CAAA,EAAKqB,GAAAA,CAAUpB,gBAAiBoD,KACrDhD,EAASkB,GAAcD,EAAAtB,EAAA,CAAA,EAAKuB,GAAAA,CAAWtB,gBAAiBoD,KACxDlD,EAAUqB,GAAexB,EAAA,CAAA,EAAKwB,EAAe,CAAEvB,gBAAkBoD,EAA8B,KAApB1F,MA8F/DQ,KAAMA,IAIbH,EAAM6F,eACH7F,EAAM8F,UAAU,CACZxD,SACAyC,mBAAoB,IAAKxD,EAAqB,CAAC,cAAgB,IAC/DyC,MAAO7D,EAAKiF,IAAI,qBAIpC"}
1
+ {"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport classNames from 'classnames';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating, containerRef });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n ref={containerRef}\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","containerRef","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","_ref","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","_ref1","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,WA6HEA,EA+BAA,EA3JlC,MAAMC,YAAEA,EAAWC,WAAEA,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A,IAIbH,EAAM8F,eACH9F,EAAM+F,UAAU,CACZtD,SACAuC,mBAAoB,IAAKpD,EAAqB,CAAC,cAAgB,IAC/DqC,MAAO9D,EAAKkF,IAAI,qBAIpC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as t,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{phoneFormatters as s,phoneValidationRules as l}from"./validate.js";import a from"../FormFields/Fieldset/Fieldset.js";import u from"./PhoneInputFields.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){c(e,r,t[r])})}return e}function f(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function m(c){var m,d;const{i18n:b}=i(),h=c.requiredFields||[...(null==c||null===(m=c.items)||void 0===m?void 0:m.length)?["phonePrefix"]:[],"phoneNumber"],j=h.includes("phonePrefix")&&!!(null==c||null===(d=c.items)||void 0===d?void 0:d.length),O=h.includes("phoneNumber"),g=n(f(p({i18n:b},c),{schema:h,defaultData:c.data,rules:l,formatters:s}));r(()=>{g.setSchema(h)},[h.toString()]);const{data:y,valid:P,errors:v,isValid:w,triggerValidation:F}=g;r(()=>{c.onChange({data:y,valid:P,errors:v,isValid:w})},[y,P,v,w]);const x=t({showValidation:F});r(()=>{c.setComponentRef(x.current)},[c.setComponentRef]);const S=o(e=>{if(v[e]){const r="phoneNumber"===e?"phoneNumberErrorKey":"phonePrefixErrorKey",t=c[r]?c[r]:v[e].errorMessage;return"string"==typeof t?b.get(t):null}return null},[v]);return e(a,{classNameModifiers:["phone-input"]},e(u,p({getError:S,showNumber:O,showPrefix:j,form:g},c)))}m.defaultProps={phoneLabel:"telephoneNumber"};export{m as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as t,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{phoneFormatters as s,phoneValidationRules as l}from"./validate.js";import a from"../FormFields/Fieldset/Fieldset.js";import u from"./PhoneInputFields.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(r){c(e,r,t[r])})}return e}function f(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function m(c){var m,d;const{i18n:b}=i(),h=c.requiredFields||[...(null==c||null===(m=c.items)||void 0===m?void 0:m.length)?["phonePrefix"]:[],"phoneNumber"],j=h.includes("phonePrefix")&&!!(null==c||null===(d=c.items)||void 0===d?void 0:d.length),O=h.includes("phoneNumber"),g=n(f(p({i18n:b},c),{schema:h,defaultData:c.data,rules:l,formatters:s}));r(()=>{g.setSchema(h)},[h.toString()]);const{data:y,valid:P,errors:v,isValid:w,triggerValidation:F}=g;r(()=>{c.onChange({data:y,valid:P,errors:v,isValid:w})},[y,P,v,w]);const x=t({showValidation:F});r(()=>{c.setComponentRef(x.current)},[c.setComponentRef]);const S=o(e=>{if(v[e]){var r;const t="phoneNumber"===e?"phoneNumberErrorKey":"phonePrefixErrorKey",o=c[t]?c[t]:v[e].errorMessage;return null!==(r=b.get(o))&&void 0!==r?r:null}return null},[v]);return e(a,{classNameModifiers:["phone-input"]},e(u,p({getError:S,showNumber:O,showPrefix:j,form:g},c)))}m.defaultProps={phoneLabel:"telephoneNumber"};export{m as default};
2
2
  //# sourceMappingURL=PhoneInputForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInputForm.js","sources":["../../../../../src/components/internal/PhoneInput/PhoneInputForm.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './PhoneInput.scss';\nimport { phoneFormatters, phoneValidationRules } from './validate';\nimport { PhoneInputFormProps, PhoneInputSchema } from './types';\nimport Fieldset from '../FormFields/Fieldset';\nimport PhoneInputFields from './PhoneInputFields';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\n/**\n *\n * @param PhoneInputFormProps\n * @constructor\n */\nfunction PhoneInputForm(props: Readonly<PhoneInputFormProps>) {\n const { i18n } = useCoreContext();\n\n const schema = props.requiredFields || [...(props?.items?.length ? ['phonePrefix'] : []), 'phoneNumber'];\n const showPrefix = schema.includes('phonePrefix') && !!props?.items?.length;\n const showNumber = schema.includes('phoneNumber');\n\n const form = useForm<PhoneInputSchema>({\n i18n,\n ...props,\n schema,\n defaultData: props.data,\n rules: phoneValidationRules,\n formatters: phoneFormatters\n });\n\n useEffect(() => {\n form.setSchema(schema);\n }, [schema.toString()]);\n\n const { data, valid, errors, isValid, triggerValidation } = form;\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const componentRef = useRef<ComponentMethodsRef>({\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n props.setComponentRef(componentRef.current);\n }, [props.setComponentRef]);\n\n // This is here for MBWay, prob should be moved up\n // MBWay has a weird way of loading its error messages\n // They come form the prop phoneNumberErrorKey: 'mobileNumber.invalid'\n // Strangely it's defined as invalidPhoneNumber in the validation rules\n const getPhoneFieldError = useCallback(\n (field: string) => {\n if (errors[field]) {\n const propsField = field === 'phoneNumber' ? 'phoneNumberErrorKey' : 'phonePrefixErrorKey';\n const key = props[propsField] ? props[propsField] : errors[field].errorMessage;\n return typeof key === 'string' ? i18n.get(key) : null;\n }\n return null;\n },\n [errors]\n );\n\n return (\n <Fieldset classNameModifiers={['phone-input']}>\n <PhoneInputFields getError={getPhoneFieldError} showNumber={showNumber} showPrefix={showPrefix} form={form} {...props} />\n </Fieldset>\n );\n}\n\nPhoneInputForm.defaultProps = {\n phoneLabel: 'telephoneNumber'\n};\n\nexport default PhoneInputForm;\n"],"names":["PhoneInputForm","props","i18n","useCoreContext","schema","requiredFields","items","length","showPrefix","includes","showNumber","form","useForm","_object_spread_props","_object_spread","defaultData","data","rules","phoneValidationRules","formatters","phoneFormatters","useEffect","setSchema","toString","valid","errors","isValid","triggerValidation","onChange","componentRef","useRef","showValidation","setComponentRef","current","getPhoneFieldError","useCallback","field","propsField","key","errorMessage","get","h","Fieldset","classNameModifiers","PhoneInputFields","getError","defaultProps","phoneLabel"],"mappings":"oyCAgBA,SAASA,EAAeC,OAGwBA,EACWA,EAHvD,MAAMC,KAAEA,GAASC,IAEXC,EAASH,EAAMI,gBAAkB,KAAKJ,SAAY,QAAZA,EAAAA,EAAOK,aAAPL,IAAAA,SAAAA,EAAcM,QAAS,CAAC,eAAiB,GAAK,eACpFC,EAAaJ,EAAOK,SAAS,mBAAoBR,SAAY,QAAZA,EAAAA,EAAOK,iBAAPL,OAAAA,EAAAA,EAAcM,QAC/DG,EAAaN,EAAOK,SAAS,eAE7BE,EAAOC,EAA0BC,EAAAC,EAAA,CACnCZ,QACGD,GAAAA,CACHG,SACAW,YAAad,EAAMe,KACnBC,MAAOC,EACPC,WAAYC,KAGhBC,EAAU,KACNV,EAAKW,UAAUlB,IAChB,CAACA,EAAOmB,aAEX,MAAMP,KAAEA,EAAIQ,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,kBAAEA,GAAsBhB,EAE5DU,EAAU,KACNpB,EAAM2B,SAAS,CAAEZ,OAAMQ,QAAOC,SAAQC,aACvC,CAACV,EAAMQ,EAAOC,EAAQC,IAEzB,MAAMG,EAAeC,EAA4B,CAC7CC,eAAgBJ,IAGpBN,EAAU,KACNpB,EAAM+B,gBAAgBH,EAAaI,UACpC,CAAChC,EAAM+B,kBAMV,MAAME,EAAqBC,EACtBC,IACG,GAAIX,EAAOW,GAAQ,CACf,MAAMC,EAAuB,gBAAVD,EAA0B,sBAAwB,sBAC/DE,EAAMrC,EAAMoC,GAAcpC,EAAMoC,GAAcZ,EAAOW,GAAOG,aAClE,MAAsB,iBAARD,EAAmBpC,EAAKsC,IAAIF,GAAO,IACrD,CACA,OAAO,MAEX,CAACb,IAGL,OACIgB,EAACC,EAAAA,CAASC,mBAAoB,CAAC,gBAC3BF,EAACG,EAAAA,EAAAA,CAAiBC,SAAUX,EAAoBxB,WAAYA,EAAYF,WAAYA,EAAYG,KAAMA,GAAUV,IAG5H,CAEAD,EAAe8C,aAAe,CAC1BC,WAAY"}
1
+ {"version":3,"file":"PhoneInputForm.js","sources":["../../../../../src/components/internal/PhoneInput/PhoneInputForm.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './PhoneInput.scss';\nimport { phoneFormatters, phoneValidationRules } from './validate';\nimport { PhoneInputFormProps, PhoneInputSchema } from './types';\nimport Fieldset from '../FormFields/Fieldset';\nimport PhoneInputFields from './PhoneInputFields';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\n/**\n *\n * @param PhoneInputFormProps\n * @constructor\n */\nfunction PhoneInputForm(props: Readonly<PhoneInputFormProps>) {\n const { i18n } = useCoreContext();\n\n const schema = props.requiredFields || [...(props?.items?.length ? ['phonePrefix'] : []), 'phoneNumber'];\n const showPrefix = schema.includes('phonePrefix') && !!props?.items?.length;\n const showNumber = schema.includes('phoneNumber');\n\n const form = useForm<PhoneInputSchema>({\n i18n,\n ...props,\n schema,\n defaultData: props.data,\n rules: phoneValidationRules,\n formatters: phoneFormatters\n });\n\n useEffect(() => {\n form.setSchema(schema);\n }, [schema.toString()]);\n\n const { data, valid, errors, isValid, triggerValidation } = form;\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const componentRef = useRef<ComponentMethodsRef>({\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n props.setComponentRef(componentRef.current);\n }, [props.setComponentRef]);\n\n // This is here for MBWay, prob should be moved up\n // MBWay has a weird way of loading its error messages\n // They come form the prop phoneNumberErrorKey: 'mobileNumber.invalid'\n // Strangely it's defined as invalidPhoneNumber in the validation rules\n const getPhoneFieldError = useCallback(\n (field: string) => {\n if (errors[field]) {\n const propsField = field === 'phoneNumber' ? 'phoneNumberErrorKey' : 'phonePrefixErrorKey';\n const key = props[propsField] ? props[propsField] : errors[field].errorMessage;\n return i18n.get(key) ?? null;\n }\n return null;\n },\n [errors]\n );\n\n return (\n <Fieldset classNameModifiers={['phone-input']}>\n <PhoneInputFields getError={getPhoneFieldError} showNumber={showNumber} showPrefix={showPrefix} form={form} {...props} />\n </Fieldset>\n );\n}\n\nPhoneInputForm.defaultProps = {\n phoneLabel: 'telephoneNumber'\n};\n\nexport default PhoneInputForm;\n"],"names":["PhoneInputForm","props","i18n","useCoreContext","schema","requiredFields","items","length","showPrefix","includes","showNumber","form","useForm","_object_spread_props","_object_spread","defaultData","data","rules","phoneValidationRules","formatters","phoneFormatters","useEffect","setSchema","toString","valid","errors","isValid","triggerValidation","onChange","componentRef","useRef","showValidation","setComponentRef","current","getPhoneFieldError","useCallback","field","propsField","key","errorMessage","get","h","Fieldset","classNameModifiers","PhoneInputFields","getError","defaultProps","phoneLabel"],"mappings":"oyCAgBA,SAASA,EAAeC,OAGwBA,EACWA,EAHvD,MAAMC,KAAEA,GAASC,IAEXC,EAASH,EAAMI,gBAAkB,KAAKJ,SAAY,QAAZA,EAAAA,EAAOK,aAAPL,IAAAA,SAAAA,EAAcM,QAAS,CAAC,eAAiB,GAAK,eACpFC,EAAaJ,EAAOK,SAAS,mBAAoBR,SAAY,QAAZA,EAAAA,EAAOK,iBAAPL,OAAAA,EAAAA,EAAcM,QAC/DG,EAAaN,EAAOK,SAAS,eAE7BE,EAAOC,EAA0BC,EAAAC,EAAA,CACnCZ,QACGD,GAAAA,CACHG,SACAW,YAAad,EAAMe,KACnBC,MAAOC,EACPC,WAAYC,KAGhBC,EAAU,KACNV,EAAKW,UAAUlB,IAChB,CAACA,EAAOmB,aAEX,MAAMP,KAAEA,EAAIQ,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,kBAAEA,GAAsBhB,EAE5DU,EAAU,KACNpB,EAAM2B,SAAS,CAAEZ,OAAMQ,QAAOC,SAAQC,aACvC,CAACV,EAAMQ,EAAOC,EAAQC,IAEzB,MAAMG,EAAeC,EAA4B,CAC7CC,eAAgBJ,IAGpBN,EAAU,KACNpB,EAAM+B,gBAAgBH,EAAaI,UACpC,CAAChC,EAAM+B,kBAMV,MAAME,EAAqBC,EACtBC,IACG,GAAIX,EAAOW,GAAQ,CAGRlC,IAAAA,EAFP,MAAMmC,EAAuB,gBAAVD,EAA0B,sBAAwB,sBAC/DE,EAAMrC,EAAMoC,GAAcpC,EAAMoC,GAAcZ,EAAOW,GAAOG,aAClE,OAAgBD,QAATpC,EAAAA,EAAKsC,IAAIF,cAATpC,EAAAA,EAAiB,IAC5B,CACA,OAAO,MAEX,CAACuB,IAGL,OACIgB,EAACC,EAAAA,CAASC,mBAAoB,CAAC,gBAC3BF,EAACG,EAAAA,EAAAA,CAAiBC,SAAUX,EAAoBxB,WAAYA,EAAYF,WAAYA,EAAYG,KAAMA,GAAUV,IAG5H,CAEAD,EAAe8C,aAAe,CAC1BC,WAAY"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{useState as n,useRef as o,useEffect as c}from"../../../external/preact/hooks/dist/hooks.js";import{useAmount as l}from"../../../core/Context/AmountProvider.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(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 r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,c={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}if(c=function(e,t){if(null==e)return{};var r,n,o={},c=Object.getOwnPropertyNames(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}function s(s){let{label:p=null,icon:f=null,payButton:b,onSubmit:y,name:O,showPayButton:m,setComponentRef:j}=s,g=i(s,["label","icon","payButton","onSubmit","name","showPayButton","setComponentRef"]);const{i18n:P}=r(),[w,d]=n("ready"),{amount:h}=l(),v=o({setStatus:d});c(()=>{j(v.current)},[j]);if(m)return e(t,null,b(u(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({},g),{status:w,icon:f,classNameModifiers:["standalone"],label:p||(h&&{}.hasOwnProperty.call(h,"value")&&0===h.value?`${P.get("preauthorizeWith")} ${O}`:`${P.get("continueTo")} ${O}`),onClick:y})))}export{s as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{useState as n}from"../../../external/preact/hooks/dist/hooks.js";import{useAmount as o}from"../../../core/Context/AmountProvider.js";function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(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 r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function a(e,t){if(null==e)return{};var r,n,o,c={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}if(c=function(e,t){if(null==e)return{};var r,n,o={},c=Object.getOwnPropertyNames(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}function i(i){let{label:u=null,icon:s=null,payButton:p,onSubmit:f,name:b,showPayButton:y}=i,O=a(i,["label","icon","payButton","onSubmit","name","showPayButton"]);const{i18n:m}=r(),[j,g]=n("ready"),{amount:P}=o();this.setStatus=e=>{g(e)};if(y)return e(t,null,p(l(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){c(e,t,r[t])})}return e}({},O),{status:j,icon:s,classNameModifiers:["standalone"],label:u||(P&&{}.hasOwnProperty.call(P,"value")&&0===P.value?`${m.get("preauthorizeWith")} ${b}`:`${m.get("continueTo")} ${b}`),onClick:f})))}export{i as default};
2
2
  //# sourceMappingURL=RedirectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectButton.js","sources":["../../../../../src/components/internal/RedirectButton/RedirectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport interface RedirectButtonProps {\n label?: string;\n icon?: string;\n payButton: Function;\n onSubmit: Function;\n name: string;\n showPayButton: boolean;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\nfunction RedirectButton({\n label = null,\n icon = null,\n payButton,\n onSubmit,\n name,\n showPayButton,\n setComponentRef,\n ...props\n}: Readonly<RedirectButtonProps>) {\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { amount } = useAmount();\n\n const redirectButtonRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus\n });\n\n useEffect(() => {\n setComponentRef(redirectButtonRef.current);\n }, [setComponentRef]);\n\n const payButtonLabel = () => {\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n if (isZeroAuth) return `${i18n.get('preauthorizeWith')} ${name}`;\n return `${i18n.get('continueTo')} ${name}`;\n };\n\n if (!showPayButton) {\n return;\n }\n\n return (\n <Fragment>\n {payButton({\n ...props,\n status,\n icon,\n classNameModifiers: ['standalone'],\n label: label || payButtonLabel(),\n onClick: onSubmit\n })}\n </Fragment>\n );\n}\n\nexport default RedirectButton;\n"],"names":["RedirectButton","_0","label","icon","payButton","onSubmit","name","showPayButton","setComponentRef","props","i18n","useCoreContext","status","setStatus","useState","amount","useAmount","redirectButtonRef","useRef","useEffect","current","h","Fragment","_object_spread_props","_object_spread","classNameModifiers","hasOwnProperty","call","value","get","onClick"],"mappings":"k6CAgBA,SAASA,EAAeC,GAAA,IAAAC,MACpBA,EAAQ,KAAIC,KACZA,EAAO,KAAIC,UACXA,EAASC,SACTA,EAAQC,KACRA,EAAIC,cACJA,EAAaC,gBACbA,GAE4BP,EADzBQ,EAAAA,EAAAA,EAAAA,kFAEH,MAAMC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,OAAEA,GAAWC,IAEbC,EAAoBC,EAA4B,CAClDL,UAAWA,IAGfM,EAAU,KACNX,EAAgBS,EAAkBG,UACnC,CAACZ,IAQJ,GAAKD,EAIL,OACIc,EAACC,EAAAA,KACIlB,EAAUmB,oUAAAC,CAAA,GACJf,GAAAA,CACHG,SACAT,OACAsB,mBAAoB,CAAC,cACrBvB,MAAOA,IAhBIa,GAAU,CAAC,EAAEW,eAAeC,KAAKZ,EAAQ,UAA6B,IAAjBA,EAAOa,MACxD,GAAGlB,EAAKmB,IAAI,uBAAuBvB,IACnD,GAAGI,EAAKmB,IAAI,iBAAiBvB,KAe5BwB,QAASzB,KAIzB"}
1
+ {"version":3,"file":"RedirectButton.js","sources":["../../../../../src/components/internal/RedirectButton/RedirectButton.tsx"],"sourcesContent":["import { h, Fragment, Ref } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { useState } from 'preact/hooks';\nimport { useAmount } from '../../../core/Context/AmountProvider';\n\n// TODO this should ideally be remove but we need let prop propagate down\n// probably not worth changing this behaviour now\nexport interface RedirectButtonProps {\n label?: string;\n icon?: string;\n payButton: Function;\n onSubmit: Function;\n name: string;\n showPayButton: boolean;\n ref?: Ref<typeof RedirectButton>;\n}\n\nfunction RedirectButton({ label = null, icon = null, payButton, onSubmit, name, showPayButton, ...props }: Readonly<RedirectButtonProps>) {\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { amount } = useAmount();\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const payButtonLabel = () => {\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n if (isZeroAuth) return `${i18n.get('preauthorizeWith')} ${name}`;\n return `${i18n.get('continueTo')} ${name}`;\n };\n\n if (!showPayButton) {\n return;\n }\n\n return (\n <Fragment>\n {payButton({\n ...props,\n status,\n icon,\n classNameModifiers: ['standalone'],\n label: label || payButtonLabel(),\n onClick: onSubmit\n })}\n </Fragment>\n );\n}\n\nexport default RedirectButton;\n"],"names":["RedirectButton","_0","label","icon","payButton","onSubmit","name","showPayButton","props","i18n","useCoreContext","status","setStatus","useState","amount","useAmount","this","newStatus","h","Fragment","_object_spread_props","_object_spread","classNameModifiers","hasOwnProperty","call","value","get","onClick"],"mappings":"u4CAiBA,SAASA,EAAeC,GAAA,IAAAC,MAAEA,EAAQ,KAAIC,KAAEA,EAAO,KAAIC,UAAEA,EAASC,SAAEA,EAAQC,KAAEA,EAAIC,cAAEA,GAAwDN,EAAtCO,EAAAA,EAAAA,EAAAA,gEAC9F,MAAMC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,OAAEA,GAAWC,IAEnBC,KAAKJ,UAAYK,IACbL,EAAUK,IASd,GAAKV,EAIL,OACIW,EAACC,EAAAA,KACIf,EAAUgB,oUAAAC,CAAA,GACJb,GAAAA,CACHG,SACAR,OACAmB,mBAAoB,CAAC,cACrBpB,MAAOA,IAhBIY,GAAU,CAAC,EAAES,eAAeC,KAAKV,EAAQ,UAA6B,IAAjBA,EAAOW,MACxD,GAAGhB,EAAKiB,IAAI,uBAAuBpB,IACnD,GAAGG,EAAKiB,IAAI,iBAAiBpB,KAe5BqB,QAAStB,KAIzB"}