@adyen/adyen-web 6.34.1 → 6.36.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 (220) hide show
  1. package/dist/cjs/adyen.css +7 -8
  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 +2649 -1958
  6. package/dist/es/adyen.css +7 -8
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -1
  9. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  10. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  13. package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
  14. package/dist/es/components/Card/components/CardInput/components/CardFields.js.map +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/CardNumber.js +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js +2 -0
  20. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -0
  21. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js +2 -0
  22. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js.map +1 -0
  23. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  24. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  25. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  26. package/dist/es/components/Card/constants.js.map +1 -1
  27. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  28. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  29. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  30. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  31. package/dist/es/components/Donation/Donation.js +1 -1
  32. package/dist/es/components/Donation/Donation.js.map +1 -1
  33. package/dist/es/components/Donation/DonationCampaignService.js +2 -0
  34. package/dist/es/components/Donation/DonationCampaignService.js.map +1 -0
  35. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  36. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  37. package/dist/es/components/Donation/components/utils.js.map +1 -1
  38. package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
  39. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  40. package/dist/es/components/Iris/Iris.js +1 -1
  41. package/dist/es/components/Iris/Iris.js.map +1 -1
  42. package/dist/es/components/Iris/types.js.map +1 -1
  43. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  44. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  45. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  46. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  47. package/dist/es/components/internal/Address/Address.js +1 -1
  48. package/dist/es/components/internal/Address/Address.js.map +1 -1
  49. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  50. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  51. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  54. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  55. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  56. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  57. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  58. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  59. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  60. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  61. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  62. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  63. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  64. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  65. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  69. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  70. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  71. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  72. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  73. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  74. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processBrand.js +1 -1
  75. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  76. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js +1 -1
  77. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  78. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  79. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  80. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  81. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  82. package/dist/es/components/internal/UIElement/utils.js +1 -1
  83. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  84. package/dist/es/core/Analytics/Analytics.js +1 -1
  85. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  86. package/dist/es/core/Analytics/AnalyticsService.js.map +1 -1
  87. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  88. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  89. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  90. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  91. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  92. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  93. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  94. package/dist/es/core/Services/sessions/constants.js +1 -1
  95. package/dist/es/core/Services/sessions/constants.js.map +1 -1
  96. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  97. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  98. package/dist/es/core/Services/sessions/make-donation.js +2 -0
  99. package/dist/es/core/Services/sessions/make-donation.js.map +1 -0
  100. package/dist/es/core/config.js +1 -1
  101. package/dist/es/core/config.js.map +1 -1
  102. package/dist/es/core/core.registry.js +1 -1
  103. package/dist/es/core/core.registry.js.map +1 -1
  104. package/dist/es/core/utils.js +1 -1
  105. package/dist/es/core/utils.js.map +1 -1
  106. package/dist/es/index.d.ts +2649 -1958
  107. package/dist/es/utils/createSdkData.js +1 -1
  108. package/dist/es/utils/createSdkData.js.map +1 -1
  109. package/dist/es-legacy/adyen.css +7 -8
  110. package/dist/es-legacy/adyen.css.map +1 -1
  111. package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -1
  112. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  113. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  114. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  115. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  116. package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
  117. package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js.map +1 -1
  118. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  119. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  120. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js +1 -1
  121. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  122. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js +2 -0
  123. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -0
  124. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js +2 -0
  125. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js.map +1 -0
  126. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  127. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  128. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  129. package/dist/es-legacy/components/Card/constants.js.map +1 -1
  130. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  131. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  133. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  134. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  135. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  136. package/dist/es-legacy/components/Donation/DonationCampaignService.js +2 -0
  137. package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -0
  138. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  139. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  140. package/dist/es-legacy/components/Donation/components/utils.js.map +1 -1
  141. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  142. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  143. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  144. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  145. package/dist/es-legacy/components/Iris/types.js.map +1 -1
  146. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  147. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  148. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  149. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  150. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  151. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  152. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  153. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  154. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  155. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  156. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  157. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  158. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  159. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  160. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  161. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  162. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  163. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  164. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  165. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  166. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  167. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  168. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  169. package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
  170. package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
  171. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  172. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  173. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  174. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  175. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  176. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  177. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processBrand.js +1 -1
  178. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  179. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js +1 -1
  180. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  181. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  182. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  183. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  184. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  185. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  186. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  187. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  188. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  189. package/dist/es-legacy/core/Analytics/AnalyticsService.js.map +1 -1
  190. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  191. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  192. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  193. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  194. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  195. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
  196. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  197. package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
  198. package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
  199. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  200. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  201. package/dist/es-legacy/core/Services/sessions/make-donation.js +2 -0
  202. package/dist/es-legacy/core/Services/sessions/make-donation.js.map +1 -0
  203. package/dist/es-legacy/core/config.js +1 -1
  204. package/dist/es-legacy/core/config.js.map +1 -1
  205. package/dist/es-legacy/core/core.registry.js +1 -1
  206. package/dist/es-legacy/core/core.registry.js.map +1 -1
  207. package/dist/es-legacy/core/utils.js +1 -1
  208. package/dist/es-legacy/core/utils.js.map +1 -1
  209. package/dist/es-legacy/utils/createSdkData.js +1 -1
  210. package/dist/es-legacy/utils/createSdkData.js.map +1 -1
  211. package/package.json +21 -21
  212. package/styles/adyen.css +7 -8
  213. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js +0 -2
  214. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js.map +0 -1
  215. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js +0 -2
  216. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +0 -1
  217. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js +0 -2
  218. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js.map +0 -1
  219. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js +0 -2
  220. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import e from"../../../../_virtual/index.js";import{createElement as t,Fragment as n,toChildArray as a,cloneElement as l}from"../../../../external/preact/dist/preact.js";import r from"../../Spinner/Spinner.js";import o from"../../Icon/Icon.js";import{ARIA_ERROR_SUFFIX as i,ARIA_CONTEXT_SUFFIX as c}from"../../../../core/Errors/constants.js";import{useRef as s,useMemo as d,useState as u,useCallback as p}from"../../../../external/preact/hooks/dist/hooks.js";import{getUniqueId as m}from"../../../../utils/idGenerator.js";import{PREFIX as f}from"../../Icon/constants.js";import h from"../../../../utils/uuid.js";function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){y(e,t,n[t])})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const k=y=>{const{children:k,className:v,classNameModifiers:j,dir:O,disabled:g,readOnly:x,errorMessage:w,helper:E,inputWrapperModifiers:N,isLoading:F,isValid:P,label:S,labelEndAdornment:$,name:I,onBlur:L,onFieldBlur:C,onFocus:A,onFocusField:M,showValidIcon:T,useLabelElement:V,showErrorElement:D,showContextualElement:q,staticValue:B,contextualText:H,filled:R,focused:W,i18n:z,contextVisibleToScreenReader:G,renderAlternativeToLabel:J,onInputContainerClick:K}=y,Q=null==G||G,U=D&&"string"==typeof w&&w.length>0,X=q&&!U&&(null==H?void 0:H.length)>0,Y=s(m(`adyen-checkout-${I}`)),Z=d(()=>B?`input-static-value-${h()}`:null,[B]),[ee,te]=u(!1),[ne,ae]=u(!1);null!=W&&te(!!W),null!=R&&ae(!!R);const le=p(e=>{te(!0),null==A||A(e)},[A]),re=p(e=>{te(!1),null==L||L(e),null==C||C(e)},[L,C]),oe=p(()=>t(n,null,"string"==typeof S&&t("span",{className:e({"adyen-checkout__label__text":!0,"adyen-checkout__label__text--error":w}),"data-id":I,"data-testid":I},S),"function"==typeof S&&S(),$&&t("span",{className:"adyen-checkout__label-adornment--end"},$),E&&t("span",{className:"adyen-checkout__helper-text"},E)),[S,w,$,E]),ie=p(()=>{const s=t("span",b(_({className:e({"adyen-checkout-contextual-text--error":!0,"adyen-checkout-contextual-text--hidden":!U})},Q&&{id:`${Y.current}${i}`}),{"aria-hidden":Q?null:"true"}),w),d=t("span",b(_({className:e({"adyen-checkout-contextual-text":!0,"adyen-checkout-contextual-text--hidden":!X})},Q&&{id:`${Y.current}${c}`}),{"aria-hidden":Q?null:"true"}),H);return t(n,null,t("div",{className:e(["adyen-checkout__input-wrapper",...N.map(e=>`adyen-checkout__input-wrapper--${e}`)]),dir:O,onClick:K},B&&t("span",{id:Z,className:"adyen-checkout__field-static-value"},B),a(k).map(e=>{const t=b(_({isValid:P,onFocusHandler:le,onBlurHandler:re,isInvalid:!!w,"aria-owns":Z},I&&{uniqueId:Y.current}),{showErrorElement:D});return l(e,t)}),F&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading"},t(r,{size:"small"})),P&&!1!==T&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid"},t(o,{type:`${f}checkmark_black`,alt:null==z?void 0:z.get("field.valid")})),w&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid"},t(o,{type:`${f}field_error`,alt:null==z?void 0:z.get("error.title")}))),s,d)},[k,w,H,F,P,le,re]),ce=p(({onFocusField:n,focused:a,filled:l,disabled:r,name:o,uniqueId:i,useLabelElement:c,isSecuredField:s,children:d,renderAlternativeToLabel:u})=>{const p={onClick:n,className:e({"adyen-checkout__label":!0,"adyen-checkout__label--focused":a,"adyen-checkout__label--filled":l,"adyen-checkout__label--disabled":r})};return c?t("label",_({},p,!s&&o&&{htmlFor:i}),d):u(p,d,i)},[]);return t("div",{"data-testid":"form-field",className:e("adyen-checkout__field",v,j.map(e=>`adyen-checkout__field--${e}`),{"adyen-checkout__field--error":w,"adyen-checkout__field--valid":P,"adyen-checkout__field--inactive":x||g})},t(ce,{onFocusField:M,name:I,disabled:g,filled:ne,focused:ee,useLabelElement:V,uniqueId:Y.current,isSecuredField:!Q,renderAlternativeToLabel:J},oe()),ie())};k.defaultProps={className:"",classNameModifiers:[],inputWrapperModifiers:[],useLabelElement:!0,showErrorElement:!0,showContextualElement:!0,renderAlternativeToLabel:()=>null};export{k as default};
1
+ import e from"../../../../_virtual/index.js";import{createElement as t,Fragment as n,toChildArray as a,cloneElement as l}from"../../../../external/preact/dist/preact.js";import r from"../../Spinner/Spinner.js";import o from"../../Icon/Icon.js";import{ARIA_ERROR_SUFFIX as i,ARIA_CONTEXT_SUFFIX as c}from"../../../../core/Errors/constants.js";import{useRef as s,useMemo as d,useState as u,useCallback as p}from"../../../../external/preact/hooks/dist/hooks.js";import{getUniqueId as m}from"../../../../utils/idGenerator.js";import{PREFIX as f}from"../../Icon/constants.js";import h from"../../../../utils/uuid.js";function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){y(e,t,n[t])})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}const k=y=>{const{children:k,className:v,classNameModifiers:j,dir:O,disabled:g,readOnly:x,errorMessage:w,helper:E,inputWrapperModifiers:N,isLoading:F,isValid:P,label:$,labelEndAdornment:S,name:I,onBlur:L,onFieldBlur:C,onFocus:A,onFocusField:M,showValidIcon:T,useLabelElement:V,showErrorElement:D,showContextualElement:q,staticValue:B,contextualText:H,filled:R,focused:W,i18n:z,contextVisibleToScreenReader:G,renderAlternativeToLabel:J,onInputContainerClick:K}=y,Q=null==G||G,U=D&&"string"==typeof w&&w.length>0,X=q&&!U&&H&&H.length>0,Y=s(m(`adyen-checkout-${I}`)),Z=d(()=>B?`input-static-value-${h()}`:null,[B]),[ee,te]=u(!1),[ne,ae]=u(!1);null!=W&&te(!!W),null!=R&&ae(!!R);const le=p(e=>{te(!0),null==A||A(e)},[A]),re=p(e=>{te(!1),null==L||L(e),null==C||C(e)},[L,C]),oe=p(()=>t(n,null,"string"==typeof $&&t("span",{className:e({"adyen-checkout__label__text":!0,"adyen-checkout__label__text--error":w}),"data-id":I,"data-testid":I},$),"function"==typeof $&&$(),S&&t("span",{className:"adyen-checkout__label-adornment--end"},S),E&&t("span",{className:"adyen-checkout__helper-text"},E)),[$,w,S,E]),ie=p(()=>{const s=t("span",b(_({className:e({"adyen-checkout-contextual-text--error":!0,"adyen-checkout-contextual-text--hidden":!U})},Q&&{id:`${Y.current}${i}`}),{"aria-hidden":Q?void 0:"true"}),w),d=t("span",b(_({className:e({"adyen-checkout-contextual-text":!0,"adyen-checkout-contextual-text--hidden":!X})},Q&&{id:`${Y.current}${c}`}),{"aria-hidden":Q?void 0:"true"}),H);return t(n,null,t("div",{className:e(["adyen-checkout__input-wrapper",...N.map(e=>`adyen-checkout__input-wrapper--${e}`)]),dir:O,onClick:K},B&&t("span",{id:Z,className:"adyen-checkout__field-static-value"},B),a(k).map(e=>{const t=b(_({isValid:P,onFocusHandler:le,onBlurHandler:re,isInvalid:!!w,"aria-owns":Z},I&&{uniqueId:Y.current}),{showErrorElement:D});return l(e,t)}),F&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading"},t(r,{size:"small"})),P&&!1!==T&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid"},t(o,{type:`${f}checkmark_black`,alt:null==z?void 0:z.get("field.valid")})),w&&t("span",{className:"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid"},t(o,{type:`${f}field_error`,alt:null==z?void 0:z.get("error.title")}))),s,d)},[k,w,H,F,P,le,re]),ce=p(({onFocusField:n,focused:a,filled:l,disabled:r,name:o,uniqueId:i,useLabelElement:c,isSecuredField:s,children:d,renderAlternativeToLabel:u})=>{const p={onClick:n,className:e({"adyen-checkout__label":!0,"adyen-checkout__label--focused":a,"adyen-checkout__label--filled":l,"adyen-checkout__label--disabled":r})};return c?t("label",_({},p,!s&&o&&{htmlFor:i,id:`${i}-label`}),d):u(p,d,i)},[]);return t("div",{"data-testid":"form-field",className:e("adyen-checkout__field",v,null==j?void 0:j.map(e=>`adyen-checkout__field--${e}`),{"adyen-checkout__field--error":w,"adyen-checkout__field--valid":P,"adyen-checkout__field--inactive":x||g})},t(ce,{onFocusField:M,name:I,disabled:g,filled:ne,focused:ee,useLabelElement:V,uniqueId:Y.current,isSecuredField:!Q,renderAlternativeToLabel:J},oe()),ie())};k.defaultProps={className:"",classNameModifiers:[],inputWrapperModifiers:[],useLabelElement:!0,showErrorElement:!0,showContextualElement:!0,renderAlternativeToLabel:()=>null};export{k as default};
2
2
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useMemo, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\nimport { PREFIX } from '../../Icon/constants';\nimport uuid from '../../../../utils/uuid';\n\nconst Field: FunctionalComponent<Readonly<FieldProps>> = props => {\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n staticValue,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel,\n onInputContainerClick\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText?.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const staticValueId = useMemo(() => (staticValue ? `input-static-value-${uuid()}` : null), [staticValue]);\n\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n data-testid={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n {/* The <div> element has a child <input> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n onClick={onInputContainerClick}\n >\n {staticValue && (\n <span id={staticValueId} className=\"adyen-checkout__field-static-value\">\n {staticValue}\n </span>\n )}\n\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const propsFromFieldComponent = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n 'aria-owns': staticValueId,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n\n return cloneElement(child as VNode, propsFromFieldComponent);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type={`${PREFIX}checkmark_black`} alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type={`${PREFIX}field_error`} alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n /**\n * Use cases:\n * - Not all form controls want/need a label e.g. many checkboxes describe what they are in their own markup and don't need the wrapping Field to also generate a labelling element\n * - securedFields *can't* have a label (screen-reader's can make the association, over different browser contexts, between the label and the input)\n */\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if we are NOT dealing with the label for a securedField... we can give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && name && { htmlFor: uniqueId })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n data-testid=\"form-field\"\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","staticValue","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","onInputContainerClick","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","staticValueId","useMemo","uuid","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","data-testid","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","onClick","toChildArray","child","propsFromFieldComponent","_object_spread_props","_object_spread","isInvalid","cloneElement","Spinner","size","Icon","type","PREFIX","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","htmlFor","defaultProps"],"mappings":"64CAYA,MAAMA,EAAmDC,IACrD,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBAChBA,EAAqBC,YACrBA,EAAWC,eACXA,EAEAC,OAAQC,EACRC,QAASC,EAAYC,KACrBA,EAAIC,6BACJA,EAA4BC,yBAC5BA,EAAwBC,sBACxBA,GACAhC,EAIEiC,EAAqBH,SAAAA,EACrBI,EAAYb,GAA4C,iBAAjBd,GAA6BA,EAAa4B,OAAS,EAC1FC,EAAcd,I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MAAAA,CACGT,cAAY,aACZtD,UAAWoD,EACP,wBACApD,EACAC,EAAmB+D,IAAIC,GAAK,0BAA0BA,KACtD,CACI,+BAAgC5D,EAChC,+BAAgCI,EAChC,kCAAmCL,GAAYD,KAIvD8C,EAACgC,GAAAA,CACGjE,aAAcA,EACdJ,KAAMA,EACNT,SAAUA,EACVoB,OAAQA,GACRE,QAASA,GACTP,gBAAiBA,EACjBiB,SAAUA,EAASuB,QACnBwB,gBAAiBnD,EACjBF,yBAA0BA,GAEzBmB,MAEJO,OAKb1D,EAAMwF,aAAe,CACjBrF,UAAW,GACXC,mBAAoB,GACpBM,sBAAuB,GACvBW,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBS,yBAA0B,IAAM"}
1
+ {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useMemo, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\nimport { PREFIX } from '../../Icon/constants';\nimport uuid from '../../../../utils/uuid';\n\nconst Field: FunctionalComponent<Readonly<FieldProps>> = props => {\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n staticValue,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel,\n onInputContainerClick\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText && contextualText.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const staticValueId = useMemo(() => (staticValue ? `input-static-value-${uuid()}` : null), [staticValue]);\n\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n data-testid={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? undefined : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n {/* The <div> element has a child <input> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n onClick={onInputContainerClick}\n >\n {staticValue && (\n <span id={staticValueId} className=\"adyen-checkout__field-static-value\">\n {staticValue}\n </span>\n )}\n\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const propsFromFieldComponent = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n 'aria-owns': staticValueId,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n\n return cloneElement(child as VNode, propsFromFieldComponent);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type={`${PREFIX}checkmark_black`} alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type={`${PREFIX}field_error`} alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n /**\n * Use cases:\n * - Not all form controls want/need a label e.g. many checkboxes describe what they are in their own markup and don't need the wrapping Field to also generate a labelling element\n * - securedFields *can't* have a label (screen-reader's can make the association, over different browser contexts, between the label and the input)\n */\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if we are NOT dealing with the label for a securedField... we can give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && name && { htmlFor: uniqueId, id: `${uniqueId}-label` })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n data-testid=\"form-field\"\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers?.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","staticValue","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","onInputContainerClick","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","staticValueId","useMemo","uuid","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","data-testid","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","undefined","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","onClick","toChildArray","child","propsFromFieldComponent","_object_spread_props","_object_spread","isInvalid","cloneElement","Spinner","size","Icon","type","PREFIX","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","htmlFor","defaultProps"],"mappings":"64CAYA,MAAMA,EAAmDC,IACrD,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBA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yBAAyB,EACzB,iCAAkC3B,EAClC,gCAAiCF,EACjC,kCAAmCpB,KAI3C,OAAOe,EAEH+B,EAACvC,QAAAA,EAAAA,CAAAA,EAAU0E,GAA2BD,GAAkBvE,GAAQ,CAAEyE,QAASlD,EAAUsB,GAAI,GAAGtB,YACvFpC,GAGL8B,EAAyBuD,EAAqBrF,EAAUoC,IAahE,IAMJ,OACIc,EAACe,MAAAA,CACGV,cAAY,aACZtD,UAAWoD,EACP,wBACApD,EACAC,eAAAA,EAAoBgE,IAAIC,GAAK,0BAA0BA,KACvD,CACI,+BAAgC7D,EAChC,+BAAgCI,EAChC,kCAAmCL,GAAYD,KAIvD8C,EAACiC,GAAAA,CACGlE,aAAcA,EACdJ,KAAMA,EACNT,SAAUA,EACVoB,OAAQA,GACRE,QAASA,GACTP,gBAAiBA,EACjBiB,SAAUA,EAASuB,QACnByB,gBAAiBpD,EACjBF,yBAA0BA,GAEzBmB,MAEJO,OAKb1D,EAAMyF,aAAe,CACjBtF,UAAW,GACXC,mBAAoB,GACpBM,sBAAuB,GACvBW,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBS,yBAA0B,IAAM"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import{getUniqueId as i}from"../../../../utils/idGenerator.js";import{useMemo as a}from"../../../../external/preact/hooks/dist/hooks.js";function d({children:d,classNameModifiers:o=[],classNamesFields:r=[],label:l,readonly:c=!1,description:n,id:m}){const{i18n:_}=s(),f=a(()=>i("fieldset-description"),[]);return e("fieldset",{id:m,className:t(["adyen-checkout__fieldset",...o.map(e=>`adyen-checkout__fieldset--${e}`),{"adyen-checkout__fieldset--readonly":c}]),"aria-describedby":n?f:null},l&&e("legend",{className:"adyen-checkout__fieldset__title"},_.get(l)),n&&e("p",{id:f,className:"adyen-checkout__fieldset__description"},_.get(n)),e("div",{className:t("adyen-checkout__fieldset__fields",r)},d))}export{d as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import{getUniqueId as i}from"../../../../utils/idGenerator.js";import{useMemo as a}from"../../../../external/preact/hooks/dist/hooks.js";function d({children:d,classNameModifiers:o=[],classNamesFields:r=[],label:l,readonly:c=!1,description:n,id:_,renderLabelAsSectionHeading:m=!1}){const{i18n:f}=s(),p=a(()=>i("fieldset-description"),[]);return e("fieldset",{id:_,className:t(["adyen-checkout__fieldset",...o.map(e=>`adyen-checkout__fieldset--${e}`),{"adyen-checkout__fieldset--readonly":c}]),"aria-describedby":n?p:null},l&&e("legend",{className:"adyen-checkout__fieldset__title"},m?e("h2",{className:"adyen-checkout__fieldset__title-heading"},f.get(l)):f.get(l)),n&&e("p",{id:p,className:"adyen-checkout__fieldset__description"},f.get(n)),e("div",{className:t("adyen-checkout__fieldset__fields",r)},d))}export{d as default};
2
2
  //# sourceMappingURL=Fieldset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Fieldset.js","sources":["../../../../../../src/components/internal/FormFields/Fieldset/Fieldset.tsx"],"sourcesContent":["import { h, ComponentChildren } from 'preact';\nimport cx from 'classnames';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './Fieldset.scss';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { useMemo } from 'preact/hooks';\n\ninterface FieldsetProps {\n children: ComponentChildren;\n classNameModifiers?: string[];\n classNamesFields?: string[];\n label?: string;\n description?: string;\n readonly?: boolean;\n id?: string;\n}\n\nexport default function Fieldset({\n children,\n classNameModifiers: classNameFieldsetModifiers = [],\n classNamesFields = [],\n label,\n readonly = false,\n description,\n id\n}: Readonly<FieldsetProps>) {\n const { i18n } = useCoreContext();\n\n const describedById = useMemo(() => getUniqueId('fieldset-description'), []);\n\n return (\n <fieldset\n id={id}\n className={cx([\n 'adyen-checkout__fieldset',\n ...classNameFieldsetModifiers.map(m => `adyen-checkout__fieldset--${m}`),\n { 'adyen-checkout__fieldset--readonly': readonly }\n ])}\n aria-describedby={description ? describedById : null}\n >\n {label && <legend className=\"adyen-checkout__fieldset__title\">{i18n.get(label)}</legend>}\n {description && (\n <p id={describedById} className=\"adyen-checkout__fieldset__description\">\n {i18n.get(description)}\n </p>\n )}\n <div className={cx('adyen-checkout__fieldset__fields', classNamesFields)}>{children}</div>\n </fieldset>\n );\n}\n"],"names":["Fieldset","children","classNameModifiers","classNameFieldsetModifiers","classNamesFields","label","readonly","description","id","i18n","useCoreContext","describedById","useMemo","getUniqueId","h","fieldset","className","cx","map","m","aria-describedby","legend","get","p","div"],"mappings":"2UAiBe,SAASA,GAASC,SAC7BA,EACAC,mBAAoBC,EAA6B,GAAEC,iBACnDA,EAAmB,GAAEC,MACrBA,EAAKC,SACLA,GAAW,EAAKC,YAChBA,EAAWC,GACXA,IAEA,MAAMC,KAAEA,GAASC,IAEXC,EAAgBC,EAAQ,IAAMC,EAAY,wBAAyB,IAEzE,OACIC,EAACC,WAAAA,CACGP,GAAIA,EACJQ,UAAWC,EAAG,CACV,8BACGd,EAA2Be,IAAIC,GAAK,6BAA6BA,KACpE,CAAE,qCAAsCb,KAE5Cc,mBAAkBb,EAAcI,EAAgB,MAE/CN,GAASS,EAACO,SAAAA,CAAOL,UAAU,mCAAmCP,EAAKa,IAAIjB,IACvEE,GACGO,EAACS,IAAAA,CAAEf,GAAIG,EAAeK,UAAU,yCAC3BP,EAAKa,IAAIf,IAGlBO,EAACU,MAAAA,CAAIR,UAAWC,EAAG,mCAAoCb,IAAoBH,GAGvF"}
1
+ {"version":3,"file":"Fieldset.js","sources":["../../../../../../src/components/internal/FormFields/Fieldset/Fieldset.tsx"],"sourcesContent":["import { h, ComponentChildren } from 'preact';\nimport cx from 'classnames';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './Fieldset.scss';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { useMemo } from 'preact/hooks';\n\ninterface FieldsetProps {\n children: ComponentChildren;\n classNameModifiers?: string[];\n classNamesFields?: string[];\n label?: string;\n description?: string;\n readonly?: boolean;\n id?: string;\n renderLabelAsSectionHeading?: boolean;\n}\n\nexport default function Fieldset({\n children,\n classNameModifiers: classNameFieldsetModifiers = [],\n classNamesFields = [],\n label,\n readonly = false,\n description,\n id,\n renderLabelAsSectionHeading = false\n}: Readonly<FieldsetProps>) {\n const { i18n } = useCoreContext();\n\n const describedById = useMemo(() => getUniqueId('fieldset-description'), []);\n\n return (\n <fieldset\n id={id}\n className={cx([\n 'adyen-checkout__fieldset',\n ...classNameFieldsetModifiers.map(m => `adyen-checkout__fieldset--${m}`),\n { 'adyen-checkout__fieldset--readonly': readonly }\n ])}\n aria-describedby={description ? describedById : null}\n >\n {label && (\n <legend className=\"adyen-checkout__fieldset__title\">\n {renderLabelAsSectionHeading ? <h2 className=\"adyen-checkout__fieldset__title-heading\">{i18n.get(label)}</h2> : i18n.get(label)}\n </legend>\n )}\n {description && (\n <p id={describedById} className=\"adyen-checkout__fieldset__description\">\n {i18n.get(description)}\n </p>\n )}\n <div className={cx('adyen-checkout__fieldset__fields', classNamesFields)}>{children}</div>\n </fieldset>\n );\n}\n"],"names":["Fieldset","children","classNameModifiers","classNameFieldsetModifiers","classNamesFields","label","readonly","description","id","renderLabelAsSectionHeading","i18n","useCoreContext","describedById","useMemo","getUniqueId","h","fieldset","className","cx","map","m","aria-describedby","legend","h2","get","p","div"],"mappings":"2UAkBe,SAASA,GAASC,SAC7BA,EACAC,mBAAoBC,EAA6B,GAAEC,iBACnDA,EAAmB,GAAEC,MACrBA,EAAKC,SACLA,GAAW,EAAKC,YAChBA,EAAWC,GACXA,EAAEC,4BACFA,GAA8B,IAE9B,MAAMC,KAAEA,GAASC,IAEXC,EAAgBC,EAAQ,IAAMC,EAAY,wBAAyB,IAEzE,OACIC,EAACC,WAAAA,CACGR,GAAIA,EACJS,UAAWC,EAAG,CACV,8BACGf,EAA2BgB,IAAIC,GAAK,6BAA6BA,KACpE,CAAE,qCAAsCd,KAE5Ce,mBAAkBd,EAAcK,EAAgB,MAE/CP,GACGU,EAACO,SAAAA,CAAOL,UAAU,mCACbR,EAA8BM,EAACQ,KAAAA,CAAGN,UAAU,2CAA2CP,EAAKc,IAAInB,IAAeK,EAAKc,IAAInB,IAGhIE,GACGQ,EAACU,IAAAA,CAAEjB,GAAII,EAAeK,UAAU,yCAC3BP,EAAKc,IAAIjB,IAGlBQ,EAACW,MAAAA,CAAIT,UAAWC,EAAG,mCAAoCd,IAAoBH,GAGvF"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import n from"../../../../../_virtual/index.js";import r from"../../../Img/Img.js";import{useMemo as o}from"../../../../../external/preact/hooks/dist/hooks.js";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){a(e,t,n[t])})}return e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(e,t){if(null==e)return{};var n,r,o,a={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(n=Reflect.ownKeys(Object(e)),o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}if(a=function(e,t){if(null==e)return{};var n,r,o={},a=Object.getOwnPropertyNames(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(n=Object.getOwnPropertySymbols(e),o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}function d(t){let{filterable:n,toggleButtonRef:r}=t,o=l(t,["filterable","toggleButtonRef"]);if(n){const{id:t}=o,n=l(o,["id"]);return e("div",i(c({},n),{ref:r}))}return e("button",i(c({id:o.id,"aria-expanded":o.showList,"aria-disabled":o.readonly,"aria-describedby":o.ariaDescribedBy,type:"button"},o),{ref:r}))}function u(a){const{active:c,selected:i,inputText:l,readonly:u,showList:s,required:p}=a,f=o(()=>{const e=i.selectedOptionName||i.name;return!0!==("string"==typeof e&&""!==e.trim())},[i,a.placeholder]),b=i.selectedOptionName||i.name||a.placeholder||"",y=s?l:b,_=u?null:a.filterable?e=>{e.preventDefault(),document.activeElement===a.filterInputRef.current?a.showList||a.toggleList(e):a.filterInputRef.current&&a.filterInputRef.current.focus()}:a.toggleList,m=c.id?`listItem-${c.id}`:"";return e(d,{className:n({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":u,"adyen-checkout__dropdown__button--active":s,"adyen-checkout__dropdown__button--invalid":a.isInvalid,"adyen-checkout__dropdown__button--valid":a.isValid,"adyen-checkout__dropdown__button--disabled":i.disabled}),disabled:a.disabled,filterable:a.filterable,onClick:_,onKeyDown:u?null:a.onButtonKeyDown,toggleButtonRef:a.toggleButtonRef,id:a.id},a.filterable?e(t,null,!s&&i.icon&&e(r,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":a.selectListId,"aria-expanded":s,"aria-owns":a.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:a.onInput,ref:a.filterInputRef,role:"combobox","aria-activedescendant":m,type:"text",readOnly:a.readonly,"aria-disabled":a.readonly,id:a.id,"aria-describedby":a.ariaDescribedBy,required:p}),!s&&i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)):e(t,null,i.icon&&e(r,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("span",{className:n("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":f})},b),i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)))}export{u as default};
1
+ import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import n from"../../../Img/Img.js";import{useMemo as r}from"../../../../../external/preact/hooks/dist/hooks.js";function a(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function i(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){a(e,t,o[t])})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function l(e,t){if(null==e)return{};var o,n,r,a={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(e)),r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var o,n,r={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)o=a[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o]);return r}(e,t),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}function d(t){let{filterable:o,toggleButtonRef:n,showList:r,selectListId:a}=t,d=l(t,["filterable","toggleButtonRef","showList","selectListId"]);if(o){const{id:t}=d,o=l(d,["id"]);return e("div",c(i({},o),{ref:n}))}return e("button",c(i({id:d.id,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":a,"aria-disabled":d.readonly,"aria-describedby":d.ariaDescribedBy,"aria-labelledby":d.id?`${d.id}-label ${d.id}-value`:void 0,type:"button"},d),{ref:n}))}function s(a){const{active:i,selected:c,inputText:l,readonly:s,showList:u,required:p}=a,b=r(()=>{const e=c.selectedOptionName||c.name;return!0!==("string"==typeof e&&""!==e.trim())},[c,a.placeholder]),f=c.selectedOptionName||c.name||a.placeholder||"",y=u?l:f,_=s?null:a.filterable?e=>{e.preventDefault(),document.activeElement===a.filterInputRef.current?a.showList||a.toggleList(e):a.filterInputRef.current&&a.filterInputRef.current.focus()}:a.toggleList,m=i.id?`listItem-${i.id}`:"";return e(d,{className:o({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":u,"adyen-checkout__dropdown__button--invalid":a.isInvalid,"adyen-checkout__dropdown__button--valid":a.isValid,"adyen-checkout__dropdown__button--disabled":c.disabled}),disabled:a.disabled,filterable:a.filterable,onClick:_,onKeyDown:s?null:a.onButtonKeyDown,toggleButtonRef:a.toggleButtonRef,id:a.id,showList:u,selectListId:a.selectListId},a.filterable?e(t,null,!u&&c.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:c.icon,alt:c.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":a.selectListId,"aria-expanded":u,"aria-owns":a.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:a.onInput,ref:a.filterInputRef,role:"combobox","aria-activedescendant":m,type:"text",readOnly:a.readonly,"aria-disabled":a.readonly,id:a.id,"aria-describedby":a.ariaDescribedBy,required:p}),!u&&c.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},c.secondaryText)):e(t,null,c.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:c.icon,alt:c.name}),e("span",{id:a.id?`${a.id}-value`:void 0,className:o("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":b})},f),c.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},c.secondaryText)))}export{s as default};
2
2
  //# sourceMappingURL=SelectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return <button id={props.id} aria-expanded={props.showList} aria-disabled={props.readonly} aria-describedby={props.ariaDescribedBy} type={'button'} {...props} ref={toggleButtonRef} />;\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","_0","filterable","toggleButtonRef","props","id","strippedProps","h","div","ref","button","aria-expanded","showList","aria-disabled","readonly","aria-describedby","ariaDescribedBy","type","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-controls","selectListId","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span","classnames"],"mappings":"8pDAOA,SAASA,EAAoBC,GAAA,IAAAC,WAAEA,EAAUC,gBAAEA,GAA2BF,EAAPG,EAAAA,EAAAA,EAAAA,kCAC3D,GAAIF,EAAY,CAEZ,MAAMG,GAAEA,GAAyBD,EAAlBE,EAAAA,EAAkBF,EAAAA,QACjC,OAAOG,EAACC,MAAAA,EAAAA,EAAAA,CAAAA,EAAQF,GAAAA,CAAeG,IAAKN,IACxC,CAEA,OAAOI,EAACG,SAAAA,EAAAA,EAAAA,CAAOL,GAAID,EAAMC,GAAIM,gBAAeP,EAAMQ,SAAUC,gBAAeT,EAAMU,SAAUC,mBAAkBX,EAAMY,gBAAiBC,KAAM,UAAcb,GAAAA,CAAOK,IAAKN,IACxK,CAEA,SAASe,EAAad,GAClB,MAAMe,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAASP,SAAEA,EAAQF,SAAEA,EAAQU,SAAEA,GAAalB,EAEhEmB,EAAuBC,EAAQ,KACjC,MAAM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EAAMC,GACVU,mBAAkBX,EAAMY,gBACxBM,SAAUA,KAEZV,GAAYQ,EAAS6C,eACnB1D,EAAC2D,OAAAA,CAAKzB,UAAU,oDAAoDrB,EAAS6C,gBAlCrF1D,EAAC0C,OACI7B,EAAS8B,MAAQ3C,EAAC4C,EAAAA,CAAIV,UAAU,yCAAyCW,IAAKhC,EAAS8B,KAAMG,IAAKjC,EAASO,OAC5GpB,EAAC2D,OAAAA,CACGzB,UAAW0B,EAAW,yCAA0C,CAC5D,qDAAsD5C,KAGzDE,GAEJL,EAAS6C,eAAiB1D,EAAC2D,OAAAA,CAAKzB,UAAU,oDAAoDrB,EAAS6C,gBA+B5H"}
1
+ {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, showList, selectListId, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return (\n <button\n id={props.id}\n aria-haspopup=\"listbox\"\n aria-expanded={showList}\n aria-controls={selectListId}\n aria-disabled={props.readonly}\n aria-describedby={props.ariaDescribedBy}\n aria-labelledby={props.id ? `${props.id}-label ${props.id}-value` : undefined}\n type={'button'}\n {...props}\n ref={toggleButtonRef}\n />\n );\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n showList={showList}\n selectListId={props.selectListId}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n id={props.id ? `${props.id}-value` : undefined}\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","_0","filterable","toggleButtonRef","showList","selectListId","props","id","strippedProps","h","div","ref","button","aria-haspopup","aria-expanded","aria-controls","aria-disabled","readonly","aria-describedby","ariaDescribedBy","aria-labelledby","undefined","type","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span","classnames"],"mappings":"8pDAOA,SAASA,EAAoBC,OAAAC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,aAAEA,GAAwBJ,EAAPK,EAAAA,EAAAA,EAAAA,4DACnF,GAAIJ,EAAY,CAEZ,MAAMK,GAAEA,GAAyBD,EAAlBE,EAAAA,EAAkBF,EAAAA,QACjC,OAAOG,EAACC,MAAAA,EAAAA,EAAAA,CAAAA,EAAQF,GAAAA,CAAeG,IAAKR,IACxC,CAEA,OACIM,EAACG,SAAAA,EAAAA,EAAAA,CACGL,GAAID,EAAMC,GACVM,gBAAc,UACdC,gBAAeV,EACfW,gBAAeV,EACfW,gBAAeV,EAAMW,SACrBC,mBAAkBZ,EAAMa,gBACxBC,k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AKjC,EAASO,OACzHvB,EAACkD,QAAAA,CACGC,MAAOzB,EACP0B,oBAAkB,OAClB9C,gBAAeT,EAAMD,aACrBS,gBAAeV,EACf0D,YAAWxD,EAAMD,aACjB0D,aAAa,MACbjB,UAAU,+BACVkB,QAAS1D,EAAM0D,QACfrD,IAAKL,EAAMmC,eACXwB,KAAK,WACLC,wBAAuBrB,EACvBvB,KAAK,OACL6C,SAAU7D,EAAMW,SAChBD,gBAAeV,EAAMW,SACrBV,GAAID,EAAMC,GACVW,mBAAkBZ,EAAMa,gBACxBQ,SAAUA,KAEZvB,GAAYqB,EAAS2C,eACnB3D,EAAC4D,OAAAA,CAAKvB,UAAU,oDAAoDrB,EAAS2C,gBAnCrF3D,EAAC6C,OACI7B,EAAS8B,MAAQ9C,EAAC+C,EAAAA,CAAIV,UAAU,yCAAyCW,IAAKhC,EAAS8B,KAAMG,IAAKjC,EAASO,OAC5GvB,EAAC4D,OAAAA,CACG9D,GAAID,EAAMC,GAAK,GAAGD,EAAMC,gBAAac,EACrCyB,UAAWwB,EAAW,yCAA0C,CAC5D,qDAAsD1C,KAGzDE,GAEJL,EAAS2C,eAAiB3D,EAAC4D,OAAAA,CAAKvB,UAAU,oDAAoDrB,EAAS2C,gBA+B5H"}
@@ -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"./IssuerButton.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({items:s=[],selectedIssuerId:i,onChange:a})=>{const{i18n:u}=o(),l=t(e=>{const t=e.currentTarget.value;Object.defineProperty(e.target,"value",{value:t}),a(e)},[a]);return e("div",{className:"adyen-checkout__issuer-button-group",role:"group","aria-label":u.get("issuerList.selectField.contextualText")},s.map(t=>e(r,c(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){n(e,t,r[t])})}return e}({key:t.id},t),{selected:i===t.id,onClick:l}))))};export{s 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"./IssuerButton.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}const s=({items:s=[],selectedIssuerId:i,onChange:a})=>{const{i18n:u}=o(),l=t(e=>{const t=e.currentTarget.value;Object.defineProperty(e.target,"value",{value:t}),a(e)},[a]);return e("fieldset",{className:"adyen-checkout__issuer-button-group","aria-label":u.get("issuerList.selectField.contextualText")},s.map(t=>e(r,c(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){n(e,t,r[t])})}return e}({key:t.id},t),{selected:i===t.id,onClick:l}))))};export{s as default};
2
2
  //# sourceMappingURL=IssuerButtonGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerButtonGroup.js","sources":["../../../../../../src/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport IssuerButton from './IssuerButton';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './IssuerButtonGroup.scss';\nimport { IssuerItem } from '../types';\n\ninterface IssuerButtonGroupProps {\n items: IssuerItem[];\n selectedIssuerId: string;\n onChange: (event: UIEvent) => void;\n}\n\nconst IssuerButtonGroup = ({ items = [], selectedIssuerId, onChange }: Readonly<IssuerButtonGroupProps>) => {\n const { i18n } = useCoreContext();\n\n const handleClick = useCallback(\n (event: UIEvent) => {\n const value = (event.currentTarget as HTMLButtonElement).value;\n Object.defineProperty(event.target, 'value', { value });\n onChange(event);\n },\n [onChange]\n );\n\n return (\n <div className=\"adyen-checkout__issuer-button-group\" role=\"group\" aria-label={i18n.get('issuerList.selectField.contextualText')}>\n {items.map(issuer => (\n <IssuerButton key={issuer.id} {...issuer} selected={selectedIssuerId === issuer.id} onClick={handleClick} />\n ))}\n </div>\n );\n};\n\nexport default IssuerButtonGroup;\n"],"names":["IssuerButtonGroup","items","selectedIssuerId","onChange","i18n","useCoreContext","handleClick","useCallback","event","value","currentTarget","Object","defineProperty","target","h","div","className","role","aria-label","get","map","issuer","IssuerButton","key","id","selected","onClick"],"mappings":"yuBAaA,MAAMA,EAAoB,EAAGC,QAAQ,GAAIC,mBAAkBC,eACvD,MAAMC,KAAEA,GAASC,IAEXC,EAAcC,EACfC,IACG,MAAMC,EAASD,EAAME,cAAoCD,MACzDE,OAAOC,eAAeJ,EAAMK,OAAQ,QAAS,CAAEJ,UAC/CN,EAASK,IAEb,CAACL,IAGL,OACIW,EAACC,MAAAA,CAAIC,UAAU,sCAAsCC,KAAK,QAAQC,aAAYd,EAAKe,IAAI,0CAClFlB,EAAMmB,IAAIC,GACPP,EAACQ,EAAAA,oUAAAA,CAAAA,CAAaC,IAAKF,EAAOG,IAAQH,GAAAA,CAAQI,SAAUvB,IAAqBmB,EAAOG,GAAIE,QAASpB"}
1
+ {"version":3,"file":"IssuerButtonGroup.js","sources":["../../../../../../src/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport IssuerButton from './IssuerButton';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport './IssuerButtonGroup.scss';\nimport { IssuerItem } from '../types';\n\ninterface IssuerButtonGroupProps {\n items: IssuerItem[];\n selectedIssuerId: string;\n onChange: (event: UIEvent) => void;\n}\n\nconst IssuerButtonGroup = ({ items = [], selectedIssuerId, onChange }: Readonly<IssuerButtonGroupProps>) => {\n const { i18n } = useCoreContext();\n\n const handleClick = useCallback(\n (event: UIEvent) => {\n const value = (event.currentTarget as HTMLButtonElement).value;\n Object.defineProperty(event.target, 'value', { value });\n onChange(event);\n },\n [onChange]\n );\n\n return (\n <fieldset className=\"adyen-checkout__issuer-button-group\" aria-label={i18n.get('issuerList.selectField.contextualText')}>\n {items.map(issuer => (\n <IssuerButton key={issuer.id} {...issuer} selected={selectedIssuerId === issuer.id} onClick={handleClick} />\n ))}\n </fieldset>\n );\n};\n\nexport default IssuerButtonGroup;\n"],"names":["IssuerButtonGroup","items","selectedIssuerId","onChange","i18n","useCoreContext","handleClick","useCallback","event","value","currentTarget","Object","defineProperty","target","h","fieldset","className","aria-label","get","map","issuer","IssuerButton","key","id","selected","onClick"],"mappings":"yuBAaA,MAAMA,EAAoB,EAAGC,QAAQ,GAAIC,mBAAkBC,eACvD,MAAMC,KAAEA,GAASC,IAEXC,EAAcC,EACfC,IACG,MAAMC,EAASD,EAAME,cAAoCD,MACzDE,OAAOC,eAAeJ,EAAMK,OAAQ,QAAS,CAAEJ,UAC/CN,EAASK,IAEb,CAACL,IAGL,OACIW,EAACC,WAAAA,CAASC,UAAU,sCAAsCC,aAAYb,EAAKc,IAAI,0CAC1EjB,EAAMkB,IAAIC,GACPN,EAACO,EAAAA,oUAAAA,CAAAA,CAAaC,IAAKF,EAAOG,IAAQH,GAAAA,CAAQI,SAAUtB,IAAqBkB,EAAOG,GAAIE,QAASnB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import l from"../FormFields/Field/Field.js";import a from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as p}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function x(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const C=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:k}=F,R=x(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=c(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=m(),Q=null==H?void 0:H({}),U=r(null);this.setStatus=e=>{$(e)};const W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:R.type,type:v.selected,target:s,issuer:r.name});R.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,R.type]),X=o(e=>{if(e){const e=new b({component:R.type,type:v.displayed,target:j.list});R.onSubmitAnalytics(e)}},[R.type,R.onSubmitAnalytics]),Y=r(y(R.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]);n(()=>{R.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===d&&J&&p(U.current,"issuer-list")},[N,B,D,K]),this.showValidation=()=>{L()};const{highlightedItems:ee}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!ee.length&&e(t,null,e(a,{selectedIssuerId:0===q?N.issuer:null,items:ee,onChange:W(0)}),e(u,null)),e(l,{label:null!=k?k:T.get("issuerList.selectField.label"),errorMessage:(te=D.issuer,te&&te.errorMessage?T.get(te.errorMessage):!!te),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),R.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(R.termsAndConditions.translationKey),urls:R.termsAndConditions.urls})),R.showPayButton&&R.payButton({status:G,label:C({issuer:N.issuer,items:[...I,...ee]},T)}));var te}F.defaultProps={onChange:()=>{}};export{F as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import l from"../FormFields/Field/Field.js";import a from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as p}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function C(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const x=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:R}=F,k=C(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=c(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=m(),Q=null==H?void 0:H({}),U=r(null),W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:k.type,type:v.selected,target:s,issuer:r.name});k.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,k.type]),X=o(e=>{if(e){const e=new b({component:k.type,type:v.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),Y=r(y(k.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]),ee=r({setStatus:$,showValidation:()=>{L()}});n(()=>{k.setComponentRef(ee.current)},[k.setComponentRef]),n(()=>{k.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===d&&J&&p(U.current,"issuer-list")},[N,B,D,K]);const{highlightedItems:te}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(a,{selectedIssuerId:0===q?N.issuer:null,items:te,onChange:W(0)}),e(u,null)),e(l,{label:null!=R?R:T.get("issuerList.selectField.label"),errorMessage:(se=D.issuer,se&&se.errorMessage?T.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.showPayButton&&k.payButton({status:G,label:x({issuer:N.issuer,items:[...I,...te]},T)}));var se}F.defaultProps={onChange:()=>{}};export{F as default};
2
2
  //# sourceMappingURL=IssuerList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: Readonly<IssuerListProps>) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_0","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","this","newStatus","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+vDAsBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAChBA,EAAKgB,YACLA,EAAWjB,OACXA,EAAMkB,eACNA,EAAiB,GAAEC,sBACnBA,EAAqBC,eACrBA,EAAcC,iBACdA,GAEwBL,EADrBM,EAAAA,EAAAA,EAAAA,+GAEH,MAAMpB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,MAAOtB,KAEJuB,EAAQC,GAAaC,EAAS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,EAAMgF,OAC/B,CAACC,EAAMC,KACCjE,EAAekE,SAASD,EAAK7E,KAAK4E,EAAKF,iBAAiBK,uUAAKC,CAAA,CAAA,EAAKH,IAC/DD,GAEX,CAAEF,iBAAkB,KAGxB,OACIO,EAACC,MAAAA,CAAIC,IAAK/C,EAAcgD,UAAU,iCAC3BV,GAAiBpE,QAChB2E,EAACI,OACGJ,EAACK,EAAAA,CACGC,iBAAkBzD,IAAAA,EAAiDV,EAAK,OAAY,KACpFzB,MAAO+E,GACPP,SAAU3B,EAAAA,KAEdyC,EAACO,SAITP,EAACQ,EAAAA,CACGC,MAAO3E,QAAAA,EAAoBnB,EAAKM,IAAI,gCACpCK,cAlFYoF,GAkFkBrE,EAAO5B,OAlFfiG,IAASA,GAAMpF,aAAeX,EAAKM,IAAIyF,GAAMpF,gBAAkBoF,IAmFrFC,mBAAoB,CAAC,eACrB3F,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhBmE,EAACY,EAAAA,CACGlG,MAAOA,EACPmG,cAAehE,IAAAA,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACNmF,UAAW,wCACXjB,SAAU3B,EAAAA,GACVuD,aAAcvC,EACdwC,QAASlC,KAIhB9C,EAAMiF,oBACHhB,EAACC,MAAAA,CAAIE,UAAU,mDACXH,EAACiB,EAAAA,CAAkBC,QAASvG,EAAKM,IAAIc,EAAMiF,mBAAmBG,gBAAiBC,KAAMrF,EAAMiF,mBAAmBI,QAIrHrF,EAAMsF,eACHtF,EAAMuF,UAAU,CACZ5E,SACA+D,MAAOjG,EAAe,CAAEC,OAAQ0B,EAAK,OAAWzB,MAAO,IAAIA,KAAU+E,KAAqB9E,MA7GlF+F,IAAAA,EAiH5B,CAEAlF,EAAW+F,aAAe,CACtBrC,SAAU"}
1
+ {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\n\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './IssuerList.scss';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: Readonly<IssuerListProps>) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n const issuerListRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(issuerListRef.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_0","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","issuerListRef","showValidation","useEffect","setComponentRef","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+vDAwBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAChBA,EAAKgB,YACLA,EAAWjB,OACXA,EAAMkB,eACNA,EAAiB,GAAEC,sBACnBA,EAAqBC,eACrBA,EAAcC,iBACdA,GAEwBL,EADrBM,EAAAA,EAAAA,EAAAA,+GAEH,MAAMpB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,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CRYPTED_EXPIRY_DATE as e,ENCRYPTED_EXPIRY_MONTH as r,ENCRYPTED_EXPIRY_YEAR as l,ENCRYPTED_SECURITY_CODE as i,CVC_POLICY_OPTIONAL as o,DATE_POLICY_OPTIONAL as t,CVC_POLICY_HIDDEN as c,DATE_POLICY_HIDDEN as s}from"../lib/constants.js";import{EMPTY_FIELD_ERROR_MESSAGES as d}from"../../../../core/Errors/constants.js";const a=e=>e?Array.prototype.slice.call(e.querySelectorAll('[data-cse*="encrypted"]')).map(e=>e.getAttribute("data-cse")):[],p=(i,o)=>(o===e?(i[r]=!1,i[l]=!1):i[o]=!1,i),y=(d,a)=>(p,y)=>{let n=!0!==a.valid[y]?((i,o)=>1!==o||i!==r&&i!==l?i:e)(y,d):null;return n=((e,r,l)=>{const{isFieldOfType:d,fieldIsValid:a}=l.reduce((l,i)=>(l.isFieldOfType||(l.isFieldOfType=e===i,l.fieldIsValid=!r.errors[i]),l),{isFieldOfType:!1,fieldIsValid:!1}),p=e===i?"cvcPolicy":"expiryDatePolicy",y="cvcPolicy"===p?o:t,n="cvcPolicy"===p?c:s;return(r[p]===y||r[p]===n)&&a&&d?null:e})(n,a,[i,e,r,l]),n&&!p.includes(n)&&p.push(n),p},n=(e,r,l)=>{var i;return{rootNode:r,fieldType:e,error:(null===(i=l.errors)||void 0===i?void 0:i[e])||d[e],type:"card"}};export{n as getErrorObject,y as getErrorReducer,a as getFields,p as validFieldsReducer};
1
+ import{ENCRYPTED_EXPIRY_DATE as e,ENCRYPTED_EXPIRY_MONTH as r,ENCRYPTED_EXPIRY_YEAR as l,ENCRYPTED_SECURITY_CODE as i,CVC_POLICY_OPTIONAL as o,DATE_POLICY_OPTIONAL as t,CVC_POLICY_HIDDEN as c,DATE_POLICY_HIDDEN as d}from"../lib/constants.js";import{EMPTY_FIELD_ERROR_MESSAGES as s}from"../../../../core/Errors/constants.js";const a=e=>e?Array.prototype.slice.call(e.querySelectorAll('[data-cse*="encrypted"]')).map(e=>e.getAttribute("data-cse")):[],n=(i,o)=>(o===e?(i[r]=!1,i[l]=!1):i[o]=!1,i),p=(s,a)=>(n,p)=>{let y=!0!==a.valid[p]?((i,o)=>1!==o||i!==r&&i!==l?i:e)(p,s):null;return y=((e,r,l)=>{const{isFieldOfType:s,fieldIsValid:a}=l.reduce((l,i)=>{var o;return l.isFieldOfType||(l.isFieldOfType=e===i,l.fieldIsValid=!(null===(o=r.errors)||void 0===o?void 0:o[i])),l},{isFieldOfType:!1,fieldIsValid:!1}),n=e===i?"cvcPolicy":"expiryDatePolicy",p="cvcPolicy"===n?o:t,y="cvcPolicy"===n?c:d;return(r[n]===p||r[n]===y)&&a&&s?null:e})(y,a,[i,e,r,l]),y&&!n.includes(y)&&n.push(y),n},y=(e,r,l)=>{var i;return{rootNode:r,fieldType:e,error:(null===(i=l.errors)||void 0===i?void 0:i[e])||s[e],type:"card"}};export{y as getErrorObject,p as getErrorReducer,a as getFields,n as validFieldsReducer};
2
2
  //# sourceMappingURL=SFPUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SFPUtils.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SFPUtils.ts"],"sourcesContent":["// ROUTINES USED IN SecuredFieldsProvider.componentDidMount TO DETECT & MAP FIELD NAMES ///////////\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE\n} from '../lib/constants';\nimport { EMPTY_FIELD_ERROR_MESSAGES } from '../../../../core/Errors/constants';\nimport type { SFPState } from './types';\n\n/**\n * Make an array of encrypted field names based on the value of the 'data-cse' attribute of elements in the rootNode\n */\nexport const getFields = rootNode => {\n if (rootNode) {\n return Array.prototype.slice.call(rootNode.querySelectorAll('[data-cse*=\"encrypted\"]')).map(f => f.getAttribute('data-cse'));\n }\n return [];\n};\n\n/**\n * If, visually, we're dealing with a single date field (expiryDate) we still need separate entries\n * for expiryMonth & expiryYear - since that is how the values will be delivered from securedFields\n */\nexport const validFieldsReducer = (acc, cur) => {\n if (cur === ENCRYPTED_EXPIRY_DATE) {\n acc[ENCRYPTED_EXPIRY_MONTH] = false;\n acc[ENCRYPTED_EXPIRY_YEAR] = false;\n } else {\n acc[cur] = false;\n }\n\n return acc;\n};\n// -- end ROUTINES USED IN SecuredFieldsProvider.componentDidMount --------------------------------\n\n// ROUTINES USED IN SecuredFieldsProvider.showValidation TO GENERATE ERRORS ///////////\n/**\n * If, visually, we're dealing with a single date field (expiryDate) remap the separate entries we have\n * for the valid states of expiryMonth & expiryYear back to the single key we use to an store an error\n * i.e `\"encryptedExpiryMonth\" & \"encryptedExpiryYear\" => \"encryptedExpiryDate\"`\n */\nconst mapDateFields = (field, numDateFields) => {\n const isDateField = field === ENCRYPTED_EXPIRY_MONTH || field === ENCRYPTED_EXPIRY_YEAR;\n return numDateFields === 1 && isDateField ? ENCRYPTED_EXPIRY_DATE : field;\n};\n\n/**\n * Skip generating an error for an optional field, unless it is already in error\n */\nconst skipOptionalFields = (field, state, fieldNames) => {\n // console.log('\\n### utils::skipOptionalField3:: examining field=', field);\n const { isFieldOfType, fieldIsValid } = fieldNames.reduce(\n (acc, fieldName) => {\n if (!acc.isFieldOfType) {\n // console.log('### utils:: fieldName:: ', fieldName, 'match=', field === fieldName);\n acc.isFieldOfType = field === fieldName;\n acc.fieldIsValid = !state.errors[fieldName];\n }\n return acc;\n },\n { isFieldOfType: false, fieldIsValid: false }\n );\n\n const policyType = field === ENCRYPTED_SECURITY_CODE ? 'cvcPolicy' : 'expiryDatePolicy';\n\n const policyOptional = policyType === 'cvcPolicy' ? CVC_POLICY_OPTIONAL : DATE_POLICY_OPTIONAL;\n const policyHidden = policyType === 'cvcPolicy' ? CVC_POLICY_HIDDEN : DATE_POLICY_HIDDEN;\n\n // if policy != required\n return (state[policyType] === policyOptional || state[policyType] === policyHidden) && fieldIsValid && isFieldOfType ? null : field;\n};\n\nexport const getErrorReducer = (numDateFields, state) => (acc, field) => {\n // We're only interested in the non-valid fields from the state.valid object...\n let val =\n state.valid[field] !== true\n ? mapDateFields(field, numDateFields) // Map the keys we use for the valid state to the key(s) we use for the error state\n : null;\n\n // Skip error generation for optional/hidden CVC & Date unless the fields are already in error\n val = skipOptionalFields(val, state, [ENCRYPTED_SECURITY_CODE, ENCRYPTED_EXPIRY_DATE, ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR]);\n\n // console.log('### utils:::: ############# val=', val);\n\n if (val && !acc.includes(val)) acc.push(val);\n\n return acc;\n};\n\n/**\n * Create an object suitable for sending to our handleOnError function\n */\nexport const getErrorObject = (fieldType: string, rootNode: HTMLElement, state: SFPState) => {\n // Get existing error OR field is empty in which case get field specific msg OR use default\n const error: string | undefined = state.errors?.[fieldType] || EMPTY_FIELD_ERROR_MESSAGES[fieldType];\n\n return {\n rootNode,\n fieldType,\n error,\n type: 'card'\n };\n};\n// -- end ROUTINES USED IN SecuredFieldsProvider.showValidation -----------------------\n"],"names":["getFields","rootNode","Array","prototype","slice","call","querySelectorAll","map","f","getAttribute","validFieldsReducer","acc","cur","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","getErrorReducer","numDateFields","state","field","val","valid","mapDateFields","fieldNames","isFieldOfType","fieldIsValid","reduce","fieldName","errors","policyType","ENCRYPTED_SECURITY_CODE","policyOptional","CVC_POLICY_OPTIONAL","DATE_POLICY_OPTIONAL","policyHidden","CVC_POLICY_HIDDEN","DATE_POLICY_HIDDEN","skipOptionalFields","includes","push","getErrorObject","fieldType","error","EMPTY_FIELD_ERROR_MESSAGES","type"],"mappings":"oUAiBO,MAAMA,EAAYC,GACjBA,EACOC,MAAMC,UAAUC,MAAMC,KAAKJ,EAASK,iBAAiB,4BAA4BC,IAAIC,GAAKA,EAAEC,aAAa,aAE7G,GAOEC,EAAqB,CAACC,EAAKC,KAChCA,IAAQC,GACRF,EAAIG,IAA0B,EAC9BH,EAAII,IAAyB,GAE7BJ,EAAIC,IAAO,EAGRD,GAyCEK,EAAkB,CAACC,EAAeC,IAAU,CAACP,EAAKQ,KAE3D,IAAIC,GACuB,IAAvBF,EAAMG,MAAMF,GAlCE,EAACA,EAAOF,IAED,IAAlBA,GADaE,IAAUL,GAA0BK,IAAUJ,EACEI,EAAxBN,EAiClCS,CAAcH,EAAOF,GACrB,KASV,OANAG,EA/BuB,EAACD,EAAOD,EAAOK,KAEtC,MAAMC,cAAEA,EAAaC,aAAEA,GAAiBF,EAAWG,OAC/C,CAACf,EAAKgB,KACGhB,EAAIa,gBAELb,EAAIa,cAAgBL,IAAUQ,EAC9BhB,EAAIc,cAAgBP,EAAMU,OAAOD,IAE9BhB,GAEX,CAAEa,eAAe,EAAOC,cAAc,IAGpCI,EAAaV,IAAUW,EAA0B,YAAc,mBAE/DC,EAAgC,cAAfF,EAA6BG,EAAsBC,EACpEC,EAA8B,cAAfL,EAA6BM,EAAoBC,EAGtE,OAAQlB,EAAMW,KAAgBE,GAAkBb,EAAMW,KAAgBK,IAAiBT,GAAgBD,EAAgB,KAAOL,GAWxHkB,CAAmBjB,EAAKF,EAAO,CAACY,EAAyBjB,EAAuBC,EAAwBC,IAI1GK,IAAQT,EAAI2B,SAASlB,IAAMT,EAAI4B,KAAKnB,GAEjCT,GAME6B,EAAiB,CAACC,EAAmBxC,EAAuBiB,KAEnCA,IAAAA,EAElC,MAAO,CACHjB,WACAwC,YACAC,OAL0C,QAAZxB,EAAAA,EAAMU,cAANV,IAAAA,OAAAA,EAAAA,EAAeuB,KAAcE,EAA2BF,GAMtFG,KAAM"}
1
+ {"version":3,"file":"SFPUtils.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SFPUtils.ts"],"sourcesContent":["// ROUTINES USED IN SecuredFieldsProvider.componentDidMount TO DETECT & MAP FIELD NAMES ///////////\nimport {\n CVC_POLICY_HIDDEN,\n CVC_POLICY_OPTIONAL,\n DATE_POLICY_HIDDEN,\n DATE_POLICY_OPTIONAL,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE\n} from '../lib/constants';\nimport { EMPTY_FIELD_ERROR_MESSAGES } from '../../../../core/Errors/constants';\nimport type { SFPState, SFPErrorMap, SFPValid } from './types';\n\n/**\n * Make an array of encrypted field names based on the value of the 'data-cse' attribute of elements in the rootNode\n */\nexport const getFields = (rootNode: HTMLElement) => {\n if (rootNode) {\n return Array.prototype.slice.call(rootNode.querySelectorAll('[data-cse*=\"encrypted\"]')).map((f: HTMLElement) => f.getAttribute('data-cse'));\n }\n return [];\n};\n\n/**\n * If, visually, we're dealing with a single date field (expiryDate) we still need separate entries\n * for expiryMonth & expiryYear - since that is how the values will be delivered from securedFields\n */\nexport const validFieldsReducer = (acc: Record<string, boolean>, cur: string): Record<string, boolean> => {\n if (cur === ENCRYPTED_EXPIRY_DATE) {\n acc[ENCRYPTED_EXPIRY_MONTH] = false;\n acc[ENCRYPTED_EXPIRY_YEAR] = false;\n } else {\n acc[cur] = false;\n }\n\n return acc;\n};\n// -- end ROUTINES USED IN SecuredFieldsProvider.componentDidMount --------------------------------\n\n// ROUTINES USED IN SecuredFieldsProvider.showValidation TO GENERATE ERRORS ///////////\n/**\n * If, visually, we're dealing with a single date field (expiryDate) remap the separate entries we have\n * for the valid states of expiryMonth & expiryYear back to the single key we use to an store an error\n * i.e `\"encryptedExpiryMonth\" & \"encryptedExpiryYear\" => \"encryptedExpiryDate\"`\n */\nconst mapDateFields = (field: string, numDateFields: number) => {\n const isDateField = field === ENCRYPTED_EXPIRY_MONTH || field === ENCRYPTED_EXPIRY_YEAR;\n return numDateFields === 1 && isDateField ? ENCRYPTED_EXPIRY_DATE : field;\n};\n\n/**\n * Skip generating an error for an optional field, unless it is already in error\n */\nconst skipOptionalFields = (field: string, state: SFPState, fieldNames: string[]) => {\n const { isFieldOfType, fieldIsValid } = fieldNames.reduce(\n (acc: { isFieldOfType: boolean; fieldIsValid: boolean }, fieldName: string) => {\n if (!acc.isFieldOfType) {\n // console.log('### utils:: fieldName:: ', fieldName, 'match=', field === fieldName);\n acc.isFieldOfType = field === fieldName;\n acc.fieldIsValid = !state.errors?.[fieldName as keyof SFPErrorMap];\n }\n return acc;\n },\n { isFieldOfType: false, fieldIsValid: false }\n );\n\n const policyType = field === ENCRYPTED_SECURITY_CODE ? 'cvcPolicy' : 'expiryDatePolicy';\n\n const policyOptional = policyType === 'cvcPolicy' ? CVC_POLICY_OPTIONAL : DATE_POLICY_OPTIONAL;\n const policyHidden = policyType === 'cvcPolicy' ? CVC_POLICY_HIDDEN : DATE_POLICY_HIDDEN;\n\n // if policy != required\n return (state[policyType] === policyOptional || state[policyType] === policyHidden) && fieldIsValid && isFieldOfType ? null : field;\n};\n\nexport const getErrorReducer = (numDateFields: number, state: SFPState) => (acc: string[], field: string) => {\n // We're only interested in the non-valid fields from the state.valid object...\n let val: string | null =\n state.valid[field as keyof SFPValid] !== true\n ? mapDateFields(field, numDateFields) // Map the keys we use for the valid state to the key(s) we use for the error state\n : null;\n\n // Skip error generation for optional/hidden CVC & Date unless the fields are already in error\n val = skipOptionalFields(val, state, [ENCRYPTED_SECURITY_CODE, ENCRYPTED_EXPIRY_DATE, ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR]);\n\n // console.log('### utils:::: ############# val=', val);\n\n if (val && !acc.includes(val)) acc.push(val);\n\n return acc;\n};\n\n/**\n * Create an object suitable for sending to our handleOnError function\n */\nexport const getErrorObject = (fieldType: string, rootNode: HTMLElement, state: SFPState) => {\n // Get existing error OR field is empty in which case get field specific msg OR use default\n const error: string | undefined =\n state.errors?.[fieldType as keyof SFPErrorMap] || EMPTY_FIELD_ERROR_MESSAGES[fieldType as keyof typeof EMPTY_FIELD_ERROR_MESSAGES];\n\n return {\n rootNode,\n fieldType,\n error,\n type: 'card'\n };\n};\n// -- end ROUTINES USED IN SecuredFieldsProvider.showValidation -----------------------\n"],"names":["getFields","rootNode","Array","prototype","slice","call","querySelectorAll","map","f","getAttribute","validFieldsReducer","acc","cur","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","getErrorReducer","numDateFields","state","field","val","valid","mapDateFields","fieldNames","isFieldOfType","fieldIsValid","reduce","fieldName","errors","policyType","ENCRYPTED_SECURITY_CODE","policyOptional","CVC_POLICY_OPTIONAL","DATE_POLICY_OPTIONAL","policyHidden","CVC_POLICY_HIDDEN","DATE_POLICY_HIDDEN","skipOptionalFields","includes","push","getErrorObject","fieldType","error","EMPTY_FIELD_ERROR_MESSAGES","type"],"mappings":"oUAiBO,MAAMA,EAAaC,GAClBA,EACOC,MAAMC,UAAUC,MAAMC,KAAKJ,EAASK,iBAAiB,4BAA4BC,IAAKC,GAAmBA,EAAEC,aAAa,aAE5H,GAOEC,EAAqB,CAACC,EAA8BC,KACzDA,IAAQC,GACRF,EAAIG,IAA0B,EAC9BH,EAAII,IAAyB,GAE7BJ,EAAIC,IAAO,EAGRD,GAwCEK,EAAkB,CAACC,EAAuBC,IAAoB,CAACP,EAAeQ,KAEvF,IAAIC,GACyC,IAAzCF,EAAMG,MAAMF,GAjCE,EAACA,EAAeF,IAET,IAAlBA,GADaE,IAAUL,GAA0BK,IAAUJ,EACEI,EAAxBN,EAgClCS,CAAcH,EAAOF,GACrB,KASV,OANAG,EA9BuB,EAACD,EAAeD,EAAiBK,KACxD,MAAMC,cAAEA,EAAaC,aAAEA,GAAiBF,EAAWG,OAC/C,CAACf,EAAwDgB,KAI7BT,IAAAA,EAExB,OALKP,EAAIa,gBAELb,EAAIa,cAAgBL,IAAUQ,EAC9BhB,EAAIc,eAA4B,QAAZP,EAAAA,EAAMU,cAANV,IAAAA,OAAAA,EAAAA,EAAeS,KAEhChB,GAEX,CAAEa,eAAe,EAAOC,cAAc,IAGpCI,EAAaV,IAAUW,EAA0B,YAAc,mBAE/DC,EAAgC,cAAfF,EAA6BG,EAAsBC,EACpEC,EAA8B,cAAfL,EAA6BM,EAAoBC,EAGtE,OAAQlB,EAAMW,KAAgBE,GAAkBb,EAAMW,KAAgBK,IAAiBT,GAAgBD,EAAgB,KAAOL,GAWxHkB,CAAmBjB,EAAKF,EAAO,CAACY,EAAyBjB,EAAuBC,EAAwBC,IAI1GK,IAAQT,EAAI2B,SAASlB,IAAMT,EAAI4B,KAAKnB,GAEjCT,GAME6B,EAAiB,CAACC,EAAmBxC,EAAuBiB,KAGjEA,IAAAA,EAEJ,MAAO,CACHjB,WACAwC,YACAC,OALY,QAAZxB,EAAAA,EAAMU,cAANV,IAAAA,OAAAA,EAAAA,EAAeuB,KAAmCE,EAA2BF,GAM7EG,KAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj,\n SFFieldType\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { TxVariants } from '../../../tx-variants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static readonly defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy();\n this.initializeCSF(this.rootNode);\n } else {\n if (this.props.componentType === TxVariants.customCard) {\n console.debug(\n 'You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a \"data-cse\" attribute e.g. <div data-cse=\"encryptedCardNumber\"></div>'\n );\n }\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n // Pass all the state data up - Used right now for loading status\n this.props.onStateUpdate?.(this.state);\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n componentType: this.props.componentType,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n onSubmitAnalytics: this.props.onSubmitAnalytics,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: null },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: SFFieldType): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType as SFFieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public getRootNode(): HTMLElement {\n return this.rootNode;\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: null },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","componentType","TxVariants","customCard","console","debug","handleOnNoDataRequired","componentDidUpdate","_this_props_onStateUpdate","_this_props","checkForKCPFields","onStateUpdate","call","state","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","_this_props_placeholders","loadingContext","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","onSubmitAnalytics","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","getRootNode","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"4/CAgCA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,QAAQC,IACXX,KAAKY,gBAAgBD,GAAS,IAIlCX,KAAKa,cAAgBT,EAAOU,OAAOC,GAAKA,EAAEC,MAAM,WAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,YAEpBF,KAAKC,MAAMmB,gBAAkBC,EAAWC,YACxCC,QAAQC,MACJ,yOAGRxB,KAAKyB,yBAEb,CAEOC,kBAAAA,OAGHC,EAAAC,EAFA5B,KAAK6B,oBAEmB,QAAxBF,GAAAC,EAAA5B,KAAKC,OAAM6B,qBAAX,IAAAH,GAAAA,EAAAI,KAAAH,EAA2B5B,KAAKgC,MACpC,CAEOC,oBAAAA,GACHjC,KAAKkC,IAAM,KACXC,aAAanC,KAAKoC,oBAClBD,aAAanC,KAAKqC,qBACtB,CAEQlB,aAAAA,CAAcmB,GA+CA,IAAAC,EA9ClB,IAAIC,EAAiBxC,KAAKC,M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B4F,KAAKxK,MACjEA,KAAK8E,iBAAmByF,EAASzF,iBAAiB0F,KAAKxK,MAEvDA,KAAKmJ,yBAA2BnJ,KAAKmJ,yBAAyBqB,KAAKxK,MAGnEA,KAAK0H,WAAa1H,KAAK0H,WAAW8C,KAAKxK,MACvCA,KAAK6H,aAAe7H,KAAK6H,aAAa2C,KAAKxK,MAC3CA,KAAKmH,sBAAwBnH,KAAKmH,sBAAsBqD,KAAKxK,MAC7DA,KAAKkI,eAAiBlI,KAAKkI,eAAesC,KAAKxK,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQsJ,KAAKxK,KACrC,EAEA+J,EAvEElK,EAuEqB4K,eAAeA"}
1
+ {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj,\n SFFieldType\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { TxVariants } from '../../../tx-variants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode: HTMLElement;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props: SFPProps;\n private issuingCountryCode: string;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static readonly defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy();\n this.initializeCSF(this.rootNode);\n } else {\n if (this.props.componentType === (TxVariants.customCard as string)) {\n console.debug(\n 'You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a \"data-cse\" attribute e.g. <div data-cse=\"encryptedCardNumber\"></div>'\n );\n }\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n // Pass all the state data up - Used right now for loading status\n this.props.onStateUpdate?.(this.state);\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n componentType: this.props.componentType,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n onSubmitAnalytics: this.props.onSubmitAnalytics,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: null },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: SFFieldType): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType as SFFieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public getRootNode(): HTMLElement {\n return this.rootNode;\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach((field: SFFieldType) => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: null },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state: SFPState) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","componentType","TxVariants","customCard","console","debug","handleOnNoDataRequired","componentDidUpdate","_this_props_onStateUpdate","_this_props","checkForKCPFields","onStateUpdate","call","state","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","_this_props_placeholders","loadingContext","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","onSubmitAnalytics","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","getRootNode","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"4/CAgCA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,QAAQC,IACXX,KAAKY,gBAAgBD,GAAS,IAIlCX,KAAKa,cAAgBT,EAAOU,OAAOC,GAAKA,EAAEC,MAAM,WAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,YAEpBF,KAAKC,MAAMmB,gBAAmBC,EAAWC,YACzCC,QAAQC,MACJ,yOAGRxB,KAAKyB,yBAEb,CAEOC,kBAAAA,OAGHC,EAAAC,EAFA5B,KAAK6B,oBAEmB,QAAxBF,GAAAC,EAAA5B,KAAKC,OAAM6B,qBAAX,IAAAH,GAAAA,EAAAI,KAAAH,EAA2B5B,KAAKgC,MACpC,CAEOC,oBAAAA,GACHjC,KAAKkC,IAAM,KACXC,aAAanC,KAAKoC,oBAClBD,aAAanC,KAAKqC,qBACtB,CAEQlB,aAAAA,CAAcmB,GA+CA,IAAAC,EA9ClB,IAAIC,EAAiBxC,KAAKC,MAAMuC,eAOhC,MAAMC,EAA8B,CAChCvC,SAAUoC,EACVI,KAAM1C,KAAKC,MAAMyC,KACjBtB,cAAepB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J,KAAKmJ,yBAAyBqB,KAAKxK,MAGnEA,KAAK0H,WAAa1H,KAAK0H,WAAW8C,KAAKxK,MACvCA,KAAK6H,aAAe7H,KAAK6H,aAAa2C,KAAKxK,MAC3CA,KAAKmH,sBAAwBnH,KAAKmH,sBAAsBqD,KAAKxK,MAC7DA,KAAKkI,eAAiBlI,KAAKkI,eAAesC,KAAKxK,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQsJ,KAAKxK,KACrC,EAEA+J,EAvEElK,EAuEqB4K,eAAeA"}
@@ -1,2 +1,2 @@
1
- import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";import{mustHandleDualBrandingAccordingToEURegulations as t}from"../../../Card/components/CardInput/utils.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as r}from"../../../Card/constants.js";function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}const s=(e,n)=>e.reduce((e,t)=>e||n.includes(t.brand),!1),u=e=>e.map(e=>function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(n){o(e,n,t[n])})}return e}({},e)),a=(e,n="mc",t="visa")=>{const r=u(e);return r[0].brand!==n&&r[0].brand!==t&&r.reverse(),r.length=1,r};function d(o,d,c,i={}){const{type:l,cvcPolicy:p}=o,{sfp:b}=d,{dualBrandSelectElements:g,setDualBrandSelectElements:f,setSelectedBrandValue:C,issuingCountryCode:B,setIssuingCountryCode:y}=c;return{processBinLookup:(o,d)=>{var c;const g=(null==o?void 0:o.issuingCountryCode)?o.issuingCountryCode.toLowerCase():null;if(y(g),!o||!Object.keys(o).length){f([]),C("");const e=d&&"card"!==l?l:null;return b.current.processBinLookupResponse(o,{brand:e,cvcPolicy:p}),void(i.current=0)}if(null===(c=o.supportedBrands)||void 0===c?void 0:c.length){const d=s(o.supportedBrands,n),c=d?a(o.supportedBrands):u(o.supportedBrands);if(c.length>1){const n=t(r,c,"brand"),s=e(c,n);f(s.dualBrandSelectElements),C(s.selectedBrandValue),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:[s.leadBrand]}),s.leadBrand.panLength>0&&(i.current=s.leadBrand.panLength)}else f([]),C(""),d||C(c[0].brand),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:c}),c[0].panLength>0&&(i.current=c[0].panLength)}},handleDualBrandSelection:e=>{let n=e;if(e instanceof Event){const t=e.target;n=t.getAttribute("data-value")||t.getAttribute("value")}let t=[];n&&(t=g.reduce((e,t)=>(t.brandObject.brand===n&&e.push(t.brandObject),e),[]),t.length&&(C(n),b.current.processBinLookupResponse({issuingCountryCode:B,supportedBrands:t,isDualBrandSelection:!0})))}}}export{u as cloneBrandsArr,s as containsExcludedBrand,d as default,a as removeExcludedBrand};
1
+ import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";import{requiresDualBrandSelection as r}from"../../../Card/components/CardInput/utils.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as t}from"../../../Card/constants.js";function o(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}const s=(e,n)=>e.reduce((e,r)=>e||n.includes(r.brand),!1),u=e=>e.map(e=>function(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.forEach(function(n){o(e,n,r[n])})}return e}({},e)),a=(e,n="mc",r="visa")=>{const t=u(e);return t[0].brand!==n&&t[0].brand!==r&&t.reverse(),t.length=1,t};function d(o,d,c,i={}){const{type:l,cvcPolicy:p}=o,{sfp:b}=d,{dualBrandSelectElements:g,setDualBrandSelectElements:C,setSelectedBrandValue:B,issuingCountryCode:f,setIssuingCountryCode:y}=c;return{processBinLookup:(o,d)=>{var c;const g=(null==o?void 0:o.issuingCountryCode)?o.issuingCountryCode.toLowerCase():null;if(y(g),!o||!Object.keys(o).length){C([]),B("");const e=d&&"card"!==l?l:null;return b.current.processBinLookupResponse(o,{brand:e,cvcPolicy:p}),void(i.current=0)}if(null===(c=o.supportedBrands)||void 0===c?void 0:c.length){const d=s(o.supportedBrands,n),c=d?a(o.supportedBrands):u(o.supportedBrands);if(c.length>1){const n=r(t,c,"brand"),s=e(c,n);C(s.dualBrandSelectElements),B(s.selectedBrandValue),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:[s.leadBrand]}),s.leadBrand.panLength>0&&(i.current=s.leadBrand.panLength)}else C([]),B(""),d||B(c[0].brand),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:c}),c[0].panLength>0&&(i.current=c[0].panLength)}},handleDualBrandSelection:e=>{let n=[];e&&(n=g.reduce((n,r)=>(r.brandObject.brand===e&&n.push(r.brandObject),n),[]),n.length&&(B(e),b.current.processBinLookupResponse({issuingCountryCode:f,supportedBrands:n,isDualBrandSelection:!0})))}}}export{u as cloneBrandsArr,s as containsExcludedBrand,d as default,a as removeExcludedBrand};
2
2
  //# sourceMappingURL=extensions.js.map