@adyen/adyen-web 6.38.0 → 6.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/cjs/adyen.css +91 -91
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +91 -75
  6. package/dist/es/adyen.css +91 -91
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  9. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  10. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  11. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  12. package/dist/es/components/Affirm/Affirm.js +1 -1
  13. package/dist/es/components/Affirm/Affirm.js.map +1 -1
  14. package/dist/es/components/Affirm/config.js +1 -1
  15. package/dist/es/components/Affirm/config.js.map +1 -1
  16. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  17. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  18. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  19. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  20. package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
  21. package/dist/es/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  22. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  23. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  24. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  26. package/dist/es/components/PayPal/Paypal.js +1 -1
  27. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  28. package/dist/es/components/PayPal/constants.js +1 -1
  29. package/dist/es/components/PayPal/constants.js.map +1 -1
  30. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  31. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  32. package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
  33. package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
  34. package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
  35. package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
  36. package/dist/es/components/Pix/components/PixQRDetails.js +1 -1
  37. package/dist/es/components/Pix/components/PixQRDetails.js.map +1 -1
  38. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  39. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  40. package/dist/es/components/internal/Address/Address.js +1 -1
  41. package/dist/es/components/internal/Address/Address.js.map +1 -1
  42. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  43. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  44. package/dist/es/components/internal/Address/constants.js +1 -1
  45. package/dist/es/components/internal/Address/constants.js.map +1 -1
  46. package/dist/es/components/internal/Address/utils.js +1 -1
  47. package/dist/es/components/internal/Address/utils.js.map +1 -1
  48. package/dist/es/components/internal/Button/Button.js +1 -1
  49. package/dist/es/components/internal/Button/Button.js.map +1 -1
  50. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  51. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  54. package/dist/es/components/internal/ClickToPay/components/CtPLogin/validate.js +1 -1
  55. package/dist/es/components/internal/ClickToPay/components/CtPLogin/validate.js.map +1 -1
  56. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  57. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  58. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  59. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  60. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  61. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  62. package/dist/es/components/internal/FormFields/InputBase.js +1 -1
  63. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  64. package/dist/es/components/internal/FormFields/RadioGroup/RadioGroup.js +1 -1
  65. package/dist/es/components/internal/FormFields/RadioGroup/RadioGroup.js.map +1 -1
  66. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  67. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  68. package/dist/es/components/internal/FormFields/Select/components/SelectList.js +1 -1
  69. package/dist/es/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
  70. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  71. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  72. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  73. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  74. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  75. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  76. package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js +1 -1
  77. package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
  78. package/dist/es/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js +1 -1
  79. package/dist/es/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js.map +1 -1
  80. package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
  81. package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
  82. package/dist/es/core/config.js +1 -1
  83. package/dist/es/external/preact/dist/preact.js +1 -1
  84. package/dist/es/external/preact/dist/preact.js.map +1 -1
  85. package/dist/es/index.d.ts +91 -75
  86. package/dist/es/packages/server/translations/en-US.json.js +1 -1
  87. package/dist/es/utils/Validator/ValidationRuleResult.js +1 -1
  88. package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
  89. package/dist/es/utils/Validator/Validator.js +1 -1
  90. package/dist/es/utils/Validator/Validator.js.map +1 -1
  91. package/dist/es/utils/useForm/useForm.js +1 -1
  92. package/dist/es/utils/useForm/useForm.js.map +1 -1
  93. package/dist/es-legacy/adyen.css +91 -91
  94. package/dist/es-legacy/adyen.css.map +1 -1
  95. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  96. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  97. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  98. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  99. package/dist/es-legacy/components/Affirm/Affirm.js +1 -1
  100. package/dist/es-legacy/components/Affirm/Affirm.js.map +1 -1
  101. package/dist/es-legacy/components/Affirm/config.js +1 -1
  102. package/dist/es-legacy/components/Affirm/config.js.map +1 -1
  103. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  104. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  105. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  106. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  107. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
  108. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  109. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  110. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  111. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  112. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  113. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  114. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  115. package/dist/es-legacy/components/PayPal/constants.js +1 -1
  116. package/dist/es-legacy/components/PayPal/constants.js.map +1 -1
  117. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  118. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  119. package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
  120. package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
  121. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
  122. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
  123. package/dist/es-legacy/components/Pix/components/PixQRDetails.js +1 -1
  124. package/dist/es-legacy/components/Pix/components/PixQRDetails.js.map +1 -1
  125. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  126. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  127. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  128. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  129. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  130. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  131. package/dist/es-legacy/components/internal/Address/constants.js +1 -1
  132. package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
  133. package/dist/es-legacy/components/internal/Address/utils.js +1 -1
  134. package/dist/es-legacy/components/internal/Address/utils.js.map +1 -1
  135. package/dist/es-legacy/components/internal/Button/Button.js +1 -1
  136. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  137. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  138. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  139. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  140. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  141. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/validate.js +1 -1
  142. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/validate.js.map +1 -1
  143. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  144. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  145. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  146. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  147. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  148. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  149. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  150. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  151. package/dist/es-legacy/components/internal/FormFields/RadioGroup/RadioGroup.js +1 -1
  152. package/dist/es-legacy/components/internal/FormFields/RadioGroup/RadioGroup.js.map +1 -1
  153. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  154. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  155. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js +1 -1
  156. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
  157. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  158. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  159. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  160. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  161. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  162. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  163. package/dist/es-legacy/components/internal/SendCopyToEmail/SendCopyToEmail.js +1 -1
  164. package/dist/es-legacy/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
  165. package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js +1 -1
  166. package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/BrazilPersonalDetail.js.map +1 -1
  167. package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
  168. package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
  169. package/dist/es-legacy/core/config.js +1 -1
  170. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  171. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  172. package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
  173. package/dist/es-legacy/utils/Validator/ValidationRuleResult.js +1 -1
  174. package/dist/es-legacy/utils/Validator/ValidationRuleResult.js.map +1 -1
  175. package/dist/es-legacy/utils/Validator/Validator.js +1 -1
  176. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  177. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  178. package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
  179. package/package.json +17 -17
  180. package/styles/adyen.css +91 -91
@@ -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, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\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 FieldContainer(props: Readonly<FieldContainerProps>) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName);\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 switch (fieldName) {\n case '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 case '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 default:\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 />\n </Field>\n );\n }\n}\n\nexport default FieldContainer;\n"],"names":["FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","fieldName","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"],"mappings":"iTAyBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,GAAaZ,EAEhHa,EAAgBT,EAAKG,GACrBO,EAA0BV,EAAKW,QAC/BC,EAAsBhB,EAAMiB,eAAeC,wBAAwBJ,EAAiBP,GACpFY,EAAmBnB,EAAMiB,eAAeG,eAAeb,EAAWO,GAClEO,EAAgBL,EAAa,IAAIf,EAAKqB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGtB,EAAKqB,IAAIH,KAAYE,IAChCG,EA1BV,SAAyBnB,EAA2BE,EAAmBN,EAAgBsB,OACxElB,EAKeA,EAL1B,GAA+C,yBAApCA,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,cAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBrB,EAAOE,GAAWiB,aAChE,OAAOvB,EAAKqB,IAAIG,EAAgBC,EACpC,CAGA,OADiBzB,EAAKqB,IAAqB,QAAjBjB,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DvB,EAAOE,EAChC,CAkByBsB,CAAgBxB,EAAQE,EAAWN,EAAMsB,GAE9D,OAAQhB,GACJ,IAAK,UACD,OACIuB,EAACC,EAAAA,CACGC,iBAAkBhC,EAAMgC,iBACxB7B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBpB,MAAOA,EACPqB,UAAWlB,IAGvB,IAAK,kBACD,OACIc,EAACK,EAAAA,CACGhC,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBnB,gBAAiBA,EACjBG,eAAgBjB,EAAMiB,eACtBJ,MAAOA,EACPqB,UAAWlB,IAGvB,QACI,OACIc,EAACM,EAAAA,CACGb,MAAOA,EACPpB,mBAAoBA,EACpBqB,aAAcA,EACda,QAAS/B,EAAMC,GACf+B,KAAM/B,EACNN,KAAMA,EACNsC,QAASC,GAAKxC,EAAMyC,sBAAsBlC,EAAWiC,GACrD/B,OAAQ+B,GAAKxC,EAAM0C,qBAAqBnC,EAAWiC,IAEnDV,EAACa,EAAAA,CACGL,KAAM/B,EACNJ,mBAAoBA,EACpBU,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRmC,UAAWjC,EACXD,WAAYA,EACZE,SAAUA,EACVsB,UAAWlB,KAKnC"}
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';\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);\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 switch (fieldName) {\n case '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 case '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 default:\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}\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":"2WA2BA,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,EAA0BT,EAAKU,QAC/BC,EAAsBf,EAAMgB,eAAeC,wBAAwBJ,EAAiBlB,GACpFuB,EAAmBlB,EAAMgB,eAAeG,eAAexB,EAAWkB,GAClEO,EAAgBL,EAAa,IAAId,EAAKoB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGrB,EAAKoB,IAAIH,KAAYE,IAChCG,EAnCV,SAAyBlB,EAA2BV,EAAmBM,EAAgBqB,OACxEjB,EAKeA,EAL1B,GAA+C,yBAApCA,EAAAA,EAAOV,UAAPU,IAAAA,OAAAA,EAAAA,EAAmBkB,cAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBpB,EAAOV,GAAW4B,aAChE,OAAOtB,EAAKoB,IAAIG,EAAgBC,EACpC,CAGA,OADiBxB,EAAKoB,IAAqB,QAAjBhB,EAAAA,EAAOV,UAAPU,IAAAA,OAAAA,EAAAA,EAAmBkB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DtB,EAAOV,EAChC,CA2ByBiC,CAAgBvB,EAAQV,EAAWM,EAAMqB,GAE9D,OAAQ3B,GACJ,IAAK,UACD,OACIkC,EAACC,EAAAA,CACGC,iBAAkB/B,EAAM+B,iBACxB5B,mBAAoBA,EACpBmB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBhC,EAAMgC,iBACxBpB,MAAOA,EACPqB,UAAWlB,IAGvB,IAAK,kBACD,OACIc,EAACK,EAAAA,CACG/B,mBAAoBA,EACpBmB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBhC,EAAMgC,iBACxBnB,gBAAiBA,EACjBG,eAAgBhB,EAAMgB,eACtBJ,MAAOA,EACPqB,UAAWlB,IAGvB,QACI,OACIc,EAACM,EAAAA,CACGb,MAAOA,EACPnB,mBAAoBA,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,MAKxE"}
@@ -1,2 +1,2 @@
1
- const e="N/A",a=["street","houseNumberOrName","postalCode","city","stateOrProvince","country"],[s,t,l,r,o,c]=a,i={AU:{hasDataset:!0,labels:{[t]:"apartmentSuite",[o]:"state",[s]:"address"},optionalFields:[t],placeholders:{[o]:"select.state"},schema:[c,s,t,r,[[o,50],[l,50]]]},BR:{hasDataset:!0,labels:{[o]:"state"},placeholders:{[o]:"select.state"}},CA:{hasDataset:!0,labels:{[t]:"apartmentSuite",[o]:"provinceOrTerritory",[s]:"address"},optionalFields:[t],schema:[c,s,t,[[r,70],[l,30]],o]},GB:{labels:{[r]:"cityTown"},schema:[c,[[t,30],[s,70]],[[r,70],[l,30]],o]},US:{hasDataset:!0,labels:{[l]:"zipCode",[t]:"apartmentSuite",[o]:"state",[s]:"address"},optionalFields:[t],placeholders:{[o]:"select.state"},schema:[c,s,t,r,[[o,50],[l,50]]]},default:{optionalFields:[],placeholders:{[o]:"select.provinceOrTerritory"},schema:[c,[[s,70],[t,30]],[[l,30],[r,70]],o]}},d=Object.keys(i).reduce((e,a)=>(e[a]={labels:i[a].labels,schema:[l]},e),{}),p=Object.keys(i);export{a as ADDRESS_SCHEMA,i as ADDRESS_SPECIFICATIONS,r as CITY,p as COUNTRIES_WITH_CUSTOM_SPECIFICATION,c as COUNTRY,e as FALLBACK_VALUE,t as HOUSE_NUMBER_OR_NAME,d as PARTIAL_ADDRESS_SCHEMA,l as POSTAL_CODE,o as STATE_OR_PROVINCE,s as STREET};
1
+ const e="N/A",s=["street","houseNumberOrName","postalCode","city","stateOrProvince","country"],[a,t,l,r,o,c]=s,d={street:"address-line1",houseNumberOrName:"address-line2",postalCode:"postal-code",city:"address-level2"},i={AU:{hasDataset:!0,labels:{[t]:"apartmentSuite",[o]:"state",[a]:"address"},optionalFields:[t],placeholders:{[o]:"select.state"},schema:[c,a,t,r,[[o,50],[l,50]]]},BR:{hasDataset:!0,labels:{[o]:"state"},placeholders:{[o]:"select.state"}},CA:{hasDataset:!0,labels:{[t]:"apartmentSuite",[o]:"provinceOrTerritory",[a]:"address"},optionalFields:[t],schema:[c,a,t,[[r,70],[l,30]],o]},GB:{labels:{[r]:"cityTown"},schema:[c,[[t,30],[a,70]],[[r,70],[l,30]],o]},US:{hasDataset:!0,labels:{[l]:"zipCode",[t]:"apartmentSuite",[o]:"state",[a]:"address"},optionalFields:[t],placeholders:{[o]:"select.state"},schema:[c,a,t,r,[[o,50],[l,50]]]},default:{optionalFields:[],placeholders:{[o]:"select.provinceOrTerritory"},schema:[c,[[a,70],[t,30]],[[l,30],[r,70]],o]}},p=Object.keys(i).reduce((e,s)=>(e[s]={labels:i[s].labels,schema:[l]},e),{}),h=Object.keys(i);export{d as ADDRESS_FIELD_TOKEN_MAP,s as ADDRESS_SCHEMA,i as ADDRESS_SPECIFICATIONS,r as CITY,h as COUNTRIES_WITH_CUSTOM_SPECIFICATION,c as COUNTRY,e as FALLBACK_VALUE,t as HOUSE_NUMBER_OR_NAME,p as PARTIAL_ADDRESS_SCHEMA,l as POSTAL_CODE,o as STATE_OR_PROVINCE,a as STREET};
2
2
  //# sourceMappingURL=constants.js.map
@@ -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// 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 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_SPECIFICATIONS","AU","hasDataset","labels","optionalFields","placeholders","schema","BR","CA","GB","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,EAEhFO,EAAgD,CACzDC,GAAI,CACAC,YAAY,EACZC,OAAQ,CACJR,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,QACrBJ,CAACA,GAAS,WAEdU,eAAgB,CAACT,GACjBU,aAAc,CACVP,CAACA,GAAoB,gBAEzBQ,OAAQ,CAACP,EAASL,EAAQC,EAAsBE,EAAM,CAAC,CAACC,EAAmB,IAAK,CAACF,EAAa,OAElGW,GAAI,CACAL,YAAY,EACZC,OAAQ,CACJL,CAACA,GAAoB,SAEzBO,aAAc,CACVP,CAACA,GAAoB,iBAG7BU,GAAI,CACAN,YAAY,EACZC,OAAQ,CACJR,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,sBACrBJ,CAACA,GAAS,WAEdU,eAAgB,CAACT,GACjBW,OAAQ,CAACP,EAASL,EAAQC,EAAsB,CAAC,CAACE,EAAM,IAAK,CAACD,EAAa,KAAME,IAErFW,GAAI,CACAN,OAAQ,CACJN,CAACA,GAAO,YAEZS,OAAQ,CAACP,EAAS,CAAC,CAACJ,EAAsB,IAAK,CAACD,EAAQ,KAAM,CAAC,CAACG,EAAM,IAAK,CAACD,EAAa,KAAME,IAEnGY,GAAI,CACAR,YAAY,EACZC,OAAQ,CACJP,CAACA,GAAc,UACfD,CAACA,GAAuB,iBACxBG,CAACA,GAAoB,QACrBJ,CAACA,GAAS,WAEdU,eAAgB,CAACT,GACjBU,aAAc,CACVP,CAACA,GAAoB,gBAEzBQ,OAAQ,CAACP,EAASL,EAAQC,EAAsBE,EAAM,CAAC,CAACC,EAAmB,IAAK,CAACF,EAAa,OAElGe,QAAS,CACLP,eAAgB,GAChBC,aAAc,CACVP,CAACA,GAAoB,8BAEzBQ,OAAQ,CAACP,EAAS,CAAC,CAACL,EAAQ,IAAK,CAACC,EAAsB,KAAM,CAAC,CAACC,EAAa,IAAK,CAACC,EAAM,KAAMC,KAI1Fc,EAAgDC,OAAOC,KAAKd,GAAwBe,OAAO,CAACC,EAAKC,KAC1GD,EAAIC,GAAe,CACfd,OAAQH,EAAuBiB,GAAad,OAC5CG,OAAQ,CAACV,IAENoB,GACR,CAAA,GAEUE,EAAsCL,OAAOC,KAAKd"}
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 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","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,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,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,OAElGoB,QAAS,CACLP,eAAgB,GAChBC,aAAc,CACVZ,CAACA,GAAoB,8BAEzBa,OAAQ,CAACZ,EAAS,CAAC,CAACL,EAAQ,IAAK,CAACC,EAAsB,KAAM,CAAC,CAACC,EAAa,IAAK,CAACC,EAAM,KAAMC,KAI1FmB,EAAgDC,OAAOC,KAAKd,GAAwBe,OAAO,CAACC,EAAKC,KAC1GD,EAAIC,GAAe,CACfd,OAAQH,EAAuBiB,GAAad,OAC5CG,OAAQ,CAACf,IAENyB,GACR,CAAA,GAEUE,EAAsCL,OAAOC,KAAKd"}
@@ -1,2 +1,2 @@
1
- import{ADDRESS_SCHEMA as l}from"./constants.js";const n=(n,o,t)=>l.includes(n)?(null==t?void 0:t[n])?o.get(null==t?void 0:t[n]):o.get(n):null;export{n as mapFieldKey};
1
+ import{ADDRESS_SCHEMA as l}from"./constants.js";const d=(d,s,e)=>l.includes(d)?(null==e?void 0:e[d])?s.get(null==e?void 0:e[d]):s.get(d):null,s=(l,d)=>l||("billingAddress"===d||"deliveryAddress"===d?d:void 0);export{s as getAddressTypeFromLabel,d as mapFieldKey};
2
2
  //# sourceMappingURL=utils.js.map
@@ -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 } 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"],"names":["mapFieldKey","key","i18n","countrySpecificLabels","ADDRESS_SCHEMA","includes","get"],"mappings":"gDAUO,MAAMA,EAAc,CAACC,EAAaC,EAAgBC,IACjDC,EAAeC,SAASJ,IACjBE,aAAAA,EAAAA,EAAwBF,IAAOC,EAAKI,IAAIH,eAAAA,EAAwBF,IAAQC,EAAKI,IAAIL,GAErF"}
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,IACjBE,aAAAA,EAAAA,EAAwBF,IAAOC,EAAKI,IAAIH,eAAAA,EAAwBF,IAAQC,EAAKI,IAAIL,GAErF,KAGEM,EAA0B,CAACC,EAA0BC,IAC1DD,IAGU,mBAAVC,GAAwC,oBAAVA,EACvBA,OADX"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{classNameModifiers:e=[],disabled:i,href:r,icon:s,onClickCompletedIcon:l,inline:c,label:d,ariaLabel:u,ariaDescribedBy:p,ariaExpanded:m,ariaControls:b,status:h,variant:_,buttonRef:y,onClickCompletedLabel:f,onMouseEnter:g,onMouseLeave:k,onFocus:C,onBlur:v,onKeyDown:x,onKeyPress:N}=this.props,{completed:S}=this.state,{i18n:L}=o(),j=l||s?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=l?l:s,alt:"","aria-hidden":"true"}):"",B=[...e,..."primary"===_?[]:[_],...c?["inline"]:[],...S?["completed"]:[],..."loading"===h||"redirect"===h?["loading"]:[]],D=a(["adyen-checkout__button",...B.map(e=>`adyen-checkout__button--${e}`)]),M={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),L.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},j,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=f?f:d))},P=M[h]||M.default;return r?t("a",{className:D,href:r,target:this.props.target,rel:this.props.rel,"aria-disabled":i,onClick:e=>{i&&e.preventDefault()}},P):t("button",{ref:y,className:D,type:"button",disabled:i,onClick:this.onClick,"aria-label":u,"aria-describedby":p,"aria-expanded":m,"aria-controls":b,onMouseEnter:g,onMouseLeave:k,onKeyDown:x,onFocus:C,onBlur:v,onKeyPress:N},P,"loading"!==h&&"redirect"!==h&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},L.get(this.buttonStatusSRLabel(h))))}constructor(...e){super(...e),i(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
1
+ import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class r extends e{render(){const{id:e,classNameModifiers:i=[],disabled:r,href:s,icon:l,onClickCompletedIcon:c,inline:d,label:u,ariaLabel:p,ariaLabelledBy:m,ariaDescribedBy:b,ariaExpanded:h,ariaControls:_,status:y,variant:f,buttonRef:g,onClickCompletedLabel:k,onMouseEnter:C,onMouseLeave:v,onFocus:x,onBlur:N,onKeyDown:S,onKeyPress:L}=this.props,{completed:B}=this.state,{i18n:j}=o(),D=c||l?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed&&null!=c?c:l,alt:"","aria-hidden":"true"}):"",M=[...i,..."primary"===f?[]:[f],...d?["inline"]:[],...B?["completed"]:[],..."loading"===y||"redirect"===y?["loading"]:[]],P=a(["adyen-checkout__button",...M.map(e=>`adyen-checkout__button--${e}`)]),E={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),j.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},D,t("span",{className:"adyen-checkout__button__text"},this.state.completed&&null!=k?k:u))},K=E[y]||E.default;return s?t("a",{className:P,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":r,onClick:e=>{r&&e.preventDefault()}},K):t("button",{ref:g,id:e,className:P,type:"button",disabled:r,onClick:this.onClick,"aria-label":p,"aria-labelledby":m,"aria-describedby":b,"aria-expanded":h,"aria-controls":_,onMouseEnter:C,onMouseLeave:v,onKeyDown:S,onFocus:x,onBlur:N,onKeyPress:L},K,"loading"!==y&&"redirect"!==y&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},j.get(this.buttonStatusSRLabel(y))))}constructor(...e){super(...e),i(this,"onClick",e=>{var t,a;(e.preventDefault(),this.props.disabled)||(null===(t=(a=this.props).onClick)||void 0===t||t.call(a,e,{complete:this.complete}))}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(r,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{r as default};
2
2
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","_this_props_onClick","_this_props","call","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,gBACTA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFvB,GAAwBD,EACpByB,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,WAAanB,QAAAA,EAAgCD,EAC7D6B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXlC,KACa,YAAZY,EAAwB,GAAK,CAACA,MAC9BP,EAAS,CAAC,UAAY,MACtBkB,EAAY,CAAC,aAAe,MACjB,YAAXZ,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEwB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,EAAe,CACjBC,QACIZ,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAAStC,QAAAA,KAG/BuC,SACIhB,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAAStC,QAAAA,IACtBoB,EAAKoB,IAAI,0BAGlBC,QACIlB,EAACa,OAAAA,CAAKX,UAAU,mCACXH,EACDC,EAACa,OAAAA,CAAKX,UAAU,gCAAgCT,KAAKG,MAAMD,WAAaT,QAAAA,EAAkCR,KAKhHyC,EAAaR,EAAa5B,IAAW4B,EAAaO,QAExD,OAAI5C,EAEI0B,EAACoB,IAAAA,CACGlB,UAAWK,EACXjC,KAAMA,EACN+C,OAAQ5B,KAAKC,MAAM2B,OACnBC,IAAK7B,KAAKC,MAAM4B,IAChBC,gBAAelD,EACfmD,QAAUC,IACFpD,GACAoD,EAAEC,mBAITP,GAMTnB,EAAC2B,SAAAA,CACGC,IAAK3C,EACLiB,UAAWK,EACXsB,KAAK,SACLxD,SAAUA,EACVmD,QAAS/B,KAAK+B,QACdM,aAAYnD,EACZoD,mBAAkBnD,EAClBoD,gBAAenD,EACfoD,gBAAenD,EACfK,aAAcA,EACdC,aAAcA,EACdG,UAAWA,EACXF,QAASA,EACTC,OAAQA,EACRE,WAAYA,GAEX2B,EACW,YAAXpC,GAAmC,aAAXA,GAAyBU,KAAKC,MAAMwC,SAC7DlC,EAACa,OAAAA,CAAKsB,KAAK,SAASC,YAAU,SAASlC,UAAU,yCAC5CL,EAAKoB,IAAIxB,KAAK4C,oBAAoBtD,KAInD,mBArJJuD,SAAAC,GAUIC,EAAA/C,KAAO+B,UAAWC,QAIVgB,EAAAC,GAHJjB,EAAEC,iBAEGjC,KAAKC,MAAMrB,YACM,QAAlBoE,GAAAC,EAAAjD,KAAKC,OAAM8B,eAAX,IAAAiB,GAAAA,EAAAE,KAAAD,EAAqBjB,EAAG,CAAEmB,SAAUnD,KAAKmD,cAIjDJ,EAAA/C,KAAOmD,WAAW,CAACC,EAAQ,OACvBpD,KAAKqD,SAAS,CAAEnD,WAAW,IAC3BoD,WAAW,KACPtD,KAAKqD,SAAS,CAAEnD,WAAW,KAC5BkD,KAGPL,EAAA/C,KAAiB4C,sBAAuBtD,IACK,CACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/ByD,EADEvE,EACqB+E,eAAe,CAClCjE,OAAQ,UACRC,QAAS,UACTX,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR4C,OAAQ"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n id,\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaExpanded,\n ariaControls,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n id={id}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","id","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaExpanded","ariaControls","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-labelledby","aria-describedby","aria-expanded","aria-controls","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","_this_props_onClick","_this_props","call","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,GACFA,EAAEC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,aACfA,EAAYC,aACZA,EAAYC,OACZA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFxB,GAAwBD,EACpB0B,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,KAAKG,MAAMD,WAAapB,QAAAA,EAAgCD,EAC7D8B,IAAI,GACJC,cAAY,SAGhB,GAGFC,EAAY,IACXnC,KACa,YAAZa,EAAwB,GAAK,CAACA,MAC9BR,EAAS,CAAC,UAAY,MACtBmB,EAAY,CAAC,aAAe,MACjB,YAAXZ,GAAmC,aAAXA,EAAwB,CAAC,WAAa,IAGhEwB,EAAgBC,EAAW,CAAC,4BAA6BF,EAAUG,IAAIC,GAAK,2BAA2BA,OAEvGC,EAAe,CACjBC,QACIZ,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAASvC,QAAAA,KAG/BwC,SACIhB,EAACa,OAAAA,CAAKR,cAAY,OAAOH,UAAU,mCAC/BF,EAACc,EAAAA,CAAQC,KAAK,SAASvC,QAAAA,IACtBqB,EAAKoB,IAAI,0BAGlBC,QACIlB,EAACa,OAAAA,CAAKX,UAAU,mCACXH,EACDC,EAACa,OAAAA,CAAKX,UAAU,gCAAgCT,KAAKG,MAAMD,WAAaT,QAAAA,EAAkCT,KAKhH0C,EAAaR,EAAa5B,IAAW4B,EAAaO,QAExD,OAAI7C,EAEI2B,EAACoB,IAAAA,CACGlB,UAAWK,EACXlC,KAAMA,EACNgD,OAAQ5B,KAAKC,MAAM2B,OACnBC,IAAK7B,KAAKC,MAAM4B,IAChBC,gBAAenD,EACfoD,QAAUC,IACFrD,GACAqD,EAAEC,mBAITP,GAMTnB,EAAC2B,SAAAA,CACGC,IAAK3C,EACLf,GAAIA,EACJgC,UAAWK,EACXsB,KAAK,SACLzD,SAAUA,EACVoD,QAAS/B,KAAK+B,QACdM,aAAYpD,EACZqD,kBAAiBpD,EACjBqD,mBAAkBpD,EAClBqD,gBAAepD,EACfqD,gBAAepD,EACfK,aAAcA,EACdC,aAAcA,EACdG,UAAWA,EACXF,QAASA,EACTC,OAAQA,EACRE,WAAYA,GAEX2B,EACW,YAAXpC,GAAmC,aAAXA,GAAyBU,KAAKC,MAAMyC,SAC7DnC,EAACa,OAAAA,CAAKuB,KAAK,SAASC,YAAU,SAASnC,UAAU,yCAC5CL,EAAKoB,IAAIxB,KAAK6C,oBAAoBvD,KAInD,mBAzJJwD,SAAAC,GAUIC,EAAAhD,KAAO+B,UAAWC,QAIViB,EAAAC,GAHJlB,EAAEC,iBAEGjC,KAAKC,MAAMtB,YACM,QAAlBsE,GAAAC,EAAAlD,KAAKC,OAAM8B,eAAX,IAAAkB,GAAAA,EAAAE,KAAAD,EAAqBlB,EAAG,CAAEoB,SAAUpD,KAAKoD,cAIjDJ,EAAAhD,KAAOoD,WAAW,CAACC,EAAQ,OACvBrD,KAAKsD,SAAS,CAAEpD,WAAW,IAC3BqD,WAAW,KACPvD,KAAKsD,SAAS,CAAEpD,WAAW,KAC5BmD,KAGPL,EAAAhD,KAAiB6C,sBAAuBvD,IACK,CACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/B0D,EADE1E,EACqBkF,eAAe,CAClClE,OAAQ,UACRC,QAAS,UACTZ,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR6C,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:y}=s(),[P,h]=r(null),[j,v]=r(!1),[I,E]=r(null),[S,k]=r(!1),[x,w]=r(null),T=e(t=>{w(t)},[]),b=e(({data:t,isValid:o})=>{var r;h(t.shopperLogin),v(o),(null==t||null===(r=t.shopperLogin)||void 0===r?void 0:r.length)>0&&g(!0)},[]),L=e(async()=>{if(E(null),j){k(!0);try{const{isEnrolled:t}=await C({shopperEmail:P});t?await y():(E("NOT_FOUND"),k(!1))}catch(t){t instanceof m&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),u(t)?E(null==t?void 0:t.reason):console.error(t),k(!1)}}else x.validateInput()},[C,y,P,j,x]),M=e(t=>{"Enter"===t.key&&L()},[L]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:b,onSetInputHandlers:T,disabled:S,errorMessage:I&&d.get(`ctp.errors.${I}`),onPressEnter:L}),t(n,{label:d.get("continue"),variant:f?"primary":"secondary",status:S&&"loading",onClick:()=>{L()},onKeyDown:M}))};export{d as default};
1
+ import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:I}=s(),[P,y]=r(null),[h,j]=r(!1),[E,v]=r(null),[S,k]=r(!1),[x,L]=r(null),A=e(t=>{L(t)},[]),T=e(({data:t,isValid:o})=>{var r;y(t.shopperLogin),j(o),(null==t||null===(r=t.shopperLogin)||void 0===r?void 0:r.length)>0&&g(!0)},[]),w=e(async()=>{if(v(null),h){k(!0);try{const{isEnrolled:t}=await C({shopperEmail:P});t?await I():(v("NOT_FOUND"),k(!1))}catch(t){t instanceof m&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),u(t)?v("INVALID_PARAMETER"===t.reason?"INVALID_EMAIL":t.reason):console.error(t),k(!1)}}else x.validateInput()},[C,I,P,h,x]),M=e(t=>{"Enter"===t.key&&w()},[w]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:T,onSetInputHandlers:A,disabled:S,errorMessage:E&&d.get(`ctp.errors.${E}`),onPressEnter:w}),t(n,{label:d.get("continue"),variant:f?"primary":"secondary",status:S&&"loading",onClick:()=>{w()},onKeyDown:M}))};export{d as default};
2
2
  //# sourceMappingURL=CtPLogin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) setErrorCode(error?.reason);\n else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n const handleButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void handleOnLoginButtonClick();\n }\n },\n [handleOnLoginButtonClick]\n );\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n onKeyDown={handleButtonKeyDown}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","handleButtonKeyDown","event","key","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick","onKeyDown"],"mappings":"qnBAaA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC,0BAAEA,EAAyBC,6BAAEA,EAA4BC,0BAAEA,EAAyBC,wBAAEA,GAA4BC,KACjHC,EAAcC,GAAmBC,EAAiB,OAClDC,EAASC,GAAcF,GAAkB,IACzCG,EAAWC,GAAgBJ,EAAiB,OAC5CK,EAAaC,GAAkBN,GAAkB,IACjDO,EAAoBC,GAAyBR,EAAgC,MAE9ES,EAA0BC,EAAaC,IACzCH,EAAsBG,IACvB,IAEGC,EAAsBF,EAAY,EAAGG,OAAMZ,cAKzCY,IAAAA,EAJJd,EAAgBc,EAAKf,cACrBI,EAAWD,IAGPY,SAAkB,QAAlBA,EAAAA,EAAMf,oBAANe,IAAAA,OAAAA,EAAAA,EAAoBC,QAAS,GAC7BpB,GAA6B,IAElC,IAEGqB,EAA2BL,EAAYM,UAGzC,GAFAZ,EAAa,MAERH,EAAL,CAKAK,GAAe,GAEf,IACI,MAAMW,WAAEA,SAAqBtB,EAA0B,CAAEuB,aAAcpB,IACnEmB,QACMrB,KAENQ,EAAa,aACbE,GAAe,GAEvB,CAAE,MAAOa,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,sBAAsBH,EAAMI,cACrEJ,aAAiBK,GAAcH,QAAQC,KAAKH,EAAMI,YAClDE,EAAYN,GAAQf,EAAae,eAAAA,EAAOO,QACvCL,QAAQF,MAAMA,GAEnBb,GAAe,EACnB,CAnBA,MAFIC,EAAmBoB,iBAsBxB,CAAChC,EAA2BC,EAAyBE,EAAcG,EAASM,IAEzEqB,EAAsBlB,EACvBmB,IACqB,UAAdA,EAAMC,KACDf,KAGb,CAACA,IAGL,OACIgB,EAACC,EAAAA,KACGD,EAACE,EAAWC,MAAK,CAACC,aAAcJ,EAACK,EAAAA,OAAa7C,EAAK8C,IAAI,oBAEvDN,EAACE,EAAWK,KAAI,KAAE/C,EAAK8C,IAAI,uBAE3BN,EAACQ,EAAAA,CACGC,SAAU5B,EACV6B,mBAAoBhC,EACpBiC,SAAUrC,EACVsC,aAAcxC,GAAaZ,EAAK8C,IAAI,cAAclC,KAClDyC,aAAc7B,IAGlBgB,EAACc,EAAAA,CACGC,MAAOvD,EAAK8C,IAAI,YAChBU,QAAStD,EAA4B,UAAY,YACjDuD,OAAQ3C,GAAe,UACvB4C,QAAS,KACAlC,KAETmC,UAAWtB"}
1
+ {"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) {\n setErrorCode(error.reason === 'INVALID_PARAMETER' ? 'INVALID_EMAIL' : error.reason);\n } else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n const handleButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void handleOnLoginButtonClick();\n }\n },\n [handleOnLoginButtonClick]\n );\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n onKeyDown={handleButtonKeyDown}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","handleButtonKeyDown","event","key","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick","onKeyDown"],"mappings":"qnBAaA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC,0BAAEA,EAAyBC,6BAAEA,EAA4BC,0BAAEA,EAAyBC,wBAAEA,GAA4BC,KACjHC,EAAcC,GAAmBC,EAAiB,OAClDC,EAASC,GAAcF,GAAkB,IACzCG,EAAWC,GAAgBJ,EAAiB,OAC5CK,EAAaC,GAAkBN,GAAkB,IACjDO,EAAoBC,GAAyBR,EAAgC,MAE9ES,EAA0BC,EAAaC,IACzCH,EAAsBG,IACvB,IAEGC,EAAsBF,EAAY,EAAGG,OAAMZ,cAKzCY,IAAAA,EAJJd,EAAgBc,EAAKf,cACrBI,EAAWD,IAGPY,SAAkB,QAAlBA,EAAAA,EAAMf,oBAANe,IAAAA,OAAAA,EAAAA,EAAoBC,QAAS,GAC7BpB,GAA6B,IAElC,IAEGqB,EAA2BL,EAAYM,UAGzC,GAFAZ,EAAa,MAERH,EAAL,CAKAK,GAAe,GAEf,IACI,MAAMW,WAAEA,SAAqBtB,EAA0B,CAAEuB,aAAcpB,IACnEmB,QACMrB,KAENQ,EAAa,aACbE,GAAe,GAEvB,CAAE,MAAOa,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,sBAAsBH,EAAMI,cACrEJ,aAAiBK,GAAcH,QAAQC,KAAKH,EAAMI,YAClDE,EAAYN,GACZf,EAA8B,sBAAjBe,EAAMO,OAAiC,gBAAkBP,EAAMO,QACzEL,QAAQF,MAAMA,GAErBb,GAAe,EACnB,CApBA,MAFIC,EAAmBoB,iBAuBxB,CAAChC,EAA2BC,EAAyBE,EAAcG,EAASM,IAEzEqB,EAAsBlB,EACvBmB,IACqB,UAAdA,EAAMC,KACDf,KAGb,CAACA,IAGL,OACIgB,EAACC,EAAAA,KACGD,EAACE,EAAWC,MAAK,CAACC,aAAcJ,EAACK,EAAAA,OAAa7C,EAAK8C,IAAI,oBAEvDN,EAACE,EAAWK,KAAI,KAAE/C,EAAK8C,IAAI,uBAE3BN,EAACQ,EAAAA,CACGC,SAAU5B,EACV6B,mBAAoBhC,EACpBiC,SAAUrC,EACVsC,aAAcxC,GAAaZ,EAAK8C,IAAI,cAAclC,KAClDyC,aAAc7B,IAGlBgB,EAACc,EAAAA,CACGC,MAAOvD,EAAK8C,IAAI,YAChBU,QAAStD,EAA4B,UAAY,YACjDuD,OAAQ3C,GAAe,UACvB4C,QAAS,KACAlC,KAETmC,UAAWtB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const d=d=>{const{i18n:m}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&d.errorMessage&&l(c.current,"shopperLogin")},[d.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,d.onSetInputHandlers(j.current)},[E,d.onSetInputHandlers]);const k=s(e=>{"Enter"===e.key&&d.onPressEnter()},[d.onPressEnter]);return t(()=>{d.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:m.get("ctp.login.inputLabel"),errorMessage:I?d.errorMessage||!!F.shopperLogin:null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:d.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyPress:k})))};export{d as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const m=m=>{const{i18n:d}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&m.errorMessage&&l(c.current,"shopperLogin")},[m.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,m.onSetInputHandlers(j.current)},[E,m.onSetInputHandlers]);const M=s(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);return t(()=>{m.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:d.get("ctp.login.inputLabel"),errorMessage:I?m.errorMessage||F.shopperLogin&&d.get(F.shopperLogin.errorMessage):null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:m.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyPress:M,autocomplete:"email"})))};export{m as default};
2
2
  //# sourceMappingURL=CtPLoginInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,IAEXC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAwC,CACjHC,OAHe,CAAC,gBAIhBC,MAAOC,EACPC,WAAYZ,IAEVa,EAAwBZ,EAA8B,CAAEa,cAAe,KAAMC,WAAY,QACxFC,EAAmBC,GAAwBC,GAAkB,GAE9DJ,EAAgBK,EAAY,KAC9BF,GAAqB,GACrBb,KACD,CAACA,IAEJgB,EAAU,KACFpB,EAAaqB,SAAWxB,EAAMyB,cAC9BC,EAAgBvB,EAAaqB,QAAS,iBAE3C,CAACxB,EAAMyB,eAEVF,EAAU,KACFjB,EAAKqB,cAAcP,GAAqB,IAC7C,CAACd,EAAKqB,eAETJ,EAAU,KACNP,EAAsBQ,QAAQP,cAAgBA,EAC9CjB,EAAM4B,mBAAmBZ,EAAsBQ,UAChD,CAACP,EAAejB,EAAM4B,qBAEzB,MAAMC,EAAmBP,EACpBQ,IACqB,UAAdA,EAAMC,KACD/B,EAAMgC,gBAGnB,CAAChC,EAAMgC,eAOX,OAJAT,EAAU,KACNvB,EAAMiC,SAAS,CAAE3B,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbyB,EAACC,MAAAA,CAAIC,IAAKjC,GACN+B,EAACG,EAAAA,CACGC,KAAK,eACLC,MAAOtC,EAAKuC,IAAI,wBAChBf,aAAcN,EAAoBnB,EAAMyB,gBAAkBhB,EAAOkB,aAAe,KAChFc,mBAAoB,CAAC,gBACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOxC,EAAKqB,aACZoB,SAAU/C,EAAM+C,SAChBC,QAAS3C,EAAgB,eAAgB,SACzC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB"}
1
+ {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || (errors.shopperLogin && i18n.get(errors.shopperLogin.errorMessage)) : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n autocomplete={'email'}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","autocomplete"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,IAEXC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAwC,CACjHC,OAHe,CAAC,gBAIhBC,MAAOC,EACPC,WAAYZ,IAEVa,EAAwBZ,EAA8B,CAAEa,cAAe,KAAMC,WAAY,QACxFC,EAAmBC,GAAwBC,GAAkB,GAE9DJ,EAAgBK,EAAY,KAC9BF,GAAqB,GACrBb,KACD,CAACA,IAEJgB,EAAU,KACFpB,EAAaqB,SAAWxB,EAAMyB,cAC9BC,EAAgBvB,EAAaqB,QAAS,iBAE3C,CAACxB,EAAMyB,eAEVF,EAAU,KACFjB,EAAKqB,cAAcP,GAAqB,IAC7C,CAACd,EAAKqB,eAETJ,EAAU,KACNP,EAAsBQ,QAAQP,cAAgBA,EAC9CjB,EAAM4B,mBAAmBZ,EAAsBQ,UAChD,CAACP,EAAejB,EAAM4B,qBAEzB,MAAMC,EAAmBP,EACpBQ,IACqB,UAAdA,EAAMC,KACD/B,EAAMgC,gBAGnB,CAAChC,EAAMgC,eAOX,OAJAT,EAAU,KACNvB,EAAMiC,SAAS,CAAE3B,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbyB,EAACC,MAAAA,CAAIC,IAAKjC,GACN+B,EAACG,EAAAA,CACGC,KAAK,eACLC,MAAOtC,EAAKuC,IAAI,wBAChBf,aAAcN,EAAoBnB,EAAMyB,cAAiBhB,EAAOkB,cAAgB1B,EAAKuC,IAAI/B,EAAOkB,aAAaF,cAAiB,KAC9HgB,mBAAoB,CAAC,gBACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOxC,EAAKqB,aACZoB,SAAU/C,EAAM+C,SAChBC,QAAS3C,EAAgB,eAAgB,SACzC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB,EACZsB,aAAc"}
@@ -1,2 +1,2 @@
1
- const e={shopperLogin:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]},default:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]}};export{e as loginValidationRules};
1
+ const e={shopperLogin:{validate:e=>!!e&&e.length>0,errorMessage:"ctp.errors.INVALID_EMAIL",modes:["blur"]},default:{validate:e=>!!e&&e.length>0,errorMessage:"",modes:["blur"]}};export{e as loginValidationRules};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../../../utils/Validator/types';\n\nexport const loginValidationRules: ValidatorRules = {\n shopperLogin: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n },\n default: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n }\n};\n"],"names":["loginValidationRules","shopperLogin","validate","value","length","errorMessage","modes","default"],"mappings":"MAEaA,EAAuC,CAChDC,aAAc,CACVC,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,GACdC,MAAO,CAAC,SAEZC,QAAS,CACLL,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,GACdC,MAAO,CAAC"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/validate.ts"],"sourcesContent":["import { ValidatorRules } from '../../../../../utils/Validator/types';\n\nexport const loginValidationRules: ValidatorRules = {\n shopperLogin: {\n validate: value => !!value && value.length > 0,\n errorMessage: 'ctp.errors.INVALID_EMAIL',\n modes: ['blur']\n },\n default: {\n validate: value => !!value && value.length > 0,\n errorMessage: '',\n modes: ['blur']\n }\n};\n"],"names":["loginValidationRules","shopperLogin","validate","value","length","errorMessage","modes","default"],"mappings":"MAEaA,EAAuC,CAChDC,aAAc,CACVC,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,2BACdC,MAAO,CAAC,SAEZC,QAAS,CACLL,SAAUC,KAAWA,GAASA,EAAMC,OAAS,EAC7CC,aAAc,GACdC,MAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as d}from"../../../../../../utils/setFocus.js";import u from"../../../../FormFields/Field/Field.js";import c from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&d(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(u,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(c,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e}})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as u}from"../../../../../../utils/setFocus.js";import c from"../../../../FormFields/Field/Field.js";import d from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&u(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(c,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(d,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e},autocomplete:"off"})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
2
2
  //# sourceMappingURL=CtPOneTimePasswordInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAAkD,CACpIC,OAJe,CAAC,OAKhBC,MAAOC,EACPC,WAAYb,IAEVc,EAAsBb,EAAwC,CAAEc,cAAe,OAC/EC,EAAWf,EAAyB,OACnCgB,EAAgBC,GAAsBnB,GAAkB,GAEzDgB,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDzB,GAAuBqB,EAASM,SACjCN,EAASM,QAAQC,SAEtB,CAACP,EAASM,QAAS3B,IAEtByB,EAAU,KACFpB,EAAasB,SAAW/B,EAAMiC,cAC9BC,EAAgBzB,EAAasB,QAAS,QAE3C,CAAC/B,EAAMiC,eAEVJ,EAAU,KACNN,EAAoBQ,QAAQP,cAAgBA,EAC5CxB,EAAMmC,mBAAmBZ,EAAoBQ,UAC9C,CAACP,EAAexB,EAAMmC,qBAEzB,MAAMC,EAAoBR,EAAY,KAClCX,EAAQ,MAAO,IACfV,EAAkB,MACbH,GACDqB,EAASM,QAAQC,QAErBhC,EAAMqC,gBACP,CAACrC,EAAMqC,aAAcZ,EAASM,QAAS3B,IAEpCkC,EAAyBV,EAC1BW,IACG,MAAMC,EAAUvC,EAAKwC,IAAI,cAAcF,KACnCC,GAASjC,EAAkBiC,IAEnC,CAACvC,IAGCyC,EAAmBd,EACpBe,IACqB,UAAdA,EAAMC,KACD5C,EAAM6C,gBAGnB,CAAC7C,EAAM6C,eAGXhB,EAAU,KACN7B,EAAM8C,SAAS,CAAElC,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAEjB,MAAMgC,EAAqBnB,EAAY,IAC9BF,EAEEpB,GAAkBN,EAAMiC,cAAgBe,EAAgB/C,EAAMc,EAAOe,IAAK7B,EAAKwC,IAAI,uBAF9D,KAG7B,CAACf,EAAgBpB,EAAgBN,EAAMiC,aAAclB,EAAOe,IAAK7B,IAEpE,OACIgD,EAACC,MAAAA,CAAIC,IAAK1C,EAAc2C,UAAW,yCAC/BH,EAACI,EAAAA,CACGC,KAAK,kBACLC,MAAOtD,EAAKwC,IAAI,sBAChBR,aAAcc,IACdS,mBAAoB,CAAC,OACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGJ,KAAM,MACNK,YAAa,MACbC,YAAY,EACZC,MAAOjD,EAAKkB,IACZgC,SAAU9D,EAAM8D,SAChBC,QAASpD,EAAgB,MAAO,SAChCqD,OAAQrD,EAAgB,MAAO,QAC/BsD,WAAYvB,EACZwB,OAASf,IACL1B,EAASM,QAAUoB,MAI/BF,EAACC,MAAAA,CAAIE,UAAW,+CACZH,EAACkB,EAAAA,CAAiBL,SAAU9D,EAAMoE,gBAAiBC,QAAS/B,EAAwBD,aAAcD"}
1
+ {"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../../utils/useForm';\nimport { setFocusOnField } from '../../../../../../utils/setFocus';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: Readonly<CtPOneTimePasswordInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useFormWithA11y<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules,\n formHolder: containerRef\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'otp');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div ref={containerRef} className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n errorMessage={getOtpErrorMessage()}\n classNameModifiers={['otp']}\n errorLive={true}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n autocomplete={'off'}\n />\n </Field>\n <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useFormWithA11y","schema","rules","otpValidationRules","formHolder","otpInputHandlersRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","errorMessage","setFocusOnField","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","getOtpErrorMessage","getErrorMessage","h","div","ref","className","Field","name","label","classNameModifiers","errorLive","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","autocomplete","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"2uBAkCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,MACvDC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAAkD,CACpIC,OAJe,CAAC,OAKhBC,MAAOC,EACPC,WAAYb,IAEVc,EAAsBb,EAAwC,CAAEc,cAAe,OAC/EC,EAAWf,EAAyB,OACnCgB,EAAgBC,GAAsBnB,GAAkB,GAEzDgB,EAAgBI,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDzB,GAAuBqB,EAASM,SACjCN,EAASM,QAAQC,SAEtB,CAACP,EAASM,QAAS3B,IAEtByB,EAAU,KACFpB,EAAasB,SAAW/B,EAAMiC,cAC9BC,EAAgBzB,EAAasB,QAAS,QAE3C,CAAC/B,EAAMiC,eAEVJ,EAAU,KACNN,EAAoBQ,QAAQP,cAAgBA,EAC5CxB,EAAMmC,mBAAmBZ,EAAoBQ,UAC9C,CAACP,EAAexB,EAAMmC,qBAEzB,MAAMC,EAAoBR,EAAY,KAClCX,EAAQ,MAAO,IACfV,EAAkB,MACbH,GACDqB,EAASM,QAAQC,QAErBhC,EAAMqC,gBACP,CAACrC,EAAMqC,aAAcZ,EAASM,QAAS3B,IAEpCkC,EAAyBV,EAC1BW,IACG,MAAMC,EAAUvC,EAAKwC,IAAI,cAAcF,KACnCC,GAASjC,EAAkBiC,IAEnC,CAACvC,IAGCyC,EAAmBd,EACpBe,IACqB,UAAdA,EAAMC,KACD5C,EAAM6C,gBAGnB,CAAC7C,EAAM6C,eAGXhB,EAAU,KACN7B,EAAM8C,SAAS,CAAElC,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAEjB,MAAMgC,EAAqBnB,EAAY,IAC9BF,EAEEpB,GAAkBN,EAAMiC,cAAgBe,EAAgB/C,EAAMc,EAAOe,IAAK7B,EAAKwC,IAAI,uBAF9D,KAG7B,CAACf,EAAgBpB,EAAgBN,EAAMiC,aAAclB,EAAOe,IAAK7B,IAEpE,OACIgD,EAACC,MAAAA,CAAIC,IAAK1C,EAAc2C,UAAW,yCAC/BH,EAACI,EAAAA,CACGC,KAAK,kBACLC,MAAOtD,EAAKwC,IAAI,sBAChBR,aAAcc,IACdS,mBAAoB,CAAC,OACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGJ,KAAM,MACNK,YAAa,MACbC,YAAY,EACZC,MAAOjD,EAAKkB,IACZgC,SAAU9D,EAAM8D,SAChBC,QAASpD,EAAgB,MAAO,SAChCqD,OAAQrD,EAAgB,MAAO,QAC/BsD,WAAYvB,EACZwB,OAASf,IACL1B,EAASM,QAAUoB,GAEvBgB,aAAc,SAGtBlB,EAACC,MAAAA,CAAIE,UAAW,+CACZH,EAACmB,EAAAA,CAAiBN,SAAU9D,EAAMqE,gBAAiBC,QAAShC,EAAwBD,aAAcD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useEffect as o,useCallback as r}from"../../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../context/useClickToPayContext.js";import n from"../../../../../../_virtual/index.js";import{useCoreContext as a}from"../../../../../../core/Context/CoreProvider.js";import c from"../../../../Icon/Icon.js";import{isSrciError as i}from"../../../services/utils.js";import{PREFIX as d}from"../../../../Icon/constants.js";import l from"../../../../Button/Button.js";const m=({onError:m,onResendCode:p,disabled:u})=>{const[f,k]=t(null),[h,j]=t(!1),{i18n:C}=a(),{startIdentityValidation:v}=s();o(()=>{let e=null;return f>0&&(e=setTimeout(()=>k(f-1),1e3)),()=>clearTimeout(e)},[f]),o(()=>{let e=null;return h&&(e=setTimeout(()=>{j(!1),k(60)},2e3)),()=>clearTimeout(e)},[h]);const y=r(async e=>{e.preventDefault();try{p(),j(!0),await v()}catch(e){if(k(0),j(!1),!i(e))return void console.error(e);m(e.reason)}},[v,m,p]);return h?e("div",{role:"alert",className:"adyen-checkout-ctp__otp-resend-code--confirmation"},C.get("ctp.otp.codeResent"),e(c,{type:`${d}checkmark_black`,height:14,width:14})):f>0?e("div",{role:"timer",className:"adyen-checkout-ctp__otp-resend-code--disabled"},C.get("ctp.otp.resendCode")," -"," ",e("span",{className:"adyen-checkout-ctp__otp-resend-code-counter"}," ",f>0&&`${f}s`," ")):e(l,{classNameModifiers:[n("otp-resend-code",{"otp-resend-code--disabled":u})],onClick:y,variant:"link",inline:!0,disabled:u},C.get("ctp.otp.resendCode"))};export{m as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useEffect as o,useCallback as r}from"../../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../context/useClickToPayContext.js";import n from"../../../../../../_virtual/index.js";import{useCoreContext as c}from"../../../../../../core/Context/CoreProvider.js";import{useA11yReporter as a}from"../../../../../../core/Errors/useA11yReporter.js";import i from"../../../../Icon/Icon.js";import{isSrciError as d}from"../../../services/utils.js";import{PREFIX as p}from"../../../../Icon/constants.js";import l from"../../../../Button/Button.js";const m=({onError:m,onResendCode:u,disabled:f})=>{const[k,C]=t(null),[h,j]=t(!1),{i18n:y}=c(),{startIdentityValidation:v}=s(),[_,x]=t(null);a(_),o(()=>{let e;return k>0&&(e=setTimeout(()=>C(k-1),1e3)),60===k?x(`${y.get("ctp.otp.resendCode")} - ${k}s`):0===k&&x(y.get("ctp.otp.resendCode")),()=>clearTimeout(e)},[k]),o(()=>{let e;return h&&(e=setTimeout(()=>{j(!1),C(60)},2e3)),()=>clearTimeout(e)},[h]);const b=r(async e=>{e.preventDefault();try{u(),j(!0),await v()}catch(e){if(C(0),j(!1),!d(e))return void console.error(e);m(e.reason)}},[v,m,u]);return h?e("div",{role:"alert",className:"adyen-checkout-ctp__otp-resend-code--confirmation"},y.get("ctp.otp.codeResent"),e(i,{type:`${p}checkmark_black`,height:14,width:14})):k>0?e("div",{role:"timer",className:"adyen-checkout-ctp__otp-resend-code--disabled"},y.get("ctp.otp.resendCode")," -"," ",e("span",{className:"adyen-checkout-ctp__otp-resend-code-counter"}," ",k>0&&`${k}s`," ")):e(l,{classNameModifiers:[n("otp-resend-code",{"otp-resend-code--disabled":f})],onClick:b,variant:"link",inline:!0,disabled:f},y.get("ctp.otp.resendCode"))};export{m as default};
2
2
  //# sourceMappingURL=CtPResendOtpLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPResendOtpLink.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport classnames from 'classnames';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport Icon from '../../../../Icon';\nimport { isSrciError } from '../../../services/utils';\nimport { PREFIX } from '../../../../Icon/constants';\nimport Button from '../../../../Button';\n\nconst CONFIRMATION_SHOWING_TIME = 2000;\n\ninterface CtPResendOtpLinkProps {\n onError(errorCode: string): void;\n onResendCode(): void;\n disabled: boolean;\n}\n\nconst CtPResendOtpLink = ({ onError, onResendCode, disabled }: Readonly<CtPResendOtpLinkProps>): h.JSX.Element => {\n const [counter, setCounter] = useState<number>(null);\n const [showConfirmation, setShowConfirmation] = useState<boolean>(false);\n const { i18n } = useCoreContext();\n const { startIdentityValidation } = useClickToPayContext();\n\n useEffect(() => {\n let timeout = null;\n if (counter > 0) {\n timeout = setTimeout(() => setCounter(counter - 1), 1000);\n }\n return () => clearTimeout(timeout);\n }, [counter]);\n\n useEffect(() => {\n let timeout = null;\n\n if (showConfirmation) {\n timeout = setTimeout(() => {\n setShowConfirmation(false);\n setCounter(60);\n }, CONFIRMATION_SHOWING_TIME);\n }\n return () => clearTimeout(timeout);\n }, [showConfirmation]);\n\n const handleResendCodeClick = useCallback(\n async event => {\n event.preventDefault();\n\n try {\n onResendCode();\n setShowConfirmation(true);\n await startIdentityValidation();\n } catch (error: unknown) {\n setCounter(0);\n setShowConfirmation(false);\n\n if (!isSrciError(error)) {\n console.error(error);\n return;\n }\n\n onError(error.reason);\n }\n },\n [startIdentityValidation, onError, onResendCode]\n );\n\n if (showConfirmation) {\n return (\n <div role=\"alert\" className=\"adyen-checkout-ctp__otp-resend-code--confirmation\">\n {i18n.get('ctp.otp.codeResent')}\n <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />\n </div>\n );\n }\n\n if (counter > 0) {\n return (\n <div role=\"timer\" className=\"adyen-checkout-ctp__otp-resend-code--disabled\">\n {i18n.get('ctp.otp.resendCode')} -{' '}\n <span className=\"adyen-checkout-ctp__otp-resend-code-counter\"> {counter > 0 && `${counter}s`} </span>\n </div>\n );\n }\n\n return (\n <Button\n classNameModifiers={[classnames('otp-resend-code', { 'otp-resend-code--disabled': disabled })]}\n onClick={handleResendCodeClick}\n variant=\"link\"\n inline={true}\n disabled={disabled}\n >\n {i18n.get('ctp.otp.resendCode')}\n </Button>\n );\n};\n\nexport default CtPResendOtpLink;\n"],"names":["CtPResendOtpLink","onError","onResendCode","disabled","counter","setCounter","useState","showConfirmation","setShowConfirmation","i18n","useCoreContext","startIdentityValidation","useClickToPayContext","useEffect","timeout","setTimeout","clearTimeout","handleResendCodeClick","useCallback","async","event","preventDefault","error","isSrciError","console","reason","h","div","role","className","get","Icon","type","PREFIX","height","width","span","Button","classNameModifiers","classnames","onClick","variant","inline"],"mappings":"ikBAUA,MAQMA,EAAmB,EAAGC,UAASC,eAAcC,eAC/C,MAAOC,EAASC,GAAcC,EAAiB,OACxCC,EAAkBC,GAAuBF,GAAkB,IAC5DG,KAAEA,GAASC,KACXC,wBAAEA,GAA4BC,IAEpCC,EAAU,KACN,IAAIC,EAAU,KAId,OAHIV,EAAU,IACVU,EAAUC,WAAW,IAAMV,EAAWD,EAAU,GAAI,MAEjD,IAAMY,aAAaF,IAC3B,CAACV,IAEJS,EAAU,KACN,IAAIC,EAAU,KAQd,OANIP,IACAO,EAAUC,WAAW,KACjBP,GAAoB,GACpBH,EAAW,KA5BO,MA+BnB,IAAMW,aAAaF,IAC3B,CAACP,IAEJ,MAAMU,EAAwBC,EAC1BC,MAAMC,IACFA,EAAMC,iBAEN,IACInB,IACAM,GAAoB,SACdG,GACV,CAAE,MAAOW,GAIL,GAHAjB,EAAW,GACXG,GAAoB,IAEfe,EAAYD,GAEb,YADAE,QAAQF,MAAMA,GAIlBrB,EAAQqB,EAAMG,OAClB,GAEJ,CAACd,EAAyBV,EAASC,IAGvC,OAAIK,EAEImB,EAACC,MAAAA,CAAIC,KAAK,QAAQC,UAAU,qDACvBpB,EAAKqB,IAAI,sBACVJ,EAACK,EAAAA,CAAKC,KAAM,GAAGC,mBAAyBC,OAAQ,GAAIC,MAAO,MAKnE/B,EAAU,EAENsB,EAACC,MAAAA,CAAIC,KAAK,QAAQC,UAAU,iDACvBpB,EAAKqB,IAAI,sBAAsB,KAAG,IACnCJ,EAACU,OAAAA,CAAKP,UAAU,+CAA8C,IAAEzB,EAAU,GAAK,GAAGA,KAAW,MAMrGsB,EAACW,EAAAA,CACGC,mBAAoB,CAACC,EAAW,kBAAmB,CAAE,4BAA6BpC,KAClFqC,QAASvB,EACTwB,QAAQ,OACRC,QAAQ,EACRvC,SAAUA,GAETM,EAAKqB,IAAI"}
1
+ {"version":3,"file":"CtPResendOtpLink.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.tsx"],"sourcesContent":["import { h, TargetedMouseEvent } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport classnames from 'classnames';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport { useA11yReporter } from '../../../../../../core/Errors/useA11yReporter';\nimport Icon from '../../../../Icon';\nimport { isSrciError } from '../../../services/utils';\nimport { PREFIX } from '../../../../Icon/constants';\nimport Button from '../../../../Button';\n\nconst CONFIRMATION_SHOWING_TIME = 2000;\nconst RESEND_OTP_COUNTDOWN_SECONDS = 60;\n\ninterface CtPResendOtpLinkProps {\n onError(errorCode: string): void;\n onResendCode(): void;\n disabled: boolean;\n}\n\nconst CtPResendOtpLink = ({ onError, onResendCode, disabled }: Readonly<CtPResendOtpLinkProps>): h.JSX.Element => {\n const [counter, setCounter] = useState<number | null>(null);\n const [showConfirmation, setShowConfirmation] = useState<boolean>(false);\n const { i18n } = useCoreContext();\n const { startIdentityValidation } = useClickToPayContext();\n const [resendStatusMessage, setResendStatusMessage] = useState<string | null>(null);\n useA11yReporter(resendStatusMessage);\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n if (counter > 0) {\n timeout = setTimeout(() => setCounter(counter - 1), 1000);\n }\n if (counter === RESEND_OTP_COUNTDOWN_SECONDS) {\n setResendStatusMessage(`${i18n.get('ctp.otp.resendCode')} - ${counter}s`);\n } else if (counter === 0) {\n setResendStatusMessage(i18n.get('ctp.otp.resendCode'));\n }\n return () => clearTimeout(timeout);\n }, [counter]);\n\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n if (showConfirmation) {\n timeout = setTimeout(() => {\n setShowConfirmation(false);\n setCounter(RESEND_OTP_COUNTDOWN_SECONDS);\n }, CONFIRMATION_SHOWING_TIME);\n }\n return () => clearTimeout(timeout);\n }, [showConfirmation]);\n\n const handleResendCodeClick = useCallback(\n async (event: TargetedMouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n\n try {\n onResendCode();\n setShowConfirmation(true);\n await startIdentityValidation();\n } catch (error: unknown) {\n setCounter(0);\n setShowConfirmation(false);\n\n if (!isSrciError(error)) {\n console.error(error);\n return;\n }\n\n onError(error.reason);\n }\n },\n [startIdentityValidation, onError, onResendCode]\n );\n\n if (showConfirmation) {\n return (\n <div role=\"alert\" className=\"adyen-checkout-ctp__otp-resend-code--confirmation\">\n {i18n.get('ctp.otp.codeResent')}\n <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />\n </div>\n );\n }\n\n if (counter > 0) {\n return (\n <div role=\"timer\" className=\"adyen-checkout-ctp__otp-resend-code--disabled\">\n {i18n.get('ctp.otp.resendCode')} -{' '}\n <span className=\"adyen-checkout-ctp__otp-resend-code-counter\"> {counter > 0 && `${counter}s`} </span>\n </div>\n );\n }\n\n return (\n <Button\n classNameModifiers={[classnames('otp-resend-code', { 'otp-resend-code--disabled': disabled })]}\n onClick={handleResendCodeClick}\n variant=\"link\"\n inline={true}\n disabled={disabled}\n >\n {i18n.get('ctp.otp.resendCode')}\n </Button>\n );\n};\n\nexport default CtPResendOtpLink;\n"],"names":["CtPResendOtpLink","onError","onResendCode","disabled","counter","setCounter","useState","showConfirmation","setShowConfirmation","i18n","useCoreContext","startIdentityValidation","useClickToPayContext","resendStatusMessage","setResendStatusMessage","useA11yReporter","useEffect","timeout","setTimeout","get","clearTimeout","handleResendCodeClick","useCallback","async","event","preventDefault","error","isSrciError","console","reason","h","div","role","className","Icon","type","PREFIX","height","width","span","Button","classNameModifiers","classnames","onClick","variant","inline"],"mappings":"opBAWA,MASMA,EAAmB,EAAGC,UAASC,eAAcC,eAC/C,MAAOC,EAASC,GAAcC,EAAwB,OAC/CC,EAAkBC,GAAuBF,GAAkB,IAC5DG,KAAEA,GAASC,KACXC,wBAAEA,GAA4BC,KAC7BC,EAAqBC,GAA0BR,EAAwB,MAC9ES,EAAgBF,GAEhBG,EAAU,KACN,IAAIC,EASJ,OARIb,EAAU,IACVa,EAAUC,WAAW,IAAMb,EAAWD,EAAU,GAAI,MAnB3B,KAqBzBA,EACAU,EAAuB,GAAGL,EAAKU,IAAI,2BAA2Bf,MAC3C,IAAZA,GACPU,EAAuBL,EAAKU,IAAI,uBAE7B,IAAMC,aAAaH,IAC3B,CAACb,IAEJY,EAAU,KACN,IAAIC,EAQJ,OANIV,IACAU,EAAUC,WAAW,KACjBV,GAAoB,GACpBH,EAnCqB,KADH,MAuCnB,IAAMe,aAAaH,IAC3B,CAACV,IAEJ,MAAMc,EAAwBC,EAC1BC,MAAOC,IACHA,EAAMC,iBAEN,IACIvB,IACAM,GAAoB,SACdG,GACV,CAAE,MAAOe,GAIL,GAHArB,EAAW,GACXG,GAAoB,IAEfmB,EAAYD,GAEb,YADAE,QAAQF,MAAMA,GAIlBzB,EAAQyB,EAAMG,OAClB,GAEJ,CAAClB,EAAyBV,EAASC,IAGvC,OAAIK,EAEIuB,EAACC,MAAAA,CAAIC,KAAK,QAAQC,UAAU,qDACvBxB,EAAKU,IAAI,sBACVW,EAACI,EAAAA,CAAKC,KAAM,GAAGC,mBAAyBC,OAAQ,GAAIC,MAAO,MAKnElC,EAAU,EAEN0B,EAACC,MAAAA,CAAIC,KAAK,QAAQC,UAAU,iDACvBxB,EAAKU,IAAI,sBAAsB,KAAG,IACnCW,EAACS,OAAAA,CAAKN,UAAU,+CAA8C,IAAE7B,EAAU,GAAK,GAAGA,KAAW,MAMrG0B,EAACU,EAAAA,CACGC,mBAAoB,CAACC,EAAW,kBAAmB,CAAE,4BAA6BvC,KAClFwC,QAAStB,EACTuB,QAAQ,OACRC,QAAQ,EACR1C,SAAUA,GAETM,EAAKU,IAAI"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import n from"../FormFields/Field/Field.js";import o from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as a}from"./validate.js";import{useCoreContext as s}from"../../../core/Context/CoreProvider.js";import{getFormattedData as l}from"./utils.js";import m from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import u from"../FormFields/InputText.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(r){c(e,r,t[r])})}return e}function d(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const b=["name","registrationNumber"];function f(c){const{label:b="",namePrefix:f,requiredFields:g,visibility:y}=c,{i18n:j}=s(),{handleChangeFor:O,triggerValidation:v,data:F,valid:h,errors:N,isValid:P}=m({schema:g,rules:p({},a,c.validationRules),defaultData:c.data}),w=r({});var C;Object.keys(w.current).length||(null===(C=c.setComponentRef)||void 0===C||C.call(c,w.current));w.current.showValidation=()=>{v()};const D=e=>`${f?`${f}.`:""}${e}`,k=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)},M=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)};return t(()=>{const e=l(F);c.onChange({data:e,valid:h,errors:N,isValid:P})},[F,h,N,P]),"hidden"===y?null:"readOnly"===y?e(o,d(p({},c),{data:F})):e(i,{classNameModifiers:[b],label:b},g.includes("name")&&e(n,{label:j.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!N.name,i18n:j,name:D("companyName")},e(u,{name:D("name"),value:F.name,classNameModifiers:["name"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1})),g.includes("registrationNumber")&&e(n,{label:j.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!N.registrationNumber,i18n:j,name:D("registrationNumber")},e(u,{name:D("registrationNumber"),value:F.registrationNumber,classNameModifiers:["registrationNumber"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1})))}f.defaultProps={data:{},onChange:()=>{},visibility:"editable",requiredFields:b,validationRules:a};export{b as COMPANY_DETAILS_SCHEMA,f as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import o from"../FormFields/Field/Field.js";import n from"./ReadOnlyCompanyDetails.js";import{companyDetailsValidationRules as a}from"./validate.js";import{useCoreContext as s}from"../../../core/Context/CoreProvider.js";import{getFormattedData as l}from"./utils.js";import m from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import u from"../FormFields/InputText.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(r){c(e,r,t[r])})}return e}function d(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}const b=["name","registrationNumber"];function f(c){const{label:b="",namePrefix:f,requiredFields:g,visibility:y}=c,{i18n:j}=s(),{handleChangeFor:O,triggerValidation:v,data:F,valid:h,errors:N,isValid:P}=m({schema:g,rules:p({},a,c.validationRules),defaultData:c.data}),w=r({});var C;Object.keys(w.current).length||(null===(C=c.setComponentRef)||void 0===C||C.call(c,w.current));w.current.showValidation=()=>{v()};const D=e=>`${f?`${f}.`:""}${e}`,k=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)},M=e=>r=>{const{name:t}=r.target,i=t.split(`${f}.`).pop();O(i,e)(r)};return t(()=>{const e=l(F);c.onChange({data:e,valid:h,errors:N,isValid:P})},[F,h,N,P]),"hidden"===y?null:"readOnly"===y?e(n,d(p({},c),{data:F})):e(i,{classNameModifiers:[b],label:b},g.includes("name")&&e(o,{label:j.get("companyDetails.name"),classNameModifiers:["name"],errorMessage:!!N.name,i18n:j,name:D("companyName")},e(u,{name:D("name"),value:F.name,classNameModifiers:["name"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1,autocomplete:"organization"})),g.includes("registrationNumber")&&e(o,{label:j.get("companyDetails.registrationNumber"),classNameModifiers:["registrationNumber"],errorMessage:!!N.registrationNumber,i18n:j,name:D("registrationNumber")},e(u,{name:D("registrationNumber"),value:F.registrationNumber,classNameModifiers:["registrationNumber"],onInput:M("input"),onBlur:k("blur"),spellcheck:!1,autocomplete:void 0})))}f.defaultProps={data:{},onChange:()=>{},visibility:"editable",requiredFields:b,validationRules:a};export{b as COMPANY_DETAILS_SCHEMA,f as default};
2
2
  //# sourceMappingURL=CompanyDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompanyDetails.js","sources":["../../../../../src/components/internal/CompanyDetails/CompanyDetails.tsx"],"sourcesContent":["import { h, FocusEventHandler, InputEventHandler } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyCompanyDetails from './ReadOnlyCompanyDetails';\nimport { companyDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { getFormattedData } from './utils';\nimport { CompanyDetailsSchema, CompanyDetailsProps } from './types';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\n\nexport const COMPANY_DETAILS_SCHEMA = ['name', 'registrationNumber'];\n\nexport default function CompanyDetails(props: Readonly<CompanyDetailsProps>) {\n const { label = '', namePrefix, requiredFields, visibility } = props;\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<CompanyDetailsSchema>({\n schema: requiredFields,\n rules: { ...companyDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const companyDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(companyDetailsRef.current).length) {\n props.setComponentRef?.(companyDetailsRef.current);\n }\n\n // Expose method expected by (parent) Address.tsx\n companyDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n const eventHandler =\n (mode: HandleChangeForModeType): FocusEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const inputEventHandler =\n (mode: HandleChangeForModeType): InputEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyCompanyDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label}>\n {requiredFields.includes('name') && (\n <Field\n label={i18n.get('companyDetails.name')}\n classNameModifiers={['name']}\n errorMessage={!!errors.name}\n i18n={i18n}\n name={generateFieldName('companyName')}\n >\n <InputText\n name={generateFieldName('name')}\n value={data.name}\n classNameModifiers={['name']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n\n {requiredFields.includes('registrationNumber') && (\n <Field\n label={i18n.get('companyDetails.registrationNumber')}\n classNameModifiers={['registrationNumber']}\n errorMessage={!!errors.registrationNumber}\n i18n={i18n}\n name={generateFieldName('registrationNumber')}\n >\n <InputText\n name={generateFieldName('registrationNumber')}\n value={data.registrationNumber}\n classNameModifiers={['registrationNumber']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n />\n </Field>\n )}\n </Fieldset>\n );\n}\n\nCompanyDetails.defaultProps = {\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: COMPANY_DETAILS_SCHEMA,\n validationRules: companyDetailsValidationRules\n};\n"],"names":["COMPANY_DETAILS_SCHEMA","CompanyDetails","props","label","namePrefix","requiredFields","visibility","i18n","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","companyDetailsValidationRules","validationRules","defaultData","companyDetailsRef","useRef","Object","keys","current","length","setComponentRef","showValidation","generateFieldName","name","eventHandler","mode","e","target","key","split","pop","inputEventHandler","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyCompanyDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","InputText","value","onInput","onBlur","spellcheck","registrationNumber","defaultProps"],"mappings":"u5CAcaA,EAAyB,CAAC,OAAQ,sBAEhC,SAASC,EAAeC,GACnC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,eAAEA,EAAcC,WAAEA,GAAeJ,GACzDK,KAAEA,GAASC,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA8B,CACvGC,OAAQX,EACRY,MAAOC,EAAA,CAAA,EAAKC,EAAkCjB,EAAMkB,iBACpDC,YAAanB,EAAMS,OAIjBW,EAAoBC,EAA4B,IAGlDrB,IAAAA,EADCsB,OAAOC,KAAKH,EAAkBI,SAASC,SACnB,QAArBzB,EAAAA,EAAM0B,2BAAN1B,GAAAA,EAAAA,KAAAA,EAAwBoB,EAAkBI,UAI9CJ,EAAkBI,QAAQG,eAAiB,KACvCnB,KAGJ,MAAMoB,EAAqBC,GAAyB,GAAG3B,EAAa,GAAGA,KAAgB,KAAK2B,IAEtFC,EACDC,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGjC,MAAekC,MAEzC7B,EAAgB2B,EAAKH,EAArBxB,CAA2ByB,IAG7BK,EACDN,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGjC,MAAekC,MAEzC7B,EAAgB2B,EAAKH,EAArBxB,CAA2ByB,IAQnC,OALAM,EAAU,KACN,MAAMC,EAAgBC,EAAiB/B,GACvCT,EAAMyC,SAAS,CAAEhC,KAAM8B,EAAe7B,QAAOC,SAAQC,aACtD,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAfR,EAAgC,KACjB,aAAfA,EAAkCsC,EAACC,EAAAA,EAAAA,EAAAA,GAA2B3C,GAAAA,CAAOS,KAAMA,KAG3EiC,EAACE,EAAAA,CAASC,mBAAoB,CAAC5C,GAAQA,MAAOA,GACzCE,EAAe2C,SAAS,SACrBJ,EAACK,EAAAA,CACG9C,MAAOI,EAAK2C,IAAI,uBAChBH,mBAAoB,CAAC,QACrBI,eAAgBtC,EAAOkB,KACvBxB,KAAMA,EACNwB,KAAMD,EAAkB,gBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,QACxBuB,MAAO1C,EAAKoB,KACZgB,mBAAoB,CAAC,QACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,KAKvBnD,EAAe2C,SAAS,uBACrBJ,EAACK,EAAAA,CACG9C,MAAOI,EAAK2C,IAAI,qCAChBH,mBAAoB,CAAC,sBACrBI,eAAgBtC,EAAO4C,mBACvBlD,KAAMA,EACNwB,KAAMD,EAAkB,uBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,sBACxBuB,MAAO1C,EAAK8C,mBACZV,mBAAoB,CAAC,sBACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,KAMpC,CAEAvD,EAAeyD,aAAe,CAC1B/C,KAAM,CAAA,EACNgC,SAAU,OACVrC,WAAY,WACZD,eAAgBL,EAChBoB,gBAAiBD"}
1
+ {"version":3,"file":"CompanyDetails.js","sources":["../../../../../src/components/internal/CompanyDetails/CompanyDetails.tsx"],"sourcesContent":["import { h, FocusEventHandler, InputEventHandler } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyCompanyDetails from './ReadOnlyCompanyDetails';\nimport { companyDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { getFormattedData } from './utils';\nimport { CompanyDetailsSchema, CompanyDetailsProps } from './types';\nimport useForm from '../../../utils/useForm';\nimport InputText from '../FormFields/InputText';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport { HandleChangeForModeType } from '../../../utils/useForm/types';\n\nexport const COMPANY_DETAILS_SCHEMA = ['name', 'registrationNumber'];\n\nexport default function CompanyDetails(props: Readonly<CompanyDetailsProps>) {\n const { label = '', namePrefix, requiredFields, visibility } = props;\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<CompanyDetailsSchema>({\n schema: requiredFields,\n rules: { ...companyDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const companyDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(companyDetailsRef.current).length) {\n props.setComponentRef?.(companyDetailsRef.current);\n }\n\n // Expose method expected by (parent) Address.tsx\n companyDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n const eventHandler =\n (mode: HandleChangeForModeType): FocusEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const inputEventHandler =\n (mode: HandleChangeForModeType): InputEventHandler<HTMLInputElement> =>\n (e): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyCompanyDetails {...props} data={data} />;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label}>\n {requiredFields.includes('name') && (\n <Field\n label={i18n.get('companyDetails.name')}\n classNameModifiers={['name']}\n errorMessage={!!errors.name}\n i18n={i18n}\n name={generateFieldName('companyName')}\n >\n <InputText\n name={generateFieldName('name')}\n value={data.name}\n classNameModifiers={['name']}\n onInput={inputEventHandler('input')}\n onBlur={eventHandler('blur')}\n spellcheck={false}\n 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","_object_spread","companyDetailsValidationRules","validationRules","defaultData","companyDetailsRef","useRef","Object","keys","current","length","setComponentRef","showValidation","generateFieldName","name","eventHandler","mode","e","target","key","split","pop","inputEventHandler","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyCompanyDetails","Fieldset","classNameModifiers","includes","Field","get","errorMessage","InputText","value","onInput","onBlur","spellcheck","autocomplete","registrationNumber","undefined","defaultProps"],"mappings":"u5CAcaA,EAAyB,CAAC,OAAQ,sBAEhC,SAASC,EAAeC,GACnC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,eAAEA,EAAcC,WAAEA,GAAeJ,GACzDK,KAAEA,GAASC,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA8B,CACvGC,OAAQX,EACRY,MAAOC,EAAA,CAAA,EAAKC,EAAkCjB,EAAMkB,iBACpDC,YAAanB,EAAMS,OAIjBW,EAAoBC,EAA4B,IAGlDrB,IAAAA,EADCsB,OAAOC,KAAKH,EAAkBI,SAASC,SACnB,QAArBzB,EAAAA,EAAM0B,2BAAN1B,GAAAA,EAAAA,KAAAA,EAAwBoB,EAAkBI,UAI9CJ,EAAkBI,QAAQG,eAAiB,KACvCnB,KAGJ,MAAMoB,EAAqBC,GAAyB,GAAG3B,EAAa,GAAGA,KAAgB,KAAK2B,IAEtFC,EACDC,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGjC,MAAekC,MAEzC7B,EAAgB2B,EAAKH,EAArBxB,CAA2ByB,IAG7BK,EACDN,GACAC,IACG,MAAMH,KAAEA,GAASG,EAAEC,OACbC,EAAML,EAAKM,MAAM,GAAGjC,MAAekC,MAEzC7B,EAAgB2B,EAAKH,EAArBxB,CAA2ByB,IAQnC,OALAM,EAAU,KACN,MAAMC,EAAgBC,EAAiB/B,GACvCT,EAAMyC,SAAS,CAAEhC,KAAM8B,EAAe7B,QAAOC,SAAQC,aACtD,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAfR,EAAgC,KACjB,aAAfA,EAAkCsC,EAACC,EAAAA,EAAAA,EAAAA,GAA2B3C,GAAAA,CAAOS,KAAMA,KAG3EiC,EAACE,EAAAA,CAASC,mBAAoB,CAAC5C,GAAQA,MAAOA,GACzCE,EAAe2C,SAAS,SACrBJ,EAACK,EAAAA,CACG9C,MAAOI,EAAK2C,IAAI,uBAChBH,mBAAoB,CAAC,QACrBI,eAAgBtC,EAAOkB,KACvBxB,KAAMA,EACNwB,KAAMD,EAAkB,gBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,QACxBuB,MAAO1C,EAAKoB,KACZgB,mBAAoB,CAAC,QACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,EACZC,aAAc,kBAKzBpD,EAAe2C,SAAS,uBACrBJ,EAACK,EAAAA,CACG9C,MAAOI,EAAK2C,IAAI,qCAChBH,mBAAoB,CAAC,sBACrBI,eAAgBtC,EAAO6C,mBACvBnD,KAAMA,EACNwB,KAAMD,EAAkB,uBAExBc,EAACQ,EAAAA,CACGrB,KAAMD,EAAkB,sBACxBuB,MAAO1C,EAAK+C,mBACZX,mBAAoB,CAAC,sBACrBO,QAASf,EAAkB,SAC3BgB,OAAQvB,EAAa,QACrBwB,YAAY,EACZC,kBAAcE,KAMtC,CAEA1D,EAAe2D,aAAe,CAC1BjD,KAAM,CAAA,EACNgC,SAAU,OACVrC,WAAY,WACZD,eAAgBL,EAChBoB,gBAAiBD"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import r from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as n,ARIA_CONTEXT_SUFFIX as o}from"../../../core/Errors/constants.js";function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,t){if(null==e)return{};var r,n,o={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}function c(c){let{setRef:u}=c,s=i(c,["setRef"]);const{autoCorrect:p,classNameModifiers:d,isInvalid:y,isValid:f,readonly:b=null,spellcheck:O,type:m,uniqueId:j,disabled:v}=s,h=s.className;Object.prototype.hasOwnProperty.call(s,"onChange")&&console.error("Error: Form fields that rely on InputBase may not have an onChange property");const g=t(e=>{s.onInput(e)},[s.onInput]),P=t(e=>{(null==s?void 0:s.onKeyPress)&&s.onKeyPress(e)},[null==s?void 0:s.onKeyPress]),w=t(e=>{(null==s?void 0:s.onKeyUp)&&s.onKeyUp(e)},[null==s?void 0:s.onKeyUp]),I=t(e=>{var t,r;null==s||null===(t=s.onBlurHandler)||void 0===t||t.call(s,e),s.trimOnBlur&&(e.target.value=e.target.value.trim()),null==s||null===(r=s.onBlur)||void 0===r||r.call(s,e)},[s.onBlur,s.onBlurHandler]),k=t(e=>{var t;null==s||null===(t=s.onFocusHandler)||void 0===t||t.call(s,e)},[s.onFocusHandler]),_=r("adyen-checkout__input",[`adyen-checkout__input--${m}`],h,{"adyen-checkout__input--invalid":y,"adyen-checkout__input--valid":f},d.map(e=>`adyen-checkout__input--${e}`)),{classNameModifiers:x,uniqueId:E,isInvalid:K,isValid:B,addContextualElement:C}=s,N=i(s,["classNameModifiers","uniqueId","isInvalid","isValid","addContextualElement"]);return e("input",a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){l(e,t,r[t])})}return e}({id:j},N),{"aria-required":N.required,type:m,className:_,readOnly:b,spellcheck:O,autoCorrect:p,"aria-describedby":`${j}${y?n:o}`,"aria-invalid":y,onInput:g,onBlur:I,onFocus:k,onKeyUp:w,onKeyPress:P,disabled:v,ref:u}))}c.defaultProps={type:"text",classNameModifiers:[]};export{c as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import r from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as n,ARIA_CONTEXT_SUFFIX as o}from"../../../core/Errors/constants.js";function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}if(l=function(e,t){if(null==e)return{};var r,n,o={},l=Object.getOwnPropertyNames(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}function c(c){let{setRef:u}=c,s=i(c,["setRef"]);const{autoCorrect:p,classNameModifiers:d,isInvalid:y,isValid:f,readonly:b=null,spellcheck:O,type:m,uniqueId:j,disabled:v}=s,h=s.className;Object.prototype.hasOwnProperty.call(s,"onChange")&&console.error("Error: Form fields that rely on InputBase may not have an onChange property");const g=t(e=>{s.onInput(e)},[s.onInput]),P=t(e=>{(null==s?void 0:s.onKeyPress)&&s.onKeyPress(e)},[null==s?void 0:s.onKeyPress]),w=t(e=>{(null==s?void 0:s.onKeyUp)&&s.onKeyUp(e)},[null==s?void 0:s.onKeyUp]),I=t(e=>{var t,r;null==s||null===(t=s.onBlurHandler)||void 0===t||t.call(s,e),s.trimOnBlur&&(e.target.value=e.target.value.trim()),null==s||null===(r=s.onBlur)||void 0===r||r.call(s,e)},[s.onBlur,s.onBlurHandler]),k=t(e=>{var t;null==s||null===(t=s.onFocusHandler)||void 0===t||t.call(s,e)},[s.onFocusHandler]),_=r("adyen-checkout__input",[`adyen-checkout__input--${m}`],h,{"adyen-checkout__input--invalid":y,"adyen-checkout__input--valid":f},d.map(e=>`adyen-checkout__input--${e}`)),{classNameModifiers:x,uniqueId:E,isInvalid:K,isValid:B,addContextualElement:C,autocomplete:N}=s,S=i(s,["classNameModifiers","uniqueId","isInvalid","isValid","addContextualElement","autocomplete"]);return e("input",a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){l(e,t,r[t])})}return e}({id:j},S),{autocomplete:N,"aria-required":S.required,type:m,className:_,readOnly:b,spellcheck:O,autoCorrect:p,"aria-describedby":`${j}${y?n:o}`,"aria-invalid":y,onInput:g,onBlur:I,onFocus:k,onKeyUp:w,onKeyPress:P,disabled:v,ref:u}))}c.defaultProps={type:"text",classNameModifiers:[]};export{c as default};
2
2
  //# sourceMappingURL=InputBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...restProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...restProps}\n aria-required={restProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'spellcheck'\n spellcheck={spellcheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","_0","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellcheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","restProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"03CAuCe,SAASA,EAAUC,OAAAC,OAAEA,GAA4CD,EAAjCE,EAAAA,EAAAA,EAAAA,YAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,EACfC,IACGnB,EAAMoB,QAAQD,IAElB,CAACnB,EAAMoB,UAULC,EAAiBH,EAClBC,KACOnB,aAAAA,EAAAA,EAAOsB,aAAYtB,EAAMsB,WAAWH,IAE5C,CAACnB,aAAAA,EAAAA,EAAOsB,aASNC,EAAcL,EACfC,KACOnB,aAAAA,EAAAA,EAAOwB,UAASxB,EAAMwB,QAAQL,IAEtC,CAACnB,aAAAA,EAAAA,EAAOwB,UAGNC,EAAaP,EACdC,QACGnB,EAMAA,EANAA,iBAAAA,EAAAA,EAAO0B,qBAAP1B,IAAAA,GAAAA,EAAAA,KAAAA,EAAuBmB,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,SAAa,QAAbA,EAAAA,EAAO+B,cAAP/B,IAAAA,GAAAA,OAAAA,EAAgBmB,IAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,EACfC,IACGnB,IAAAA,EAAAA,iBAAAA,EAAAA,EAAOiC,sBAAPjC,IAAAA,GAAAA,EAAAA,KAAAA,EAAwBmB,IAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B5B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBkC,IAAIC,GAAK,0BAA0BA,OAIlDnC,mBAAoBoC,EAAK9B,SAAU+B,EAAKpC,UAAWqC,EAAKpC,QAASqC,EAAIC,qBAAsBC,GAAsB3C,EAAd4C,EAAAA,EAAc5C,EAAAA,gFAEzH,OACI6C,EAACC,QAAAA,oUAAAA,CAAAA,CACGC,GAAIvC,GACAoC,GAAAA,CACJI,gBAAeJ,EAAUK,SACzB1C,KAAMA,EACNG,UAAWwB,EACXgB,SAAU7C,EAEVC,WAAYA,EACZL,YAAaA,EACbkD,mBAAkB,GAAG3C,IAAWL,EAAYiD,EAAoBC,IAChEC,eAAcnD,EACdiB,QAASH,EACTc,OAAQN,EACR8B,QAASvB,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACV+C,IAAKzD,IAGjB,CAEAF,EAAU4D,aAAe,CACrBlD,KAAM,OACNL,mBAAoB"}
1
+ {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport { AutocompleteValue } from './types';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n /**\n * WCAG 2.2 autocomplete token for browser autofill.\n * Pass undefined to omit the attribute entirely.\n * @see https://www.w3.org/TR/WCAG22/#input-purposes\n */\n autocomplete: AutocompleteValue;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, autocomplete, ...restProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...restProps}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'autocomplete'\n autocomplete={autocomplete}\n aria-required={restProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'spellcheck'\n spellcheck={spellcheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","_0","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellcheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","autocomplete","restProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"03CA8Ce,SAASA,EAAUC,OAAAC,OAAEA,GAA4CD,EAAjCE,EAAAA,EAAAA,EAAAA,YAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,EACfC,IACGnB,EAAMoB,QAAQD,IAElB,CAACnB,EAAMoB,UAULC,EAAiBH,EAClBC,KACOnB,aAAAA,EAAAA,EAAOsB,aAAYtB,EAAMsB,WAAWH,IAE5C,CAACnB,aAAAA,EAAAA,EAAOsB,aASNC,EAAcL,EACfC,KACOnB,aAAAA,EAAAA,EAAOwB,UAASxB,EAAMwB,QAAQL,IAEtC,CAACnB,aAAAA,EAAAA,EAAOwB,UAGNC,EAAaP,EACdC,QACGnB,EAMAA,EANAA,iBAAAA,EAAAA,EAAO0B,qBAAP1B,IAAAA,GAAAA,EAAAA,KAAAA,EAAuBmB,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,SAAa,QAAbA,EAAAA,EAAO+B,cAAP/B,IAAAA,GAAAA,OAAAA,EAAgBmB,IAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,EACfC,IACGnB,IAAAA,EAAAA,iBAAAA,EAAAA,EAAOiC,sBAAPjC,IAAAA,GAAAA,EAAAA,KAAAA,EAAwBmB,IAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B5B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBkC,IAAIC,GAAK,0BAA0BA,OAIlDnC,mBAAoBoC,EAAK9B,SAAU+B,EAAKpC,UAAWqC,EAAKpC,QAASqC,EAAIC,qBAAsBC,EAAGC,aAAEA,GAA+B5C,EAAd6C,EAAAA,EAAc7C,EAAAA,+FAEvI,OACI8C,EAACC,QAAAA,oUAAAA,CAAAA,CACGC,GAAIxC,GACAqC,GAAAA,CAEJD,aAAcA,EACdK,gBAAeJ,EAAUK,SACzB3C,KAAMA,EACNG,UAAWwB,EACXiB,SAAU9C,EAEVC,WAAYA,EACZL,YAAaA,EACbmD,mBAAkB,GAAG5C,IAAWL,EAAYkD,EAAoBC,IAChEC,eAAcpD,EACdiB,QAASH,EACTc,OAAQN,EACR+B,QAASxB,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACVgD,IAAK1D,IAGjB,CAEAF,EAAU6D,aAAe,CACrBnD,KAAM,OACNL,mBAAoB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../../../_virtual/index.js";import{getUniqueId as a}from"../../../../utils/idGenerator.js";import{useCoreContext as t}from"../../../../core/Context/CoreProvider.js";function o(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function n(n){const{items:i,name:c,onChange:l,value:u,isInvalid:d,uniqueId:s,ariaLabel:_,style:p="classic"}=n,{i18n:m}=t(),f=null==s?void 0:s.replace(/[0-9]/g,"").substring(0,s.lastIndexOf("-"));return e("div",function(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{},t=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),t.forEach(function(r){o(e,r,a[r])})}return e}({className:r(["adyen-checkout__radio_group",`adyen-checkout__radio_group--${p}`]),role:"radiogroup"},_&&{"aria-label":_}),i.map(t=>{const o=a(f);return e("div",{key:t.id,className:"adyen-checkout__radio_group__input-wrapper"},e("input",{id:o,type:"radio",checked:u===t.id,className:"adyen-checkout__radio_group__input",name:c,onChange:l,onClick:l,value:t.id}),e("label",{className:r(["adyen-checkout__label__text","adyen-checkout__radio_group__label",n.className,{"adyen-checkout__radio_group__label--invalid":d}]),htmlFor:o},m.get(t.name)))}))}n.defaultProps={onChange:()=>{},items:[]};export{n as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../../../_virtual/index.js";import{getUniqueId as t}from"../../../../utils/idGenerator.js";import{useCoreContext as a}from"../../../../core/Context/CoreProvider.js";function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(n){const{items:i,name:c,onChange:l,value:u,isInvalid:d,uniqueId:s,ariaLabel:_,style:p="classic"}=n,{i18n:m}=a(),f=null==s?void 0:s.replace(/[0-9]/g,"").substring(0,s.lastIndexOf("-"));return e("div",function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(r){o(e,r,t[r])})}return e}({className:r(["adyen-checkout__radio_group",`adyen-checkout__radio_group--${p}`]),role:"radiogroup"},_&&{"aria-label":_}),i.map(a=>{const o=t(f);return e("div",{key:a.id,className:"adyen-checkout__radio_group__input-wrapper"},e("input",{id:o,type:"radio",checked:u===a.id,className:"adyen-checkout__radio_group__input",name:c,onChange:l,onClick:l,value:a.id}),e("label",{className:r(["adyen-checkout__label__text","adyen-checkout__radio_group__label",n.className,{"adyen-checkout__radio_group__label--invalid":d}]),htmlFor:o},m.get(a.name)))}))}n.defaultProps={onChange:()=>{},items:[],autocomplete:void 0};export{n as default};
2
2
  //# sourceMappingURL=RadioGroup.js.map