@adyen/adyen-web 6.41.1 → 6.43.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 (94) hide show
  1. package/dist/cjs/adyen.css +4 -2
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +1 -1
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +15 -2
  6. package/dist/es/adyen.css +4 -2
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  9. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  10. package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js +2 -0
  11. package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
  12. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  13. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  14. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  15. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  16. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  17. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  18. package/dist/es/components/ThreeDS2/constants.js +1 -1
  19. package/dist/es/components/ThreeDS2/constants.js.map +1 -1
  20. package/dist/es/components/internal/Address/Address.js +1 -1
  21. package/dist/es/components/internal/Address/Address.js.map +1 -1
  22. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  23. package/dist/es/components/internal/Address/validate.js +1 -1
  24. package/dist/es/components/internal/Address/validate.js.map +1 -1
  25. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  26. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  27. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  28. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  29. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  30. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  31. package/dist/es/components/internal/IFrame/Iframe.js +1 -1
  32. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  33. package/dist/es/components/internal/Tag/Tag.js +2 -0
  34. package/dist/es/components/internal/Tag/Tag.js.map +1 -0
  35. package/dist/es/components/internal/Tag/Tag.module.scss.js +2 -0
  36. package/dist/es/components/internal/Tag/Tag.module.scss.js.map +1 -0
  37. package/dist/es/components/internal/Tag/TagList.js +2 -0
  38. package/dist/es/components/internal/Tag/TagList.js.map +1 -0
  39. package/dist/es/components/internal/Tag/TagList.module.scss.js +2 -0
  40. package/dist/es/components/internal/Tag/TagList.module.scss.js.map +1 -0
  41. package/dist/es/components/internal/Tag/types.js +2 -0
  42. package/dist/es/components/internal/Tag/types.js.map +1 -0
  43. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  44. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  45. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  46. package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  47. package/dist/es/core/config.js +1 -1
  48. package/dist/es/index.d.ts +15 -2
  49. package/dist/es/packages/server/translations/en-US.json.js +1 -1
  50. package/dist/es-legacy/adyen.css +4 -2
  51. package/dist/es-legacy/adyen.css.map +1 -1
  52. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  53. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  54. package/dist/es-legacy/components/Dropin/utils/paymentMethodsAnalytics.js +2 -0
  55. package/dist/es-legacy/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
  56. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  57. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  58. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  59. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  60. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  61. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  62. package/dist/es-legacy/components/ThreeDS2/constants.js +1 -1
  63. package/dist/es-legacy/components/ThreeDS2/constants.js.map +1 -1
  64. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  65. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  66. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  67. package/dist/es-legacy/components/internal/Address/validate.js +1 -1
  68. package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
  69. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  70. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  71. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  72. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  73. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  74. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  75. package/dist/es-legacy/components/internal/IFrame/Iframe.js +1 -1
  76. package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
  77. package/dist/es-legacy/components/internal/Tag/Tag.js +2 -0
  78. package/dist/es-legacy/components/internal/Tag/Tag.js.map +1 -0
  79. package/dist/es-legacy/components/internal/Tag/Tag.module.scss.js +2 -0
  80. package/dist/es-legacy/components/internal/Tag/Tag.module.scss.js.map +1 -0
  81. package/dist/es-legacy/components/internal/Tag/TagList.js +2 -0
  82. package/dist/es-legacy/components/internal/Tag/TagList.js.map +1 -0
  83. package/dist/es-legacy/components/internal/Tag/TagList.module.scss.js +2 -0
  84. package/dist/es-legacy/components/internal/Tag/TagList.module.scss.js.map +1 -0
  85. package/dist/es-legacy/components/internal/Tag/types.js +2 -0
  86. package/dist/es-legacy/components/internal/Tag/types.js.map +1 -0
  87. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  88. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  89. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  90. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  91. package/dist/es-legacy/core/config.js +1 -1
  92. package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
  93. package/package.json +6 -6
  94. package/styles/adyen.css +4 -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,gBAAiB,CAACjB,EAAMiB,iBAEhFG,EAAuBH,EAAeI,+BAA+BrB,EAAMsB,aAAaC,OAAOC,GAASpB,EAAeqB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBjC,EAAMkC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBrC,EAAMkC,kBAAkBR,GAAsBG,IAElES,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA,GAAcC,EAAqB,CAClHC,OAAQ3B,EACR4B,YAAahD,EAAMsC,KAEnBW,MAAO,IAAKC,EAA0BjC,MAAoBjB,EAAMmD,iBAChEC,WAAYC,IAKVC,EAAoB3C,EAA4BX,EAAMsC,MAAsBiB,SAC5EC,GAAoBlB,EAAKiB,SAAWD,EAAkBxC,UAAU2C,cAChEC,EAAkBxC,EAAQ,KAAA,IAAYoB,EAAMiB,QAASC,IAAqB,CAAClB,EAAMkB,IAEjFG,EAAgBC,EACjBC,IACG,MACMC,EADqBC,EACaC,OAAO,CAACC,EAAkBC,KAE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AKsE,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,KACb6B,gBAAiB,KACjBb,KAAM,CAAA,EACNwD,SAAU,OACVzF,WAAY,WACZD,eAAgB2D,EAChB9C,eAAgB,CAAA,EAChB6F,sBAAuB,OACvBC,qBAAsB"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps, AddressType } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, COUNTRY, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './Address.scss';\nimport { getAddressTypeFromLabel } from './utils';\n\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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vB5EoG,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,QAAQQ,EAAmB,IAExDG,EAAiC,CAC1CC,WAAY,CACRd,YAAa,CAACC,EAAKc,KACf,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,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M,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
+ {"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,GAA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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,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,yFACfi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AC,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,GAAIn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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,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useRef as t,useState as n,useMemo as r,useEffect as l}from"../../../../external/preact/hooks/dist/hooks.js";import s from"../../../../_virtual/index.js";import o from"./components/SelectButton.js";import a from"./components/SelectList.js";import i from"../../../../utils/uuid.js";import{keys as c}from"./constants.js";import{ARIA_ERROR_SUFFIX as u,ARIA_CONTEXT_SUFFIX as d}from"../../../../core/Errors/constants.js";import{simulateFocusScroll as m}from"../utils.js";import{useCoreContext as f}from"../../../../core/Context/CoreProvider.js";function p({items:p=[],className:g="",classNameModifiers:v=[],filterable:h=!0,readonly:y=!1,onChange:b=()=>{},onInput:k,selectedValue:w,name:I,isInvalid:L,isValid:j,placeholder:D,uniqueId:x,disabled:T,disableTextFilter:B,clearOnSelect:C,blurOnClose:E,onListToggle:N,required:S,additionalDescribedBy:$}){const{i18n:_}=f(),M=t(null),P=t(null),R=t(null),q=t(null),[O,V]=n(null),[A,F]=n(!1),[H,K]=n(null),U=r(()=>`select-${i()}`,[]),z=p.find(e=>e.id===w)||{},[G,J]=n(),[Q,W]=n(z),X=z,Y=B?p:p.filter(e=>!O||e.name.toLowerCase().includes(O.toLowerCase())),Z=[x?`${x}${L?u:d}`:null,$].filter(Boolean).join(" ")||null,ee=e=>{if(!e)return;const t=document.getElementById(`listItem-${e.id}`);m(t)},te=()=>{E&&M.current.blur(),F(!1)},ne=()=>{F(!0)},re=e=>{const t=e.currentTarget.getAttribute("data-value");return Y.find(e=>e.id==t)},le=e=>{let t;e.preventDefault(),t=e.currentTarget instanceof HTMLElement&&"option"===e.currentTarget.getAttribute("role")?re(e):Q.id&&Y.some(e=>e.id===Q.id)?Q:O?Y[0]:{id:w},t&&!t.disabled&&(b({target:{value:t.id,name:I}}),C&&J(null),te())},se=e=>{switch(e.key){case c.space:case c.enter:le(e);break;case c.arrowDown:e.preventDefault(),(()=>{if(!Y||Y.length<1)return;const e=Y.findIndex(e=>e.id===Q.id)+1,t=e<Y.length?e:0,n=Y[t];ee(n),W(n)})();break;case c.arrowUp:e.preventDefault(),(()=>{if(!Y||Y.length<1)return;const e=Y.findIndex(e=>e.id===Q.id)-1,t=e<0?Y.length-1:e,n=Y[t];ee(n),W(n)})()}};return l(()=>{A?J(null):V(null)},[A]),l(()=>{A&&h&&M.current&&M.current.focus(),N?.(A)},[A]),l(()=>{function e(e){(e.composedPath?!e.composedPath().includes(P.current):!P.current.contains(e.target))&&te()}return document.addEventListener("click",e,!1),()=>{document.removeEventListener("click",e,!1)}},[P]),l(()=>{const e=setTimeout(()=>{0===Y.length?K(_.get("select.noOptionsFound")):K(_.get("select.results",{values:{count:Y.length}}))},500);return()=>clearTimeout(e)},[A,Y.length,_]),e("div",{className:s(["adyen-checkout__dropdown",g,...v.map(e=>`adyen-checkout__dropdown--${e}`)]),ref:P},e(o,{inputText:G,id:x??null,active:Q,selected:X,filterInputRef:M,filterable:h,isInvalid:L,isValid:j,onButtonKeyDown:e=>{e.key===c.enter&&h&&A&&O?le(e):e.key===c.escape?te():![c.arrowUp,c.arrowDown,c.enter].includes(e.key)&&(e.key!==c.space||h&&A)?(e.shiftKey&&e.key===c.tab||e.key===c.tab)&&te():(e.preventDefault(),A?se(e):ne())},onInput:e=>{const t=e.target.value;J(t),V(t),A||ne(),k&&k(t)},placeholder:D,readonly:y,selectListId:U,showList:A,toggleButtonRef:R,toggleList:e=>{e.preventDefault(),A?(J(X.name),te()):(J(null),ne())},disabled:T,ariaDescribedBy:Z,required:S}),e(a,{active:Q,filteredItems:Y,onHover:e=>{e.preventDefault();const t=re(e);W(t)},onSelect:le,selected:X,selectListId:U,selectListRef:q,showList:A}),e("div",{key:G,role:"status","aria-live":"polite","aria-relevant":"additions text",className:"adyen-checkout-sr-panel--sr-only"},H))}p.defaultProps={className:"",classNameModifiers:[],filterable:!0,items:[],readonly:!1,onChange:()=>{}};export{p as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useRef as t,useState as n,useMemo as r,useEffect as l}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../../../_virtual/index.js";import s from"./components/SelectButton.js";import a from"./components/SelectList.js";import i from"../../../../utils/uuid.js";import{keys as c}from"./constants.js";import{ARIA_ERROR_SUFFIX as u,ARIA_CONTEXT_SUFFIX as d}from"../../../../core/Errors/constants.js";import{simulateFocusScroll as m}from"../utils.js";import{useCoreContext as f}from"../../../../core/Context/CoreProvider.js";function p({items:p=[],className:g="",classNameModifiers:v=[],filterable:h=!0,readonly:y=!1,onChange:b=()=>{},onInput:k,selectedValue:w,name:I,isInvalid:L,isValid:j,placeholder:D,uniqueId:x,disabled:T,disableTextFilter:_,clearOnSelect:B,blurOnClose:C,onListToggle:E,required:N,additionalDescribedBy:S}){const{i18n:$}=f(),M=t(null),P=t(null),R=t(null),q=t(null),[O,V]=n(null),[A,F]=n(!1),[H,K]=n(null),U=r(()=>`select-${i()}`,[]),z=p.find(e=>e.id===w)||{},[G,J]=n(),[Q,W]=n(z),X=z,Y=_?p:p.filter(e=>!O||e.name.toLowerCase().includes(O.toLowerCase())),Z=[x?`${x}${L?u:d}`:null,S].filter(Boolean).join(" ")||null,ee=e=>{if(!e)return;const t=document.getElementById(`listItem-${e.id}`);m(t)},te=()=>{C&&M.current.blur(),F(!1)},ne=()=>{F(!0)},re=e=>{const t=e.currentTarget.getAttribute("data-value");return Y.find(e=>e.id==t)},le=e=>{let t;e.preventDefault(),t=e.currentTarget instanceof HTMLElement&&"option"===e.currentTarget.getAttribute("role")?re(e):Q.id&&Y.some(e=>e.id===Q.id)?Q:O?Y[0]:{id:w},t&&!t.disabled&&(b({target:{value:t.id,name:I}}),B&&J(null),te())},oe=e=>{switch(e.key){case c.space:case c.enter:le(e);break;case c.arrowDown:e.preventDefault(),(()=>{if(!Y||Y.length<1)return;const e=Y.findIndex(e=>e.id===Q.id)+1,t=e<Y.length?e:0,n=Y[t];ee(n),W(n)})();break;case c.arrowUp:e.preventDefault(),(()=>{if(!Y||Y.length<1)return;const e=Y.findIndex(e=>e.id===Q.id)-1,t=e<0?Y.length-1:e,n=Y[t];ee(n),W(n)})()}};return l(()=>{A?J(null):V(null)},[A]),l(()=>{A&&h&&M.current&&M.current.focus(),E?.(A)},[A]),l(()=>{function e(e){(e.composedPath?!e.composedPath().includes(P.current):!P.current.contains(e.target))&&te()}return document.addEventListener("click",e,!1),()=>{document.removeEventListener("click",e,!1)}},[P]),l(()=>{const e=setTimeout(()=>{0===Y.length?K($.get("select.noOptionsFound")):K($.get("select.results",{values:{count:Y.length}}))},500);return()=>clearTimeout(e)},[A,Y.length,$]),e("div",{className:o(["adyen-checkout__dropdown",g,...v.map(e=>`adyen-checkout__dropdown--${e}`)]),ref:P},e(s,{inputText:G,id:x??null,active:Q,selected:X,filterInputRef:M,filterable:h,isInvalid:L,isValid:j,onButtonKeyDown:e=>{e.key===c.enter&&h&&A&&O?le(e):e.key===c.escape?te():![c.arrowUp,c.arrowDown,c.enter].includes(e.key)&&(e.key!==c.space||h&&A)?(e.shiftKey&&e.key===c.tab||e.key===c.tab)&&te():(e.preventDefault(),A?oe(e):ne())},onInput:e=>{const t=e.target.value;J(t),V(t),A||ne(),k&&k(t)},placeholder:D,readonly:y,selectListId:U,showList:A,toggleButtonRef:R,toggleList:e=>{e.preventDefault(),A?(J(X.name),te()):(J(null),ne())},disabled:T,ariaDescribedBy:Z,required:N}),e(a,{active:Q,filteredItems:Y,onHover:e=>{e.preventDefault();const t=re(e);W(t)},onSelect:le,selected:X,selectListId:U,selectListRef:q,showList:A}),e("div",{key:G,role:"status","aria-live":"polite","aria-relevant":"additions text",className:"adyen-checkout__dropdown__status"},H))}p.defaultProps={className:"",classNameModifiers:[],filterable:!0,items:[],readonly:!1,onChange:()=>{}};export{p as default};
2
2
  //# sourceMappingURL=Select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../../../../src/components/internal/FormFields/Select/Select.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport SelectButton from './components/SelectButton';\nimport SelectList from './components/SelectList';\nimport uuid from '../../../../utils/uuid';\nimport { keys } from './constants';\nimport { SelectItem, SelectProps } from './types';\nimport './Select.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { simulateFocusScroll } from '../utils';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\nfunction Select({\n items = [],\n className = '',\n classNameModifiers = [],\n filterable = true,\n readonly = false,\n onChange = () => {},\n onInput,\n selectedValue,\n name,\n isInvalid,\n isValid,\n placeholder,\n uniqueId,\n disabled,\n disableTextFilter,\n clearOnSelect,\n blurOnClose,\n onListToggle,\n required,\n additionalDescribedBy\n}: Readonly<SelectProps>) {\n const { i18n } = useCoreContext();\n const filterInputRef = useRef(null);\n const selectContainerRef = useRef(null);\n const toggleButtonRef = useRef(null);\n const selectListRef = useRef(null);\n const [textFilter, setTextFilter] = useState<string>(null);\n const [showList, setShowList] = useState<boolean>(false);\n const [statusMessage, setStatusMessage] = useState<string | null>(null);\n const selectListId: string = useMemo(() => `select-${uuid()}`, []);\n\n const active: SelectItem = items.find(i => i.id === selectedValue) || ({} as SelectItem);\n\n const [inputText, setInputText] = useState<string>();\n\n const [activeOption, setActiveOption] = useState<SelectItem>(active);\n\n const selectedOption = active;\n\n const filteredItems = disableTextFilter ? items : items.filter(item => !textFilter || item.name.toLowerCase().includes(textFilter.toLowerCase()));\n\n const suffix = isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX;\n const baseDescribedBy = uniqueId ? `${uniqueId}${suffix}` : null;\n const ariaDescribedBy = [baseDescribedBy, additionalDescribedBy].filter(Boolean).join(' ') || null;\n\n const setNextActive = () => {\n if (!filteredItems || filteredItems.length < 1) return;\n const possibleNextIndex = filteredItems.findIndex(listItem => listItem.id === activeOption.id) + 1;\n const nextIndex = possibleNextIndex < filteredItems.length ? possibleNextIndex : 0;\n const nextItem = filteredItems[nextIndex];\n scrollToItem(nextItem);\n setActiveOption(nextItem);\n };\n\n const setPreviousActive = () => {\n if (!filteredItems || filteredItems.length < 1) return;\n const possibleNextIndex = filteredItems.findIndex(listItem => listItem.id === activeOption.id) - 1;\n const nextIndex = possibleNextIndex < 0 ? filteredItems.length - 1 : possibleNextIndex;\n const nextItem = filteredItems[nextIndex];\n scrollToItem(nextItem);\n setActiveOption(nextItem);\n };\n\n const scrollToItem = (item: SelectItem) => {\n if (!item) return;\n const nextElement = document.getElementById(`listItem-${item.id}`);\n simulateFocusScroll(nextElement);\n };\n\n /**\n * Closes the selectList, empties the text filter and focuses the button element\n */\n const closeList = () => {\n //blurs the field when the list is closed, makes for a better UX for most users, needs more testing\n if (blurOnClose) {\n filterInputRef.current.blur();\n }\n setShowList(false);\n };\n\n const openList = () => {\n setShowList(true);\n };\n\n const extractItemFromEvent = (e: Event): SelectItem => {\n const value = (e.currentTarget as HTMLInputElement).getAttribute('data-value');\n return filteredItems.find(listItem => listItem.id == value);\n };\n\n /**\n * Closes the select list and fires an onChange\n * @param e - Event\n */\n const handleSelect = (e: Event) => {\n e.preventDefault();\n\n // We use a local variable here since writing and if statement is cleaner then a long ternary\n let valueToEmit;\n\n if (e.currentTarget instanceof HTMLElement && e.currentTarget.getAttribute('role') === 'option') {\n // This is the main scenario when clicking and item in the list\n // Item comes from the event\n valueToEmit = extractItemFromEvent(e);\n } else if (activeOption.id && filteredItems.some(item => item.id === activeOption.id)) {\n // This is the scenario where a user is using the keyboard to navigate\n // In the case item comes from the visually select item\n valueToEmit = activeOption;\n } else {\n // This is the scenario the user didn't select anything\n if (textFilter) {\n // if we filtering for something then select the first option\n valueToEmit = filteredItems[0];\n } else {\n // This will happen when we want to keep an already chosen option\n // If no active option we should just emit again with the value that was already selected\n valueToEmit = { id: selectedValue };\n }\n }\n\n if (valueToEmit && !valueToEmit.disabled) {\n onChange({ target: { value: valueToEmit.id, name: name } });\n\n if (clearOnSelect) setInputText(null);\n\n closeList();\n }\n };\n\n /**\n * Handles hovering and directions\n * @param e - Event\n */\n const handleHover = (e: Event) => {\n e.preventDefault();\n const item = extractItemFromEvent(e);\n setActiveOption(item);\n };\n\n /**\n * Handle keyDown events on the selectList button\n * Responsible for opening and closing the list\n * @param e - KeyboardEvent\n */\n const handleButtonKeyDown = (e: KeyboardEvent) => {\n if (e.key === keys.enter && filterable && showList && textFilter) {\n handleSelect(e);\n } else if (e.key === keys.escape) {\n // When user has focused Select button but not yet moved into Select list - close list and keep focus on the Select Button re. a11y guidelines\n // https://w3c.github.io/aria-practices/examples/disclosure/disclosure-navigation.html\n closeList();\n } else if ([keys.arrowUp, keys.arrowDown, keys.enter].includes(e.key) || (e.key === keys.space && (!filterable || !showList))) {\n e.preventDefault();\n if (!showList) {\n openList();\n } else {\n handleNavigationKeys(e);\n }\n } else if (e.shiftKey && e.key === keys.tab) {\n // Shift-Tab out of Select - close list re. a11y guidelines (above)\n closeList();\n } else if (e.key === keys.tab) {\n closeList();\n }\n };\n\n /**\n * Handles movement with navigation keys and enter\n * Navigates through the list, or select an element, or focus the filter input, or close the menu.\n * @param e - KeyDownEvent\n */\n const handleNavigationKeys = (e: KeyboardEvent) => {\n switch (e.key) {\n case keys.space:\n case keys.enter:\n handleSelect(e);\n break;\n case keys.arrowDown:\n e.preventDefault();\n setNextActive();\n break;\n case keys.arrowUp:\n e.preventDefault();\n setPreviousActive();\n break;\n default:\n }\n };\n\n /**\n * Updates the state with the current text filter value and opens the dropdown\n * @param e - KeyboardEvent\n */\n const handleTextFilter = (e: KeyboardEvent) => {\n const value: string = (e.target as HTMLInputElement).value;\n setInputText(value);\n setTextFilter(value);\n\n // Open the dropdown when user starts typing\n if (!showList) {\n openList();\n }\n\n if (onInput) {\n onInput(value);\n }\n };\n\n /**\n * Toggles the selectList and focuses in either the filter input or in the selectList button\n * @param e - Event\n */\n const toggleList = (e: Event) => {\n e.preventDefault();\n if (!showList) {\n setInputText(null);\n openList();\n } else {\n setInputText(selectedOption.name);\n closeList();\n }\n };\n\n useEffect(() => {\n if (showList) {\n setInputText(null);\n } else {\n setTextFilter(null);\n }\n }, [showList]);\n\n /**\n * Focus on the input if filterable\n */\n useEffect(() => {\n if (showList && filterable && filterInputRef.current) {\n filterInputRef.current.focus();\n }\n onListToggle?.(showList);\n }, [showList]);\n\n useEffect(() => {\n /**\n * Close the select list when clicking outside the list\n * @param e - MouseEvent\n */\n function handleClickOutside(e: MouseEvent) {\n // use composedPath so it can also check when inside a web component\n // if composedPath is not available fallback to e.target\n const clickIsOutside = e.composedPath\n ? !e.composedPath().includes(selectContainerRef.current)\n : !selectContainerRef.current.contains(e.target);\n if (clickIsOutside) {\n closeList();\n }\n }\n\n document.addEventListener('click', handleClickOutside, false);\n\n return () => {\n document.removeEventListener('click', handleClickOutside, false);\n };\n }, [selectContainerRef]);\n\n /**\n * Update status message for screen readers when no options are found\n */\n useEffect(() => {\n // Debounce to avoid announcing on every keystroke\n const SR_ANNOUNCEMENT_DELAY_MS = 500;\n const timer = setTimeout(() => {\n if (filteredItems.length === 0) {\n setStatusMessage(i18n.get('select.noOptionsFound'));\n } else {\n setStatusMessage(i18n.get('select.results', { values: { count: filteredItems.length } }));\n }\n }, SR_ANNOUNCEMENT_DELAY_MS);\n\n return () => clearTimeout(timer);\n }, [showList, filteredItems.length, i18n]);\n\n return (\n <div\n className={cx(['adyen-checkout__dropdown', className, ...classNameModifiers.map(m => `adyen-checkout__dropdown--${m}`)])}\n ref={selectContainerRef}\n >\n <SelectButton\n inputText={inputText}\n id={uniqueId ?? null}\n active={activeOption}\n selected={selectedOption}\n filterInputRef={filterInputRef}\n filterable={filterable}\n isInvalid={isInvalid}\n isValid={isValid}\n onButtonKeyDown={handleButtonKeyDown}\n onInput={handleTextFilter}\n placeholder={placeholder}\n readonly={readonly}\n selectListId={selectListId}\n showList={showList}\n toggleButtonRef={toggleButtonRef}\n toggleList={toggleList}\n disabled={disabled}\n ariaDescribedBy={ariaDescribedBy}\n required={required}\n />\n <SelectList\n active={activeOption}\n filteredItems={filteredItems}\n onHover={handleHover}\n onSelect={handleSelect}\n selected={selectedOption}\n selectListId={selectListId}\n selectListRef={selectListRef}\n showList={showList}\n />\n <div\n key={inputText}\n role=\"status\"\n aria-live=\"polite\"\n // aria-relevant seems to be needed here make make sure a second time we get\n // \"No options found\" we still announce the status message.\n // What happens otherwise is that just the first status message is announced\n // tested on VoiceOver on Chrome\n aria-relevant=\"additions text\"\n className=\"adyen-checkout-sr-panel--sr-only\"\n >\n {statusMessage}\n </div>\n </div>\n );\n}\n\nSelect.defaultProps = {\n className: '',\n classNameModifiers: [],\n filterable: true,\n items: [],\n readonly: false,\n onChange: () => {}\n};\n\nexport default Select;\n"],"names":["Select","items","className","classNameModifiers","filterable","readonly","onChange","onInput","selectedValue","name","isInvalid","isValid","placeholder","uniqueId","disabled","disableTextFilter","clearOnSelect","blurOnClose","onListToggle","required","additionalDescribedBy","i18n","useCoreContext","filterInputRef","useRef","selectContainerRef","toggleButtonRef","selectListRef","textFilter","setTextFilter","useState","showList","setShowList","statusMessage","setStatusMessage","selectListId","useMemo","uuid","active","find","i","id","inputText","setInputText","activeOption","setActiveOption","selectedOption","filteredItems","filter","item","toLowerCase","includes","ariaDescribedBy","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","Boolean","join","scrollToItem","nextElement","document","getElementById","simulateFocusScroll","closeList","current","blur","openList","extractItemFromEvent","e","value","currentTarget","getAttribute","listItem","handleSelect","valueToEmit","preventDefault","HTMLElement","some","target","handleNavigationKeys","key","keys","space","enter","arrowDown","length","possibleNextIndex","findIndex","nextIndex","nextItem","setNextActive","arrowUp","setPreviousActive","useEffect","focus","handleClickOutside","composedPath","contains","addEventListener","removeEventListener","timer","setTimeout","get","values","count","clearTimeout","h","div","cx","map","m","ref","SelectButton","selected","onButtonKeyDown","escape","shiftKey","tab","toggleList","SelectList","onHover","onSelect","role","aria-live","aria-relevant","defaultProps"],"mappings":"8mBAaA,SAASA,GAAOC,MACZA,EAAQ,GAAEC,UACVA,EAAY,GAAEC,mBACdA,EAAqB,GAAEC,WACvBA,GAAa,EAAIC,SACjBA,GAAW,EAAKC,SAChBA,EAAW,OAAQC,QACnBA,EAAOC,cACPA,EAAaC,KACbA,EAAIC,UACJA,EAASC,QACTA,EAAOC,YACPA,EAAWC,SACXA,EAAQC,SACRA,EAAQC,kBACRA,EAAiBC,cACjBA,EAAaC,YACbA,EAAWC,aACXA,EAAYC,SACZA,EAAQC,sBACRA,IAEA,MAAMC,KAAEA,GAASC,IACXC,EAAiBC,EAAO,MACxBC,EAAqBD,EAAO,MAC5BE,EAAkBF,EAAO,MACzBG,EAAgBH,EAAO,OACtBI,EAAYC,GAAiBC,EAAiB,OAC9CC,EAAUC,GAAeF,GAAkB,IAC3CG,EAAeC,GAAoBJ,EAAwB,MAC5DK,EAAuBC,EAAQ,IAAM,UAAUC,MAAU,IAEzDC,EAAqBrC,EAAMsC,KAAKC,GAAKA,EAAEC,KAAOjC,IAAmB,CAAA,GAEhEkC,EAAWC,GAAgBb,KAE3Bc,EAAcC,GAAmBf,EAAqBQ,GAEvDQ,EAAiBR,EAEjBS,EAAgBhC,EAAoBd,EAAQA,EAAM+C,OAAOC,IAASrB,GAAcqB,EAAKxC,KAAK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GAAc2B,GAAYH,EAClD4C,GAAaL,GACNA,EAAEY,MAAQC,EAAKkC,OAGtBpD,MACO,CAACkB,EAAKU,QAASV,EAAKG,UAAWH,EAAKE,OAAO/B,SAASgB,EAAEY,OAASZ,EAAEY,MAAQC,EAAKC,OAAW7E,GAAe2B,IAOxGoC,EAAEgD,UAAYhD,EAAEY,MAAQC,EAAKoC,KAG7BjD,EAAEY,MAAQC,EAAKoC,MADtBtD,MARAK,EAAEO,iBACG3C,EAGD+C,GAAqBX,GAFrBF,OA8IA1D,QAvGc4D,IACtB,MAAMC,EAAiBD,EAAEU,OAA4BT,MACrDzB,EAAayB,GACbvC,EAAcuC,GAGTrC,GACDkC,KAGA1D,GACAA,EAAQ6D,IA6FJxD,YAAaA,EACbP,SAAUA,EACV8B,aAAcA,EACdJ,SAAUA,EACVL,gBAAiBA,EACjB2F,WA1FQlD,IAChBA,EAAEO,iBACG3C,GAIDY,EAAaG,EAAerC,MAC5BqD,OAJAnB,EAAa,MACbsB,OAuFInD,SAAUA,EACVsC,gBAAiBA,EACjBjC,SAAUA,IAEdsF,EAACa,EAAAA,CACGhF,OAAQM,EACRG,cAAeA,EACfwE,QAjLSpD,IACjBA,EAAEO,iBACF,MAAMzB,EAAOiB,GAAqBC,GAClCtB,EAAgBI,IA+KRuE,SAAUhD,GACVwC,SAAUlE,EACVX,aAAcA,EACdR,cAAeA,EACfI,SAAUA,IAEd0E,EAACC,MAAAA,CACG3B,IAAKrC,EACL+E,KAAK,SACLC,YAAU,SAKVC,gBAAc,iBACdzH,UAAU,oCAET+B,GAIjB,CAEAjC,EAAO4H,aAAe,CAClB1H,UAAW,GACXC,mBAAoB,GACpBC,YAAY,EACZH,MAAO,GACPI,UAAU,EACVC,SAAU"}
1
+ {"version":3,"file":"Select.js","sources":["../../../../../../src/components/internal/FormFields/Select/Select.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport SelectButton from './components/SelectButton';\nimport SelectList from './components/SelectList';\nimport uuid from '../../../../utils/uuid';\nimport { keys } from './constants';\nimport { SelectItem, SelectProps } from './types';\nimport './Select.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { simulateFocusScroll } from '../utils';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\nfunction Select({\n items = [],\n className = '',\n classNameModifiers = [],\n filterable = true,\n readonly = false,\n onChange = () => {},\n onInput,\n selectedValue,\n name,\n isInvalid,\n isValid,\n placeholder,\n uniqueId,\n disabled,\n disableTextFilter,\n clearOnSelect,\n blurOnClose,\n onListToggle,\n required,\n additionalDescribedBy\n}: Readonly<SelectProps>) {\n const { i18n } = useCoreContext();\n const filterInputRef = useRef(null);\n const selectContainerRef = useRef(null);\n const toggleButtonRef = useRef(null);\n const selectListRef = useRef(null);\n const [textFilter, setTextFilter] = useState<string>(null);\n const [showList, setShowList] = useState<boolean>(false);\n const [statusMessage, setStatusMessage] = useState<string | null>(null);\n const selectListId: string = useMemo(() => `select-${uuid()}`, []);\n\n const active: SelectItem = items.find(i => i.id === selectedValue) || ({} as SelectItem);\n\n const [inputText, setInputText] = useState<string>();\n\n const [activeOption, setActiveOption] = useState<SelectItem>(active);\n\n const selectedOption = active;\n\n const filteredItems = disableTextFilter ? items : items.filter(item => !textFilter || item.name.toLowerCase().includes(textFilter.toLowerCase()));\n\n const suffix = isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX;\n const baseDescribedBy = uniqueId ? `${uniqueId}${suffix}` : null;\n const ariaDescribedBy = [baseDescribedBy, additionalDescribedBy].filter(Boolean).join(' ') || null;\n\n const setNextActive = () => {\n if (!filteredItems || filteredItems.length < 1) return;\n const possibleNextIndex = filteredItems.findIndex(listItem => listItem.id === activeOption.id) + 1;\n const nextIndex = possibleNextIndex < filteredItems.length ? possibleNextIndex : 0;\n const nextItem = filteredItems[nextIndex];\n scrollToItem(nextItem);\n setActiveOption(nextItem);\n };\n\n const setPreviousActive = () => {\n if (!filteredItems || filteredItems.length < 1) return;\n const possibleNextIndex = filteredItems.findIndex(listItem => listItem.id === activeOption.id) - 1;\n const nextIndex = possibleNextIndex < 0 ? filteredItems.length - 1 : possibleNextIndex;\n const nextItem = filteredItems[nextIndex];\n scrollToItem(nextItem);\n setActiveOption(nextItem);\n };\n\n const scrollToItem = (item: SelectItem) => {\n if (!item) return;\n const nextElement = document.getElementById(`listItem-${item.id}`);\n simulateFocusScroll(nextElement);\n };\n\n /**\n * Closes the selectList, empties the text filter and focuses the button element\n */\n const closeList = () => {\n //blurs the field when the list is closed, makes for a better UX for most users, needs more testing\n if (blurOnClose) {\n filterInputRef.current.blur();\n }\n setShowList(false);\n };\n\n const openList = () => {\n setShowList(true);\n };\n\n const extractItemFromEvent = (e: Event): SelectItem => {\n const value = (e.currentTarget as HTMLInputElement).getAttribute('data-value');\n return filteredItems.find(listItem => listItem.id == value);\n };\n\n /**\n * Closes the select list and fires an onChange\n * @param e - Event\n */\n const handleSelect = (e: Event) => {\n e.preventDefault();\n\n // We use a local variable here since writing and if statement is cleaner then a long ternary\n let valueToEmit;\n\n if (e.currentTarget instanceof HTMLElement && e.currentTarget.getAttribute('role') === 'option') {\n // This is the main scenario when clicking and item in the list\n // Item comes from the event\n valueToEmit = extractItemFromEvent(e);\n } else if (activeOption.id && filteredItems.some(item => item.id === activeOption.id)) {\n // This is the scenario where a user is using the keyboard to navigate\n // In the case item comes from the visually select item\n valueToEmit = activeOption;\n } else {\n // This is the scenario the user didn't select anything\n if (textFilter) {\n // if we filtering for something then select the first option\n valueToEmit = filteredItems[0];\n } else {\n // This will happen when we want to keep an already chosen option\n // If no active option we should just emit again with the value that was already selected\n valueToEmit = { id: selectedValue };\n }\n }\n\n if (valueToEmit && !valueToEmit.disabled) {\n onChange({ target: { value: valueToEmit.id, name: name } });\n\n if (clearOnSelect) setInputText(null);\n\n closeList();\n }\n };\n\n /**\n * Handles hovering and directions\n * @param e - Event\n */\n const handleHover = (e: Event) => {\n e.preventDefault();\n const item = extractItemFromEvent(e);\n setActiveOption(item);\n };\n\n /**\n * Handle keyDown events on the selectList button\n * Responsible for opening and closing the list\n * @param e - KeyboardEvent\n */\n const handleButtonKeyDown = (e: KeyboardEvent) => {\n if (e.key === keys.enter && filterable && showList && textFilter) {\n handleSelect(e);\n } else if (e.key === keys.escape) {\n // When user has focused Select button but not yet moved into Select list - close list and keep focus on the Select Button re. a11y guidelines\n // https://w3c.github.io/aria-practices/examples/disclosure/disclosure-navigation.html\n closeList();\n } else if ([keys.arrowUp, keys.arrowDown, keys.enter].includes(e.key) || (e.key === keys.space && (!filterable || !showList))) {\n e.preventDefault();\n if (!showList) {\n openList();\n } else {\n handleNavigationKeys(e);\n }\n } else if (e.shiftKey && e.key === keys.tab) {\n // Shift-Tab out of Select - close list re. a11y guidelines (above)\n closeList();\n } else if (e.key === keys.tab) {\n closeList();\n }\n };\n\n /**\n * Handles movement with navigation keys and enter\n * Navigates through the list, or select an element, or focus the filter input, or close the menu.\n * @param e - KeyDownEvent\n */\n const handleNavigationKeys = (e: KeyboardEvent) => {\n switch (e.key) {\n case keys.space:\n case keys.enter:\n handleSelect(e);\n break;\n case keys.arrowDown:\n e.preventDefault();\n setNextActive();\n break;\n case keys.arrowUp:\n e.preventDefault();\n setPreviousActive();\n break;\n default:\n }\n };\n\n /**\n * Updates the state with the current text filter value and opens the dropdown\n * @param e - KeyboardEvent\n */\n const handleTextFilter = (e: KeyboardEvent) => {\n const value: string = (e.target as HTMLInputElement).value;\n setInputText(value);\n setTextFilter(value);\n\n // Open the dropdown when user starts typing\n if (!showList) {\n openList();\n }\n\n if (onInput) {\n onInput(value);\n }\n };\n\n /**\n * Toggles the selectList and focuses in either the filter input or in the selectList button\n * @param e - Event\n */\n const toggleList = (e: Event) => {\n e.preventDefault();\n if (!showList) {\n setInputText(null);\n openList();\n } else {\n setInputText(selectedOption.name);\n closeList();\n }\n };\n\n useEffect(() => {\n if (showList) {\n setInputText(null);\n } else {\n setTextFilter(null);\n }\n }, [showList]);\n\n /**\n * Focus on the input if filterable\n */\n useEffect(() => {\n if (showList && filterable && filterInputRef.current) {\n filterInputRef.current.focus();\n }\n onListToggle?.(showList);\n }, [showList]);\n\n useEffect(() => {\n /**\n * Close the select list when clicking outside the list\n * @param e - MouseEvent\n */\n function handleClickOutside(e: MouseEvent) {\n // use composedPath so it can also check when inside a web component\n // if composedPath is not available fallback to e.target\n const clickIsOutside = e.composedPath\n ? !e.composedPath().includes(selectContainerRef.current)\n : !selectContainerRef.current.contains(e.target);\n if (clickIsOutside) {\n closeList();\n }\n }\n\n document.addEventListener('click', handleClickOutside, false);\n\n return () => {\n document.removeEventListener('click', handleClickOutside, false);\n };\n }, [selectContainerRef]);\n\n /**\n * Update status message for screen readers when no options are found\n */\n useEffect(() => {\n // Debounce to avoid announcing on every keystroke\n const SR_ANNOUNCEMENT_DELAY_MS = 500;\n const timer = setTimeout(() => {\n if (filteredItems.length === 0) {\n setStatusMessage(i18n.get('select.noOptionsFound'));\n } else {\n setStatusMessage(i18n.get('select.results', { values: { count: filteredItems.length } }));\n }\n }, SR_ANNOUNCEMENT_DELAY_MS);\n\n return () => clearTimeout(timer);\n }, [showList, filteredItems.length, i18n]);\n\n return (\n <div\n className={cx(['adyen-checkout__dropdown', className, ...classNameModifiers.map(m => `adyen-checkout__dropdown--${m}`)])}\n ref={selectContainerRef}\n >\n <SelectButton\n inputText={inputText}\n id={uniqueId ?? null}\n active={activeOption}\n selected={selectedOption}\n filterInputRef={filterInputRef}\n filterable={filterable}\n isInvalid={isInvalid}\n isValid={isValid}\n onButtonKeyDown={handleButtonKeyDown}\n onInput={handleTextFilter}\n placeholder={placeholder}\n readonly={readonly}\n selectListId={selectListId}\n showList={showList}\n toggleButtonRef={toggleButtonRef}\n toggleList={toggleList}\n disabled={disabled}\n ariaDescribedBy={ariaDescribedBy}\n required={required}\n />\n <SelectList\n active={activeOption}\n filteredItems={filteredItems}\n onHover={handleHover}\n onSelect={handleSelect}\n selected={selectedOption}\n selectListId={selectListId}\n selectListRef={selectListRef}\n showList={showList}\n />\n <div\n key={inputText}\n role=\"status\"\n aria-live=\"polite\"\n // aria-relevant seems to be needed here make make sure a second time we get\n // \"No options found\" we still announce the status message.\n // What happens otherwise is that just the first status message is announced\n // tested on VoiceOver on Chrome\n aria-relevant=\"additions text\"\n className=\"adyen-checkout__dropdown__status\"\n >\n {statusMessage}\n </div>\n </div>\n );\n}\n\nSelect.defaultProps = {\n className: '',\n classNameModifiers: [],\n filterable: true,\n items: [],\n readonly: false,\n onChange: () => {}\n};\n\nexport default Select;\n"],"names":["Select","items","className","classNameModifiers","filterable","readonly","onChange","onInput","selectedValue","name","isInvalid","isValid","placeholder","uniqueId","disabled","disableTextFilter","clearOnSelect","blurOnClose","onListToggle","required","additionalDescribedBy","i18n","useCoreContext","filterInputRef","useRef","selectContainerRef","toggleButtonRef","selectListRef","textFilter","setTextFilter","useState","showList","setShowList","statusMessage","setStatusMessage","selectListId","useMemo","uuid","active","find","i","id","inputText","setInputText","activeOption","setActiveOption","selectedOption","filteredItems","filter","item","toLowerCase","includes","ariaDescribedBy","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","Boolean","join","scrollToItem","nextElement","document","getElementById","simulateFocusScroll","closeList","current","blur","openList","extractItemFromEvent","e","value","currentTarget","getAttribute","listItem","handleSelect","valueToEmit","preventDefault","HTMLElement","some","target","handleNavigationKeys","key","keys","space","enter","arrowDown","length","possibleNextIndex","findIndex","nextIndex","nextItem","setNextActive","arrowUp","setPreviousActive","useEffect","focus","handleClickOutside","composedPath","contains","addEventListener","removeEventListener","timer","setTimeout","get","values","count","clearTimeout","h","div","cx","map","m","ref","SelectButton","selected","onButtonKeyDown","escape","shiftKey","tab","toggleList","SelectList","onHover","onSelect","role","aria-live","aria-relevant","defaultProps"],"mappings":"8mBAaA,SAASA,GAAOC,MACZA,EAAQ,GAAEC,UACVA,EAAY,GAAEC,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cA,EACdJ,SAAUA,EACVL,gBAAiBA,EACjB2F,WA1FQlD,IAChBA,EAAEO,iBACG3C,GAIDY,EAAaG,EAAerC,MAC5BqD,OAJAnB,EAAa,MACbsB,OAuFInD,SAAUA,EACVsC,gBAAiBA,EACjBjC,SAAUA,IAEdsF,EAACa,EAAAA,CACGhF,OAAQM,EACRG,cAAeA,EACfwE,QAjLSpD,IACjBA,EAAEO,iBACF,MAAMzB,EAAOiB,GAAqBC,GAClCtB,EAAgBI,IA+KRuE,SAAUhD,GACVwC,SAAUlE,EACVX,aAAcA,EACdR,cAAeA,EACfI,SAAUA,IAEd0E,EAACC,MAAAA,CACG3B,IAAKrC,EACL+E,KAAK,SACLC,YAAU,SAKVC,gBAAc,iBACdzH,UAAU,oCAET+B,GAIjB,CAEAjC,EAAO4H,aAAe,CAClB1H,UAAW,GACXC,mBAAoB,GACpBC,YAAY,EACZH,MAAO,GACPI,UAAU,EACVC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import a from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";import{useMemo as n}from"../../../../../external/preact/hooks/dist/hooks.js";function d({filterable:t,toggleButtonRef:a,showList:o,selectListId:n,...d}){if(t){const{id:t,...o}=d;return e("div",{...o,ref:a})}return e("button",{role:"combobox",type:"button",id:d.id,className:d.className,"aria-haspopup":"listbox","aria-expanded":o,"aria-controls":n,"aria-activedescendant":d["aria-activedescendant"]||void 0,disabled:d.disabled,"aria-disabled":d.readonly,"aria-describedby":d["aria-describedby"],"aria-labelledby":d.id?`${d.id}-label ${d.id}-value`:void 0,onClick:d.onClick,onKeyDown:d.onKeyDown,ref:a},d.children)}function i(i){const{active:r,selected:l,inputText:c,readonly:s,showList:u,required:_}=i,p=n(()=>{const e=l.selectedOptionName||l.name;return!0!==("string"==typeof e&&""!==e.trim())},[l,i.placeholder]),b=l.selectedOptionName||l.name||i.placeholder||"",y=u?c??"":b,m=s?null:i.filterable?e=>{e.preventDefault(),document.activeElement===i.filterInputRef.current?i.showList||i.toggleList(e):i.filterInputRef.current&&i.filterInputRef.current.focus()}:i.toggleList,f=r.id?`listItem-${r.id}`:"";return e(d,{className:a({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":u,"adyen-checkout__dropdown__button--invalid":i.isInvalid,"adyen-checkout__dropdown__button--valid":i.isValid,"adyen-checkout__dropdown__button--disabled":l.disabled}),disabled:i.disabled,filterable:i.filterable,onClick:m,onKeyDown:s?null:i.onButtonKeyDown,toggleButtonRef:i.toggleButtonRef,id:i.id,showList:u,selectListId:i.selectListId,"aria-activedescendant":!i.filterable&&u&&f||void 0,"aria-describedby":i.ariaDescribedBy},i.filterable?e(t,null,!u&&l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":i.selectListId,"aria-expanded":u,"aria-owns":i.selectListId,autoComplete:"off",className:a("adyen-checkout__filter-input",{"adyen-checkout__filter-input--placeholder":!u&&p}),onInput:i.onInput,ref:i.filterInputRef,role:"combobox","aria-activedescendant":f,type:"text",readOnly:i.readonly,"aria-disabled":i.readonly,id:i.id,"aria-describedby":i.ariaDescribedBy,required:_}),!u&&l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)):e(t,null,l.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:l.icon,alt:l.name}),e("span",{id:i.id?`${i.id}-value`:void 0,className:a("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":p})},b),l.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},l.secondaryText)))}export{i as default};
1
+ import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import a from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";import{TagList as d}from"../../../Tag/TagList.js";import{useMemo as n}from"../../../../../external/preact/hooks/dist/hooks.js";function i({filterable:t,toggleButtonRef:a,showList:o,selectListId:d,readonly:n,...i}){if(t){const{id:t,...o}=i;return e("div",{...o,ref:a})}return e("button",{role:"combobox",type:"button",id:i.id,className:i.className,"aria-haspopup":"listbox","aria-expanded":o,"aria-controls":d,"aria-activedescendant":i["aria-activedescendant"]||void 0,disabled:i.disabled,"aria-disabled":n,"aria-describedby":i["aria-describedby"],"aria-labelledby":i.id?`${i.id}-label ${i.id}-value`:void 0,onClick:i.onClick,onKeyDown:i.onKeyDown,ref:a},i.children)}function r(r){const{active:l,selected:s,inputText:c,readonly:u,showList:_,required:p}=r,b=n(()=>{const e=s.selectedOptionName||s.name;return!0!==("string"==typeof e&&""!==e.trim())},[s,r.placeholder]),m=s.selectedOptionName||s.name||r.placeholder||"",y=_?c??"":m,f=e=>{e.preventDefault(),r.filterInputRef.current?.focus(),e.target===r.filterInputRef.current&&r.showList||r.toggleList(e)},h=l.id?`listItem-${l.id}`:"";return e(i,{className:a({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":u,"adyen-checkout__dropdown__button--active":_,"adyen-checkout__dropdown__button--invalid":r.isInvalid,"adyen-checkout__dropdown__button--valid":r.isValid,"adyen-checkout__dropdown__button--disabled":s.disabled}),disabled:r.disabled,filterable:r.filterable,readonly:u,onClick:u?null:r.filterable?f:r.toggleList,onKeyDown:u?null:r.onButtonKeyDown,toggleButtonRef:r.toggleButtonRef,id:r.id,showList:_,selectListId:r.selectListId,"aria-activedescendant":!r.filterable&&_&&h||void 0,"aria-describedby":r.ariaDescribedBy},r.filterable?e(t,null,!_&&s.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:s.icon,alt:s.name}),e("input",{value:y,"aria-autocomplete":"list","aria-controls":r.selectListId,"aria-expanded":_,"aria-owns":r.selectListId,autoComplete:"off",className:a("adyen-checkout__filter-input",{"adyen-checkout__filter-input--placeholder":!_&&b}),onInput:r.onInput,ref:r.filterInputRef,role:"combobox","aria-activedescendant":h,type:"text",readOnly:r.readonly,"aria-disabled":r.readonly,id:r.id,"aria-describedby":r.ariaDescribedBy,required:p}),!_&&e(d,{tags:s.tags,className:"adyen-checkout__dropdown__button__tags"})):e(t,null,s.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:s.icon,alt:s.name}),e("span",{id:r.id?`${r.id}-value`:void 0,className:a("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":b})},m),e(d,{tags:s.tags,className:"adyen-checkout__dropdown__button__tags"})))}export{r as default};
2
2
  //# sourceMappingURL=SelectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment, Ref } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonElementProps, SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, showList, selectListId, ...props }: Readonly<SelectButtonElementProps>) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef as Ref<HTMLDivElement>} />;\n }\n\n return (\n <button\n role=\"combobox\"\n type=\"button\"\n id={props.id}\n className={props.className}\n aria-haspopup=\"listbox\"\n aria-expanded={showList}\n aria-controls={selectListId}\n aria-activedescendant={props['aria-activedescendant'] || undefined}\n disabled={props.disabled}\n aria-disabled={props.readonly}\n aria-describedby={props['aria-describedby']}\n aria-labelledby={props.id ? `${props.id as string}-label ${props.id as string}-value` : undefined}\n onClick={props.onClick}\n onKeyDown={props.onKeyDown}\n ref={toggleButtonRef as Ref<HTMLButtonElement>}\n >\n {props.children}\n </button>\n );\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n // When list is open, show user's typed input (or empty); otherwise show selected value\n const textWhenListOpen = inputText ?? '';\n const displayInputText = showList ? textWhenListOpen : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n showList={showList}\n selectListId={props.selectListId}\n aria-activedescendant={!props.filterable && showList ? currentSelectedItemId || undefined : undefined}\n aria-describedby={props.ariaDescribedBy}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n id={props.id ? `${props.id}-value` : undefined}\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className={classnames('adyen-checkout__filter-input', {\n 'adyen-checkout__filter-input--placeholder': !showList && isShowingPlaceholder\n })}\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","filterable","toggleButtonRef","showList","selectListId","props","id","strippedProps","h","div","ref","button","role","type","className","aria-haspopup","aria-expanded","aria-controls","aria-activedescendant","undefined","disabled","aria-disabled","readonly","aria-describedby","aria-labelledby","onClick","onKeyDown","children","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","currentSelectedItemId","cx","isInvalid","isValid","onButtonKeyDown","ariaDescribedBy","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-owns","autoComplete","classnames","onInput","readOnly","secondaryText","span"],"mappings":"4PAOA,SAASA,GAAoBC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,aAAEA,KAAiBC,IACnF,GAAIJ,EAAY,CAEZ,MA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A,CAAKxD,UAAU,oDAAoDgB,EAASuC,gBAiC5H"}
1
+ {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment, Ref } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonElementProps, SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { TagList } from '../../../Tag';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, showList, selectListId, readonly, ...props }: Readonly<SelectButtonElementProps>) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef as Ref<HTMLDivElement>} />;\n }\n\n return (\n <button\n role=\"combobox\"\n type=\"button\"\n id={props.id}\n className={props.className}\n aria-haspopup=\"listbox\"\n aria-expanded={showList}\n aria-controls={selectListId}\n aria-activedescendant={props['aria-activedescendant'] || undefined}\n disabled={props.disabled}\n aria-disabled={readonly}\n aria-describedby={props['aria-describedby']}\n aria-labelledby={props.id ? `${props.id as string}-label ${props.id as string}-value` : undefined}\n onClick={props.onClick}\n onKeyDown={props.onKeyDown}\n ref={toggleButtonRef as Ref<HTMLButtonElement>}\n >\n {props.children}\n </button>\n );\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n // When list is open, show user's typed input (or empty); otherwise show selected value\n const textWhenListOpen = inputText ?? '';\n const displayInputText = showList ? textWhenListOpen : displayText;\n\n const handleClick = (e: Event) => {\n e.preventDefault();\n props.filterInputRef.current?.focus();\n\n // Clicking the input of an open list keeps it open\n if (e.target === props.filterInputRef.current && props.showList) return;\n\n props.toggleList(e);\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to toggle the list and focus on the input\n // 3. Otherwise we just toggle the list\n const getOnClickHandler = (): ((e: Event) => void) | null => {\n if (readonly) return null;\n\n if (props.filterable) return handleClick;\n\n return props.toggleList;\n };\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n readonly={readonly}\n onClick={getOnClickHandler()}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n id={props.id}\n showList={showList}\n selectListId={props.selectListId}\n aria-activedescendant={!props.filterable && showList ? currentSelectedItemId || undefined : undefined}\n aria-describedby={props.ariaDescribedBy}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n id={props.id ? `${props.id}-value` : undefined}\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n <TagList tags={selected.tags} className=\"adyen-checkout__dropdown__button__tags\" />\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className={classnames('adyen-checkout__filter-input', {\n 'adyen-checkout__filter-input--placeholder': !showList && isShowingPlaceholder\n })}\n onInput={props.onInput}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n aria-disabled={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && <TagList tags={selected.tags} className=\"adyen-checkout__dropdown__button__tags\" />}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","filterable","toggleButtonRef","showList","selectListId","readonly","props","id","strippedProps","h","div","ref","button","role","type","className","aria-haspopup","aria-expanded","aria-controls","aria-activedescendant","undefined","disabled","aria-disabled","aria-describedby","aria-labelledby","onClick","onKeyDown","children","SelectButton","active","selected","inputText","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","handleClick","e","preventDefault","filterInputRef","current","focus","target","toggleList","currentSelectedItemId","cx","isInvalid","isValid","onButtonKeyDown","ariaDescribedBy","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-owns","autoComplete","classnames","onInput","readOnly","TagList","tags","span"],"mappings":"8SAQA,SAASA,GAAoBC,WAAEA,EAAUC,gBAAEA,EAAeC,SAAEA,EAAQC,aAAEA,EAAYC,SAAEA,KAAaC,IAC7F,GAAIL,EAAY,CAEZ,MAAMM,GAAEA,KAAOC,GAAkBF,EACjC,OAAOG,EAACC,MAAAA,IAAQF,EAAeG,IAAKT,GACxC,CAEA,OACIO,EAACG,SAAAA,CACGC,KAAK,WACLC,KAAK,SACLP,GAAID,EAAMC,GACVQ,UAAWT,EAAMS,UACjBC,gBAAc,UACdC,gBAAed,EACfe,gBAAed,EACfe,wBAAuBb,EAAM,+BAA4Bc,EACzDC,SAAUf,EAAMe,SAChBC,gBAAej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BjB,EAAMgD,iBAEtBhD,EAAML,WAcJQ,EAAC8C,QACKpD,GAAY2B,EAAS0B,MAAQ/C,EAACgD,EAAAA,CAAI1C,UAAU,yCAAyC2C,IAAK5B,EAAS0B,KAAMG,IAAK7B,EAASO,OACzH5B,EAACmD,QAAAA,CACGC,MAAOrB,EACPsB,oBAAkB,OAClB5C,gBAAeZ,EAAMF,aACrBa,gBAAed,EACf4D,YAAWzD,EAAMF,aACjB4D,aAAa,MACbjD,UAAWkD,EAAW,+BAAgC,CAClD,6CAA8C9D,GAAY8B,IAE9DiC,QAAS5D,EAAM4D,QACfvD,IAAKL,EAAMsC,eACX/B,KAAK,WACLM,wBAAuB8B,EACvBnC,KAAK,OACLqD,SAAU7D,EAAMD,SAChBiB,gBAAehB,EAAMD,SACrBE,GAAID,EAAMC,GACVgB,mBAAkBjB,EAAMgD,gBACxBtB,SAAUA,KAEZ7B,GAAYM,EAAC2D,EAAAA,CAAQC,KAAMvC,EAASuC,KAAMtD,UAAU,4CApC1DN,EAAC8C,OACIzB,EAAS0B,MAAQ/C,EAACgD,EAAAA,CAAI1C,UAAU,yCAAyC2C,IAAK5B,EAAS0B,KAAMG,IAAK7B,EAASO,OAC5G5B,EAAC6D,OAAAA,CACG/D,GAAID,EAAMC,GAAK,GAAGD,EAAMC,gBAAaa,EACrCL,UAAWkD,EAAW,yCAA0C,CAC5D,qDAAsDhC,KAGzDE,GAEL1B,EAAC2D,EAAAA,CAAQC,KAAMvC,EAASuC,KAAMtD,UAAU,4CA+B5D"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../Img/Img.js";import o from"../../../Icon/Icon.js";import{PREFIX as d}from"../../../Icon/constants.js";const n=({item:n,active:c,selected:s,...l})=>e("li",{"aria-disabled":!!n.disabled,"aria-selected":s,className:t(["adyen-checkout__dropdown__element",{"adyen-checkout__dropdown__element--active":c,"adyen-checkout__dropdown__element--disabled":!!n.disabled}]),"data-disabled":!0===n.disabled||null,"data-value":n.id,onClick:l.onSelect,onMouseEnter:l.onHover,role:"option",id:`listItem-${n.id}`},n.icon&&e(a,{className:"adyen-checkout__dropdown__element__icon",alt:n.name,src:n.icon}),e("span",{className:"adyen-checkout__dropdown__element__text"},n.name),n.secondaryText&&e("span",{className:"adyen-checkout__dropdown__element__secondary-text"},n.secondaryText),s&&e(o,{type:`${d}checkmark_black`,height:14,width:14}));export{n as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import a from"../../../../../_virtual/index.js";import t from"../../../Img/Img.js";import o from"../../../Icon/Icon.js";import{PREFIX as d}from"../../../Icon/constants.js";import{TagList as n}from"../../../Tag/TagList.js";const c=({item:c,active:_,selected:s,...r})=>e("li",{"aria-disabled":!!c.disabled,"aria-selected":s,className:a(["adyen-checkout__dropdown__element",{"adyen-checkout__dropdown__element--active":_,"adyen-checkout__dropdown__element--disabled":!!c.disabled}]),"data-disabled":!0===c.disabled||null,"data-value":c.id,onClick:r.onSelect,onMouseEnter:r.onHover,role:"option",id:`listItem-${c.id}`},e("div",{className:"adyen-checkout__dropdown__element__content"},e("div",{className:"adyen-checkout__dropdown__element__primary"},c.icon&&e(t,{className:"adyen-checkout__dropdown__element__icon",alt:c.name,src:c.icon}),e("span",{className:"adyen-checkout__dropdown__element__text"},c.name)),c.secondaryText&&e("span",{className:"adyen-checkout__dropdown__element__secondary-text"},c.secondaryText)),e(n,{tags:c.tags,className:"adyen-checkout__dropdown__element__tags"}),s&&e(o,{type:`${d}checkmark_black`,height:14,width:14}));export{c as default};
2
2
  //# sourceMappingURL=SelectListItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\nimport { PREFIX } from '../../../Icon/constants';\n\nconst SelectListItem = ({ item, active, selected, ...props }: Readonly<SelectItemProps>) => {\n return (\n /* eslint-disable jsx-a11y/click-events-have-key-events */\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role */\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n {selected && <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","item","active","selected","props","h","li","aria-disabled","disabled","aria-selected","className","cx","data-disabled","data-value","id","onClick","onSelect","onMouseEnter","onHover","role","icon","Img","alt","name","src","span","secondaryText","Icon","type","PREFIX","height","width"],"mappings":"0PAOA,MAAMA,EAAiB,EAAGC,OAAMC,SAAQC,cAAaC,KAG7CC,EAACC,KAAAA,CACGC,kBAAiBN,EAAKO,SACtBC,gBAAeN,EACfO,UAAWC,EAAG,CACV,oCACA,CACI,4CAA6CT,EAC7C,gDAAiDD,EAAKO,YAM9DI,iBAAiC,IAAlBX,EAAKO,UAA2B,KAC/CK,aAAYZ,EAAKa,GACjBC,QAASX,EAAMY,SACfC,aAAcb,EAAMc,QAEpBC,KAAK,SAELL,GAAI,YAAYb,EAAKa,MAEpBb,EAAKmB,MAAQf,EAACgB,EAAAA,CAAIX,UAAU,0CAA0CY,IAAKrB,EAAKsB,KAAMC,IAAKvB,EAAKmB,OACjGf,EAACoB,OAAAA,CAAKf,UAAU,2CAA2CT,EAAKsB,MAC/DtB,EAAKyB,eAAiBrB,EAACoB,OAAAA,CAAKf,UAAU,qDAAqDT,EAAKyB,eAChGvB,GAAYE,EAACsB,EAAAA,CAAKC,KAAM,GAAGC,mBAAyBC,OAAQ,GAAIC,MAAO"}
1
+ {"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\nimport { PREFIX } from '../../../Icon/constants';\nimport { TagList } from '../../../Tag';\n\nconst SelectListItem = ({ item, active, selected, ...props }: Readonly<SelectItemProps>) => {\n return (\n /* eslint-disable jsx-a11y/click-events-have-key-events */\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role */\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n <div className=\"adyen-checkout__dropdown__element__content\">\n <div className=\"adyen-checkout__dropdown__element__primary\">\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n </div>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n </div>\n <TagList tags={item.tags} className=\"adyen-checkout__dropdown__element__tags\" />\n {selected && <Icon type={`${PREFIX}checkmark_black`} height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","item","active","selected","props","h","li","aria-disabled","disabled","aria-selected","className","cx","data-disabled","data-value","id","onClick","onSelect","onMouseEnter","onHover","role","div","icon","Img","alt","name","src","span","secondaryText","TagList","tags","Icon","type","PREFIX","height","width"],"mappings":"4SAQA,MAAMA,EAAiB,EAAGC,OAAMC,SAAQC,cAAaC,KAG7CC,EAACC,KAAAA,CACGC,kBAAiBN,EAAKO,SACtBC,gBAAeN,EACfO,UAAWC,EAAG,CACV,oCACA,CACI,4CAA6CT,EAC7C,gDAAiDD,EAAKO,YAM9DI,iBAAiC,IAAlBX,EAAKO,UAA2B,KAC/CK,aAAYZ,EAAKa,GACjBC,QAASX,EAAMY,SACfC,aAAcb,EAAMc,QAEpBC,KAAK,SAELL,GAAI,YAAYb,EAAKa,MAErBT,EAACe,MAAAA,CAAIV,UAAU,8CACXL,EAACe,MAAAA,CAAIV,UAAU,8CACVT,EAAKoB,MAAQhB,EAACiB,EAAAA,CAAIZ,UAAU,0CAA0Ca,IAAKtB,EAAKuB,KAAMC,IAAKxB,EAAKoB,OACjGhB,EAACqB,OAAAA,CAAKhB,UAAU,2CAA2CT,EAAKuB,OAEnEvB,EAAK0B,eAAiBtB,EAACqB,OAAAA,CAAKhB,UAAU,qDAAqDT,EAAK0B,gBAErGtB,EAACuB,EAAAA,CAAQC,KAAM5B,EAAK4B,KAAMnB,UAAU,4CACnCP,GAAYE,EAACyB,EAAAA,CAAKC,KAAM,GAAGC,mBAAyBC,OAAQ,GAAIC,MAAO"}
@@ -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"}
@@ -0,0 +1,2 @@
1
+ import{createElement as s}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import e from"./Tag.module.scss.js";import{TagVariant as r}from"./types.js";const a={[r.SUCCESS]:e.success,[r.INFO]:e.info},o=({label:o,variant:m=r.INFO})=>s("span",{className:t(e.tag,a[m])},o);export{o as Tag};
2
+ //# sourceMappingURL=Tag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.js","sources":["../../../../../src/components/internal/Tag/Tag.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport type { TagProps } from './types';\nimport styles from './Tag.module.scss';\nimport { TagVariant } from './types';\n\nconst variantClass: Record<TagVariant, string> = {\n [TagVariant.SUCCESS]: styles.success,\n [TagVariant.INFO]: styles.info\n};\n\nexport const Tag = ({ label, variant = TagVariant.INFO }: Readonly<TagProps>) => {\n return <span className={cx(styles.tag, variantClass[variant])}>{label}</span>;\n};\n"],"names":["variantClass","TagVariant","SUCCESS","styles","success","INFO","info","Tag","label","variant","h","span","className","cx","tag"],"mappings":"8LAMA,MAAMA,EAA2C,CAC7C,CAACC,EAAWC,SAAUC,EAAOC,QAC7B,CAACH,EAAWI,MAAOF,EAAOG,MAGjBC,EAAM,EAAGC,QAAOC,UAAUR,EAAWI,QACvCK,EAACC,OAAAA,CAAKC,UAAWC,EAAGV,EAAOW,IAAKd,EAAaS,KAAYD"}
@@ -0,0 +1,2 @@
1
+ var _={tag:"Tag-module_tag__zTym4",success:"Tag-module_success__UU5x9",info:"Tag-module_info__iyn3C"};export{_ as default};
2
+ //# sourceMappingURL=Tag.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{createElement as a}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{Tag as e}from"./Tag.js";import s from"./TagList.module.scss.js";const r=({tags:r,className:l})=>r?.length?a("div",{className:t(s.tagList,l)},r.map((t,s)=>a(e,{key:`${s}-${t.label}`,label:t.label,variant:t.variant}))):null;export{r as TagList};
2
+ //# sourceMappingURL=TagList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagList.js","sources":["../../../../../src/components/internal/Tag/TagList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { Tag } from './Tag';\nimport type { TagListProps } from './types';\nimport styles from './TagList.module.scss';\n\nexport const TagList = ({ tags, className }: Readonly<TagListProps>) => {\n if (!tags?.length) return null;\n return (\n <div className={cx(styles.tagList, className)}>\n {tags.map((tag, index) => (\n <Tag key={`${index}-${tag.label}`} label={tag.label} variant={tag.variant} />\n ))}\n </div>\n );\n};\n"],"names":["TagList","tags","className","length","h","div","cx","styles","tagList","map","tag","index","Tag","key","label","variant"],"mappings":"+LAMaA,EAAU,EAAGC,OAAMC,eACvBD,GAAME,OAEPC,EAACC,MAAAA,CAAIH,UAAWI,EAAGC,EAAOC,QAASN,IAC9BD,EAAKQ,IAAI,CAACC,EAAKC,IACZP,EAACQ,EAAAA,CAAIC,IAAK,GAAGF,KAASD,EAAII,QAASA,MAAOJ,EAAII,MAAOC,QAASL,EAAIK,YAJpD"}
@@ -0,0 +1,2 @@
1
+ var t={tagList:"TagList-module_tagList__qCdT0"};export{t as default};
2
+ //# sourceMappingURL=TagList.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagList.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ var n=function(n){return n.SUCCESS="success",n.INFO="info",n}({});export{n as TagVariant};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../../src/components/internal/Tag/types.ts"],"sourcesContent":["export enum TagVariant {\n SUCCESS = 'success',\n INFO = 'info'\n}\n\nexport interface TagProps {\n label: string;\n variant?: TagVariant;\n}\n\nexport interface TagListProps {\n tags?: TagProps[];\n className?: string;\n}\n"],"names":["TagVariant"],"mappings":"AAAO,IAAAA,EAAKA,SAAAA,GAAAA,yCAAAA,CAGX,CAHWA,CAGX,CAAA"}
@@ -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