@adyen/kyc-components 3.21.2 → 3.21.3

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.
@@ -8799,159 +8799,6 @@ function InputDate(props) {
8799
8799
  maxLength: 10
8800
8800
  });
8801
8801
  }
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
8802
  const defaultFieldMetadata$8 = {
8956
8803
  label: "taxId"
8957
8804
  };
@@ -9251,6 +9098,9 @@ const defaultFieldConfig$8 = {
9251
9098
  validators: validatePatternOnBlur(/^\d{12}$/)
9252
9099
  }
9253
9100
  };
9101
+ const vatAbsenceReasonMetadata = {
9102
+ validators: [validateNotEmptyOnBlur]
9103
+ };
9254
9104
  const defaultFieldMetadata$7 = {
9255
9105
  label: "vatNumber"
9256
9106
  };
@@ -9898,6 +9748,159 @@ const inferTaxIdNumberType = (taxId2, country2, companyType2) => {
9898
9748
  }
9899
9749
  }
9900
9750
  };
9751
+ const STOCK_EXCHANGE_MIC_FIELD = ["stockExchangeMIC"];
9752
+ function StockExchangeMICField({
9753
+ data,
9754
+ valid,
9755
+ errors,
9756
+ labels: labels2,
9757
+ placeholders,
9758
+ readonly,
9759
+ mask,
9760
+ guidanceText,
9761
+ shouldValidate,
9762
+ handleChangeFor
9763
+ }) {
9764
+ return jsx(MaskedInputText, {
9765
+ name: "stockExchangeMIC",
9766
+ label: labels2.stockExchangeMIC ?? "",
9767
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockExchangeMIC,
9768
+ placeholder: placeholders == null ? void 0 : placeholders.stockExchangeMIC,
9769
+ ...mask,
9770
+ classNameModifiers: {
9771
+ field: ["stockExchangeMIC"],
9772
+ input: ["stockExchangeMIC"]
9773
+ },
9774
+ errorMessage: errors.stockExchangeMIC,
9775
+ isValid: valid.stockExchangeMIC ?? false,
9776
+ value: data.stockExchangeMIC ?? "",
9777
+ readonly,
9778
+ shouldValidate,
9779
+ onInput: handleChangeFor("stockExchangeMIC", "input"),
9780
+ onBlur: handleChangeFor("stockExchangeMIC", "blur"),
9781
+ "aria-required": true,
9782
+ "aria-label": labels2.stockExchangeMIC,
9783
+ "aria-invalid": !valid.stockExchangeMIC
9784
+ });
9785
+ }
9786
+ const stockExchangeMICFieldMetadata = {
9787
+ label: "stockExchangeMIC",
9788
+ validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[a-zA-Z0-9]{4}$/)],
9789
+ mask: {
9790
+ mask: makeMask(...alphanumericInputs(4)),
9791
+ transformOnType: uppercase
9792
+ },
9793
+ guidanceText: {
9794
+ key: "enterNCharactersForExample",
9795
+ values: {
9796
+ numChars: "4",
9797
+ example: "XNAS"
9798
+ }
9799
+ }
9800
+ };
9801
+ const STOCK_ISIN_FIELD = ["stockISIN"];
9802
+ function StockISINField({
9803
+ data,
9804
+ valid,
9805
+ errors,
9806
+ labels: labels2,
9807
+ placeholders,
9808
+ readonly,
9809
+ mask,
9810
+ guidanceText,
9811
+ shouldValidate,
9812
+ handleChangeFor
9813
+ }) {
9814
+ return jsx(MaskedInputText, {
9815
+ name: "stockISIN",
9816
+ label: labels2.stockISIN ?? "",
9817
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockISIN,
9818
+ placeholder: placeholders == null ? void 0 : placeholders.stockISIN,
9819
+ ...mask,
9820
+ classNameModifiers: {
9821
+ field: ["stockISIN"],
9822
+ input: ["stockISIN"]
9823
+ },
9824
+ errorMessage: errors.stockISIN,
9825
+ isValid: valid.stockISIN ?? false,
9826
+ value: data.stockISIN ?? "",
9827
+ readonly,
9828
+ shouldValidate,
9829
+ onInput: handleChangeFor("stockISIN", "input"),
9830
+ onBlur: handleChangeFor("stockISIN", "blur"),
9831
+ "aria-required": true,
9832
+ "aria-label": labels2.stockISIN,
9833
+ "aria-invalid": !valid.stockISIN
9834
+ });
9835
+ }
9836
+ const stockISINFieldMetadata = {
9837
+ label: "stockISIN",
9838
+ validators: [validateNotEmptyOnBlur, {
9839
+ modes: ["blur"],
9840
+ validate: (value) => !!value && isISIN(value)
9841
+ }],
9842
+ mask: {
9843
+ mask: makeMask(...alphaInputs(2), ...alphanumericInputs(9), ...numericInputs(1)),
9844
+ transformOnType: uppercase
9845
+ },
9846
+ helperText: "stockISINHelper",
9847
+ guidanceText: {
9848
+ key: "validationPleaseEnterAValidStockISIN",
9849
+ values: {
9850
+ example: "NL0012969182"
9851
+ }
9852
+ }
9853
+ };
9854
+ const STOCK_TICKER_SYMBOL_FIELD = ["stockTickerSymbol"];
9855
+ function StockTickerSymbolField({
9856
+ data,
9857
+ valid,
9858
+ errors,
9859
+ labels: labels2,
9860
+ placeholders,
9861
+ readonly,
9862
+ mask,
9863
+ guidanceText,
9864
+ shouldValidate,
9865
+ handleChangeFor
9866
+ }) {
9867
+ return jsx(MaskedInputText, {
9868
+ name: "stockTickerSymbol",
9869
+ label: labels2.stockTickerSymbol ?? "",
9870
+ formatGuidance: guidanceText == null ? void 0 : guidanceText.stockTickerSymbol,
9871
+ placeholder: placeholders == null ? void 0 : placeholders.stockTickerSymbol,
9872
+ ...mask,
9873
+ classNameModifiers: {
9874
+ field: ["stockTickerSymbol"],
9875
+ input: ["stockTickerSymbol"]
9876
+ },
9877
+ errorMessage: errors.stockTickerSymbol,
9878
+ isValid: valid.stockTickerSymbol ?? false,
9879
+ value: data.stockTickerSymbol ?? "",
9880
+ readonly,
9881
+ shouldValidate,
9882
+ onInput: handleChangeFor("stockTickerSymbol", "input"),
9883
+ onBlur: handleChangeFor("stockTickerSymbol", "blur"),
9884
+ "aria-required": true,
9885
+ "aria-label": labels2.stockTickerSymbol,
9886
+ "aria-invalid": !valid.stockTickerSymbol
9887
+ });
9888
+ }
9889
+ const stockTickerSymbolFieldMetadata = {
9890
+ label: "stockTickerSymbol",
9891
+ validators: [validateNotEmptyOnBlur, validatePatternOnBlur(/^[A-Z\d]{1,5}$/)],
9892
+ mask: {
9893
+ mask: makeMask(...alphanumericInputs(1), ...alphanumericInputs(4)),
9894
+ transformOnType: uppercase
9895
+ },
9896
+ guidanceText: {
9897
+ key: "enterAMaximumOfNCharactersForExample",
9898
+ values: {
9899
+ maxChars: "5",
9900
+ example: "ADYEN"
9901
+ }
9902
+ }
9903
+ };
9901
9904
  function TaxIdNumberTypeSelector({
9902
9905
  country: country2,
9903
9906
  companyType: companyType2,
@@ -10121,16 +10124,24 @@ const vatAbsenceReasons = [
10121
10124
  "belowTaxThreshold"
10122
10125
  /* BelowTaxThreshold */
10123
10126
  ];
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;
10127
+ const VAT_NUMBER_FIELD = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
10128
+ function VatNumberField({
10129
+ data,
10130
+ valid,
10131
+ errors,
10132
+ labels: labels2,
10133
+ mask,
10134
+ guidanceText,
10135
+ placeholders,
10136
+ readonly,
10137
+ shouldValidate,
10138
+ handleChangeFor,
10139
+ canExempt,
10140
+ country: country2,
10141
+ vatNumberType,
10142
+ setVatNumberType
10143
+ }) {
10144
+ var _a;
10134
10145
  const {
10135
10146
  isExperimentEnabled
10136
10147
  } = useExperimentsContext();
@@ -10142,115 +10153,64 @@ function VatNumber(props) {
10142
10153
  id: VatAbsenceReason.CountryWithoutVatOrGstSystem,
10143
10154
  name: VatAbsenceReason.CountryWithoutVatOrGstSystem
10144
10155
  }]);
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) {
10156
+ const showVatExemptedOption = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
10157
+ const handleVatNumberTypeChange = (vatType) => {
10158
+ if (vatType === "exempted") {
10159
+ if (!canExempt) {
10201
10160
  throw Error(`${country2} does not allow VAT exemptions`);
10202
10161
  }
10203
10162
  handleChangeFor("exemptedFromVat")(true);
10204
- setTaxIdNumberType(void 0);
10163
+ setVatNumberType(void 0);
10205
10164
  return;
10206
10165
  }
10207
- if (exemptionIsPossible && data.exemptedFromVat === true) {
10166
+ if (canExempt && data.exemptedFromVat === true) {
10208
10167
  handleChangeFor("exemptedFromVat")(false);
10209
10168
  }
10210
- setTaxIdNumberType(taxIdType);
10169
+ setVatNumberType(vatType);
10211
10170
  };
10212
10171
  return jsxs("div", {
10213
- className: "adyen-kyc-field--tax-id",
10214
- children: [jsx(StateContextSetter, {
10215
- stateRef
10216
- }), jsx(TaxIdNumberTypeSelector, {
10172
+ className: "adyen-kyc-field__vat-number",
10173
+ children: [jsx(TaxIdNumberTypeSelector, {
10217
10174
  country: country2,
10218
- setSelected: handleTaxIdNumberTypeChange,
10219
- selected: data.exemptedFromVat ? "exempted" : taxIdNumberType,
10220
- exemptedOption: showTaxIdExemptedOption ? formUtils.getLabel("exemptedFromVat", "iDontHaveAVatNumber") : false
10175
+ setSelected: handleVatNumberTypeChange,
10176
+ selected: data.exemptedFromVat ? "exempted" : vatNumberType,
10177
+ exemptedOption: showVatExemptedOption ? labels2.exemptedFromVat : false
10221
10178
  }), jsx(MaskedInputText, {
10222
- name: "vatNumber",
10223
- label: formUtils.getLabel("vatNumber"),
10224
- formatGuidance: formUtils.getGuidanceText("vatNumber"),
10225
- ...formUtils.getMask("vatNumber"),
10179
+ "aria-required": true,
10180
+ "aria-label": labels2.vatNumber,
10181
+ "aria-invalid": !valid.vatNumber,
10226
10182
  classNameModifiers: {
10227
10183
  field: ["tax-id"],
10228
10184
  input: ["vatNumber"]
10229
10185
  },
10230
- errorMessage: formUtils.getErrorMessage("vatNumber", errors, fieldProblems),
10231
- shouldValidate: props.shouldValidate,
10232
- isValid: valid.vatNumber,
10233
- value: data.vatNumber ?? "",
10234
- readonly: formUtils.isReadOnly("vatNumber"),
10186
+ name: "vatNumber",
10187
+ value: (data == null ? void 0 : data.vatNumber) ?? "",
10188
+ label: labels2.vatNumber ?? "",
10189
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.vatNumber) ?? "",
10190
+ placeholder: placeholders == null ? void 0 : placeholders.vatNumber,
10191
+ errorMessage: errors.vatNumber,
10192
+ isValid: Boolean(valid.vatNumber),
10235
10193
  onInput: handleChangeFor("vatNumber", "input"),
10236
10194
  onBlur: handleChangeFor("vatNumber", "blur"),
10237
- disabled: data.exemptedFromVat
10238
- }), formUtils.isRequiredField("exemptedFromVat") && !showTaxIdExemptedOption && jsx(Checkbox, {
10195
+ disabled: data.exemptedFromVat,
10196
+ readonly,
10197
+ shouldValidate,
10198
+ ...mask
10199
+ }), canExempt && !showVatExemptedOption && jsx(Checkbox, {
10200
+ "aria-required": false,
10201
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
10202
+ "aria-invalid": false,
10239
10203
  name: "exemptedFromVat",
10240
- label: formUtils.getLabel("exemptedFromVat", "iDontHaveAVatNumber"),
10204
+ label: labels2 == null ? void 0 : labels2.exemptedFromVat,
10241
10205
  value: "exemptedFromVat",
10242
- readonly: formUtils.isReadOnly("exemptedFromVat"),
10243
10206
  classNameModifiers: ["exempted-from-tax"],
10244
10207
  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, {
10208
+ onChange: handleChangeFor("exemptedFromVat")
10209
+ }), data.exemptedFromVat && jsx(Field, {
10250
10210
  name: "vatAbsenceReason",
10251
10211
  classNameModifiers: ["tax-id-absence-reason"],
10252
- label: formUtils.getLabel("vatAbsenceReason", "vatAbsenceReason"),
10253
- errorMessage: formUtils.getErrorMessage("vatAbsenceReason", errors, fieldProblems),
10212
+ label: labels2 == null ? void 0 : labels2.vatAbsenceReason,
10213
+ errorMessage: errors.vatAbsenceReason,
10254
10214
  isValid: valid.vatAbsenceReason,
10255
10215
  children: (childProps) => jsx(RadioGroup, {
10256
10216
  ...childProps,
@@ -10262,7 +10222,7 @@ function VatNumber(props) {
10262
10222
  name: reason
10263
10223
  }))
10264
10224
  })
10265
- }) : null]
10225
+ })]
10266
10226
  });
10267
10227
  }
10268
10228
  const companyRegistrationDetailsValidationRules = {
@@ -10300,27 +10260,33 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
10300
10260
  companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
10301
10261
  country: CountryCodes.PuertoRico
10302
10262
  }];
10303
- const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", "stockTickerSymbol", ...vatNumberFields, ...taxIdFields, "dateOfIncorporation"];
10263
+ const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", "stockTickerSymbol", ...VAT_NUMBER_FIELD, ...taxIdFields, "dateOfIncorporation"];
10304
10264
  function CompanyRegistrationDetailsComponent(props) {
10305
- var _a, _b;
10265
+ var _a, _b, _c;
10306
10266
  const {
10307
10267
  i18n
10308
10268
  } = useI18nContext();
10269
+ const {
10270
+ companyNameAndCountry
10271
+ } = useGlobalData();
10309
10272
  let mergedProps = props;
10273
+ 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;
10274
+ const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
10310
10275
  mergedProps = mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, mergedProps);
10311
10276
  mergedProps = mergeFieldMetadataIntoProps("stockISIN", stockISINFieldMetadata, mergedProps);
10312
10277
  mergedProps = mergeFieldMetadataIntoProps("stockTickerSymbol", stockTickerSymbolFieldMetadata, mergedProps);
10278
+ mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[mergedProps.country], {
10279
+ vatNumberType
10280
+ }, defaultFieldMetadata$7), mergedProps);
10281
+ mergedProps = mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, mergedProps);
10313
10282
  const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === mergedProps.country && f.companyType.includes(mergedProps.companyType));
10314
10283
  const stateRef = useRef({
10315
10284
  setState: null
10316
10285
  });
10317
- const COMPANY_REGISTRATION_DETAILS = mergedProps.id;
10286
+ const COMPANY_REGISTRATION_DETAILS = mergedProps.id ?? "companyRegistrationDetails";
10318
10287
  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;
10288
+ const directChildFields = requiredFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation", "vatNumber"].includes(field));
10289
+ const legalCompanyName2 = companyNameAndCountry == null ? void 0 : companyNameAndCountry.legalCompanyName;
10324
10290
  const isSameNameAsLegalName = !mergedProps.data.tradingName ? true : mergedProps.data.tradingName === legalCompanyName2;
10325
10291
  const {
10326
10292
  handleChangeFor,
@@ -10333,7 +10299,7 @@ function CompanyRegistrationDetailsComponent(props) {
10333
10299
  setData
10334
10300
  } = useForm({
10335
10301
  ...mergedProps,
10336
- schema: directChildFields,
10302
+ 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
10303
  defaultData: {
10338
10304
  ...mergedProps.data,
10339
10305
  sameNameAsLegalName: isSameNameAsLegalName,
@@ -10376,7 +10342,6 @@ function CompanyRegistrationDetailsComponent(props) {
10376
10342
  setData("tradingName", tradingNameIsSameAsLegalName ? legalCompanyName2 : "");
10377
10343
  };
10378
10344
  const registrationNumberProps = getFieldProps(mergedProps, businessRegistrationNumberFields);
10379
- const vatNumberProps = getFieldProps(mergedProps, vatNumberFields);
10380
10345
  const taxIdProps = getFieldProps(mergedProps, taxIdFields);
10381
10346
  const handleChange = ({
10382
10347
  currentState,
@@ -10387,7 +10352,7 @@ function CompanyRegistrationDetailsComponent(props) {
10387
10352
  let schema = requiredFields;
10388
10353
  let hasSchemaChanged = false;
10389
10354
  if (formUtils.isRequiredField("vatNumber")) {
10390
- schema = currentData.exemptedFromVat ? schema.filter((child) => child !== "vatNumber") : schema.filter((child) => child !== "vatAbsenceReason");
10355
+ schema = currentData.exemptedFromVat ? schema.filter((child) => child !== "vatNumber") : schema.filter((child) => child !== "vatAbsenceReason" && child !== "exemptedFromVat");
10391
10356
  hasSchemaChanged = true;
10392
10357
  }
10393
10358
  if (formUtils.isRequiredField("taxId") && currentData.exemptedFromTax) {
@@ -10501,10 +10466,22 @@ function CompanyRegistrationDetailsComponent(props) {
10501
10466
  companyType: mergedProps.companyType,
10502
10467
  country: mergedProps.country,
10503
10468
  dataStoreId: COMPANY_REGISTRATION_DETAILS
10504
- }), formUtils.isRequiredField("vatNumber") && jsx(VatNumber, {
10505
- ...vatNumberProps,
10506
- dataStoreId: COMPANY_REGISTRATION_DETAILS,
10507
- country: mergedProps.country
10469
+ }), formUtils.isRequiredField("vatNumber") && jsx(VatNumberField, {
10470
+ data: formUtils.getFieldData(data, VAT_NUMBER_FIELD),
10471
+ valid: formUtils.getFieldValid(valid, VAT_NUMBER_FIELD),
10472
+ errors: formUtils.getFieldErrors(errors, fieldProblems, VAT_NUMBER_FIELD),
10473
+ labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
10474
+ exemptedFromVat: "iDontHaveAVatNumber"
10475
+ }),
10476
+ mask: formUtils.getMask("vatNumber"),
10477
+ guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
10478
+ placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
10479
+ readonly: formUtils.isReadOnly("vatNumber"),
10480
+ handleChangeFor,
10481
+ country: mergedProps.country,
10482
+ canExempt: formUtils.isRequiredField("exemptedFromVat"),
10483
+ vatNumberType,
10484
+ setVatNumberType
10508
10485
  }), formUtils.isRequiredField("taxId") && jsx(TaxId, {
10509
10486
  ...taxIdProps,
10510
10487
  dataStoreId: COMPANY_REGISTRATION_DETAILS,
@@ -24473,107 +24450,6 @@ const defaultFieldConfig$1 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig
24473
24450
  };
24474
24451
  }
24475
24452
  }), {});
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
24453
  const ADDITIONAL_INFORMATION_FORM_ID = "additionalInformation";
24578
24454
  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
24455
  function AdditionalInformationComponent({
@@ -24646,6 +24522,8 @@ function AdditionalInformationComponent({
24646
24522
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
24647
24523
  vatNumberType
24648
24524
  }, defaultFieldMetadata$7), acc);
24525
+ case "vatAbsenceReason":
24526
+ return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
24649
24527
  case "dateOfIncorporation":
24650
24528
  return {
24651
24529
  ...acc,
@@ -25760,7 +25638,6 @@ const Modal = ({
25760
25638
  size = "medium",
25761
25639
  title,
25762
25640
  isDismissible = true,
25763
- isOpen = true,
25764
25641
  onClose = noop,
25765
25642
  role: role2 = "dialog"
25766
25643
  }) => {
@@ -25768,10 +25645,10 @@ const Modal = ({
25768
25645
  i18n
25769
25646
  } = useI18nContext();
25770
25647
  const closeModal = useCallback(() => {
25771
- if (isOpen && isDismissible) {
25648
+ if (isDismissible) {
25772
25649
  onClose();
25773
25650
  }
25774
- }, [isDismissible, isOpen, onClose]);
25651
+ }, [isDismissible, onClose]);
25775
25652
  useEffect(() => {
25776
25653
  const handleEscapeKey = ({
25777
25654
  code: code2
@@ -25780,21 +25657,17 @@ const Modal = ({
25780
25657
  closeModal();
25781
25658
  }
25782
25659
  };
25783
- if (isOpen) {
25784
- document.documentElement.classList.add("u-overflow-hidden");
25785
- document.addEventListener("keydown", handleEscapeKey);
25786
- } else {
25660
+ document.documentElement.classList.add("u-overflow-hidden");
25661
+ document.addEventListener("keydown", handleEscapeKey);
25662
+ return () => {
25787
25663
  document.documentElement.classList.remove("u-overflow-hidden");
25788
25664
  document.removeEventListener("keydown", handleEscapeKey);
25789
- }
25790
- return () => document.removeEventListener("keydown", handleEscapeKey);
25791
- }, [closeModal, isDismissible, isOpen]);
25665
+ };
25666
+ }, [closeModal, isDismissible]);
25792
25667
  return jsx("div", {
25793
- className: cx("adyen-kyc-overlay", {
25794
- "adyen-kyc-overlay--visible": isOpen
25795
- }),
25668
+ className: cx("adyen-kyc-overlay", "adyen-kyc-overlay--visible"),
25796
25669
  role: "none",
25797
- children: isOpen && jsxs("div", {
25670
+ children: jsxs("div", {
25798
25671
  className: cx(classNames == null ? void 0 : classNames.modal, "adyen-kyc-modal", {
25799
25672
  "adyen-kyc-modal--small": size === "small",
25800
25673
  "adyen-kyc-modal--large": size === "large"
@@ -28196,6 +28069,8 @@ function CompanyOtherDetails({
28196
28069
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
28197
28070
  vatNumberType
28198
28071
  }, defaultFieldMetadata$7), acc);
28072
+ case "vatAbsenceReason":
28073
+ return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
28199
28074
  default:
28200
28075
  return acc;
28201
28076
  }
@@ -39078,7 +38953,7 @@ const ConfigurationApiProvider = ({
39078
38953
  isEmbeddedDropin,
39079
38954
  loadingContext
39080
38955
  } = authContext;
39081
- const sdkVersion = "3.21.2";
38956
+ const sdkVersion = "3.21.3";
39082
38957
  useAnalytics({
39083
38958
  onUserEvent,
39084
38959
  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;
@@ -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.3",
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
- }