@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.mjs CHANGED
@@ -13584,21 +13584,14 @@ function useDynamicFlowCore(props) {
13584
13584
  void onAction(__spreadValues({ method: "GET" }, initialAction));
13585
13585
  }
13586
13586
  if (initialStep && !initialAction) {
13587
- initialiseWithStep(initialStep, null, true);
13587
+ initialiseWithStep(initialStep, null);
13588
13588
  trackCoreEvent("Step Shown", { isFirstStep: true });
13589
13589
  }
13590
13590
  }, []);
13591
13591
  const onBack = (action) => {
13592
13592
  if (action) {
13593
13593
  return () => {
13594
- onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true })).then(() => {
13595
- setStepStack((value) => {
13596
- const newStepStack = [...value.slice(0, -2), ...value.slice(-1)];
13597
- stepComponentRef.current = newStepStack[newStepStack.length - 1];
13598
- return newStepStack;
13599
- });
13600
- }).catch(() => {
13601
- });
13594
+ void onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true }), "replace-current");
13602
13595
  };
13603
13596
  }
13604
13597
  if (nativeBack) {
@@ -13615,8 +13608,8 @@ function useDynamicFlowCore(props) {
13615
13608
  }
13616
13609
  };
13617
13610
  const initialiseWithStep = useCallback2(
13618
- (newStep, etag, isNewStep = false) => {
13619
- var _a2, _b, _c, _d, _e;
13611
+ (newStep, etag, overrideStackBehavior) => {
13612
+ var _a2, _b, _c, _d, _e, _f;
13620
13613
  (_a2 = stepComponentRef.current) == null ? void 0 : _a2.stop();
13621
13614
  stepRef.current = newStep;
13622
13615
  etagRef.current = etag;
@@ -13635,9 +13628,9 @@ function useDynamicFlowCore(props) {
13635
13628
  }
13636
13629
  };
13637
13630
  try {
13638
- const { stackBehavior = void 0 } = (_b = newStep.navigation) != null ? _b : {};
13631
+ const stackBehavior = (_c = overrideStackBehavior != null ? overrideStackBehavior : (_b = newStep.navigation) == null ? void 0 : _b.stackBehavior) != null ? _c : "default";
13639
13632
  const newStepComponent = mapStepToComponent({
13640
- stepLocalValue: (_d = (_c = stepComponentRef.current) == null ? void 0 : _c.getLocalValue()) != null ? _d : null,
13633
+ stepLocalValue: (_e = (_d = stepComponentRef.current) == null ? void 0 : _d.getLocalValue()) != null ? _e : null,
13641
13634
  step: newStep,
13642
13635
  displayStepTitle,
13643
13636
  loadingState: "idle",
@@ -13654,9 +13647,6 @@ function useDynamicFlowCore(props) {
13654
13647
  onBack
13655
13648
  });
13656
13649
  const getStack = (current) => {
13657
- if (!isNewStep) {
13658
- return current.slice(0, -1);
13659
- }
13660
13650
  switch (stackBehavior) {
13661
13651
  case "remove-all":
13662
13652
  return [];
@@ -13669,7 +13659,7 @@ function useDynamicFlowCore(props) {
13669
13659
  return current;
13670
13660
  }
13671
13661
  };
13672
- (_e = stepComponentRef == null ? void 0 : stepComponentRef.current) == null ? void 0 : _e.setLoadingState("idle");
13662
+ (_f = stepComponentRef == null ? void 0 : stepComponentRef.current) == null ? void 0 : _f.setLoadingState("idle");
13673
13663
  setStepStack((value) => {
13674
13664
  stepComponentRef.current = newStepComponent;
13675
13665
  return [...getStack(value), newStepComponent];
@@ -13720,7 +13710,7 @@ function useDynamicFlowCore(props) {
13720
13710
  // eslint-disable-next-line react-hooks/exhaustive-deps
13721
13711
  []
13722
13712
  );
13723
- const onAction = useCallback2(async (action) => {
13713
+ const onAction = useCallback2(async (action, stackOverride) => {
13724
13714
  var _a2, _b, _c;
13725
13715
  try {
13726
13716
  (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("submitting");
@@ -13740,7 +13730,7 @@ function useDynamicFlowCore(props) {
13740
13730
  }
13741
13731
  case "replace-step": {
13742
13732
  const isFirstStep = stepRef.current === null;
13743
- initialiseWithStep(command.step, command.etag, true);
13733
+ initialiseWithStep(command.step, command.etag, stackOverride);
13744
13734
  trackCoreEvent("Step Shown", { isFirstStep });
13745
13735
  break;
13746
13736
  }
@@ -13748,7 +13738,7 @@ function useDynamicFlowCore(props) {
13748
13738
  const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
13749
13739
  const { errors = { error: genericErrorMessage } } = command.body;
13750
13740
  if (stepRef.current) {
13751
- initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors, model }), etagRef.current);
13741
+ initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors, model }), etagRef.current, "replace-current");
13752
13742
  } else {
13753
13743
  closeWithError(new Error("Initial request failed"), {});
13754
13744
  }
@@ -13783,7 +13773,7 @@ function useDynamicFlowCore(props) {
13783
13773
  case "refresh-step":
13784
13774
  {
13785
13775
  const errors = errorsOverride != null ? errorsOverride : command.step.errors;
13786
- initialiseWithStep(__spreadProps(__spreadValues({}, command.step), { errors }), command.etag);
13776
+ initialiseWithStep(__spreadProps(__spreadValues({}, command.step), { errors }), command.etag, "replace-current");
13787
13777
  }
13788
13778
  break;
13789
13779
  case "error": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.28.8-experimental-4d66e42",
3
+ "version": "3.28.8-experimental-5304a6a",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",