@wise/dynamic-flow-client 3.28.8-experimental-4d66e42 → 3.28.8-experimental-5304a6a

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.
package/build/main.js CHANGED
@@ -13602,21 +13602,14 @@ function useDynamicFlowCore(props) {
13602
13602
  void onAction(__spreadValues({ method: "GET" }, initialAction));
13603
13603
  }
13604
13604
  if (initialStep && !initialAction) {
13605
- initialiseWithStep(initialStep, null, true);
13605
+ initialiseWithStep(initialStep, null);
13606
13606
  trackCoreEvent("Step Shown", { isFirstStep: true });
13607
13607
  }
13608
13608
  }, []);
13609
13609
  const onBack = (action) => {
13610
13610
  if (action) {
13611
13611
  return () => {
13612
- onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true })).then(() => {
13613
- setStepStack((value) => {
13614
- const newStepStack = [...value.slice(0, -2), ...value.slice(-1)];
13615
- stepComponentRef.current = newStepStack[newStepStack.length - 1];
13616
- return newStepStack;
13617
- });
13618
- }).catch(() => {
13619
- });
13612
+ void onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true }), "replace-current");
13620
13613
  };
13621
13614
  }
13622
13615
  if (nativeBack) {
@@ -13633,8 +13626,8 @@ function useDynamicFlowCore(props) {
13633
13626
  }
13634
13627
  };
13635
13628
  const initialiseWithStep = (0, import_react17.useCallback)(
13636
- (newStep, etag, isNewStep = false) => {
13637
- var _a2, _b, _c, _d, _e;
13629
+ (newStep, etag, overrideStackBehavior) => {
13630
+ var _a2, _b, _c, _d, _e, _f;
13638
13631
  (_a2 = stepComponentRef.current) == null ? void 0 : _a2.stop();
13639
13632
  stepRef.current = newStep;
13640
13633
  etagRef.current = etag;
@@ -13653,9 +13646,9 @@ function useDynamicFlowCore(props) {
13653
13646
  }
13654
13647
  };
13655
13648
  try {
13656
- const { stackBehavior = void 0 } = (_b = newStep.navigation) != null ? _b : {};
13649
+ const stackBehavior = (_c = overrideStackBehavior != null ? overrideStackBehavior : (_b = newStep.navigation) == null ? void 0 : _b.stackBehavior) != null ? _c : "default";
13657
13650
  const newStepComponent = mapStepToComponent({
13658
- stepLocalValue: (_d = (_c = stepComponentRef.current) == null ? void 0 : _c.getLocalValue()) != null ? _d : null,
13651
+ stepLocalValue: (_e = (_d = stepComponentRef.current) == null ? void 0 : _d.getLocalValue()) != null ? _e : null,
13659
13652
  step: newStep,
13660
13653
  displayStepTitle,
13661
13654
  loadingState: "idle",
@@ -13672,9 +13665,6 @@ function useDynamicFlowCore(props) {
13672
13665
  onBack
13673
13666
  });
13674
13667
  const getStack = (current) => {
13675
- if (!isNewStep) {
13676
- return current.slice(0, -1);
13677
- }
13678
13668
  switch (stackBehavior) {
13679
13669
  case "remove-all":
13680
13670
  return [];
@@ -13687,7 +13677,7 @@ function useDynamicFlowCore(props) {
13687
13677
  return current;
13688
13678
  }
13689
13679
  };
13690
- (_e = stepComponentRef == null ? void 0 : stepComponentRef.current) == null ? void 0 : _e.setLoadingState("idle");
13680
+ (_f = stepComponentRef == null ? void 0 : stepComponentRef.current) == null ? void 0 : _f.setLoadingState("idle");
13691
13681
  setStepStack((value) => {
13692
13682
  stepComponentRef.current = newStepComponent;
13693
13683
  return [...getStack(value), newStepComponent];
@@ -13738,7 +13728,7 @@ function useDynamicFlowCore(props) {
13738
13728
  // eslint-disable-next-line react-hooks/exhaustive-deps
13739
13729
  []
13740
13730
  );
13741
- const onAction = (0, import_react17.useCallback)(async (action) => {
13731
+ const onAction = (0, import_react17.useCallback)(async (action, stackOverride) => {
13742
13732
  var _a2, _b, _c;
13743
13733
  try {
13744
13734
  (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("submitting");
@@ -13758,7 +13748,7 @@ function useDynamicFlowCore(props) {
13758
13748
  }
13759
13749
  case "replace-step": {
13760
13750
  const isFirstStep = stepRef.current === null;
13761
- initialiseWithStep(command.step, command.etag, true);
13751
+ initialiseWithStep(command.step, command.etag, stackOverride);
13762
13752
  trackCoreEvent("Step Shown", { isFirstStep });
13763
13753
  break;
13764
13754
  }
@@ -13766,7 +13756,7 @@ function useDynamicFlowCore(props) {
13766
13756
  const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
13767
13757
  const { errors = { error: genericErrorMessage } } = command.body;
13768
13758
  if (stepRef.current) {
13769
- initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors, model }), etagRef.current);
13759
+ initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors, model }), etagRef.current, "replace-current");
13770
13760
  } else {
13771
13761
  closeWithError(new Error("Initial request failed"), {});
13772
13762
  }
@@ -13801,7 +13791,7 @@ function useDynamicFlowCore(props) {
13801
13791
  case "refresh-step":
13802
13792
  {
13803
13793
  const errors = errorsOverride != null ? errorsOverride : command.step.errors;
13804
- initialiseWithStep(__spreadProps(__spreadValues({}, command.step), { errors }), command.etag);
13794
+ initialiseWithStep(__spreadProps(__spreadValues({}, command.step), { errors }), command.etag, "replace-current");
13805
13795
  }
13806
13796
  break;
13807
13797
  case "error": {