@adyen/kyc-components 3.46.1 → 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();
@@ -22936,6 +22947,13 @@ function PayoutAccount(props) {
22936
22947
  const bankNameProps = getFieldProps(props, bankNameFields);
22937
22948
  const bankCodeProps = getFieldProps(props, bankCodeFields);
22938
22949
  const bankCityProps = getFieldProps(props, bankCityFields);
22950
+ const { clearStateSlice } = useGlobalDataSlice(
22951
+ "payoutAccountDetails"
22952
+ );
22953
+ const handleAccountFormatChange = (accountFormat2) => {
22954
+ clearStateSlice();
22955
+ setAccountFormat(accountFormat2);
22956
+ };
22939
22957
  return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
22940
22958
  /* @__PURE__ */ jsx(
22941
22959
  FormHeader,
@@ -22958,7 +22976,7 @@ function PayoutAccount(props) {
22958
22976
  BankAccountFormat,
22959
22977
  {
22960
22978
  bankAccountFormat: accountFormat,
22961
- handleAccountFormatChange: setAccountFormat
22979
+ handleAccountFormatChange
22962
22980
  }
22963
22981
  ),
22964
22982
  formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
@@ -26563,10 +26581,16 @@ function getPropsFromConfigurations(scenarioConfiguration, forms, remediationAct
26563
26581
  }
26564
26582
  case TrustedFieldsProvider.SINGPASS: {
26565
26583
  if (legalEntityType === "organization") {
26566
- 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])];
26567
26588
  }
26568
26589
  if (legalEntityType === "individual") {
26569
- 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])];
26570
26594
  }
26571
26595
  return acc;
26572
26596
  }
@@ -45780,7 +45804,7 @@ const ConfigurationApiProvider = ({
45780
45804
  }) => {
45781
45805
  const authContext = useAuthContext();
45782
45806
  const { isEmbeddedDropin, loadingContext } = authContext;
45783
- const sdkVersion = "3.46.1";
45807
+ const sdkVersion = "3.46.2";
45784
45808
  const rootLegalEntityId = useGlobalStore((store) => store.rootLegalEntity.id);
45785
45809
  useAnalytics({
45786
45810
  onUserEvent,
@@ -46113,6 +46137,44 @@ function StateReducer() {
46113
46137
  mergedState.initialData = structuredClone(state.initialData);
46114
46138
  return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
46115
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
+ }
46116
46178
  case "resetState": {
46117
46179
  const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
46118
46180
  return {
@@ -46627,7 +46689,7 @@ const DebugModal = ({ onExit }) => {
46627
46689
  const [tab, setTab] = useState("metadata");
46628
46690
  const rootLegalEntity = useGlobalStore((store) => store.rootLegalEntity);
46629
46691
  const metadata = {
46630
- sdkVersion: "3.46.1",
46692
+ sdkVersion: "3.46.2",
46631
46693
  locale: i18n.locale,
46632
46694
  rootLegalEntityId: rootLegalEntity.id
46633
46695
  };
@@ -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.1",
3
+ "version": "3.46.2",
4
4
  "keywords": [
5
5
  "adyen",
6
6
  "adyen-kyc",