@adyen/adyen-web 6.36.0 → 6.38.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 (264) hide show
  1. package/dist/cjs/adyen.css +11 -11
  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 +13 -7
  6. package/dist/es/adyen.css +11 -11
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  9. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  10. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  12. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  13. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  14. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  15. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  16. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  17. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  18. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  19. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  20. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  21. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  22. package/dist/es/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js +1 -1
  23. package/dist/es/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js.map +1 -1
  24. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  25. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  26. package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
  27. package/dist/es/components/Card/components/CardInput/components/CVC.js.map +1 -1
  28. package/dist/es/components/Card/components/CardInput/components/CVCHint.js +1 -1
  29. package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  30. package/dist/es/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  31. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  32. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  33. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  34. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js +1 -1
  35. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -1
  36. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  37. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  38. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  39. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  40. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
  41. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
  42. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js +1 -1
  43. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js.map +1 -1
  44. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  45. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  46. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  47. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  48. package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
  49. package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
  50. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  51. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  52. package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
  53. package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
  54. package/dist/es/components/PayTo/components/PayToPhone.js +1 -1
  55. package/dist/es/components/PayTo/components/PayToPhone.js.map +1 -1
  56. package/dist/es/components/Pix/components/PixInput/PixInput.js +1 -1
  57. package/dist/es/components/Pix/components/PixInput/PixInput.js.map +1 -1
  58. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  59. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  60. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  61. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  62. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  63. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  64. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  65. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  66. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  67. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  68. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  69. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  70. package/dist/es/components/UPI/UPI.js +1 -1
  71. package/dist/es/components/UPI/UPI.js.map +1 -1
  72. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  73. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  74. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  75. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  76. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  77. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  78. package/dist/es/components/UPI/constants.js +1 -1
  79. package/dist/es/components/UPI/constants.js.map +1 -1
  80. package/dist/es/components/internal/Address/Address.js +1 -1
  81. package/dist/es/components/internal/Address/Address.js.map +1 -1
  82. package/dist/es/components/internal/Await/Await.js +1 -1
  83. package/dist/es/components/internal/Await/Await.js.map +1 -1
  84. package/dist/es/components/internal/BrandIcons/BrandIcons.js +1 -1
  85. package/dist/es/components/internal/BrandIcons/BrandIcons.js.map +1 -1
  86. package/dist/es/components/internal/BrandImage/BrandImage.js +1 -1
  87. package/dist/es/components/internal/BrandImage/BrandImage.js.map +1 -1
  88. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js +1 -1
  89. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js.map +1 -1
  90. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  91. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  92. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  93. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  94. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  95. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  96. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  97. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  98. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  99. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  100. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  101. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  102. package/dist/es/components/internal/Img/Img.js.map +1 -1
  103. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  104. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  105. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  106. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  107. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  108. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  109. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  110. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  111. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  112. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  113. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  114. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  115. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  116. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  117. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  118. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  119. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  120. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  121. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  122. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  123. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  124. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  125. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  126. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  127. package/dist/es/core/config.js +1 -1
  128. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  129. package/dist/es/index.d.ts +13 -7
  130. package/dist/es/language/LanguageService.js.map +1 -1
  131. package/dist/es/utils/useForm/useErrorFocus.js +2 -0
  132. package/dist/es/utils/useForm/useErrorFocus.js.map +1 -0
  133. package/dist/es/utils/useForm/useFormWithA11y.js +2 -0
  134. package/dist/es/utils/useForm/useFormWithA11y.js.map +1 -0
  135. package/dist/es-legacy/adyen.css +11 -11
  136. package/dist/es-legacy/adyen.css.map +1 -1
  137. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  138. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  139. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  140. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  141. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  142. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  143. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  144. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  145. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  146. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  147. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  148. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  149. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  150. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  151. package/dist/es-legacy/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js +1 -1
  152. package/dist/es-legacy/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js.map +1 -1
  153. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  154. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  155. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
  156. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js.map +1 -1
  157. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js +1 -1
  158. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  159. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  160. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  161. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js.map +1 -1
  162. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  163. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js +1 -1
  164. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -1
  165. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  166. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  167. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  168. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  169. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
  170. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
  171. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js +1 -1
  172. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js.map +1 -1
  173. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  174. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  175. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  176. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  177. package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
  178. package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
  179. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  180. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  181. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
  182. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
  183. package/dist/es-legacy/components/PayTo/components/PayToPhone.js +1 -1
  184. package/dist/es-legacy/components/PayTo/components/PayToPhone.js.map +1 -1
  185. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js +1 -1
  186. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js.map +1 -1
  187. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  188. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  189. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  190. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  191. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  192. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  193. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  194. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  195. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  196. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  197. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  198. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  199. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  200. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  201. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  202. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  203. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  204. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  205. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
  206. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
  207. package/dist/es-legacy/components/UPI/constants.js +1 -1
  208. package/dist/es-legacy/components/UPI/constants.js.map +1 -1
  209. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  210. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  211. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  212. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  213. package/dist/es-legacy/components/internal/BrandIcons/BrandIcons.js +1 -1
  214. package/dist/es-legacy/components/internal/BrandIcons/BrandIcons.js.map +1 -1
  215. package/dist/es-legacy/components/internal/BrandImage/BrandImage.js +1 -1
  216. package/dist/es-legacy/components/internal/BrandImage/BrandImage.js.map +1 -1
  217. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js +1 -1
  218. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js.map +1 -1
  219. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  220. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  221. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  222. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  223. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  224. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  225. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  226. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  227. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  228. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  229. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  230. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  231. package/dist/es-legacy/components/internal/Img/Img.js.map +1 -1
  232. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  233. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  234. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  235. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  236. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  237. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  238. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  239. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  240. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  241. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  242. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  243. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  244. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  245. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  246. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  247. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  248. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  249. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js +1 -1
  250. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -1
  251. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  252. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  253. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  254. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  255. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  256. package/dist/es-legacy/core/config.js +1 -1
  257. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  258. package/dist/es-legacy/language/LanguageService.js.map +1 -1
  259. package/dist/es-legacy/utils/useForm/useErrorFocus.js +2 -0
  260. package/dist/es-legacy/utils/useForm/useErrorFocus.js.map +1 -0
  261. package/dist/es-legacy/utils/useForm/useFormWithA11y.js +2 -0
  262. package/dist/es-legacy/utils/useForm/useFormWithA11y.js.map +1 -0
  263. package/package.json +16 -16
  264. package/styles/adyen.css +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useForm<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","handleChangeFor","data","triggerValidation","valid","errors","isValid","useForm","schema","rules","loginValidationRules","loginInputHandlersRef","useRef","validateInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","shopperLogin","current","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","Field","name","label","get","errorMessage","classNameModifiers","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"oeA0BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,KAEXC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAgC,CACzGC,OAFe,CAAC,gBAGhBC,MAAOC,IAELC,EAAwBC,EAA8B,CAAEC,cAAe,QACtEC,EAAmBC,GAAwBC,GAAkB,GAE9DH,EAAgBI,EAAY,KAC9BF,GAAqB,GACrBZ,KACD,CAACA,IAEJe,EAAU,KACFhB,EAAKiB,cAAcJ,GAAqB,IAC7C,CAACb,EAAKiB,eAETD,EAAU,KACNP,EAAsBS,QAAQP,cAAgBA,EAC9Cf,EAAMuB,mBAAmBV,EAAsBS,UAChD,CAACP,EAAef,EAAMuB,qBAEzB,MAAMC,EAAmBL,EACpBM,IACqB,UAAdA,EAAMC,KACD1B,EAAM2B,gBAGnB,CAAC3B,EAAM2B,eAOX,OAJAP,EAAU,KACNpB,EAAM4B,SAAS,CAAExB,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbsB,EAACC,EAAAA,CACGC,KAAK,eACLC,MAAO/B,EAAKgC,IAAI,wBAChBC,aAAclB,EAAoBhB,EAAMkC,gBAAkB3B,EAAOc,aAAe,KAChFc,mBAAoB,CAAC,iBAErBN,EAACO,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOnC,EAAKiB,aACZmB,SAAUxC,EAAMwC,SAChBC,QAAStC,EAAgB,eAAgB,SACzCuC,OAAQvC,EAAgB,eAAgB,QACxCwC,WAAYnB"}
1
+ {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,IAEXC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAwC,CACjHC,OAHe,CAAC,gBAIhBC,MAAOC,EACPC,WAAYZ,IAEVa,EAAwBZ,EAA8B,CAAEa,cAAe,KAAMC,WAAY,QACxFC,EAAmBC,GAAwBC,GAAkB,GAE9DJ,EAAgBK,EAAY,KAC9BF,GAAqB,GACrBb,KACD,CAACA,IAEJgB,EAAU,KACFpB,EAAaqB,SAAWxB,EAAMyB,cAC9BC,EAAgBvB,EAAaqB,QAAS,iBAE3C,CAACxB,EAAMyB,eAEVF,EAAU,KACFjB,EAAKqB,cAAcP,GAAqB,IAC7C,CAACd,EAAKqB,eAETJ,EAAU,KACNP,EAAsBQ,QAAQP,cAAgBA,EAC9CjB,EAAM4B,mBAAmBZ,EAAsBQ,UAChD,CAACP,EAAejB,EAAM4B,qBAEzB,MAAMC,EAAmBP,EACpBQ,IACqB,UAAdA,EAAMC,KACD/B,EAAMgC,gBAGnB,CAAChC,EAAMgC,eAOX,OAJAT,EAAU,KACNvB,EAAMiC,SAAS,CAAE3B,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbyB,EAACC,MAAAA,CAAIC,IAAKjC,GACN+B,EAACG,EAAAA,CACGC,KAAK,eACLC,MAAOtC,EAAKuC,IAAI,wBAChBf,aAAcN,EAAoBnB,EAAMyB,gBAAkBhB,EAAOkB,aAAe,KAChFc,mBAAoB,CAAC,gBACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOxC,EAAKqB,aACZoB,SAAU/C,EAAM+C,SAChBC,QAAS3C,EAAgB,eAAgB,SACzC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useForm.js";import d from"../../../../FormFields/Field/Field.js";import c from"../../../../FormFields/InputText.js";import{getErrorMessage as u}from"../../../../../../utils/getErrorMessage.js";const m=m=>{const{i18n:f}=i(),{configuration:{disableOtpAutoFocus:g}}=l(),[C,j]=t(null),{handleChangeFor:F,data:b,triggerValidation:h,valid:k,errors:v,isValid:x,setData:E}=p({schema:["otp"],rules:a}),P=r({validateInput:null}),I=r(null),[R,y]=t(!1),M=o(()=>{y(!0),h()},[h]);s(()=>{b.otp&&y(!0)},[b.otp]),s(()=>{!g&&I.current&&I.current.focus()},[I.current,g]),s(()=>{P.current.validateInput=M,m.onSetInputHandlers(P.current)},[M,m.onSetInputHandlers]);const V=o(()=>{E("otp",""),j(null),g||I.current.focus(),m.onResendCode()},[m.onResendCode,I.current,g]),_=o(e=>{const t=f.get(`ctp.errors.${e}`);t&&j(t)},[f]),w=o(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);s(()=>{m.onChange({data:b,valid:k,errors:v,isValid:x})},[b,k,v]);const L=o(()=>R?C||m.errorMessage||u(f,v.otp,f.get("ctp.otp.fieldLabel")):null,[R,C,m.errorMessage,v.otp,f]);return e("div",{className:"adyen-checkout-ctp__otp-field-wrapper"},e(d,{name:"oneTimePassword",label:f.get("ctp.otp.fieldLabel"),errorMessage:L(),classNameModifiers:["otp"]},e(c,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:m.disabled,onInput:F("otp","input"),onBlur:F("otp","blur"),onKeyPress:w,setRef:e=>{I.current=e}})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:m.isValidatingOtp,onError:_,onResendCode:V})))};export{m as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as d}from"../../../../../../utils/setFocus.js";import u from"../../../../FormFields/Field/Field.js";import c from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&d(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(u,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(c,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e}})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
2
2
  //# sourceMappingURL=CtPOneTimePasswordInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../../utils/useForm';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useForm<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field name=\"oneTimePassword\" label={i18n.get('ctp.otp.fieldLabel')} errorMessage={getOtpErrorMessage()} classNameModifiers={['otp']}>\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useForm","schema","rules","otpValidationRules","otpInputHandlersRef","useRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","errorMessage","getErrorMessage","h","div","className","Field","name","label","classNameModifiers","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","ref","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"6pBAiCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,OACvDC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAA0C,CAC5HC,OAHe,CAAC,OAIhBC,MAAOC,IAELC,EAAsBC,EAAwC,CAAEC,cAAe,OAC/EC,EAAWF,EAAyB,OACnCG,EAAgBC,GAAsBjB,GAAkB,GAEzDc,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,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LvC,EAASM,QAAUiC,MAI/BhB,EAACC,MAAAA,CAAIC,UAAW,+CACZF,EAACiB,EAAAA,CAAiBN,SAAUzD,EAAMgE,gBAAiBC,QAAS/B,EAAwBD,aAAcD"}
1
+ {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBA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,EAAMiC,aAAclB,EAAOe,IAAK7B,IAEpE,OACIgD,EAACC,MAAAA,CAAIC,IAAK1C,EAAc2C,UAAW,yCAC/BH,EAACI,EAAAA,CACGC,KAAK,kBACLC,MAAOtD,EAAKwC,IAAI,sBAChBR,aAAcc,IACdS,mBAAoB,CAAC,OACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGJ,KAAM,MACNK,YAAa,MACbC,YAAY,EACZC,MAAOjD,EAAKkB,IACZgC,SAAU9D,EAAM8D,SAChBC,QAASpD,EAAgB,MAAO,SAChCqD,OAAQrD,EAAgB,MAAO,QAC/BsD,WAAYvB,EACZwB,OAASf,IACL1B,EAASM,QAAUoB,MAI/BF,EAACC,MAAAA,CAAIE,UAAW,+CACZH,EAACkB,EAAAA,CAAiBL,SAAU9D,EAAMoE,gBAAiBC,QAAS/B,EAAwBD,aAAcD"}
@@ -1,2 +1,2 @@
1
- import{getVisaSetttings as e,VISA_SDK_PROD as t,VISA_SDK_TEST as r}from"./config.js";import n from"./AbstractSrcInitiator.js";import i from"./SrciError.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(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}const s={email:"EMAIL",telephoneNumber:"MOBILE_NUMBER"};class a extends n{isSdkIsAvailableOnWindow(){var e;return!!(null===(e=window.vAdapters)||void 0===e?void 0:e.VisaSRCI)}assignSdkReference(){this.schemeSdk=new window.vAdapters.VisaSRCI}async init(t,r){try{const n=c(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){o(e,t,r[t])})}return e}({},t,e(this.customSdkConfiguration)),{srciTransactionId:r});await this.schemeSdk.init(n)}catch(e){throw new i(e,"init",this.schemeName)}}async identityLookup({identityValue:e,type:t}){try{const r={identityValue:e,type:s[t]};return await this.schemeSdk.identityLookup(r)}catch(e){throw new i(e,"identityLookup",this.schemeName)}}async completeIdentityValidation(e){try{return await this.schemeSdk.completeIdentityValidation(e)}catch(e){throw new i(e,"completeIdentityValidation",this.schemeName)}}constructor(e,n,i){super(e.toLowerCase().includes("live")?t:r,n,i),o(this,"schemeName","visa")}}export{a as default};
1
+ import{getVisaSetttings as t,VISA_SDK_PROD as e,VISA_SDK_TEST as r}from"./config.js";import n from"./AbstractSrcInitiator.js";import i from"./SrciError.js";function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}const s={email:"EMAIL",telephoneNumber:"MOBILE_NUMBER"};class a extends n{isSdkIsAvailableOnWindow(){var t;return!!(null===(t=window.vAdapters)||void 0===t?void 0:t.VisaSRCI)}assignSdkReference(){this.schemeSdk=new window.vAdapters.VisaSRCI}async init(e,r){try{const n=c(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){o(t,e,r[e])})}return t}({},e,t(this.customSdkConfiguration)),{srciTransactionId:r});await this.schemeSdk.init(n);const i=document.getElementById("vcop-src-system-frame");null==i||i.setAttribute("aria-hidden","true"),null==i||i.setAttribute("tabindex","-1"),null==i||i.setAttribute("inert","")}catch(t){throw new i(t,"init",this.schemeName)}}async identityLookup({identityValue:t,type:e}){try{const r={identityValue:t,type:s[e]};return await this.schemeSdk.identityLookup(r)}catch(t){throw new i(t,"identityLookup",this.schemeName)}}async completeIdentityValidation(t){try{return await this.schemeSdk.completeIdentityValidation(t)}catch(t){throw new i(t,"completeIdentityValidation",this.schemeName)}}constructor(t,n,i){super(t.toLowerCase().includes("live")?e:r,n,i),o(this,"schemeName","visa")}}export{a as default};
2
2
  //# sourceMappingURL=VisaSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VisaSdk.js","sources":["../../../../../../../src/components/internal/ClickToPay/services/sdks/VisaSdk.ts"],"sourcesContent":["import { getVisaSetttings, VISA_SDK_PROD, VISA_SDK_TEST } from './config';\nimport AbstractSrcInitiator from './AbstractSrcInitiator';\nimport SrciError, { MastercardError, VisaError } from './SrciError';\nimport type {\n CustomSdkConfiguration,\n SrciCompleteIdentityValidationResponse,\n SrcIdentityLookupParams,\n SrciIdentityLookupResponse,\n SrcInitParams\n} from './types';\nimport type { IAnalytics } from '../../../../../core/Analytics/Analytics';\n\nconst IdentityTypeMap = {\n email: 'EMAIL',\n telephoneNumber: 'MOBILE_NUMBER'\n};\n\nclass VisaSdk extends AbstractSrcInitiator {\n public readonly schemeName = 'visa';\n\n constructor(environment: string, customSdkConfig: CustomSdkConfiguration, analytics: IAnalytics) {\n super(environment.toLowerCase().includes('live') ? VISA_SDK_PROD : VISA_SDK_TEST, customSdkConfig, analytics);\n }\n\n protected isSdkIsAvailableOnWindow(): boolean {\n // @ts-ignore vAdapters is created by the VISA sdk\n if (window.vAdapters?.VisaSRCI) return true;\n return false;\n }\n\n protected assignSdkReference(): void {\n // @ts-ignore vAdapters is created by the VISA sdk\n this.schemeSdk = new window.vAdapters.VisaSRCI();\n }\n\n public async init(params: SrcInitParams, srciTransactionId: string): Promise<void> {\n try {\n const sdkProps = {\n ...params,\n ...getVisaSetttings(this.customSdkConfiguration),\n srciTransactionId\n };\n\n await this.schemeSdk.init(sdkProps);\n } catch (err) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'init', this.schemeName);\n throw srciError;\n }\n }\n\n public async identityLookup({ identityValue, type }: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse> {\n try {\n const consumerIdentity = {\n identityValue,\n type: IdentityTypeMap[type]\n };\n\n const response = await this.schemeSdk.identityLookup(consumerIdentity);\n return response;\n } catch (err) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'identityLookup', this.schemeName);\n throw srciError;\n }\n }\n\n public async completeIdentityValidation(otp: string): Promise<SrciCompleteIdentityValidationResponse> {\n try {\n const response = await this.schemeSdk.completeIdentityValidation(otp);\n return response;\n } catch (err: unknown) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'completeIdentityValidation', this.schemeName);\n throw srciError;\n }\n }\n}\n\nexport default VisaSdk;\n"],"names":["IdentityTypeMap","email","telephoneNumber","VisaSdk","AbstractSrcInitiator","isSdkIsAvailableOnWindow","window","vAdapters","VisaSRCI","assignSdkReference","this","schemeSdk","init","params","srciTransactionId","sdkProps","_object_spread_props","_object_spread","getVisaSetttings","customSdkConfiguration","err","SrciError","schemeName","identityLookup","identityValue","type","consumerIdentity","completeIdentityValidation","otp","constructor","environment","customSdkConfig","analytics","super","toLowerCase","includes","VISA_SDK_PROD","VISA_SDK_TEST","_define_property"],"mappings":"ioBAYA,MAAMA,EAAkB,CACpBC,MAAO,QACPC,gBAAiB,iBAGrB,MAAMC,UAAgBC,EAORC,wBAAAA,GAEFC,IAAAA,EAAJ,SAAoB,QAAhBA,EAAAA,OAAOC,qBAAPD,SAAAA,EAAkBE,SAE1B,CAEUC,kBAAAA,GAENC,KAAKC,UAAY,IAAIL,OAAOC,UAAUC,QAC1C,CAEA,UAAaI,CAAKC,EAAuBC,GACrC,IACI,MAAMC,EAAWC,oUAAAC,CAAA,CAAA,EACVJ,EACAK,EAAiBR,KAAKS,yBAAsB,CAC/CL,4BAGEJ,KAAKC,UAAUC,KAAKG,EAC9B,CAAE,MAAOK,GAEL,MADkB,IAAIC,EAAUD,EAAoC,OAAQV,KAAKY,WAErF,CACJ,CAEA,oBAAaC,EAAeC,cAAEA,EAAaC,KAAEA,IACzC,IACI,MAAMC,EAAmB,CACrBF,gBACAC,KAAMzB,EAAgByB,IAI1B,aADuBf,KAAKC,UAAUY,eAAeG,EAEzD,CAAE,MAAON,GAEL,MADkB,IAAIC,EAAUD,EAAoC,iBAAkBV,KAAKY,WAE/F,CACJ,CAEA,gCAAaK,CAA2BC,GACpC,IAEI,aADuBlB,KAAKC,UAAUgB,2BAA2BC,EAErE,CAAE,MAAOR,GAEL,MADkB,IAAIC,EAAUD,EAAoC,6BAA8BV,KAAKY,WAE3G,CACJ,CArDA,WAAAO,CAAYC,EAAqBC,EAAyCC,GACtEC,MAAMH,EAAYI,cAAcC,SAAS,QAAUC,EAAgBC,EAAeN,EAAiBC,GAHvGM,EAAA5B,KAAgBY,aAAa,OAI7B"}
1
+ {"version":3,"file":"VisaSdk.js","sources":["../../../../../../../src/components/internal/ClickToPay/services/sdks/VisaSdk.ts"],"sourcesContent":["import { getVisaSetttings, VISA_SDK_PROD, VISA_SDK_TEST } from './config';\nimport AbstractSrcInitiator from './AbstractSrcInitiator';\nimport SrciError, { MastercardError, VisaError } from './SrciError';\nimport type {\n CustomSdkConfiguration,\n SrciCompleteIdentityValidationResponse,\n SrcIdentityLookupParams,\n SrciIdentityLookupResponse,\n SrcInitParams\n} from './types';\nimport type { IAnalytics } from '../../../../../core/Analytics/Analytics';\n\nconst IdentityTypeMap = {\n email: 'EMAIL',\n telephoneNumber: 'MOBILE_NUMBER'\n};\n\nclass VisaSdk extends AbstractSrcInitiator {\n public readonly schemeName = 'visa';\n\n constructor(environment: string, customSdkConfig: CustomSdkConfiguration, analytics: IAnalytics) {\n super(environment.toLowerCase().includes('live') ? VISA_SDK_PROD : VISA_SDK_TEST, customSdkConfig, analytics);\n }\n\n protected isSdkIsAvailableOnWindow(): boolean {\n // @ts-ignore vAdapters is created by the VISA sdk\n if (window.vAdapters?.VisaSRCI) return true;\n return false;\n }\n\n protected assignSdkReference(): void {\n // @ts-ignore vAdapters is created by the VISA sdk\n this.schemeSdk = new window.vAdapters.VisaSRCI();\n }\n\n public async init(params: SrcInitParams, srciTransactionId: string): Promise<void> {\n try {\n const sdkProps = {\n ...params,\n ...getVisaSetttings(this.customSdkConfiguration),\n srciTransactionId\n };\n\n await this.schemeSdk.init(sdkProps);\n const systemIframe = document.getElementById('vcop-src-system-frame');\n systemIframe?.setAttribute('aria-hidden', 'true');\n systemIframe?.setAttribute('tabindex', '-1');\n systemIframe?.setAttribute('inert', '');\n } catch (err) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'init', this.schemeName);\n throw srciError;\n }\n }\n\n public async identityLookup({ identityValue, type }: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse> {\n try {\n const consumerIdentity = {\n identityValue,\n type: IdentityTypeMap[type]\n };\n\n const response = await this.schemeSdk.identityLookup(consumerIdentity);\n return response;\n } catch (err) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'identityLookup', this.schemeName);\n throw srciError;\n }\n }\n\n public async completeIdentityValidation(otp: string): Promise<SrciCompleteIdentityValidationResponse> {\n try {\n const response = await this.schemeSdk.completeIdentityValidation(otp);\n return response;\n } catch (err: unknown) {\n const srciError = new SrciError(err as VisaError | MastercardError, 'completeIdentityValidation', this.schemeName);\n throw srciError;\n }\n }\n}\n\nexport default VisaSdk;\n"],"names":["IdentityTypeMap","email","telephoneNumber","VisaSdk","AbstractSrcInitiator","isSdkIsAvailableOnWindow","window","vAdapters","VisaSRCI","assignSdkReference","this","schemeSdk","init","params","srciTransactionId","sdkProps","_object_spread_props","_object_spread","getVisaSetttings","customSdkConfiguration","systemIframe","document","getElementById","setAttribute","err","SrciError","schemeName","identityLookup","identityValue","type","consumerIdentity","completeIdentityValidation","otp","constructor","environment","customSdkConfig","analytics","super","toLowerCase","includes","VISA_SDK_PROD","VISA_SDK_TEST","_define_property"],"mappings":"ioBAYA,MAAMA,EAAkB,CACpBC,MAAO,QACPC,gBAAiB,iBAGrB,MAAMC,UAAgBC,EAORC,wBAAAA,GAEFC,IAAAA,EAAJ,SAAoB,QAAhBA,EAAAA,OAAOC,qBAAPD,SAAAA,EAAkBE,SAE1B,CAEUC,kBAAAA,GAENC,KAAKC,UAAY,IAAIL,OAAOC,UAAUC,QAC1C,CAEA,UAAaI,CAAKC,EAAuBC,GACrC,IACI,MAAMC,EAAWC,oUAAAC,CAAA,CAAA,EACVJ,EACAK,EAAiBR,KAAKS,yBAAsB,CAC/CL,4BAGEJ,KAAKC,UAAUC,KAAKG,GAC1B,MAAMK,EAAeC,SAASC,eAAe,yBAC7CF,SAAAA,EAAcG,aAAa,cAAe,QAC1CH,SAAAA,EAAcG,aAAa,WAAY,MACvCH,SAAAA,EAAcG,aAAa,QAAS,GACxC,CAAE,MAAOC,GAEL,MADkB,IAAIC,EAAUD,EAAoC,OAAQd,KAAKgB,WAErF,CACJ,CAEA,oBAAaC,EAAeC,cAAEA,EAAaC,KAAEA,IACzC,IACI,MAAMC,EAAmB,CACrBF,gBACAC,KAAM7B,EAAgB6B,IAI1B,aADuBnB,KAAKC,UAAUgB,eAAeG,EAEzD,CAAE,MAAON,GAEL,MADkB,IAAIC,EAAUD,EAAoC,iBAAkBd,KAAKgB,WAE/F,CACJ,CAEA,gCAAaK,CAA2BC,GACpC,IAEI,aADuBtB,KAAKC,UAAUoB,2BAA2BC,EAErE,CAAE,MAAOR,GAEL,MADkB,IAAIC,EAAUD,EAAoC,6BAA8Bd,KAAKgB,WAE3G,CACJ,CAzDA,WAAAO,CAAYC,EAAqBC,EAAyCC,GACtEC,MAAMH,EAAYI,cAAcC,SAAS,QAAUC,EAAgBC,EAAeN,EAAiBC,GAHvGM,EAAAhC,KAAgBgB,aAAa,OAI7B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import n from"../FormFields/Field/Field.js";import a from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as o}from"./validate.js";import{useCoreContext as s}from"../../../core/Context/CoreProvider.js";import{getFormattedData as l}from"./utils.js";import m from"../../../utils/useForm/useForm.js";import c from"../FormFields/InputText.js";function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(r){u(e,r,t[r])})}return e}function d(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const f=["name","registrationNumber"];function b(u){const{label:f="",namePrefix:b,requiredFields:g,visibility:y}=u,{i18n:j}=s(),{handleChangeFor:O,triggerValidation:v,data:h,valid:F,errors:N,isValid:P}=m({schema:g,rules:p({},o,u.validationRules),defaultData:u.data}),w=r({});var D;Object.keys(w.current).length||(null===(D=u.setComponentRef)||void 0===D||D.call(u,w.current));w.current.showValidation=()=>{v()};const k=e=>`${b?`${b}.`:""}${e}`,C=e=>r=>{const{name:t}=r.target,i=t.split(`${b}.`).pop();O(i,e)(r)},M=e=>r=>{const{name:t}=r.target,i=t.split(`${b}.`).pop();O(i,e)(r)};return t(()=>{const e=l(h);u.onChange({data:e,valid:F,errors:N,isValid:P})},[h,F,N,P]),"hidden"===y?null:"readOnly"===y?e(a,d(p({},u),{data:h})):e(i,{classNameModifiers:[f],label:f},g.includes("name")&&e(n,{label:j.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!N.name,i18n:j,name:k("companyName")},e(c,{name:k("name"),value:h.name,classNameModifiers:["name"],onInput:M("input"),onBlur:C("blur"),spellcheck:!1})),g.includes("registrationNumber")&&e(n,{label:j.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!N.registrationNumber,i18n:j,name:k("registrationNumber")},e(c,{name:k("registrationNumber"),value:h.registrationNumber,classNameModifiers:["registrationNumber"],onInput:M("input"),onBlur:C("blur"),spellcheck:!1})))}b.defaultProps={data:{},onChange:()=>{},visibility:"editable",requiredFields:f,validationRules:o};export{f as COMPANY_DETAILS_SCHEMA,b as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import n from"../FormFields/Field/Field.js";import o from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as a}from"./validate.js";import{useCoreContext as s}from"../../../core/Context/CoreProvider.js";import{getFormattedData as l}from"./utils.js";import m from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import u from"../FormFields/InputText.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(r){c(e,r,t[r])})}return e}function d(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const b=["name","registrationNumber"];function f(c){const{label:b="",namePrefix:f,requiredFields:g,visibility:y}=c,{i18n:j}=s(),{handleChangeFor:O,triggerValidation:v,data:F,valid:h,errors:N,isValid:P}=m({schema:g,rules:p({},a,c.validationRules),defaultData:c.data}),w=r({});var C;Object.keys(w.current).length||(null===(C=c.setComponentRef)||void 0===C||C.call(c,w.current));w.current.showValidation=()=>{v()};const D=e=>`${f?`${f}.`:""}${e}`,k=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)},M=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)};return t(()=>{const e=l(F);c.onChange({data:e,valid:h,errors:N,isValid:P})},[F,h,N,P]),"hidden"===y?null:"readOnly"===y?e(o,d(p({},c),{data:F})):e(i,{classNameModifiers:[b],label:b},g.includes("name")&&e(n,{label:j.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!N.name,i18n:j,name:D("companyName")},e(u,{name:D("name"),value:F.name,classNameModifiers:["name"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1})),g.includes("registrationNumber")&&e(n,{label:j.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!N.registrationNumber,i18n:j,name:D("registrationNumber")},e(u,{name:D("registrationNumber"),value:F.registrationNumber,classNameModifiers:["registrationNumber"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1})))}f.defaultProps={data:{},onChange:()=>{},visibility:"editable",requiredFields:b,validationRules:a};export{b as COMPANY_DETAILS_SCHEMA,f as default};
2
2
  //# sourceMappingURL=CompanyDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompanyDetails.js","sources":["../../../../../src/components/internal/CompanyDetails/CompanyDetails.tsx"],"sourcesContent":["import { h, FocusEventHandler, InputEventHandler } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyCompanyDetails from './ReadOnlyCompanyDetails';\nimport { companyDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { getFormattedData } from './utils';\nimport { CompanyDetailsSchema, CompanyDetailsProps } from './types';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\n\nexport const COMPANY_DETAILS_SCHEMA = ['name', 'registrationNumber'];\n\nexport default function CompanyDetails(props: Readonly<CompanyDetailsProps>) {\n const { label = '', namePrefix, requiredFields, visibility } = props;\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<CompanyDetailsSchema>({\n schema: requiredFields,\n rules: { ...companyDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const companyDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(companyDetailsRef.current).length) {\n props.setComponentRef?.(companyDetailsRef.current);\n }\n\n // Expose method expected by (parent) Address.tsx\n companyDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n const eventHandler =\n (mode: HandleChangeForModeType): FocusEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const inputEventHandler =\n (mode: HandleChangeForModeType): InputEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyCompanyDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label}>\n {requiredFields.includes('name') && (\n <Field\n label={i18n.get('companyDetails.name')}\n classNameModifiers={['name']}\n errorMessage={!!errors.name}\n i18n={i18n}\n name={generateFieldName('companyName')}\n >\n <InputText\n name={generateFieldName('name')}\n value={data.name}\n classNameModifiers={['name']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n\n {requiredFields.includes('registrationNumber') && (\n <Field\n label={i18n.get('companyDetails.registrationNumber')}\n classNameModifiers={['registrationNumber']}\n errorMessage={!!errors.registrationNumber}\n i18n={i18n}\n name={generateFieldName('registrationNumber')}\n >\n <InputText\n name={generateFieldName('registrationNumber')}\n value={data.registrationNumber}\n classNameModifiers={['registrationNumber']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nCompanyDetails.defaultProps = {\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: COMPANY_DETAILS_SCHEMA,\n validationRules: companyDetailsValidationRules\n};\n"],"names":["COMPANY_DETAILS_SCHEMA","CompanyDetails","props","label","namePrefix","requiredFields","visibility","i18n","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","companyDetailsValidationRules","validationRules","defaultData","companyDetailsRef","useRef","Object","keys","current","length","setComponentRef","showValidation","generateFieldName","name","eventHandler","mode","e","target","key","split","pop","inputEventHandler","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyCompanyDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","InputText","value","onInput","onBlur","spellcheck","registrationNumber","defaultProps"],"mappings":"m2CAcaA,EAAyB,CAAC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K2C,IAAI,uBAChBH,mBAAoB,CAAC,QACrBI,eAAgBtC,EAAOkB,KACvBxB,KAAMA,EACNwB,KAAMD,EAAkB,gBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,QACxBuB,MAAO1C,EAAKoB,KACZgB,mBAAoB,CAAC,QACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,KAKvBnD,EAAe2C,SAAS,uBACrBJ,EAACK,EAAAA,CACG9C,MAAOI,EAAK2C,IAAI,qCAChBH,mBAAoB,CAAC,sBACrBI,eAAgBtC,EAAO4C,mBACvBlD,KAAMA,EACNwB,KAAMD,EAAkB,uBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,sBACxBuB,MAAO1C,EAAK8C,mBACZV,mBAAoB,CAAC,sBACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,KAMpC,CAEAvD,EAAeyD,aAAe,CAC1B/C,KAAM,CAAA,EACNgC,SAAU,OACVrC,WAAY,WACZD,eAAgBL,EAChBoB,gBAAiBD"}
1
+ {"version":3,"file":"CompanyDetails.js","sources":["../../../../../src/components/internal/CompanyDetails/CompanyDetails.tsx"],"sourcesContent":["import { h, FocusEventHandler, InputEventHandler } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyCompanyDetails from './ReadOnlyCompanyDetails';\nimport { companyDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { getFormattedData } from './utils';\nimport { CompanyDetailsSchema, CompanyDetailsProps } from './types';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\n\nexport const COMPANY_DETAILS_SCHEMA = ['name', 'registrationNumber'];\n\nexport default function CompanyDetails(props: Readonly<CompanyDetailsProps>) {\n const { label = '', namePrefix, requiredFields, visibility } = props;\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<CompanyDetailsSchema>({\n schema: requiredFields,\n rules: { ...companyDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const companyDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(companyDetailsRef.current).length) {\n props.setComponentRef?.(companyDetailsRef.current);\n }\n\n // Expose method expected by (parent) Address.tsx\n companyDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n const eventHandler =\n (mode: HandleChangeForModeType): FocusEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const inputEventHandler =\n (mode: HandleChangeForModeType): InputEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyCompanyDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label}>\n {requiredFields.includes('name') && (\n <Field\n label={i18n.get('companyDetails.name')}\n classNameModifiers={['name']}\n errorMessage={!!errors.name}\n i18n={i18n}\n name={generateFieldName('companyName')}\n >\n <InputText\n name={generateFieldName('name')}\n value={data.name}\n classNameModifiers={['name']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n\n {requiredFields.includes('registrationNumber') && (\n <Field\n label={i18n.get('companyDetails.registrationNumber')}\n classNameModifiers={['registrationNumber']}\n errorMessage={!!errors.registrationNumber}\n i18n={i18n}\n name={generateFieldName('registrationNumber')}\n >\n <InputText\n name={generateFieldName('registrationNumber')}\n value={data.registrationNumber}\n classNameModifiers={['registrationNumber']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nCompanyDetails.defaultProps = {\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: COMPANY_DETAILS_SCHEMA,\n validationRules: companyDetailsValidationRules\n};\n"],"names":["COMPANY_DETAILS_SCHEMA","CompanyDetails","props","label","namePrefix","requiredFields","visibility","i18n","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","companyDetailsValidationRules","validationRules","defaultData","companyDetailsRef","useRef","Object","keys","current","length","setComponentRef","showValidation","generateFieldName","name","eventHandler","mode","e","target","key","split","pop","inputEventHandler","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyCompanyDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","InputText","value","onInput","onBlur","spellcheck","registrationNumber","defaultProps"],"mappings":"u5CAcaA,EAAyB,CAAC,OAAQ,sBAEhC,SAASC,EAAeC,GACnC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,eAAEA,EAAcC,WAAEA,GAAeJ,GACzDK,KAAEA,GAASC,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA8B,CACvGC,OAAQX,EACRY,MAAOC,EAAA,CAAA,EAAKC,EAAkCjB,EAAMkB,iBACpDC,YAAanB,EAAMS,OAIjBW,EAAoBC,EAA4B,IAGlDrB,IAAAA,EADCsB,OAAOC,KAAKH,EAAkBI,SAASC,SACnB,QAArBzB,EAAAA,EAAM0B,2BAAN1B,GAAAA,EAAAA,KAAAA,EAAwBoB,EAAkBI,UAI9C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ACZV,mBAAoB,CAAC,sBACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,KAMpC,CAEAvD,EAAeyD,aAAe,CAC1B/C,KAAM,CAAA,EACNgC,SAAU,OACVrC,WAAY,WACZD,eAAgBL,EAChBoB,gBAAiBD"}
@@ -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:$,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};
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:L,name:S,onBlur:I,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,errorLive:Q}=y,U=null==G||G,X=D&&"string"==typeof w&&w.length>0,Y=q&&!X&&H&&H.length>0,Z=s(m(`adyen-checkout-${S}`)),ee=d(()=>B?`input-static-value-${h()}`:null,[B]),[te,ne]=u(!1),[ae,le]=u(!1);null!=W&&ne(!!W),null!=R&&le(!!R);const re=p(e=>{ne(!0),null==A||A(e)},[A]),oe=p(e=>{ne(!1),null==I||I(e),null==C||C(e)},[I,C]),ie=p(()=>t(n,null,"string"==typeof $&&t("span",{className:e({"adyen-checkout__label__text":!0,"adyen-checkout__label__text--error":w}),"data-id":S,"data-testid":S},$),"function"==typeof $&&$(),L&&t("span",{className:"adyen-checkout__label-adornment--end"},L),E&&t("span",{className:"adyen-checkout__helper-text"},E)),[$,w,L,E]),ce=p(()=>{const s=t("span",_(b(_({className:e({"adyen-checkout-contextual-text--error":!0,"adyen-checkout-contextual-text--hidden":!X})},U&&{id:`${Z.current}${i}`}),{"aria-hidden":U?void 0:"true"}),U&&Q&&{"aria-live":"polite"}),w),d=t("span",b(_({className:e({"adyen-checkout-contextual-text":!0,"adyen-checkout-contextual-text--hidden":!Y})},U&&{id:`${Z.current}${c}`}),{"aria-hidden":U?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:ee,className:"adyen-checkout__field-static-value"},B),a(k).map(e=>{const t=b(_({isValid:P,onFocusHandler:re,onBlurHandler:oe,isInvalid:!!w,"aria-owns":ee},S&&{uniqueId:Z.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,re,oe]),se=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(se,{onFocusField:M,name:S,disabled:g,filled:ae,focused:te,useLabelElement:V,uniqueId:Z.current,isSecuredField:!U,renderAlternativeToLabel:J},ie()),ce())};k.defaultProps={className:"",classNameModifiers:[],inputWrapperModifiers:[],useLabelElement:!0,showErrorElement:!0,showContextualElement:!0,renderAlternativeToLabel:()=>null};export{k as default};
2
2
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useMemo, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\nimport { PREFIX } from '../../Icon/constants';\nimport uuid from '../../../../utils/uuid';\n\nconst Field: FunctionalComponent<Readonly<FieldProps>> = props => {\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n staticValue,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel,\n onInputContainerClick\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText && contextualText.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const staticValueId = useMemo(() => (staticValue ? `input-static-value-${uuid()}` : null), [staticValue]);\n\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n data-testid={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n {/* The <div> element has a child <input> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n onClick={onInputContainerClick}\n >\n {staticValue && (\n <span id={staticValueId} className=\"adyen-checkout__field-static-value\">\n {staticValue}\n </span>\n )}\n\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const propsFromFieldComponent = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n 'aria-owns': staticValueId,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n\n return cloneElement(child as VNode, propsFromFieldComponent);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type={`${PREFIX}checkmark_black`} alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type={`${PREFIX}field_error`} alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n /**\n * Use cases:\n * - Not all form controls want/need a label e.g. many checkboxes describe what they are in their own markup and don't need the wrapping Field to also generate a labelling element\n * - securedFields *can't* have a label (screen-reader's can make the association, over different browser contexts, between the label and the input)\n */\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if we are NOT dealing with the label for a securedField... we can give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && name && { htmlFor: uniqueId, id: `${uniqueId}-label` })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n data-testid=\"form-field\"\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers?.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","staticValue","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","onInputContainerClick","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","staticValueId","useMemo","uuid","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","data-testid","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","undefined","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","onClick","toChildArray","child","propsFromFieldComponent","_object_spread_props","_object_spread","isInvalid","cloneElement","Spinner","size","Icon","type","PREFIX","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","htmlFor","defaultProps"],"mappings":"64CAYA,MAAMA,EAAmDC,IACrD,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBAChBA,EAAqBC,YACrBA,EAAWC,eACXA,EAEAC,OAAQC,EACRC,QAASC,EAAYC,KACrBA,EAAIC,6BACJA,EAA4BC,yBAC5BA,EAAwBC,sBACxBA,GACAhC,EAIEiC,EAAqBH,SAAAA,EACrBI,EAAYb,GAA4C,iBAAjBd,GAA6BA,EAAa4B,OAAS,EAC1FC,EAAcd,IAA0BY,GAAaV,GAAkBA,EAAeW,OAAS,EAE/FE,EAAWC,EAAOC,EAAY,kBAAkBzB,MAChD0B,EAAgBC,EAAQ,IAAOlB,EAAc,sB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,KACvD,CACI,+BAAgC7D,EAChC,+BAAgCI,EAChC,kCAAmCL,GAAYD,KAIvD8C,EAACiC,GAAAA,CACGlE,aAAcA,EACdJ,KAAMA,EACNT,SAAUA,EACVoB,OAAQA,GACRE,QAASA,GACTP,gBAAiBA,EACjBiB,SAAUA,EAASuB,QACnByB,gBAAiBpD,EACjBF,yBAA0BA,GAEzBmB,MAEJO,OAKb1D,EAAMyF,aAAe,CACjBtF,UAAW,GACXC,mBAAoB,GACpBM,sBAAuB,GACvBW,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBS,yBAA0B,IAAM"}
1
+ {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useMemo, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\nimport { PREFIX } from '../../Icon/constants';\nimport uuid from '../../../../utils/uuid';\n\nconst Field: FunctionalComponent<Readonly<FieldProps>> = props => {\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n staticValue,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel,\n onInputContainerClick,\n errorLive\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText && contextualText.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const staticValueId = useMemo(() => (staticValue ? `input-static-value-${uuid()}` : null), [staticValue]);\n\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n data-testid={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n {...(contextVisibleToSR && errorLive && { 'aria-live': 'polite' })}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n {/* The <div> element has a child <input> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n onClick={onInputContainerClick}\n >\n {staticValue && (\n <span id={staticValueId} className=\"adyen-checkout__field-static-value\">\n {staticValue}\n </span>\n )}\n\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const propsFromFieldComponent = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n 'aria-owns': staticValueId,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n\n return cloneElement(child as VNode, propsFromFieldComponent);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type={`${PREFIX}checkmark_black`} alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type={`${PREFIX}field_error`} alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n /**\n * Use cases:\n * - Not all form controls want/need a label e.g. many checkboxes describe what they are in their own markup and don't need the wrapping Field to also generate a labelling element\n * - securedFields *can't* have a label (screen-reader's can make the association, over different browser contexts, between the label and the input)\n */\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if we are NOT dealing with the label for a securedField... we can give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && name && { htmlFor: uniqueId, id: `${uniqueId}-label` })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n data-testid=\"form-field\"\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers?.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","staticValue","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","onInputContainerClick","errorLive","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","staticValueId","useMemo","uuid","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","data-testid","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","undefined","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","onClick","toChildArray","child","propsFromFieldComponent","_object_spread_props","_object_spread","isInvalid","cloneElement","Spinner","size","Icon","type","PREFIX","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","htmlFor","defaultProps"],"mappings":"64CAYA,MAAMA,EAAmDC,IACrD,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBAChBA,EAAqBC,YACrBA,EAAWC,e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,EACThB,UAAWqD,EAAW,CAClB,yBAAyB,EACzB,iCAAkC5B,EAClC,gCAAiCF,EACjC,kCAAmCpB,KAI3C,OAAOe,EAEHgC,EAACxC,QAAAA,EAAAA,CAAAA,EAAU2E,GAA2BD,GAAkBxE,GAAQ,CAAE0E,QAASlD,EAAUsB,GAAI,GAAGtB,YACvFrC,GAGL8B,EAAyBwD,EAAqBtF,EAAUqC,IAahE,IAMJ,OACIc,EAACe,MAAAA,CACGV,cAAY,aACZvD,UAAWqD,EACP,wBACArD,EACAC,eAAAA,EAAoBiE,IAAIC,GAAK,0BAA0BA,KACvD,CACI,+BAAgC9D,EAChC,+BAAgCI,EAChC,kCAAmCL,GAAYD,KAIvD+C,EAACiC,GAAAA,CACGnE,aAAcA,EACdJ,KAAMA,EACNT,SAAUA,EACVoB,OAAQA,GACRE,QAASA,GACTP,gBAAiBA,EACjBkB,SAAUA,EAASuB,QACnByB,gBAAiBpD,EACjBH,yBAA0BA,GAEzBoB,MAEJO,OAKb3D,EAAM0F,aAAe,CACjBvF,UAAW,GACXC,mBAAoB,GACpBM,sBAAuB,GACvBW,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBS,yBAA0B,IAAM"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import n from"../../../Img/Img.js";import{useMemo as r}from"../../../../../external/preact/hooks/dist/hooks.js";function a(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){a(e,t,o[t])})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function l(e,t){if(null==e)return{};var o,n,r,a={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(e)),r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var o,n,r={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)o=a[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o]);return r}(e,t),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}function d(t){let{filterable:o,toggleButtonRef:n,showList:r,selectListId:a}=t,d=l(t,["filterable","toggleButtonRef","showList","selectListId"]);if(o){const{id:t}=d,o=l(d,["id"]);return e("div",c(i({},o),{ref:n}))}return e("button",c(i({id:d.id,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":a,"aria-disabled":d.readonly,"aria-describedby":d.ariaDescribedBy,"aria-labelledby":d.id?`${d.id}-label ${d.id}-value`:void 0,type:"button"},d),{ref:n}))}function s(a){const{active:i,selected:c,inputText:l,readonly:s,showList:u,required:p}=a,b=r(()=>{const e=c.selectedOptionName||c.name;return!0!==("string"==typeof e&&""!==e.trim())},[c,a.placeholder]),f=c.selectedOptionName||c.name||a.placeholder||"",y=u?l:f,_=s?null:a.filterable?e=>{e.preventDefault(),document.activeElement===a.filterInputRef.current?a.showList||a.toggleList(e):a.filterInputRef.current&&a.filterInputRef.current.focus()}:a.toggleList,m=i.id?`listItem-${i.id}`:"";return e(d,{className:o({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":u,"adyen-checkout__dropdown__button--invalid":a.isInvalid,"adyen-checkout__dropdown__button--valid":a.isValid,"adyen-checkout__dropdown__button--disabled":c.disabled}),disabled:a.disabled,filterable:a.filterable,onClick:_,onKeyDown:s?null:a.onButtonKeyDown,toggleButtonRef:a.toggleButtonRef,id:a.id,showList:u,selectListId:a.selectListId},a.filterable?e(t,null,!u&&c.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:c.icon,alt:c.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":a.selectListId,"aria-expanded":u,"aria-owns":a.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:a.onInput,ref:a.filterInputRef,role:"combobox","aria-activedescendant":m,type:"text",readOnly:a.readonly,"aria-disabled":a.readonly,id:a.id,"aria-describedby":a.ariaDescribedBy,required:p}),!u&&c.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},c.secondaryText)):e(t,null,c.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:c.icon,alt:c.name}),e("span",{id:a.id?`${a.id}-value`:void 0,className:o("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":b})},f),c.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},c.secondaryText)))}export{s as default};
1
+ import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import n from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";import{useMemo as r}from"../../../../../external/preact/hooks/dist/hooks.js";function a(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]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){a(e,t,n[t])})}return e}function l(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var 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}function c(e,t){if(null==e)return{};var n,o,r,a={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(n=Reflect.ownKeys(Object(e)),r=0;r<n.length;r++)o=n[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o]);return a}if(a=function(e,t){if(null==e)return{};var n,o,r={},a=Object.getOwnPropertyNames(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}(e,t),Object.getOwnPropertySymbols)for(n=Object.getOwnPropertySymbols(e),r=0;r<n.length;r++)o=n[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o]);return a}function d(t){let{filterable:n,toggleButtonRef:o,showList:r,selectListId:a}=t,d=c(t,["filterable","toggleButtonRef","showList","selectListId"]);if(n){const{id:t}=d,n=c(d,["id"]);return e("div",l(i({},n),{ref:o}))}return e("button",l(i({id:d.id,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":a,"aria-disabled":d.readonly,"aria-describedby":d.ariaDescribedBy,"aria-labelledby":d.id?`${d.id}-label ${d.id}-value`:void 0,type:"button"},d),{ref:o}))}function s(a){const{active:i,selected:l,inputText:c,readonly:s,showList:u,required:p}=a,b=r(()=>{const e=l.selectedOptionName||l.name;return!0!==("string"==typeof e&&""!==e.trim())},[l,a.placeholder]),f=l.selectedOptionName||l.name||a.placeholder||"",y=u?null!=c?c:"":f,_=s?null:a.filterable?e=>{e.preventDefault(),document.activeElement===a.filterInputRef.current?a.showList||a.toggleList(e):a.filterInputRef.current&&a.filterInputRef.current.focus()}:a.toggleList,m=i.id?`listItem-${i.id}`:"";return e(d,{className:n({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":u,"adyen-checkout__dropdown__button--invalid":a.isInvalid,"adyen-checkout__dropdown__button--valid":a.isValid,"adyen-checkout__dropdown__button--disabled":l.disabled}),disabled:a.disabled,filterable:a.filterable,onClick:_,onKeyDown:s?null:a.onButtonKeyDown,toggleButtonRef:a.toggleButtonRef,id:a.id,showList:u,selectListId:a.selectListId},a.filterable?e(t,null,!u&&l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":a.selectListId,"aria-expanded":u,"aria-owns":a.selectListId,autoComplete:"off",className:n("adyen-checkout__filter-input",{"adyen-checkout__filter-input--placeholder":!u&&b}),onInput:a.onInput,ref:a.filterInputRef,role:"combobox","aria-activedescendant":m,type:"text",readOnly:a.readonly,"aria-disabled":a.readonly,id:a.id,"aria-describedby":a.ariaDescribedBy,required:p}),!u&&l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)):e(t,null,l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("span",{id:a.id?`${a.id}-value`:void 0,className:n("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":b})},f),l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)))}export{s as default};
2
2
  //# sourceMappingURL=SelectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, showList, selectListId, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return (\n <button\n id={props.id}\n aria-haspopup=\"listbox\"\n aria-expanded={showList}\n aria-controls={selectListId}\n aria-disabled={props.readonly}\n aria-describedby={props.ariaDescribedBy}\n aria-labelledby={props.id ? `${props.id}-label ${props.id}-value` : undefined}\n type={'button'}\n {...props}\n ref={toggleButtonRef}\n />\n );\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n showList={showList}\n selectListId={props.selectListId}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n id={props.id ? `${props.id}-value` : undefined}\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","_0","filterable","toggleButtonRef","showList","selectListId","props","id","strippedProps","h","div","ref","button","aria-haspopup","aria-expanded","aria-controls","aria-disabled","readonly","aria-describedby","ariaDescribedBy","aria-labelledby","undefined","type","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span","classnames"],"mappings":"8pDAOA,SAASA,EAAoBC,OAAAC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,aAAEA,GAAwBJ,EAAPK,EAAAA,EAAAA,EAAAA,4DACnF,GAAIJ,EAAY,CAEZ,MAAMK,GAAEA,GAAyBD,EAAlBE,EAAAA,EAAkBF,EAAAA,QACjC,OAAOG,EAACC,MAAAA,EAAAA,EAAAA,CAAAA,EAAQF,GAAAA,CAAeG,IAAKR,IACxC,CAEA,OACIM,EAACG,SAAAA,EAAAA,EAAAA,CACGL,GAAID,EAAMC,GACVM,gBAAc,UACdC,gBAAeV,EACfW,gBAAeV,EACfW,gBAAeV,EAAMW,SACrBC,mBAAkBZ,EAAMa,gBACxBC,kBAAiBd,EAAMC,GAAK,GAAGD,EAAMC,YAAYD,EAAMC,gBAAac,EACpEC,KAAM,UACFhB,GAAAA,CACJK,IAAKR,IAGjB,CAEA,SAASoB,EAAajB,GAClB,MAAMkB,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAAST,SAAEA,EAAQb,SAAEA,EAAQuB,SAAEA,GAAarB,EAEhEsB,EAAuBC,EAAQ,KACjC,MAAMC,EAAcL,EAASM,oBAAsBN,EAASO,KAE5D,OAAwB,KADoB,iBAAhBF,GAAmD,KAAvBA,EAAYG,SAErE,CAACR,EAAUnB,EAAM4B,cAGdJ,EAAcL,EAASM,oBAAsBN,EAASO,MAAQ1B,EAAM4B,aAAe,GAInFC,EAAmB/B,EAAWsB,EAAYI,EAc1CM,EAAiBnB,EAAW,KAAOX,EAAMJ,WAZ7BmC,IACdA,EAAEC,iBACEC,SAASC,gBAAkBlC,EAAMmC,eAAeC,QAC3CpC,EAAMF,UACPE,EAAMqC,WAAWN,GAEd/B,EAAMmC,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AAac,EACrCyB,UAAWwB,EAAW,yCAA0C,CAC5D,qDAAsD1C,KAGzDE,GAEJL,EAAS2C,eAAiB3D,EAAC4D,OAAAA,CAAKvB,UAAU,oDAAoDrB,EAAS2C,gBA+B5H"}
1
+ {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, showList, selectListId, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return (\n <button\n id={props.id}\n aria-haspopup=\"listbox\"\n aria-expanded={showList}\n aria-controls={selectListId}\n aria-disabled={props.readonly}\n aria-describedby={props.ariaDescribedBy}\n aria-labelledby={props.id ? `${props.id}-label ${props.id}-value` : undefined}\n type={'button'}\n {...props}\n ref={toggleButtonRef}\n />\n );\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n // When list is open, show user's typed input (or empty); otherwise show selected value\n const textWhenListOpen = inputText ?? '';\n const displayInputText = showList ? textWhenListOpen : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n showList={showList}\n selectListId={props.selectListId}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n id={props.id ? `${props.id}-value` : undefined}\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className={classnames('adyen-checkout__filter-input', {\n 'adyen-checkout__filter-input--placeholder': !showList && isShowingPlaceholder\n })}\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","_0","filterable","toggleButtonRef","showList","selectListId","props","id","strippedProps","h","div","ref","button","aria-haspopup","aria-expanded","aria-controls","aria-disabled","readonly","aria-describedby","ariaDescribedBy","aria-labelledby","undefined","type","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-owns","autoComplete","classnames","onInput","role","aria-activedescendant","readOnly","secondaryText","span"],"mappings":"8pDAOA,SAASA,EAAoBC,OAAAC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,aAAEA,GAAwBJ,EAAPK,EAAAA,EAAAA,EAAAA,4DACnF,GAAIJ,EAAY,CAEZ,MAAMK,GAAEA,GAAyBD,EAAlBE,EAAAA,EAAkBF,EAAAA,QACjC,OAAOG,EAACC,MAAAA,EAAAA,EAAAA,CAAAA,EAAQF,GAAAA,CAAeG,IAAKR,IACxC,CAEA,OACIM,EAACG,SAAAA,EAAAA,EAAAA,CACGL,GAAID,EAAMC,GACVM,gBAAc,UACdC,gBAAeV,EACfW,gBAAeV,EACfW,gBAAeV,EAAMW,SACrBC,mBAAkBZ,EAAMa,gBACxBC,kBAAiBd,EAAMC,GAAK,GAAGD,EAAMC,YAAYD,EAAMC,gBAAac,EACpEC,KAAM,UACFhB,GAAAA,CACJK,IAAKR,IAGjB,CAEA,SAASoB,EAAajB,GAClB,MAAMkB,OAAEA,EAAMC,S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ACbjB,UAAWkB,EAAW,+BAAgC,CAClD,6CAA8C5D,GAAYwB,IAE9DqC,QAAS3D,EAAM2D,QACftD,IAAKL,EAAMmC,eACXyB,KAAK,WACLC,wBAAuBtB,EACvBvB,KAAK,OACL8C,SAAU9D,EAAMW,SAChBD,gBAAeV,EAAMW,SACrBV,GAAID,EAAMC,GACVW,mBAAkBZ,EAAMa,gBACxBQ,SAAUA,KAEZvB,GAAYqB,EAAS4C,eACnB5D,EAAC6D,OAAAA,CAAKxB,UAAU,oDAAoDrB,EAAS4C,gBArCrF5D,EAAC6C,OACI7B,EAAS8B,MAAQ9C,EAAC+C,EAAAA,CAAIV,UAAU,yCAAyCW,IAAKhC,EAAS8B,KAAMG,IAAKjC,EAASO,OAC5GvB,EAAC6D,OAAAA,CACG/D,GAAID,EAAMC,GAAK,GAAGD,EAAMC,gBAAac,EACrCyB,UAAWkB,EAAW,yCAA0C,CAC5D,qDAAsDpC,KAGzDE,GAEJL,EAAS4C,eAAiB5D,EAAC6D,OAAAA,CAAKxB,UAAU,oDAAoDrB,EAAS4C,gBAiC5H"}
@@ -1 +1 @@
1
- {"version":3,"file":"Img.js","sources":["../../../../../src/components/internal/Img/Img.tsx"],"sourcesContent":["import { JSX } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Img.scss';\nimport { h } from 'preact';\nimport { ImgProps } from './types';\n\nexport default function Img(props: Readonly<ImgProps>) {\n const { backgroundUrl = '', className = '', classNameModifiers = [], src = '', alt = '', showOnError = false } = props;\n const [loaded, setLoaded] = useState(false);\n const imageRef = useRef(null);\n\n const handleLoad = () => {\n setLoaded(true);\n };\n\n const handleError = (e: JSX.TargetedEvent<HTMLImageElement, Event>) => {\n setLoaded(showOnError);\n props?.onError?.(e);\n };\n\n const classNames = cx(\n [className],\n 'adyen-checkout__image',\n { 'adyen-checkout__image--loaded': loaded },\n ...classNameModifiers.map(modifier => `adyen-checkout__image--${modifier}`)\n );\n\n useEffect(() => {\n const image = backgroundUrl ? new Image() : imageRef.current;\n image.src = backgroundUrl || src;\n image.onload = handleLoad;\n setLoaded(!!image.complete);\n }, []);\n\n if (backgroundUrl) {\n return <div data-testid=\"background\" style={{ backgroundUrl } as JSX.CSSProperties} {...props} className={classNames} />;\n }\n\n return <img {...props} alt={alt} ref={imageRef} className={classNames} onError={handleError} />;\n}\n"],"names":["Img","props","backgroundUrl","className","classNameModifiers","src","alt","showOnError","loaded","setLoaded","useState","imageRef","useRef","handleLoad","classNames","cx","map","modifier","useEffect","image","Image","current","onload","complete","h","div","data-testid","style","img","ref","onError","e"],"mappings":"8/BAOe,SAASA,EAAIC,GACxB,MAAMC,cAAEA,EAAgB,GAAEC,UAAEA,EAAY,GAAEC,mBAAEA,EAAqB,GAAEC,IAAEA,EAAM,GAAEC,IAAEA,EAAM,GAAEC,YAAEA,GAAc,GAAUN,GAC1GO,EAAQC,GAAaC,GAAS,GAC/BC,EAAWC,EAAO,MAElBC,EAAa,KACfJ,GAAU,IAQRK,EAAaC,EACf,CAACZ,GACD,wBACA,CAAE,gCAAiCK,MAChCJ,EAAmBY,IAAIC,GAAY,0BAA0BA,MAUpE,OAPAC,EAAU,KACN,MAAMC,EAAQjB,EAAgB,IAAIkB,MAAUT,EAASU,QACrDF,EAAMd,IAAMH,GAAiBG,EAC7Bc,EAAMG,OAAST,EACfJ,IAAYU,EAAMI,WACnB,IAECrB,EACOsB,EAACC,MAAAA,EAAAA,EAAAA,CAAIC,cAAY,aAAaC,MAAO,CAAEzB,kBAA0CD,GAAAA,CAAOE,UAAWW,KAGvGU,EAACI,MAAAA,EAAAA,EAAAA,CAAAA,EAAQ3B,GAAAA,CAAOK,IAAKA,EAAKuB,IAAKlB,EAAUR,UAAWW,EAAYgB,QAvBlDC,IAEjB9B,IAAAA,EADAQ,EAAUF,GACVN,SAAc,QAAdA,EAAAA,EAAO6B,eAAP7B,IAAAA,GAAAA,OAAAA,EAAiB8B,MAsBzB"}
1
+ {"version":3,"file":"Img.js","sources":["../../../../../src/components/internal/Img/Img.tsx"],"sourcesContent":["import { JSX } from 'preact';\nimport { useRef, useState, useEffect } from 'preact/hooks';\nimport cx from 'classnames';\nimport './Img.scss';\nimport { h } from 'preact';\nimport { ImgProps } from './types';\n\nexport default function Img(props: Readonly<ImgProps>) {\n const { backgroundUrl = '', className = '', classNameModifiers = [], src = '', alt = '', showOnError = false } = props;\n const [loaded, setLoaded] = useState(false);\n const imageRef = useRef(null);\n\n const handleLoad = () => {\n setLoaded(true);\n };\n\n const handleError = (e: JSX.TargetedEvent<HTMLImageElement, Event>) => {\n setLoaded(showOnError);\n props?.onError?.(e);\n };\n\n const classNames = cx(\n [className],\n 'adyen-checkout__image',\n { 'adyen-checkout__image--loaded': loaded },\n ...classNameModifiers.map(modifier => `adyen-checkout__image--${modifier}`)\n );\n\n useEffect(() => {\n const image = backgroundUrl ? new Image() : imageRef.current;\n image.src = backgroundUrl || src;\n image.onload = handleLoad;\n setLoaded(!!image.complete);\n }, []);\n\n if (backgroundUrl) {\n return <div data-testid=\"background\" style={{ backgroundUrl }} {...props} className={classNames} />;\n }\n\n return <img {...props} alt={alt} ref={imageRef} className={classNames} onError={handleError} />;\n}\n"],"names":["Img","props","backgroundUrl","className","classNameModifiers","src","alt","showOnError","loaded","setLoaded","useState","imageRef","useRef","handleLoad","classNames","cx","map","modifier","useEffect","image","Image","current","onload","complete","h","div","data-testid","style","img","ref","onError","e"],"mappings":"8/BAOe,SAASA,EAAIC,GACxB,MAAMC,cAAEA,EAAgB,GAAEC,UAAEA,EAAY,GAAEC,mBAAEA,EAAqB,GAAEC,IAAEA,EAAM,GAAEC,IAAEA,EAAM,GAAEC,YAAEA,GAAc,GAAUN,GAC1GO,EAAQC,GAAaC,GAAS,GAC/BC,EAAWC,EAAO,MAElBC,EAAa,KACfJ,GAAU,IAQRK,EAAaC,EACf,CAACZ,GACD,wBACA,CAAE,gCAAiCK,MAChCJ,EAAmBY,IAAIC,GAAY,0BAA0BA,MAUpE,OAPAC,EAAU,KACN,MAAMC,EAAQjB,EAAgB,IAAIkB,MAAUT,EAASU,QACrDF,EAAMd,IAAMH,GAAiBG,EAC7Bc,EAAMG,OAAST,EACfJ,IAAYU,EAAMI,WACnB,IAECrB,EACOsB,EAACC,MAAAA,EAAAA,EAAAA,CAAIC,cAAY,aAAaC,MAAO,CAAEzB,kBAAqBD,GAAAA,CAAOE,UAAWW,KAGlFU,EAACI,MAAAA,EAAAA,EAAAA,CAAAA,EAAQ3B,GAAAA,CAAOK,IAAKA,EAAKuB,IAAKlB,EAAUR,UAAWW,EAAYgB,QAvBlDC,IAEjB9B,IAAAA,EADAQ,EAAUF,GACVN,SAAc,QAAdA,EAAAA,EAAO6B,eAAP7B,IAAAA,GAAAA,OAAAA,EAAiB8B,MAsBzB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import l from"../FormFields/Field/Field.js";import a from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as p}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function C(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const x=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:R}=F,k=C(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=c(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=m(),Q=null==H?void 0:H({}),U=r(null),W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:k.type,type:v.selected,target:s,issuer:r.name});k.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,k.type]),X=o(e=>{if(e){const e=new b({component:k.type,type:v.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),Y=r(y(k.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]),ee=r({setStatus:$,showValidation:()=>{L()}});n(()=>{k.setComponentRef(ee.current)},[k.setComponentRef]),n(()=>{k.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===d&&J&&p(U.current,"issuer-list")},[N,B,D,K]);const{highlightedItems:te}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(a,{selectedIssuerId:0===q?N.issuer:null,items:te,onChange:W(0)}),e(u,null)),e(l,{label:null!=R?R:T.get("issuerList.selectField.label"),errorMessage:(se=D.issuer,se&&se.errorMessage?T.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.showPayButton&&k.payButton({status:G,label:x({issuer:N.issuer,items:[...I,...te]},T)}));var se}F.defaultProps={onChange:()=>{}};export{F as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import{setFocusOnField as l}from"../../../utils/setFocus.js";import a from"../FormFields/Field/Field.js";import u from"./IssuerButtonGroup/IssuerButtonGroup.js";import c from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as m}from"../../../core/Context/CoreProvider.js";import d from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as p}from"../../../core/Errors/constants.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function C(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const x=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:R}=F,k=C(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=m(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=d(),Q=null==H?void 0:H({}),U=r(null),W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:k.type,type:v.selected,target:s,issuer:r.name});k.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,k.type]),X=o(e=>{if(e){const e=new b({component:k.type,type:v.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),Y=r(y(k.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]),ee=r({setStatus:$,showValidation:()=>{L()}});n(()=>{k.setComponentRef(ee.current)},[k.setComponentRef]),n(()=>{k.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===p&&J&&l(U.current,"issuer-list")},[N,B,D,K]);const{highlightedItems:te}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(u,{selectedIssuerId:0===q?N.issuer:null,items:te,onChange:W(0)}),e(c,null)),e(a,{label:null!=R?R:T.get("issuerList.selectField.label"),errorMessage:(se=D.issuer,se&&se.errorMessage?T.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.showPayButton&&k.payButton({status:G,label:x({issuer:N.issuer,items:[...I,...te]},T)}));var se}F.defaultProps={onChange:()=>{}};export{F as default};
2
2
  //# sourceMappingURL=IssuerList.js.map
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useMemo as r,useRef as t,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import l from"../FormFields/Fieldset/Fieldset.js";import s from"../FormFields/Field/Field.js";import i from"./ReadOnlyPersonalDetails.js";import{personalDetailsValidationRules as o}from"./validate.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{checkDateInputSupport as m}from"../FormFields/InputDate/utils.js";import{getFormattedData as p}from"./utils.js";import u from"../../../utils/useForm/useForm.js";import d from"../FormFields/InputText.js";import f from"../FormFields/InputDate/InputDate.js";import c from"../FormFields/InputEmail.js";import h from"../FormFields/InputTelephone.js";import{getErrorMessage as b}from"../../../utils/getErrorMessage.js";function N(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){N(e,r,t[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const j=["firstName","lastName","dateOfBirth","shopperEmail","telephoneNumber"];function F(N){const{label:j="",namePrefix:F,placeholders:y,requiredFields:v,visibility:M}=N,{i18n:B}=n(),E=r(m,[]),{handleChangeFor:P,triggerValidation:I,data:w,valid:D,errors:q,isValid:C}=u({schema:v,rules:O({},o,N.validationRules),defaultData:N.data}),k=t({showValidation:()=>{I()}});a(()=>{N.setComponentRef(k.current)},[N.setComponentRef]);const x=e=>r=>{const{name:t}=r.target,a=t.split(`${F}.`).pop();P(a,e)(r)},R=e=>`${F?`${F}.`:""}${e}`;return a(()=>{const e=p(w);N.onChange({data:e,valid:D,errors:q,isValid:C})},[w,D,q,C]),"hidden"===M?null:"readOnly"===M?e(i,g(O({},N),{data:w})):e(l,{classNameModifiers:["personalDetails"],label:j},v.includes("firstName")&&e(s,{label:B.get("firstName"),classNameModifiers:["col-50","firstName"],errorMessage:b(B,q.firstName,B.get("firstName")),name:"firstName",i18n:B},e(d,{name:R("firstName"),value:w.firstName,classNameModifiers:["firstName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.firstName,spellcheck:!1,required:!0})),v.includes("lastName")&&e(s,{label:B.get("lastName"),classNameModifiers:["col-50","lastName"],errorMessage:b(B,q.lastName,B.get("lastName")),name:"lastName",i18n:B},e(d,{name:R("lastName"),value:w.lastName,classNameModifiers:["lastName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.lastName,spellcheck:!1,required:!0})),v.includes("dateOfBirth")&&e(s,{label:B.get("dateOfBirth"),classNameModifiers:["col-50","dateOfBirth"],errorMessage:b(B,q.dateOfBirth,B.get("dateOfBirth")),helper:E?null:B.get("dateOfBirth.format"),name:"dateOfBirth",i18n:B},e(f,{name:R("dateOfBirth"),value:w.dateOfBirth,classNameModifiers:["dateOfBirth"],onInput:x("input"),onBlur:x("blur"),placeholder:y.dateOfBirth,required:!0})),v.includes("shopperEmail")&&e(s,{label:B.get("shopperEmail"),classNameModifiers:["shopperEmail"],errorMessage:b(B,q.shopperEmail,B.get("shopperEmail")),dir:"ltr",name:"emailAddress",i18n:B},e(c,{name:R("shopperEmail"),value:w.shopperEmail,classNameModifiers:["shopperEmail"],onInput:x("input"),onBlur:x("blur"),placeholder:y.shopperEmail,required:!0})),v.includes("telephoneNumber")&&e(s,{label:B.get("telephoneNumber"),classNameModifiers:["telephoneNumber"],errorMessage:b(B,q.telephoneNumber,B.get("telephoneNumber")),dir:"ltr",name:"telephoneNumber",i18n:B},e(h,{name:R("telephoneNumber"),value:w.telephoneNumber,classNameModifiers:["telephoneNumber"],onInput:x("input"),onBlur:x("blur"),placeholder:y.telephoneNumber,required:!0})))}F.defaultProps={data:{},onChange:()=>{},placeholders:{},requiredFields:j,validationRules:o,visibility:"editable"};export{j as PERSONAL_DETAILS_SCHEMA,F as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useMemo as r,useRef as t,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import s from"../FormFields/Fieldset/Fieldset.js";import i from"../FormFields/Field/Field.js";import l from"./ReadOnlyPersonalDetails.js";import{personalDetailsValidationRules as o}from"./validate.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{checkDateInputSupport as m}from"../FormFields/InputDate/utils.js";import{getFormattedData as p}from"./utils.js";import u from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import d from"../FormFields/InputText.js";import f from"../FormFields/InputDate/InputDate.js";import c from"../FormFields/InputEmail.js";import h from"../FormFields/InputTelephone.js";import{getErrorMessage as b}from"../../../utils/getErrorMessage.js";function N(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){N(e,r,t[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const j=["firstName","lastName","dateOfBirth","shopperEmail","telephoneNumber"];function F(N){const{label:j="",namePrefix:F,placeholders:y,requiredFields:v,visibility:M}=N,{i18n:B}=n(),E=r(m,[]),{handleChangeFor:P,triggerValidation:I,data:w,valid:D,errors:C,isValid:q}=u({schema:v,rules:O({},o,N.validationRules),defaultData:N.data}),k=t({showValidation:()=>{I()}});a(()=>{N.setComponentRef(k.current)},[N.setComponentRef]);const x=e=>r=>{const{name:t}=r.target,a=t.split(`${F}.`).pop();P(a,e)(r)},R=e=>`${F?`${F}.`:""}${e}`;return a(()=>{const e=p(w);N.onChange({data:e,valid:D,errors:C,isValid:q})},[w,D,C,q]),"hidden"===M?null:"readOnly"===M?e(l,g(O({},N),{data:w})):e(s,{classNameModifiers:["personalDetails"],label:j},v.includes("firstName")&&e(i,{label:B.get("firstName"),classNameModifiers:["col-50","firstName"],errorMessage:b(B,C.firstName,B.get("firstName")),name:"firstName",i18n:B},e(d,{name:R("firstName"),value:w.firstName,classNameModifiers:["firstName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.firstName,spellcheck:!1,required:!0})),v.includes("lastName")&&e(i,{label:B.get("lastName"),classNameModifiers:["col-50","lastName"],errorMessage:b(B,C.lastName,B.get("lastName")),name:"lastName",i18n:B},e(d,{name:R("lastName"),value:w.lastName,classNameModifiers:["lastName"],onInput:x("input"),onBlur:x("blur"),placeholder:y.lastName,spellcheck:!1,required:!0})),v.includes("dateOfBirth")&&e(i,{label:B.get("dateOfBirth"),classNameModifiers:["col-50","dateOfBirth"],errorMessage:b(B,C.dateOfBirth,B.get("dateOfBirth")),helper:E?null:B.get("dateOfBirth.format"),name:"dateOfBirth",i18n:B},e(f,{name:R("dateOfBirth"),value:w.dateOfBirth,classNameModifiers:["dateOfBirth"],onInput:x("input"),onBlur:x("blur"),placeholder:y.dateOfBirth,required:!0})),v.includes("shopperEmail")&&e(i,{label:B.get("shopperEmail"),classNameModifiers:["shopperEmail"],errorMessage:b(B,C.shopperEmail,B.get("shopperEmail")),dir:"ltr",name:"emailAddress",i18n:B},e(c,{name:R("shopperEmail"),value:w.shopperEmail,classNameModifiers:["shopperEmail"],onInput:x("input"),onBlur:x("blur"),placeholder:y.shopperEmail,required:!0})),v.includes("telephoneNumber")&&e(i,{label:B.get("telephoneNumber"),classNameModifiers:["telephoneNumber"],errorMessage:b(B,C.telephoneNumber,B.get("telephoneNumber")),dir:"ltr",name:"telephoneNumber",i18n:B},e(h,{name:R("telephoneNumber"),value:w.telephoneNumber,classNameModifiers:["telephoneNumber"],onInput:x("input"),onBlur:x("blur"),placeholder:y.telephoneNumber,required:!0})))}F.defaultProps={data:{},onChange:()=>{},placeholders:{},requiredFields:j,validationRules:o,visibility:"editable"};export{j as PERSONAL_DETAILS_SCHEMA,F as default};
2
2
  //# sourceMappingURL=PersonalDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { GenericEventHandler, h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\nimport './PersonalDetails.scss';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: Readonly<PersonalDetailsProps>) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n const personalDetailsRef = useRef<ComponentMethodsRef>({\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(personalDetailsRef.current);\n }, [props.setComponentRef]);\n\n const eventHandler =\n (mode: HandleChangeForModeType): GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellcheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellcheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","personalDetailsRef","useRef","showValidation","useEffect","setComponentRef","current","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellcheck","required","lastName","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"6oDAqBaA,EAA0B,CAAC,YAAa,WAAY,cAAe,eAAgB,mBAEjF,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAEXC,EAAuBC,EAAQC,EAAuB,KACtDC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA+B,CACxGC,OAAQd,EAERe,MAAOC,EAAA,CAAA,EAAKC,EAAmCrB,EAAMsB,iBACrDC,YAAavB,EAAMa,OAGjBW,EAAqB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AAa,SACtByB,OAAQzB,EAAa,QACrB0B,YAAarD,EAAa+D,gBAC1BR,UAAU,KAMlC,CAEA3D,EAAgBqE,aAAe,CAC3BvD,KAAM,CAAA,EACN4B,SAAU,OACVtC,aAAc,CAAA,EACdC,eAAgBN,EAChBwB,gBAAiBD,EACjBhB,WAAY"}
1
+ {"version":3,"file":"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { GenericEventHandler, h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\nimport './PersonalDetails.scss';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: Readonly<PersonalDetailsProps>) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n const personalDetailsRef = useRef<ComponentMethodsRef>({\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(personalDetailsRef.current);\n }, [props.setComponentRef]);\n\n const eventHandler =\n (mode: HandleChangeForModeType): GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellcheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellcheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","personalDetailsRef","useRef","showValidation","useEffect","setComponentRef","current","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellcheck","required","lastName","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"isDAqBaA,EAA0B,CAAC,YAAa,WAAY,cAAe,eAAgB,mBAEjF,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAEXC,EAAuBC,EAAQC,EAAuB,KACtDC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA+B,CACxGC,OAAQd,EAERe,MAAOC,EAAA,CAAA,EAAKC,EAAmCrB,EAAMsB,iBACrDC,YAAavB,EAAMa,OAGjBW,EAAqBC,EAA4B,CACnDC,eAAgB,KACZd,OAIRe,EAAU,KACN3B,EAAM4B,gBAAgBJ,EAAmBK,UAC1C,CAAC7B,EAAM4B,kBAEV,MAAME,EACDC,GACAC,IACG,MAAMC,KAAEA,GAASD,EAAEE,OACbC,EAAMF,EAAKG,MAAM,GAAGlC,MAAemC,MAEzC1B,EAAgBwB,EAAKJ,EAArBpB,CAA2BqB,IAG7BM,EAAqBL,GAAyB,GAAG/B,EAAa,GAAGA,KAAgB,KAAK+B,IAO5F,OALAN,EAAU,KACN,MAAMY,EAAgBC,EAAiB3B,GACvCb,EAAMyC,SAAS,CAAE5B,KAAM0B,EAAezB,QAAOC,SAAQC,aACtD,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAfX,EAAgC,KACjB,aAAfA,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