@adyen/kyc-components 3.0.0 → 3.0.2
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.
|
@@ -6187,6 +6187,7 @@ const nonInputs = (str, options) => Array.from(str).map((char) => ({
|
|
|
6187
6187
|
includeInValue: (options == null ? void 0 : options.includeInValue) ?? false,
|
|
6188
6188
|
displayEagerly: (options == null ? void 0 : options.displayEagerly) ?? true
|
|
6189
6189
|
}));
|
|
6190
|
+
const spacer = nonInputs(" ")[0];
|
|
6190
6191
|
const alphaInputs = (length, optional = false) => makeArrayOfRepeatedObjects(length, {
|
|
6191
6192
|
type: "input",
|
|
6192
6193
|
allow: /[A-Za-z]/,
|
|
@@ -6374,7 +6375,15 @@ const businessRegistrationNumberMasks = {
|
|
|
6374
6375
|
default: {
|
|
6375
6376
|
mask: makeMask(...nonInputs("FL", {
|
|
6376
6377
|
includeInValue: true
|
|
6377
|
-
}),
|
|
6378
|
+
}), spacer, ...nonInputs("-", {
|
|
6379
|
+
includeInValue: true
|
|
6380
|
+
}), spacer, ...numericInputs(4), spacer, ...nonInputs(".", {
|
|
6381
|
+
includeInValue: true
|
|
6382
|
+
}), spacer, ...numericInputs(3), spacer, ...nonInputs(".", {
|
|
6383
|
+
includeInValue: true
|
|
6384
|
+
}), spacer, ...numericInputs(3), spacer, ...nonInputs("-", {
|
|
6385
|
+
includeInValue: true
|
|
6386
|
+
}), spacer, ...numericInputs(1))
|
|
6378
6387
|
}
|
|
6379
6388
|
},
|
|
6380
6389
|
[CountryCodes.Lithuania]: {
|
|
@@ -6438,7 +6447,11 @@ const businessRegistrationNumberMasks = {
|
|
|
6438
6447
|
},
|
|
6439
6448
|
[CountryCodes.Romania]: {
|
|
6440
6449
|
default: {
|
|
6441
|
-
mask: makeMask(...alphaInputs(1), ...numericInputs(2),
|
|
6450
|
+
mask: makeMask(...alphaInputs(1), ...numericInputs(2), spacer, ...nonInputs("/", {
|
|
6451
|
+
includeInValue: true
|
|
6452
|
+
}), spacer, ...numericInputs(1), ...numericInputs(8, true), spacer, ...nonInputs("/", {
|
|
6453
|
+
includeInValue: true
|
|
6454
|
+
}), spacer, ...numericInputs(4)),
|
|
6442
6455
|
transformOnType: uppercase
|
|
6443
6456
|
}
|
|
6444
6457
|
},
|
|
@@ -6528,7 +6541,7 @@ const businessRegistrationNumberPatterns = {
|
|
|
6528
6541
|
soleProprietorship: /^\d{8}$/
|
|
6529
6542
|
},
|
|
6530
6543
|
[CountryCodes.Cyprus]: {
|
|
6531
|
-
default: /^[
|
|
6544
|
+
default: /^[A-Z]{1,2}\d{1,8}$/
|
|
6532
6545
|
},
|
|
6533
6546
|
[CountryCodes.CzechRepublic]: {
|
|
6534
6547
|
default: /^\d{8,10}$/
|
|
@@ -6635,7 +6648,7 @@ const businessRegistrationNumberPatterns = {
|
|
|
6635
6648
|
default: /^\d{9}$/
|
|
6636
6649
|
},
|
|
6637
6650
|
[CountryCodes.Romania]: {
|
|
6638
|
-
default: /^
|
|
6651
|
+
default: /^[A-Z]\d{2}\/\d{1,9}\/\d{4}$/
|
|
6639
6652
|
},
|
|
6640
6653
|
[CountryCodes.Singapore]: {
|
|
6641
6654
|
default: /^[a-zA-Z0-9]{9,10}$/
|
|
@@ -6810,7 +6823,7 @@ const defaultFieldConfig = {
|
|
|
6810
6823
|
helperText: {
|
|
6811
6824
|
key: "enterAMaximumOfNCharactersWithAMixForExample",
|
|
6812
6825
|
values: {
|
|
6813
|
-
|
|
6826
|
+
maxChars: "9",
|
|
6814
6827
|
example: "T1001a, FN89060n"
|
|
6815
6828
|
}
|
|
6816
6829
|
}
|
|
@@ -7310,7 +7323,7 @@ const defaultFieldConfig = {
|
|
|
7310
7323
|
helperText: {
|
|
7311
7324
|
key: "enterAMaximumOfNMoreDigitsForExample",
|
|
7312
7325
|
values: {
|
|
7313
|
-
|
|
7326
|
+
maxDigits: "15",
|
|
7314
7327
|
example: "J40/8302/1997"
|
|
7315
7328
|
}
|
|
7316
7329
|
}
|
|
@@ -7322,8 +7335,8 @@ const defaultFieldConfig = {
|
|
|
7322
7335
|
helperText: {
|
|
7323
7336
|
key: "enterXToYCharactersWithAMixForExample",
|
|
7324
7337
|
values: {
|
|
7325
|
-
|
|
7326
|
-
|
|
7338
|
+
minChars: "9",
|
|
7339
|
+
maxChars: "10",
|
|
7327
7340
|
example: "200312345A"
|
|
7328
7341
|
}
|
|
7329
7342
|
}
|
|
@@ -7975,6 +7988,24 @@ function CompanyRegistrationNumberTypeSelector({
|
|
|
7975
7988
|
})
|
|
7976
7989
|
});
|
|
7977
7990
|
}
|
|
7991
|
+
const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
|
|
7992
|
+
const optionsForCountry = companyRegistrationNumberOptions[country2];
|
|
7993
|
+
const metadataFn = defaultFieldConfig[country2];
|
|
7994
|
+
if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
|
|
7995
|
+
return void 0;
|
|
7996
|
+
for (const option of optionsForCountry) {
|
|
7997
|
+
const fieldMetadata = metadataFn({
|
|
7998
|
+
companyType: companyType2,
|
|
7999
|
+
registrationNumberType: option.id
|
|
8000
|
+
});
|
|
8001
|
+
if (!fieldMetadata.validators)
|
|
8002
|
+
continue;
|
|
8003
|
+
const validators = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
|
|
8004
|
+
if (validators.every((validator) => validator.validate(registrationNumber2))) {
|
|
8005
|
+
return option.id;
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
};
|
|
7978
8009
|
function TaxIdNumberTypeSelector({
|
|
7979
8010
|
country: country2,
|
|
7980
8011
|
selected,
|
|
@@ -8991,14 +9022,14 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
|
|
|
8991
9022
|
}];
|
|
8992
9023
|
const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", ...vatNumberFields, ...taxIdFields, "dateOfIncorporation"];
|
|
8993
9024
|
function CompanyRegistrationDetailsComponent(props) {
|
|
8994
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
9025
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8995
9026
|
const {
|
|
8996
9027
|
i18n
|
|
8997
9028
|
} = useI18nContext();
|
|
8998
9029
|
const {
|
|
8999
9030
|
isExperimentEnabled
|
|
9000
9031
|
} = useExperimentsContext();
|
|
9001
|
-
const
|
|
9032
|
+
const isTypeSelectorEnabled = isExperimentEnabled(ExperimentNames.EnableIdentityFieldTypeSelector);
|
|
9002
9033
|
const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === props.country && f.companyType.includes(props.companyType));
|
|
9003
9034
|
const stateRef = useRef({
|
|
9004
9035
|
setState: null
|
|
@@ -9031,8 +9062,8 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9031
9062
|
rules: companyRegistrationDetailsValidationRules,
|
|
9032
9063
|
fieldProblems: props == null ? void 0 : props.fieldValidationErrors
|
|
9033
9064
|
});
|
|
9034
|
-
const defaultRegistrationNumberType =
|
|
9035
|
-
const defaultVatNumberType = ((
|
|
9065
|
+
const defaultRegistrationNumberType = props.data.registrationNumber ? inferCompanyRegistrationNumberType(props.data.registrationNumber, props.country, props.companyType) : (_e = companyRegistrationNumberOptions[companyCountry2]) == null ? void 0 : _e[0].id;
|
|
9066
|
+
const defaultVatNumberType = ((_f = taxIdNumberOptions[companyCountry2]) == null ? void 0 : _f[0].id) ?? ((_g = props.labels) == null ? void 0 : _g.vatNumber);
|
|
9036
9067
|
const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
|
|
9037
9068
|
const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
|
|
9038
9069
|
useEffect(() => {
|
|
@@ -9200,7 +9231,7 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9200
9231
|
"aria-label": formUtils.getLabel("stockISIN"),
|
|
9201
9232
|
"aria-invalid": !valid.stockISIN
|
|
9202
9233
|
})
|
|
9203
|
-
}),
|
|
9234
|
+
}), isTypeSelectorEnabled && formUtils.isRequiredField("registrationNumber") && jsx(CompanyRegistrationNumberTypeSelector, {
|
|
9204
9235
|
companyType: props.companyType,
|
|
9205
9236
|
country: props.country,
|
|
9206
9237
|
setSelected: setRegistrationNumberType,
|
|
@@ -9212,7 +9243,7 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9212
9243
|
dataStoreId: COMPANY_REGISTRATION_DETAILS,
|
|
9213
9244
|
labels: registrationNumberCustomLabel,
|
|
9214
9245
|
registrationNumberType
|
|
9215
|
-
}),
|
|
9246
|
+
}), isTypeSelectorEnabled && formUtils.isRequiredField("vatNumber") && jsx(TaxIdNumberTypeSelector, {
|
|
9216
9247
|
country: props.country,
|
|
9217
9248
|
setSelected: setVatNumberType,
|
|
9218
9249
|
selected: vatNumberType
|
package/dist/types/components/internal/IdFieldTypeSelector/inferCompanyRegistrationNumberType.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompanyTypesValue } from '../../../core/models/api/company-types-value';
|
|
2
|
+
import { CountryCode } from '../../../core/models/country-code';
|
|
3
|
+
import { CompanyRegistrationNumberType } from './countryIdNumberTypes';
|
|
4
|
+
/**
|
|
5
|
+
* For existing data, we need to infer the company registration number type from the existing data.
|
|
6
|
+
* Otherwise, the incorrect mask will be applied.
|
|
7
|
+
* We don't store this choice in the API.
|
|
8
|
+
* @param registrationNumber the existing company registration number
|
|
9
|
+
* @param country the country of the LE
|
|
10
|
+
* @param companyType the company type, e.g. `nonProfit`
|
|
11
|
+
*/
|
|
12
|
+
export declare const inferCompanyRegistrationNumberType: (registrationNumber: string, country: CountryCode, companyType: CompanyTypesValue) => CompanyRegistrationNumberType | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputToken, Mask, MaskToken, NonInputToken } from './maskTypes';
|
|
2
2
|
export declare const nonInputs: (str: string, options?: Partial<NonInputToken>) => NonInputToken[];
|
|
3
|
+
export declare const spacer: NonInputToken;
|
|
3
4
|
export declare const alphaInputs: (length: number, optional?: boolean) => InputToken[];
|
|
4
5
|
export declare const numericInputs: (length: number, optional?: boolean) => InputToken[];
|
|
5
6
|
export declare const alphanumericInputs: (length: number, optional?: boolean) => InputToken[];
|