@adyen/kyc-components 3.45.1 → 3.45.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.
@@ -3021,12 +3021,23 @@ function useGlobalDataSlice(sliceId, caller) {
3021
3021
  }),
3022
3022
  [sliceId, caller]
3023
3023
  );
3024
+ const clearState = useCallback(
3025
+ () => dispatch({
3026
+ type: "removeFromState",
3027
+ value: { dataStoreId: sliceId, caller }
3028
+ }),
3029
+ [sliceId, caller]
3030
+ );
3024
3031
  const updateStateSlice = useMemo(
3025
3032
  // can this debounce be useDebounce?
3026
3033
  () => debounce$1(updateState, ON_CHANGE_DEBOUNCE_DURATION),
3027
3034
  [updateState]
3028
3035
  );
3029
- return { sliceData, updateStateSlice };
3036
+ const clearStateSlice = useMemo(
3037
+ () => debounce$1(clearState, ON_CHANGE_DEBOUNCE_DURATION),
3038
+ [clearState]
3039
+ );
3040
+ return { sliceData, updateStateSlice, clearStateSlice };
3030
3041
  }
3031
3042
  function useResetGlobalData(caller) {
3032
3043
  const { dispatch } = useStateContext();
@@ -22901,6 +22912,13 @@ function PayoutAccount(props) {
22901
22912
  const bankNameProps = getFieldProps(props, bankNameFields);
22902
22913
  const bankCodeProps = getFieldProps(props, bankCodeFields);
22903
22914
  const bankCityProps = getFieldProps(props, bankCityFields);
22915
+ const { clearStateSlice } = useGlobalDataSlice(
22916
+ "payoutAccountDetails"
22917
+ );
22918
+ const handleAccountFormatChange = (accountFormat2) => {
22919
+ clearStateSlice();
22920
+ setAccountFormat(accountFormat2);
22921
+ };
22904
22922
  return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
22905
22923
  /* @__PURE__ */ jsx(
22906
22924
  FormHeader,
@@ -22923,7 +22941,7 @@ function PayoutAccount(props) {
22923
22941
  BankAccountFormat,
22924
22942
  {
22925
22943
  bankAccountFormat: accountFormat,
22926
- handleAccountFormatChange: setAccountFormat
22944
+ handleAccountFormatChange
22927
22945
  }
22928
22946
  ),
22929
22947
  formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
@@ -26527,10 +26545,16 @@ function getPropsFromConfigurations(scenarioConfiguration, forms, remediationAct
26527
26545
  }
26528
26546
  case TrustedFieldsProvider.SINGPASS: {
26529
26547
  if (legalEntityType === "organization") {
26530
- return [...acc, ...trusted.fields.map((tf) => businessDetailsApiKeyMapping[tf])];
26548
+ const orgFields = trusted.fields.filter(
26549
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "organization"
26550
+ );
26551
+ return [...acc, ...orgFields.map((tf) => businessDetailsApiKeyMapping[tf])];
26531
26552
  }
26532
26553
  if (legalEntityType === "individual") {
26533
- return [...acc, ...trusted.fields.map((tf) => individualApiKeyMapping[tf])];
26554
+ const individualFields = trusted.fields.filter(
26555
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "individual"
26556
+ );
26557
+ return [...acc, ...individualFields.map((tf) => individualApiKeyMapping[tf])];
26534
26558
  }
26535
26559
  return acc;
26536
26560
  }
@@ -44844,7 +44868,7 @@ const ConfigurationApiProvider = ({
44844
44868
  }) => {
44845
44869
  const authContext = useAuthContext();
44846
44870
  const { isEmbeddedDropin, loadingContext } = authContext;
44847
- const sdkVersion = "3.45.1";
44871
+ const sdkVersion = "3.45.2";
44848
44872
  const rootLegalEntityId = useGlobalStore((store) => store.rootLegalEntity.id);
44849
44873
  useAnalytics({
44850
44874
  onUserEvent,
@@ -45177,6 +45201,44 @@ function StateReducer() {
45177
45201
  mergedState.initialData = structuredClone(state.initialData);
45178
45202
  return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
45179
45203
  }
45204
+ case "removeFromState": {
45205
+ const state = structuredClone(currState);
45206
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
45207
+ const mergedState = {
45208
+ ...state,
45209
+ data: {
45210
+ ...state.data,
45211
+ [dataStoreId]: {}
45212
+ },
45213
+ // Add data in allData state prop in case we will need them later
45214
+ allData: {
45215
+ ...state.allData,
45216
+ [dataStoreId]: {}
45217
+ },
45218
+ errors: {
45219
+ ...state.errors,
45220
+ [dataStoreId]: {}
45221
+ },
45222
+ valid: {
45223
+ ...state.valid,
45224
+ [dataStoreId]: {}
45225
+ },
45226
+ fieldProblems: {
45227
+ ...state.fieldProblems,
45228
+ [dataStoreId]: {}
45229
+ }
45230
+ };
45231
+ mergedState.validityByForm = {
45232
+ ...mergedState.validityByForm,
45233
+ [dataStoreId]: {}
45234
+ };
45235
+ mergedState.allValid = Object.values(mergedState.validityByForm).every(
45236
+ (isValid) => isValid
45237
+ );
45238
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
45239
+ mergedState.initialData = structuredClone(state.initialData);
45240
+ return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
45241
+ }
45180
45242
  case "resetState": {
45181
45243
  const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
45182
45244
  return {
@@ -45691,7 +45753,7 @@ const DebugModal = ({ onExit }) => {
45691
45753
  const [tab, setTab] = useState("metadata");
45692
45754
  const rootLegalEntity = useGlobalStore((store) => store.rootLegalEntity);
45693
45755
  const metadata = {
45694
- sdkVersion: "3.45.1",
45756
+ sdkVersion: "3.45.2",
45695
45757
  locale: i18n.locale,
45696
45758
  rootLegalEntityId: rootLegalEntity.id
45697
45759
  };
@@ -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.45.1",
3
+ "version": "3.45.2",
4
4
  "keywords": [
5
5
  "adyen",
6
6
  "adyen-kyc",