@adyen/kyc-components 3.46.0 → 3.46.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.
@@ -3054,12 +3054,23 @@ function useGlobalDataSlice(sliceId, caller) {
3054
3054
  }),
3055
3055
  [sliceId, caller]
3056
3056
  );
3057
+ const clearState = useCallback(
3058
+ () => dispatch({
3059
+ type: "removeFromState",
3060
+ value: { dataStoreId: sliceId, caller }
3061
+ }),
3062
+ [sliceId, caller]
3063
+ );
3057
3064
  const updateStateSlice = useMemo(
3058
3065
  // can this debounce be useDebounce?
3059
3066
  () => debounce$1(updateState, ON_CHANGE_DEBOUNCE_DURATION),
3060
3067
  [updateState]
3061
3068
  );
3062
- return { sliceData, updateStateSlice };
3069
+ const clearStateSlice = useMemo(
3070
+ () => debounce$1(clearState, ON_CHANGE_DEBOUNCE_DURATION),
3071
+ [clearState]
3072
+ );
3073
+ return { sliceData, updateStateSlice, clearStateSlice };
3063
3074
  }
3064
3075
  function useResetGlobalData(caller) {
3065
3076
  const { dispatch } = useStateContext();
@@ -17478,6 +17489,11 @@ const validatePhoneCountryCodeNotEmptyOnBlur = {
17478
17489
  validate: (phone) => !isEmpty$1(phone == null ? void 0 : phone.phoneCountryCode),
17479
17490
  errorMessage: "missingPhoneCountryCode"
17480
17491
  };
17492
+ const validatePhoneNumberNotEmpty = {
17493
+ modes: ["blur"],
17494
+ validate: (phone) => !isEmpty$1(phone == null ? void 0 : phone.number),
17495
+ errorMessage: "invalidPhoneNumber"
17496
+ };
17481
17497
  const useAsyncPhoneValidationRules = () => {
17482
17498
  const { validatePhoneNumber: validatePhoneNumber2 } = useConfigurationApi();
17483
17499
  return useMemo(
@@ -17494,7 +17510,7 @@ const useAsyncPhoneValidationRules = () => {
17494
17510
  [validatePhoneNumber2]
17495
17511
  );
17496
17512
  };
17497
- const defaultValidators = [validatePhoneCountryCodeNotEmptyOnBlur];
17513
+ const defaultValidators = [validatePhoneCountryCodeNotEmptyOnBlur, validatePhoneNumberNotEmpty];
17498
17514
  const defaultFieldMetadata$6 = {
17499
17515
  label: "phoneNumber",
17500
17516
  validators: defaultValidators
@@ -22931,6 +22947,13 @@ function PayoutAccount(props) {
22931
22947
  const bankNameProps = getFieldProps(props, bankNameFields);
22932
22948
  const bankCodeProps = getFieldProps(props, bankCodeFields);
22933
22949
  const bankCityProps = getFieldProps(props, bankCityFields);
22950
+ const { clearStateSlice } = useGlobalDataSlice(
22951
+ "payoutAccountDetails"
22952
+ );
22953
+ const handleAccountFormatChange = (accountFormat2) => {
22954
+ clearStateSlice();
22955
+ setAccountFormat(accountFormat2);
22956
+ };
22934
22957
  return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
22935
22958
  /* @__PURE__ */ jsx(
22936
22959
  FormHeader,
@@ -22953,7 +22976,7 @@ function PayoutAccount(props) {
22953
22976
  BankAccountFormat,
22954
22977
  {
22955
22978
  bankAccountFormat: accountFormat,
22956
- handleAccountFormatChange: setAccountFormat
22979
+ handleAccountFormatChange
22957
22980
  }
22958
22981
  ),
22959
22982
  formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
@@ -26558,10 +26581,16 @@ function getPropsFromConfigurations(scenarioConfiguration, forms, remediationAct
26558
26581
  }
26559
26582
  case TrustedFieldsProvider.SINGPASS: {
26560
26583
  if (legalEntityType === "organization") {
26561
- return [...acc, ...trusted.fields.map((tf) => businessDetailsApiKeyMapping[tf])];
26584
+ const orgFields = trusted.fields.filter(
26585
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "organization"
26586
+ );
26587
+ return [...acc, ...orgFields.map((tf) => businessDetailsApiKeyMapping[tf])];
26562
26588
  }
26563
26589
  if (legalEntityType === "individual") {
26564
- return [...acc, ...trusted.fields.map((tf) => individualApiKeyMapping[tf])];
26590
+ const individualFields = trusted.fields.filter(
26591
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "individual"
26592
+ );
26593
+ return [...acc, ...individualFields.map((tf) => individualApiKeyMapping[tf])];
26565
26594
  }
26566
26595
  return acc;
26567
26596
  }
@@ -32295,7 +32324,6 @@ const mapCustomerSupportSchemaToCustomerSupportType = (customerSupport) => {
32295
32324
  const logger$t = createLogger("CustomerSupport");
32296
32325
  function CustomerSupport({
32297
32326
  country,
32298
- onNavigateBack,
32299
32327
  onSubmit,
32300
32328
  legalEntityResponse,
32301
32329
  handleUpdateLegalEntity
@@ -32353,15 +32381,7 @@ function CustomerSupport({
32353
32381
  shouldValidate
32354
32382
  }
32355
32383
  ),
32356
- /* @__PURE__ */ jsx(
32357
- ActionBar,
32358
- {
32359
- onBack: onNavigateBack,
32360
- onNext: submitForm,
32361
- backButtonLabel: i18n.get("saveAndGoToOverview"),
32362
- nextButtonLabel: i18n.get("submit")
32363
- }
32364
- )
32384
+ /* @__PURE__ */ jsx(ActionBar, { onNext: submitForm, nextButtonLabel: i18n.get("submit") })
32365
32385
  ] });
32366
32386
  }
32367
32387
  function useDataMissingRemediations({
@@ -41113,7 +41133,6 @@ function DropinComposer({
41113
41133
  {
41114
41134
  legalEntityResponse: rootLegalEntity,
41115
41135
  country: rootLegalEntityCountry,
41116
- onNavigateBack: navigateBack,
41117
41136
  onSubmit: async () => {
41118
41137
  await refreshLegalEntity();
41119
41138
  navigateTo(TaskTypes.TASKS_OVERVIEW);
@@ -45785,7 +45804,7 @@ const ConfigurationApiProvider = ({
45785
45804
  }) => {
45786
45805
  const authContext = useAuthContext();
45787
45806
  const { isEmbeddedDropin, loadingContext } = authContext;
45788
- const sdkVersion = "3.46.0";
45807
+ const sdkVersion = "3.46.2";
45789
45808
  const rootLegalEntityId = useGlobalStore((store) => store.rootLegalEntity.id);
45790
45809
  useAnalytics({
45791
45810
  onUserEvent,
@@ -46118,6 +46137,44 @@ function StateReducer() {
46118
46137
  mergedState.initialData = structuredClone(state.initialData);
46119
46138
  return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
46120
46139
  }
46140
+ case "removeFromState": {
46141
+ const state = structuredClone(currState);
46142
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
46143
+ const mergedState = {
46144
+ ...state,
46145
+ data: {
46146
+ ...state.data,
46147
+ [dataStoreId]: {}
46148
+ },
46149
+ // Add data in allData state prop in case we will need them later
46150
+ allData: {
46151
+ ...state.allData,
46152
+ [dataStoreId]: {}
46153
+ },
46154
+ errors: {
46155
+ ...state.errors,
46156
+ [dataStoreId]: {}
46157
+ },
46158
+ valid: {
46159
+ ...state.valid,
46160
+ [dataStoreId]: {}
46161
+ },
46162
+ fieldProblems: {
46163
+ ...state.fieldProblems,
46164
+ [dataStoreId]: {}
46165
+ }
46166
+ };
46167
+ mergedState.validityByForm = {
46168
+ ...mergedState.validityByForm,
46169
+ [dataStoreId]: {}
46170
+ };
46171
+ mergedState.allValid = Object.values(mergedState.validityByForm).every(
46172
+ (isValid) => isValid
46173
+ );
46174
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
46175
+ mergedState.initialData = structuredClone(state.initialData);
46176
+ return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
46177
+ }
46121
46178
  case "resetState": {
46122
46179
  const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
46123
46180
  return {
@@ -46632,7 +46689,7 @@ const DebugModal = ({ onExit }) => {
46632
46689
  const [tab, setTab] = useState("metadata");
46633
46690
  const rootLegalEntity = useGlobalStore((store) => store.rootLegalEntity);
46634
46691
  const metadata = {
46635
- sdkVersion: "3.46.0",
46692
+ sdkVersion: "3.46.2",
46636
46693
  locale: i18n.locale,
46637
46694
  rootLegalEntityId: rootLegalEntity.id
46638
46695
  };
@@ -1,2 +1,2 @@
1
1
  import type { CustomerSupportProps } from './types';
2
- export declare function CustomerSupport({ country, onNavigateBack, onSubmit, legalEntityResponse, handleUpdateLegalEntity, }: CustomerSupportProps): import("preact").JSX.Element;
2
+ export declare function CustomerSupport({ country, onSubmit, legalEntityResponse, handleUpdateLegalEntity, }: CustomerSupportProps): import("preact").JSX.Element;
@@ -13,7 +13,6 @@ export interface CustomerSupportSchema {
13
13
  export interface CustomerSupportProps extends BaseInnerFormProps<CustomerSupportSchema> {
14
14
  country: CountryCode;
15
15
  legalEntityResponse: ExistingLegalEntity;
16
- onNavigateBack(): void;
17
16
  onSubmit(): void;
18
17
  handleUpdateLegalEntity: DropinAPIHandlers['handleUpdateLegalEntity'];
19
18
  }
@@ -19,7 +19,7 @@ export interface SFValue {
19
19
  dataStoreId?: string;
20
20
  }
21
21
  export interface SCAction {
22
- type: 'addToState' | 'resetState';
22
+ type: 'addToState' | 'resetState' | 'removeFromState';
23
23
  value?: SFValue;
24
24
  }
25
25
  export interface SCCurrent {
@@ -3,6 +3,7 @@ export declare function useGlobalData<TLDS extends TopLevelDataSchema>(): TLDS;
3
3
  interface UseGlobalDataSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName]> {
4
4
  sliceData: SliceData | undefined;
5
5
  updateStateSlice: (updatedSlice: StateSlice<TLDS, SliceName, SliceData>) => void;
6
+ clearStateSlice: () => void;
6
7
  }
7
8
  export declare function useGlobalDataSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName] = NonNullable<TLDS[SliceName]>>(sliceId: SliceName, caller?: string): UseGlobalDataSlice<TLDS, SliceName, SliceData>;
8
9
  export declare function useResetGlobalData<TLDS extends TopLevelDataSchema>(caller?: string): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "3.46.0",
3
+ "version": "3.46.2",
4
4
  "keywords": [
5
5
  "adyen",
6
6
  "adyen-kyc",