@adyen/kyc-components 3.21.2 → 3.21.4

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.
@@ -6539,17 +6539,27 @@ const taxIdNumberOptions = {
6539
6539
  name: "socialSecurityNumber",
6540
6540
  applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
6541
6541
  }],
6542
+ [CountryCodes.PuertoRico]: [{
6543
+ id: "EIN",
6544
+ name: "ein"
6545
+ }, {
6546
+ id: "SSN",
6547
+ name: "ssn",
6548
+ applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
6549
+ }],
6542
6550
  [CountryCodes.UnitedStates]: [{
6543
6551
  id: "EIN",
6544
6552
  name: "ein"
6545
6553
  }, {
6546
6554
  id: "SSN",
6547
- name: "ssn"
6555
+ name: "ssn",
6556
+ applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
6548
6557
  }]
6549
6558
  };
6550
6559
  const getTaxIdNumberOptions = (country2, companyType2) => {
6551
6560
  const optionsForCountry = taxIdNumberOptions[country2];
6552
6561
  if (!companyType2 || !optionsForCountry) return optionsForCountry;
6562
+ if (country2 === "US" || country2 === "PR") return optionsForCountry.filter((option) => option.id === "EIN");
6553
6563
  return optionsForCountry.filter((option) => {
6554
6564
  var _a;
6555
6565
  return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
@@ -8799,159 +8809,6 @@ function InputDate(props) {
8799
8809
  maxLength: 10
8800
8810
  });
8801
8811
  }
8802
- const STOCK_EXCHANGE_MIC_FIELD = ["stockExchangeMIC"];
8803
- function StockExchangeMICField({
8804
- data,
8805
- valid,
8806
- errors,
8807
- labels: labels2,
8808
- placeholders,
8809
- readonly,
8810
- mask,
8811
- guidanceText,
8812
- shouldValidate,
8813
- handleChangeFor
8814
- }) {
8815
- return jsx(MaskedInputText, {
8816
- name: "stockExchangeMIC",
8817
- label: labels2.stockExchangeMIC ?? "",
8818
- formatGuidance: guidanceText == null ? void 0 : guidanceText.stockExchangeMIC,
8819
- placeholder: placeholders == null ? void 0 : placeholders.stockExchangeMIC,
8820
- ...mask,
8821
- classNameModifiers: {
8822
- field: ["stockExchangeMIC"],
8823
- input: ["stockExchangeMIC"]
8824
- },
8825
- errorMessage: errors.stockExchangeMIC,
8826
- isValid: valid.stockExchangeMIC ?? false,
8827
- value: data.stockExchangeMIC ?? "",
8828
- readonly,
8829
- shouldValidate,
8830
- onInput: handleChangeFor("stockExchangeMIC", "input"),
8831
- onBlur: handleChangeFor("stockExchangeMIC", "blur"),
8832
- "aria-required": true,
8833
- "aria-label": labels2.stockExchangeMIC,
8834
- "aria-invalid": !valid.stockExchangeMIC
8835
- });
8836
- }
8837
- const stockExchangeMICFieldMetadata = {
8838
- label: "stockExchangeMIC",
8839
- validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[a-zA-Z0-9]{4}$/)],
8840
- mask: {
8841
- mask: makeMask(...alphanumericInputs(4)),
8842
- transformOnType: uppercase
8843
- },
8844
- guidanceText: {
8845
- key: "enterNCharactersForExample",
8846
- values: {
8847
- numChars: "4",
8848
- example: "XNAS"
8849
- }
8850
- }
8851
- };
8852
- const STOCK_ISIN_FIELD = ["stockISIN"];
8853
- function StockISINField({
8854
- data,
8855
- valid,
8856
- errors,
8857
- labels: labels2,
8858
- placeholders,
8859
- readonly,
8860
- mask,
8861
- guidanceText,
8862
- shouldValidate,
8863
- handleChangeFor
8864
- }) {
8865
- return jsx(MaskedInputText, {
8866
- name: "stockISIN",
8867
- label: labels2.stockISIN ?? "",
8868
- formatGuidance: guidanceText == null ? void 0 : guidanceText.stockISIN,
8869
- placeholder: placeholders == null ? void 0 : placeholders.stockISIN,
8870
- ...mask,
8871
- classNameModifiers: {
8872
- field: ["stockISIN"],
8873
- input: ["stockISIN"]
8874
- },
8875
- errorMessage: errors.stockISIN,
8876
- isValid: valid.stockISIN ?? false,
8877
- value: data.stockISIN ?? "",
8878
- readonly,
8879
- shouldValidate,
8880
- onInput: handleChangeFor("stockISIN", "input"),
8881
- onBlur: handleChangeFor("stockISIN", "blur"),
8882
- "aria-required": true,
8883
- "aria-label": labels2.stockISIN,
8884
- "aria-invalid": !valid.stockISIN
8885
- });
8886
- }
8887
- const stockISINFieldMetadata = {
8888
- label: "stockISIN",
8889
- validators: [validateNotEmptyOnBlur, {
8890
- modes: ["blur"],
8891
- validate: (value) => !!value && isISIN(value)
8892
- }],
8893
- mask: {
8894
- mask: makeMask(...alphaInputs(2), ...alphanumericInputs(9), ...numericInputs(1)),
8895
- transformOnType: uppercase
8896
- },
8897
- helperText: "stockISINHelper",
8898
- guidanceText: {
8899
- key: "validationPleaseEnterAValidStockISIN",
8900
- values: {
8901
- example: "NL0012969182"
8902
- }
8903
- }
8904
- };
8905
- const STOCK_TICKER_SYMBOL_FIELD = ["stockTickerSymbol"];
8906
- function StockTickerSymbolField({
8907
- data,
8908
- valid,
8909
- errors,
8910
- labels: labels2,
8911
- placeholders,
8912
- readonly,
8913
- mask,
8914
- guidanceText,
8915
- shouldValidate,
8916
- handleChangeFor
8917
- }) {
8918
- return jsx(MaskedInputText, {
8919
- name: "stockTickerSymbol",
8920
- label: labels2.stockTickerSymbol ?? "",
8921
- formatGuidance: guidanceText == null ? void 0 : guidanceText.stockTickerSymbol,
8922
- placeholder: placeholders == null ? void 0 : placeholders.stockTickerSymbol,
8923
- ...mask,
8924
- classNameModifiers: {
8925
- field: ["stockTickerSymbol"],
8926
- input: ["stockTickerSymbol"]
8927
- },
8928
- errorMessage: errors.stockTickerSymbol,
8929
- isValid: valid.stockTickerSymbol ?? false,
8930
- value: data.stockTickerSymbol ?? "",
8931
- readonly,
8932
- shouldValidate,
8933
- onInput: handleChangeFor("stockTickerSymbol", "input"),
8934
- onBlur: handleChangeFor("stockTickerSymbol", "blur"),
8935
- "aria-required": true,
8936
- "aria-label": labels2.stockTickerSymbol,
8937
- "aria-invalid": !valid.stockTickerSymbol
8938
- });
8939
- }
8940
- const stockTickerSymbolFieldMetadata = {
8941
- label: "stockTickerSymbol",
8942
- validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[A-Z\d]{1,5}$/)],
8943
- mask: {
8944
- mask: makeMask(...alphanumericInputs(1), ...alphanumericInputs(4)),
8945
- transformOnType: uppercase
8946
- },
8947
- guidanceText: {
8948
- key: "enterAMaximumOfNCharactersForExample",
8949
- values: {
8950
- maxChars: "5",
8951
- example: "ADYEN"
8952
- }
8953
- }
8954
- };
8955
8812
  const defaultFieldMetadata$8 = {
8956
8813
  label: "taxId"
8957
8814
  };
@@ -9251,6 +9108,9 @@ const defaultFieldConfig$8 = {
9251
9108
  validators: validatePatternOnBlur(/^\d{12}$/)
9252
9109
  }
9253
9110
  };
9111
+ const vatAbsenceReasonMetadata = {
9112
+ validators: [validateNotEmptyOnBlur]
9113
+ };
9254
9114
  const defaultFieldMetadata$7 = {
9255
9115
  label: "vatNumber"
9256
9116
  };
@@ -9898,6 +9758,159 @@ const inferTaxIdNumberType = (taxId2, country2, companyType2) => {
9898
9758
  }
9899
9759
  }
9900
9760
  };
9761
+ const STOCK_EXCHANGE_MIC_FIELD = ["stockExchangeMIC"];
9762
+ function StockExchangeMICField({
9763
+ data,
9764
+ valid,
9765
+ errors,
9766
+ labels: labels2,
9767
+ placeholders,
9768
+ readonly,
9769
+ mask,
9770
+ guidanceText,
9771
+ shouldValidate,
9772
+ handleChangeFor
9773
+ }) {
9774
+ return jsx(MaskedInputText, {
9775
+ name: "stockExchangeMIC",
9776
+ label: labels2.stockExchangeMIC ?? "",
9777
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockExchangeMIC,
9778
+ placeholder: placeholders == null ? void 0 : placeholders.stockExchangeMIC,
9779
+ ...mask,
9780
+ classNameModifiers: {
9781
+ field: ["stockExchangeMIC"],
9782
+ input: ["stockExchangeMIC"]
9783
+ },
9784
+ errorMessage: errors.stockExchangeMIC,
9785
+ isValid: valid.stockExchangeMIC ?? false,
9786
+ value: data.stockExchangeMIC ?? "",
9787
+ readonly,
9788
+ shouldValidate,
9789
+ onInput: handleChangeFor("stockExchangeMIC", "input"),
9790
+ onBlur: handleChangeFor("stockExchangeMIC", "blur"),
9791
+ "aria-required": true,
9792
+ "aria-label": labels2.stockExchangeMIC,
9793
+ "aria-invalid": !valid.stockExchangeMIC
9794
+ });
9795
+ }
9796
+ const stockExchangeMICFieldMetadata = {
9797
+ label: "stockExchangeMIC",
9798
+ validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[a-zA-Z0-9]{4}$/)],
9799
+ mask: {
9800
+ mask: makeMask(...alphanumericInputs(4)),
9801
+ transformOnType: uppercase
9802
+ },
9803
+ guidanceText: {
9804
+ key: "enterNCharactersForExample",
9805
+ values: {
9806
+ numChars: "4",
9807
+ example: "XNAS"
9808
+ }
9809
+ }
9810
+ };
9811
+ const STOCK_ISIN_FIELD = ["stockISIN"];
9812
+ function StockISINField({
9813
+ data,
9814
+ valid,
9815
+ errors,
9816
+ labels: labels2,
9817
+ placeholders,
9818
+ readonly,
9819
+ mask,
9820
+ guidanceText,
9821
+ shouldValidate,
9822
+ handleChangeFor
9823
+ }) {
9824
+ return jsx(MaskedInputText, {
9825
+ name: "stockISIN",
9826
+ label: labels2.stockISIN ?? "",
9827
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockISIN,
9828
+ placeholder: placeholders == null ? void 0 : placeholders.stockISIN,
9829
+ ...mask,
9830
+ classNameModifiers: {
9831
+ field: ["stockISIN"],
9832
+ input: ["stockISIN"]
9833
+ },
9834
+ errorMessage: errors.stockISIN,
9835
+ isValid: valid.stockISIN ?? false,
9836
+ value: data.stockISIN ?? "",
9837
+ readonly,
9838
+ shouldValidate,
9839
+ onInput: handleChangeFor("stockISIN", "input"),
9840
+ onBlur: handleChangeFor("stockISIN", "blur"),
9841
+ "aria-required": true,
9842
+ "aria-label": labels2.stockISIN,
9843
+ "aria-invalid": !valid.stockISIN
9844
+ });
9845
+ }
9846
+ const stockISINFieldMetadata = {
9847
+ label: "stockISIN",
9848
+ validators: [validateNotEmptyOnBlur, {
9849
+ modes: ["blur"],
9850
+ validate: (value) => !!value && isISIN(value)
9851
+ }],
9852
+ mask: {
9853
+ mask: makeMask(...alphaInputs(2), ...alphanumericInputs(9), ...numericInputs(1)),
9854
+ transformOnType: uppercase
9855
+ },
9856
+ helperText: "stockISINHelper",
9857
+ guidanceText: {
9858
+ key: "validationPleaseEnterAValidStockISIN",
9859
+ values: {
9860
+ example: "NL0012969182"
9861
+ }
9862
+ }
9863
+ };
9864
+ const STOCK_TICKER_SYMBOL_FIELD = ["stockTickerSymbol"];
9865
+ function StockTickerSymbolField({
9866
+ data,
9867
+ valid,
9868
+ errors,
9869
+ labels: labels2,
9870
+ placeholders,
9871
+ readonly,
9872
+ mask,
9873
+ guidanceText,
9874
+ shouldValidate,
9875
+ handleChangeFor
9876
+ }) {
9877
+ return jsx(MaskedInputText, {
9878
+ name: "stockTickerSymbol",
9879
+ label: labels2.stockTickerSymbol ?? "",
9880
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockTickerSymbol,
9881
+ placeholder: placeholders == null ? void 0 : placeholders.stockTickerSymbol,
9882
+ ...mask,
9883
+ classNameModifiers: {
9884
+ field: ["stockTickerSymbol"],
9885
+ input: ["stockTickerSymbol"]
9886
+ },
9887
+ errorMessage: errors.stockTickerSymbol,
9888
+ isValid: valid.stockTickerSymbol ?? false,
9889
+ value: data.stockTickerSymbol ?? "",
9890
+ readonly,
9891
+ shouldValidate,
9892
+ onInput: handleChangeFor("stockTickerSymbol", "input"),
9893
+ onBlur: handleChangeFor("stockTickerSymbol", "blur"),
9894
+ "aria-required": true,
9895
+ "aria-label": labels2.stockTickerSymbol,
9896
+ "aria-invalid": !valid.stockTickerSymbol
9897
+ });
9898
+ }
9899
+ const stockTickerSymbolFieldMetadata = {
9900
+ label: "stockTickerSymbol",
9901
+ validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[A-Z\d]{1,5}$/)],
9902
+ mask: {
9903
+ mask: makeMask(...alphanumericInputs(1), ...alphanumericInputs(4)),
9904
+ transformOnType: uppercase
9905
+ },
9906
+ guidanceText: {
9907
+ key: "enterAMaximumOfNCharactersForExample",
9908
+ values: {
9909
+ maxChars: "5",
9910
+ example: "ADYEN"
9911
+ }
9912
+ }
9913
+ };
9901
9914
  function TaxIdNumberTypeSelector({
9902
9915
  country: country2,
9903
9916
  companyType: companyType2,
@@ -10121,16 +10134,24 @@ const vatAbsenceReasons = [
10121
10134
  "belowTaxThreshold"
10122
10135
  /* BelowTaxThreshold */
10123
10136
  ];
10124
- const vatNumberFields = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
10125
- function VatNumber(props) {
10126
- var _a, _b, _c;
10127
- const {
10128
- data: propData,
10129
- country: country2,
10130
- fieldValidationErrors,
10131
- dataStoreId,
10132
- fieldConfig = defaultFieldConfig$7
10133
- } = props;
10137
+ const VAT_NUMBER_FIELD = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
10138
+ function VatNumberField({
10139
+ data,
10140
+ valid,
10141
+ errors,
10142
+ labels: labels2,
10143
+ mask,
10144
+ guidanceText,
10145
+ placeholders,
10146
+ readonly,
10147
+ shouldValidate,
10148
+ handleChangeFor,
10149
+ canExempt,
10150
+ country: country2,
10151
+ vatNumberType,
10152
+ setVatNumberType
10153
+ }) {
10154
+ var _a;
10134
10155
  const {
10135
10156
  isExperimentEnabled
10136
10157
  } = useExperimentsContext();
@@ -10142,115 +10163,64 @@ function VatNumber(props) {
10142
10163
  id: VatAbsenceReason.CountryWithoutVatOrGstSystem,
10143
10164
  name: VatAbsenceReason.CountryWithoutVatOrGstSystem
10144
10165
  }]);
10145
- const existingTaxId = propData == null ? void 0 : propData.vatNumber;
10146
- const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, void 0) : (_a = taxIdNumberOptions[country2]) == null ? void 0 : _a[0].id;
10147
- const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
10148
- const metadata = resolveFieldMetadata(fieldConfig[country2], {
10149
- vatNumberType: taxIdNumberType
10150
- }, defaultFieldMetadata$7);
10151
- const mergedProps = mergeFieldMetadataIntoProps("vatNumber", metadata, props);
10152
- const {
10153
- i18n
10154
- } = useI18nContext();
10155
- const formUtils = formUtilities(mergedProps, i18n);
10156
- const stateRef = useRef({
10157
- setState: null
10158
- });
10159
- const {
10160
- handleChangeFor,
10161
- data,
10162
- valid,
10163
- errors,
10164
- isValid,
10165
- fieldProblems
10166
- } = useForm({
10167
- ...mergedProps,
10168
- schema: (data2) => data2.exemptedFromVat ? ["vatAbsenceReason", "exemptedFromVat"] : ["vatNumber", "exemptedFromVat"],
10169
- rules: mergedProps.validators,
10170
- defaultData: {
10171
- ...propData,
10172
- exemptedFromVat: !!(propData == null ? void 0 : propData.exemptedFromVat)
10173
- },
10174
- // exemptedFromVat should be a boolean
10175
- fieldProblems: fieldValidationErrors
10176
- });
10177
- useEffect(() => {
10178
- if (data.vatNumber || taxIdNumberType) {
10179
- handleChangeFor("vatNumber", "blur")(data.vatNumber);
10180
- }
10181
- }, [taxIdNumberType, country2]);
10182
- useEffect(() => {
10183
- var _a2, _b2;
10184
- (_b2 = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
10185
- type: "addToState",
10186
- value: {
10187
- data,
10188
- valid,
10189
- errors,
10190
- caller: "vatNumber",
10191
- dataStoreId
10192
- }
10193
- });
10194
- }, [data, valid, errors, isValid]);
10195
- if (!formUtils.isRequiredField("vatNumber")) return null;
10196
- const exemptionIsPossible = ((_b = mergedProps.requiredFields) == null ? void 0 : _b.includes("exemptedFromVat")) ?? false;
10197
- const showTaxIdExemptedOption = exemptionIsPossible && ((_c = taxIdNumberOptions[country2]) == null ? void 0 : _c.length) > 1;
10198
- const handleTaxIdNumberTypeChange = (taxIdType) => {
10199
- if (taxIdType === "exempted") {
10200
- if (!exemptionIsPossible) {
10166
+ const showVatExemptedOption = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
10167
+ const handleVatNumberTypeChange = (vatType) => {
10168
+ if (vatType === "exempted") {
10169
+ if (!canExempt) {
10201
10170
  throw Error(`${country2} does not allow VAT exemptions`);
10202
10171
  }
10203
10172
  handleChangeFor("exemptedFromVat")(true);
10204
- setTaxIdNumberType(void 0);
10173
+ setVatNumberType(void 0);
10205
10174
  return;
10206
10175
  }
10207
- if (exemptionIsPossible && data.exemptedFromVat === true) {
10176
+ if (canExempt && data.exemptedFromVat === true) {
10208
10177
  handleChangeFor("exemptedFromVat")(false);
10209
10178
  }
10210
- setTaxIdNumberType(taxIdType);
10179
+ setVatNumberType(vatType);
10211
10180
  };
10212
10181
  return jsxs("div", {
10213
- className: "adyen-kyc-field--tax-id",
10214
- children: [jsx(StateContextSetter, {
10215
- stateRef
10216
- }), jsx(TaxIdNumberTypeSelector, {
10182
+ className: "adyen-kyc-field__vat-number",
10183
+ children: [jsx(TaxIdNumberTypeSelector, {
10217
10184
  country: country2,
10218
- setSelected: handleTaxIdNumberTypeChange,
10219
- selected: data.exemptedFromVat ? "exempted" : taxIdNumberType,
10220
- exemptedOption: showTaxIdExemptedOption ? formUtils.getLabel("exemptedFromVat", "iDontHaveAVatNumber") : false
10185
+ setSelected: handleVatNumberTypeChange,
10186
+ selected: data.exemptedFromVat ? "exempted" : vatNumberType,
10187
+ exemptedOption: showVatExemptedOption ? labels2.exemptedFromVat : false
10221
10188
  }), jsx(MaskedInputText, {
10222
- name: "vatNumber",
10223
- label: formUtils.getLabel("vatNumber"),
10224
- formatGuidance: formUtils.getGuidanceText("vatNumber"),
10225
- ...formUtils.getMask("vatNumber"),
10189
+ "aria-required": true,
10190
+ "aria-label": labels2.vatNumber,
10191
+ "aria-invalid": !valid.vatNumber,
10226
10192
  classNameModifiers: {
10227
10193
  field: ["tax-id"],
10228
10194
  input: ["vatNumber"]
10229
10195
  },
10230
- errorMessage: formUtils.getErrorMessage("vatNumber", errors, fieldProblems),
10231
- shouldValidate: props.shouldValidate,
10232
- isValid: valid.vatNumber,
10233
- value: data.vatNumber ?? "",
10234
- readonly: formUtils.isReadOnly("vatNumber"),
10196
+ name: "vatNumber",
10197
+ value: (data == null ? void 0 : data.vatNumber) ?? "",
10198
+ label: labels2.vatNumber ?? "",
10199
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.vatNumber) ?? "",
10200
+ placeholder: placeholders == null ? void 0 : placeholders.vatNumber,
10201
+ errorMessage: errors.vatNumber,
10202
+ isValid: Boolean(valid.vatNumber),
10235
10203
  onInput: handleChangeFor("vatNumber", "input"),
10236
10204
  onBlur: handleChangeFor("vatNumber", "blur"),
10237
- disabled: data.exemptedFromVat
10238
- }), formUtils.isRequiredField("exemptedFromVat") && !showTaxIdExemptedOption && jsx(Checkbox, {
10205
+ disabled: data.exemptedFromVat,
10206
+ readonly,
10207
+ shouldValidate,
10208
+ ...mask
10209
+ }), canExempt && !showVatExemptedOption && jsx(Checkbox, {
10210
+ "aria-required": false,
10211
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
10212
+ "aria-invalid": false,
10239
10213
  name: "exemptedFromVat",
10240
- label: formUtils.getLabel("exemptedFromVat", "iDontHaveAVatNumber"),
10214
+ label: labels2 == null ? void 0 : labels2.exemptedFromVat,
10241
10215
  value: "exemptedFromVat",
10242
- readonly: formUtils.isReadOnly("exemptedFromVat"),
10243
10216
  classNameModifiers: ["exempted-from-tax"],
10244
10217
  checked: data.exemptedFromVat ?? false,
10245
- onChange: handleChangeFor("exemptedFromVat"),
10246
- "aria-required": false,
10247
- "aria-label": formUtils.getLabel("exemptedFromVat"),
10248
- "aria-invalid": false
10249
- }), data.exemptedFromVat ? jsx(Field, {
10218
+ onChange: handleChangeFor("exemptedFromVat")
10219
+ }), data.exemptedFromVat && jsx(Field, {
10250
10220
  name: "vatAbsenceReason",
10251
10221
  classNameModifiers: ["tax-id-absence-reason"],
10252
- label: formUtils.getLabel("vatAbsenceReason", "vatAbsenceReason"),
10253
- errorMessage: formUtils.getErrorMessage("vatAbsenceReason", errors, fieldProblems),
10222
+ label: labels2 == null ? void 0 : labels2.vatAbsenceReason,
10223
+ errorMessage: errors.vatAbsenceReason,
10254
10224
  isValid: valid.vatAbsenceReason,
10255
10225
  children: (childProps) => jsx(RadioGroup, {
10256
10226
  ...childProps,
@@ -10262,7 +10232,7 @@ function VatNumber(props) {
10262
10232
  name: reason
10263
10233
  }))
10264
10234
  })
10265
- }) : null]
10235
+ })]
10266
10236
  });
10267
10237
  }
10268
10238
  const companyRegistrationDetailsValidationRules = {
@@ -10300,27 +10270,33 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
10300
10270
  companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
10301
10271
  country: CountryCodes.PuertoRico
10302
10272
  }];
10303
- const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", "stockTickerSymbol", ...vatNumberFields, ...taxIdFields, "dateOfIncorporation"];
10273
+ const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", "stockTickerSymbol", ...VAT_NUMBER_FIELD, ...taxIdFields, "dateOfIncorporation"];
10304
10274
  function CompanyRegistrationDetailsComponent(props) {
10305
- var _a, _b;
10275
+ var _a, _b, _c;
10306
10276
  const {
10307
10277
  i18n
10308
10278
  } = useI18nContext();
10279
+ const {
10280
+ companyNameAndCountry
10281
+ } = useGlobalData();
10309
10282
  let mergedProps = props;
10283
+ const defaultVatNumberType = ((_a = mergedProps.data) == null ? void 0 : _a.vatNumber) ? inferTaxIdNumberType((_b = mergedProps.data) == null ? void 0 : _b.vatNumber, mergedProps.country) : (_c = taxIdNumberOptions[mergedProps.country]) == null ? void 0 : _c[0].id;
10284
+ const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
10310
10285
  mergedProps = mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, mergedProps);
10311
10286
  mergedProps = mergeFieldMetadataIntoProps("stockISIN", stockISINFieldMetadata, mergedProps);
10312
10287
  mergedProps = mergeFieldMetadataIntoProps("stockTickerSymbol", stockTickerSymbolFieldMetadata, mergedProps);
10288
+ mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[mergedProps.country], {
10289
+ vatNumberType
10290
+ }, defaultFieldMetadata$7), mergedProps);
10291
+ mergedProps = mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, mergedProps);
10313
10292
  const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === mergedProps.country && f.companyType.includes(mergedProps.companyType));
10314
10293
  const stateRef = useRef({
10315
10294
  setState: null
10316
10295
  });
10317
- const COMPANY_REGISTRATION_DETAILS = mergedProps.id;
10296
+ const COMPANY_REGISTRATION_DETAILS = mergedProps.id ?? "companyRegistrationDetails";
10318
10297
  const requiredFields = mergedProps.requiredFields || companyRegistrationDetailsFields;
10319
- const directChildFields = requiredFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation"].includes(field));
10320
- const {
10321
- getData
10322
- } = useStateContext();
10323
- const legalCompanyName2 = (_b = (_a = getData()) == null ? void 0 : _a.companyNameAndCountry) == null ? void 0 : _b.legalCompanyName;
10298
+ const directChildFields = requiredFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation", "vatNumber"].includes(field));
10299
+ const legalCompanyName2 = companyNameAndCountry == null ? void 0 : companyNameAndCountry.legalCompanyName;
10324
10300
  const isSameNameAsLegalName = !mergedProps.data.tradingName ? true : mergedProps.data.tradingName === legalCompanyName2;
10325
10301
  const {
10326
10302
  handleChangeFor,
@@ -10333,7 +10309,7 @@ function CompanyRegistrationDetailsComponent(props) {
10333
10309
  setData
10334
10310
  } = useForm({
10335
10311
  ...mergedProps,
10336
- schema: directChildFields,
10312
+ schema: (currentData) => !currentData.exemptedFromVat ? (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatAbsenceReason")) ?? directChildFields : (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatNumber")) ?? directChildFields,
10337
10313
  defaultData: {
10338
10314
  ...mergedProps.data,
10339
10315
  sameNameAsLegalName: isSameNameAsLegalName,
@@ -10376,7 +10352,6 @@ function CompanyRegistrationDetailsComponent(props) {
10376
10352
  setData("tradingName", tradingNameIsSameAsLegalName ? legalCompanyName2 : "");
10377
10353
  };
10378
10354
  const registrationNumberProps = getFieldProps(mergedProps, businessRegistrationNumberFields);
10379
- const vatNumberProps = getFieldProps(mergedProps, vatNumberFields);
10380
10355
  const taxIdProps = getFieldProps(mergedProps, taxIdFields);
10381
10356
  const handleChange = ({
10382
10357
  currentState,
@@ -10387,7 +10362,7 @@ function CompanyRegistrationDetailsComponent(props) {
10387
10362
  let schema = requiredFields;
10388
10363
  let hasSchemaChanged = false;
10389
10364
  if (formUtils.isRequiredField("vatNumber")) {
10390
- schema = currentData.exemptedFromVat ? schema.filter((child) => child !== "vatNumber") : schema.filter((child) => child !== "vatAbsenceReason");
10365
+ schema = currentData.exemptedFromVat ? schema.filter((child) => child !== "vatNumber") : schema.filter((child) => child !== "vatAbsenceReason" && child !== "exemptedFromVat");
10391
10366
  hasSchemaChanged = true;
10392
10367
  }
10393
10368
  if (formUtils.isRequiredField("taxId") && currentData.exemptedFromTax) {
@@ -10501,10 +10476,22 @@ function CompanyRegistrationDetailsComponent(props) {
10501
10476
  companyType: mergedProps.companyType,
10502
10477
  country: mergedProps.country,
10503
10478
  dataStoreId: COMPANY_REGISTRATION_DETAILS
10504
- }), formUtils.isRequiredField("vatNumber") && jsx(VatNumber, {
10505
- ...vatNumberProps,
10506
- dataStoreId: COMPANY_REGISTRATION_DETAILS,
10507
- country: mergedProps.country
10479
+ }), formUtils.isRequiredField("vatNumber") && jsx(VatNumberField, {
10480
+ data: formUtils.getFieldData(data, VAT_NUMBER_FIELD),
10481
+ valid: formUtils.getFieldValid(valid, VAT_NUMBER_FIELD),
10482
+ errors: formUtils.getFieldErrors(errors, fieldProblems, VAT_NUMBER_FIELD),
10483
+ labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
10484
+ exemptedFromVat: "iDontHaveAVatNumber"
10485
+ }),
10486
+ mask: formUtils.getMask("vatNumber"),
10487
+ guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
10488
+ placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
10489
+ readonly: formUtils.isReadOnly("vatNumber"),
10490
+ handleChangeFor,
10491
+ country: mergedProps.country,
10492
+ canExempt: formUtils.isRequiredField("exemptedFromVat"),
10493
+ vatNumberType,
10494
+ setVatNumberType
10508
10495
  }), formUtils.isRequiredField("taxId") && jsx(TaxId, {
10509
10496
  ...taxIdProps,
10510
10497
  dataStoreId: COMPANY_REGISTRATION_DETAILS,
@@ -24473,107 +24460,6 @@ const defaultFieldConfig$1 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig
24473
24460
  };
24474
24461
  }
24475
24462
  }), {});
24476
- const VAT_NUMBER_FIELD = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
24477
- function VatNumberField({
24478
- data,
24479
- valid,
24480
- errors,
24481
- labels: labels2,
24482
- mask,
24483
- guidanceText,
24484
- placeholders,
24485
- readonly,
24486
- shouldValidate,
24487
- handleChangeFor,
24488
- canExempt,
24489
- country: country2,
24490
- vatNumberType,
24491
- setVatNumberType
24492
- }) {
24493
- var _a;
24494
- const {
24495
- isExperimentEnabled
24496
- } = useExperimentsContext();
24497
- const showExtraTaxExemptionReasons = isExperimentEnabled(ExperimentNames.ShowExtraTaxExemptionReasons);
24498
- const extraVatAbsenceReasons = vatAbsenceReasons.map((reason) => ({
24499
- id: reason,
24500
- name: reason
24501
- })).concat([{
24502
- id: VatAbsenceReason.CountryWithoutVatOrGstSystem,
24503
- name: VatAbsenceReason.CountryWithoutVatOrGstSystem
24504
- }]);
24505
- const showVatExemptedOption = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
24506
- const handleVatNumberTypeChange = (vatType) => {
24507
- if (vatType === "exempted") {
24508
- if (!canExempt) {
24509
- throw Error(`${country2} does not allow VAT exemptions`);
24510
- }
24511
- handleChangeFor("exemptedFromVat")(true);
24512
- setVatNumberType(void 0);
24513
- return;
24514
- }
24515
- if (canExempt && data.exemptedFromVat === true) {
24516
- handleChangeFor("exemptedFromVat")(false);
24517
- }
24518
- setVatNumberType(vatType);
24519
- };
24520
- return jsxs("div", {
24521
- className: "adyen-kyc-field__vat-number",
24522
- children: [jsx(TaxIdNumberTypeSelector, {
24523
- country: country2,
24524
- setSelected: handleVatNumberTypeChange,
24525
- selected: data.exemptedFromVat ? "exempted" : vatNumberType,
24526
- exemptedOption: showVatExemptedOption ? labels2.exemptedFromVat : false
24527
- }), jsx(MaskedInputText, {
24528
- "aria-required": true,
24529
- "aria-label": labels2.vatNumber,
24530
- "aria-invalid": !valid.vatNumber,
24531
- classNameModifiers: {
24532
- field: ["tax-id"],
24533
- input: ["vatNumber"]
24534
- },
24535
- name: "vatNumber",
24536
- value: (data == null ? void 0 : data.vatNumber) ?? "",
24537
- label: labels2.vatNumber ?? "",
24538
- formatGuidance: (guidanceText == null ? void 0 : guidanceText.vatNumber) ?? "",
24539
- placeholder: placeholders == null ? void 0 : placeholders.vatNumber,
24540
- errorMessage: errors.vatNumber,
24541
- isValid: Boolean(valid.vatNumber),
24542
- onInput: handleChangeFor("vatNumber", "input"),
24543
- onBlur: handleChangeFor("vatNumber", "blur"),
24544
- disabled: data.exemptedFromVat,
24545
- readonly,
24546
- shouldValidate,
24547
- ...mask
24548
- }), canExempt && !showVatExemptedOption && jsx(Checkbox, {
24549
- "aria-required": false,
24550
- "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
24551
- "aria-invalid": false,
24552
- name: "exemptedFromVat",
24553
- label: labels2 == null ? void 0 : labels2.exemptedFromVat,
24554
- value: "exemptedFromVat",
24555
- classNameModifiers: ["exempted-from-tax"],
24556
- checked: data.exemptedFromVat ?? false,
24557
- onChange: handleChangeFor("exemptedFromVat")
24558
- }), data.exemptedFromVat && jsx(Field, {
24559
- name: "vatAbsenceReason",
24560
- classNameModifiers: ["tax-id-absence-reason"],
24561
- label: labels2 == null ? void 0 : labels2.vatAbsenceReason,
24562
- errorMessage: errors.vatAbsenceReason,
24563
- isValid: valid.vatAbsenceReason,
24564
- children: (childProps) => jsx(RadioGroup, {
24565
- ...childProps,
24566
- name: "vatAbsenceReason",
24567
- onChange: handleChangeFor("vatAbsenceReason", "input"),
24568
- value: data.vatAbsenceReason,
24569
- items: showExtraTaxExemptionReasons ? extraVatAbsenceReasons : vatAbsenceReasons.map((reason) => ({
24570
- id: reason,
24571
- name: reason
24572
- }))
24573
- })
24574
- })]
24575
- });
24576
- }
24577
24463
  const ADDITIONAL_INFORMATION_FORM_ID = "additionalInformation";
24578
24464
  const additionalInformationFields = [...LEGAL_COMPANY_NAME_FIELD, ...DBA_NAME_FIELD, ...BUSINESS_REGISTRATION_NUMBER_FIELD, ...TAX_INFORMATION_FIELD, ...VAT_NUMBER_FIELD, ...DATE_OF_INCORPORATION_FIELD, ...STOCK_EXCHANGE_MIC_FIELD, ...STOCK_ISIN_FIELD, ...STOCK_TICKER_SYMBOL_FIELD];
24579
24465
  function AdditionalInformationComponent({
@@ -24646,6 +24532,8 @@ function AdditionalInformationComponent({
24646
24532
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
24647
24533
  vatNumberType
24648
24534
  }, defaultFieldMetadata$7), acc);
24535
+ case "vatAbsenceReason":
24536
+ return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
24649
24537
  case "dateOfIncorporation":
24650
24538
  return {
24651
24539
  ...acc,
@@ -25760,7 +25648,6 @@ const Modal = ({
25760
25648
  size = "medium",
25761
25649
  title,
25762
25650
  isDismissible = true,
25763
- isOpen = true,
25764
25651
  onClose = noop,
25765
25652
  role: role2 = "dialog"
25766
25653
  }) => {
@@ -25768,10 +25655,10 @@ const Modal = ({
25768
25655
  i18n
25769
25656
  } = useI18nContext();
25770
25657
  const closeModal = useCallback(() => {
25771
- if (isOpen && isDismissible) {
25658
+ if (isDismissible) {
25772
25659
  onClose();
25773
25660
  }
25774
- }, [isDismissible, isOpen, onClose]);
25661
+ }, [isDismissible, onClose]);
25775
25662
  useEffect(() => {
25776
25663
  const handleEscapeKey = ({
25777
25664
  code: code2
@@ -25780,21 +25667,17 @@ const Modal = ({
25780
25667
  closeModal();
25781
25668
  }
25782
25669
  };
25783
- if (isOpen) {
25784
- document.documentElement.classList.add("u-overflow-hidden");
25785
- document.addEventListener("keydown", handleEscapeKey);
25786
- } else {
25670
+ document.documentElement.classList.add("u-overflow-hidden");
25671
+ document.addEventListener("keydown", handleEscapeKey);
25672
+ return () => {
25787
25673
  document.documentElement.classList.remove("u-overflow-hidden");
25788
25674
  document.removeEventListener("keydown", handleEscapeKey);
25789
- }
25790
- return () => document.removeEventListener("keydown", handleEscapeKey);
25791
- }, [closeModal, isDismissible, isOpen]);
25675
+ };
25676
+ }, [closeModal, isDismissible]);
25792
25677
  return jsx("div", {
25793
- className: cx("adyen-kyc-overlay", {
25794
- "adyen-kyc-overlay--visible": isOpen
25795
- }),
25678
+ className: cx("adyen-kyc-overlay", "adyen-kyc-overlay--visible"),
25796
25679
  role: "none",
25797
- children: isOpen && jsxs("div", {
25680
+ children: jsxs("div", {
25798
25681
  className: cx(classNames == null ? void 0 : classNames.modal, "adyen-kyc-modal", {
25799
25682
  "adyen-kyc-modal--small": size === "small",
25800
25683
  "adyen-kyc-modal--large": size === "large"
@@ -28196,6 +28079,8 @@ function CompanyOtherDetails({
28196
28079
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
28197
28080
  vatNumberType
28198
28081
  }, defaultFieldMetadata$7), acc);
28082
+ case "vatAbsenceReason":
28083
+ return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
28199
28084
  default:
28200
28085
  return acc;
28201
28086
  }
@@ -39078,7 +38963,7 @@ const ConfigurationApiProvider = ({
39078
38963
  isEmbeddedDropin,
39079
38964
  loadingContext
39080
38965
  } = authContext;
39081
- const sdkVersion = "3.21.2";
38966
+ const sdkVersion = "3.21.4";
39082
38967
  useAnalytics({
39083
38968
  onUserEvent,
39084
38969
  legalEntityId: rootLegalEntityId,
@@ -3,8 +3,8 @@ import type { CompanyTypesValue } from '../../core/models/api/company-types-valu
3
3
  import type { CountryCode } from '../../core/models/country-code';
4
4
  import type { BusinessRegistrationNumberSchema } from '../internal/BusinessRegistrationNumber/types';
5
5
  import type { TaxIdSchema } from '../internal/TaxId/types';
6
- import type { VatNumberSchema } from '../internal/VatNumber/types';
7
- export interface CompanyRegistrationDetailsSchema extends BusinessRegistrationNumberSchema, TaxIdSchema, VatNumberSchema {
6
+ import type { VatNumberFieldSchema } from '../internal/VatNumberField/types';
7
+ export interface CompanyRegistrationDetailsSchema extends BusinessRegistrationNumberSchema, TaxIdSchema, VatNumberFieldSchema {
8
8
  tradingName?: string;
9
9
  sameNameAsLegalName?: boolean;
10
10
  stockExchangeMIC?: string;
@@ -131,12 +131,21 @@ export declare const taxIdNumberOptions: {
131
131
  readonly name: "socialSecurityNumber";
132
132
  readonly applicableOnlyFor: readonly [CompanyTypesValue.SOLE_PROPRIETORSHIP];
133
133
  }];
134
+ readonly PR: readonly [{
135
+ readonly id: "EIN";
136
+ readonly name: "ein";
137
+ }, {
138
+ readonly id: "SSN";
139
+ readonly name: "ssn";
140
+ readonly applicableOnlyFor: readonly [CompanyTypesValue.SOLE_PROPRIETORSHIP];
141
+ }];
134
142
  readonly US: readonly [{
135
143
  readonly id: "EIN";
136
144
  readonly name: "ein";
137
145
  }, {
138
146
  readonly id: "SSN";
139
147
  readonly name: "ssn";
148
+ readonly applicableOnlyFor: readonly [CompanyTypesValue.SOLE_PROPRIETORSHIP];
140
149
  }];
141
150
  };
142
151
  export declare const getTaxIdNumberOptions: (country: CountryCode, companyType: CompanyTypesValue | LegalEntityType.TRUST | undefined) => readonly TaxIdNumberOption[] | undefined;
@@ -13,9 +13,8 @@ export interface ModalProps {
13
13
  footer?: string;
14
14
  };
15
15
  isDismissible?: boolean;
16
- isOpen?: boolean;
17
16
  title?: string;
18
17
  onClose?: () => void;
19
18
  role?: JSX.AriaRole;
20
19
  }
21
- export declare const Modal: ({ content, footer, header, classNames, size, title, isDismissible, isOpen, onClose, role, }: ModalProps) => JSX.Element;
20
+ export declare const Modal: ({ content, footer, header, classNames, size, title, isDismissible, onClose, role, }: ModalProps) => JSX.Element;
@@ -1,10 +1,11 @@
1
1
  import type { FieldMetadata } from '../../../core/models/country-config';
2
2
  import type { PerCountryFieldConfig } from '../../../core/models/field-configurations';
3
3
  import type { TaxIdNumberType } from '../IdFieldTypeSelector/countryIdNumberTypes';
4
- import type { VatNumberSchema } from './types';
4
+ import type { VatNumberFieldSchema } from './types';
5
+ export declare const vatAbsenceReasonMetadata: FieldMetadata<VatNumberFieldSchema, 'vatAbsenceReason'>;
5
6
  interface FieldConfigParams {
6
7
  vatNumberType: TaxIdNumberType | undefined;
7
8
  }
8
- export declare const defaultFieldMetadata: FieldMetadata<VatNumberSchema, 'vatNumber'>;
9
- export declare const defaultFieldConfig: PerCountryFieldConfig<VatNumberSchema, 'vatNumber', FieldConfigParams>;
9
+ export declare const defaultFieldMetadata: FieldMetadata<VatNumberFieldSchema, 'vatNumber'>;
10
+ export declare const defaultFieldConfig: PerCountryFieldConfig<VatNumberFieldSchema, 'vatNumber', FieldConfigParams>;
10
11
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "3.21.2",
3
+ "version": "3.21.4",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,3 +0,0 @@
1
- import type { VatNumberProps, VatNumberSchema } from './types';
2
- export declare const vatNumberFields: Array<keyof VatNumberSchema>;
3
- export default function VatNumber(props: VatNumberProps): import("preact").JSX.Element;
@@ -1 +0,0 @@
1
- export { default, vatNumberFields } from './VatNumber';
@@ -1,12 +0,0 @@
1
- import type { BaseInnerFormProps } from '../../../core/hooks/useForm';
2
- import type { CountryCode } from '../../../core/models/country-code';
3
- import type { defaultFieldConfig } from './fieldConfig';
4
- export interface VatNumberSchema {
5
- vatNumber?: string;
6
- exemptedFromVat?: boolean;
7
- vatAbsenceReason?: string;
8
- }
9
- export interface VatNumberProps extends BaseInnerFormProps<VatNumberSchema> {
10
- country: CountryCode;
11
- fieldConfig?: typeof defaultFieldConfig;
12
- }