@adyen/adyen-web 6.41.1 → 6.42.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 (53) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +15 -2
  4. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  5. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  6. package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js +2 -0
  7. package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
  8. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  9. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  10. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  11. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  12. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  13. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  14. package/dist/es/components/ThreeDS2/constants.js +1 -1
  15. package/dist/es/components/ThreeDS2/constants.js.map +1 -1
  16. package/dist/es/components/internal/Address/Address.js +1 -1
  17. package/dist/es/components/internal/Address/Address.js.map +1 -1
  18. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  19. package/dist/es/components/internal/Address/validate.js +1 -1
  20. package/dist/es/components/internal/Address/validate.js.map +1 -1
  21. package/dist/es/components/internal/IFrame/Iframe.js +1 -1
  22. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  23. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  24. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  25. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  26. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  27. package/dist/es/core/config.js +1 -1
  28. package/dist/es/index.d.ts +15 -2
  29. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  30. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  31. package/dist/es-legacy/components/Dropin/utils/paymentMethodsAnalytics.js +2 -0
  32. package/dist/es-legacy/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
  33. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  34. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  35. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  36. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  37. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  38. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  39. package/dist/es-legacy/components/ThreeDS2/constants.js +1 -1
  40. package/dist/es-legacy/components/ThreeDS2/constants.js.map +1 -1
  41. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  42. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  43. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  44. package/dist/es-legacy/components/internal/Address/validate.js +1 -1
  45. package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
  46. package/dist/es-legacy/components/internal/IFrame/Iframe.js +1 -1
  47. package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
  48. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  49. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  50. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  51. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  52. package/dist/es-legacy/core/config.js +1 -1
  53. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\n }\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={dataWithCountry}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, effectiveCountry, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","data","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","country","effectiveCountry","toUpperCase","dataWithCountry","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"g8BAmBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAC5FQ,EAA2BC,EAAwBT,EAAMQ,YAAaL,GAGtEO,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCf,EAAMgB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAenB,EAAMiB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BAAsB"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\nexport default function Address(props: Readonly<AddressProps>) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n const addressType: AddressType = getAddressTypeFromLabel(props.addressType, label);\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n // In partial address mode the country field is not rendered, so it is absent from the address schema.\n // The country the merchant configured must still be part of the form data for country dependent rules to be applied.\n const merchantCountry = (props.data as AddressData)?.country;\n const formSchema = merchantCountry && !requiredFieldsSchema.includes(COUNTRY) ? [...requiredFieldsSchema, COUNTRY] : requiredFieldsSchema;\n const defaultData = useMemo<AddressData>(\n () => (merchantCountry ? { ...props.data, country: merchantCountry.toUpperCase() } : (props.data)),\n [props.data, merchantCountry]\n );\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: formSchema,\n defaultData,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = defaultData[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n addressType={addressType}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label, 'address']} label={label} renderLabelAsSectionHeading>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressType","getAddressTypeFromLabel","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","merchantCountry","data","country","formSchema","COUNTRY","defaultData","toUpperCase","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"68BAmBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAC5FQ,EAA2BC,EAAwBT,EAAMQ,YAAaL,GAGtEO,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCf,EAAMgB,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAenB,EAAMiB,gBAAiB,CAACjB,EAAMiB,iBAEhFG,EAAuBH,EAAeI,+BAA+BrB,EAAMsB,aAAaC,OAAOC,GAASpB,EAAeqB,SAASD,KA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AAgBgC,EAAW,SACpCuB,OAAQvD,EAAgBgC,EAAW,QACnCwB,iBAAkBxD,EAAgBgC,EAAW,QAC7C/D,eAAgBA,EAChBwF,UAAWC,EAA8BC,EAA2B3B,EAAWzC,EAAKC,SACpFoE,YAAY,EACZC,UAAWrC,GAAc/C,SAASuD,GAClCxE,YAAaA,EACbsG,sBAAuB9G,EAAM8G,sBAC7BC,qBAAsB/G,EAAM+G,uBApBY,KA+B9CC,GAAgB/F,EAAegG,2BAA2B1E,EAAKC,SAErE,OACIuD,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAAC/F,EAAO,WAAYA,MAAOA,EAAOiH,6BAAAA,GAC3DnF,GACG8D,EAACsB,EAAAA,CACGnF,gBAAiBlC,EAAMkC,gBACvBoF,kBAAmBtH,EAAMsH,kBACzBC,SAAU5D,GACVU,gBAAiBA,GACjBmD,qBAAsBzF,EACtB0F,iBAAkBpF,EAClB9B,sBAAuBA,EACvBmH,eAAgBzH,EAAKsE,IAAI,iCACzBoD,wBAAyB3H,EAAM2H,0BAGtCtF,GACG0D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIpG,GAAUA,aAAiBqG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwEvG,EAvB5EoG,IAAI,EAAEpG,EAAOwG,KAAU/B,GAAazE,EAAO,CAAE0E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAazE,EAAO,CAAA,MAK5H,CAEAzB,EAAQkI,aAAe,CACnB3G,YAAa,KACbkC,gBAAiB,KACjBjB,KAAM,CAAA,EACNuD,SAAU,OACVzF,WAAY,WACZD,eAAgB2D,EAChB9C,eAAgB,CAAA,EAChB6F,sBAAuB,OACvBC,qBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = (val: string) => val.replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"0FAIA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAgBX,GAAgBA,EAAIC,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oBACRI,UAAW,IAGnBwD,GAAI,CACAnD,WAAY,CACRT,OAAQ,WACRI,UAAW,IAGnByD,GAAI,CACApD,WAAY,CACRd,YAAaC,IACT,MAAM4B,EAAQ5B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYoB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAMzB,UAAU,EAAGK,IAE9BJ,OAAQ"}
1
+ {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { FormatterContext } from '../../../utils/Formatters/types';\nimport { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = (val: string) => val.replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val: string, context: FormatterContext) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"0FAKA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAgBX,GAAgBA,EAAIC,QAAQQ,EAAmB,IAExDG,EAAiC,CAC1CC,WAAY,CACRd,YAAa,CAACC,EAAac,KACvB,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWd,YACpE,OAAImB,EACOA,EAAalB,GAIjBA,IAGfoB,OAAQ,CACJrB,YAAaY,GAEjBU,kBAAmB,CACftB,YAAaY,GAEjBW,KAAM,CACFvB,YAAaY,IAORQ,EAAiD,CAC1DI,GAAI,CACAV,WAAYhB,EAAqB,IAErC2B,GAAI,CACAX,WAAYhB,EAAqB,IAErC4B,GAAI,CACAZ,WAAYhB,EAAqB,IAErC6B,GAAI,CACAb,WAAYhB,EAAqB,IAErC8B,GAAI,CACAd,WAAY,CAERd,YAAaC,IACT,MAAM4B,EAAQ5B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYoB,EAAMC,SAAS,KAAO,EAAI,EAC5C,OAAOD,EAAMzB,UAAU,EAAGK,IAE9BJ,OAAQ,wBACRI,UAAW,IAGnBsB,GAAI,CACAjB,WAAY,CACRT,OAAQ,oBACRI,UAAW,IAGnBuB,GAAI,CACAlB,WAAYhB,EAAqB,IAErCmC,GAAI,CACAnB,WAAYhB,EAAqB,IAErCoC,GAAI,CAC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IACtDM,EAAYoB,EAAMC,SAAS,KAAO,EAAI,EAC5C,OAAOD,EAAMzB,UAAU,EAAGK,IAE9BJ,OAAQ,kBACRI,UAAW,IAGnBkD,GAAI,CACA7C,WAAY,CACRd,YAAaC,GACKA,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IAC/CC,UAAU,EAAG,GAE9BC,OAAQ,WACRI,UAAW,IAGnBmD,GAAI,CACA9C,WAAYhB,EAAqB,IAErC+D,GAAI,CACA/C,WAAY,CACRT,OAAQ,kBACRI,UAAW,IAGnBqD,GAAI,CACAhD,WAAYhB,EAAqB,IAErCiE,GAAI,CACAjD,WAAYhB,EAAqB,IAErCkE,GAAI,CACAlD,WAAY,CACRT,OAAQ,oBACRI,UAAW,IAGnBwD,GAAI,CACAnD,WAAY,CACRT,OAAQ,WACRI,UAAW,IAGnByD,GAAI,CACApD,WAAY,CACRd,YAAaC,IACT,MAAM4B,EAAQ5B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYoB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAMzB,UAAU,EAAGK,IAE9BJ,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{countrySpecificFormatters as t}from"./validate.formats.js";import{ERROR_FIELD_REQUIRED as r,ERROR_INVALID_FORMAT_EXPECTS as e}from"../../../core/Errors/constants.js";import{isEmpty as a}from"../../../utils/validator-utils.js";const n=t=>({pattern:new RegExp(`\\d{${t}}`)}),o=(r,n,o)=>{if(n){if(a(r))return null;o.postalCode.errorMessage={translationKey:e,translationObject:{values:{format:t[n]?.postalCode.format||null}}};const d=s[n]?.pattern;return d?d.test(r):!!r}return!a(r)||null},s={AT:n(4),AU:n(4),BE:{pattern:/(?:(?:[1-9])(?:\d{3}))/},BG:n(4),BR:{pattern:/^\d{5}-?\d{3}$/},CA:{pattern:/(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/},CH:{pattern:/[1-9]\d{3}/},CY:n(4),CZ:{pattern:/\d{3}\s?\d{2}/},DE:n(5),DK:n(4),EE:n(5),ES:{pattern:/(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/},FI:n(5),FR:n(5),GB:{pattern:/^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/},GE:n(4),GR:{pattern:/^\d{3}\s{0,1}\d{2}$/},HR:{pattern:/^([1-5])[0-9]{4}$/},HU:n(4),IE:{pattern:/(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/},IS:n(3),IT:n(5),LI:n(4),LT:{pattern:/^(LT-\d{5}|\d{4,5})$/},LU:n(4),LV:{pattern:/^(LV-)[0-9]{4}$/},MC:{pattern:/^980\d{2}$/},MT:{pattern:/^[A-Za-z]{3}\d{4}$/},MY:n(5),NL:{pattern:/(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/},NO:n(4),PL:{pattern:/^\d{2}[-]{0,1}\d{3}$/},PT:{pattern:/^([1-9]\d{3})([- ]?(\d{3})? *)$/},RO:n(6),SI:n(4),SE:n(5),SG:n(6),SK:n(5),US:n(5)},d=t=>{const e={postalCode:{modes:["blur"],validate:r=>o(r,t,e),errorMessage:r}};return e},l=t=>{const e={postalCode:{modes:["blur"],validate:(t,r)=>{const a=r.state.data.country;return o(t,a,e)},errorMessage:r},houseNumberOrName:{validate:(r,e)=>{const n=e.state?.data?.country;return n&&t.countryHasOptionalField(n,"houseNumberOrName")||!a(r)||null},modes:["blur"],errorMessage:r},default:{validate:t=>!a(t)||null,modes:["blur"],errorMessage:r}};return e};export{l as getAddressValidationRules,d as getPartialAddressValidationRules,o as validatePostalCode};
1
+ import{countrySpecificFormatters as t}from"./validate.formats.js";import{ERROR_FIELD_REQUIRED as r,ERROR_INVALID_FORMAT_EXPECTS as e}from"../../../core/Errors/constants.js";import{isEmpty as a}from"../../../utils/validator-utils.js";const n=t=>({pattern:new RegExp(`\\d{${t}}`)}),o=(r,n,o)=>{if(n){if(a(r))return null;o.postalCode.errorMessage={translationKey:e,translationObject:{values:{format:t[n]?.postalCode.format||null}}};const d=s[n]?.pattern;return d?d.test(r):!!r}return!a(r)||null},s={AT:n(4),AU:n(4),BE:{pattern:/(?:(?:[1-9])(?:\d{3}))/},BG:n(4),BR:{pattern:/^\d{5}-?\d{3}$/},CA:{pattern:/(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/},CH:{pattern:/[1-9]\d{3}/},CY:n(4),CZ:{pattern:/\d{3}\s?\d{2}/},DE:n(5),DK:n(4),EE:n(5),ES:{pattern:/(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/},FI:n(5),FR:n(5),GB:{pattern:/^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/},GE:n(4),GR:{pattern:/^\d{3}\s{0,1}\d{2}$/},HR:{pattern:/^([1-5])[0-9]{4}$/},HU:n(4),IE:{pattern:/(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/},IS:n(3),IT:n(5),LI:n(4),LT:{pattern:/^(LT-\d{5}|\d{4,5})$/},LU:n(4),LV:{pattern:/^(LV-)[0-9]{4}$/},MC:{pattern:/^980\d{2}$/},MT:{pattern:/^[A-Za-z]{3}\d{4}$/},MY:n(5),NL:{pattern:/(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/},NO:n(4),PL:{pattern:/^\d{2}[-]{0,1}\d{3}$/},PT:{pattern:/^([1-9]\d{3})([- ]?(\d{3})? *)$/},RO:n(6),SI:n(4),SE:n(5),SG:n(6),SK:n(5),US:{pattern:/^\d{5}(?:-\d{4})?$/}},d=t=>{const e={postalCode:{modes:["blur"],validate:r=>o(r,t,e),errorMessage:r}};return e},l=t=>{const e={postalCode:{modes:["blur"],validate:(t,r)=>{const a=r.state.data.country;return o(t,a,e)},errorMessage:r},houseNumberOrName:{validate:(r,e)=>{const n=e.state?.data?.country;return n&&t.countryHasOptionalField(n,"houseNumberOrName")||!a(r)||null},modes:["blur"],errorMessage:r},default:{validate:t=>!a(t)||null,modes:["blur"],errorMessage:r}};return e};export{l as getAddressValidationRules,d as getPartialAddressValidationRules,o as validatePostalCode};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../../../core/Errors/constants';\nimport { isEmpty } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: createPatternByDigits(5)\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n houseNumberOrName: {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n default: {\n validate: value => (isEmpty(value) ? null : true), // true, if there are chars other than spaces\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","getAddressValidationRules","specifications","addressValidationRules","context","state","data","houseNumberOrName","value","selectedCountry","countryHasOptionalField","default"],"mappings":"yOAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,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,wBACfkD,GAAI,CAAElD,QAAS,mCACfmD,GAAIrD,EAAsB,GAC1BsD,GAAItD,EAAsB,GAC1BuD,GAAIvD,EAAsB,GAC1BwD,GAAIxD,EAAsB,GAC1ByD,GAAIzD,EAAsB,GAC1B0D,GAAI1D,EAAsB,IASjB2D,EAAoCC,IAC7C,MAAMC,EAAkC,CACpCpD,WAAY,CACRqD,MAAO,CAAC,QACRC,SAAU1D,GACCD,EAAmBC,EAAKuD,EAASC,GAE5CnD,aAAcsD,IAGtB,OAAOH,GAGEI,EAA6BC,IACtC,MAAMC,EAAyC,CAC3C1D,WAAY,CACRqD,MAAO,CAAC,QACRC,SAAU,CAAC1D,EAAK+D,KACZ,MAAMR,EAAUQ,EAAQC,MAAMC,KAAKV,QACnC,OAAOxD,EAAmBC,EAAKuD,EAASO,IAE5CzD,aAAcsD,GAElBO,kBAAmB,CACfR,SAAU,CAACS,EAAOJ,KACd,MAAMK,EAAkBL,EAAQC,OAAOC,MAAMV,QAE7C,OADmBa,GAAmBP,EAAeQ,wBAAwBD,EAAiB,uBACxEjE,EAAQgE,IAAS,MAE3CV,MAAO,CAAC,QACRpD,aAAcsD,GAElBW,QAAS,CACLZ,SAAUS,IAAUhE,EAAQgE,IAAS,KACrCV,MAAO,CAAC,QACRpD,aAAcsD,IAGtB,OAAOG"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS } from '../../../core/Errors/constants';\nimport { isEmpty } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n houseNumberOrName: {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n default: {\n validate: value => (isEmpty(value) ? null : true), // true, if there are chars other than spaces\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","getAddressValidationRules","specifications","addressValidationRules","context","state","data","houseNumberOrName","value","selectedCountry","countryHasOptionalField","default"],"mappings":"yOAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,EAAqBC,KACjE,GAAID,EAAa,CAEb,GAAIE,EAAQH,GAAM,OAAO,KAGxBE,EAAeE,WAA6BC,aAAe,CACxDC,eAAgBC,EAChBC,kBAAmB,CACfC,OAAQ,CACJC,OAAQC,EAA0BV,IAAcG,WAAWM,QAAU,QAKjF,MAAMb,EAAUe,EAAmBX,IAAcJ,QACjD,OAAOA,EAAUA,EAAQgB,KAAKb,KAASA,CAC3C,CAEA,OAAOG,EAAQH,IAAO,MAGpBY,EAAqB,CACvBE,GAAInB,EAAsB,GAC1BoB,GAAIpB,EAAsB,GAC1BqB,GAAI,CAAEnB,QAAS,0BACfoB,GAAItB,EAAsB,GAC1BuB,GAAI,CAAErB,QAAS,kBACfsB,GAAI,CAAEtB,QAAS,+CACfuB,GAAI,CAAEvB,QAAS,cACfwB,GAAI1B,EAAsB,GAC1B2B,GAAI,CAAEzB,QAAS,iBACf0B,GAAI5B,EAAsB,GAC1B6B,GAAI7B,EAAsB,GAC1B8B,GAAI9B,EAAsB,GAC1B+B,GAAI,CAAE7B,QAAS,kCACf8B,GAAIhC,EAAsB,GAC1BiC,GAAIjC,EAAsB,GAC1BkC,GAAI,CAAEhC,QAAS,yFACfiC,GAAInC,EAAsB,GAC1BoC,GAAI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AAOG"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as i}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";function a(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}class n extends e{iframeOnLoad(){this.props.callback&&"function"==typeof this.props.callback&&this.props.callback(this.iframeEl.contentWindow)}componentDidMount(){this.iframeEl.addEventListener?this.iframeEl.addEventListener("load",this.iframeOnLoad.bind(this),!1):this.iframeEl.attachEvent?this.iframeEl.attachEvent("onload",this.iframeOnLoad.bind(this)):this.iframeEl.onload=this.iframeOnLoad.bind(this)}componentWillUnmount(){this.iframeEl.removeEventListener?this.iframeEl.removeEventListener("load",this.iframeOnLoad.bind(this),!1):this.iframeEl.detachEvent?this.iframeEl.detachEvent("onload",this.iframeOnLoad.bind(this)):this.iframeEl.onload=null}render({name:e,src:a,width:n,height:r,minWidth:o,minHeight:l,allow:s,title:h,classNameModifiers:m}){const d=m.filter(e=>!!e);return i("iframe",{ref:e=>{this.iframeEl=e},allow:s,className:t("adyen-checkout__iframe",`adyen-checkout__iframe--${e}`,d.length&&m.map(i=>`adyen-checkout__iframe--${e}-${i}`)),name:e,src:a,width:n,height:r,frameBorder:"0",title:h,referrerpolicy:"origin","min-width":o,"min-height":l})}constructor(...e){super(...e),a(this,"iframeEl",void 0)}}a(n,"defaultProps",{width:"0",height:"0",minWidth:"0",minHeight:"0",src:null,allow:null,title:"components iframe",classNameModifiers:[]});export{n as default};
1
+ import{Component as e,createElement as i}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";function a(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}class n extends e{iframeOnLoad(){this.props.callback&&"function"==typeof this.props.callback&&this.props.callback(this.iframeEl.contentWindow)}componentDidMount(){this.iframeEl.addEventListener?this.iframeEl.addEventListener("load",this.iframeOnLoad.bind(this),!1):this.iframeEl.attachEvent?this.iframeEl.attachEvent("onload",this.iframeOnLoad.bind(this)):this.iframeEl.onload=this.iframeOnLoad.bind(this)}componentWillUnmount(){this.iframeEl.removeEventListener?this.iframeEl.removeEventListener("load",this.iframeOnLoad.bind(this),!1):this.iframeEl.detachEvent?this.iframeEl.detachEvent("onload",this.iframeOnLoad.bind(this)):this.iframeEl.onload=null}render({name:e,src:a,width:n,height:r,minWidth:o,minHeight:s,allow:l,title:h,sandbox:m,classNameModifiers:d}){const f=d.filter(e=>!!e);return i("iframe",{ref:e=>{this.iframeEl=e},allow:l,className:t("adyen-checkout__iframe",`adyen-checkout__iframe--${e}`,f.length&&d.map(i=>`adyen-checkout__iframe--${e}-${i}`)),name:e,src:a,width:n,height:r,frameBorder:"0",title:h,referrerpolicy:"origin","min-width":o,"min-height":s,sandbox:m})}constructor(...e){super(...e),a(this,"iframeEl",void 0)}}a(n,"defaultProps",{width:"0",height:"0",minWidth:"0",minHeight:"0",src:null,allow:null,title:"components iframe",classNameModifiers:[]});export{n as default};
2
2
  //# sourceMappingURL=Iframe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Iframe.js","sources":["../../../../../src/components/internal/IFrame/Iframe.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport './Iframe.scss';\n\ninterface IframeProps {\n width?: string;\n height?: string;\n minWidth?: string;\n minHeight?: string;\n border?: string;\n src?: string;\n allow?: string;\n name?: string;\n title?: string;\n classNameModifiers?: string[];\n callback?: (contentWindow) => void;\n}\n\nclass Iframe extends Component<Readonly<IframeProps>> {\n public static readonly defaultProps = {\n width: '0',\n height: '0',\n minWidth: '0',\n minHeight: '0',\n src: null,\n allow: null,\n title: 'components iframe',\n classNameModifiers: []\n };\n\n private iframeEl;\n\n iframeOnLoad() {\n if (this.props.callback && typeof this.props.callback === 'function') {\n this.props.callback(this.iframeEl.contentWindow);\n }\n }\n\n componentDidMount() {\n if (this.iframeEl.addEventListener) {\n this.iframeEl.addEventListener('load', this.iframeOnLoad.bind(this), false);\n } else if (this.iframeEl.attachEvent) {\n // IE fallback\n this.iframeEl.attachEvent('onload', this.iframeOnLoad.bind(this));\n } else {\n this.iframeEl.onload = this.iframeOnLoad.bind(this);\n }\n }\n\n componentWillUnmount() {\n if (this.iframeEl.removeEventListener) {\n this.iframeEl.removeEventListener('load', this.iframeOnLoad.bind(this), false);\n } else if (this.iframeEl.detachEvent) {\n // IE fallback\n this.iframeEl.detachEvent('onload', this.iframeOnLoad.bind(this));\n } else {\n this.iframeEl.onload = null;\n }\n }\n\n render({ name, src, width, height, minWidth, minHeight, allow, title, classNameModifiers }: IframeProps) {\n const validClassNameModifiers = classNameModifiers.filter(m => !!m);\n\n return (\n <iframe\n ref={ref => {\n this.iframeEl = ref;\n }}\n allow={allow}\n className={classNames(\n 'adyen-checkout__iframe',\n `adyen-checkout__iframe--${name}`,\n validClassNameModifiers.length && classNameModifiers.map(m => `adyen-checkout__iframe--${name}-${m}`)\n )}\n name={name}\n src={src}\n width={width}\n height={height}\n frameBorder=\"0\"\n title={title}\n /* eslint-disable react/no-unknown-property */\n referrerpolicy=\"origin\"\n min-width={minWidth}\n min-height={minHeight}\n /* eslint-enable react/no-unknown-property */\n />\n );\n }\n}\n\nexport default Iframe;\n"],"names":["Iframe","Component","iframeOnLoad","this","props","callback","iframeEl","contentWindow","componentDidMount","addEventListener","bind","attachEvent","onload","componentWillUnmount","removeEventListener","detachEvent","render","name","src","width","height","minWidth","minHeight","allow","title","classNameModifiers","validClassNameModifiers","filter","m","h","iframe","ref","className","classNames","length","map","frameBorder","referrerpolicy","min-width","min-height","super","args","_define_property","defaultProps"],"mappings":"yPAkBA,MAAMA,UAAeC,EAcjBC,YAAAA,GACQC,KAAKC,MAAMC,UAA2C,mBAAxBF,KAAKC,MAAMC,UACzCF,KAAKC,MAAMC,SAASF,KAAKG,SAASC,cAE1C,CAEAC,iBAAAA,GACQL,KAAKG,SAASG,iBACdN,KAAKG,SAASG,iBAAiB,OAAQN,KAAKD,aAAaQ,KAAKP,OAAO,GAC9DA,KAAKG,SAASK,YAErBR,KAAKG,SAASK,YAAY,SAAUR,KAAKD,aAAaQ,KAAKP,OAE3DA,KAAKG,SAASM,OAAST,KAAKD,aAAaQ,KAAKP,KAEtD,CAEAU,oBAAAA,GACQV,KAAKG,SAASQ,oBACdX,KAAKG,SAASQ,oBAAoB,OAAQX,KAAKD,aAAaQ,KAAKP,OAAO,GACjEA,KAAKG,SAASS,YAErBZ,KAAKG,SAASS,YAAY,SAAUZ,KAAKD,aAAaQ,KAAKP,OAE3DA,KAAKG,SAASM,OAAS,IAE/B,CAEAI,MAAAA,EAAOC,KAAEA,EAAIC,IAAEA,EAAGC,MAAEA,EAAKC,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAASC,MAAEA,EAAKC,MAAEA,EAAKC,mBAAEA,IAClE,MAAMC,EAA0BD,EAAmBE,OAAOC,KAAOA,GAEjE,OACIC,EAACC,SAAAA,CACGC,IAAKA,IACD5B,KAAKG,SAAWyB,GAEpBR,MAAOA,EACPS,UAAWC,EACP,yBACA,2BAA2BhB,IAC3BS,EAAwBQ,QAAUT,EAAmBU,IAAIP,GAAK,2BAA2BX,KAAQW,MAErGX,KAAMA,EACNC,IAAKA,EACLC,MAAOA,EACPC,OAAQA,EACRgB,YAAY,IACZZ,MAAOA,EAEPa,eAAe,SACfC,YAAWjB,EACXkB,aAAYjB,GAIxB,mBArEJkB,SAAAC,GAYIC,EAAAvC,KAAQG,oBAXRoC,EADE1C,EACqB2C,eAAe,CAClCxB,MAAO,IACPC,OAAQ,IACRC,SAAU,IACVC,UAAW,IACXJ,IAAK,KACLK,MAAO,KACPC,MAAO,oBACPC,mBAAoB"}
1
+ {"version":3,"file":"Iframe.js","sources":["../../../../../src/components/internal/IFrame/Iframe.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport './Iframe.scss';\n\ninterface IframeProps {\n width?: string;\n height?: string;\n minWidth?: string;\n minHeight?: string;\n border?: string;\n src?: string;\n allow?: string;\n name?: string;\n title?: string;\n sandbox?: string;\n classNameModifiers?: string[];\n callback?: (contentWindow) => void;\n}\n\nclass Iframe extends Component<Readonly<IframeProps>> {\n public static readonly defaultProps = {\n width: '0',\n height: '0',\n minWidth: '0',\n minHeight: '0',\n src: null,\n allow: null,\n title: 'components iframe',\n classNameModifiers: []\n };\n\n private iframeEl;\n\n iframeOnLoad() {\n if (this.props.callback && typeof this.props.callback === 'function') {\n this.props.callback(this.iframeEl.contentWindow);\n }\n }\n\n componentDidMount() {\n if (this.iframeEl.addEventListener) {\n this.iframeEl.addEventListener('load', this.iframeOnLoad.bind(this), false);\n } else if (this.iframeEl.attachEvent) {\n // IE fallback\n this.iframeEl.attachEvent('onload', this.iframeOnLoad.bind(this));\n } else {\n this.iframeEl.onload = this.iframeOnLoad.bind(this);\n }\n }\n\n componentWillUnmount() {\n if (this.iframeEl.removeEventListener) {\n this.iframeEl.removeEventListener('load', this.iframeOnLoad.bind(this), false);\n } else if (this.iframeEl.detachEvent) {\n // IE fallback\n this.iframeEl.detachEvent('onload', this.iframeOnLoad.bind(this));\n } else {\n this.iframeEl.onload = null;\n }\n }\n\n render({ name, src, width, height, minWidth, minHeight, allow, title, sandbox, classNameModifiers }: IframeProps) {\n const validClassNameModifiers = classNameModifiers.filter(m => !!m);\n\n return (\n <iframe\n ref={ref => {\n this.iframeEl = ref;\n }}\n allow={allow}\n className={classNames(\n 'adyen-checkout__iframe',\n `adyen-checkout__iframe--${name}`,\n validClassNameModifiers.length && classNameModifiers.map(m => `adyen-checkout__iframe--${name}-${m}`)\n )}\n name={name}\n src={src}\n width={width}\n height={height}\n frameBorder=\"0\"\n title={title}\n /* eslint-disable react/no-unknown-property */\n referrerpolicy=\"origin\"\n min-width={minWidth}\n min-height={minHeight}\n sandbox={sandbox}\n /* eslint-enable react/no-unknown-property */\n />\n );\n }\n}\n\nexport default Iframe;\n"],"names":["Iframe","Component","iframeOnLoad","this","props","callback","iframeEl","contentWindow","componentDidMount","addEventListener","bind","attachEvent","onload","componentWillUnmount","removeEventListener","detachEvent","render","name","src","width","height","minWidth","minHeight","allow","title","sandbox","classNameModifiers","validClassNameModifiers","filter","m","h","iframe","ref","className","classNames","length","map","frameBorder","referrerpolicy","min-width","min-height","super","args","_define_property","defaultProps"],"mappings":"yPAmBA,MAAMA,UAAeC,EAcjBC,YAAAA,GACQC,KAAKC,MAAMC,UAA2C,mBAAxBF,KAAKC,MAAMC,UACzCF,KAAKC,MAAMC,SAASF,KAAKG,SAASC,cAE1C,CAEAC,iBAAAA,GACQL,KAAKG,SAASG,iBACdN,KAAKG,SAASG,iBAAiB,OAAQN,KAAKD,aAAaQ,KAAKP,OAAO,GAC9DA,KAAKG,SAASK,YAErBR,KAAKG,SAASK,YAAY,SAAUR,KAAKD,aAAaQ,KAAKP,OAE3DA,KAAKG,SAASM,OAAST,KAAKD,aAAaQ,KAAKP,KAEtD,CAEAU,oBAAAA,GACQV,KAAKG,SAASQ,oBACdX,KAAKG,SAASQ,oBAAoB,OAAQX,KAAKD,aAAaQ,KAAKP,OAAO,GACjEA,KAAKG,SAASS,YAErBZ,KAAKG,SAASS,YAAY,SAAUZ,KAAKD,aAAaQ,KAAKP,OAE3DA,KAAKG,SAASM,OAAS,IAE/B,CAEAI,MAAAA,EAAOC,KAAEA,EAAIC,IAAEA,EAAGC,MAAEA,EAAKC,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAASC,MAAEA,EAAKC,MAAEA,EAAKC,QAAEA,EAAOC,mBAAEA,IAC3E,MAAMC,EAA0BD,EAAmBE,OAAOC,KAAOA,GAEjE,OACIC,EAACC,SAAAA,CACGC,IAAKA,IACD7B,KAAKG,SAAW0B,GAEpBT,MAAOA,EACPU,UAAWC,EACP,yBACA,2BAA2BjB,IAC3BU,EAAwBQ,QAAUT,EAAmBU,IAAIP,GAAK,2BAA2BZ,KAAQY,MAErGZ,KAAMA,EACNC,IAAKA,EACLC,MAAOA,EACPC,OAAQA,EACRiB,YAAY,IACZb,MAAOA,EAEPc,eAAe,SACfC,YAAWlB,EACXmB,aAAYlB,EACZG,QAASA,GAIrB,mBAtEJgB,SAAAC,GAYIC,EAAAxC,KAAQG,oBAXRqC,EADE3C,EACqB4C,eAAe,CAClCzB,MAAO,IACPC,OAAQ,IACRC,SAAU,IACVC,UAAW,IACXJ,IAAK,KACLK,MAAO,KACPC,MAAO,oBACPE,mBAAoB"}
@@ -1,2 +1,2 @@
1
- import{AbstractAnalyticsEvent as e,AnalyticsEventCategory as t}from"./AbstractAnalyticsEvent.js";import{mapErrorCodesForAnalytics as o}from"../utils.js";function r(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var i=function(e){return e.instantPaymentButton="instant_payment_button",e.dualBrandButton="dual_brand_button",e.fastlaneSignupConsentToggle="fastlane_signup_consent_toggle",e.otherPaymentMethodButton="otherpaymentmethod_button",e.featuredIssuer="featured_issuer",e.list="list",e.listSearch="list_search",e.qrDownloadButton="qr_download_button",e.segmentedControl="segmented_control",e.cardNumber="card_number",e.expiryDate="expiry_date",e.expiryMonth="expiry_month",e.expiryYear="expiry_year",e.securityCode="security_code",e.donationAmountButton="donation_amount_button",e}({}),d=function(e){return e.clicked="clicked",e.rendered="rendered",e.selected="selected",e.validationError="validationError",e.focus="focus",e.unfocus="unfocus",e.configured="configured",e.displayed="displayed",e.input="input",e.download="download",e.sdkDownloadInitiated="sdkDownloadInitiated",e.sdkDownloadFailed="sdkDownloadFailed",e.sdkDownloadAborted="sdkDownloadAborted",e.sdkDownloadCompleted="sdkDownloadCompleted",e.Initialized="initialized",e.LookupStarted="lookupStarted",e.LookupUserNotFound="lookupUserNotFound",e.OtpStarted="otpStarted",e.OtpSucceeded="otpSucceeded",e.OtpCanceled="otpCanceled",e.OtpFailed="otpFailed",e.AddressSelectorClicked="addressSelectorClicked",e.AddressSelectorClosed="addressSelectorClosed",e.AddressChanged="addressChanged",e}({});class s extends e{get configDataExcludedFields(){return["paymentMethodsConfiguration","elementRef","isDropin","oneClick","storedPaymentMethodId","paymentMethodId","isInstantPayment","type","data","holderName","shopperEmail","email","telephoneNumber","clickToPayConfiguration","modules","i18n"]}createAnalyticsConfigData(e){if(!e)return{};const t={};try{for(const[o,r]of Object.entries(e))this.configDataExcludedFields.includes(o)||("function"==typeof r?t[o]="function":Array.isArray(r)?t[o]=r.join(", ").substring(0,128):t[o]="object"==typeof r&&null!==r?JSON.stringify(r).substring(0,128):r);return t}catch(e){return t}}getEventCategory(){return t.info}constructor(e){super(e.component),r(this,"type",void 0),r(this,"configData",void 0),r(this,"target",void 0),r(this,"issuer",void 0),r(this,"isExpress",void 0),r(this,"expressPage",void 0),r(this,"isStoredPaymentMethod",void 0),r(this,"brand",void 0),r(this,"selectedValue",void 0),r(this,"validationErrorCode",void 0),r(this,"validationErrorMessage",void 0),r(this,"presentedValues",void 0),r(this,"cdnUrl",void 0),this.type=e.type,e.target&&(this.target=e.target),e.issuer&&(this.issuer=e.issuer),void 0!==e.isStoredPaymentMethod&&(this.isStoredPaymentMethod=e.isStoredPaymentMethod),void 0!==e.isExpress&&(this.isExpress=e.isExpress),e.expressPage&&(this.expressPage=e.expressPage),e.brand&&(this.brand=e.brand),e.cdnUrl&&(this.cdnUrl=e.cdnUrl),e.selectedValue&&(this.selectedValue=e.selectedValue),e.validationErrorCode&&(this.validationErrorCode=e.validationErrorCode),e.validationErrorMessage&&(this.validationErrorMessage=e.validationErrorMessage),e.presentedValues&&(this.presentedValues=e.presentedValues),"rendered"===this.type&&(this.configData=this.createAnalyticsConfigData(e?.configData)),"validationError"===this.type&&(this.validationErrorCode=o(this.validationErrorCode,this.target))}}export{s as AnalyticsInfoEvent,d as InfoEventType,i as UiTarget};
1
+ import{AbstractAnalyticsEvent as e,AnalyticsEventCategory as t}from"./AbstractAnalyticsEvent.js";import{mapErrorCodesForAnalytics as o}from"../utils.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}var i=function(e){return e.instantPaymentButton="instant_payment_button",e.dualBrandButton="dual_brand_button",e.fastlaneSignupConsentToggle="fastlane_signup_consent_toggle",e.otherPaymentMethodButton="otherpaymentmethod_button",e.featuredIssuer="featured_issuer",e.list="list",e.listSearch="list_search",e.qrDownloadButton="qr_download_button",e.segmentedControl="segmented_control",e.cardNumber="card_number",e.expiryDate="expiry_date",e.expiryMonth="expiry_month",e.expiryYear="expiry_year",e.securityCode="security_code",e.donationAmountButton="donation_amount_button",e}({}),d=function(e){return e.clicked="clicked",e.rendered="rendered",e.selected="selected",e.validationError="validationError",e.focus="focus",e.unfocus="unfocus",e.configured="configured",e.displayed="displayed",e.input="input",e.download="download",e.sdkDownloadInitiated="sdkDownloadInitiated",e.sdkDownloadFailed="sdkDownloadFailed",e.sdkDownloadAborted="sdkDownloadAborted",e.sdkDownloadCompleted="sdkDownloadCompleted",e.Initialized="initialized",e.LookupStarted="lookupStarted",e.LookupUserNotFound="lookupUserNotFound",e.OtpStarted="otpStarted",e.OtpSucceeded="otpSucceeded",e.OtpCanceled="otpCanceled",e.OtpFailed="otpFailed",e.AddressSelectorClicked="addressSelectorClicked",e.AddressSelectorClosed="addressSelectorClosed",e.AddressChanged="addressChanged",e.PaymentListDisplayed="paymentListDisplayed",e}({});class s extends e{get configDataExcludedFields(){return["paymentMethodsConfiguration","elementRef","isDropin","oneClick","storedPaymentMethodId","paymentMethodId","isInstantPayment","type","data","holderName","shopperEmail","email","telephoneNumber","clickToPayConfiguration","modules","i18n"]}createAnalyticsConfigData(e){if(!e)return{};const t={};try{for(const[o,a]of Object.entries(e))this.configDataExcludedFields.includes(o)||("function"==typeof a?t[o]="function":Array.isArray(a)?t[o]=a.join(", ").substring(0,128):t[o]="object"==typeof a&&null!==a?JSON.stringify(a).substring(0,128):a);return t}catch(e){return t}}getEventCategory(){return t.info}constructor(e){super(e.component),a(this,"type",void 0),a(this,"configData",void 0),a(this,"target",void 0),a(this,"issuer",void 0),a(this,"isExpress",void 0),a(this,"expressPage",void 0),a(this,"isStoredPaymentMethod",void 0),a(this,"brand",void 0),a(this,"selectedValue",void 0),a(this,"validationErrorCode",void 0),a(this,"validationErrorMessage",void 0),a(this,"presentedValues",void 0),a(this,"availablePaymentMethods",void 0),a(this,"unavailablePaymentMethods",void 0),a(this,"cdnUrl",void 0),this.type=e.type,e.target&&(this.target=e.target),e.issuer&&(this.issuer=e.issuer),void 0!==e.isStoredPaymentMethod&&(this.isStoredPaymentMethod=e.isStoredPaymentMethod),void 0!==e.isExpress&&(this.isExpress=e.isExpress),e.expressPage&&(this.expressPage=e.expressPage),e.brand&&(this.brand=e.brand),e.cdnUrl&&(this.cdnUrl=e.cdnUrl),e.selectedValue&&(this.selectedValue=e.selectedValue),e.validationErrorCode&&(this.validationErrorCode=e.validationErrorCode),e.validationErrorMessage&&(this.validationErrorMessage=e.validationErrorMessage),e.presentedValues&&(this.presentedValues=e.presentedValues),e.availablePaymentMethods&&(this.availablePaymentMethods=e.availablePaymentMethods),e.unavailablePaymentMethods&&(this.unavailablePaymentMethods=e.unavailablePaymentMethods),"rendered"===this.type&&(this.configData=this.createAnalyticsConfigData(e?.configData)),"validationError"===this.type&&(this.validationErrorCode=o(this.validationErrorCode,this.target))}}export{s as AnalyticsInfoEvent,d as InfoEventType,i as UiTarget};
2
2
  //# sourceMappingURL=AnalyticsInfoEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsInfoEvent.js","sources":["../../../../../src/core/Analytics/events/AnalyticsInfoEvent.ts"],"sourcesContent":["import { AbstractAnalyticsEvent, AnalyticsEventCategory } from './AbstractAnalyticsEvent';\nimport { mapErrorCodesForAnalytics } from '../utils';\n\ntype AnalyticsInfoEventProps = {\n type: InfoEventType;\n component: string;\n target?: UiTarget;\n issuer?: string;\n isExpress?: boolean;\n expressPage?: string;\n isStoredPaymentMethod?: boolean;\n brand?: string;\n validationErrorCode?: string;\n validationErrorMessage?: string;\n configData?: Record<string, any>;\n cdnUrl?: string;\n selectedValue?: string;\n presentedValues?: Array<string>;\n};\n\nexport enum UiTarget {\n instantPaymentButton = 'instant_payment_button',\n dualBrandButton = 'dual_brand_button',\n fastlaneSignupConsentToggle = 'fastlane_signup_consent_toggle',\n otherPaymentMethodButton = 'otherpaymentmethod_button',\n featuredIssuer = 'featured_issuer',\n list = 'list',\n listSearch = 'list_search',\n qrDownloadButton = 'qr_download_button',\n segmentedControl = 'segmented_control',\n cardNumber = 'card_number',\n expiryDate = 'expiry_date',\n expiryMonth = 'expiry_month',\n expiryYear = 'expiry_year',\n securityCode = 'security_code',\n donationAmountButton = 'donation_amount_button'\n}\n\nexport enum InfoEventType {\n /** When a UI element is clicked */\n clicked = 'clicked',\n /** When a component is rendered in the browser (e.g. render() method is called) */\n rendered = 'rendered',\n /** When a list item is selected (e.g. issuer list) */\n selected = 'selected',\n /** When there is a validation issue with the input */\n validationError = 'validationError',\n /** When input gets focus */\n focus = 'focus',\n /** When input gets unfocus */\n unfocus = 'unfocus',\n /** When iframe fields are configured */\n configured = 'configured',\n /** When a dropdown list is displayed */\n displayed = 'displayed',\n /** When shopper utilizes an input field to search for values (e.g. issuer list) */\n input = 'input',\n /** When shopper clicks to download the image (e.g. QR code image) */\n download = 'download',\n sdkDownloadInitiated = 'sdkDownloadInitiated',\n sdkDownloadFailed = 'sdkDownloadFailed',\n sdkDownloadAborted = 'sdkDownloadAborted',\n sdkDownloadCompleted = 'sdkDownloadCompleted',\n Initialized = 'initialized',\n LookupStarted = 'lookupStarted',\n LookupUserNotFound = 'lookupUserNotFound',\n OtpStarted = 'otpStarted',\n OtpSucceeded = 'otpSucceeded',\n OtpCanceled = 'otpCanceled',\n OtpFailed = 'otpFailed',\n AddressSelectorClicked = 'addressSelectorClicked',\n AddressSelectorClosed = 'addressSelectorClosed',\n AddressChanged = 'addressChanged'\n}\n\nexport class AnalyticsInfoEvent extends AbstractAnalyticsEvent {\n /**\n * Analytics event type\n */\n private readonly type: InfoEventType;\n\n /**\n * Component config data set by the merchant. Sent only in 'rendered' events\n * @private\n */\n private readonly configData?: Record<string, string | boolean>;\n private readonly target?: UiTarget;\n private readonly issuer?: string;\n private readonly isExpress?: boolean;\n private readonly expressPage?: string;\n private readonly isStoredPaymentMethod?: boolean;\n private readonly brand?: string;\n private readonly selectedValue?: string;\n private readonly validationErrorCode?: string;\n private readonly validationErrorMessage?: string;\n private readonly presentedValues?: string[];\n\n /**\n * Third party script URL's (e.g. Apple Pay)\n */\n public cdnUrl?: string;\n\n constructor(props: AnalyticsInfoEventProps) {\n super(props.component);\n\n this.type = props.type;\n\n if (props.target) this.target = props.target;\n if (props.issuer) this.issuer = props.issuer;\n if (props.isStoredPaymentMethod !== undefined) this.isStoredPaymentMethod = props.isStoredPaymentMethod;\n if (props.isExpress !== undefined) this.isExpress = props.isExpress;\n if (props.expressPage) this.expressPage = props.expressPage;\n if (props.brand) this.brand = props.brand;\n if (props.cdnUrl) this.cdnUrl = props.cdnUrl;\n if (props.selectedValue) this.selectedValue = props.selectedValue;\n if (props.validationErrorCode) this.validationErrorCode = props.validationErrorCode;\n if (props.validationErrorMessage) this.validationErrorMessage = props.validationErrorMessage;\n if (props.presentedValues) this.presentedValues = props.presentedValues;\n if (this.type === InfoEventType.rendered) {\n this.configData = this.createAnalyticsConfigData(props?.configData);\n }\n\n // Some of the more generic validation error codes required combination with target to retrieve a specific code\n if (this.type === InfoEventType.validationError) {\n this.validationErrorCode = mapErrorCodesForAnalytics(this.validationErrorCode, this.target);\n }\n }\n\n /**\n * Set of properties that must not be included when creating the configData for Analytics\n * @private\n */\n private get configDataExcludedFields() {\n const DROPIN_FIELDS = ['paymentMethodsConfiguration'];\n const FIELDS_INJECTED_BY_DROPIN = [\n 'elementRef',\n 'isDropin',\n 'oneClick',\n 'storedPaymentMethodId',\n 'paymentMethodId',\n 'isInstantPayment',\n 'type'\n ];\n const PII_FIELDS = ['data', 'holderName', 'shopperEmail', 'email', 'telephoneNumber', 'clickToPayConfiguration'];\n\n /**\n * TODO: Many unit tests are passing 'modules' as props, which leads to circular structure issue\n * The components must use the 'modules' from the core and not from the props\n */\n const UNIT_TEST_FIELDS = ['modules', 'i18n'];\n\n return [...DROPIN_FIELDS, ...FIELDS_INJECTED_BY_DROPIN, ...PII_FIELDS, ...UNIT_TEST_FIELDS];\n }\n\n /**\n * Creates a serializable analytics payload from the given config object.\n * Functions are replaced with 'function', and objects/arrays are stringified.\n */\n private createAnalyticsConfigData(config: Record<string, any>) {\n if (!config) return {};\n\n const MAX_STRING_LENGTH = 128;\n const result: Record<string, string> = {};\n\n try {\n for (const [key, value] of Object.entries(config)) {\n if (!this.configDataExcludedFields.includes(key)) {\n if (typeof value === 'function') {\n result[key] = 'function';\n } else if (Array.isArray(value)) {\n result[key] = value.join(', ').substring(0, MAX_STRING_LENGTH);\n } else if (typeof value === 'object' && value !== null) {\n result[key] = JSON.stringify(value).substring(0, MAX_STRING_LENGTH);\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n } catch (error: unknown) {\n if (process.env.NODE_ENV === 'development') console.warn('AnalyticsInfoEvent: Error when creating configData\\n', error);\n return result;\n }\n }\n\n public getEventCategory(): AnalyticsEventCategory {\n return AnalyticsEventCategory.info;\n }\n}\n"],"names":["UiTarget","InfoEventType","AnalyticsInfoEvent","AbstractAnalyticsEvent","configDataExcludedFields","createAnalyticsConfigData","config","result","key","value","Object","entries","this","includes","Array","isArray","join","substring","JSON","stringify","error","getEventCategory","AnalyticsEventCategory","info","constructor","props","super","component","_define_property","type","configData","target","issuer","isExpress","expressPage","isStoredPaymentMethod","brand","selectedValue","validationErrorCode","validationErrorMessage","presentedValues","cdnUrl","undefined","mapErrorCodesForAnalytics"],"mappings":"iRAoBO,IAAAA,EAAKA,SAAAA,GAAAA,2iBAAAA,CAgBZ,CAhBYA,CAgBZ,CAAA,GAEOC,EAAKA,SAAAA,GAAAA,OACyBA,EAAA,QAAA,UAEgDA,EAAA,SAAA,WAE7BA,EAAA,SAAA,WAEAA,EAAA,gBA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AMI,KAEdJ,EAAMM,SAAQnB,KAAKmB,OAASN,EAAMM,QAClCN,EAAMO,SAAQpB,KAAKoB,OAASP,EAAMO,aACFU,IAAhCjB,EAAMU,wBAAqCvB,KAAKuB,sBAAwBV,EAAMU,4BAC1DO,IAApBjB,EAAMQ,YAAyBrB,KAAKqB,UAAYR,EAAMQ,WACtDR,EAAMS,cAAatB,KAAKsB,YAAcT,EAAMS,aAC5CT,EAAMW,QAAOxB,KAAKwB,MAAQX,EAAMW,OAChCX,EAAMgB,SAAQ7B,KAAK6B,OAAShB,EAAMgB,QAClChB,EAAMY,gBAAezB,KAAKyB,cAAgBZ,EAAMY,eAChDZ,EAAMa,sBAAqB1B,KAAK0B,oBAAsBb,EAAMa,qBAC5Db,EAAMc,yBAAwB3B,KAAK2B,uBAAyBd,EAAMc,wBAClEd,EAAMe,kBAAiB5B,KAAK4B,gBAAkBf,EAAMe,iBAC3C,aAAT5B,KAAKiB,OACLjB,KAAKkB,WAAalB,KAAKP,0BAA0BoB,GAAOK,aAI/C,oBAATlB,KAAKiB,OACLjB,KAAK0B,oBAAsBK,EAA0B/B,KAAK0B,oBAAqB1B,KAAKmB,QAE5F"}
1
+ {"version":3,"file":"AnalyticsInfoEvent.js","sources":["../../../../../src/core/Analytics/events/AnalyticsInfoEvent.ts"],"sourcesContent":["import { AbstractAnalyticsEvent, AnalyticsEventCategory } from './AbstractAnalyticsEvent';\nimport { mapErrorCodesForAnalytics } from '../utils';\n\nexport type AnalyticsPaymentMethod<DisplayMode extends string = string> = {\n paymentMethodType: string;\n brands?: string[];\n fundingSource?: 'debit' | 'credit' | 'prepaid';\n displayMode: DisplayMode;\n};\n\ntype AnalyticsInfoEventProps = {\n type: InfoEventType;\n component: string;\n target?: UiTarget;\n issuer?: string;\n isExpress?: boolean;\n expressPage?: string;\n isStoredPaymentMethod?: boolean;\n brand?: string;\n validationErrorCode?: string;\n validationErrorMessage?: string;\n configData?: Record<string, any>;\n cdnUrl?: string;\n selectedValue?: string;\n presentedValues?: Array<string>;\n availablePaymentMethods?: AnalyticsPaymentMethod[];\n unavailablePaymentMethods?: AnalyticsPaymentMethod[];\n};\n\nexport enum UiTarget {\n instantPaymentButton = 'instant_payment_button',\n dualBrandButton = 'dual_brand_button',\n fastlaneSignupConsentToggle = 'fastlane_signup_consent_toggle',\n otherPaymentMethodButton = 'otherpaymentmethod_button',\n featuredIssuer = 'featured_issuer',\n list = 'list',\n listSearch = 'list_search',\n qrDownloadButton = 'qr_download_button',\n segmentedControl = 'segmented_control',\n cardNumber = 'card_number',\n expiryDate = 'expiry_date',\n expiryMonth = 'expiry_month',\n expiryYear = 'expiry_year',\n securityCode = 'security_code',\n donationAmountButton = 'donation_amount_button'\n}\n\nexport enum InfoEventType {\n /** When a UI element is clicked */\n clicked = 'clicked',\n /** When a component is rendered in the browser (e.g. render() method is called) */\n rendered = 'rendered',\n /** When a list item is selected (e.g. issuer list) */\n selected = 'selected',\n /** When there is a validation issue with the input */\n validationError = 'validationError',\n /** When input gets focus */\n focus = 'focus',\n /** When input gets unfocus */\n unfocus = 'unfocus',\n /** When iframe fields are configured */\n configured = 'configured',\n /** When a dropdown list is displayed */\n displayed = 'displayed',\n /** When shopper utilizes an input field to search for values (e.g. issuer list) */\n input = 'input',\n /** When shopper clicks to download the image (e.g. QR code image) */\n download = 'download',\n sdkDownloadInitiated = 'sdkDownloadInitiated',\n sdkDownloadFailed = 'sdkDownloadFailed',\n sdkDownloadAborted = 'sdkDownloadAborted',\n sdkDownloadCompleted = 'sdkDownloadCompleted',\n Initialized = 'initialized',\n LookupStarted = 'lookupStarted',\n LookupUserNotFound = 'lookupUserNotFound',\n OtpStarted = 'otpStarted',\n OtpSucceeded = 'otpSucceeded',\n OtpCanceled = 'otpCanceled',\n OtpFailed = 'otpFailed',\n AddressSelectorClicked = 'addressSelectorClicked',\n AddressSelectorClosed = 'addressSelectorClosed',\n AddressChanged = 'addressChanged',\n PaymentListDisplayed = 'paymentListDisplayed'\n}\n\nexport class AnalyticsInfoEvent extends AbstractAnalyticsEvent {\n /**\n * Analytics event type\n */\n private readonly type: InfoEventType;\n\n /**\n * Component config data set by the merchant. Sent only in 'rendered' events\n * @private\n */\n private readonly configData?: Record<string, string | boolean>;\n private readonly target?: UiTarget;\n private readonly issuer?: string;\n private readonly isExpress?: boolean;\n private readonly expressPage?: string;\n private readonly isStoredPaymentMethod?: boolean;\n private readonly brand?: string;\n private readonly selectedValue?: string;\n private readonly validationErrorCode?: string;\n private readonly validationErrorMessage?: string;\n private readonly presentedValues?: string[];\n private readonly availablePaymentMethods?: AnalyticsPaymentMethod[];\n private readonly unavailablePaymentMethods?: AnalyticsPaymentMethod[];\n\n /**\n * Third party script URL's (e.g. Apple Pay)\n */\n public cdnUrl?: string;\n\n constructor(props: AnalyticsInfoEventProps) {\n super(props.component);\n\n this.type = props.type;\n\n if (props.target) this.target = props.target;\n if (props.issuer) this.issuer = props.issuer;\n if (props.isStoredPaymentMethod !== undefined) this.isStoredPaymentMethod = props.isStoredPaymentMethod;\n if (props.isExpress !== undefined) this.isExpress = props.isExpress;\n if (props.expressPage) this.expressPage = props.expressPage;\n if (props.brand) this.brand = props.brand;\n if (props.cdnUrl) this.cdnUrl = props.cdnUrl;\n if (props.selectedValue) this.selectedValue = props.selectedValue;\n if (props.validationErrorCode) this.validationErrorCode = props.validationErrorCode;\n if (props.validationErrorMessage) this.validationErrorMessage = props.validationErrorMessage;\n if (props.presentedValues) this.presentedValues = props.presentedValues;\n if (props.availablePaymentMethods) this.availablePaymentMethods = props.availablePaymentMethods;\n if (props.unavailablePaymentMethods) this.unavailablePaymentMethods = props.unavailablePaymentMethods;\n if (this.type === InfoEventType.rendered) {\n this.configData = this.createAnalyticsConfigData(props?.configData);\n }\n\n // Some of the more generic validation error codes required combination with target to retrieve a specific code\n if (this.type === InfoEventType.validationError) {\n this.validationErrorCode = mapErrorCodesForAnalytics(this.validationErrorCode, this.target);\n }\n }\n\n /**\n * Set of properties that must not be included when creating the configData for Analytics\n * @private\n */\n private get configDataExcludedFields() {\n const DROPIN_FIELDS = ['paymentMethodsConfiguration'];\n const FIELDS_INJECTED_BY_DROPIN = [\n 'elementRef',\n 'isDropin',\n 'oneClick',\n 'storedPaymentMethodId',\n 'paymentMethodId',\n 'isInstantPayment',\n 'type'\n ];\n const PII_FIELDS = ['data', 'holderName', 'shopperEmail', 'email', 'telephoneNumber', 'clickToPayConfiguration'];\n\n /**\n * TODO: Many unit tests are passing 'modules' as props, which leads to circular structure issue\n * The components must use the 'modules' from the core and not from the props\n */\n const UNIT_TEST_FIELDS = ['modules', 'i18n'];\n\n return [...DROPIN_FIELDS, ...FIELDS_INJECTED_BY_DROPIN, ...PII_FIELDS, ...UNIT_TEST_FIELDS];\n }\n\n /**\n * Creates a serializable analytics payload from the given config object.\n * Functions are replaced with 'function', and objects/arrays are stringified.\n */\n private createAnalyticsConfigData(config: Record<string, any>) {\n if (!config) return {};\n\n const MAX_STRING_LENGTH = 128;\n const result: Record<string, string> = {};\n\n try {\n for (const [key, value] of Object.entries(config)) {\n if (!this.configDataExcludedFields.includes(key)) {\n if (typeof value === 'function') {\n result[key] = 'function';\n } else if (Array.isArray(value)) {\n result[key] = value.join(', ').substring(0, MAX_STRING_LENGTH);\n } else if (typeof value === 'object' && value !== null) {\n result[key] = JSON.stringify(value).substring(0, MAX_STRING_LENGTH);\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n } catch (error: unknown) {\n if (process.env.NODE_ENV === 'development') console.warn('AnalyticsInfoEvent: Error when creating configData\\n', error);\n return result;\n }\n }\n\n public getEventCategory(): AnalyticsEventCategory {\n return AnalyticsEventCategory.info;\n }\n}\n"],"names":["UiTarget","InfoEventType","AnalyticsInfoEvent","AbstractAnalyticsEvent","configDataExcludedFields","createAnalyticsConfigData","config","result","key","value","Object","entries","this","includes","Array","isArray","join","substring","JSON","stringify","error","getEventCategory","AnalyticsEventCategory","info","constructor","props","super","component","_define_property","type","configData","target","issuer","isExpress","expressPage","isStoredPaymentMethod","brand","selectedValue","validationErrorCode","validationErrorMessage","presentedValues","availablePaymentMethods","unavailablePaymentMethods","cdnUrl","undefined","mapErrorCodesForAnalytics"],"mappings":"iRA6BO,IAAAA,EAAKA,SAAAA,GAAAA,2iBAAAA,CAgBZ,CAhBYA,CAgBZ,CAAA,GAEOC,EAAKA,SAAAA,GAAAA,OACyBA,EAAA,QAAA,UAEgDA,EAAA,SAAA,WAE7BA,EAAA,SAAA,WAEAA,EAAA,gBAAA,kBAE1BA,EAAA,MAAA,QAEEA,EAAA,QAAA,UAEUA,EAAA,WAAA,aAEAA,EAAA,UAAA,YAE2CA,EAAA,MAAA,QAEdA,EAAA,SAAA,6jBAnB3DA,CAoCZ,CApCYA,CAoCZ,CAAA,GAEO,MAAMC,UAA2BC,EA6DpC,4BAAYC,GAmBR,MAAO,CAlBgB,8BAEnB,aACA,WACA,WACA,wBACA,kBACA,mBACA,OAEgB,OAAQ,aAAc,eAAgB,QAAS,kBAAmB,0BAM5D,UAAW,OAGzC,CAMQC,yBAAAA,CAA0BC,GAC9B,IAAKA,EAAQ,MAAO,CAAA,EAEpB,MACMC,EAAiC,CAAA,EAEvC,IACI,IAAK,MAAOC,EAAKC,KAAUC,OAAOC,QAAQL,GACjCM,KAAKR,yBAAyBS,SAASL,KACnB,mBAAVC,EACPF,EAAOC,GAAO,WACPM,MAAMC,QAAQN,GACrBF,EAAOC,GAAOC,EAAMO,KAAK,MAAMC,UAAU,EAT/B,KAWVV,EAAOC,GADiB,iBAAVC,GAAgC,OAAVA,EACtBS,KAAKC,UAAUV,GAAOQ,UAAU,EAXpC,KAaIR,GAK1B,OAAOF,CACX,CAAE,MAAOa,GAEL,OAAOb,CACX,CACJ,CAEOc,gBAAAA,GACH,OAAOC,EAAuBC,IAClC,CAxFA,WAAAC,CAAYC,GACRC,MAAMD,EAAME,WA1BhBC,EAAAhB,KAAiBiB,eAMjBD,EAAAhB,KAAiBkB,kBAAjB,GACAF,OAAiBG,cAAjB,GACAH,EAAAhB,KAAiBo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get3DS2FlowProps as e}from"../../../components/ThreeDS2/components/utils.js";import t from"../../../utils/uuid.js";const o=(e,o,n,r)=>{const i=o.getComponent(n);if(!i)throw Error(`Action Element of type ${n} not found in the registry`);return new i(e,{...r,id:`${n}-${t()}`})},n=e=>(t,n,r,i)=>{const s={...i,...r,onError:i.onError,statusType:e,originalAction:r};return o(t,n,r.paymentMethodType,s)},r={redirect:(e,t,n,r)=>{const i={...r,...n,statusType:"redirect",originalAction:n};return o(e,t,"redirect",i)},threeDS2:(t,n,r,i)=>{const s="fingerprint"===r.subtype?"threeDS2DeviceFingerprint":"threeDS2Challenge",a="fingerprint"===r.subtype||i.isMDFlow?r.paymentData:r.authorisationToken,l={core:t,token:r.token,paymentData:a,onActionHandled:i.onActionHandled,on3DS2RedirectFlowComplete:i.on3DS2RedirectFlowComplete,onAdditionalDetails:i.onAdditionalDetails,onError:i.onError,isDropin:!!i.isDropin,loadingContext:i.loadingContext,clientKey:i.clientKey,paymentMethodType:i.paymentMethodType,challengeWindowSize:i.challengeWindowSize,isMDFlow:i.isMDFlow,modules:{analytics:i.modules?.analytics,resources:i.modules?.resources},...e(r.subtype,i)};return o(t,n,s,l)},voucher:n("custom"),qrCode:n("custom"),await:n("custom"),bankTransfer:n("custom"),sdk:n("custom")};export{r as default};
1
+ import{get3DS2FlowProps as e}from"../../../components/ThreeDS2/components/utils.js";import t from"../../../utils/uuid.js";const o=(e,o,n,r)=>{const i=o.getComponent(n);if(!i)throw Error(`Action Element of type ${n} not found in the registry`);return new i(e,{...r,id:`${n}-${t()}`})},n=e=>(t,n,r,i)=>{const s={...i,...r,onError:i.onError,statusType:e,originalAction:r};return o(t,n,r.paymentMethodType,s)},r={redirect:(e,t,n,r)=>{const i={...r,...n,statusType:"redirect",originalAction:n};return o(e,t,"redirect",i)},threeDS2:(t,n,r,i)=>{const s="fingerprint"===r.subtype?"threeDS2DeviceFingerprint":"threeDS2Challenge",a="fingerprint"===r.subtype||i.isMDFlow?r.paymentData:r.authorisationToken,l={core:t,token:r.token,paymentData:a,onActionHandled:i.onActionHandled,on3DS2RedirectFlowComplete:i.on3DS2RedirectFlowComplete,onAdditionalDetails:i.onAdditionalDetails,onError:i.onError,isDropin:!!i.isDropin,loadingContext:i.loadingContext,clientKey:i.clientKey,paymentMethodType:i.paymentMethodType,challengeWindowSize:i.challengeWindowSize,usePasskeyIFrameAttributes:i.usePasskeyIFrameAttributes,isMDFlow:i.isMDFlow,modules:{analytics:i.modules?.analytics,resources:i.modules?.resources},...e(r.subtype,i)};return o(t,n,s,l)},voucher:n("custom"),qrCode:n("custom"),await:n("custom"),bankTransfer:n("custom"),sdk:n("custom")};export{r as default};
2
2
  //# sourceMappingURL=actionTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actionTypes.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/actionTypes.ts"],"sourcesContent":["import { get3DS2FlowProps } from '../../../components/ThreeDS2/components/utils';\nimport uuid from '../../../utils/uuid';\nimport type { StatusFromAction, ThreeDS2ActionProps, UIElement, UIElementProps } from '../../../types';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\nimport type { ThreeDS2ConfigProps } from '../../../types';\nimport type { ActionHandlerConfig } from './types';\n\nconst createComponent = (core: ICore, registry: IRegistry, componentType: string, props: ActionHandlerConfig | ThreeDS2ConfigProps): UIElement => {\n const Element = registry.getComponent(componentType);\n\n if (!Element) {\n throw Error(`Action Element of type ${componentType} not found in the registry`);\n }\n\n const element = new Element(core, { ...props, id: `${componentType}-${uuid()}` });\n return element;\n};\n\nconst getActionHandler = (statusType: StatusFromAction) => {\n return (core: ICore, registry: IRegistry, action: PaymentAction, props: UIElementProps): UIElement => {\n const config: ActionHandlerConfig = {\n ...props,\n ...action,\n onError: props.onError,\n statusType,\n originalAction: action\n };\n\n return createComponent(core, registry, action.paymentMethodType, config);\n };\n};\n\nconst actionTypes = {\n redirect: (core: ICore, registry, action: PaymentAction, props: UIElementProps): UIElement => {\n const config: ActionHandlerConfig = {\n ...props,\n ...action,\n statusType: 'redirect',\n originalAction: action\n };\n\n return createComponent(core, registry, 'redirect', config);\n },\n\n threeDS2: (core: ICore, registry, action: PaymentAction, props: ThreeDS2ActionProps): UIElement => {\n const componentType = action.subtype === 'fingerprint' ? 'threeDS2DeviceFingerprint' : 'threeDS2Challenge';\n\n /**\n * NOTE: the isMDFlow prop comes from the options object, added within the MDFlow when it calls createFromAction(action, options) to initiate a 3DS2 component\n * It replaces the useOriginalFlow config prop that the MDFlow used to pass when directly initiating the threeDS2Fingerprint or threeDS2Challenge components\n */\n const paymentData = action.subtype === 'fingerprint' || props.isMDFlow ? action.paymentData : action.authorisationToken;\n\n const config: ThreeDS2ConfigProps = {\n // Props common to both flows\n core,\n token: action.token,\n paymentData,\n onActionHandled: props.onActionHandled,\n on3DS2RedirectFlowComplete: props.on3DS2RedirectFlowComplete, // NOTE: We only ever expect props.on3DS2RedirectFlowComplete to be defined for the MDFlow\n onAdditionalDetails: props.onAdditionalDetails, // Needed to prevent regression in v6.24.0 re. supporting onAdditionalDetails being directly set on Card component (in v7 we will *not* allow this, & this line can be removed)\n onError: props.onError,\n isDropin: !!props.isDropin,\n loadingContext: props.loadingContext,\n clientKey: props.clientKey,\n paymentMethodType: props.paymentMethodType,\n challengeWindowSize: props.challengeWindowSize, // always pass challengeWindowSize in case it's been set directly in the handleAction config object\n isMDFlow: props.isMDFlow,\n modules: {\n analytics: props.modules?.analytics,\n resources: props.modules?.resources\n },\n\n // Props unique to a particular flow\n ...get3DS2FlowProps(action.subtype, props)\n };\n\n return createComponent(core, registry, componentType, config);\n },\n\n voucher: getActionHandler('custom'),\n qrCode: getActionHandler('custom'),\n await: getActionHandler('custom'),\n bankTransfer: getActionHandler('custom'),\n sdk: getActionHandler('custom')\n} as const;\n\nexport default actionTypes;\n"],"names":["createComponent","core","registry","componentType","props","Element","getComponent","Error","id","uuid","getActionHandler","statusType","action","config","onError","originalAction","paymentMethodType","actionTypes","redirect","threeDS2","subtype","paymentData","isMDFlow","authorisationToken","token","onActionHandled","on3DS2RedirectFlowComplete","onAdditionalDetails","isDropin","loadingContext","clientKey","challengeWindowSize","modules","analytics","resources","get3DS2FlowProps","voucher","qrCode","await","bankTransfer","sdk"],"mappings":"0HASA,MAAMA,EAAkB,CAACC,EAAaC,EAAqBC,EAAuBC,KAC9E,MAAMC,EAAUH,EAASI,aAAaH,GAEtC,IAAKE,EACD,MAAME,MAAM,0BAA0BJ,+BAI1C,OADgB,IAAIE,EAAQJ,EAAM,IAAKG,EAAOI,GAAI,GAAGL,KAAiBM,SAIpEC,EAAoBC,GACf,CAACV,EAAaC,EAAqBU,EAAuBR,KAC7D,MAAMS,EAA8B,IAC7BT,KACAQ,EACHE,QAASV,EAAMU,QACfH,aACAI,eAAgBH,GAGpB,OAAOZ,EAAgBC,EAAMC,EAAUU,EAAOI,kBAAmBH,IAInEI,EAAc,CAChBC,SAAU,CAACjB,EAAaC,EAAUU,EAAuBR,KACrD,MAAMS,EAA8B,IAC7BT,KACAQ,EACHD,WAAY,WACZI,eAAgBH,GAGpB,OAAOZ,EAAgBC,EAAMC,EAAU,WAAYW,IAGvDM,SAAU,CAAClB,EAAaC,EAAUU,EAAuBR,KACrD,MAAMD,EAAmC,gBAAnBS,EAAOQ,QAA4B,4BAA8B,oBAMjFC,EAAiC,gBAAnBT,EAAOQ,SAA6BhB,EAAMkB,SAAWV,EAAOS,YAAcT,EAAOW,mBAE/FV,EAA8B,CAEhCZ,OACAuB,MAAOZ,EAAOY,MACdH,cACAI,gBAAiBrB,EAAMqB,gBACvBC,2BAA4BtB,EAAMsB,2BAClCC,oBAAqBvB,EAAMuB,oBAC3Bb,QAASV,EAAMU,QACfc,WAAYxB,EAAMwB,SAClBC,eAAgBzB,EAAMyB,eACtBC,UAAW1B,EAAM0B,UACjBd,kBAAmBZ,EAAMY,kBACzBe,oBAAqB3B,EAAM2B,oBAC3BT,SAAUlB,EAAMkB,SAChBU,QAAS,CACLC,UAAW7B,EAAM4B,SAASC,UAC1BC,UAAW9B,EAAM4B,SAASE,cAI3BC,EAAiBvB,EAAOQ,QAAShB,IAGxC,OAAOJ,EAAgBC,EAAMC,EAAUC,EAAeU,IAG1DuB,QAAS1B,EAAiB,UAC1B2B,OAAQ3B,EAAiB,UACzB4B,MAAO5B,EAAiB,UACxB6B,aAAc7B,EAAiB,UAC/B8B,IAAK9B,EAAiB"}
1
+ {"version":3,"file":"actionTypes.js","sources":["../../../../../src/core/ProcessResponse/PaymentAction/actionTypes.ts"],"sourcesContent":["import { get3DS2FlowProps } from '../../../components/ThreeDS2/components/utils';\nimport uuid from '../../../utils/uuid';\nimport type { StatusFromAction, ThreeDS2ActionProps, UIElement, UIElementProps } from '../../../types';\nimport type { PaymentAction } from '../../../types/global-types';\nimport type { IRegistry } from '../../core.registry';\nimport type { ICore } from '../../types';\nimport type { ThreeDS2ConfigProps } from '../../../types';\nimport type { ActionHandlerConfig } from './types';\n\nconst createComponent = (core: ICore, registry: IRegistry, componentType: string, props: ActionHandlerConfig | ThreeDS2ConfigProps): UIElement => {\n const Element = registry.getComponent(componentType);\n\n if (!Element) {\n throw Error(`Action Element of type ${componentType} not found in the registry`);\n }\n\n const element = new Element(core, { ...props, id: `${componentType}-${uuid()}` });\n return element;\n};\n\nconst getActionHandler = (statusType: StatusFromAction) => {\n return (core: ICore, registry: IRegistry, action: PaymentAction, props: UIElementProps): UIElement => {\n const config: ActionHandlerConfig = {\n ...props,\n ...action,\n onError: props.onError,\n statusType,\n originalAction: action\n };\n\n return createComponent(core, registry, action.paymentMethodType, config);\n };\n};\n\nconst actionTypes = {\n redirect: (core: ICore, registry, action: PaymentAction, props: UIElementProps): UIElement => {\n const config: ActionHandlerConfig = {\n ...props,\n ...action,\n statusType: 'redirect',\n originalAction: action\n };\n\n return createComponent(core, registry, 'redirect', config);\n },\n\n threeDS2: (core: ICore, registry, action: PaymentAction, props: ThreeDS2ActionProps): UIElement => {\n const componentType = action.subtype === 'fingerprint' ? 'threeDS2DeviceFingerprint' : 'threeDS2Challenge';\n\n /**\n * NOTE: the isMDFlow prop comes from the options object, added within the MDFlow when it calls createFromAction(action, options) to initiate a 3DS2 component\n * It replaces the useOriginalFlow config prop that the MDFlow used to pass when directly initiating the threeDS2Fingerprint or threeDS2Challenge components\n */\n const paymentData = action.subtype === 'fingerprint' || props.isMDFlow ? action.paymentData : action.authorisationToken;\n\n const config: ThreeDS2ConfigProps = {\n // Props common to both flows\n core,\n token: action.token,\n paymentData,\n onActionHandled: props.onActionHandled,\n on3DS2RedirectFlowComplete: props.on3DS2RedirectFlowComplete, // NOTE: We only ever expect props.on3DS2RedirectFlowComplete to be defined for the MDFlow\n onAdditionalDetails: props.onAdditionalDetails, // Needed to prevent regression in v6.24.0 re. supporting onAdditionalDetails being directly set on Card component (in v7 we will *not* allow this, & this line can be removed)\n onError: props.onError,\n isDropin: !!props.isDropin,\n loadingContext: props.loadingContext,\n clientKey: props.clientKey,\n paymentMethodType: props.paymentMethodType,\n challengeWindowSize: props.challengeWindowSize, // always pass challengeWindowSize in case it's been set directly in the handleAction config object\n usePasskeyIFrameAttributes: props.usePasskeyIFrameAttributes,\n isMDFlow: props.isMDFlow,\n modules: {\n analytics: props.modules?.analytics,\n resources: props.modules?.resources\n },\n\n // Props unique to a particular flow\n ...get3DS2FlowProps(action.subtype, props)\n };\n\n return createComponent(core, registry, componentType, config);\n },\n\n voucher: getActionHandler('custom'),\n qrCode: getActionHandler('custom'),\n await: getActionHandler('custom'),\n bankTransfer: getActionHandler('custom'),\n sdk: getActionHandler('custom')\n} as const;\n\nexport default actionTypes;\n"],"names":["createComponent","core","registry","componentType","props","Element","getComponent","Error","id","uuid","getActionHandler","statusType","action","config","onError","originalAction","paymentMethodType","actionTypes","redirect","threeDS2","subtype","paymentData","isMDFlow","authorisationToken","token","onActionHandled","on3DS2RedirectFlowComplete","onAdditionalDetails","isDropin","loadingContext","clientKey","challengeWindowSize","usePasskeyIFrameAttributes","modules","analytics","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,OAAOJ,EAAgBC,EAAMC,EAAUC,EAAeU,IAG1DwB,QAAS3B,EAAiB,UAC1B4B,OAAQ5B,EAAiB,UACzB6B,MAAO7B,EAAiB,UACxB8B,aAAc9B,EAAiB,UAC/B+B,IAAK/B,EAAiB"}
@@ -1,2 +1,2 @@
1
- function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.41.1","LIBRARY_VERSION is not defined"),t=e("esm","BUNDLE_TYPE is not defined"),r=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","donation","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],i=6e4;var d=function(e){return e.WEB="web",e}({});const a="web";var s=function(e){return e.NATIVE="nativeComponent",e.GENERIC="genericComponent",e}({});export{d as CHANNEL,i as DEFAULT_HTTP_TIMEOUT,n as FALLBACK_CONTEXT,r as GENERIC_OPTIONS,t as LIBRARY_BUNDLE_TYPE,o as LIBRARY_VERSION,s as PAYMENT_METHOD_BEHAVIOR,a as PLATFORM};
1
+ function e(e,n){if(null==e)throw new Error(n);return e}const n="https://checkoutshopper-live.adyen.com/checkoutshopper/",o=e("6.42.0","LIBRARY_VERSION is not defined"),t=e("esm","BUNDLE_TYPE is not defined"),r=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","donation","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],i=6e4;var d=function(e){return e.WEB="web",e}({});const a="web";var s=function(e){return e.NATIVE="nativeComponent",e.GENERIC="genericComponent",e}({});export{d as CHANNEL,i as DEFAULT_HTTP_TIMEOUT,n as FALLBACK_CONTEXT,r as GENERIC_OPTIONS,t as LIBRARY_BUNDLE_TYPE,o as LIBRARY_VERSION,s as PAYMENT_METHOD_BEHAVIOR,a as PLATFORM};
2
2
  //# sourceMappingURL=config.js.map
@@ -1842,6 +1842,12 @@ interface ThreeDS2Configuration extends UIElementProps {
1842
1842
  token?: string;
1843
1843
  type?: string;
1844
1844
  challengeWindowSize?: ChallengeWindowSize;
1845
+ /**
1846
+ * @internal Visa Passkey only. Requires isMDFlow.
1847
+ * When true, adds sandbox and allow attributes to the challenge iframe
1848
+ * for WebAuthn credential creation/retrieval.
1849
+ */
1850
+ usePasskeyIFrameAttributes?: boolean;
1845
1851
  }
1846
1852
  interface ThreeDS2DeviceFingerprintConfiguration extends ThreeDS2Configuration {
1847
1853
  clientKey?: string;
@@ -1957,6 +1963,12 @@ type ThreeDS2ConfigProps = {
1957
1963
  readonly clientKey: string;
1958
1964
  readonly paymentMethodType: string;
1959
1965
  readonly challengeWindowSize?: ChallengeWindowSize;
1966
+ /**
1967
+ * @internal Visa Passkey only. Requires isMDFlow.
1968
+ * When true, adds sandbox and allow attributes to the challenge iframe
1969
+ * for WebAuthn credential creation/retrieval.
1970
+ */
1971
+ readonly usePasskeyIFrameAttributes?: boolean;
1960
1972
  readonly isMDFlow?: boolean;
1961
1973
  readonly modules?: {
1962
1974
  readonly analytics?: IAnalytics;
@@ -1967,7 +1979,7 @@ type ThreeDS2ConfigProps = {
1967
1979
  readonly elementRef?: UIElement;
1968
1980
  readonly i18n?: Language;
1969
1981
  };
1970
- type ThreeDS2ActionProps = CardConfiguration & Pick<ThreeDS2ConfigProps, 'isMDFlow' | 'on3DS2RedirectFlowComplete'>;
1982
+ type ThreeDS2ActionProps = CardConfiguration & Pick<ThreeDS2ConfigProps, 'isMDFlow' | 'on3DS2RedirectFlowComplete' | 'usePasskeyIFrameAttributes'>;
1971
1983
 
1972
1984
  type CoreCallbacks$1 = Pick<CoreConfiguration, 'beforeRedirect' | 'beforeSubmit' | 'onSubmit' | 'onAdditionalDetails' | 'onPaymentFailed' | 'onPaymentCompleted' | 'onChange' | 'onActionHandled' | 'onError' | 'onEnterKeyPressed'>;
1973
1985
  type CustomCardConfiguration = CoreCallbacks$1 & {
@@ -6374,6 +6386,7 @@ type NonMappedPaymentMethodsMap = {
6374
6386
  [key: string]: any;
6375
6387
  };
6376
6388
  type PaymentMethodsConfiguration = PaymentMethodsConfigurationMap & PaymentActionTypesMap & NonMappedPaymentMethodsMap;
6389
+ type PaymentMethodDisplayMode = 'fastlane' | 'instant' | 'stored' | 'regular';
6377
6390
  type InstantPaymentTypes = 'paywithgoogle' | 'googlepay' | 'applepay';
6378
6391
  interface DropinConfiguration extends UIElementProps {
6379
6392
  /**
@@ -8723,4 +8736,4 @@ declare namespace AdyenCheckout {
8723
8736
  }
8724
8737
 
8725
8738
  export { ANCVElement as ANCV, AchElement as Ach, AddressElement as Address, AdyenCheckout, AdyenCheckoutError, Affirm, AfterPay, AfterPayB2B, AmazonPayElement as AmazonPay, ApplePayElement as ApplePay, Atome, BacsElement as BacsDirectDebit, BancontactElement as Bancontact, BankTransferElement as BankTransfer, BCMCMobileElement as BcmcMobile, BillDeskOnlineElement as BillDeskOnline, BillDeskWalletElement as BillDeskWallet, BlikElement as Blik, BoletoElement as Boleto, CardElement as Card, CashAppPay, ClickToPayElement as ClickToPay, Core, CustomCard, DokuElement as Doku, DonationElement as Donation, DotpayElement as Dotpay, DragonpayElement as Dragonpay, DropinElement as Dropin, DuitNowElement as DuitNow, EPSElement as EPS, EcontextElement as Econtext, FacilyPay10x as FacilPay10x, FacilyPay12x as FacilPay12x, FacilyPay3x as FacilPay3x, FacilyPay4x as FacilPay4x, FacilyPay6x as FacilPay6x, Fastlane, FastlaneSDK, GiftcardElement as Giftcard, GiropayElement as Giropay, GooglePay, Iris, IrisMode, KlarnaPayments as Klarna, MBWayElement as MBWay, MealVoucherFRElement as MealVoucherFR, MolPayEBankingMYElement as MolPayEBankingMY, MolPayEBankingTHElement as MolPayEBankingTH, MolPayEbankingVNElement as MolPayEBankingVN, MultibancoElement as Multibanco, OnlineBankingCZElement as OnlineBankingCZ, OnlineBankingFI, OnlineBankingINElement as OnlineBankingIN, OnlineBankingPL, OnlineBankingSKElement as OnlineBankingSK, OxxoElement as Oxxo, PayByBank, PayByBankPixElement as PayByBankPix, PayByBankUS, PayMeElement as PayMe, PayNowElement as PayNow, PaypalElement as PayPal, PayToElement as PayTo, PayuNetCashcardElement as PayuCashcard, PayuNetBankingElement as PayuNetBanking, PersonalDetailsElement as PersonalDetails, PixElement as Pix, PreAuthorizedDebitCanada, PromptPayElement as PromptPay, RatePay, RatePayDirectDebit, RedirectElement as Redirect, Riverty, SepaElement as SepaDirectDebit, SwishElement as Swish, ThreeDS2Challenge, ThreeDS2DeviceFingerprint, TrustlyElement as Trustly, TwintElement as Twint, UIElement, UPI, VippsElement as Vipps, WalletINElement as WalletIN, WeChatPayElement as WeChat, index_d as components, initializeFastlane };
8726
- export type { ANCVConfiguration, ANCVDataState, AchConfiguration, AchPlaceholders, ActionDescriptionType, ActionHandledReturnObject, AdditionalDetailsActions, AdditionalDetailsData, AddressData, AddressField, AmazonPayBackendConfiguration, AmazonPayButtonProps, AmazonPayButtonSettings, AmazonPayComponentProps, AmazonPayConfiguration, AmazonPayElementData, AmazonWindowObject, App, ApplePayButtonStyle, ApplePayButtonType, ApplePayConfiguration, ApplePayElementData, ApplePayPaymentAuthorizationResult, ApplePayPaymentOrderDetails, ApplePaySessionRequest, ApplePayWebConfiguration, AwaitComponentProps, AwaitConfiguration, BankDetailsSchema, BankTransferConfiguration, BankTransferSchema, BankTransferState, BeforeSubmitActions, BinLookupResponse, BinLookupResponseRaw, BoletoConfiguration, BoletoElementProps, BoletoInputDataState, BoletoInputErrorState, BoletoInputValidState, BrandConfiguration, BrandObject, BrowserInfo, CReqData, CardAllValidData, CardAutoCompleteData, CardBackendConfiguration, CardBinLookupData, CardBinValueData, CardBrandData, CardBrandsConfiguration, CardConfigSuccessData, CardConfiguration, CardElementData, CardErrorData, CardFieldValidData, CardFocusData, CardLoadData, CardPlaceholders, CashAppPayConfiguration, CashAppPayElementData, CashAppPayEventData, ChallengeData, ChallengeResolveData, ChallengeWindowSize, ChangeActionOptions, ChangePaymentDetailsButtonProps, ChargeAmount, CheckoutAdvancedFlowResponse, CheckoutDetailsRequest, CheckoutSession, CheckoutSessionConfig, ClickToPayConfiguration, ClickToPayPaymentData, ClickToPayProps, ClickToPayScheme, CommonVoucherProps, ComponentFocusObject, ComponentMethodsRef, CoreConfiguration, CoreModules, Currency, CustomCardConfiguration, CustomTranslations, DecodeObject, DeliverySpecifications, DokuVoucherResultProps, DonationCampaign, DonationCampaignOptions, DonationConfiguration, DonationOptions, DonationProps, DragonpayConfiguraton, DragonpayInputData, DragonpayInputIssuerItem, DragonpayInputProps, DragonpayVoucherResultProps, DropinComponentProps, DropinComponentState, DropinConfiguration, DropinStatus, DropinStatusProps, DualBrandButtons, DualBrandSelectElement, DualBrandingChangeHandler, EcontextConfiguration, EcontextInputSchema, EcontextVoucherResultProps, ErrorCodeObject, ExtendedMerchantInfo, FastlaneAddress, FastlaneAuthenticatedCustomerResult, FastlaneConfiguration, FastlaneConsentRenderState, FastlaneData, FastlaneOptions, FastlanePaymentMethodConfiguration, FastlaneProfile, FastlaneSDKConfiguration, FastlaneShipping, FastlaneShippingAddressSelectorResult, FastlaneSignupConfiguration, FastlaneWindowInstance, FieldsetVisibility, FingerPrintData, FingerprintResolveData, FundingSource, FundingSourceKeys, GiftCardBalanceCheckErrorType, GiftCardConfiguration, GiftCardElementData, GiftCardValidationError, GooglePayConfiguration, GooglePaymentDataRequest, ICore, IDropin, InstantPaymentTypes, Intent, IrisConfiguration, IrisData, IrisState, IssuerListConfiguration, IssuerListData, KlarnaAction, KlarnaAdditionalDetailsData, KlarnaComponentRef, KlarnaConfiguration, KlarnaSdkData, KlarnaWidgetAuthorizeResponse, KlarnaWidgetProps, LedgerCurrencies, MandateFrequencyType, MandateType, OnChangeData, OpenInvoiceActiveFieldsets, OpenInvoiceConfiguration, OpenInvoiceFieldsetsRefs, OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError, OpenInvoiceStateValid, OpenInvoiceVisibility, Order, OrderButtonProps, OrderStatus, PayPalConfiguration, PayToConfiguration, PayToData, PayToPlaceholdersType, PayloadJSON, PaymentAction, PaymentActionsType, PaymentAmount, PaymentCompletedData, PaymentData, PaymentFailedData, PaymentMethodBrand, PaymentMethodData, PaymentMethodGroup, PaymentMethodOptions, PaymentMethods, PaymentMethodsConfiguration, PaymentMethodsRequestData, PaymentMethodsResponse, PaymentResponseData, PersonalDetailsSchema, PixConfiguration, PixElementData, PostMsgParseErrorObject, PreAuthorizedDebitCanadaConfiguration, PreAuthorizedDebitCanadaPlaceholders, ProcessedPaymentStatusResponse, QRLoaderConfiguration, RawPaymentMethod, RawPaymentResponse, RawPaymentStatusResponse, RawStoredPaymentMethod, RecurringMetadata, RedirectConfiguration, Region, ResultCode, ResultObject, ResultValue, SepaConfiguration, SepaElementData, SessionsResponse, SignOutButtonProps, SocialSecurityMode, StatusFromAction, SubmitActions, SubmitData, SupportedLocale, SupportedPayPalFundingSources, ThreeDS2ActionProps, ThreeDS2ChallengeConfiguration, ThreeDS2ConfigProps, ThreeDS2DeviceFingerprintConfiguration, ThreeDS2FingerprintResponse, ThreeDS2FlowObject, ThreeDS2FlowProps, ThreeDS2Token, UIElementProps, UIElementStatus, UPIAppList, UPIConfiguration, UpdateAmazonCheckoutSessionRequest, UpiMode, UpiPaymentData, UpiType, ValidationError, VoucherConfiguration, VoucherDetail, VoucherProps, balanceCheckResponseType, onBalanceCheckCallbackType, onOrderCancelData, onOrderCancelInternalCallback, onOrderCancelType, onOrderRequestCallbackType, onOrderUpdatedCallbackType, onRequiringConfirmationCallbackType };
8739
+ export type { ANCVConfiguration, ANCVDataState, AchConfiguration, AchPlaceholders, ActionDescriptionType, ActionHandledReturnObject, AdditionalDetailsActions, AdditionalDetailsData, AddressData, AddressField, AmazonPayBackendConfiguration, AmazonPayButtonProps, AmazonPayButtonSettings, AmazonPayComponentProps, AmazonPayConfiguration, AmazonPayElementData, AmazonWindowObject, App, ApplePayButtonStyle, ApplePayButtonType, ApplePayConfiguration, ApplePayElementData, ApplePayPaymentAuthorizationResult, ApplePayPaymentOrderDetails, ApplePaySessionRequest, ApplePayWebConfiguration, AwaitComponentProps, AwaitConfiguration, BankDetailsSchema, BankTransferConfiguration, BankTransferSchema, BankTransferState, BeforeSubmitActions, BinLookupResponse, BinLookupResponseRaw, BoletoConfiguration, BoletoElementProps, BoletoInputDataState, BoletoInputErrorState, BoletoInputValidState, BrandConfiguration, BrandObject, BrowserInfo, CReqData, CardAllValidData, CardAutoCompleteData, CardBackendConfiguration, CardBinLookupData, CardBinValueData, CardBrandData, CardBrandsConfiguration, CardConfigSuccessData, CardConfiguration, CardElementData, CardErrorData, CardFieldValidData, CardFocusData, CardLoadData, CardPlaceholders, CashAppPayConfiguration, CashAppPayElementData, CashAppPayEventData, ChallengeData, ChallengeResolveData, ChallengeWindowSize, ChangeActionOptions, ChangePaymentDetailsButtonProps, ChargeAmount, CheckoutAdvancedFlowResponse, CheckoutDetailsRequest, CheckoutSession, CheckoutSessionConfig, ClickToPayConfiguration, ClickToPayPaymentData, ClickToPayProps, ClickToPayScheme, CommonVoucherProps, ComponentFocusObject, ComponentMethodsRef, CoreConfiguration, CoreModules, Currency, CustomCardConfiguration, CustomTranslations, DecodeObject, DeliverySpecifications, DokuVoucherResultProps, DonationCampaign, DonationCampaignOptions, DonationConfiguration, DonationOptions, DonationProps, DragonpayConfiguraton, DragonpayInputData, DragonpayInputIssuerItem, DragonpayInputProps, DragonpayVoucherResultProps, DropinComponentProps, DropinComponentState, DropinConfiguration, DropinStatus, DropinStatusProps, DualBrandButtons, DualBrandSelectElement, DualBrandingChangeHandler, EcontextConfiguration, EcontextInputSchema, EcontextVoucherResultProps, ErrorCodeObject, ExtendedMerchantInfo, FastlaneAddress, FastlaneAuthenticatedCustomerResult, FastlaneConfiguration, FastlaneConsentRenderState, FastlaneData, FastlaneOptions, FastlanePaymentMethodConfiguration, FastlaneProfile, FastlaneSDKConfiguration, FastlaneShipping, FastlaneShippingAddressSelectorResult, FastlaneSignupConfiguration, FastlaneWindowInstance, FieldsetVisibility, FingerPrintData, FingerprintResolveData, FundingSource, FundingSourceKeys, GiftCardBalanceCheckErrorType, GiftCardConfiguration, GiftCardElementData, GiftCardValidationError, GooglePayConfiguration, GooglePaymentDataRequest, ICore, IDropin, InstantPaymentTypes, Intent, IrisConfiguration, IrisData, IrisState, IssuerListConfiguration, IssuerListData, KlarnaAction, KlarnaAdditionalDetailsData, KlarnaComponentRef, KlarnaConfiguration, KlarnaSdkData, KlarnaWidgetAuthorizeResponse, KlarnaWidgetProps, LedgerCurrencies, MandateFrequencyType, MandateType, OnChangeData, OpenInvoiceActiveFieldsets, OpenInvoiceConfiguration, OpenInvoiceFieldsetsRefs, OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError, OpenInvoiceStateValid, OpenInvoiceVisibility, Order, OrderButtonProps, OrderStatus, PayPalConfiguration, PayToConfiguration, PayToData, PayToPlaceholdersType, PayloadJSON, PaymentAction, PaymentActionsType, PaymentAmount, PaymentCompletedData, PaymentData, PaymentFailedData, PaymentMethodBrand, PaymentMethodData, PaymentMethodDisplayMode, PaymentMethodGroup, PaymentMethodOptions, PaymentMethods, PaymentMethodsConfiguration, PaymentMethodsRequestData, PaymentMethodsResponse, PaymentResponseData, PersonalDetailsSchema, PixConfiguration, PixElementData, PostMsgParseErrorObject, PreAuthorizedDebitCanadaConfiguration, PreAuthorizedDebitCanadaPlaceholders, ProcessedPaymentStatusResponse, QRLoaderConfiguration, RawPaymentMethod, RawPaymentResponse, RawPaymentStatusResponse, RawStoredPaymentMethod, RecurringMetadata, RedirectConfiguration, Region, ResultCode, ResultObject, ResultValue, SepaConfiguration, SepaElementData, SessionsResponse, SignOutButtonProps, SocialSecurityMode, StatusFromAction, SubmitActions, SubmitData, SupportedLocale, SupportedPayPalFundingSources, ThreeDS2ActionProps, ThreeDS2ChallengeConfiguration, ThreeDS2ConfigProps, ThreeDS2DeviceFingerprintConfiguration, ThreeDS2FingerprintResponse, ThreeDS2FlowObject, ThreeDS2FlowProps, ThreeDS2Token, UIElementProps, UIElementStatus, UPIAppList, UPIConfiguration, UpdateAmazonCheckoutSessionRequest, UpiMode, UpiPaymentData, UpiType, ValidationError, VoucherConfiguration, VoucherDetail, VoucherProps, balanceCheckResponseType, onBalanceCheckCallbackType, onOrderCancelData, onOrderCancelInternalCallback, onOrderCancelType, onOrderRequestCallbackType, onOrderUpdatedCallbackType, onRequiringConfirmationCallbackType };
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import n from"./PaymentMethod/PaymentMethodList.js";import o from"./status/index.js";import a from"../../../core/Services/order-status.js";import{sanitizeOrder as r}from"../../internal/UIElement/utils.js";import i from"../../../core/Errors/AdyenCheckoutError.js";import d from"../../internal/Button/Button.js";import{AnalyticsInfoEvent as h,UiTarget as l,InfoEventType as p}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{DropinSuccessState as c}from"./DropinSuccessState.js";function m(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function y(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),n.forEach(function(e){m(t,e,s[e])})}return t}function u(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class P extends t{componentDidMount(){this.prepareDropinData()}componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}render(){const{elements:t,fastlanePaymentElement:a,instantPaymentElements:r,storedPaymentElements:i,status:h,activePaymentMethod:l,showDefaultPaymentMethodList:p}=this.state,m="loading"===h.type,y="redirect"===h.type,u=!!((null==t?void 0:t.length)||(null==r?void 0:r.length)||(null==i?void 0:i.length));switch(h.type){case"success":var P;return e(c,{message:null===(P=h.props)||void 0===P?void 0:P.message});case"error":var M;return e(o.Error,{message:null===(M=h.props)||void 0===M?void 0:M.message});case"custom":var v,f;return null===(f=h.props)||void 0===f||null===(v=f.component)||void 0===v?void 0:v.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${h.type}`},y&&h.props.component&&h.props.component.render(),m&&h.props&&h.props.component&&h.props.component.render(),!p&&e(s,null,e(n,{isLoading:m,paymentMethods:a,activePaymentMethod:l,onSelect:this.handleOnSelectPaymentMethod,openFirstPaymentMethod:!0,showRadioButton:this.props.showRadioButton}),u&&e(d,{classNameModifiers:["dropin-show-paymentmethods"],variant:"link",inline:!0,label:"Other payment methods",onClick:this.onShowDefaultPaymentMethodListClick})),u&&p&&e(n,{isLoading:m||y,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:t,instantPaymentMethods:r,storedPaymentMethods:i,activePaymentMethod:l,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openPaymentMethod:this.props.openPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}constructor(...t){super(...t),m(this,"state",{elements:[],fastlanePaymentElement:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{},showDefaultPaymentMethodList:!0}),m(this,"prepareDropinData",()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[n,o,r,i]=this.props.onCreateElements(),d=t?a({clientKey:e,loadingContext:s},t):null;Promise.all([n,o,r,i,d]).then(([t,e,s,n,o])=>{this.setState({orderStatus:o,elements:e,instantPaymentElements:s,storedPaymentElements:t,fastlanePaymentElement:n,showDefaultPaymentMethodList:0===n.length}),this.setStatus("ready"),this.props.onElementsCreated([...s,...t,...e,...n])}),this.onOrderCancel=this.getOnOrderCancel()}),m(this,"setStatus",(t,e={})=>{this.setState({status:{type:t,props:e}})}),m(this,"setActivePaymentMethod",t=>{t!==this.state.activePaymentMethod&&(this.setState(e=>({activePaymentMethod:t,cachedPaymentMethods:u(y({},e.cachedPaymentMethods),{[t._id]:!0})})),this.state.cachedPaymentMethods[t._id]&&t.activate())}),m(this,"handleOnSelectPaymentMethod",t=>{const{activePaymentMethod:e}=this.state;var s,n;(this.setActivePaymentMethod(t),e&&e._id!==t._id||!e)&&(null===(s=(n=this.props).onSelect)||void 0===s||s.call(n,t))}),m(this,"handleDisableStoredPaymentMethod",t=>{this.setState({isDisabling:!0}),new Promise((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s)).then(()=>{this.setState(e=>({storedPaymentElements:e.storedPaymentElements.filter(e=>e._id!==t._id)})),this.setState({isDisabling:!1})}).catch(()=>{this.setState({isDisabling:!1})})}),m(this,"onShowDefaultPaymentMethodListClick",()=>{var t;this.setState({showDefaultPaymentMethodList:!0});const e=new h({type:p.clicked,target:l.otherPaymentMethodButton,component:"dropin"});null===(t=this.props.modules)||void 0===t||t.analytics.sendAnalytics(e)}),m(this,"getOnOrderCancel",()=>this.props.onOrderCancel?t=>{const e=r(t.order);new Promise((t,s)=>{this.props.onOrderCancel({order:e},{resolve:t,reject:s})}).then(({amount:t})=>this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null,t)).catch(t=>{throw new i("NETWORK_ERROR",t)})}:this.props.session?t=>{this.props.session.cancelOrder(t).then(()=>this.props.core.update({order:null})).catch(t=>{console.error(t),this.setStatus((null==t?void 0:t.message)||"error")})}:null),m(this,"onOrderCancel",void 0)}}export{P as DropinComponent,P as default};
1
+ import{Component as t,createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import o from"./PaymentMethod/PaymentMethodList.js";import n from"./status/index.js";import a from"../../../core/Services/order-status.js";import{sanitizeOrder as r}from"../../internal/UIElement/utils.js";import i from"../../../core/Errors/AdyenCheckoutError.js";import d from"../../internal/Button/Button.js";import h from"../elements/splitPaymentMethods.js";import{createAvailablePaymentsList as l,createUnavailablePaymentsList as p}from"../utils/paymentMethodsAnalytics.js";import{AnalyticsInfoEvent as m,InfoEventType as c,UiTarget as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{DropinSuccessState as u}from"./DropinSuccessState.js";function P(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function M(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},o=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),o.forEach(function(e){P(t,e,s[e])})}return t}function v(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class f extends t{componentDidMount(){this.prepareDropinData()}componentDidUpdate(t,e){e.status.type!==this.state.status.type&&this.state.activePaymentMethod&&this.state.activePaymentMethod.setStatus(this.state.status.type),"ready"===this.state.status.type&&"ready"!==e.status.type&&this.props.onReady&&this.props.onReady()}closeActivePaymentMethod(){this.setState({activePaymentMethod:null})}render(){const{elements:t,fastlanePaymentElement:a,instantPaymentElements:r,storedPaymentElements:i,status:h,activePaymentMethod:l,showDefaultPaymentMethodList:p}=this.state,m="loading"===h.type,c="redirect"===h.type,y=!!((null==t?void 0:t.length)||(null==r?void 0:r.length)||(null==i?void 0:i.length));switch(h.type){case"success":var P;return e(u,{message:null===(P=h.props)||void 0===P?void 0:P.message});case"error":var M;return e(n.Error,{message:null===(M=h.props)||void 0===M?void 0:M.message});case"custom":var v,f;return null===(f=h.props)||void 0===f||null===(v=f.component)||void 0===v?void 0:v.render();default:return e("div",{className:`adyen-checkout__dropin adyen-checkout__dropin--${h.type}`},c&&h.props.component&&h.props.component.render(),m&&h.props&&h.props.component&&h.props.component.render(),!p&&e(s,null,e(o,{isLoading:m,paymentMethods:a,activePaymentMethod:l,onSelect:this.handleOnSelectPaymentMethod,openFirstPaymentMethod:!0,showRadioButton:this.props.showRadioButton}),y&&e(d,{classNameModifiers:["dropin-show-paymentmethods"],variant:"link",inline:!0,label:"Other payment methods",onClick:this.onShowDefaultPaymentMethodListClick})),y&&p&&e(o,{isLoading:m||c,isDisablingPaymentMethod:this.state.isDisabling,paymentMethods:t,instantPaymentMethods:r,storedPaymentMethods:i,activePaymentMethod:l,order:this.props.order,orderStatus:this.state.orderStatus,onOrderCancel:this.onOrderCancel,onSelect:this.handleOnSelectPaymentMethod,openPaymentMethod:this.props.openPaymentMethod,openFirstPaymentMethod:this.props.openFirstPaymentMethod,openFirstStoredPaymentMethod:this.props.openFirstStoredPaymentMethod,onDisableStoredPaymentMethod:this.handleDisableStoredPaymentMethod,showRemovePaymentMethodButton:this.props.showRemovePaymentMethodButton,showRadioButton:this.props.showRadioButton}))}}constructor(...t){super(...t),P(this,"state",{elements:[],fastlanePaymentElement:[],instantPaymentElements:[],storedPaymentElements:[],orderStatus:null,isDisabling:!1,status:{type:"loading",props:void 0},activePaymentMethod:null,cachedPaymentMethods:{},showDefaultPaymentMethodList:!0}),P(this,"prepareDropinData",()=>{const{order:t,clientKey:e,loadingContext:s}=this.props,[o,n,r,i]=this.props.onCreateElements(),d=t?a({clientKey:e,loadingContext:s},t):null;Promise.all([o,n,r,i,d]).then(([t,e,s,o,n])=>{this.setState({orderStatus:n,elements:e,instantPaymentElements:s,storedPaymentElements:t,fastlanePaymentElement:o,showDefaultPaymentMethodList:0===o.length}),this.setStatus("ready"),this.props.onElementsCreated([...s,...t,...e,...o]),this.reportPaymentMethodList({fastlane:o,instant:s,stored:t,regular:e})}).catch(()=>{this.setStatus("error")}),this.onOrderCancel=this.getOnOrderCancel()}),P(this,"reportPaymentMethodList",t=>{try{var e;const{paymentMethods:s,storedPaymentMethods:o,instantPaymentMethods:n,fastlanePaymentMethod:a}=h(this.props.core.paymentMethodsResponse,null!==(e=this.props.instantPaymentTypes)&&void 0!==e?e:[]),r=[{displayMode:"fastlane",paymentMethods:a?[a]:[]},{displayMode:"instant",paymentMethods:n},{displayMode:"stored",paymentMethods:o},{displayMode:"regular",paymentMethods:s}],i=l(r.map(t=>t.displayMode),t,this.props.core),d=p(r,t),y=new m({type:c.PaymentListDisplayed,component:"dropin",availablePaymentMethods:i,unavailablePaymentMethods:d});this.props.core.modules.analytics.sendAnalytics(y)}catch(t){console.warn("Drop-in: failed to report payment method list analytics",t)}}),P(this,"setStatus",(t,e={})=>{this.setState({status:{type:t,props:e}})}),P(this,"setActivePaymentMethod",t=>{t!==this.state.activePaymentMethod&&(this.setState(e=>({activePaymentMethod:t,cachedPaymentMethods:v(M({},e.cachedPaymentMethods),{[t._id]:!0})})),this.state.cachedPaymentMethods[t._id]&&t.activate())}),P(this,"handleOnSelectPaymentMethod",t=>{const{activePaymentMethod:e}=this.state;var s,o;(this.setActivePaymentMethod(t),e&&e._id!==t._id||!e)&&(null===(s=(o=this.props).onSelect)||void 0===s||s.call(o,t))}),P(this,"handleDisableStoredPaymentMethod",t=>{this.setState({isDisabling:!0}),new Promise((e,s)=>this.props.onDisableStoredPaymentMethod(t.props.storedPaymentMethodId,e,s)).then(()=>{this.setState(e=>({storedPaymentElements:e.storedPaymentElements.filter(e=>e._id!==t._id)})),this.setState({isDisabling:!1})}).catch(()=>{this.setState({isDisabling:!1})})}),P(this,"onShowDefaultPaymentMethodListClick",()=>{var t;this.setState({showDefaultPaymentMethodList:!0});const e=new m({type:c.clicked,target:y.otherPaymentMethodButton,component:"dropin"});null===(t=this.props.modules)||void 0===t||t.analytics.sendAnalytics(e)}),P(this,"getOnOrderCancel",()=>this.props.onOrderCancel?t=>{const e=r(t.order);new Promise((t,s)=>{this.props.onOrderCancel({order:e},{resolve:t,reject:s})}).then(({amount:t})=>this.props.elementRef.handleAdvanceFlowPaymentMethodsUpdate(null,t)).catch(t=>{throw new i("NETWORK_ERROR",t)})}:this.props.session?t=>{this.props.session.cancelOrder(t).then(()=>this.props.core.update({order:null})).catch(t=>{console.error(t),this.setStatus((null==t?void 0:t.message)||"error")})}:null),P(this,"onOrderCancel",void 0)}}export{f as DropinComponent,f as default};
2
2
  //# sourceMappingURL=DropinComponent.js.map