@adyen/adyen-web 6.35.0 → 6.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/cjs/adyen.css +7 -7
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +2786 -2102
  6. package/dist/es/adyen.css +7 -7
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -1
  9. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  10. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
  13. package/dist/es/components/Card/components/CardInput/components/CVCHint.js +1 -1
  14. package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  17. package/dist/es/components/Donation/Donation.js +1 -1
  18. package/dist/es/components/Donation/Donation.js.map +1 -1
  19. package/dist/es/components/Donation/DonationCampaignService.js +2 -0
  20. package/dist/es/components/Donation/DonationCampaignService.js.map +1 -0
  21. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  22. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  23. package/dist/es/components/Donation/components/utils.js.map +1 -1
  24. package/dist/es/components/Iris/Iris.js +1 -1
  25. package/dist/es/components/Iris/Iris.js.map +1 -1
  26. package/dist/es/components/Iris/types.js.map +1 -1
  27. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  28. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  29. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  30. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  31. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  32. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  33. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  34. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  35. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  36. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  37. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  38. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  39. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  40. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  41. package/dist/es/components/UPI/UPI.js +1 -1
  42. package/dist/es/components/UPI/UPI.js.map +1 -1
  43. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  44. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  45. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  46. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  47. package/dist/es/components/UPI/constants.js +1 -1
  48. package/dist/es/components/UPI/constants.js.map +1 -1
  49. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  50. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  51. package/dist/es/components/internal/Address/Address.js +1 -1
  52. package/dist/es/components/internal/Address/Address.js.map +1 -1
  53. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  56. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  57. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  58. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  59. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  60. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  61. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  62. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  63. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  64. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  65. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  66. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  67. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  69. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  70. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  71. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  72. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  73. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  74. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  75. package/dist/es/components/internal/UIElement/utils.js +1 -1
  76. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  77. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  78. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  79. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  80. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  81. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  82. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  83. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  84. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  85. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  86. package/dist/es/core/Services/sessions/constants.js +1 -1
  87. package/dist/es/core/Services/sessions/constants.js.map +1 -1
  88. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  89. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  90. package/dist/es/core/Services/sessions/make-donation.js +2 -0
  91. package/dist/es/core/Services/sessions/make-donation.js.map +1 -0
  92. package/dist/es/core/config.js +1 -1
  93. package/dist/es/core/config.js.map +1 -1
  94. package/dist/es/core/core.registry.js +1 -1
  95. package/dist/es/core/core.registry.js.map +1 -1
  96. package/dist/es/core/utils.js +1 -1
  97. package/dist/es/core/utils.js.map +1 -1
  98. package/dist/es/index.d.ts +2786 -2102
  99. package/dist/es-legacy/adyen.css +7 -7
  100. package/dist/es-legacy/adyen.css.map +1 -1
  101. package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -1
  102. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  103. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  104. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
  105. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
  106. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js +1 -1
  107. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  108. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  109. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  110. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  111. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  112. package/dist/es-legacy/components/Donation/DonationCampaignService.js +2 -0
  113. package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -0
  114. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  115. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  116. package/dist/es-legacy/components/Donation/components/utils.js.map +1 -1
  117. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  118. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  119. package/dist/es-legacy/components/Iris/types.js.map +1 -1
  120. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  121. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  122. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  123. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  124. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  125. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  126. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  127. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  128. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  129. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  130. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  131. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  132. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  133. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  134. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  135. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  136. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  137. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  138. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  139. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  140. package/dist/es-legacy/components/UPI/constants.js +1 -1
  141. package/dist/es-legacy/components/UPI/constants.js.map +1 -1
  142. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  143. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  144. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  145. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  146. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  147. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  148. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  149. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  150. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  151. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  152. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  153. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  154. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  155. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  156. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  157. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  158. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  159. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  160. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  161. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  162. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  163. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  164. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  165. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  166. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  167. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  168. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  169. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  170. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  171. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  172. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  173. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  174. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  175. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
  176. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  177. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  178. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  179. package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
  180. package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
  181. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  182. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  183. package/dist/es-legacy/core/Services/sessions/make-donation.js +2 -0
  184. package/dist/es-legacy/core/Services/sessions/make-donation.js.map +1 -0
  185. package/dist/es-legacy/core/config.js +1 -1
  186. package/dist/es-legacy/core/config.js.map +1 -1
  187. package/dist/es-legacy/core/core.registry.js +1 -1
  188. package/dist/es-legacy/core/core.registry.js.map +1 -1
  189. package/dist/es-legacy/core/utils.js +1 -1
  190. package/dist/es-legacy/core/utils.js.map +1 -1
  191. package/package.json +20 -20
  192. package/styles/adyen.css +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName);\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton}\n mandate={this.props.mandate}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","_object_spread","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","h","QRLoader","qrCodeData","encodeURIComponent","brandLogo","onComplete","introduction","i18n","get","countdownTime","onActionHandled","showAmount","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","_this_core_modules_resources","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"m9CAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,OAAOC,EAAA,CACHC,0BAA2BC,KACxBH,EAEX,CAEA,WAAWI,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH,MAAMC,IAAEA,GAAQH,KAAKC,MAAMG,MAAQ,CAAA,EAEnC,MAAO,CACHC,cAAeT,EAAA,CACXU,KAAMN,KAAKO,aACPP,KAAKO,cAAgBC,EAAWC,aAAcN,aAAAA,EAAAA,EAAKO,KAAM,CAAEC,MAAOR,EAAIO,KAGtF,CAEA,UAAIE,GACA,MAAMC,4BAAEA,GAAgCb,KAAKL,MAE7C,OAAKkB,EAIEb,KAAKc,SAASC,IAAIZ,KAAUa,KAAMb,EAAIa,KAAMC,KAAMd,EAAIc,QAHlD,EAIf,CAEA,eAAIV,GACA,OAAIP,KAAKkB,OAASC,EAASC,QAChBZ,EAAWa,OAEfb,EAAWC,UACtB,CAEmBa,iBAAAA,GACf,MAAMhB,KAAEA,EAAIiB,IAA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B+D,EAAgBD,EAAKE,OAAS,EAEpC3D,KAAKkB,KAAOpB,KAAc4D,EAAgBvC,EAASyC,OAASzC,EAASC,QAErEpB,KAAKc,SAAW2C,EAAK1C,IAAIZ,IAEH,IAAA0D,EADlB,MAAMC,EAAY,OAAO3D,EAAIO,GAAGqD,gBAC1BC,EAAuC,QAA3BH,EAAA7D,KAAKiE,KAAKC,QAAQC,iBAAlB,IAAAN,OAAA,EAAAA,EAA6BO,UAA7BP,CAAwCC,GAC1D,MAAO,CAAEpD,GAAIP,EAAIO,GAAIO,KAAMd,EAAIc,KAAMD,KAAMgD,IAEnD,EAtBAR,EADEhE,EACqBc,OAAOE,EAAW6D,KACzCb,EAFEhE,EAEqB8E,aAAa,CAAC9D,EAAW6D,IAAK7D,EAAWa,OAAQb,EAAWC,aAInF+C,EANEhE,EAMwB+E,eAAe,CACrC1D,6BAA6B,EAC7BuB,cAAeoC"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { Await } from '../internal/Await';\nimport { QRLoader } from '../internal/QRLoader';\nimport { UPIAppList, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport { UPI_COUNTDOWN_TIME, UPI_MODE } from './constants';\nimport { PaymentMethodBrand } from '../../types/global-types';\nimport { ICore } from '../../types';\n\n/**\n * For mobile:\n * We should show upi_intent depending on if `apps` are returned in /paymentMethods response.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * Show upi_qr as default\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static readonly type = TxVariants.upi;\n public static readonly txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_intent];\n private readonly mode: UpiMode;\n private readonly appsList: UPIAppList;\n\n protected static readonly defaultProps = {\n showPaymentMethodItemImages: true,\n countdownTime: UPI_COUNTDOWN_TIME\n };\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n const { apps = [] } = this.props;\n const hasIntentApps = apps.length > 0;\n\n this.mode = isMobile() && hasIntentApps ? UPI_MODE.INTENT : UPI_MODE.QR_CODE;\n\n this.appsList = apps.map(app => {\n const imageName = `upi/${app.id.toLowerCase()}`;\n const brandIcon = this.core.modules.resources?.getImage()(imageName) ?? '';\n return { id: app.id, name: app.name, icon: brandIcon };\n });\n }\n\n protected formatProps(props: UPIConfiguration): UPIConfiguration {\n return {\n showOtherInsteadOfNumber: !isMobile(),\n ...props\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get brands(): PaymentMethodBrand[] {\n const { showPaymentMethodItemImages } = this.props;\n\n if (!showPaymentMethodItemImages) {\n return [];\n }\n\n return this.appsList.map(app => ({ icon: app.icon, name: app.name }));\n }\n\n get paymentType(): UpiType {\n if (this.mode === UPI_MODE.QR_CODE) {\n return TxVariants.upi_qr;\n }\n return TxVariants.upi_intent;\n }\n\n protected override componentToRender(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n\n const isAutoPay = !!this.props.mandate;\n\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : undefined}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n?.get('upi.qrCodeWaitingMessage') ?? ''}\n countdownTime={this.props.countdownTime}\n onActionHandled={this.onActionHandled}\n showAmount={!isAutoPay}\n />\n );\n case 'await':\n return (\n <Await\n url={url}\n type={paymentMethodType ?? ''}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount={!isAutoPay}\n countdownTime={this.props.countdownTime}\n clientKey={this.props.clientKey ?? ''}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n?.get('upi.vpaWaitingMessage') ?? ''}\n awaitText={this.props.i18n?.get('await.waitForConfirmation') ?? ''}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n setComponentRef={this.setComponentRef}\n payButton={this.payButton}\n onChange={this.setState}\n appsList={this.appsList}\n mode={this.mode}\n showPayButton={this.props.showPayButton ?? true}\n mandate={this.props.mandate}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","_object_spread","showOtherInsteadOfNumber","isMobile","isValid","this","state","formatData","app","data","paymentMethod","type","paymentType","TxVariants","upi_intent","id","appId","brands","showPaymentMethodItemImages","appsList","map","icon","name","mode","UPI_MODE","QR_CODE","upi_qr","componentToRender","url","paymentMethodType","isAutoPay","mandate","_this_props_i18n","h","QRLoader","qrCodeData","encodeURIComponent","undefined","brandLogo","onComplete","introduction","_ref","i18n","get","countdownTime","onActionHandled","showAmount","_this_props_clientKey","_ref1","_ref2","_this_props_i18n1","_this_props_i18n2","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","_this_props_showPayButton","UPIComponent","setComponentRef","payButton","onChange","setState","showPayButton","onSubmitAnalytics","submitAnalytics","constructor","checkout","super","_define_property","apps","hasIntentApps","length","INTENT","_this_core_modules_resources","imageName","toLowerCase","brandIcon","core","modules","resources","getImage","upi","txVariants","defaultProps","UPI_COUNTDOWN_TIME"],"mappings":"m9CAqBA,MAAMA,UAAYC,EAyBJC,WAAAA,CAAYC,GAClB,OAAOC,EAAA,CACHC,0BAA2BC,KACxBH,EAEX,CAEA,WAAWI,GACP,OAAOC,KAAKC,MAAMF,OACtB,CAEOG,UAAAA,GACH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O,CAAE/D,GAAIP,EAAIO,GAAIO,KAAMd,EAAIc,KAAMD,KAAM2D,IAEnD,EAtBAR,EADE3E,EACqBc,OAAOE,EAAWwE,KACzCb,EAFE3E,EAEqByF,aAAa,CAACzE,EAAWwE,IAAKxE,EAAWa,OAAQb,EAAWC,aAInF0D,EANE3E,EAMwB0F,eAAe,CACrCrE,6BAA6B,EAC7B0B,cAAe4C"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as n,useRef as r,useEffect as o,useCallback as a,useMemo as s}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../../../../core/Context/useImage.js";import{UPI_MODE as l,A11Y as c}from"../../constants.js";import"../../../../_virtual/index.js";import{SegmentedControlRegion as d}from"../../../internal/SegmentedControl/SegmentedControlRegion.js";import u from"../UPIIntentAppList/UPIIntentAppList.js";import{useCoreContext as p}from"../../../../core/Context/CoreProvider.js";import m from"../../../internal/Alert/Alert.js";import f from"../UPIMandate/UPIMandate.js";import{useAmount as b}from"../../../../core/Context/AmountProvider.js";import{BrandIcons as g}from"../../../internal/BrandIcons/BrandIcons.js";function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){y(e,t,n[t])})}return e}function j({mode:y,onChange:j,payButton:h,setComponentRef:C,showPayButton:N,mandate:O,appsList:E}){const{i18n:P}=p(),v=i(),[A,B]=n("ready"),[k,R]=n(null),{amount:S}=b(),[T,w]=n(y===l.QR_CODE),x=O&&e(f,{mandate:O,amount:S}),L=r({setStatus:B,showValidation:()=>{y===l.INTENT&&D()}});o(()=>{C(L.current)},[C]);const Q=a(e=>{(null==e?void 0:e.id)!==(null==k?void 0:k.id)&&(R(e),w(!0),B("ready"))},[k]),D=a(()=>{k?(B("ready"),w(!0)):(B("error"),w(!1))},[k]),M=s(()=>E.map(e=>({src:e.icon,alt:e.name})),[E]);return o(()=>{y!==l.QR_CODE?j({data:I({},k&&{app:k}),isValid:T}):j({data:{},valid:{},errors:{},isValid:!0})},[k,T,y,j]),e(t,null,y===l.INTENT&&e(d,{id:c.AreaId.INTENT,ariaLabelledBy:c.ButtonId.INTENT,className:"adyen-checkout-upi-area-intent"},e("span",{className:"adyen-checkout-upi-instruction-label"},P.get("upi.intent.instruction")),"error"===A&&e(m,{icon:"cross"},P.get("upi.error.noAppSelected")),e(u,{disabled:"loading"===A,appsList:E,selectedAppId:null==k?void 0:k.id,onAppSelect:Q}),x,N&&h({label:P.get("continue"),status:A})),y===l.QR_CODE&&e(d,{id:c.AreaId.QR,ariaLabelledBy:c.ButtonId.QR,className:"adyen-checkout-upi-area-qr-code"},e("span",{className:"adyen-checkout-upi-instruction-label"},P.get("upi.qrCode.instruction")),e(g,{className:"adyen-checkout-upi-brands",brandIcons:M,showIconOnError:!0,smallIcons:!0,remainingBrandsLabel:`+ ${P.get("paymentMethodBrand.other")}`}),x,N&&h({label:P.get("generateQRCode"),icon:v({imageFolder:"components/"})("qr"),status:A})))}export{j as default};
1
+ import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as n,useRef as a,useMemo as o,useEffect as r,useCallback as i}from"../../../../external/preact/hooks/dist/hooks.js";import s from"../../../../core/Context/useImage.js";import{MAX_PRIMARY_APPS as l,UPI_MODE as p,A11Y as c}from"../../constants.js";import"../../../../_virtual/index.js";import{SegmentedControlRegion as d}from"../../../internal/SegmentedControl/SegmentedControlRegion.js";import u from"../UPIIntentAppList/UPIIntentAppList.js";import{useCoreContext as m}from"../../../../core/Context/CoreProvider.js";import f from"../../../internal/Alert/Alert.js";import g from"../UPIMandate/UPIMandate.js";import{useAmount as y}from"../../../../core/Context/AmountProvider.js";import{BrandIcons as b}from"../../../internal/BrandIcons/BrandIcons.js";import h from"../../../internal/ContentSeparator/ContentSeparator.js";import I from"../../../internal/FormFields/Field/Field.js";import j from"../../../internal/FormFields/Select/Select.js";import{AnalyticsInfoEvent as N,InfoEventType as C,UiTarget as v}from"../../../../core/Analytics/events/AnalyticsInfoEvent.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as S}from"../../../../core/Analytics/constants.js";import{debounce as A}from"../../../../utils/debounce.js";function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){w(e,t,n[t])})}return e}function k({mode:w,onChange:k,payButton:O,setComponentRef:T,showPayButton:P,mandate:_,appsList:B,onSubmitAnalytics:L}){const{i18n:R}=m(),x=s(),[F,Q]=n("ready"),[M,V]=n(null),{amount:D}=y(),[U,q]=n(w===p.QR_CODE),$=_&&e(g,{mandate:_,amount:D}),z=a({setStatus:Q,showValidation:()=>{w===p.INTENT&&ee()}}),G=o(()=>B.slice(0,l),[B]),H=o(()=>B.slice(l),[B]);r(()=>{T(z.current)},[T]);const J=i((e,t)=>{e&&e.id!==(null==M?void 0:M.id)&&(V(e),q(!0),Q("ready"),L(new N({component:"upi_intent",type:C.selected,target:t,issuer:e.name})))},[M,L]),K=i(e=>J(e,v.list),[J]),W=i(e=>{const t=H.find(t=>t.id===e.target.value);J(t,v.listSearch)},[H,J]),X=i(e=>{e&&L(new N({component:"upi_intent",type:C.displayed,target:v.list}))},[L]),Y=a(A(L,S)),Z=i(()=>{Y.current({type:C.input,target:v.listSearch})},[]),ee=i(()=>{M?(Q("ready"),q(!0)):(Q("error"),q(!1))},[M]),te=o(()=>B.map(e=>({src:e.icon,alt:e.name})),[B]);return r(()=>{w!==p.QR_CODE?k({data:E({},M&&{app:M}),isValid:U}):k({data:{},valid:{},errors:{},isValid:!0})},[M,U,w,k]),r(()=>{w===p.INTENT&&0!==G.length&&L(new N({component:"upi_intent",type:C.displayed,target:v.list,presentedValues:G.map(e=>e.id)}))},[]),e(t,null,w===p.INTENT&&e(d,{id:c.AreaId.INTENT,ariaLabelledBy:c.ButtonId.INTENT,className:"adyen-checkout-upi-area-intent"},e("span",{className:"adyen-checkout-upi-instruction-label"},R.get("upi.intent.instruction")),e("span",{className:"adyen-checkout-upi-instruction-title"},R.get("upi.intent.apps.title")),"error"===F&&e(f,{icon:"cross"},R.get("upi.error.noAppSelected")),e(u,{disabled:"loading"===F,appsList:G,selectedAppId:null==M?void 0:M.id,onAppSelect:K}),H.length>0&&e(t,null,e(h,{classNames:["adyen-checkout-upi-instruction-separator"],label:"issuerList.separatorText"}),e(I,{label:R.get("upi.intent.apps.dropdown.label"),classNameModifiers:["upi-app-list"],name:"upi-app-list"},e(j,{items:H,selectedValue:H.some(e=>e.id===(null==M?void 0:M.id))?null==M?void 0:M.id:void 0,placeholder:R.get("upi.intent.apps.dropdown.placeholder"),name:"upi-app-list",className:"adyen-checkout__upi-app-list__dropdown",onChange:W,onInput:Z,onListToggle:X}))),$,P&&O({label:R.get("continue"),status:F})),w===p.QR_CODE&&e(d,{id:c.AreaId.QR,ariaLabelledBy:c.ButtonId.QR,className:"adyen-checkout-upi-area-qr-code"},e("span",{className:"adyen-checkout-upi-instruction-label-caption"},R.get("upi.qrCode.instruction")),e(b,{className:"adyen-checkout-upi-brands",brandIcons:te,showIconOnError:!0,smallIcons:!0,remainingBrandsLabel:`+ ${R.get("paymentMethodBrand.other")}`}),$,P&&O({label:R.get("generateQRCode"),icon:x({imageFolder:"components/"})("qr"),status:F})))}export{k as default};
2
2
  //# sourceMappingURL=UPIComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../types';\nimport { App, UPIAppList, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport { A11Y, UPI_MODE } from '../../constants';\nimport { SegmentedControlRegion } from '../../../internal/SegmentedControl';\nimport UPIIntentAppList from '../UPIIntentAppList';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Alert from '../../../internal/Alert';\nimport UPIMandate, { Mandate } from '../UPIMandate/UPIMandate';\nimport { PayButtonProps } from '../../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../../core/Context/AmountProvider';\nimport { BrandIcon } from '../../../internal/BrandIcons/types';\nimport { BrandIcons } from '../../../internal/BrandIcons/BrandIcons';\nimport { ValidationRuleResult } from '../../../../utils/Validator/ValidationRuleResult';\nimport './UPIComponent.scss';\n\ntype UpiData = { app?: App };\n\ntype OnChangeProps = { data: UpiData; valid?: { [key: string]: boolean }; errors?: { [key: string]: ValidationRuleResult }; isValid: boolean };\ninterface UPIComponentProps {\n mode: UpiMode;\n showPayButton: boolean;\n appsList: UPIAppList;\n mandate?: Mandate;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n payButton(props: PayButtonProps): h.JSX.Element;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n}\n\nexport default function UPIComponent({\n mode,\n onChange,\n payButton,\n setComponentRef,\n showPayButton,\n mandate,\n appsList\n}: Readonly<UPIComponentProps>): h.JSX.Element {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const [selectedApp, setSelectedApp] = useState<App>(null);\n const { amount } = useAmount();\n const [isValid, setIsValid] = useState<boolean>(mode === UPI_MODE.QR_CODE);\n const mandateComponent = mandate && <UPIMandate mandate={mandate} amount={amount} />;\n\n const upiRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n if (mode === UPI_MODE.INTENT) {\n validateIntentApp();\n }\n }\n });\n\n useEffect(() => {\n setComponentRef(upiRef.current);\n }, [setComponentRef]);\n\n const handleAppSelect = useCallback(\n (app: App) => {\n if (app?.id === selectedApp?.id) return;\n\n setSelectedApp(app);\n setIsValid(true);\n setStatus('ready');\n },\n [selectedApp]\n );\n\n const validateIntentApp = useCallback(() => {\n if (selectedApp) {\n setStatus('ready');\n setIsValid(true);\n } else {\n setStatus('error');\n setIsValid(false);\n }\n }, [selectedApp]);\n\n const brandIcons: BrandIcon[] = useMemo(\n () =>\n appsList.map(app => ({\n src: app.icon,\n alt: app.name\n })),\n [appsList]\n );\n\n useEffect(() => {\n if (mode === UPI_MODE.QR_CODE) {\n /**\n * When selecting QR code mode, we need to clear the state data and trigger 'onChange'.\n */\n onChange({ data: {}, valid: {}, errors: {}, isValid: true });\n return;\n }\n onChange({\n data: { ...(selectedApp && { app: selectedApp }) },\n isValid\n });\n }, [selectedApp, isValid, mode, onChange]);\n\n return (\n <Fragment>\n {mode === UPI_MODE.INTENT && (\n <SegmentedControlRegion id={A11Y.AreaId.INTENT} ariaLabelledBy={A11Y.ButtonId.INTENT} className=\"adyen-checkout-upi-area-intent\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.intent.instruction')}</span>\n {status === 'error' && <Alert icon=\"cross\">{i18n.get('upi.error.noAppSelected')}</Alert>}\n <UPIIntentAppList\n disabled={status === 'loading'}\n appsList={appsList}\n selectedAppId={selectedApp?.id}\n onAppSelect={handleAppSelect}\n />\n {mandateComponent}\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </SegmentedControlRegion>\n )}\n {mode === UPI_MODE.QR_CODE && (\n <SegmentedControlRegion id={A11Y.AreaId.QR} ariaLabelledBy={A11Y.ButtonId.QR} className=\"adyen-checkout-upi-area-qr-code\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.qrCode.instruction')}</span>\n <BrandIcons\n className=\"adyen-checkout-upi-brands\"\n brandIcons={brandIcons}\n showIconOnError\n smallIcons\n remainingBrandsLabel={`+ ${i18n.get('paymentMethodBrand.other')}`}\n />\n {mandateComponent}\n {showPayButton &&\n payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status\n })}\n </SegmentedControlRegion>\n )}\n </Fragment>\n );\n}\n"],"names":["UPIComponent","mode","onChange","payButton","setComponentRef","showPayButton","mandate","appsList","i18n","useCoreContext","getImage","useImage","status","setStatus","useState","selectedApp","setSelectedApp","amount","useAmount","isValid","setIsValid","UPI_MODE","QR_CODE","mandateComponent","h","UPIMandate","upiRef","useRef","showValidation","INTENT","validateIntentApp","useEffect","current","handleAppSelect","useCallback","app","id","brandIcons","useMemo","map","src","icon","alt","name","data","_object_spread","valid","errors","Fragment","SegmentedControlRegion","A11Y","AreaId","ariaLabelledBy","ButtonId","className","span","get","Alert","UPIIntentAppList","disabled","selectedAppId","onAppSelect","label","QR","BrandIcons","showIconOnError","smallIcons","remainingBrandsLabel","imageFolder"],"mappings":"4vCA+Be,SAASA,GAAaC,KACjCA,EAAIC,SACJA,EAAQC,UACRA,EAASC,gBACTA,EAAeC,cACfA,EAAaC,QACbA,EAAOC,SACPA,IAEA,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACVC,EAAQC,GAAaC,EAA0B,UAC/CC,EAAaC,GAAkBF,EAAc,OAC9CG,OAAEA,GAAWC,KACZC,EAASC,GAAcN,EAAkBb,IAASoB,EAASC,SAC5DC,EAAmBjB,GAAWkB,EAACC,EAAAA,CAAWnB,QAASA,EAASW,OAAQA,IAEpES,EAASC,EAA4B,CACvCd,UAAWA,EACXe,eAAgB,KACR3B,IAASoB,EAASQ,QAClBC,OAKZC,EAAU,KACN3B,EAAgBsB,EAAOM,UACxB,CAAC5B,IAEJ,MAAM6B,EAAkBC,EACnBC,KACOA,aAAAA,EAAAA,EAAKC,OAAOrB,aAAA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BAAsB,KAAK3D,EAAKgD,IAAI,gCAEvCjC,EACAlB,GACGF,EAAU,CACN2D,MAAOtD,EAAKgD,IAAI,kBAChBf,KAAM/B,EAAS,CAAE0D,YAAa,eAAxB1D,CAAyC,MAC/CE,YAM5B"}
1
+ {"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport { ComponentMethodsRef, UIElementStatus } from '../../../types';\nimport { App, UPIAppList, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport { A11Y, MAX_PRIMARY_APPS, UPI_MODE } from '../../constants';\nimport { SegmentedControlRegion } from '../../../internal/SegmentedControl';\nimport UPIIntentAppList from '../UPIIntentAppList';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Alert from '../../../internal/Alert';\nimport UPIMandate, { Mandate } from '../UPIMandate/UPIMandate';\nimport { PayButtonProps } from '../../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../../core/Context/AmountProvider';\nimport { BrandIcon } from '../../../internal/BrandIcons/types';\nimport { BrandIcons } from '../../../internal/BrandIcons/BrandIcons';\nimport { ValidationRuleResult } from '../../../../utils/Validator/ValidationRuleResult';\nimport './UPIComponent.scss';\nimport ContentSeparator from '../../../internal/ContentSeparator';\nimport Field from '../../../internal/FormFields/Field';\nimport Select from '../../../internal/FormFields/Select';\nimport { SelectTargetObject } from '../../../internal/FormFields/Select/types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../../core/Analytics/constants';\nimport { debounce } from '../../../../utils/debounce';\n\ntype UpiData = { app?: App };\n\ntype OnChangeProps = { data: UpiData; valid?: { [key: string]: boolean }; errors?: { [key: string]: ValidationRuleResult }; isValid: boolean };\ninterface UPIComponentProps {\n mode: UpiMode;\n showPayButton: boolean;\n appsList: UPIAppList;\n mandate?: Mandate;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n payButton(props: PayButtonProps): h.JSX.Element;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSubmitAnalytics(event: AbstractAnalyticsEvent): void;\n}\n\nexport default function UPIComponent({\n mode,\n onChange,\n payButton,\n setComponentRef,\n showPayButton,\n mandate,\n appsList,\n onSubmitAnalytics\n}: Readonly<UPIComponentProps>): h.JSX.Element {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const [selectedApp, setSelectedApp] = useState<App | null>(null);\n const { amount } = useAmount();\n const [isValid, setIsValid] = useState<boolean>(mode === UPI_MODE.QR_CODE);\n const mandateComponent = mandate && <UPIMandate mandate={mandate} amount={amount} />;\n\n const upiRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n if (mode === UPI_MODE.INTENT) {\n validateIntentApp();\n }\n }\n });\n\n const priorityApps = useMemo(() => appsList.slice(0, MAX_PRIMARY_APPS), [appsList]);\n const lowPriorityApps = useMemo(() => appsList.slice(MAX_PRIMARY_APPS), [appsList]);\n\n useEffect(() => {\n setComponentRef(upiRef.current);\n }, [setComponentRef]);\n\n const selectApp = useCallback(\n (app: App | undefined, target: UiTarget) => {\n if (!app || app.id === selectedApp?.id) return;\n\n setSelectedApp(app);\n setIsValid(true);\n setStatus('ready');\n\n onSubmitAnalytics(\n new AnalyticsInfoEvent({\n component: 'upi_intent',\n type: InfoEventType.selected,\n target,\n issuer: app.name\n })\n );\n },\n [selectedApp, onSubmitAnalytics]\n );\n\n const handleAppSelect = useCallback((app: App) => selectApp(app, UiTarget.list), [selectApp]);\n\n const handleDropdownSelect = useCallback(\n (event: { target: SelectTargetObject }) => {\n const app = lowPriorityApps.find(a => a.id === event.target.value);\n selectApp(app, UiTarget.listSearch);\n },\n [lowPriorityApps, selectApp]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n onSubmitAnalytics(\n new AnalyticsInfoEvent({\n component: 'upi_intent',\n type: InfoEventType.displayed,\n target: UiTarget.list\n })\n );\n }\n },\n [onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n const validateIntentApp = useCallback(() => {\n if (selectedApp) {\n setStatus('ready');\n setIsValid(true);\n } else {\n setStatus('error');\n setIsValid(false);\n }\n }, [selectedApp]);\n\n const brandIcons: BrandIcon[] = useMemo(\n () =>\n appsList.map(app => ({\n src: app.icon,\n alt: app.name\n })),\n [appsList]\n );\n\n useEffect(() => {\n if (mode === UPI_MODE.QR_CODE) {\n /**\n * When selecting QR code mode, we need to clear the state data and trigger 'onChange'.\n */\n onChange({ data: {}, valid: {}, errors: {}, isValid: true });\n return;\n }\n onChange({\n data: { ...(selectedApp && { app: selectedApp }) },\n isValid\n });\n }, [selectedApp, isValid, mode, onChange]);\n\n useEffect(() => {\n if (mode !== UPI_MODE.INTENT || priorityApps.length === 0) return;\n\n onSubmitAnalytics(\n new AnalyticsInfoEvent({\n component: 'upi_intent',\n type: InfoEventType.displayed,\n target: UiTarget.list,\n presentedValues: priorityApps.map(a => a.id)\n })\n );\n }, []);\n\n return (\n <Fragment>\n {mode === UPI_MODE.INTENT && (\n <SegmentedControlRegion id={A11Y.AreaId.INTENT} ariaLabelledBy={A11Y.ButtonId.INTENT} className=\"adyen-checkout-upi-area-intent\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.intent.instruction')}</span>\n <span className=\"adyen-checkout-upi-instruction-title\">{i18n.get('upi.intent.apps.title')}</span>\n {status === 'error' && <Alert icon={'cross'}>{i18n.get('upi.error.noAppSelected')}</Alert>}\n <UPIIntentAppList\n disabled={status === 'loading'}\n appsList={priorityApps}\n selectedAppId={selectedApp?.id}\n onAppSelect={handleAppSelect}\n />\n {lowPriorityApps.length > 0 && (\n <Fragment>\n <ContentSeparator classNames={['adyen-checkout-upi-instruction-separator']} label=\"issuerList.separatorText\" />\n <Field label={i18n.get('upi.intent.apps.dropdown.label')} classNameModifiers={['upi-app-list']} name={'upi-app-list'}>\n <Select\n items={lowPriorityApps}\n selectedValue={lowPriorityApps.some(a => a.id === selectedApp?.id) ? selectedApp?.id : undefined}\n placeholder={i18n.get('upi.intent.apps.dropdown.placeholder')}\n name={'upi-app-list'}\n className={'adyen-checkout__upi-app-list__dropdown'}\n onChange={handleDropdownSelect}\n onInput={handleSearch}\n onListToggle={handleListToggle}\n />\n </Field>\n </Fragment>\n )}\n {mandateComponent}\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </SegmentedControlRegion>\n )}\n {mode === UPI_MODE.QR_CODE && (\n <SegmentedControlRegion id={A11Y.AreaId.QR} ariaLabelledBy={A11Y.ButtonId.QR} className=\"adyen-checkout-upi-area-qr-code\">\n <span className=\"adyen-checkout-upi-instruction-label-caption\">{i18n.get('upi.qrCode.instruction')}</span>\n <BrandIcons\n className=\"adyen-checkout-upi-brands\"\n brandIcons={brandIcons}\n showIconOnError\n smallIcons\n remainingBrandsLabel={`+ ${i18n.get('paymentMethodBrand.other')}`}\n />\n {mandateComponent}\n {showPayButton &&\n payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status\n })}\n </SegmentedControlRegion>\n )}\n </Fragment>\n );\n}\n"],"names":["UPIComponent","mode","onChange","payButton","setComponentRef","showPayButton","mandate","appsList","onSubmitAnalytics","i18n","useCoreContext","getImage","useImage","status","setStatus","useState","selectedApp","setSelectedApp","amount","useAmount","isValid","setIsValid","UPI_MODE","QR_CODE","mandateComponent","h","UPIMandate","upiRef","useRef","showValidation","INTENT","validateIntentApp","priorityApps","useMemo","slice","MAX_PRIMARY_APPS","lowPriorityApps","useEffect","current","selectApp","useCallback","app","target","id","AnalyticsInfoEvent","component","type","InfoEventType","selected","issuer","name","handleAppSelect","UiTarget","list","handleDropdownSelect","event","find","a","value","listSearch","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","input","brandIcons","map","src","icon","alt","data","_object_spread","valid","errors","length","presentedValues","Fragment","SegmentedControlRegion","A11Y","AreaId","ariaLabelledBy","ButtonId","className","span","get","Alert","UPIIntentAppList","disabled","selectedAppId","onAppSelect","ContentSeparator","classNames","label","Field","classNameModifiers","Select","items","selectedValue","some","undefined","placeholder","onInput","onListToggle","QR","BrandIcons","showIconOnError","smallIcons","remainingBrandsLabel","imageFolder"],"mappings":"guDAwCe,SAASA,GAAaC,KACjCA,EAAIC,SACJA,EAAQC,UACRA,EAASC,gBACTA,EAAeC,cACfA,EAAaC,QACbA,EAAOC,SACPA,EAAQC,kBACRA,IAEA,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACVC,EAAQC,GAAaC,EAA0B,UAC/CC,EAAaC,GAAkBF,EAAqB,OACrDG,OAAEA,GAAWC,KACZC,EAASC,GAAcN,EAAkBd,IAASqB,EAASC,SAC5DC,EAAmBlB,GAAWmB,EAACC,EAAAA,CAAWpB,QAASA,EAASY,OAAQA,IAEpES,EAASC,EAA4B,CACvCd,UAAWA,EACXe,eAAgB,KACR5B,IAASqB,EAASQ,QAClBC,QAKNC,EAAeC,EAAQ,IAAM1B,EAAS2B,MAAM,EAAGC,GAAmB,CAAC5B,IACnE6B,EAAkBH,EAAQ,IAAM1B,EAAS2B,MAAMC,GAAmB,CAAC5B,IAEzE8B,EAAU,KACNjC,EAAgBuB,EAAOW,UACxB,CAAClC,IAEJ,MAAMmC,EAAYC,EACd,CAACC,EAAsBC,KACdD,GAAOA,EAAIE,MAAO3B,aAAAA,EAAAA,EAAa2B,M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,EAAAA,CACGtB,UAAU,4BACVjB,WAAYA,GACZwC,iBAAAA,EACAC,YAAAA,EACAC,qBAAsB,KAAKrG,EAAK8E,IAAI,gCAEvC/D,EACAnB,GACGF,EAAU,CACN4F,MAAOtF,EAAK8E,IAAI,kBAChBhB,KAAM5D,EAAS,CAAEoG,YAAa,eAAxBpG,CAAyC,MAC/CE,YAM5B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import a from"./UPIIntentAppItem/UPIIntentAppItem.js";import{useCoreContext as p}from"../../../../core/Context/CoreProvider.js";const i=({appsList:i,selectedAppId:r,disabled:o,onAppSelect:n})=>{const{i18n:s}=p();return e("ul",{className:t({"adyen-checkout-upi-app-list":!0,"adyen-checkout-upi-app-list--loading":o}),role:"radiogroup","aria-label":s.get("paymentMethodsList.aria.label")},i.map(t=>{const p=`adyen-checkout-upi-app-item-${t.id}`,i=r===t.id;return e(a,{key:p,app:{id:t.id,name:t.name},imgSrc:t.icon,isSelected:i,onSelect:n})}))};export{i as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import p from"./UPIIntentAppItem/UPIIntentAppItem.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";const r=({appsList:r,selectedAppId:i,disabled:o,onAppSelect:n})=>{const{i18n:s}=a();return e("ul",{className:t({"adyen-checkout-upi-app-list":!0,"adyen-checkout-upi-app-list--loading":o}),role:"radiogroup","aria-label":s.get("paymentMethodsList.aria.label")},r.map(t=>{const a=`adyen-checkout-upi-app-item-${t.id}`,r=i===t.id;return e(p,{key:a,app:t,imgSrc:t.icon,isSelected:r,onSelect:n})}))};export{r as default};
2
2
  //# sourceMappingURL=UPIIntentAppList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UPIIntentAppList.js","sources":["../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { App, UPIAppList } from '../../types';\nimport UPIIntentAppItem from './UPIIntentAppItem';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './UPIIntentAppList.scss';\n\ninterface UPIIntentAppListProps {\n appsList: UPIAppList;\n selectedAppId?: string;\n disabled?: boolean;\n onAppSelect: (app: App) => void;\n}\n\nconst UPIIntentAppList = ({ appsList, selectedAppId, disabled, onAppSelect }: Readonly<UPIIntentAppListProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n\n return (\n /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n <ul\n className={classNames({\n 'adyen-checkout-upi-app-list': true,\n 'adyen-checkout-upi-app-list--loading': disabled\n })}\n role=\"radiogroup\"\n aria-label={i18n.get('paymentMethodsList.aria.label')}\n >\n {appsList.map(app => {\n const key = `adyen-checkout-upi-app-item-${app.id}`;\n const isSelected = selectedAppId === app.id;\n return (\n <UPIIntentAppItem\n key={key}\n app={{ id: app.id, name: app.name }}\n imgSrc={app.icon}\n isSelected={isSelected}\n onSelect={onAppSelect}\n />\n );\n })}\n </ul>\n );\n};\n\nexport default UPIIntentAppList;\n"],"names":["UPIIntentAppList","appsList","selectedAppId","disabled","onAppSelect","i18n","useCoreContext","h","ul","className","classNames","role","aria-label","get","map","app","key","id","isSelected","UPIIntentAppItem","name","imgSrc","icon","onSelect"],"mappings":"wPAcA,MAAMA,EAAmB,EAAGC,WAAUC,gBAAeC,WAAUC,kBAC3D,MAAMC,KAAEA,GAASC,IAEjB,OAEIC,EAACC,KAAAA,CACGC,UAAWC,EAAW,CAClB,+BAA+B,EAC/B,uCAAwCP,IAE5CQ,KAAK,aACLC,aAAYP,EAAKQ,IAAI,kCAEpBZ,EAASa,IAAIC,IACV,MAAMC,EAAM,+BAA+BD,EAAIE,KACzCC,EAAahB,IAAkBa,EAAIE,GACzC,OACIV,EAACY,EAAAA,CACGH,IAAKA,EACLD,IAAK,CAAEE,GAAIF,EAAIE,GAAIG,KAAML,EAAIK,MAC7BC,OAAQN,EAAIO,KACZJ,WAAYA,EACZK,SAAUnB"}
1
+ {"version":3,"file":"UPIIntentAppList.js","sources":["../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { App, UPIAppList } from '../../types';\nimport UPIIntentAppItem from './UPIIntentAppItem';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './UPIIntentAppList.scss';\n\ninterface UPIIntentAppListProps {\n appsList: UPIAppList;\n selectedAppId?: string;\n disabled?: boolean;\n onAppSelect: (app: App) => void;\n}\n\nconst UPIIntentAppList = ({ appsList, selectedAppId, disabled, onAppSelect }: Readonly<UPIIntentAppListProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n\n return (\n /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n <ul\n className={classNames({\n 'adyen-checkout-upi-app-list': true,\n 'adyen-checkout-upi-app-list--loading': disabled\n })}\n role=\"radiogroup\"\n aria-label={i18n.get('paymentMethodsList.aria.label')}\n >\n {appsList.map(app => {\n const key = `adyen-checkout-upi-app-item-${app.id}`;\n const isSelected = selectedAppId === app.id;\n return <UPIIntentAppItem key={key} app={app} imgSrc={app.icon} isSelected={isSelected} onSelect={onAppSelect} />;\n })}\n </ul>\n );\n};\n\nexport default UPIIntentAppList;\n"],"names":["UPIIntentAppList","appsList","selectedAppId","disabled","onAppSelect","i18n","useCoreContext","h","ul","className","classNames","role","aria-label","get","map","app","key","id","isSelected","UPIIntentAppItem","imgSrc","icon","onSelect"],"mappings":"wPAcA,MAAMA,EAAmB,EAAGC,WAAUC,gBAAeC,WAAUC,kBAC3D,MAAMC,KAAEA,GAASC,IAEjB,OAEIC,EAACC,KAAAA,CACGC,UAAWC,EAAW,CAClB,+BAA+B,EAC/B,uCAAwCP,IAE5CQ,KAAK,aACLC,aAAYP,EAAKQ,IAAI,kCAEpBZ,EAASa,IAAIC,IACV,MAAMC,EAAM,+BAA+BD,EAAIE,KACzCC,EAAahB,IAAkBa,EAAIE,GACzC,OAAOV,EAACY,EAAAA,CAAiBH,IAAKA,EAAKD,IAAKA,EAAKK,OAAQL,EAAIM,KAAMH,WAAYA,EAAYI,SAAUlB"}
@@ -1,2 +1,2 @@
1
- const t={QR_CODE:"qrCode",INTENT:"intent"},e={ButtonId:{QR:"upi-button-qrCode",INTENT:"upi-button-intent"},AreaId:{QR:"upi-area-qrCode",INTENT:"upi-area-intent"}},n=5;export{e as A11Y,n as UPI_COUNTDOWN_TIME,t as UPI_MODE};
1
+ const t={QR_CODE:"qrCode",INTENT:"intent"},e=4,n={ButtonId:{QR:"upi-button-qrCode",INTENT:"upi-button-intent"},AreaId:{QR:"upi-area-qrCode",INTENT:"upi-area-intent"}},o=5;export{n as A11Y,e as MAX_PRIMARY_APPS,o as UPI_COUNTDOWN_TIME,t as UPI_MODE};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/components/UPI/constants.ts"],"sourcesContent":["import { UpiMode } from './types';\n\nexport const UPI_MODE = {\n QR_CODE: 'qrCode' as UpiMode,\n INTENT: 'intent' as UpiMode\n} as const;\n\nexport const A11Y = {\n ButtonId: {\n QR: 'upi-button-qrCode',\n INTENT: 'upi-button-intent'\n },\n AreaId: {\n QR: 'upi-area-qrCode',\n INTENT: 'upi-area-intent'\n }\n};\n\nexport const UPI_COUNTDOWN_TIME = 5;\n"],"names":["UPI_MODE","QR_CODE","INTENT","A11Y","ButtonId","QR","AreaId","UPI_COUNTDOWN_TIME"],"mappings":"MAEaA,EAAW,CACpBC,QAAS,SACTC,OAAQ,UAGCC,EAAO,CAChBC,SAAU,CACNC,GAAI,oBACJH,OAAQ,qBAEZI,OAAQ,CACJD,GAAI,kBACJH,OAAQ,oBAIHK,EAAqB"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/components/UPI/constants.ts"],"sourcesContent":["import { UpiMode } from './types';\n\nexport const UPI_MODE = {\n QR_CODE: 'qrCode' as UpiMode,\n INTENT: 'intent' as UpiMode\n} as const;\n\nexport const MAX_PRIMARY_APPS = 4;\n\nexport const A11Y = {\n ButtonId: {\n QR: 'upi-button-qrCode',\n INTENT: 'upi-button-intent'\n },\n AreaId: {\n QR: 'upi-area-qrCode',\n INTENT: 'upi-area-intent'\n }\n};\n\nexport const UPI_COUNTDOWN_TIME = 5;\n"],"names":["UPI_MODE","QR_CODE","INTENT","MAX_PRIMARY_APPS","A11Y","ButtonId","QR","AreaId","UPI_COUNTDOWN_TIME"],"mappings":"MAEaA,EAAW,CACpBC,QAAS,SACTC,OAAQ,UAGCC,EAAmB,EAEnBC,EAAO,CAChBC,SAAU,CACNC,GAAI,oBACJJ,OAAQ,qBAEZK,OAAQ,CACJD,GAAI,kBACJJ,OAAQ,oBAIHM,EAAqB"}
@@ -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 s from"../../internal/IssuerList/IssuerList.js";import r from"../../../utils/get-issuer-image.js";import{FALLBACK_CONTEXT as i}from"../../../core/config.js";import o from"../../internal/RedirectButton/RedirectButton.js";function n(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function p(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),r.forEach(function(e){n(t,e,s[e])})}return t}function a(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 s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class u extends e{formatProps(t){const e=t.details&&t.details.length&&(t.details.find(t=>"issuer"===t.key)||{}).items||t.issuers||[];return a(p({},t),{issuers:e})}formatData(){var t,e;return{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}}get isValid(){var t;return 0===this.props.issuers.length||!!(null===(t=this.state)||void 0===t?void 0:t.isValid)}get brands(){return this.props.showPaymentMethodItemImages?this.props.issuers.map(t=>({icon:t.icon,name:t.id})):[]}componentToRender(){return this.props.issuers.length>0?t(s,a(p({ref:t=>{this.componentRef=t},items:this.props.issuers,highlightedIds:this.props.highlightedIssuers},this.props,this.state),{showImage:this.props.showImage,type:this.constructor.type,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,contextualText:this.props.i18n.get("issuerList.selectField.contextualText"),onSubmitAnalytics:this.submitAnalytics})):t(o,a(p({showPayButton:this.props.showPayButton,name:this.props.name},this.props),{onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}}))}constructor(t,e){super(t,e);const s=t=>this.resources.getImage(t);if(this.props.showImage){const t=r({loadingContext:this.props.loadingContext},this.constructor.type,s);this.props.issuers=this.props.issuers.map(e=>a(p({},e),{icon:t(e.id)}))}}}n(u,"defaultProps",{showImage:!0,issuers:[],highlightedIssuers:[],loadingContext:i,showPaymentMethodItemImages:!1});export{u as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import s from"../../internal/IssuerList/IssuerList.js";import r from"../../../utils/get-issuer-image.js";import{FALLBACK_CONTEXT as o}from"../../../core/config.js";import i from"../../internal/RedirectButton/RedirectButton.js";function n(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function p(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),r.forEach(function(e){n(t,e,s[e])})}return t}function a(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 s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class u extends e{formatProps(t){var e,s;const r=(null==t||null===(e=t.details)||void 0===e?void 0:e.length)&&(null===(s=t.details.find(t=>"issuer"===t.key))||void 0===s?void 0:s.items)||t.issuers||[];return a(p({},t),{issuers:r})}formatData(){var t,e;return{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}}get isValid(){var t;return 0===this.props.issuers.length||Boolean(null===(t=this.state)||void 0===t?void 0:t.isValid)}get brands(){return this.props.showPaymentMethodItemImages?this.props.issuers.map(t=>({icon:t.icon,name:t.id})):[]}componentToRender(){return this.props.issuers.length>0?t(s,a(p({items:this.props.issuers,highlightedIds:this.props.highlightedIssuers},this.props,this.state),{setComponentRef:this.setComponentRef,showImage:this.props.showImage,type:this.constructor.type,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,contextualText:this.props.i18n.get("issuerList.selectField.contextualText"),onSubmitAnalytics:this.submitAnalytics})):t(i,a(p({showPayButton:this.props.showPayButton,name:this.props.name},this.props),{onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}}))}constructor(t,e){super(t,e);const s=t=>this.resources.getImage(t);if(this.props.showImage){const t=r({loadingContext:this.props.loadingContext},this.constructor.type,s);this.props.issuers=this.props.issuers.map(e=>a(p({},e),{icon:t(e.id)}))}}}n(u,"defaultProps",{showImage:!0,issuers:[],highlightedIssuers:[],loadingContext:o,showPaymentMethodItemImages:!1});export{u as default};
2
2
  //# sourceMappingURL=IssuerListContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListContainer.js","sources":["../../../../../src/components/helpers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport RedirectButton from '../../internal/RedirectButton';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\nimport { PaymentMethodBrand } from '../../../types/global-types';\n\nclass IssuerListContainer<TProps extends IssuerListConfiguration = IssuerListConfiguration, TData = IssuerListData> extends UIElement<TProps> {\n protected static readonly defaultProps = {\n showImage: true,\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: TProps) {\n super(checkout, props);\n\n const getImage = props => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props) {\n const issuers = (props.details && props.details.length && (props.details.find(d => d.key === 'issuer') || {}).items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): TData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n } as TData;\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): PaymentMethodBrand[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n protected override componentToRender(): h.JSX.Element {\n return this.props.issuers.length > 0 ? (\n <IssuerList\n ref={ref => {\n this.componentRef = ref;\n }}\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n ) : (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","_object_spread","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","brands","showPaymentMethodItemImages","map","brand","icon","name","id","componentToRender","h","IssuerList","ref","componentRef","highlightedIds","highlightedIssuers","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","i18n","get","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","checkout","super","getImage","resources","getIssuerIcon","getIssuerImageUrl","loadingContext","item","_define_property","defaultProps","FALLBACK_CONTEXT"],"mappings":"spCAUA,MAAMA,UAAsHC,EAwBxHC,WAAAA,CAAYC,GACR,MAAMC,EAAWD,EAAME,SAAWF,EAAME,QAAQC,SAAWH,EAAME,QAAQE,KAAKC,GAAe,WAAVA,EAAEC,MAAqB,CAAA,GAAIC,OAAUP,EAAMC,SAAW,GACzI,OAAOO,EAAAC,EAAA,CAAA,EAAKT,GAAAA,CAAOC,WACvB,CAKAS,UAAAA,OAIoBC,EAAAC,EAHhB,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKD,KACXE,OAAkB,QAAVJ,EAAAG,KAAKE,iBAALL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nC,KAAKf,MAAMC,QAAUc,KAAKf,MAAMC,QAAQqB,IAAIiC,GAAS/C,EAAAC,EAAA,CAAA,EAC9C8C,GAAAA,CACH/B,KAAM4B,EAAcG,EAAK7B,MAEjC,CACJ,EArBA8B,EADE3D,EACwB4D,eAAe,CACrCvB,WAAW,EACXjC,QAAS,GACTgC,mBAAoB,GACpBqB,eAAgBI,EAChBrC,6BAA6B"}
1
+ {"version":3,"file":"IssuerListContainer.js","sources":["../../../../../src/components/helpers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport RedirectButton from '../../internal/RedirectButton';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\nimport { PaymentMethodBrand } from '../../../types/global-types';\nimport { ImageOptions } from '../../../core/Context/Resources';\n\nclass IssuerListContainer<TProps extends IssuerListConfiguration = IssuerListConfiguration, TData = IssuerListData> extends UIElement<TProps> {\n protected static readonly defaultProps = {\n showImage: true,\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: TProps) {\n super(checkout, props);\n\n const getImage = (props: ImageOptions) => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props: TProps): TProps {\n const issuers =\n // @ts-expect-error - details is not in the props type but we need it for backward compatibility\n (props?.details?.length && props.details.find((d: Record<string, unknown>) => d.key === 'issuer')?.items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): TData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n } as TData;\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return Boolean(this.state?.isValid);\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): PaymentMethodBrand[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n protected override componentToRender(): h.JSX.Element {\n return this.props.issuers.length > 0 ? (\n <IssuerList\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n setComponentRef={this.setComponentRef}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n ) : (\n <RedirectButton\n showPayButton={this.props.showPayButton}\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","_object_spread","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","Boolean","brands","showPaymentMethodItemImages","map","brand","icon","name","id","componentToRender","h","IssuerList","highlightedIds","highlightedIssuers","setComponentRef","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","i18n","get","onSubmitAnalytics","submitAnalytics","RedirectButton","showPayButton","ref","componentRef","checkout","super","getImage","resources","getIssuerIcon","getIssuerImageUrl","loadingContext","item","_define_property","defaultProps","FALLBACK_CONTEXT"],"mappings":"spCAWA,MAAMA,UAAsHC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AA,EAAAA,CACGC,cAAehC,KAAKf,MAAM+C,cAC1BrB,KAAMX,KAAKf,MAAM0B,MACbX,KAAKf,OAAK,CACdsC,SAAUvB,KAAKwB,OACfC,UAAWzB,KAAKyB,UAChBQ,IAAKA,IACDjC,KAAKkC,aAAeD,KAIpC,CAxFA,WAAAb,CAAYe,EAAiBlD,GACzBmD,MAAMD,EAAUlD,GAEhB,MAAMoD,EAAYpD,GAAwBe,KAAKsC,UAAUD,SAASpD,GAElE,GAAIe,KAAKf,MAAMkC,UAAW,CACtB,MAAMoB,EAAgBC,EAAkB,CAAEC,eAAgBzC,KAAKf,MAAMwD,gBAAkBzC,KAAKoB,iBAAqBiB,GAEjHrC,KAAKf,MAAMC,QAAUc,KAAKf,MAAMC,QAAQsB,IAAIkC,GAASjD,EAAAC,EAAA,CAAA,EAC9CgD,GAAAA,CACHhC,KAAM6B,EAAcG,EAAK9B,MAEjC,CACJ,EArBA+B,EADE7D,EACwB8D,eAAe,CACrCzB,WAAW,EACXjC,QAAS,GACT+B,mBAAoB,GACpBwB,eAAgBI,EAChBtC,6BAA6B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as u,countrySpecificFormatters as d}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as v}from"../../../utils/validator-utils.js";import{useCoreContext as O}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){h(e,t,r[t])})}return e}function F(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 C(h){var C,A;const{i18n:P}=O(),{label:w="",requiredFields:S,visibility:k,iOSFocusedField:x=null,showContextualElement:D}=h,M=r({});var E;Object.keys(M.current).length||(null===(E=h.setComponentRef)||void 0===E||E.call(h,M.current));const B=o(()=>new f(h.specifications),[h.specifications]),N=B.getAddressSchemaForCountryFlat(h.countryCode).filter(e=>S.includes(e)),[L,R]=n(!1),[V,q]=n(!1),[H,T]=n(""),_=!!h.onAddressLookup,[I,U]=n(!1),$=!h.onAddressLookup||(L||V),{data:z,errors:G,valid:J,isValid:K,handleChangeFor:Q,triggerValidation:W,setData:X,mergeData:Y}=m({schema:N,defaultData:h.data,rules:j({},c(B),h.validationRules),formatters:u}),Z=r(null===(C=h.data)||void 0===C?void 0:C.country),ee=null===(A=z.country||Z.current)||void 0===A?void 0:A.toUpperCase(),te=o(()=>F(j({},z),{country:ee}),[z,ee]),re=s(e=>{const t=y.reduce((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t},{});Y(t),U(!0),W(),R(!0)},[R,W,X]),oe=s(()=>{q(!0)},[]);M.current.showValidation=()=>{W(),T(!_||$||K?"":P.get("address.errors.incomplete"))};const ne=N.filter(e=>!x||e===x);if(a(()=>{if(I)return void U(!1);const e=B.countryHasDataset(z.country)?"":b,t=F(j({},z),{stateOrProvince:e});S.forEach(e=>{var r;Q(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")}),t.postalCode&&Q("postalCode","blur")(z.postalCode)},[z.country]),a(()=>{const e=S.includes("stateOrProvince"),t=z.country&&B.countryHasDataset(z.country),r=e&&t,o=z.stateOrProvince||(r?"":b);Q("stateOrProvince","input")(o)},[]),a(()=>{const e=B.getOptionalFieldsForCountry(z.country),t=y.reduce((t,r)=>{const o=e.includes(r),n=S.includes(r),s=z[r],a=h.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t},{});!t.country&&Z.current&&(t.country=Z.current),h.onChange({data:t,valid:J,errors:G,isValid:K})},[z,J,G,K]),"hidden"===k)return null;if("readOnly"===k)return e(l,{data:z,label:w});const se=(t,{classNameModifiers:r=[]})=>S.includes(t)?e(p,{key:t,allowedCountries:h.allowedCountries,classNameModifiers:[...r,t],data:te,errors:G,valid:J,fieldName:t,onInput:Q(t,"input"),onBlur:Q(t,"blur"),onDropdownChange:Q(t,"blur"),specifications:B,maxLength:v(d,t,ee),trimOnBlur:!0,disabled:!ne.includes(t),onFieldFocusAnalytics:h.onFieldFocusAnalytics,onFieldBlurAnalytics:h.onFieldBlurAnalytics}):null,ae=B.getAddressSchemaForCountry(z.country);return e(t,null,e(i,{classNameModifiers:[w,"address"],label:w},_&&e(g,{onAddressLookup:h.onAddressLookup,onAddressSelected:h.onAddressSelected,onSelect:re,onManualAddress:oe,externalErrorMessage:H,hideManualButton:$,showContextualElement:D,contextualText:P.get("address.search.contextualText"),addressSearchDebounceMs:h.addressSearchDebounceMs}),$&&e(t,null,ae.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>se(e,{classNameModifiers:[`col-${t}`]}))):se(t,{})))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as d,countrySpecificFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as v}from"../../../utils/validator-utils.js";import{useCoreContext as O}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){h(e,t,r[t])})}return e}function F(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 C(h){var C,A;const{i18n:P}=O(),{label:S="",requiredFields:w,visibility:k,iOSFocusedField:x=null,showContextualElement:D}=h,M=r({});var E;Object.keys(M.current).length||(null===(E=h.setComponentRef)||void 0===E||E.call(h,M.current));const B=o(()=>new f(h.specifications),[h.specifications]),L=B.getAddressSchemaForCountryFlat(h.countryCode).filter(e=>w.includes(e)),[N,R]=n(!1),[V,H]=n(!1),[q,T]=n(""),_=!!h.onAddressLookup,[I,U]=n(!1),$=!h.onAddressLookup||(N||V),{data:z,errors:G,valid:J,isValid:K,handleChangeFor:Q,triggerValidation:W,setData:X,mergeData:Y}=m({schema:L,defaultData:h.data,rules:j({},c(B),h.validationRules),formatters:d}),Z=r(null===(C=h.data)||void 0===C?void 0:C.country),ee=null===(A=z.country||Z.current)||void 0===A?void 0:A.toUpperCase(),te=o(()=>F(j({},z),{country:ee}),[z,ee]),re=s(e=>{const t=y.reduce((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t},{});Y(t),U(!0),W(),R(!0)},[R,W,X]),oe=s(()=>{H(!0)},[]);M.current.showValidation=()=>{W(),T(!_||$||K?"":P.get("address.errors.incomplete"))};const ne=L.filter(e=>!x||e===x);if(a(()=>{if(I)return void U(!1);const e=B.countryHasDataset(z.country)?"":b,t=F(j({},z),{stateOrProvince:e});w.forEach(e=>{var r;Q(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")}),t.postalCode&&Q("postalCode","blur")(z.postalCode)},[z.country]),a(()=>{const e=w.includes("stateOrProvince"),t=z.country&&B.countryHasDataset(z.country),r=e&&t,o=z.stateOrProvince||(r?"":b);Q("stateOrProvince","input")(o)},[]),a(()=>{const e=B.getOptionalFieldsForCountry(z.country),t=y.reduce((t,r)=>{const o=e.includes(r),n=w.includes(r),s=z[r],a=h.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t},{});!t.country&&Z.current&&(t.country=Z.current),h.onChange({data:t,valid:J,errors:G,isValid:K})},[z,J,G,K]),"hidden"===k)return null;if("readOnly"===k)return e(l,{data:z,label:S});const se=(t,{classNameModifiers:r=[]})=>w.includes(t)?e(p,{key:t,allowedCountries:h.allowedCountries,classNameModifiers:[...r,t],data:te,errors:G,valid:J,fieldName:t,onInput:Q(t,"input"),onBlur:Q(t,"blur"),onDropdownChange:Q(t,"blur"),specifications:B,maxLength:v(u,t,ee),trimOnBlur:!0,disabled:!ne.includes(t),onFieldFocusAnalytics:h.onFieldFocusAnalytics,onFieldBlurAnalytics:h.onFieldBlurAnalytics}):null,ae=B.getAddressSchemaForCountry(z.country);return e(t,null,e(i,{classNameModifiers:[S,"address"],label:S,renderLabelAsSectionHeading:!0},_&&e(g,{onAddressLookup:h.onAddressLookup,onAddressSelected:h.onAddressSelected,onSelect:re,onManualAddress:oe,externalErrorMessage:q,hideManualButton:$,showContextualElement:D,contextualText:P.get("address.search.contextualText"),addressSearchDebounceMs:h.addressSearchDebounceMs}),$&&e(t,null,ae.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>se(e,{classNameModifiers:[`col-${t}`]}))):se(t,{})))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
2
2
  //# sourceMappingURL=Address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\n }\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={dataWithCountry}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, effectiveCountry, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label}>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","data","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","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,SAAU3D,GACVU,gBAAiBA,GACjBkD,qBAAsB3F,EACtB4F,iBAAkBtF,EAClB5B,sBAAuBA,EACvBmH,eAAgBzH,EAAKuE,IAAI,iCACzBmD,wBAAyB5H,EAAM4H,0BAGtCxF,GACG6D,EAACmB,EAAAA,KAAUF,GAAcW,IAAItG,GAAUA,aAAiBuG,MAxBpE7B,EAAC8B,MAAAA,CAAIC,UAAU,+BAwBwEzG,EAvB5EsG,IAAI,EAAEtG,EAAO0G,KAAU9B,GAAa5E,EAAO,CAAE6E,mBAAoB,CAAC,OAAO6B,SAuBY9B,GAAa5E,EAAO,CAAA,MAK5H,CAEAxB,EAAQmI,aAAe,CACnB7G,YAAa,KACb6B,gBAAiB,KACjBjD,KAAM,CAAA,EACN+F,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChBjD,eAAgB,CAAA,EAChBgG,sBAAuB,OACvBC,qBAAsB"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\n }\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={dataWithCountry}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, effectiveCountry, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","data","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"goDAkBe,SAASA,EAAQC,OAsC0BA,EAC5BC,EAtC1B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BR,EAG5FS,EAAaC,EAA4B,IAG3CV,IAAAA,EADCW,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBd,EAAAA,EAAMe,2BAANf,GAAAA,EAAAA,KAAAA,EAAwBS,EAAWI,UAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAelB,EAAMgB,gBAAiB,CAAChB,EAAMgB,iBAEhFG,EAAuBH,EAAeI,+BAA+BpB,EAAMqB,aAAaC,OAAOC,GAASlB,EAAemB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBhC,EAAMiC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBpC,EAAMiC,kBAAkBR,GAAsBG,IAElE3B,KAAEA,EAAIoC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA,GAAcC,EAAqB,CAClHC,OAAQ1B,EACR2B,YAAa9C,EAAMC,KAEnB8C,MAAOC,EAAA,GAAKC,EAA0BjC,GAAoBhB,EAAMkD,iBAChEC,WAAYC,IAKVC,EAAoB3C,EAAsC,QAAVV,EAAAA,EAAMC,YAAND,IAAAA,SAADsD,EAA6BC,SAC5EC,GAA6D,QAAzCvD,EAAAA,EAAKsD,SAAWF,EAAkBxC,eAAlCZ,IAAAA,OAAAA,EAADwD,EAA6CC,cAChEC,GAAkB1C,EAAQ,IAAO2C,EAAAZ,EAAA,CA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iE,EAACsB,EAAAA,CACGtF,gBAAiBjC,EAAMiC,gBACvBuF,kBAAmBxH,EAAMwH,kBACzBC,SAAU5D,GACVU,gBAAiBA,GACjBmD,qBAAsB5F,EACtB6F,iBAAkBvF,EAClB5B,sBAAuBA,EACvBoH,eAAgB1H,EAAKuE,IAAI,iCACzBoD,wBAAyB7H,EAAM6H,0BAGtCzF,GACG6D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIvG,GAAUA,aAAiBwG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwE1G,EAvB5EuG,IAAI,EAAEvG,EAAO2G,KAAU/B,GAAa5E,EAAO,CAAE6E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa5E,EAAO,CAAA,MAK5H,CAEAxB,EAAQoI,aAAe,CACnB9G,YAAa,KACb6B,gBAAiB,KACjBjD,KAAM,CAAA,EACN+F,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChBjD,eAAgB,CAAA,EAChBgG,sBAAuB,OACvBC,qBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AddressSearch.js","sources":["../../../../../../src/components/internal/Address/components/AddressSearch.tsx"],"sourcesContent":["import Field from '../../FormFields/Field';\nimport { h } from 'preact';\nimport { AddressLookupItem } from '../types';\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport './AddressSearch.scss';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { debounce } from '../../../../utils/debounce';\nimport Select from '../../FormFields/Select';\nimport { AddressData } from '../../../../types';\n\nexport type OnAddressLookupType = (\n value: string,\n actions: {\n resolve: (value: Array<AddressLookupItem>) => void;\n reject: (reason?: any) => void;\n }\n) => Promise<void>;\n\nexport type OnAddressSelectedType = (\n value: AddressLookupItem,\n actions: {\n resolve: (value: AddressLookupItem) => void;\n reject: (reason?: any) => void;\n }\n) => Promise<void>;\n\ninterface AddressSearchProps {\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n onSelect: (addressItem: AddressData) => void;\n onManualAddress: any;\n externalErrorMessage: string;\n hideManualButton: boolean;\n showContextualElement?: boolean;\n contextualText?: string;\n placeholder?: string;\n addressSearchDebounceMs?: number;\n}\n\ninterface RejectionReason {\n errorMessage: string;\n}\n\nexport default function AddressSearch({\n onAddressLookup,\n onAddressSelected,\n onSelect,\n onManualAddress,\n externalErrorMessage,\n hideManualButton,\n showContextualElement,\n contextualText,\n placeholder,\n addressSearchDebounceMs\n}: Readonly<AddressSearchProps>) {\n const [formattedData, setFormattedData] = useState<AddressLookupItem[]>([]);\n const [originalData, setOriginalData] = useState<AddressLookupItem[]>([]);\n\n const [errorMessage, setErrorMessage] = useState('');\n\n const { i18n } = useCoreContext();\n const mapDataToSelect = data => data.map(({ id, name }) => ({ id, name }));\n\n const handlePromiseReject = useCallback((reason: RejectionReason) => {\n if (reason?.errorMessage) {\n setErrorMessage(reason.errorMessage);\n }\n }, []);\n\n const onTextInput = useCallback(\n (inputValue: string) => {\n new Promise<Array<AddressLookupItem>>((resolve, reject) => {\n void onAddressLookup(inputValue, { resolve, reject });\n })\n .then(searchArray => {\n setOriginalData(searchArray);\n setFormattedData(mapDataToSelect(searchArray));\n setErrorMessage('');\n })\n .catch(reason => handlePromiseReject(reason));\n },\n [onAddressLookup]\n );\n\n // update error message when there's a new one\n useEffect(() => {\n setErrorMessage(externalErrorMessage);\n }, [externalErrorMessage]);\n\n const onSelectItem = event => {\n if (!event.target.value) {\n setErrorMessage(i18n.get('address.errors.incomplete'));\n return;\n }\n const value = originalData.find(item => item.id === event.target.value);\n\n // 1. in case we don't get a function just select item\n if (typeof onAddressSelected !== 'function') {\n onSelect(value);\n setFormattedData([]);\n return;\n }\n\n // 2. in case callback is provided, create and call onAddressSelected\n new Promise<AddressLookupItem>((resolve, reject) => {\n void onAddressSelected(value, { resolve, reject });\n })\n .then(fullData => {\n onSelect(fullData);\n setFormattedData([]);\n })\n .catch(reason => handlePromiseReject(reason));\n };\n\n const debounceInputHandler = useMemo(() => debounce(onTextInput, addressSearchDebounceMs), []);\n\n return (\n <div className={'adyen-checkout__address-search adyen-checkout__field-group'}>\n <Field\n label={i18n.get('address')}\n classNameModifiers={['address-search']}\n errorMessage={errorMessage}\n name={'address-search'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n name={'address-search'}\n className={'adyen-checkout__address-search__dropdown'}\n placeholder={placeholder}\n onInput={debounceInputHandler}\n items={formattedData}\n onChange={onSelectItem}\n disableTextFilter={true}\n blurOnClose={true}\n />\n </Field>\n {!hideManualButton && (\n <span className=\"adyen-checkout__address-search__manual-add\">\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button\"\n onClick={onManualAddress}\n >\n {'+ ' + i18n.get('address.enterManually')}\n </button>\n </span>\n )}\n </div>\n );\n}\n"],"names":["AddressSearch","onAddressLookup","onAddressSelected","onSelect","onManualAddress","externalErrorMessage","hideManualButton","showContextualElement","contextualText","placeholder","addressSearchDebounceMs","formattedData","setFormattedData","useState","originalData","setOriginalData","errorMessage","setErrorMessage","i18n","useCoreContext","handlePromiseReject","useCallback","reason","onTextInput","inputValue","Promise","resolve","reject","then","searchArray","map","id","name","catch","useEffect","debounceInputHandler","useMemo","debounce","h","div","className","Field","label","get","classNameModifiers","Select","onInput","items","onChange","event","target","value","find","item","fullData","disableTextFilter","blurOnClose","span","button","type","onClick"],"mappings":"saA2Ce,SAASA,GAAcC,gBAClCA,EAAeC,kBACfA,EAAiBC,SACjBA,EAAQC,gBACRA,EAAeC,qBACfA,EAAoBC,iBACpBA,EAAgBC,sBAChBA,EAAqBC,eACrBA,EAAcC,YACdA,EAAWC,wBACXA,IAEA,MAAOC,EAAeC,GAAoBC,EAA8B,KACjEC,EAAcC,GAAmBF,EAA8B,KAE/DG,EAAcC,GAAmBJ,EAAS,KAE3CK,KAAEA,GAASC,IAGXC,EAAsBC,EAAaC,KACjCA,aAAAA,EAA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":["../../../../../../src/components/internal/Address/components/AddressSearch.tsx"],"sourcesContent":["import Field from '../../FormFields/Field';\nimport { h } from 'preact';\nimport { AddressLookupItem } from '../types';\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport './AddressSearch.scss';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { debounce } from '../../../../utils/debounce';\nimport Select from '../../FormFields/Select';\nimport { AddressData } from '../../../../types';\n\nexport type OnAddressLookupType = (\n value: string,\n actions: {\n resolve: (value: Array<AddressLookupItem>) => void;\n reject: (reason?: any) => void;\n }\n) => Promise<void>;\n\nexport type OnAddressSelectedType = (\n value: AddressLookupItem,\n actions: {\n resolve: (value: AddressLookupItem) => void;\n reject: (reason?: any) => void;\n }\n) => Promise<void>;\n\ninterface AddressSearchProps {\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n onSelect: (addressItem: AddressData) => void;\n onManualAddress: any;\n externalErrorMessage: string;\n hideManualButton: boolean;\n showContextualElement?: boolean;\n contextualText?: string;\n placeholder?: string;\n addressSearchDebounceMs?: number;\n}\n\ninterface RejectionReason {\n errorMessage: string;\n}\n\nexport default function AddressSearch({\n onAddressLookup,\n onAddressSelected,\n onSelect,\n onManualAddress,\n externalErrorMessage,\n hideManualButton,\n showContextualElement,\n contextualText,\n placeholder,\n addressSearchDebounceMs\n}: Readonly<AddressSearchProps>) {\n const [formattedData, setFormattedData] = useState<AddressLookupItem[]>([]);\n const [originalData, setOriginalData] = useState<AddressLookupItem[]>([]);\n\n const [errorMessage, setErrorMessage] = useState('');\n\n const { i18n } = useCoreContext();\n const mapDataToSelect = data => data.map(({ id, name }) => ({ id, name }));\n\n const handlePromiseReject = useCallback((reason: RejectionReason) => {\n if (reason?.errorMessage) {\n setErrorMessage(reason.errorMessage);\n }\n }, []);\n\n const onTextInput = useCallback(\n (inputValue: string) => {\n new Promise<Array<AddressLookupItem>>((resolve, reject) => {\n void onAddressLookup(inputValue, { resolve, reject });\n })\n .then(searchArray => {\n setOriginalData(searchArray);\n setFormattedData(mapDataToSelect(searchArray));\n setErrorMessage('');\n })\n .catch(reason => handlePromiseReject(reason));\n },\n [onAddressLookup]\n );\n\n // update error message when there's a new one\n useEffect(() => {\n setErrorMessage(externalErrorMessage);\n }, [externalErrorMessage]);\n\n const onSelectItem = event => {\n if (!event.target.value) {\n setErrorMessage(i18n.get('address.errors.incomplete'));\n return;\n }\n const value = originalData.find(item => item.id === event.target.value);\n\n // 1. in case we don't get a function just select item\n if (typeof onAddressSelected !== 'function') {\n onSelect(value);\n setFormattedData([]);\n return;\n }\n\n // 2. in case callback is provided, create and call onAddressSelected\n new Promise<AddressLookupItem>((resolve, reject) => {\n void onAddressSelected(value, { resolve, reject });\n })\n .then(fullData => {\n onSelect(fullData);\n setFormattedData([]);\n })\n .catch(reason => handlePromiseReject(reason));\n };\n\n const debounceInputHandler = useMemo(() => debounce(onTextInput, addressSearchDebounceMs), []);\n\n return (\n // The search field is intentionally rendered before the manual entry button in the DOM.\n // See: ../a11y.md\n <div className={'adyen-checkout__address-search adyen-checkout__field-group'}>\n <Field\n label={i18n.get('address')}\n classNameModifiers={['address-search']}\n errorMessage={errorMessage}\n name={'address-search'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n name={'address-search'}\n className={'adyen-checkout__address-search__dropdown'}\n placeholder={placeholder}\n onInput={debounceInputHandler}\n items={formattedData}\n onChange={onSelectItem}\n disableTextFilter={true}\n blurOnClose={true}\n />\n </Field>\n {!hideManualButton && (\n <span className=\"adyen-checkout__address-search__manual-add\">\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button\"\n onClick={onManualAddress}\n >\n {'+ ' + i18n.get('address.enterManually')}\n </button>\n </span>\n )}\n </div>\n );\n}\n"],"names":["AddressSearch","onAddressLookup","onAddressSelected","onSelect","onManualAddress","externalErrorMessage","hideManualButton","showContextualElement","contextualText","placeholder","addressSearchDebounceMs","formattedData","setFormattedData","useState","originalData","setOriginalData","errorMessage","setErrorMessage","i18n","useCoreContext","handlePromiseReject","useCallback","reason","onTextInput","inputValue","Promise","resolve","reject","then","searchArray","map","id","name","catch","useEffect","debounceInputHandler","useMemo","debounce","h","div","className","Field","label","get","classNameModifiers","Select","onInput","items","onChange","event","target","value","find","item","fullData","disableTextFilter","blurOnClose","span","button","type","onClick"],"mappings":"saA2Ce,SAASA,GAAcC,gBAClCA,EAAeC,kBACfA,EAAiBC,SACjBA,EAAQC,gBACRA,EAAeC,qBACfA,EAAoBC,iBACpBA,EAAgBC,sBAChBA,EAAqBC,eACrBA,EAAcC,YACdA,EAAWC,wBACXA,IAEA,MAAOC,EAAeC,GAAoBC,EAA8B,KACjEC,EAAcC,GAAmBF,EAA8B,KAE/DG,EAAcC,GAAmBJ,EAAS,KAE3CK,KAAEA,GAASC,IAGXC,EAAsBC,EAAaC,KACjCA,aAAAA,EAAAA,EAAQN,eACRC,EAAgBK,EAAON,eAE5B,IAEGO,EAAcF,EACfG,IACG,IAAIC,QAAkC,CAACC,EAASC,KACvC1B,EAAgBuB,EAAY,CAAEE,UAASC,aAE3CC,KAAKC,IACFd,EAAgBc,GAChBjB,EAAiCiB,EAfZC,IAAI,EAAGC,KAAIC,WAAM,CAAQD,KAAIC,WAgBlDf,EAAgB,MAEnBgB,MAAMX,GAAUF,EAAoBE,KAE7C,CAACrB,IAILiC,EAAU,KACNjB,EAAgBZ,IACjB,CAACA,IAEJ,MAyBM8B,EAAuBC,EAAQ,IAAMC,EAASd,EAAab,GAA0B,IAE3F,OAGI4B,EAACC,MAAAA,CAAIC,UAAW,8DACZF,EAACG,EAAAA,CACGC,MAAOxB,EAAKyB,IAAI,WAChBC,mBAAoB,CAAC,kBACrB5B,aAAcA,EACdgB,KAAM,iBACNzB,sBAAuBA,EACvBC,eAAgBA,GAEhB8B,EAACO,EAAAA,CACGb,KAAM,iBACNQ,UAAW,2CACX/B,YAAaA,EACbqC,QAASX,EACTY,MAAOpC,EACPqC,SA7CKC,IACjB,IAAKA,EAAMC,OAAOC,MAEd,YADAlC,EAAgBC,EAAKyB,IAAI,8BAG7B,MAAMQ,EAAQrC,EAAasC,KAAKC,GAAQA,EAAKtB,KAAOkB,EAAMC,OAAOC,OAGjE,GAAiC,mBAAtBjD,EAGP,OAFAC,EAASgD,QACTvC,EAAiB,IAKrB,IAAIa,QAA2B,CAACC,EAASC,KAChCzB,EAAkBiD,EAAO,CAAEzB,UAASC,aAExCC,KAAK0B,IACFnD,EAASmD,GACT1C,EAAiB,MAEpBqB,MAAMX,GAAUF,EAAoBE,KAwB7BiC,mBAAmB,EACnBC,aAAa,MAGnBlD,GACEgC,EAACmB,OAAAA,CAAKjB,UAAU,8CACZF,EAACoB,SAAAA,CACGC,KAAK,SACLnB,UAAU,wIACVoB,QAASxD,GAER,KAAOc,EAAKyB,IAAI,2BAMzC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../../../external/preact/dist/preact.js";import{useRef as o}from"../../../../../../external/preact/hooks/dist/hooks.js";import{CtPBrand as s}from"../../CtPBrand/CtPBrand.js";import{useCoreContext as a}from"../../../../../../core/Context/CoreProvider.js";import l from"../../../../../../core/Context/useImage.js";import{Modal as n}from"../../../../Modal/Modal.js";import c from"../../../../Img/Img.js";import r from"../../../../Button/Button.js";let i=Date.now();function p(){return i+=1,`adyen-${i}`}const m=({isOpen:i,onClose:m,focusAfterClose:d})=>{const u=o(),{i18n:f}=a(),g=l(),C=p(),_=p();return e(n,{onClose:m,isOpen:i,classNameModifiers:["ctp"],labelledBy:C,describedBy:_,focusFirst:u.current,focusAfterClose:d},({onCloseModal:o})=>e(t,null,e(c,{className:"adyen-checkout__ctp-modal-header-image",src:g({imageFolder:"components/"})("ctp_landscape"),alt:""}),e("h1",{id:C,className:"adyen-checkout__ctp-modal-title"},f.get("ctp.infoPopup.title")),e("div",{id:_},e("p",{tabIndex:-1,ref:u,className:"adyen-checkout__ctp-modal-text"},f.get("ctp.infoPopup.subtitle")),e("ul",{className:"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits"},e("li",null,f.get("ctp.infoPopup.benefit1")),e("li",null,f.get("ctp.infoPopup.benefit2")),e("li",null,f.get("ctp.infoPopup.benefit3"))),e(s,{classNameModifiers:["popup"]})),e(r,{onClick:o,label:f.get("close")})))};export{m as CtPInfoModal};
1
+ import{createElement as e,Fragment as t}from"../../../../../../external/preact/dist/preact.js";import{useRef as o}from"../../../../../../external/preact/hooks/dist/hooks.js";import{CtPBrand as s}from"../../CtPBrand/CtPBrand.js";import{useCoreContext as a}from"../../../../../../core/Context/CoreProvider.js";import l from"../../../../../../core/Context/useImage.js";import{Modal as n}from"../../../../Modal/Modal.js";import c from"../../../../Img/Img.js";import r from"../../../../Button/Button.js";let i=Date.now();function p(){return i+=1,`adyen-${i}`}const m=({isOpen:i,onClose:m,focusAfterClose:d})=>{const u=o(),{i18n:f}=a(),g=l(),C=p(),_=p();return e(n,{onClose:m,isOpen:i,classNameModifiers:["ctp"],labelledBy:C,describedBy:_,focusFirst:u.current,focusAfterClose:d},({onCloseModal:o})=>e(t,null,e(c,{className:"adyen-checkout__ctp-modal-header-image",src:g({imageFolder:"components/"})("ctp_landscape"),alt:""}),e("h2",{id:C,className:"adyen-checkout__ctp-modal-title"},f.get("ctp.infoPopup.title")),e("div",{id:_},e("p",{tabIndex:-1,ref:u,className:"adyen-checkout__ctp-modal-text"},f.get("ctp.infoPopup.subtitle")),e("ul",{className:"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits"},e("li",null,f.get("ctp.infoPopup.benefit1")),e("li",null,f.get("ctp.infoPopup.benefit2")),e("li",null,f.get("ctp.infoPopup.benefit3"))),e(s,{classNameModifiers:["popup"]})),e(r,{onClick:o,label:f.get("close")})))};export{m as CtPInfoModal};
2
2
  //# sourceMappingURL=CtPInfoModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPInfoModal.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useRef } from 'preact/hooks';\nimport { CtPBrand } from '../../CtPBrand';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport { Modal } from '../../../../Modal';\nimport Img from '../../../../Img';\nimport Button from '../../../../Button';\nimport './CtPInfoModal.scss';\n\nlet idGenerator = Date.now();\n\nfunction getUniqueId() {\n idGenerator += 1;\n return `adyen-${idGenerator}`;\n}\n\ntype CtPInfoModalProps = {\n isOpen: boolean;\n onClose(): void;\n focusAfterClose: HTMLElement;\n};\n\nconst CtPInfoModal = ({ isOpen, onClose, focusAfterClose }: Readonly<CtPInfoModalProps>) => {\n const focusFirstElement = useRef<HTMLParagraphElement>();\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const labelledBy = getUniqueId();\n const describedBy = getUniqueId();\n\n return (\n <Modal\n onClose={onClose}\n isOpen={isOpen}\n classNameModifiers={['ctp']}\n labelledBy={labelledBy}\n describedBy={describedBy}\n focusFirst={focusFirstElement.current}\n focusAfterClose={focusAfterClose}\n >\n {({ onCloseModal }) => (\n <Fragment>\n <Img className=\"adyen-checkout__ctp-modal-header-image\" src={getImage({ imageFolder: 'components/' })('ctp_landscape')} alt=\"\" />\n <h1 id={labelledBy} className=\"adyen-checkout__ctp-modal-title\">\n {i18n.get('ctp.infoPopup.title')}\n </h1>\n\n <div id={describedBy}>\n <p tabIndex={-1} ref={focusFirstElement} className=\"adyen-checkout__ctp-modal-text\">\n {i18n.get('ctp.infoPopup.subtitle')}\n </p>\n\n <ul className=\"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits\">\n <li>{i18n.get('ctp.infoPopup.benefit1')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit2')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit3')}</li>\n </ul>\n\n <CtPBrand classNameModifiers={['popup']} />\n </div>\n\n <Button onClick={onCloseModal} label={i18n.get('close')} />\n </Fragment>\n )}\n </Modal>\n );\n};\n\nexport { CtPInfoModal };\n"],"names":["idGenerator","Date","now","getUniqueId","CtPInfoModal","isOpen","onClose","focusAfterClose","focusFirstElement","useRef","i18n","useCoreContext","getImage","useImage","labelledBy","describedBy","h","Modal","classNameModifiers","focusFirst","current","onCloseModal","Fragment","Img","className","src","imageFolder","alt","h1","id","get","div","p","tabIndex","ref","ul","li","CtPBrand","Button","onClick","label"],"mappings":"mfAUA,IAAIA,EAAcC,KAAKC,MAEvB,SAASC,IAEL,OADAH,GAAe,EACR,SAASA,GACpB,CAQA,MAAMI,EAAe,EAAGC,SAAQC,UAASC,sBACrC,MAAMC,EAAoBC,KACpBC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAaX,IACbY,EAAcZ,IAEpB,OACIa,EAACC,EAAAA,CACGX,QAASA,EACTD,OAAQA,EACRa,mBAAoB,CAAC,OACrBJ,WAAYA,EACZC,YAAaA,EACbI,WAAYX,EAAkBY,QAC9Bb,gBAAiBA,GAEhB,EAAGc,kBACAL,EAACM,OACGN,EAACO,EAAAA,CAAIC,UAAU,yCAAyCC,IAAKb,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAAkBe,IAAI,KAC5HX,EAACY,KAAAA,CAAGC,GAAIf,EAAYU,UAAU,mCACzBd,EAAKoB,IAAI,wBAGdd,EAACe,MAAAA,CAAIF,GAAId,GACLC,EAACgB,IAAAA,CAAEC,UAAU,EAAIC,IAAK1B,EAAmBgB,UAAU,kCAC9Cd,EAAKoB,IAAI,2BAGdd,EAACmB,KAAAA,CAAGX,UAAU,qEACVR,EAACoB,UAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,4BAGlBd,EAACqB,EAAAA,CAASnB,mBAAoB,CAAC,YAGnCF,EAACsB,EAAAA,CAAOC,QAASlB,EAAcmB,MAAO9B,EAAKoB,IAAI"}
1
+ {"version":3,"file":"CtPInfoModal.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useRef } from 'preact/hooks';\nimport { CtPBrand } from '../../CtPBrand';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport { Modal } from '../../../../Modal';\nimport Img from '../../../../Img';\nimport Button from '../../../../Button';\nimport './CtPInfoModal.scss';\n\nlet idGenerator = Date.now();\n\nfunction getUniqueId() {\n idGenerator += 1;\n return `adyen-${idGenerator}`;\n}\n\ntype CtPInfoModalProps = {\n isOpen: boolean;\n onClose(): void;\n focusAfterClose: HTMLElement;\n};\n\nconst CtPInfoModal = ({ isOpen, onClose, focusAfterClose }: Readonly<CtPInfoModalProps>) => {\n const focusFirstElement = useRef<HTMLParagraphElement>();\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const labelledBy = getUniqueId();\n const describedBy = getUniqueId();\n\n return (\n <Modal\n onClose={onClose}\n isOpen={isOpen}\n classNameModifiers={['ctp']}\n labelledBy={labelledBy}\n describedBy={describedBy}\n focusFirst={focusFirstElement.current}\n focusAfterClose={focusAfterClose}\n >\n {({ onCloseModal }) => (\n <Fragment>\n <Img className=\"adyen-checkout__ctp-modal-header-image\" src={getImage({ imageFolder: 'components/' })('ctp_landscape')} alt=\"\" />\n <h2 id={labelledBy} className=\"adyen-checkout__ctp-modal-title\">\n {i18n.get('ctp.infoPopup.title')}\n </h2>\n\n <div id={describedBy}>\n <p tabIndex={-1} ref={focusFirstElement} className=\"adyen-checkout__ctp-modal-text\">\n {i18n.get('ctp.infoPopup.subtitle')}\n </p>\n\n <ul className=\"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits\">\n <li>{i18n.get('ctp.infoPopup.benefit1')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit2')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit3')}</li>\n </ul>\n\n <CtPBrand classNameModifiers={['popup']} />\n </div>\n\n <Button onClick={onCloseModal} label={i18n.get('close')} />\n </Fragment>\n )}\n </Modal>\n );\n};\n\nexport { CtPInfoModal };\n"],"names":["idGenerator","Date","now","getUniqueId","CtPInfoModal","isOpen","onClose","focusAfterClose","focusFirstElement","useRef","i18n","useCoreContext","getImage","useImage","labelledBy","describedBy","h","Modal","classNameModifiers","focusFirst","current","onCloseModal","Fragment","Img","className","src","imageFolder","alt","h2","id","get","div","p","tabIndex","ref","ul","li","CtPBrand","Button","onClick","label"],"mappings":"mfAUA,IAAIA,EAAcC,KAAKC,MAEvB,SAASC,IAEL,OADAH,GAAe,EACR,SAASA,GACpB,CAQA,MAAMI,EAAe,EAAGC,SAAQC,UAASC,sBACrC,MAAMC,EAAoBC,KACpBC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAaX,IACbY,EAAcZ,IAEpB,OACIa,EAACC,EAAAA,CACGX,QAASA,EACTD,OAAQA,EACRa,mBAAoB,CAAC,OACrBJ,WAAYA,EACZC,YAAaA,EACbI,WAAYX,EAAkBY,QAC9Bb,gBAAiBA,GAEhB,EAAGc,kBACAL,EAACM,OACGN,EAACO,EAAAA,CAAIC,UAAU,yCAAyCC,IAAKb,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAAkBe,IAAI,KAC5HX,EAACY,KAAAA,CAAGC,GAAIf,EAAYU,UAAU,mCACzBd,EAAKoB,IAAI,wBAGdd,EAACe,MAAAA,CAAIF,GAAId,GACLC,EAACgB,IAAAA,CAAEC,UAAU,EAAIC,IAAK1B,EAAmBgB,UAAU,kCAC9Cd,EAAKoB,IAAI,2BAGdd,EAACmB,KAAAA,CAAGX,UAAU,qEACVR,EAACoB,UAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,4BAGlBd,EAACqB,EAAAA,CAASnB,mBAAoB,CAAC,YAGnCF,EAACsB,EAAAA,CAAOC,QAASlB,EAAcmB,MAAO9B,EAAKoB,IAAI"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import a from"../Link/Link.js";function n({message:t,urls:r=[]}){return e("span",{className:"adyen-checkout-disclaimer__label"},e(i,{message:t,urls:r}))}function i({message:n,urls:i}){const l="string"==typeof n,o=i.every(e=>"string"==typeof e&&r(e));return l&&o?e(t,null,s(n,i.map(t=>function(r){return e(a,{to:t},r)}))):null}export{i as LabelOnlyDisclaimerMessage,n as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import n from"../Link/Link.js";function a({message:t,urls:r=[]}){return e("span",{className:"adyen-checkout-disclaimer__label"},e(l,{message:t,urls:r}))}function l({message:a,urls:l}){const i="string"==typeof a,o=l.every(e=>"string"==typeof e&&r(e));if(!i||!o)return null;let u;try{u=s(a,l.map(t=>function(r){return e(n,{to:t},r)}))}catch(e){u=a,console.warn(e)}return e(t,null,u)}export{l as LabelOnlyDisclaimerMessage,a as default};
2
2
  //# sourceMappingURL=DisclaimerMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText: string;\n link: string;\n}\n\ninterface InternalDisclaimerMsgObject {\n message: string;\n urls?: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n */\n\nexport default function DisclaimerMessage({ message, urls = [] }: Readonly<InternalDisclaimerMsgObject>) {\n return (\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls }: Readonly<InternalDisclaimerMsgObject>) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n return (\n <Fragment>\n {interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n )}\n </Fragment>\n );\n}\n"],"names":["DisclaimerMessage","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","Fragment","interpolateElement","map","translation","Link","to"],"mappings":"mPAyBe,SAASA,GAAkBC,QAAEA,EAAOC,KAAEA,EAAO,KACxD,OACIC,EAACC,OAAAA,CAAKC,UAAU,oCACZF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,IAClD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,MAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,IAC9E,OAAKH,GAAiBC,EAGlBL,EAACS,EAAAA,KACIC,EACGZ,EACAC,EAAKY,IAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,KAXoB,IAgB5C"}
1
+ {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText: string;\n link: string;\n}\n\ninterface InternalDisclaimerMsgObject {\n message: string;\n urls?: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n */\n\nexport default function DisclaimerMessage({ message, urls = [] }: Readonly<InternalDisclaimerMsgObject>) {\n return (\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls }: Readonly<InternalDisclaimerMsgObject>) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n let content;\n try {\n content = interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n );\n } catch (e) {\n // Fall back to raw message (i.e. the translation key) if interpolation fails\n content = message;\n // Report interpolation error to console\n console.warn(e);\n }\n\n return <Fragment>{content}</Fragment>;\n}\n"],"names":["DisclaimerMessage","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","content","interpolateElement","map","translation","Link","to","e","console","warn","Fragment"],"mappings":"mPAyBe,SAASA,GAAkBC,QAAEA,EAAOC,KAAEA,EAAO,KACxD,OACIC,EAACC,OAAAA,CAAKC,UAAU,oCACZF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,IAClD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,MAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,IAC9E,IAAKH,IAAiBC,EAAW,OAAO,KAExC,IAAII,EACJ,IACIA,EAAUC,EACNZ,EACAC,EAAKY,IAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,GAGhB,CAAE,MAAOG,GAELN,EAAUX,EAEVkB,QAAQC,KAAKF,EACjB,CAEA,OAAOf,EAACkB,EAAAA,KAAUT,EACtB"}
@@ -1,2 +1,2 @@
1
- import e from"../../../../_virtual/index.js";import{createElement as t,Fragment as n,toChildArray as a,cloneElement as l}from"../../../../external/preact/dist/preact.js";import r from"../../Spinner/Spinner.js";import o from"../../Icon/Icon.js";import{ARIA_ERROR_SUFFIX as i,ARIA_CONTEXT_SUFFIX as c}from"../../../../core/Errors/constants.js";import{useRef as s,useMemo as d,useState as u,useCallback as p}from"../../../../external/preact/hooks/dist/hooks.js";import{getUniqueId as m}from"../../../../utils/idGenerator.js";import{PREFIX as f}from"../../Icon/constants.js";import h from"../../../../utils/uuid.js";function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){y(e,t,n[t])})}return e}function b(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const k=y=>{const{children:k,className:v,classNameModifiers:j,dir:O,disabled:g,readOnly:x,errorMessage:w,helper:E,inputWrapperModifiers:N,isLoading:F,isValid:P,label:S,labelEndAdornment:$,name:I,onBlur:L,onFieldBlur:C,onFocus:A,onFocusField:M,showValidIcon:T,useLabelElement:V,showErrorElement:D,showContextualElement:q,staticValue:B,contextualText:H,filled:R,focused:W,i18n:z,contextVisibleToScreenReader:G,renderAlternativeToLabel:J,onInputContainerClick:K}=y,Q=null==G||G,U=D&&"string"==typeof w&&w.length>0,X=q&&!U&&H&&H.length>0,Y=s(m(`adyen-checkout-${I}`)),Z=d(()=>B?`input-static-value-${h()}`:null,[B]),[ee,te]=u(!1),[ne,ae]=u(!1);null!=W&&te(!!W),null!=R&&ae(!!R);const le=p(e=>{te(!0),null==A||A(e)},[A]),re=p(e=>{te(!1),null==L||L(e),null==C||C(e)},[L,C]),oe=p(()=>t(n,null,"string"==typeof S&&t("span",{className:e({"adyen-checkout__label__text":!0,"adyen-checkout__label__text--error":w}),"data-id":I,"data-testid":I},S),"function"==typeof S&&S(),$&&t("span",{className:"adyen-checkout__label-adornment--end"},$),E&&t("span",{className:"adyen-checkout__helper-text"},E)),[S,w,$,E]),ie=p(()=>{const s=t("span",b(_({className:e({"adyen-checkout-contextual-text--error":!0,"adyen-checkout-contextual-text--hidden":!U})},Q&&{id:`${Y.current}${i}`}),{"aria-hidden":Q?void 0:"true"}),w),d=t("span",b(_({className:e({"adyen-checkout-contextual-text":!0,"adyen-checkout-contextual-text--hidden":!X})},Q&&{id:`${Y.current}${c}`}),{"aria-hidden":Q?void 0:"true"}),H);return t(n,null,t("div",{className:e(["adyen-checkout__input-wrapper",...N.map(e=>`adyen-checkout__input-wrapper--${e}`)]),dir:O,onClick:K},B&&t("span",{id:Z,className:"adyen-checkout__field-static-value"},B),a(k).map(e=>{const t=b(_({isValid:P,onFocusHandler:le,onBlurHandler:re,isInvalid:!!w,"aria-owns":Z},I&&{uniqueId:Y.current}),{showErrorElement:D});return l(e,t)}),F&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading"},t(r,{size:"small"})),P&&!1!==T&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid"},t(o,{type:`${f}checkmark_black`,alt:null==z?void 0:z.get("field.valid")})),w&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid"},t(o,{type:`${f}field_error`,alt:null==z?void 0:z.get("error.title")}))),s,d)},[k,w,H,F,P,le,re]),ce=p(({onFocusField:n,focused:a,filled:l,disabled:r,name:o,uniqueId:i,useLabelElement:c,isSecuredField:s,children:d,renderAlternativeToLabel:u})=>{const p={onClick:n,className:e({"adyen-checkout__label":!0,"adyen-checkout__label--focused":a,"adyen-checkout__label--filled":l,"adyen-checkout__label--disabled":r})};return c?t("label",_({},p,!s&&o&&{htmlFor:i}),d):u(p,d,i)},[]);return t("div",{"data-testid":"form-field",className:e("adyen-checkout__field",v,null==j?void 0:j.map(e=>`adyen-checkout__field--${e}`),{"adyen-checkout__field--error":w,"adyen-checkout__field--valid":P,"adyen-checkout__field--inactive":x||g})},t(ce,{onFocusField:M,name:I,disabled:g,filled:ne,focused:ee,useLabelElement:V,uniqueId:Y.current,isSecuredField:!Q,renderAlternativeToLabel:J},oe()),ie())};k.defaultProps={className:"",classNameModifiers:[],inputWrapperModifiers:[],useLabelElement:!0,showErrorElement:!0,showContextualElement:!0,renderAlternativeToLabel:()=>null};export{k as default};
1
+ import e from"../../../../_virtual/index.js";import{createElement as t,Fragment as n,toChildArray as a,cloneElement as l}from"../../../../external/preact/dist/preact.js";import r from"../../Spinner/Spinner.js";import o from"../../Icon/Icon.js";import{ARIA_ERROR_SUFFIX as i,ARIA_CONTEXT_SUFFIX as c}from"../../../../core/Errors/constants.js";import{useRef as s,useMemo as d,useState as u,useCallback as p}from"../../../../external/preact/hooks/dist/hooks.js";import{getUniqueId as m}from"../../../../utils/idGenerator.js";import{PREFIX as f}from"../../Icon/constants.js";import h from"../../../../utils/uuid.js";function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){y(e,t,n[t])})}return e}function b(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 n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const k=y=>{const{children:k,className:v,classNameModifiers:j,dir:O,disabled:g,readOnly:x,errorMessage:w,helper:E,inputWrapperModifiers:N,isLoading:F,isValid:P,label:$,labelEndAdornment:S,name:I,onBlur:L,onFieldBlur:C,onFocus:A,onFocusField:M,showValidIcon:T,useLabelElement:V,showErrorElement:D,showContextualElement:q,staticValue:B,contextualText:H,filled:R,focused:W,i18n:z,contextVisibleToScreenReader:G,renderAlternativeToLabel:J,onInputContainerClick:K}=y,Q=null==G||G,U=D&&"string"==typeof w&&w.length>0,X=q&&!U&&H&&H.length>0,Y=s(m(`adyen-checkout-${I}`)),Z=d(()=>B?`input-static-value-${h()}`:null,[B]),[ee,te]=u(!1),[ne,ae]=u(!1);null!=W&&te(!!W),null!=R&&ae(!!R);const le=p(e=>{te(!0),null==A||A(e)},[A]),re=p(e=>{te(!1),null==L||L(e),null==C||C(e)},[L,C]),oe=p(()=>t(n,null,"string"==typeof $&&t("span",{className:e({"adyen-checkout__label__text":!0,"adyen-checkout__label__text--error":w}),"data-id":I,"data-testid":I},$),"function"==typeof $&&$(),S&&t("span",{className:"adyen-checkout__label-adornment--end"},S),E&&t("span",{className:"adyen-checkout__helper-text"},E)),[$,w,S,E]),ie=p(()=>{const s=t("span",b(_({className:e({"adyen-checkout-contextual-text--error":!0,"adyen-checkout-contextual-text--hidden":!U})},Q&&{id:`${Y.current}${i}`}),{"aria-hidden":Q?void 0:"true"}),w),d=t("span",b(_({className:e({"adyen-checkout-contextual-text":!0,"adyen-checkout-contextual-text--hidden":!X})},Q&&{id:`${Y.current}${c}`}),{"aria-hidden":Q?void 0:"true"}),H);return t(n,null,t("div",{className:e(["adyen-checkout__input-wrapper",...N.map(e=>`adyen-checkout__input-wrapper--${e}`)]),dir:O,onClick:K},B&&t("span",{id:Z,className:"adyen-checkout__field-static-value"},B),a(k).map(e=>{const t=b(_({isValid:P,onFocusHandler:le,onBlurHandler:re,isInvalid:!!w,"aria-owns":Z},I&&{uniqueId:Y.current}),{showErrorElement:D});return l(e,t)}),F&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading"},t(r,{size:"small"})),P&&!1!==T&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid"},t(o,{type:`${f}checkmark_black`,alt:null==z?void 0:z.get("field.valid")})),w&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid"},t(o,{type:`${f}field_error`,alt:null==z?void 0:z.get("error.title")}))),s,d)},[k,w,H,F,P,le,re]),ce=p(({onFocusField:n,focused:a,filled:l,disabled:r,name:o,uniqueId:i,useLabelElement:c,isSecuredField:s,children:d,renderAlternativeToLabel:u})=>{const p={onClick:n,className:e({"adyen-checkout__label":!0,"adyen-checkout__label--focused":a,"adyen-checkout__label--filled":l,"adyen-checkout__label--disabled":r})};return c?t("label",_({},p,!s&&o&&{htmlFor:i,id:`${i}-label`}),d):u(p,d,i)},[]);return t("div",{"data-testid":"form-field",className:e("adyen-checkout__field",v,null==j?void 0:j.map(e=>`adyen-checkout__field--${e}`),{"adyen-checkout__field--error":w,"adyen-checkout__field--valid":P,"adyen-checkout__field--inactive":x||g})},t(ce,{onFocusField:M,name:I,disabled:g,filled:ne,focused:ee,useLabelElement:V,uniqueId:Y.current,isSecuredField:!Q,renderAlternativeToLabel:J},oe()),ie())};k.defaultProps={className:"",classNameModifiers:[],inputWrapperModifiers:[],useLabelElement:!0,showErrorElement:!0,showContextualElement:!0,renderAlternativeToLabel:()=>null};export{k as default};
2
2
  //# sourceMappingURL=Field.js.map