@adyen/adyen-web 6.46.0 → 6.47.0-alpha.41c41fe

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 (273) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +63 -46
  4. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  5. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  6. package/dist/es/components/AmazonPay/components/AmazonPayButton.js +1 -1
  7. package/dist/es/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  8. package/dist/es/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  9. package/dist/es/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  10. package/dist/es/components/AmazonPay/components/OrderButton.js +1 -1
  11. package/dist/es/components/AmazonPay/components/OrderButton.js.map +1 -1
  12. package/dist/es/components/AmazonPay/components/SignOutButton.js +1 -1
  13. package/dist/es/components/AmazonPay/components/SignOutButton.js.map +1 -1
  14. package/dist/es/components/AmazonPay/utils.js +1 -1
  15. package/dist/es/components/AmazonPay/utils.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  19. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  20. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  21. package/dist/es/components/CashAppPay/components/CashAppComponent.js +1 -1
  22. package/dist/es/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  23. package/dist/es/components/CashAppPay/services/CashAppService.js +1 -1
  24. package/dist/es/components/CashAppPay/services/CashAppService.js.map +1 -1
  25. package/dist/es/components/CashAppPay/services/types.js.map +1 -1
  26. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  27. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  28. package/dist/es/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js +1 -1
  29. package/dist/es/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js.map +1 -1
  30. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  31. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  32. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  33. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  34. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  35. package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
  36. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  37. package/dist/es/components/PayPal/Paypal.js +1 -1
  38. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  39. package/dist/es/components/PayPal/utils/get-paypal-locale.js.map +1 -1
  40. package/dist/es/components/PayPal/utils/get-paypal-settings.js +1 -1
  41. package/dist/es/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  42. package/dist/es/components/PayPalFastlane/Fastlane.js +1 -1
  43. package/dist/es/components/PayPalFastlane/Fastlane.js.map +1 -1
  44. package/dist/es/components/PayPalFastlane/FastlaneSDK.js +1 -1
  45. package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  46. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  47. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  48. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  49. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  50. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  51. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  52. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  53. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  54. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  55. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js +1 -1
  56. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  57. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  58. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  59. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  60. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  61. package/dist/es/components/internal/Address/Address.js +1 -1
  62. package/dist/es/components/internal/Address/Address.js.map +1 -1
  63. package/dist/es/components/internal/Address/Specifications.js +1 -1
  64. package/dist/es/components/internal/Address/Specifications.js.map +1 -1
  65. package/dist/es/components/internal/Address/components/AddressSearch.js +1 -1
  66. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  67. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  68. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  69. package/dist/es/components/internal/Address/constants.js.map +1 -1
  70. package/dist/es/components/internal/Address/utils.js.map +1 -1
  71. package/dist/es/components/internal/Address/validate.formats.js +1 -1
  72. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  73. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  74. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  75. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  76. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  77. package/dist/es/components/internal/CompanyDetails/validate.js +1 -1
  78. package/dist/es/components/internal/CompanyDetails/validate.js.map +1 -1
  79. package/dist/es/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.js.map +1 -1
  80. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  81. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  82. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  83. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  84. package/dist/es/components/internal/FormFields/InputDate/InputDate.js +1 -1
  85. package/dist/es/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  86. package/dist/es/components/internal/FormFields/InputDate/utils.js.map +1 -1
  87. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  88. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  89. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  90. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  91. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  92. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  93. package/dist/es/components/internal/IbanInput/specifications.js.map +1 -1
  94. package/dist/es/components/internal/IbanInput/utils.js +1 -1
  95. package/dist/es/components/internal/IbanInput/utils.js.map +1 -1
  96. package/dist/es/components/internal/PayButton/utils.js.map +1 -1
  97. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  98. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  99. package/dist/es/components/internal/PersonalDetails/validate.js +1 -1
  100. package/dist/es/components/internal/PersonalDetails/validate.js.map +1 -1
  101. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  102. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  103. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  104. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  105. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  106. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  107. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  108. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  109. package/dist/es/core/config.js +1 -1
  110. package/dist/es/core/config.js.map +1 -1
  111. package/dist/es/core/core.js +1 -1
  112. package/dist/es/core/core.js.map +1 -1
  113. package/dist/es/core/utils.js +1 -1
  114. package/dist/es/core/utils.js.map +1 -1
  115. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
  116. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  117. package/dist/es/index.d.ts +63 -46
  118. package/dist/es/utils/Script.js.map +1 -1
  119. package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
  120. package/dist/es/utils/Validator/Validator.js +1 -1
  121. package/dist/es/utils/Validator/Validator.js.map +1 -1
  122. package/dist/es/utils/Validator/defaultRules.js +1 -1
  123. package/dist/es/utils/Validator/defaultRules.js.map +1 -1
  124. package/dist/es/utils/browserInfo.js.map +1 -1
  125. package/dist/es/utils/createSdkData.js.map +1 -1
  126. package/dist/es/utils/get-issuer-image.js +1 -1
  127. package/dist/es/utils/get-issuer-image.js.map +1 -1
  128. package/dist/es/utils/get-process-message-handler.js.map +1 -1
  129. package/dist/es/utils/getConsentUrl.js +1 -1
  130. package/dist/es/utils/getConsentUrl.js.map +1 -1
  131. package/dist/es/utils/getErrorMessage.js.map +1 -1
  132. package/dist/es/utils/getOrigin.js.map +1 -1
  133. package/dist/es/utils/isValidURL.js +1 -1
  134. package/dist/es/utils/isValidURL.js.map +1 -1
  135. package/dist/es/utils/promiseTimeout.js.map +1 -1
  136. package/dist/es/utils/useAutoFocus.js.map +1 -1
  137. package/dist/es/utils/validator-utils.js +1 -1
  138. package/dist/es/utils/validator-utils.js.map +1 -1
  139. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  140. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  141. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js +1 -1
  142. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  143. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  144. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  145. package/dist/es-legacy/components/AmazonPay/components/OrderButton.js +1 -1
  146. package/dist/es-legacy/components/AmazonPay/components/OrderButton.js.map +1 -1
  147. package/dist/es-legacy/components/AmazonPay/components/SignOutButton.js +1 -1
  148. package/dist/es-legacy/components/AmazonPay/components/SignOutButton.js.map +1 -1
  149. package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
  150. package/dist/es-legacy/components/AmazonPay/utils.js.map +1 -1
  151. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  152. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  153. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  154. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  155. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  156. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js +1 -1
  157. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  158. package/dist/es-legacy/components/CashAppPay/services/CashAppService.js +1 -1
  159. package/dist/es-legacy/components/CashAppPay/services/CashAppService.js.map +1 -1
  160. package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
  161. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  162. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  163. package/dist/es-legacy/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js +1 -1
  164. package/dist/es-legacy/components/Dragonpay/components/DragonpayVoucherResult/DragonpayVoucherResult.js.map +1 -1
  165. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  166. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  167. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  168. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +1 -1
  169. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
  170. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
  171. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  172. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  173. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  174. package/dist/es-legacy/components/PayPal/utils/get-paypal-locale.js.map +1 -1
  175. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +1 -1
  176. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  177. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js +1 -1
  178. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js.map +1 -1
  179. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js +1 -1
  180. package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
  181. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  182. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  183. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  184. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  185. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  186. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  187. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  188. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  189. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  190. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js +1 -1
  191. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  192. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  193. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  194. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  195. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  196. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  197. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  198. package/dist/es-legacy/components/internal/Address/Specifications.js +1 -1
  199. package/dist/es-legacy/components/internal/Address/Specifications.js.map +1 -1
  200. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js +1 -1
  201. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  202. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  203. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  204. package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
  205. package/dist/es-legacy/components/internal/Address/utils.js.map +1 -1
  206. package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
  207. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  208. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  209. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  210. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  211. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  212. package/dist/es-legacy/components/internal/CompanyDetails/validate.js +1 -1
  213. package/dist/es-legacy/components/internal/CompanyDetails/validate.js.map +1 -1
  214. package/dist/es-legacy/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.js.map +1 -1
  215. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  216. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  217. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  218. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  219. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js +1 -1
  220. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  221. package/dist/es-legacy/components/internal/FormFields/InputDate/utils.js.map +1 -1
  222. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  223. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  224. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  225. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  226. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  227. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  228. package/dist/es-legacy/components/internal/IbanInput/specifications.js.map +1 -1
  229. package/dist/es-legacy/components/internal/IbanInput/utils.js +1 -1
  230. package/dist/es-legacy/components/internal/IbanInput/utils.js.map +1 -1
  231. package/dist/es-legacy/components/internal/PayButton/utils.js.map +1 -1
  232. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  233. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  234. package/dist/es-legacy/components/internal/PersonalDetails/validate.js +1 -1
  235. package/dist/es-legacy/components/internal/PersonalDetails/validate.js.map +1 -1
  236. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  237. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  238. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  239. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  240. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  241. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  242. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  243. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  244. package/dist/es-legacy/core/config.js +1 -1
  245. package/dist/es-legacy/core/config.js.map +1 -1
  246. package/dist/es-legacy/core/core.js +1 -1
  247. package/dist/es-legacy/core/core.js.map +1 -1
  248. package/dist/es-legacy/core/utils.js +1 -1
  249. package/dist/es-legacy/core/utils.js.map +1 -1
  250. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
  251. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  252. package/dist/es-legacy/utils/Script.js.map +1 -1
  253. package/dist/es-legacy/utils/Validator/ValidationRuleResult.js.map +1 -1
  254. package/dist/es-legacy/utils/Validator/Validator.js +1 -1
  255. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  256. package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
  257. package/dist/es-legacy/utils/Validator/defaultRules.js.map +1 -1
  258. package/dist/es-legacy/utils/browserInfo.js.map +1 -1
  259. package/dist/es-legacy/utils/createSdkData.js.map +1 -1
  260. package/dist/es-legacy/utils/get-issuer-image.js +1 -1
  261. package/dist/es-legacy/utils/get-issuer-image.js.map +1 -1
  262. package/dist/es-legacy/utils/get-process-message-handler.js.map +1 -1
  263. package/dist/es-legacy/utils/getConsentUrl.js +1 -1
  264. package/dist/es-legacy/utils/getConsentUrl.js.map +1 -1
  265. package/dist/es-legacy/utils/getErrorMessage.js.map +1 -1
  266. package/dist/es-legacy/utils/getOrigin.js.map +1 -1
  267. package/dist/es-legacy/utils/isValidURL.js +1 -1
  268. package/dist/es-legacy/utils/isValidURL.js.map +1 -1
  269. package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
  270. package/dist/es-legacy/utils/useAutoFocus.js.map +1 -1
  271. package/dist/es-legacy/utils/validator-utils.js +1 -1
  272. package/dist/es-legacy/utils/validator-utils.js.map +1 -1
  273. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nconst EMPTY_ADDRESS_DATA: Readonly<AddressData> = {};\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n // In partial address mode the country field is not rendered, so it is absent from the address schema.\n // The country the merchant configured must still be part of the form data for country dependent rules to be applied.\n const addressData = props.data ?? EMPTY_ADDRESS_DATA;\n const merchantCountry = addressData.country;\n const formSchema = merchantCountry && !requiredFieldsSchema.includes(COUNTRY) ? [...requiredFieldsSchema, COUNTRY] : requiredFieldsSchema;\n const defaultData = useMemo<AddressData>(\n () => (merchantCountry ? { ...addressData, country: merchantCountry.toUpperCase() } : addressData),\n [addressData, merchantCountry]\n );\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: formSchema,\n defaultData,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = defaultData[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["EMPTY_ADDRESS_DATA","Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","addressData","data","merchantCountry","country","formSchema","COUNTRY","defaultData","toUpperCase","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"68BAmBA,MAAMA,EAA4C,CAAA,EAEnC,SAASC,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAC5FQ,EAA2BC,EAAwBT,EAAMQ,YAAaL,GAGtEO,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCf,EAAMgB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAenB,EAAMiB,gBAAiB,CAACjB,EAAMiB,iBAEhFG,EAA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MA,EACNO,OAAQA,EACRC,MAAOA,EACPkC,UAAWA,EACXsB,QAAStD,EAAgBgC,EAAW,SACpCuB,OAAQvD,EAAgBgC,EAAW,QACnCwB,iBAAkBxD,EAAgBgC,EAAW,QAC7ChE,eAAgBA,EAChByF,UAAWC,EAA8BC,EAA2B3B,EAAW1C,EAAKE,SACpFoE,YAAY,EACZC,UAAWrC,GAAchD,SAASwD,GAClCzE,YAAaA,EACbuG,sBAAuB/G,EAAM+G,sBAC7BC,qBAAsBhH,EAAMgH,uBApBY,KA+B9CC,GAAgBhG,EAAeiG,2BAA2B3E,EAAKE,SAErE,OACIuD,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAAChG,EAAO,WAAYA,MAAOA,EAAOkH,6BAAAA,GAC3DpF,GACG+D,EAACsB,EAAAA,CACGpF,gBAAiBlC,EAAMkC,gBACvBqF,kBAAmBvH,EAAMuH,kBACzBC,SAAU5D,GACVU,gBAAiBA,GACjBmD,qBAAsB1F,EACtB2F,iBAAkBrF,EAClB9B,sBAAuBA,EACvBoH,eAAgB1H,EAAKuE,IAAI,iCACzBoD,wBAAyB5H,EAAM4H,0BAGtCvF,GACG2D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIrG,GAAUA,aAAiBsG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwExG,EAvB5EqG,IAAI,EAAErG,EAAOyG,KAAU/B,GAAa1E,EAAO,CAAE2E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa1E,EAAO,CAAA,MAK5H,CAEAzB,EAAQmI,aAAe,CACnB5G,YAAa,KACbmC,gBAAiB,KACjBlB,KAAM,CAAA,EACNwD,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChB/C,eAAgB,CAAA,EAChB8F,sBAAuB,OACvBC,qBAAsB"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nconst EMPTY_ADDRESS_DATA: Readonly<AddressData> = {};\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n // default some props, this is preferred over \"defaultProps\"\n const {\n allowedCountries = [],\n label = '',\n requiredFields = ADDRESS_SCHEMA,\n visibility = 'editable',\n iOSFocusedField = null,\n showContextualElement,\n onChange = () => {},\n onFieldFocusAnalytics = () => {},\n onFieldBlurAnalytics = () => {}\n } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n // In partial address mode the country field is not rendered, so it is absent from the address schema.\n // The country the merchant configured must still be part of the form data for country dependent rules to be applied.\n const addressData = props.data ?? EMPTY_ADDRESS_DATA;\n const merchantCountry = addressData.country;\n const formSchema = merchantCountry && !requiredFieldsSchema.includes(COUNTRY) ? [...requiredFieldsSchema, COUNTRY] : requiredFieldsSchema;\n const defaultData = useMemo<AddressData>(\n () => (merchantCountry ? { ...addressData, country: merchantCountry.toUpperCase() } : addressData),\n [addressData, merchantCountry]\n );\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: formSchema,\n defaultData,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = data.country && specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = defaultData[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }: { classNameModifiers?: string[] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={onFieldFocusAnalytics}\n onFieldBlurAnalytics={onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n"],"names":["EMPTY_ADDRESS_DATA","Address","props","i18n","useCoreContext","allowedCountries","label","requiredFields","ADDRESS_SCHEMA","visibility","iOSFocusedField","showContextualElement","onChange","onFieldFocusAnalytics","onFieldBlurAnalytics","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","addressData","data","merchantCountry","country","formSchema","COUNTRY","defaultData","toUpperCase","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size"],"mappings":"68BAmBA,MAAMA,EAA4C,CAAA,EAEnC,SAASC,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAGXC,iBACFA,EAAmB,GAAEC,MACrBA,EAAQ,GAAEC,eACVA,EAAiBC,EAAcC,WAC/BA,EAAa,WAAUC,gBACvBA,EAAkB,KAAIC,sBACtBA,EAAqBC,SACrBA,EAAW,OAAQC,sBACnBA,EAAwB,OAAQC,qBAChCA,EAAuB,QACvBZ,EACEa,EAA2BC,EAAwBd,EAAMa,YAAaT,GAGtEW,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCpB,EAAMqB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAexB,EAAMsB,gBAAiB,CA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AAoB,IAAIA,EAAoBjB,GAC5CzC,KAAMA,EACNO,OAAQA,EACRC,MAAOA,GACPiC,UAAWA,EACXoB,QAASnD,GAAgB+B,EAAW,SACpCqB,OAAQpD,GAAgB+B,EAAW,QACnCsB,iBAAkBrD,GAAgB+B,EAAW,QAC7C/D,eAAgBA,EAChBsF,UAAWC,EAA8BC,EAA2BzB,EAAWzC,EAAKE,SACpFiE,YAAY,EACZC,UAAWnC,GAAc/C,SAASuD,GAClCxE,YAAaA,EACbF,sBAAuBA,EACvBC,qBAAsBA,IApBkB,KA+B9CqG,GAAgB3F,EAAe4F,2BAA2BtE,EAAKE,SAErE,OACIqD,EAACgB,OACGhB,EAACiB,EAAAA,CAASd,mBAAoB,CAAClG,EAAO,WAAYA,MAAOA,EAAOiH,6BAAAA,GAC3D/E,GACG6D,EAACmB,EAAAA,CACG/E,gBAAiBvC,EAAMuC,gBACvBgF,kBAAmBvH,EAAMuH,kBACzBC,SAAUvD,GACVS,gBAAiBA,GACjB+C,qBAAsBrF,EACtBsF,iBAAkBhF,EAClBjC,sBAAuBA,EACvBkH,eAAgB1H,EAAK2E,IAAI,iCACzBgD,wBAAyB5H,EAAM4H,0BAGtClF,GACGyD,EAACgB,EAAAA,KAAUF,GAAcY,IAAIhG,GAAUA,aAAiBiG,MAxBpE3B,EAAC4B,MAAAA,CAAIC,UAAU,+BAwBwEnG,EAvB5EgG,IAAI,EAAEhG,EAAOoG,KAAU5B,GAAaxE,EAAO,CAAEyE,mBAAoB,CAAC,OAAO2B,SAuBY5B,GAAaxE,EAAO,CAAA,MAK5H"}
@@ -1,2 +1,2 @@
1
- import{ADDRESS_SPECIFICATIONS as e}from"./constants.js";class t{countryHasDataset(e){return!!this.specifications?.[e]?.hasDataset}countryHasOptionalField(e,t){return!!this.specifications?.[e]?.optionalFields?.includes(t)}getAddressSchemaForCountry(e){return this.specifications?.[e]?.schema||this.specifications.default.schema}getAddressLabelsForCountry(e){return this.specifications?.[e]?.labels||this.specifications.default.labels}getOptionalFieldsForCountry(e){return this.specifications?.[e]?.optionalFields||this.specifications.default?.optionalFields||[]}getKeyForField(e,t){return this.specifications?.[t]?.labels?.[e]||this.specifications?.default?.labels?.[e]||e}getPlaceholderKeyForField(e,t){return this.specifications?.[t]?.placeholders?.[e]||this.specifications?.default?.placeholders?.[e]}getAddressSchemaForCountryFlat(e){return this.getAddressSchemaForCountry(e).flat(2).filter(e=>"string"==typeof e)}constructor(t){var i,s,a;a=void 0,(s="specifications")in(i=this)?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,this.specifications={...e,...t}}}export{t as default};
1
+ import{ADDRESS_SPECIFICATIONS as e}from"./constants.js";class t{countryHasDataset(e){return!!this.specifications?.[e]?.hasDataset}countryHasOptionalField(e,t){return!!this.specifications?.[e]?.optionalFields?.includes(t)}getAddressSchemaForCountry(t){return t&&this.specifications?.[t]?.schema||this.specifications?.default?.schema||e.default.schema}getAddressLabelsForCountry(e){return e&&this.specifications?.[e]?.labels||this.specifications?.default?.labels}getOptionalFieldsForCountry(e){return e&&this.specifications?.[e]?.optionalFields||this.specifications?.default?.optionalFields||[]}getKeyForField(e,t){return t&&this.specifications?.[t]?.labels?.[e]||this.specifications?.default?.labels?.[e]||e}getPlaceholderKeyForField(e,t){return this.specifications?.[t]?.placeholders?.[e]||this.specifications?.default?.placeholders?.[e]}getAddressSchemaForCountryFlat(e){return this.getAddressSchemaForCountry(e).flat(2).filter(e=>"string"==typeof e)}constructor(t){var s,i,a;a=void 0,(i="specifications")in(s=this)?Object.defineProperty(s,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[i]=a,this.specifications={...e,...t}}}export{t as default};
2
2
  //# sourceMappingURL=Specifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Specifications.js","sources":["../../../../../src/components/internal/Address/Specifications.ts"],"sourcesContent":["import { AddressSchema, AddressSpecifications, StringObject } from './types';\nimport { ADDRESS_SPECIFICATIONS } from './constants';\nimport { AddressField } from '../../../types/global-types';\n\nconst SCHEMA_MAX_DEPTH = 2;\n\nclass Specifications {\n private specifications: AddressSpecifications;\n\n constructor(specifications?) {\n this.specifications = { ...ADDRESS_SPECIFICATIONS, ...specifications };\n }\n\n /**\n * Checks if a certain country has a dataset.\n * @param country - The selected country\n * @returns Boolean\n */\n countryHasDataset(country: string): boolean {\n return !!this.specifications?.[country]?.hasDataset;\n }\n\n /**\n * Checks if a certain country has the passed field in their optional fields array.\n * @param country - The selected country\n * @param fieldName - The field to be checked\n * @returns Boolean\n */\n countryHasOptionalField(country: string, fieldName: AddressField): boolean {\n return !!this.specifications?.[country]?.optionalFields?.includes(fieldName);\n }\n\n /**\n * Returns the address schema of the selected country or the default address schema.\n * @param country - The selected country\n * @returns AddressSchema\n */\n getAddressSchemaForCountry(country: string): AddressSchema {\n return this.specifications?.[country]?.schema || this.specifications.default.schema;\n }\n\n /**\n * Returns the address labels of the selected country or the default address labels.\n * @param country - The selected country\n * @returns StringObject\n */\n getAddressLabelsForCountry(country: string): StringObject {\n return this.specifications?.[country]?.labels || this.specifications.default.labels;\n }\n\n /**\n * Returns the optional fields of the selected country or the default optional fields.\n * @param country - The selected country\n * @returns Optional fields array\n */\n getOptionalFieldsForCountry(country: string): string[] {\n return this.specifications?.[country]?.optionalFields || this.specifications.default?.optionalFields || [];\n }\n\n /**\n * Returns the key for a field of the passed country or the default key for that field.\n * @param fieldName - The field to be searched\n * @param country - The selected country\n */\n getKeyForField(fieldName: string, country: string): string {\n return this.specifications?.[country]?.labels?.[fieldName] || this.specifications?.default?.labels?.[fieldName] || fieldName;\n }\n\n /**\n * Returns the placeholder key for a field of the passed country or the default key for that field.\n * @param fieldName - The field to be searched\n * @param country - The selected country\n */\n getPlaceholderKeyForField(fieldName: string, country: string): string {\n return this.specifications?.[country]?.placeholders?.[fieldName] || this.specifications?.default?.placeholders?.[fieldName];\n }\n\n /**\n * Returns an array with the address schema of the selected country or the default address schema\n * Flat version of getAddressSchemaForCountry\n * @param country - The selected country\n * @returns Array\n */\n getAddressSchemaForCountryFlat(country: string): AddressField[] {\n return this.getAddressSchemaForCountry(country)\n .flat(SCHEMA_MAX_DEPTH)\n .filter((element): element is AddressField => typeof element === 'string');\n }\n}\n\nexport default Specifications;\n"],"names":["Specifications","countryHasDataset","country","this","specifications","hasDataset","countryHasOptionalField","fieldName","optionalFields","includes","getAddressSchemaForCountry","schema","default","getAddressLabelsForCountry","labels","getOptionalFieldsForCountry","getKeyForField","getPlaceholderKeyForField","placeholders","getAddressSchemaForCountryFlat","flat","filter","element","constructor","ADDRESS_SPECIFICATIONS"],"mappings":"wDAMA,MAAMA,EAYFC,iBAAAA,CAAkBC,GACd,QAASC,KAAKC,iBAAiBF,IAAUG,UAC7C,CAQAC,uBAAAA,CAAwBJ,EAAiBK,GACrC,QAASJ,KAAKC,iBAAiBF,IAAUM,gBAAgBC,SAASF,EACtE,CAOAG,0BAAAA,CAA2BR,GACvB,OAAOC,KAAKC,iBAAiBF,IAAUS,QAAUR,KAAKC,eAAeQ,QAAQD,MACjF,CAOAE,0BAAAA,CAA2BX,GACvB,OAAOC,KAAKC,iBAAiBF,IAAUY,QAAUX,KAAKC,eAAeQ,QAAQE,MACjF,CAOAC,2BAAAA,CAA4Bb,GACxB,OAAOC,KAAKC,iBAAiBF,IAAUM,gBAAkBL,KAAKC,eAAeQ,SAASJ,gBAAkB,EAC5G,CAOAQ,cAAAA,CAAeT,EAAmBL,GAC9B,OAAOC,KAAKC,iBAAiBF,IAAUY,SAASP,IAAcJ,KAAKC,gBAAgBQ,SAASE,SAASP,IAAcA,CACvH,CAOAU,yBAAAA,CAA0BV,EAAmBL,GACzC,OAAOC,KAAKC,iBAAiBF,IAAUgB,eAAeX,IAAcJ,KAAKC,gBAAgBQ,SAASM,eAAeX,EACrH,CAQAY,8BAAAA,CAA+BjB,GAC3B,OAAOC,KAAKO,2BAA2BR,GAClCkB,KAjFY,GAkFZC,OAAQC,GAAwD,iBAAZA,EAC7D,CA9EA,WAAAC,CAAYnB,yBAFJA,sBAARD,4FAGIA,KAAKC,eAAiB,IAAKoB,KAA2BpB,EAC1D"}
1
+ {"version":3,"file":"Specifications.js","sources":["../../../../../src/components/internal/Address/Specifications.ts"],"sourcesContent":["import { AddressSchema, AddressSpecifications, StringObject } from './types';\nimport { ADDRESS_SPECIFICATIONS } from './constants';\nimport { AddressField } from '../../../types/global-types';\n\nconst SCHEMA_MAX_DEPTH = 2;\n\nclass Specifications {\n private specifications: Partial<AddressSpecifications>;\n\n constructor(specifications?: AddressSpecifications) {\n this.specifications = { ...ADDRESS_SPECIFICATIONS, ...specifications };\n }\n\n /**\n * Checks if a certain country has a dataset.\n * @param country - The selected country\n * @returns Boolean\n */\n countryHasDataset(country: string): boolean {\n return !!this.specifications?.[country]?.hasDataset;\n }\n\n /**\n * Checks if a certain country has the passed field in their optional fields array.\n * @param country - The selected country\n * @param fieldName - The field to be checked\n * @returns Boolean\n */\n countryHasOptionalField(country: string, fieldName: AddressField): boolean {\n return !!this.specifications?.[country]?.optionalFields?.includes(fieldName);\n }\n\n /**\n * Returns the address schema of the selected country or the default address schema.\n * @param country - The selected country\n * @returns AddressSchema\n */\n getAddressSchemaForCountry(country?: string): AddressSchema {\n return (country && this.specifications?.[country]?.schema) || this.specifications?.default?.schema || ADDRESS_SPECIFICATIONS.default.schema;\n }\n\n /**\n * Returns the address labels of the selected country or the default address labels.\n * @param country - The selected country\n * @returns StringObject\n */\n getAddressLabelsForCountry(country?: string): StringObject | undefined {\n return (country && this.specifications?.[country]?.labels) || this.specifications?.default?.labels;\n }\n\n /**\n * Returns the optional fields of the selected country or the default optional fields.\n * @param country - The selected country\n * @returns Optional fields array\n */\n getOptionalFieldsForCountry(country?: string): string[] {\n return (country && this.specifications?.[country]?.optionalFields) || this.specifications?.default?.optionalFields || [];\n }\n\n /**\n * Returns the key for a field of the passed country or the default key for that field.\n * @param fieldName - The field to be searched\n * @param country - The selected country\n */\n getKeyForField(fieldName: string, country?: string): string {\n return (country && this.specifications?.[country]?.labels?.[fieldName]) || this.specifications?.default?.labels?.[fieldName] || fieldName;\n }\n\n /**\n * Returns the placeholder key for a field of the passed country or the default key for that field.\n * @param fieldName - The field to be searched\n * @param country - The selected country\n */\n getPlaceholderKeyForField(fieldName: string, country: string): string | undefined {\n return this.specifications?.[country]?.placeholders?.[fieldName] || this.specifications?.default?.placeholders?.[fieldName];\n }\n\n /**\n * Returns an array with the address schema of the selected country or the default address schema\n * Flat version of getAddressSchemaForCountry\n * @param country - The selected country\n * @returns Array\n */\n getAddressSchemaForCountryFlat(country?: string): AddressField[] {\n return this.getAddressSchemaForCountry(country)\n .flat(SCHEMA_MAX_DEPTH)\n .filter((element): element is AddressField => typeof element === 'string');\n }\n}\n\nexport default Specifications;\n"],"names":["Specifications","countryHasDataset","country","this","specifications","hasDataset","countryHasOptionalField","fieldName","optionalFields","includes","getAddressSchemaForCountry","schema","default","ADDRESS_SPECIFICATIONS","getAddressLabelsForCountry","labels","getOptionalFieldsForCountry","getKeyForField","getPlaceholderKeyForField","placeholders","getAddressSchemaForCountryFlat","flat","filter","element","constructor"],"mappings":"wDAMA,MAAMA,EAYFC,iBAAAA,CAAkBC,GACd,QAASC,KAAKC,iBAAiBF,IAAUG,UAC7C,CAQAC,uBAAAA,CAAwBJ,EAAiBK,GACrC,QAASJ,KAAKC,iBAAiBF,IAAUM,gBAAgBC,SAASF,EACtE,CAOAG,0BAAAA,CAA2BR,GACvB,OAAOA,GAAYC,KAAKC,iBAAiBF,IAAUS,QAAWR,KAAKC,gBAAgBQ,SAASD,QAAUE,EAAuBD,QAAQD,MACzI,CAOAG,0BAAAA,CAA2BZ,GACvB,OAAOA,GAAYC,KAAKC,iBAAiBF,IAAUa,QAAWZ,KAAKC,gBAAgBQ,SAASG,MAChG,CAOAC,2BAAAA,CAA4Bd,GACxB,OAAOA,GAAYC,KAAKC,iBAAiBF,IAAUM,gBAAmBL,KAAKC,gBAAgBQ,SAASJ,gBAAkB,EAC1H,CAOAS,cAAAA,CAAeV,EAAmBL,GAC9B,OAAQA,GAAWC,KAAKC,iBAAiBF,IAAUa,SAASR,IAAeJ,KAAKC,gBAAgBQ,SAASG,SAASR,IAAcA,CACpI,CAOAW,yBAAAA,CAA0BX,EAAmBL,GACzC,OAAOC,KAAKC,iBAAiBF,IAAUiB,eAAeZ,IAAcJ,KAAKC,gBAAgBQ,SAASO,eAAeZ,EACrH,CAQAa,8BAAAA,CAA+BlB,GAC3B,OAAOC,KAAKO,2BAA2BR,GAClCmB,KAjFY,GAkFZC,OAAQC,GAAwD,iBAAZA,EAC7D,CA9EA,WAAAC,CAAYpB,yBAFJA,sBAARD,4FAGIA,KAAKC,eAAiB,IAAKS,KAA2BT,EAC1D"}
@@ -1,2 +1,2 @@
1
- import e from"../../FormFields/Field/Field.js";import{createElement as s}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as t,useEffect as r,useMemo as o}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import{debounce as d}from"../../../../utils/debounce.js";import c from"../../FormFields/Select/Select.js";function l({onAddressLookup:l,onAddressSelected:u,onSelect:i,onManualAddress:m,externalErrorMessage:h,hideManualButton:_,showContextualElement:p,contextualText:f,placeholder:k,addressSearchDebounceMs:b}){const[x,g]=a([]),[y,M]=a([]),[j,v]=a(""),{i18n:C}=n(),F=t(e=>{e?.errorMessage&&v(e.errorMessage)},[]),S=t(e=>{new Promise((s,a)=>{l(e,{resolve:s,reject:a})}).then(e=>{M(e),g(e.map(({id:e,name:s})=>({id:e,name:s}))),v("")}).catch(e=>F(e))},[l]);r(()=>{v(h)},[h]);const w=o(()=>d(S,b),[]);return s("div",{className:"adyen-checkout__address-search adyen-checkout__field-group"},s(e,{label:C.get("address"),classNameModifiers:["address-search"],errorMessage:j,name:"address-search",showContextualElement:p,contextualText:f},s(c,{name:"address-search",className:"adyen-checkout__address-search__dropdown",placeholder:k,onInput:w,items:x,onChange:e=>{if(!e.target.value)return void v(C.get("address.errors.incomplete"));const s=y.find(s=>s.id===e.target.value);if("function"!=typeof u)return i(s),void g([]);new Promise((e,a)=>{u(s,{resolve:e,reject:a})}).then(e=>{i(e),g([])}).catch(e=>F(e))},disableTextFilter:!0,blurOnClose:!0})),!_&&s("span",{className:"adyen-checkout__address-search__manual-add"},s("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button",onClick:m},"+ "+C.get("address.enterManually"))))}export{l as default};
1
+ import e from"../../FormFields/Field/Field.js";import{createElement as s}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as t,useEffect as r,useMemo as o}from"../../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import{debounce as d}from"../../../../utils/debounce.js";import c from"../../FormFields/Select/Select.js";function l({onAddressLookup:l,onAddressSelected:u,onSelect:i,onManualAddress:m,externalErrorMessage:h,hideManualButton:_,showContextualElement:p,contextualText:f,placeholder:k,addressSearchDebounceMs:b}){const[x,g]=a([]),[y,v]=a([]),[M,j]=a(""),{i18n:C}=n(),F=t(e=>{e?.errorMessage&&j(e.errorMessage)},[]),S=t(e=>{new Promise((s,a)=>{l(e,{resolve:s,reject:a})}).then(e=>{v(e),g(e.map(({id:e,name:s})=>({id:e,name:s}))),j("")}).catch(e=>F(e))},[l]);r(()=>{j(h)},[h]);const w=o(()=>d(S,b),[]);return s("div",{className:"adyen-checkout__address-search adyen-checkout__field-group"},s(e,{label:C.get("address"),classNameModifiers:["address-search"],errorMessage:M,name:"address-search",showContextualElement:p,contextualText:f},s(c,{name:"address-search",className:"adyen-checkout__address-search__dropdown",placeholder:k,onInput:w,items:x,onChange:e=>{if(!e.target.value)return void j(C.get("address.errors.incomplete"));const s=y.find(s=>s.id===e.target.value);return s?"function"!=typeof u?(i(s),void g([])):void new Promise((e,a)=>{u(s,{resolve:e,reject:a})}).then(e=>{i(e),g([])}).catch(e=>F(e)):void 0},disableTextFilter:!0,blurOnClose:!0})),!_&&s("span",{className:"adyen-checkout__address-search__manual-add"},s("button",{type:"button",className:"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button",onClick:m},"+ "+C.get("address.enterManually"))))}export{l as default};
2
2
  //# sourceMappingURL=AddressSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddressSearch.js","sources":["../../../../../../src/components/internal/Address/components/AddressSearch.tsx"],"sourcesContent":["import Field from '../../FormFields/Field';\nimport { h } from 'preact';\nimport { AddressLookupItem } from '../types';\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport './AddressSearch.scss';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { debounce } from '../../../../utils/debounce';\nimport Select from '../../FormFields/Select';\nimport { AddressData } from '../../../../types';\n\nexport type OnAddressLookupType = (\n value: string,\n actions: {\n resolve: (value: Array<AddressLookupItem>) => void;\n reject: (reason?: RejectionReason) => void;\n }\n) => Promise<void>;\n\nexport type OnAddressSelectedType = (\n value: AddressLookupItem,\n actions: {\n resolve: (value: AddressLookupItem) => void;\n reject: (reason?: RejectionReason) => void;\n }\n) => Promise<void>;\n\ninterface AddressSearchProps {\n onAddressLookup?: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n onSelect: (addressItem: AddressData) => void;\n onManualAddress: () => void;\n externalErrorMessage: string;\n hideManualButton: boolean;\n showContextualElement?: boolean;\n contextualText?: string;\n placeholder?: string;\n addressSearchDebounceMs?: number;\n}\n\ninterface RejectionReason {\n errorMessage: string;\n}\n\nexport default function AddressSearch({\n onAddressLookup,\n onAddressSelected,\n onSelect,\n onManualAddress,\n externalErrorMessage,\n hideManualButton,\n showContextualElement,\n contextualText,\n placeholder,\n addressSearchDebounceMs\n}: Readonly<AddressSearchProps>) {\n const [formattedData, setFormattedData] = useState<AddressLookupItem[]>([]);\n const [originalData, setOriginalData] = useState<AddressLookupItem[]>([]);\n\n const [errorMessage, setErrorMessage] = useState('');\n\n const { i18n } = useCoreContext();\n const mapDataToSelect = data => data.map(({ id, name }) => ({ id, name }));\n\n const handlePromiseReject = useCallback((reason: RejectionReason) => {\n if (reason?.errorMessage) {\n setErrorMessage(reason.errorMessage);\n }\n }, []);\n\n const onTextInput = useCallback(\n (inputValue: string) => {\n new Promise<Array<AddressLookupItem>>((resolve, reject) => {\n void onAddressLookup(inputValue, { resolve, reject });\n })\n .then(searchArray => {\n setOriginalData(searchArray);\n setFormattedData(mapDataToSelect(searchArray));\n setErrorMessage('');\n })\n .catch(reason => handlePromiseReject(reason));\n },\n [onAddressLookup]\n );\n\n // update error message when there's a new one\n useEffect(() => {\n setErrorMessage(externalErrorMessage);\n }, [externalErrorMessage]);\n\n const onSelectItem = event => {\n if (!event.target.value) {\n setErrorMessage(i18n.get('address.errors.incomplete'));\n return;\n }\n const value = originalData.find(item => item.id === event.target.value);\n\n // 1. in case we don't get a function just select item\n if (typeof onAddressSelected !== 'function') {\n onSelect(value);\n setFormattedData([]);\n return;\n }\n\n // 2. in case callback is provided, create and call onAddressSelected\n new Promise<AddressLookupItem>((resolve, reject) => {\n void onAddressSelected(value, { resolve, reject });\n })\n .then(fullData => {\n onSelect(fullData);\n setFormattedData([]);\n })\n .catch(reason => handlePromiseReject(reason));\n };\n\n const debounceInputHandler = useMemo(() => debounce(onTextInput, addressSearchDebounceMs), []);\n\n return (\n // The search field is intentionally rendered before the manual entry button in the DOM.\n // See: ../a11y.md\n <div className={'adyen-checkout__address-search adyen-checkout__field-group'}>\n <Field\n label={i18n.get('address')}\n classNameModifiers={['address-search']}\n errorMessage={errorMessage}\n name={'address-search'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n name={'address-search'}\n className={'adyen-checkout__address-search__dropdown'}\n placeholder={placeholder}\n onInput={debounceInputHandler}\n items={formattedData}\n onChange={onSelectItem}\n disableTextFilter={true}\n blurOnClose={true}\n />\n </Field>\n {!hideManualButton && (\n <span className=\"adyen-checkout__address-search__manual-add\">\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button\"\n onClick={onManualAddress}\n >\n {'+ ' + i18n.get('address.enterManually')}\n </button>\n </span>\n )}\n </div>\n );\n}\n"],"names":["AddressSearch","onAddressLookup","onAddressSelected","onSelect","onManualAddress","externalErrorMessage","hideManualButton","showContextualElement","contextualText","placeholder","addressSearchDebounceMs","formattedData","setFormattedData","useState","originalData","setOriginalData","errorMessage","setErrorMessage","i18n","useCoreContext","handlePromiseReject","useCallback","reason","onTextInput","inputValue","Promise","resolve","reject","then","searchArray","map","id","name","catch","useEffect","debounceInputHandler","useMemo","debounce","h","div","className","Field","label","get","classNameModifiers","Select","onInput","items","onChange","event","target","value","find","item","fullData","disableTextFilter","blurOnClose","span","button","type","onClick"],"mappings":"saA2Ce,SAASA,GAAcC,gBAClCA,EAAeC,kBACfA,EAAiBC,SACjBA,EAAQC,gBACRA,EAAeC,qBACfA,EAAoBC,iBACpBA,EAAgBC,sBAChBA,EAAqBC,eACrBA,EAAcC,YACdA,EAAWC,wBACXA,IAEA,MAAOC,EAAeC,GAAoBC,EAA8B,KACjEC,EAAcC,GAAmBF,EAA8B,KAE/DG,EAAcC,GAAmBJ,EAAS,KAE3CK,KAAEA,GAASC,IAGXC,EAAsBC,EAAaC,IACjCA,GAAQN,cACRC,EAAgBK,EAAON,eAE5B,IAEGO,EAAcF,EACfG,IACG,IAAIC,QAAkC,CAACC,EAASC,KACvC1B,EAAgBuB,EAAY,CAAEE,UAASC,aAE3CC,KAAKC,IACFd,EAAgBc,GAChBjB,EAAiCiB,EAfZC,IAAI,EAAGC,KAAIC,WAAM,CAAQD,KAAIC,WAgBlDf,EAAgB,MAEnBgB,MAAMX,GAAUF,EAAoBE,KAE7C,CAACrB,IAILiC,EAAU,KACNjB,EAAgBZ,IACjB,CAACA,IAEJ,MAyBM8B,EAAuBC,EAAQ,IAAMC,EAASd,EAAab,GAA0B,IAE3F,OAGI4B,EAACC,MAAAA,CAAIC,UAAW,8DACZF,EAACG,EAAAA,CACGC,MAAOxB,EAAKyB,IAAI,WAChBC,mBAAoB,CAAC,kBACrB5B,aAAcA,EACdgB,KAAM,iBACNzB,sBAAuBA,EACvBC,eAAgBA,GAEhB8B,EAACO,EAAAA,CACGb,KAAM,iBACNQ,UAAW,2CACX/B,YAAaA,EACbqC,QAASX,EACTY,MAAOpC,EACPqC,SA7CKC,IACjB,IAAKA,EAAMC,OAAOC,MAEd,YADAlC,EAAgBC,EAAKyB,IAAI,8BAG7B,MAAMQ,EAAQrC,EAAasC,KAAKC,GAAQA,EAAKtB,KAAOkB,EAAMC,OAAOC,OAGjE,GAAiC,mBAAtBjD,EAGP,OAFAC,EAASgD,QACTvC,EAAiB,IAKrB,IAAIa,QAA2B,CAACC,EAASC,KAChCzB,EAAkBiD,EAAO,CAAEzB,UAASC,aAExCC,KAAK0B,IACFnD,EAASmD,GACT1C,EAAiB,MAEpBqB,MAAMX,GAAUF,EAAoBE,KAwB7BiC,mBAAmB,EACnBC,aAAa,MAGnBlD,GACEgC,EAACmB,OAAAA,CAAKjB,UAAU,8CACZF,EAACoB,SAAAA,CACGC,KAAK,SACLnB,UAAU,wIACVoB,QAASxD,GAER,KAAOc,EAAKyB,IAAI,2BAMzC"}
1
+ {"version":3,"file":"AddressSearch.js","sources":["../../../../../../src/components/internal/Address/components/AddressSearch.tsx"],"sourcesContent":["import Field from '../../FormFields/Field';\nimport { h } from 'preact';\nimport { AddressLookupItem } from '../types';\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport './AddressSearch.scss';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport { debounce } from '../../../../utils/debounce';\nimport Select from '../../FormFields/Select';\nimport { AddressData } from '../../../../types';\n\nexport type OnAddressLookupType = (\n value: string,\n actions: {\n resolve: (value: Array<AddressLookupItem>) => void;\n reject: (reason?: RejectionReason) => void;\n }\n) => Promise<void>;\n\nexport type OnAddressSelectedType = (\n value: AddressLookupItem,\n actions: {\n resolve: (value: AddressLookupItem) => void;\n reject: (reason?: RejectionReason) => void;\n }\n) => Promise<void>;\n\ninterface AddressSearchProps {\n onAddressLookup: OnAddressLookupType;\n onAddressSelected?: OnAddressSelectedType;\n onSelect: (addressItem: AddressData) => void;\n onManualAddress: () => void;\n externalErrorMessage: string;\n hideManualButton: boolean;\n showContextualElement?: boolean;\n contextualText?: string;\n placeholder?: string;\n addressSearchDebounceMs?: number;\n}\n\ninterface RejectionReason {\n errorMessage: string;\n}\n\nexport default function AddressSearch({\n onAddressLookup,\n onAddressSelected,\n onSelect,\n onManualAddress,\n externalErrorMessage,\n hideManualButton,\n showContextualElement,\n contextualText,\n placeholder,\n addressSearchDebounceMs\n}: Readonly<AddressSearchProps>) {\n const [formattedData, setFormattedData] = useState<AddressLookupItem[]>([]);\n const [originalData, setOriginalData] = useState<AddressLookupItem[]>([]);\n\n const [errorMessage, setErrorMessage] = useState('');\n\n const { i18n } = useCoreContext();\n const mapDataToSelect = data => data.map(({ id, name }) => ({ id, name }));\n\n const handlePromiseReject = useCallback((reason: RejectionReason) => {\n if (reason?.errorMessage) {\n setErrorMessage(reason.errorMessage);\n }\n }, []);\n\n const onTextInput = useCallback(\n (inputValue: string) => {\n new Promise<Array<AddressLookupItem>>((resolve, reject) => {\n void onAddressLookup(inputValue, { resolve, reject });\n })\n .then(searchArray => {\n setOriginalData(searchArray);\n setFormattedData(mapDataToSelect(searchArray));\n setErrorMessage('');\n })\n .catch(reason => handlePromiseReject(reason));\n },\n [onAddressLookup]\n );\n\n // update error message when there's a new one\n useEffect(() => {\n setErrorMessage(externalErrorMessage);\n }, [externalErrorMessage]);\n\n const onSelectItem = event => {\n if (!event.target.value) {\n setErrorMessage(i18n.get('address.errors.incomplete'));\n return;\n }\n const value = originalData.find(item => item.id === event.target.value);\n if (!value) return;\n\n // 1. in case we don't get a function just select item\n if (typeof onAddressSelected !== 'function') {\n onSelect(value);\n setFormattedData([]);\n return;\n }\n\n // 2. in case callback is provided, create and call onAddressSelected\n new Promise<AddressLookupItem>((resolve, reject) => {\n void onAddressSelected(value, { resolve, reject });\n })\n .then(fullData => {\n onSelect(fullData);\n setFormattedData([]);\n })\n .catch(reason => handlePromiseReject(reason));\n };\n\n const debounceInputHandler = useMemo(() => debounce(onTextInput, addressSearchDebounceMs), []);\n\n return (\n // The search field is intentionally rendered before the manual entry button in the DOM.\n // See: ../a11y.md\n <div className={'adyen-checkout__address-search adyen-checkout__field-group'}>\n <Field\n label={i18n.get('address')}\n classNameModifiers={['address-search']}\n errorMessage={errorMessage}\n name={'address-search'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n name={'address-search'}\n className={'adyen-checkout__address-search__dropdown'}\n placeholder={placeholder}\n onInput={debounceInputHandler}\n items={formattedData}\n onChange={onSelectItem}\n disableTextFilter={true}\n blurOnClose={true}\n />\n </Field>\n {!hideManualButton && (\n <span className=\"adyen-checkout__address-search__manual-add\">\n <button\n type=\"button\"\n className=\"adyen-checkout__button adyen-checkout__button--inline adyen-checkout__button--link adyen-checkout__address-search__manual-add__button\"\n onClick={onManualAddress}\n >\n {'+ ' + i18n.get('address.enterManually')}\n </button>\n </span>\n )}\n </div>\n );\n}\n"],"names":["AddressSearch","onAddressLookup","onAddressSelected","onSelect","onManualAddress","externalErrorMessage","hideManualButton","showContextualElement","contextualText","placeholder","addressSearchDebounceMs","formattedData","setFormattedData","useState","originalData","setOriginalData","errorMessage","setErrorMessage","i18n","useCoreContext","handlePromiseReject","useCallback","reason","onTextInput","inputValue","Promise","resolve","reject","then","searchArray","map","id","name","catch","useEffect","debounceInputHandler","useMemo","debounce","h","div","className","Field","label","get","classNameModifiers","Select","onInput","items","onChange","event","target","value","find","item","fullData","disableTextFilter","blurOnClose","span","button","type","onClick"],"mappings":"saA2Ce,SAASA,GAAcC,gBAClCA,EAAeC,kBACfA,EAAiBC,SACjBA,EAAQC,gBACRA,EAAeC,qBACfA,EAAoBC,iBACpBA,EAAgBC,sBAChB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,mBAAmB,EACnBC,aAAa,MAGnBlD,GACEgC,EAACmB,OAAAA,CAAKjB,UAAU,8CACZF,EAACoB,SAAAA,CACGC,KAAK,SACLnB,UAAU,wIACVoB,QAASxD,GAER,KAAOc,EAAKyB,IAAI,2BAMzC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import i from"./CountryField.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import t from"../../FormFields/InputText.js";import{ADDRESS_FIELD_TOKEN_MAP as n}from"../constants.js";function a(e,r){const o=n[e];if(o)return"billingAddress"===r?`billing ${o}`:"deliveryAddress"===r?`shipping ${o}`:o}function l(n){const{i18n:l}=s(),{classNameModifiers:d=[],data:c,errors:u,valid:m,fieldName:p,onInput:f,onBlur:g,trimOnBlur:F,maxLength:y,disabled:C,addressType:M}=n,b=c[p],j=c.country,v=n.specifications.countryHasOptionalField(j,p),h=n.specifications.getKeyForField(p,j),w=v?` ${l.get("field.title.optional")}`:"",x=`${l.get(h)}${w}`,B=function(e,r,o,i){if("object"==typeof e[r]?.errorMessage){const{translationKey:i,translationObject:s}=e[r].errorMessage;return o.get(i,s)}return o.get(e[r]?.errorMessage,{values:{label:i.toLowerCase()}})||!!e[r]}(u,p,l,x);return"country"===p?e(i,{allowedCountries:n.allowedCountries,classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,value:b,required:!v}):"stateOrProvince"===p?e(o,{classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,selectedCountry:j,specifications:n.specifications,value:b,required:!v}):e(r,{label:x,classNameModifiers:d,errorMessage:B,isValid:m[p],name:p,i18n:l,onFocus:e=>n.onFieldFocusAnalytics(p,e),onBlur:e=>n.onFieldBlurAnalytics(p,e)},e(t,{name:p,classNameModifiers:d,value:b,onInput:f,onBlur:g,maxlength:y,trimOnBlur:F,disabled:C,required:!v,autocomplete:a(p,M)}))}export{l as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import i from"./CountryField.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import t from"../../FormFields/InputText.js";import{ADDRESS_FIELD_TOKEN_MAP as n}from"../constants.js";function a(e,r){const o=n[e];if(o)return"billingAddress"===r?`billing ${o}`:"deliveryAddress"===r?`shipping ${o}`:o}function l(n){const{i18n:l}=s(),{classNameModifiers:d=[],data:c,errors:u,valid:m,fieldName:p,onInput:f,onBlur:g,trimOnBlur:F,maxLength:y,disabled:C,addressType:M}=n,b=c[p],j=c.country,v=!!j&&n.specifications.countryHasOptionalField(j,p),h=n.specifications.getKeyForField(p,j),w=v?` ${l.get("field.title.optional")}`:"",x=`${l.get(h)}${w}`,B=function(e,r,o,i){if("object"==typeof e[r]?.errorMessage){const{translationKey:i,translationObject:s}=e[r].errorMessage;return o.get(i,s)}return o.get(e[r]?.errorMessage,{values:{label:i.toLowerCase()}})||!!e[r]}(u,p,l,x);return"country"===p?e(i,{allowedCountries:n.allowedCountries,classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,value:b,required:!v}):"stateOrProvince"===p?e(o,{classNameModifiers:d,label:x,errorMessage:B,onDropdownChange:n.onDropdownChange,selectedCountry:j,specifications:n.specifications,value:b,required:!v}):e(r,{label:x,classNameModifiers:d,errorMessage:B,isValid:m[p],name:p,i18n:l,onFocus:e=>n.onFieldFocusAnalytics?.(p,e),onBlur:e=>n.onFieldBlurAnalytics?.(p,e)},e(t,{name:p,classNameModifiers:d,value:b,onInput:f,onBlur:g,maxlength:y,trimOnBlur:F,disabled:C,required:!v,autocomplete:a(p,M)}))}export{l as default};
2
2
  //# sourceMappingURL=FieldContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, AddressType, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\nimport { AutocompleteValue } from '../../FormFields/types';\nimport { ADDRESS_FIELD_TOKEN_MAP } from '../constants';\nimport { AddressField } from '../../../../types';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction getAddressAutocomplete(fieldName: string, addressType: AddressType): AutocompleteValue {\n const token = ADDRESS_FIELD_TOKEN_MAP[fieldName];\n if (!token) return undefined;\n if (addressType === 'billingAddress') return `billing ${token}` as AutocompleteValue;\n if (addressType === 'deliveryAddress') return `shipping ${token}` as AutocompleteValue;\n // Fallback: bare token (no prefix) when address type is unspecified\n return token as AutocompleteValue;\n}\n\nfunction FieldContainer(props: Readonly<FieldContainerProps>) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled, addressType } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName as AddressField);\n const labelKey: string = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n if (fieldName === 'country') {\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n required={!isOptional}\n />\n );\n }\n\n if (fieldName === 'stateOrProvince') {\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n required={!isOptional}\n />\n );\n }\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n autocomplete={getAddressAutocomplete(fieldName, addressType)}\n />\n </Field>\n );\n}\n\nexport default FieldContainer;\n"],"names":["getAddressAutocomplete","fieldName","addressType","token","ADDRESS_FIELD_TOKEN_MAP","FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","required","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength","autocomplete"],"mappings":"2WA4BA,SAASA,EAAuBC,EAAmBC,GAC/C,MAAMC,EAAQC,EAAwBH,GACtC,GAAKE,EACL,MAAoB,mBAAhBD,EAAyC,WAAWC,IACpC,oBAAhBD,EAA0C,YAAYC,IAEnDA,CACX,C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A,EACpBoB,aAAcA,EACda,QAAS9B,EAAMX,GACf0C,KAAM1C,EACNM,KAAMA,EACNqC,QAASC,GAAKvC,EAAMwC,sBAAsB7C,EAAW4C,GACrD/B,OAAQ+B,GAAKvC,EAAMyC,qBAAqB9C,EAAW4C,IAEnDV,EAACa,EAAAA,CACGL,KAAM1C,EACNQ,mBAAoBA,EACpBS,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRmC,UAAWjC,EACXD,WAAYA,EACZE,SAAUA,EACVsB,UAAWlB,EACX6B,aAAclD,EAAuBC,EAAWC,KAIhE"}
1
+ {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, AddressType, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\nimport { AutocompleteValue } from '../../FormFields/types';\nimport { ADDRESS_FIELD_TOKEN_MAP } from '../constants';\nimport { AddressField } from '../../../../types';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction getAddressAutocomplete(fieldName: string, addressType: AddressType): AutocompleteValue {\n const token = ADDRESS_FIELD_TOKEN_MAP[fieldName];\n if (!token) return undefined;\n if (addressType === 'billingAddress') return `billing ${token}` as AutocompleteValue;\n if (addressType === 'deliveryAddress') return `shipping ${token}` as AutocompleteValue;\n // Fallback: bare token (no prefix) when address type is unspecified\n return token as AutocompleteValue;\n}\n\nfunction FieldContainer(props: Readonly<FieldContainerProps>) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled, addressType } = props;\n\n const value: string = data[fieldName];\n const selectedCountry = data.country;\n const isOptional = selectedCountry ? props.specifications.countryHasOptionalField(selectedCountry, fieldName as AddressField) : false;\n const labelKey = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n if (fieldName === 'country') {\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n required={!isOptional}\n />\n );\n }\n\n if (fieldName === 'stateOrProvince') {\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n required={!isOptional}\n />\n );\n }\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics?.(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics?.(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n autocomplete={getAddressAutocomplete(fieldName, addressType)}\n />\n </Field>\n );\n}\n\nexport default FieldContainer;\n"],"names":["getAddressAutocomplete","fieldName","addressType","token","ADDRESS_FIELD_TOKEN_MAP","FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","required","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength","autocomplete"],"mappings":"2WA4BA,SAASA,EAAuBC,EAAmBC,GAC/C,MAAMC,EAAQC,EAAwBH,GACtC,GAAKE,EACL,MAAoB,mBAAhBD,EAAyC,WAAWC,IACpC,oBAAhBD,EAA0C,YAAYC,IAEnDA,CACX,CAEA,SAASE,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKX,UAAEA,EAASY,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,EAAQf,YAAEA,GAAgBI,EAE7HY,EAAgBR,EAAKT,GACrBkB,EAAkBT,EAAKU,QACvBC,IAAaF,GAAkBb,EAAMgB,eAAeC,wBAAwBJ,EAAiBlB,GAC7FuB,EAAWlB,EAAMgB,eAAeG,eAAexB,EAAWkB,GAC1DO,EAAgBL,EAAa,IAAId,EAAKoB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGrB,EAAKoB,IAAIH,KAAYE,IAChCG,EAnCV,SAAyBlB,EAA2BV,EAAmBM,EAAgBqB,GACnF,GAA+C,iBAApCjB,EAAOV,IAAY4B,aAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBpB,EAAOV,GAAW4B,aAChE,OAAOtB,EAAKoB,IAAIG,EAAgBC,EACpC,CAGA,OADiBxB,EAAKoB,IAAIhB,EAAOV,IAAY4B,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DtB,EAAOV,EAChC,CA2ByBiC,CAAgBvB,EAAQV,EAAWM,EAAMqB,GAE9D,MAAkB,YAAd3B,EAEIkC,EAACC,EAAAA,CACGC,iBAAkB/B,EAAM+B,iBACxB5B,mBAAoBA,EACpBmB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBhC,EAAMgC,iBACxBpB,MAAOA,EACPqB,UAAWlB,IAKL,oBAAdpB,EAEIkC,EAACK,EAAAA,CACG/B,mBAAoBA,EACpBmB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBhC,EAAMgC,iBACxBnB,gBAAiBA,EACjBG,eAAgBhB,EAAMgB,eACtBJ,MAAOA,EACPqB,UAAWlB,IAMnBc,EAACM,EAAAA,CACGb,MAAOA,EACPnB,mBAAoBA,EACpBoB,aAAcA,EACda,QAAS9B,EAAMX,GACf0C,KAAM1C,EACNM,KAAMA,EACNqC,QAASC,GAAKvC,EAAMwC,wBAAwB7C,EAAW4C,GACvD/B,OAAQ+B,GAAKvC,EAAMyC,uBAAuB9C,EAAW4C,IAErDV,EAACa,EAAAA,CACGL,KAAM1C,EACNQ,mBAAoBA,EACpBS,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRmC,UAAWjC,EACXD,WAAYA,EACZE,SAAUA,EACVsB,UAAWlB,EACX6B,aAAclD,EAAuBC,EAAWC,KAIhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../src/components/internal/Address/constants.ts"],"sourcesContent":["import { AddressSpecifications } from './types';\n\nexport const FALLBACK_VALUE = 'N/A';\nexport const ADDRESS_SCHEMA = ['street', 'houseNumberOrName', 'postalCode', 'city', 'stateOrProvince', 'country'] as const;\nexport const [STREET, HOUSE_NUMBER_OR_NAME, POSTAL_CODE, CITY, STATE_OR_PROVINCE, COUNTRY] = ADDRESS_SCHEMA;\n\n// WCAG 2.2 - Address field autocomplete tokens\nexport const ADDRESS_FIELD_TOKEN_MAP: Record<string, string> = {\n street: 'address-line1',\n houseNumberOrName: 'address-line2',\n postalCode: 'postal-code',\n city: 'address-level2'\n};\n\n// prettier-ignore\nexport const ADDRESS_SPECIFICATIONS: AddressSpecifications = {\n AU: {\n hasDataset: true,\n labels: {\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'state',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, CITY, [[STATE_OR_PROVINCE, 50], [POSTAL_CODE, 50]]]\n },\n BR: {\n hasDataset: true,\n labels: {\n [STATE_OR_PROVINCE]: 'state'\n },\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n },\n CA: {\n hasDataset: true,\n labels: {\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'provinceOrTerritory',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, [[CITY, 70], [POSTAL_CODE, 30]], STATE_OR_PROVINCE]\n },\n GB: {\n labels: {\n [CITY]: 'cityTown'\n },\n schema: [COUNTRY, [[HOUSE_NUMBER_OR_NAME, 30], [STREET, 70]], [[CITY, 70], [POSTAL_CODE, 30]], STATE_OR_PROVINCE]\n },\n JP: {\n hasDataset: true,\n labels: {\n [STATE_OR_PROVINCE]: 'prefecture',\n [CITY]: 'cityTown',\n [STREET]: 'streetNameAndBlockNumber',\n [HOUSE_NUMBER_OR_NAME]: 'buildingNameRoomNumber'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n schema: [COUNTRY, [[POSTAL_CODE, 50], [STATE_OR_PROVINCE, 50]], CITY, STREET, HOUSE_NUMBER_OR_NAME]\n },\n US: {\n hasDataset: true,\n labels: {\n [POSTAL_CODE]: 'zipCode',\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'state',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, CITY, [[STATE_OR_PROVINCE, 50], [POSTAL_CODE, 50]]]\n },\n default: {\n optionalFields: [],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.provinceOrTerritory'\n },\n schema: [COUNTRY, [[STREET, 70], [HOUSE_NUMBER_OR_NAME, 30]], [[POSTAL_CODE, 30], [CITY, 70]], STATE_OR_PROVINCE],\n }\n};\n\nexport const PARTIAL_ADDRESS_SCHEMA: AddressSpecifications = Object.keys(ADDRESS_SPECIFICATIONS).reduce((acc, countryCode) => {\n acc[countryCode] = {\n labels: ADDRESS_SPECIFICATIONS[countryCode].labels,\n schema: [POSTAL_CODE]\n };\n return acc;\n}, {} as AddressSpecifications);\n\nexport const COUNTRIES_WITH_CUSTOM_SPECIFICATION = Object.keys(ADDRESS_SPECIFICATIONS);\n"],"names":["FALLBACK_VALUE","ADDRESS_SCHEMA","STREET","HOUSE_NUMBER_OR_NAME","POSTAL_CODE","CITY","STATE_OR_PROVINCE","COUNTRY","ADDRESS_FIELD_TOKEN_MAP","street","houseNumberOrName","postalCode","city","ADDRESS_SPECIFICATIONS","AU","hasDataset","labels","optionalFields","placeholders","schema","BR","CA","GB","JP","US","default","PARTIAL_ADDRESS_SCHEMA","Object","keys","reduce","acc","countryCode","COUNTRIES_WITH_CUSTOM_SPECIFICATION"],"mappings":"AAEO,MAAMA,EAAiB,MACjBC,EAAiB,CAAC,SAAU,oBAAqB,aAAc,OAAQ,kBAAmB,YACzFC,EAAQC,EAAsBC,EAAaC,EAAMC,EAAmBC,GAAWN,EAGhFO,EAAkD,CAC3DC,OAAQ,gBACRC,kBAAmB,gBACnBC,WAAY,cACZC,KAAM,kBAIGC,EAAgD,CACzDC,GAAI,CACAC,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GAAoB,8BAEzBa,OAAQ,CAACZ,EAAS,CAAC,CAACL,EAAQ,IAAK,CAACC,EAAsB,KAAM,CAAC,CAACC,EAAa,IAAK,CAACC,EAAM,KAAMC,KAI1FoB,EAAgDC,OAAOC,KAAKf,GAAwBgB,OAAO,CAACC,EAAKC,KAC1GD,EAAIC,GAAe,CACff,OAAQH,EAAuBkB,GAAaf,OAC5CG,OAAQ,CAACf,IAEN0B,GACR,CAAA,GAEUE,EAAsCL,OAAOC,KAAKf"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/components/internal/Address/constants.ts"],"sourcesContent":["import { AddressSpecifications } from './types';\n\nexport const FALLBACK_VALUE = 'N/A';\nexport const ADDRESS_SCHEMA = ['street', 'houseNumberOrName', 'postalCode', 'city', 'stateOrProvince', 'country'] as const;\nexport const [STREET, HOUSE_NUMBER_OR_NAME, POSTAL_CODE, CITY, STATE_OR_PROVINCE, COUNTRY] = ADDRESS_SCHEMA;\n\n// WCAG 2.2 - Address field autocomplete tokens\nexport const ADDRESS_FIELD_TOKEN_MAP: Record<string, string> = {\n street: 'address-line1',\n houseNumberOrName: 'address-line2',\n postalCode: 'postal-code',\n city: 'address-level2'\n};\n\n// prettier-ignore\nexport const ADDRESS_SPECIFICATIONS = {\n AU: {\n hasDataset: true,\n labels: {\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'state',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, CITY, [[STATE_OR_PROVINCE, 50], [POSTAL_CODE, 50]]]\n },\n BR: {\n hasDataset: true,\n labels: {\n [STATE_OR_PROVINCE]: 'state'\n },\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n },\n CA: {\n hasDataset: true,\n labels: {\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'provinceOrTerritory',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, [[CITY, 70], [POSTAL_CODE, 30]], STATE_OR_PROVINCE]\n },\n GB: {\n labels: {\n [CITY]: 'cityTown'\n },\n schema: [COUNTRY, [[HOUSE_NUMBER_OR_NAME, 30], [STREET, 70]], [[CITY, 70], [POSTAL_CODE, 30]], STATE_OR_PROVINCE]\n },\n JP: {\n hasDataset: true,\n labels: {\n [STATE_OR_PROVINCE]: 'prefecture',\n [CITY]: 'cityTown',\n [STREET]: 'streetNameAndBlockNumber',\n [HOUSE_NUMBER_OR_NAME]: 'buildingNameRoomNumber'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n schema: [COUNTRY, [[POSTAL_CODE, 50], [STATE_OR_PROVINCE, 50]], CITY, STREET, HOUSE_NUMBER_OR_NAME]\n },\n US: {\n hasDataset: true,\n labels: {\n [POSTAL_CODE]: 'zipCode',\n [HOUSE_NUMBER_OR_NAME]: 'apartmentSuite',\n [STATE_OR_PROVINCE]: 'state',\n [STREET]: 'address'\n },\n optionalFields: [HOUSE_NUMBER_OR_NAME],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.state'\n },\n schema: [COUNTRY, STREET, HOUSE_NUMBER_OR_NAME, CITY, [[STATE_OR_PROVINCE, 50], [POSTAL_CODE, 50]]]\n },\n default: {\n optionalFields: [],\n placeholders: {\n [STATE_OR_PROVINCE]: 'select.provinceOrTerritory'\n },\n schema: [COUNTRY, [[STREET, 70], [HOUSE_NUMBER_OR_NAME, 30]], [[POSTAL_CODE, 30], [CITY, 70]], STATE_OR_PROVINCE],\n }\n} satisfies AddressSpecifications;\n\nexport const PARTIAL_ADDRESS_SCHEMA: AddressSpecifications = Object.keys(ADDRESS_SPECIFICATIONS).reduce((acc, countryCode) => {\n acc[countryCode] = {\n labels: ADDRESS_SPECIFICATIONS[countryCode].labels,\n schema: [POSTAL_CODE]\n };\n return acc;\n}, {} as AddressSpecifications);\n\nexport const COUNTRIES_WITH_CUSTOM_SPECIFICATION = Object.keys(ADDRESS_SPECIFICATIONS);\n"],"names":["FALLBACK_VALUE","ADDRESS_SCHEMA","STREET","HOUSE_NUMBER_OR_NAME","POSTAL_CODE","CITY","STATE_OR_PROVINCE","COUNTRY","ADDRESS_FIELD_TOKEN_MAP","street","houseNumberOrName","postalCode","city","ADDRESS_SPECIFICATIONS","AU","hasDataset","labels","optionalFields","placeholders","schema","BR","CA","GB","JP","US","default","PARTIAL_ADDRESS_SCHEMA","Object","keys","reduce","acc","countryCode","COUNTRIES_WITH_CUSTOM_SPECIFICATION"],"mappings":"AAEO,MAAMA,EAAiB,MACjBC,EAAiB,CAAC,SAAU,oBAAqB,aAAc,OAAQ,kBAAmB,YACzFC,EAAQC,EAAsBC,EAAaC,EAAMC,EAAmBC,GAAWN,EAGhFO,EAAkD,CAC3DC,OAAQ,gBACRC,kBAAmB,gBACnBC,WAAY,cACZC,KAAM,kBAIGC,EAAyB,CAClCC,GAAI,CACAC,YAAY,EACZC,OAAQ,CACJb,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,QACrBJ,CAACA,GAAS,WAEde,eAAgB,CAACd,GACjBe,aAAc,CACVZ,CAACA,GAAoB,gBAEzBa,OAAQ,CAACZ,EAASL,EAAQC,EAAsBE,EAAM,CAAC,CAACC,EAAmB,IAAK,CAACF,EAAa,OAElGgB,GAAI,CACAL,YAAY,EACZC,OAAQ,CACJV,CAACA,GAAoB,SAEzBY,aAAc,CACVZ,CAACA,GAAoB,iBAG7Be,GAAI,CACAN,YAAY,EACZC,OAAQ,CACJb,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,sBACrBJ,CAACA,GAAS,WAEde,eAAgB,CAACd,GACjBgB,OAAQ,CAACZ,EAASL,EAAQC,EAAsB,CAAC,CAACE,EAAM,IAAK,CAACD,EAAa,KAAME,IAErFgB,GAAI,CACAN,OAAQ,CACJX,CAACA,GAAO,YAEZc,OAAQ,CAACZ,EAAS,CAAC,CAACJ,EAAsB,IAAK,CAACD,EAAQ,KAAM,CAAC,CAACG,EAAM,IAAK,CAACD,EAAa,KAAME,IAEnGiB,GAAI,CACAR,YAAY,EACZC,OAAQ,CACJV,CAACA,GAAoB,aACrBD,CAACA,GAAO,WACRH,CAACA,GAAS,2BACVC,CAACA,GAAuB,0BAE5Bc,eAAgB,CAACd,GACjBgB,OAAQ,CAACZ,EAAS,CAAC,CAACH,EAAa,IAAK,CAACE,EAAmB,KAAMD,EAAMH,EAAQC,IAElFqB,GAAI,CACAT,YAAY,EACZC,OAAQ,CACJZ,CAACA,GAAc,UACfD,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,QACrBJ,CAACA,GAAS,WAEde,eAAgB,CAACd,GACjBe,aAAc,CACVZ,CAACA,GAAoB,gBAEzBa,OAAQ,CAACZ,EAASL,EAAQC,EAAsBE,EAAM,CAAC,CAACC,EAAmB,IAAK,CAACF,EAAa,OAElGqB,QAAS,CACLR,eAAgB,GAChBC,aAAc,CACVZ,CAACA,GAAoB,8BAEzBa,OAAQ,CAACZ,EAAS,CAAC,CAACL,EAAQ,IAAK,CAACC,EAAsB,KAAM,CAAC,CAACC,EAAa,IAAK,CAACC,EAAM,KAAMC,KAI1FoB,EAAgDC,OAAOC,KAAKf,GAAwBgB,OAAO,CAACC,EAAKC,KAC1GD,EAAIC,GAAe,CACff,OAAQH,EAAuBkB,GAAaf,OAC5CG,OAAQ,CAACf,IAEN0B,GACR,CAAA,GAEUE,EAAsCL,OAAOC,KAAKf"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Address/utils.ts"],"sourcesContent":["import Language from '../../../language';\nimport { ADDRESS_SCHEMA } from './constants';\nimport { AddressField } from '../../../types/global-types';\nimport { StringObject, AddressType } from './types';\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to prepend the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to prepend the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n if (ADDRESS_SCHEMA.includes(key as AddressField)) {\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n }\n return null;\n};\n\nexport const getAddressTypeFromLabel = (addressType: AddressType, label: string): AddressType => {\n if (addressType) {\n return addressType;\n }\n if (label === 'billingAddress' || label === 'deliveryAddress') {\n return label;\n }\n return undefined;\n};\n"],"names":["mapFieldKey","key","i18n","countrySpecificLabels","ADDRESS_SCHEMA","includes","get","getAddressTypeFromLabel","addressType","label"],"mappings":"gDAUO,MAAMA,EAAc,CAACC,EAAaC,EAAgBC,IACjDC,EAAeC,SAASJ,GACjBE,IAAwBF,GAAOC,EAAKI,IAAIH,IAAwBF,IAAQC,EAAKI,IAAIL,GAErF,KAGEM,EAA0B,CAACC,EAA0BC,IAC1DD,IAGU,mBAAVC,GAAwC,oBAAVA,EACvBA,OADX"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Address/utils.ts"],"sourcesContent":["import Language from '../../../language';\nimport { ADDRESS_SCHEMA } from './constants';\nimport { AddressField } from '../../../types/global-types';\nimport { StringObject, AddressType } from './types';\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to prepend the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to prepend the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n *\n * TODO: This function should probably be using Specifications instead of hardcoded ADDRESS_SCHEMA\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string | null => {\n if (ADDRESS_SCHEMA.includes(key as AddressField)) {\n return countrySpecificLabels?.[key] ? i18n.get(countrySpecificLabels?.[key]) : i18n.get(key);\n }\n return null;\n};\n\nexport const getAddressTypeFromLabel = (addressType: AddressType, label: string): AddressType => {\n if (addressType) {\n return addressType;\n }\n if (label === 'billingAddress' || label === 'deliveryAddress') {\n return label;\n }\n return undefined;\n};\n"],"names":["mapFieldKey","key","i18n","countrySpecificLabels","ADDRESS_SCHEMA","includes","get","getAddressTypeFromLabel","addressType","label"],"mappings":"gDAYO,MAAMA,EAAc,CAACC,EAAaC,EAAgBC,IACjDC,EAAeC,SAASJ,GACjBE,IAAwBF,GAAOC,EAAKI,IAAIH,IAAwBF,IAAQC,EAAKI,IAAIL,GAErF,KAGEM,EAA0B,CAACC,EAA0BC,IAC1DD,IAGU,mBAAVC,GAAwC,oBAAVA,EACvBA,OADX"}
@@ -1,2 +1,2 @@
1
- import{getFormattingRegEx as o,stripInvalidChars as t}from"../../../utils/validator-utils.js";import{convertFullToHalf as a}from"../FormFields/utils.js";const e=t=>({formatterFn:a=>a.replace(o("^\\d","g"),"").substring(0,t),format:new Array(t).fill("9").join(""),maxlength:t}),r=o=>o,l={postalCode:{formatterFn:(o,t)=>{const a=t.state.data.country,e=s[a]?.postalCode.formatterFn;return e?e(o):o}},street:{formatterFn:r},houseNumberOrName:{formatterFn:r},city:{formatterFn:r}},s={AT:{postalCode:e(4)},AU:{postalCode:e(4)},BE:{postalCode:e(4)},BG:{postalCode:e(4)},BR:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?9:8;return a.substring(0,e)},format:"12345678 or 12345-678",maxlength:9}},CA:{postalCode:{format:"A9A 9A9 or A9A9A9",maxlength:7}},CH:{postalCode:e(4)},CY:{postalCode:e(4)},CZ:{postalCode:{format:"999 99",maxlength:6}},DE:{postalCode:e(5)},DK:{postalCode:{format:"9999",maxlength:7}},EE:{postalCode:e(5)},ES:{postalCode:e(5)},FI:{postalCode:e(5)},FR:{postalCode:e(5)},GB:{postalCode:{formatterFn:o=>t(o).substring(0,8),format:"AA99 9AA or A99 9AA or A9 9AA",maxlength:8}},GR:{postalCode:{format:"999 99",maxlength:6}},HR:{postalCode:{format:"[1-5]9999",maxlength:5}},HU:{postalCode:e(4)},IE:{postalCode:{format:"A99 A999",maxlength:8}},IS:{postalCode:e(3)},IT:{postalCode:e(5)},LI:{postalCode:e(4)},LT:{postalCode:{format:"9999 or 99999 or LT-99999",maxlength:8}},LU:{postalCode:e(4)},LV:{postalCode:{format:"9999 or LV-9999",maxlength:7}},MC:{postalCode:{format:"980NN",maxlength:5}},MT:{postalCode:{format:"AA99 or AAA99 or AA9999 or AAA9999",maxlength:8}},MY:{postalCode:e(5)},NL:{postalCode:{format:"9999AA",maxlength:7}},NZ:{postalCode:e(4)},NO:{postalCode:e(4)},PL:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?6:5;return a.substring(0,e)},format:"99999 or 99-999",maxlength:6}},PT:{postalCode:{formatterFn:t=>t.replace(o("^\\d-","g"),"").substring(0,8),format:"9999-999",maxlength:8}},RO:{postalCode:e(6)},SI:{postalCode:{format:"9999 or SI-9999",maxlength:7}},SE:{postalCode:e(5)},SG:{postalCode:e(6)},SK:{postalCode:{format:"99999 or SK-99999",maxlength:8}},JP:{postalCode:{formatterFn:t=>a(t).replace(o("^\\d-","g"),"").substring(0,8),format:"999-9999",maxlength:8}},US:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?10:5;return a.substring(0,e)},format:"99999 or 99999-9999"}}};export{l as addressFormatters,s as countrySpecificFormatters};
1
+ import{getFormattingRegEx as o,stripInvalidChars as t}from"../../../utils/validator-utils.js";import{convertFullToHalf as a}from"../FormFields/utils.js";const e=t=>({formatterFn:a=>a.replace(o("^\\d","g"),"").substring(0,t),format:new Array(t).fill("9").join(""),maxlength:t}),r=o=>o,l={postalCode:{formatterFn:(o,t)=>{const a=t.state.data.country,e=a?s[a]?.postalCode.formatterFn:void 0;return e?e(o):o}},street:{formatterFn:r},houseNumberOrName:{formatterFn:r},city:{formatterFn:r}},s={AT:{postalCode:e(4)},AU:{postalCode:e(4)},BE:{postalCode:e(4)},BG:{postalCode:e(4)},BR:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?9:8;return a.substring(0,e)},format:"12345678 or 12345-678",maxlength:9}},CA:{postalCode:{format:"A9A 9A9 or A9A9A9",maxlength:7}},CH:{postalCode:e(4)},CY:{postalCode:e(4)},CZ:{postalCode:{format:"999 99",maxlength:6}},DE:{postalCode:e(5)},DK:{postalCode:{format:"9999",maxlength:7}},EE:{postalCode:e(5)},ES:{postalCode:e(5)},FI:{postalCode:e(5)},FR:{postalCode:e(5)},GB:{postalCode:{formatterFn:o=>t(o).substring(0,8),format:"AA99 9AA or A99 9AA or A9 9AA",maxlength:8}},GR:{postalCode:{format:"999 99",maxlength:6}},HR:{postalCode:{format:"[1-5]9999",maxlength:5}},HU:{postalCode:e(4)},IE:{postalCode:{format:"A99 A999",maxlength:8}},IS:{postalCode:e(3)},IT:{postalCode:e(5)},LI:{postalCode:e(4)},LT:{postalCode:{format:"9999 or 99999 or LT-99999",maxlength:8}},LU:{postalCode:e(4)},LV:{postalCode:{format:"9999 or LV-9999",maxlength:7}},MC:{postalCode:{format:"980NN",maxlength:5}},MT:{postalCode:{format:"AA99 or AAA99 or AA9999 or AAA9999",maxlength:8}},MY:{postalCode:e(5)},NL:{postalCode:{format:"9999AA",maxlength:7}},NZ:{postalCode:e(4)},NO:{postalCode:e(4)},PL:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?6:5;return a.substring(0,e)},format:"99999 or 99-999",maxlength:6}},PT:{postalCode:{formatterFn:t=>t.replace(o("^\\d-","g"),"").substring(0,8),format:"9999-999",maxlength:8}},RO:{postalCode:e(6)},SI:{postalCode:{format:"9999 or SI-9999",maxlength:7}},SE:{postalCode:e(5)},SG:{postalCode:e(6)},SK:{postalCode:{format:"99999 or SK-99999",maxlength:8}},JP:{postalCode:{formatterFn:t=>a(t).replace(o("^\\d-","g"),"").substring(0,8),format:"999-9999",maxlength:8}},US:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?10:5;return a.substring(0,e)},format:"99999 or 99999-9999"}}};export{l as addressFormatters,s as countrySpecificFormatters};
2
2
  //# sourceMappingURL=validate.formats.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { FormatterContext } from '../../../utils/Formatters/types';\nimport { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, stripInvalidChars } from '../../../utils/validator-utils';\nimport { convertFullToHalf } from '../FormFields/utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst defaultFormattingFn = (val: string) => val;\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val: string, context: FormatterContext) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: defaultFormattingFn\n },\n houseNumberOrName: {\n formatterFn: defaultFormattingFn\n },\n city: {\n formatterFn: defaultFormattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n formatterFn: val => stripInvalidChars(val).substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n // Formatter - converts full-width characters (common on Japanese keyboards, e.g. '107-0052') to their\n // half-width equivalent, then strips any remaining non-digit/hyphen characters (e.g. the postal mark '〒')\n formatterFn: val => convertFullToHalf(val).replace(getFormattingRegEx('^\\\\d-', 'g'), '').substring(0, 8),\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","defaultFormattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","stripInvalidChars","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","convertFullToHalf","US"],"mappings":"yJAMA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAuBT,GAAgBA,EAEhCU,EAAiC,CAC1CC,WAAY,CACRZ,YAAa,CAACC,EAAaY,KACvB,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWZ,YACpE,OAAIiB,EACOA,EAAahB,GAIjBA,IAGfkB,OAAQ,CACJnB,YAAaU,GAEjBU,kBAAmB,CACfpB,YAAaU,GAEjBW,KAAM,CACFrB,YAAaU,IAORQ,EAAiD,CAC1DI,GAAI,CACAV,WAAYd,EAAqB,IAErCyB,GAAI,CACAX,WAAYd,EAAqB,IAErC0B,GAAI,CACAZ,WAAYd,EAAqB,IAErC2B,GAAI,CACAb,WAAYd,EAAqB,IAErC4B,GAAI,CACAd,WAAY,CAERZ,YAAaC,IACT,MAAM0B,EAAQ1B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYkB,EAAMC,SAAS,KAAO,EAAI,EAC5C,OAAOD,EAAMvB,UAAU,EAAGK,IAE9BJ,OAAQ,wBACRI,UAAW,IAGnBoB,GAAI,CACAjB,WAAY,CACRP,OAAQ,oBACRI,UAAW,IAGnBqB,GAAI,CACAlB,WAAYd,EAAqB,IAErCiC,GAAI,CACAnB,WAAYd,EAAqB,IAErCkC,GAA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,KAAO,EAAI,EAC5C,OAAOD,EAAMvB,UAAU,EAAGK,IAE9BJ,OAAQ,kBACRI,UAAW,IAGnBiD,GAAI,CACA9C,WAAY,CACRZ,YAAaC,GACKA,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IAC/CC,UAAU,EAAG,GAE9BC,OAAQ,WACRI,UAAW,IAGnBkD,GAAI,CACA/C,WAAYd,EAAqB,IAErC8D,GAAI,CACAhD,WAAY,CACRP,OAAQ,kBACRI,UAAW,IAGnBoD,GAAI,CACAjD,WAAYd,EAAqB,IAErCgE,GAAI,CACAlD,WAAYd,EAAqB,IAErCiE,GAAI,CACAnD,WAAY,CACRP,OAAQ,oBACRI,UAAW,IAGnBuD,GAAI,CACApD,WAAY,CAGRZ,YAAaC,GAAOgE,EAAkBhE,GAAKC,QAAQC,EAAmB,QAAS,KAAM,IAAIC,UAAU,EAAG,GACtGC,OAAQ,WACRI,UAAW,IAGnByD,GAAI,CACAtD,WAAY,CACRZ,YAAaC,IACT,MAAM0B,EAAQ1B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYkB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAMvB,UAAU,EAAGK,IAE9BJ,OAAQ"}
1
+ {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { FormatterContext } from '../../../utils/Formatters/types';\nimport { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, stripInvalidChars } from '../../../utils/validator-utils';\nimport { convertFullToHalf } from '../FormFields/utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst defaultFormattingFn = (val: string) => val;\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val: string, context: FormatterContext) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = country ? countrySpecificFormatters[country]?.postalCode.formatterFn : undefined;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: defaultFormattingFn\n },\n houseNumberOrName: {\n formatterFn: defaultFormattingFn\n },\n city: {\n formatterFn: defaultFormattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n formatterFn: val => stripInvalidChars(val).substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n // Formatter - converts full-width characters (common on Japanese keyboards, e.g. '107-0052') to their\n // half-width equivalent, then strips any remaining non-digit/hyphen characters (e.g. the postal mark '〒')\n formatterFn: val => convertFullToHalf(val).replace(getFormattingRegEx('^\\\\d-', 'g'), '').substring(0, 8),\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","defaultFormattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","undefined","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","stripInvalidChars","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","convertFullToHalf","US"],"mappings":"yJAMA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAuBT,GAAgBA,EAEhCU,EAAiC,CAC1CC,WAAY,CACRZ,YAAa,CAACC,EAAaY,KACvB,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeH,EAAUI,EAA0BJ,IAAUF,WAAWZ,iBAAcmB,EAC5F,OAAIF,EACOA,EAAahB,GAIjB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,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYmB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAMxB,UAAU,EAAGK,IAE9BJ,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function c(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),n=this.core.modules.risk.riskData,s=this.core.modules.analytics.checkoutAttemptId??r,c=o?h.NATIVE:h.GENERIC,d=i(s,n,c);return e.paymentMethod&&s&&(e.paymentMethod.checkoutAttemptId=s),e.paymentMethod&&d&&(e.paymentMethod.sdkData=d),{...n&&{riskData:{clientData:n}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){c(this,"_id",`${this.constructor.type}-${e()}`),c(this,"core",void 0),c(this,"props",void 0),c(this,"state",{}),c(this,"_component",void 0),c(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}c(d,"defaultProps",{});export{d as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function d(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}const c="Component could not mount. Root node was not found.";class u{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){}handleKeyDown(t){}get mountedNode(){if(!this._node)throw new Error(c);return this._node}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),n=this.core.modules.risk.riskData,s=this.core.modules.analytics.checkoutAttemptId??r,d=o?h.NATIVE:h.GENERIC,c=i(s,n,d);return e.paymentMethod&&s&&(e.paymentMethod.checkoutAttemptId=s),e.paymentMethod&&c&&(e.paymentMethod.sdkData=c),{...n&&{riskData:{clientData:n}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error(c);return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this.mountedNode)}unmount(){return this._node&&(s(this._node,"keydown",this.handleKeyDown),t(null,this._node)),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){d(this,"_id",`${this.constructor.type}-${e()}`),d(this,"core",void 0),d(this,"props",void 0),d(this,"state",{}),d(this,"_component",void 0),d(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}d(u,"defaultProps",{});export{u as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, BaseElementState, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps, S extends BaseElementState = BaseElementState> implements IBaseElement<P> {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: S = {} as S;\n public _component: ComponentChild | undefined;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): PaymentData {\n return {} as PaymentData;\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: S): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.riskData;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key down events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {} as S;\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","setState","newState","state","data","order","componentData","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","riskData","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"mlBAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,gBAAoBJ,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAG,GACI,MAAO,CAAA,CACX,CAEUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,aAAAA,CAAcC,GACpB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfV,KAAKW,MAAQ,IAAKX,KAAKW,SAAUD,EACrC,CAMA,QAAWE,GACP,MAAMC,EAAQb,KAAKW,MAAME,OAASb,KAAKC,MAAMY,MACvCC,EAAgBd,KAAKI,aACrBW,EAAuCC,QAAQC,EAA8BH,EAAcI,eAAeC,OAC1GC,EAAapB,KAAKqB,KAAKC,QAAQC,KAAKC,SACpCC,EAAoBzB,KAAKqB,KAAKC,QAAQI,UAAUD,mBAAqBE,EACrEC,EAAwBb,EAAuCc,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBL,EAAYQ,GAS7D,OARId,EAAcI,eAAiBO,IAC/BX,EAAcI,cAAcO,kBAAoBA,GAGhDX,EAAcI,eAAiBc,IA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9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC5D,KAAKG,YAAY,6DAIhEH,KAAKqB,KAAO+B,EACZpD,KAAKF,kBAAkBG,GAEvBD,KAAKO,cAAgBP,KAAKO,cAAcsD,KAAK7D,KACjD,EAhBAqD,EAVWxD,EAUeiE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, BaseElementState, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\nconst ROOT_NODE_NOT_FOUND = 'Component could not mount. Root node was not found.';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps, S extends BaseElementState = BaseElementState> implements IBaseElement<P> {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: S = {} as S;\n public _component: ComponentChild | undefined;\n\n protected _node: HTMLElement | null = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): PaymentData {\n return {} as PaymentData;\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent): void {\n return;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>): void {\n return;\n }\n\n /**\n * The node the element is currently mounted into.\n * Throws the same error as `mount()` when the element has not been mounted yet.\n */\n protected get mountedNode(): HTMLElement {\n if (!this._node) {\n throw new Error(ROOT_NODE_NOT_FOUND);\n }\n return this._node;\n }\n\n protected setState(newState: S): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.riskData;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error(ROOT_NODE_NOT_FOUND);\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key down events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {} as S;\n\n return this.unmount().mount(this.mountedNode); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n if (this._node) {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["ROOT_NODE_NOT_FOUND","BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","mountedNode","_node","Error","setState","newState","state","data","order","componentData","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","riskData","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","orderData","pspReference","clientStateDataIndicator","activate","render","mount","domNode","node","document","querySelector","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"mlBAaA,MAAMA,EAAsB,sDAa5B,MAAeC,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,gBAAoBJ,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAG,GACI,MAAO,CAAA,CACX,CAEUC,eAAAA,CAAgBC,GAE1B,CAEUC,aAAAA,CAAcC,GAExB,CAMA,eAAcC,GACV,IAAKT,KAAKU,MACN,MAAM,IAAIC,MAAMf,GAEpB,OAAOI,KAAKU,KAChB,CAEUE,QAAAA,CAASC,GACfb,KAAKc,MAAQ,IAAKd,KAAKc,SAAUD,EACrC,CAMA,QAAWE,GACP,MAAMC,EAAQhB,KAAKc,MAAME,OAAShB,KAAKC,MAAMe,MACvCC,EAAgBjB,KAAKI,aACrBc,EAAuCC,QAAQC,EAA8BH,EAAcI,eAAeC,OAC1GC,EAAavB,KAAKwB,KAAKC,QAAQC,KAAKC,SACpCC,EAAoB5B,KAAKwB,KAAKC,QAAQI,UAAUD,mBAAqBE,EACrEC,EAAwBb,EAAuCc,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBL,EAAYQ,GAS7D,OARId,EAAcI,eAAiBO,IAC/BX,EAAcI,cAAcO,kBAAoBA,GAGhD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,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC7D,KAAKG,YAAY,6DAIhEH,KAAKwB,KAAO6B,EACZrD,KAAKF,kBAAkBG,GAEvBD,KAAKO,cAAgBP,KAAKO,cAAcuD,KAAK9D,KACjD,EAhBAsD,EAVWzD,EAUekE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import t from"../FormFields/Fieldset/Fieldset.js";import i from"../FormFields/Field/Field.js";import s from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as o}from"./validate.js";import{useCoreContext as n}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 d from"../FormFields/InputText.js";const u=["name","registrationNumber"];function p(u){const{label:p="",namePrefix:c,requiredFields:f,visibility:g}=u,{i18n:b}=n(),{handleChangeFor:F,triggerValidation:N,data:h,valid:j,errors:v,isValid:y}=m({schema:f,rules:{...o,...u.validationRules},defaultData:u.data}),C=r({});Object.keys(C.current).length||u.setComponentRef?.(C.current),C.current.showValidation=()=>{N()};const M=e=>`${c?`${c}.`:""}${e}`,x=e=>r=>{const{name:a}=r.target,t=a.split(`${c}.`).pop();F(t,e)(r)},k=e=>r=>{const{name:a}=r.target,t=a.split(`${c}.`).pop();F(t,e)(r)};return a(()=>{const e=l(h);u.onChange({data:e,valid:j,errors:v,isValid:y})},[h,j,v,y]),"hidden"===g?null:"readOnly"===g?e(s,{...u,data:h}):e(t,{classNameModifiers:[p],label:p},f.includes("name")&&e(i,{label:b.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!v.name,i18n:b,name:M("companyName")},e(d,{name:M("name"),value:h.name,classNameModifiers:["name"],onInput:k("input"),onBlur:x("blur"),spellcheck:!1,autocomplete:"organization"})),f.includes("registrationNumber")&&e(i,{label:b.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!v.registrationNumber,i18n:b,name:M("registrationNumber")},e(d,{name:M("registrationNumber"),value:h.registrationNumber,classNameModifiers:["registrationNumber"],onInput:k("input"),onBlur:x("blur"),spellcheck:!1,autocomplete:void 0})))}p.defaultProps={data:{},onChange:()=>{},visibility:"editable",requiredFields:u,validationRules:o};export{u as COMPANY_DETAILS_SCHEMA,p 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 a from"../FormFields/Fieldset/Fieldset.js";import i from"../FormFields/Field/Field.js";import s from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as o}from"./validate.js";import{useCoreContext as n}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";const d=["name","registrationNumber"];function c(c){const{label:p="",namePrefix:f,requiredFields:g=d,visibility:b="editable",data:F={},onChange:N=()=>{},validationRules:j=o}=c,{i18n:h}=n(),{handleChangeFor:v,triggerValidation:y,data:C,valid:M,errors:x,isValid:k}=m({schema:g,rules:{...o,...j},defaultData:F}),$=r({});Object.keys($.current).length||c.setComponentRef?.($.current),$.current.showValidation=()=>{y()};const D=e=>`${f?`${f}.`:""}${e}`,R=e=>r=>{const{name:t}=r.target,a=f?t.split(`${f}.`).pop():t;a&&v(a,e)(r)},V=e=>r=>{const{name:t}=r.target,a=f?t.split(`${f}.`).pop():t;a&&v(a,e)(r)};return t(()=>{const e=l(C);N({data:e,valid:M,errors:x,isValid:k})},[C,M,x,k]),"hidden"===b?null:"readOnly"===b?e(s,{...c,data:C}):e(a,{classNameModifiers:[p],label:p},g.includes("name")&&e(i,{label:h.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!x.name,i18n:h,name:D("companyName")},e(u,{name:D("name"),value:C.name,classNameModifiers:["name"],onInput:V("input"),onBlur:R("blur"),spellcheck:!1,autocomplete:"organization"})),g.includes("registrationNumber")&&e(i,{label:h.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!x.registrationNumber,i18n:h,name:D("registrationNumber")},e(u,{name:D("registrationNumber"),value:C.registrationNumber,classNameModifiers:["registrationNumber"],onInput:V("input"),onBlur:R("blur"),spellcheck:!1,autocomplete:void 0})))}export{d as COMPANY_DETAILS_SCHEMA,c 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 autocomplete={'organization'}\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 autocomplete={undefined}\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","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","autocomplete","registrationNumber","undefined","defaultProps"],"mappings":"8mBAcaA,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,MAAO,IAAKC,KAAkChB,EAAMiB,iBACpDC,YAAalB,EAAMS,OAIjBU,EAAoBC,EAA4B,IAEjDC,OAAOC,KAAKH,EAAkBI,SAASC,QACxCxB,EAAMyB,kBAAkBN,EAAkBI,SAI9CJ,EAAkBI,QAAQG,eAAiB,KACvClB,KAGJ,MAAMmB,EAAqBC,GAAyB,GAAG1B,EAAa,GAAGA,KAAgB,KAAK0B,IAEtFC,EACDC,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGhC,MAAeiC,MAEzC5B,EAAgB0B,EAAKH,EAArBvB,CAA2BwB,IAG7BK,EACDN,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGhC,MAAeiC,MAEzC5B,EAAgB0B,EAAKH,EAArBvB,CAA2BwB,IAQnC,OALAM,EAAU,KACN,MAAMC,EAAgBC,EAAiB9B,GACvCT,EAAMwC,SAAS,CAAE/B,KAAM6B,EAAe5B,QAAOC,SAAQC,aACtD,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAfR,EAAgC,KACjB,aAAfA,EAAkCqC,EAACC,EAAAA,IAA2B1C,EAAOS,KAAMA,IAG3EgC,EAACE,EAAAA,CAASC,mBAAoB,CAAC3C,GAAQA,MAAOA,GACzCE,EAAe0C,SAAS,SACrBJ,EAACK,EAAAA,CACG7C,MAAOI,EAAK0C,IAAI,uBAChBH,mBAAoB,CAAC,QACrBI,eAAgBrC,EAAOiB,KACvBvB,KAAMA,EACNuB,KAAMD,EAAkB,gBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,QACxBuB,MAAOzC,EAAKmB,KACZgB,mBAAoB,CAAC,QACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,EACZC,aAAc,kBAKzBnD,EAAe0C,SAAS,uBACrBJ,EAACK,EAAAA,CACG7C,MAAOI,EAAK0C,IAAI,qCAChBH,mBAAoB,CAAC,sBACrBI,eAAgBrC,EAAO4C,mBACvBlD,KAAMA,EACNuB,KAAMD,EAAkB,uBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,sBACxBuB,MAAOzC,EAAK8C,mBACZX,mBAAoB,CAAC,sBACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,EACZC,kBAAcE,KAMtC,CAEAzD,EAAe0D,aAAe,CAC1BhD,KAAM,CAAA,EACN+B,SAAU,OACVpC,WAAY,WACZD,eAAgBL,EAChBmB,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 {\n label = '',\n namePrefix,\n requiredFields = COMPANY_DETAILS_SCHEMA,\n visibility = 'editable',\n data: initialData = {},\n onChange = () => {},\n validationRules = companyDetailsValidationRules\n } = props;\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<CompanyDetailsSchema>({\n schema: requiredFields,\n rules: { ...companyDetailsValidationRules, ...validationRules },\n defaultData: initialData\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 = namePrefix ? name.split(`${namePrefix}.`).pop() : name;\n\n if (!key) return;\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 = namePrefix ? name.split(`${namePrefix}.`).pop() : name;\n\n if (!key) return;\n handleChangeFor(key, mode)(e);\n };\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n 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 autocomplete={'organization'}\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 autocomplete={undefined}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n"],"names":["COMPANY_DETAILS_SCHEMA","CompanyDetails","props","label","namePrefix","requiredFields","visibility","data","initialData","onChange","validationRules","companyDetailsValidationRules","i18n","useCoreContext","handleChangeFor","triggerValidation","valid","errors","isValid","useForm","schema","rules","defaultData","companyDetailsRef","useRef","Object","keys","current","length","setComponentRef","showValidation","generateFieldName","name","eventHandler","mode","e","target","key","split","pop","inputEventHandler","useEffect","formattedData","getFormattedData","h","ReadOnlyCompanyDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","InputText","value","onInput","onBlur","spellcheck","autocomplete","registrationNumber","undefined"],"mappings":"8mBAcaA,EAAyB,CAAC,OAA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KsC,IAAI,uBAChBH,mBAAoB,CAAC,QACrBI,eAAgBlC,EAAOe,KACvBpB,KAAMA,EACNoB,KAAMD,EAAkB,gBAExBa,EAACQ,EAAAA,CACGpB,KAAMD,EAAkB,QACxBsB,MAAO9C,EAAKyB,KACZe,mBAAoB,CAAC,QACrBO,QAASd,EAAkB,SAC3Be,OAAQtB,EAAa,QACrBuB,YAAY,EACZC,aAAc,kBAKzBpD,EAAe2C,SAAS,uBACrBJ,EAACK,EAAAA,CACG9C,MAAOS,EAAKsC,IAAI,qCAChBH,mBAAoB,CAAC,sBACrBI,eAAgBlC,EAAOyC,mBACvB9C,KAAMA,EACNoB,KAAMD,EAAkB,uBAExBa,EAACQ,EAAAA,CACGpB,KAAMD,EAAkB,sBACxBsB,MAAO9C,EAAKmD,mBACZX,mBAAoB,CAAC,sBACrBO,QAASd,EAAkB,SAC3Be,OAAQtB,EAAa,QACrBuB,YAAY,EACZC,kBAAcE,KAMtC"}
@@ -1,2 +1,2 @@
1
- import{isEmpty as r}from"../../../utils/validator-utils.js";import{SF_ErrorCodes as e}from"../../../core/Errors/constants.js";const a={default:{validate:r=>r&&r.length>0,modes:["blur"],errorMessage:e.ERROR_MSG_INCOMPLETE_FIELD},name:{validate:e=>!r(e)||null,errorMessage:"companyDetails.name.invalid",modes:["blur"]},registrationNumber:{validate:e=>!r(e)||null,errorMessage:"companyDetails.registrationNumber.invalid",modes:["blur"]}};export{a as companyDetailsValidationRules};
1
+ import{isEmpty as r}from"../../../utils/validator-utils.js";import{SF_ErrorCodes as e}from"../../../core/Errors/constants.js";const a={default:{validate:e=>!r(e)||null,modes:["blur"],errorMessage:e.ERROR_MSG_INCOMPLETE_FIELD},name:{validate:e=>!r(e)||null,errorMessage:"companyDetails.name.invalid",modes:["blur"]},registrationNumber:{validate:e=>!r(e)||null,errorMessage:"companyDetails.registrationNumber.invalid",modes:["blur"]}};export{a as companyDetailsValidationRules};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/CompanyDetails/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../utils/Validator/types';\nimport { isEmpty } from '../../../utils/validator-utils';\nimport { SF_ErrorCodes } from '../../../core/Errors/constants';\n\nexport const companyDetailsValidationRules: ValidatorRules = {\n default: {\n validate: value => {\n return value && value.length > 0;\n },\n modes: ['blur'],\n errorMessage: SF_ErrorCodes.ERROR_MSG_INCOMPLETE_FIELD // = 'err-gen-9100'\n },\n name: {\n validate: value => (isEmpty(value) ? null : true), // valid, if there are chars other than spaces\n errorMessage: 'companyDetails.name.invalid',\n modes: ['blur']\n },\n registrationNumber: {\n validate: value => (isEmpty(value) ? null : true),\n errorMessage: 'companyDetails.registrationNumber.invalid',\n modes: ['blur']\n }\n};\n"],"names":["companyDetailsValidationRules","default","validate","value","length","modes","errorMessage","SF_ErrorCodes","ERROR_MSG_INCOMPLETE_FIELD","name","isEmpty","registrationNumber"],"mappings":"oIAIaA,EAAgD,CACzDC,QAAS,CACLC,SAAUC,GACCA,GAASA,EAAMC,OAAS,EAEnCC,MAAO,CAAC,QACRC,aAAcC,EAAcC,4BAEhCC,KAAM,CACFP,SAAUC,IAAUO,EAAQP,IAAS,KACrCG,aAAc,8BACdD,MAAO,CAAC,SAEZM,mBAAoB,CAChBT,SAAUC,IAAUO,EAAQP,IAAS,KACrCG,aAAc,4CACdD,MAAO,CAAC"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/CompanyDetails/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../utils/Validator/types';\nimport { isEmpty } from '../../../utils/validator-utils';\nimport { SF_ErrorCodes } from '../../../core/Errors/constants';\n\nexport const companyDetailsValidationRules: ValidatorRules = {\n default: {\n validate: value => (isEmpty(value) ? null : true), // valid, if there are chars other than spaces\n modes: ['blur'],\n errorMessage: SF_ErrorCodes.ERROR_MSG_INCOMPLETE_FIELD // = 'err-gen-9100'\n },\n name: {\n validate: value => (isEmpty(value) ? null : true), // valid, if there are chars other than spaces\n errorMessage: 'companyDetails.name.invalid',\n modes: ['blur']\n },\n registrationNumber: {\n validate: value => (isEmpty(value) ? null : true),\n errorMessage: 'companyDetails.registrationNumber.invalid',\n modes: ['blur']\n }\n};\n"],"names":["companyDetailsValidationRules","default","validate","value","isEmpty","modes","errorMessage","SF_ErrorCodes","ERROR_MSG_INCOMPLETE_FIELD","name","registrationNumber"],"mappings":"oIAIaA,EAAgD,CACzDC,QAAS,CACLC,SAAUC,IAAUC,EAAQD,IAAS,KACrCE,MAAO,CAAC,QACRC,aAAcC,EAAcC,4BAEhCC,KAAM,CACFP,SAAUC,IAAUC,EAAQD,IAAS,KACrCG,aAAc,8BACdD,MAAO,CAAC,SAEZK,mBAAoB,CAChBR,SAAUC,IAAUC,EAAQD,IAAS,KACrCG,aAAc,4CACdD,MAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConsentCheckboxLabel.js","sources":["../../../../../src/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\n\ninterface ConsentCheckboxLabelProps {\n url: string;\n}\n\nexport default function ConsentCheckboxLabel(props: Readonly<ConsentCheckboxLabelProps>) {\n const { i18n } = useCoreContext();\n const linkText = i18n.get('paymentConditions');\n const translationString = i18n.get('afterPay.agreement');\n const [textBeforeLink, textAfterLink] = translationString.split('%@');\n\n if (textBeforeLink && textAfterLink) {\n return (\n <Fragment>\n {textBeforeLink}\n <a className=\"adyen-checkout-link\" target=\"_blank\" rel=\"noopener noreferrer\" href={props.url}>\n {linkText}\n </a>\n {textAfterLink}\n </Fragment>\n );\n }\n\n return <span className=\"adyen-checkout__checkbox__label\">{i18n.get('privacyPolicy')}</span>;\n}\n"],"names":["ConsentCheckboxLabel","props","i18n","useCoreContext","linkText","get","translationString","textBeforeLink","textAfterLink","split","h","Fragment","a","className","target","rel","href","url","span"],"mappings":"6JAOe,SAASA,EAAqBC,GACzC,MAAMC,KAAEA,GAASC,IACXC,EAAWF,EAAKG,IAAI,qBACpBC,EAAoBJ,EAAKG,IAAI,uBAC5BE,EAAgBC,GAAiBF,EAAkBG,MAAM,MAEhE,OAAIF,GAAkBC,EAEdE,EAACC,EAAAA,KACIJ,EACDG,EAACE,IAAAA,CAAEC,UAAU,sBAAsBC,OAAO,SAASC,IAAI,sBAAsBC,KAAMf,EAAMgB,KACpFb,GAEJI,GAKNE,EAACQ,OAAAA,CAAKL,UAAU,mCAAmCX,EAAKG,IAAI,iBACvE"}
1
+ {"version":3,"file":"ConsentCheckboxLabel.js","sources":["../../../../../src/components/internal/ConsentCheckboxLabel/ConsentCheckboxLabel.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\n\ninterface ConsentCheckboxLabelProps {\n url?: string;\n}\n\nexport default function ConsentCheckboxLabel(props: Readonly<ConsentCheckboxLabelProps>) {\n const { i18n } = useCoreContext();\n const linkText = i18n.get('paymentConditions');\n const translationString = i18n.get('afterPay.agreement');\n const [textBeforeLink, textAfterLink] = translationString.split('%@');\n\n if (textBeforeLink && textAfterLink) {\n return (\n <Fragment>\n {textBeforeLink}\n <a className=\"adyen-checkout-link\" target=\"_blank\" rel=\"noopener noreferrer\" href={props.url}>\n {linkText}\n </a>\n {textAfterLink}\n </Fragment>\n );\n }\n\n return <span className=\"adyen-checkout__checkbox__label\">{i18n.get('privacyPolicy')}</span>;\n}\n"],"names":["ConsentCheckboxLabel","props","i18n","useCoreContext","linkText","get","translationString","textBeforeLink","textAfterLink","split","h","Fragment","a","className","target","rel","href","url","span"],"mappings":"6JAOe,SAASA,EAAqBC,GACzC,MAAMC,KAAEA,GAASC,IACXC,EAAWF,EAAKG,IAAI,qBACpBC,EAAoBJ,EAAKG,IAAI,uBAC5BE,EAAgBC,GAAiBF,EAAkBG,MAAM,MAEhE,OAAIF,GAAkBC,EAEdE,EAACC,EAAAA,KACIJ,EACDG,EAACE,IAAAA,CAAEC,UAAU,sBAAsBC,OAAO,SAASC,IAAI,sBAAsBC,KAAMf,EAAMgB,KACpFb,GAEJI,GAKNE,EAACQ,OAAAA,CAAKL,UAAU,mCAAmCX,EAAKG,IAAI,iBACvE"}