@wise/dynamic-flow-client 3.1.0-beta-81cefd.37 → 3.1.1

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.
Files changed (36) hide show
  1. package/build/main.js +365 -248
  2. package/build/main.min.js +1 -1
  3. package/build/types/revamp/domain/components/AllOfComponent.d.ts +3 -3
  4. package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +1 -1
  5. package/build/types/revamp/domain/components/BoxComponent.d.ts +3 -3
  6. package/build/types/revamp/domain/components/ColumnsComponent.d.ts +4 -4
  7. package/build/types/revamp/domain/components/ContainerComponent.d.ts +4 -4
  8. package/build/types/revamp/domain/components/FormComponent.d.ts +3 -3
  9. package/build/types/revamp/domain/components/ModalComponent.d.ts +3 -3
  10. package/build/types/revamp/domain/components/ObjectComponent.d.ts +3 -3
  11. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +5 -5
  12. package/build/types/revamp/domain/components/StepDomainComponent.d.ts +14 -0
  13. package/build/types/revamp/domain/components/repeatableComponent/RepeatableComponent.d.ts +5 -5
  14. package/build/types/revamp/domain/components/utils/component-utils.d.ts +2 -2
  15. package/build/types/revamp/domain/components/utils/isPartialLocalValueMatch.d.ts +2 -3
  16. package/build/types/revamp/domain/features/summary/summary-utils.d.ts +2 -2
  17. package/build/types/revamp/domain/features/validation/validation-functions.d.ts +2 -2
  18. package/build/types/revamp/domain/mappers/layout/formLayoutToComponent.d.ts +2 -2
  19. package/build/types/revamp/domain/mappers/mapLayoutToComponent.d.ts +2 -2
  20. package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +2 -2
  21. package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +8 -0
  22. package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +3 -3
  23. package/build/types/revamp/domain/types.d.ts +13 -10
  24. package/build/types/revamp/renderers/LoadingContext.d.ts +9 -0
  25. package/build/types/revamp/renderers/StepRenderer.d.ts +2 -0
  26. package/build/types/revamp/renderers/mappers/componentToRendererProps.d.ts +2 -2
  27. package/build/types/revamp/renderers/stepComponentToProps.d.ts +4 -0
  28. package/build/types/revamp/renderers/types.d.ts +8 -1
  29. package/build/types/revamp/step/Step.d.ts +4 -3
  30. package/build/types/revamp/step/utils/getRenderFunction.d.ts +2 -2
  31. package/build/types/revamp/types.d.ts +2 -2
  32. package/build/types/revamp/utils/component-utils.d.ts +3 -3
  33. package/build/types/revamp/utils/findComponent.d.ts +2 -2
  34. package/build/types/revamp/utils/type-utils.d.ts +6 -6
  35. package/package.json +25 -25
  36. package/build/types/revamp/domain/mappers/mapStepToComponents.d.ts +0 -6
package/build/main.js CHANGED
@@ -8612,7 +8612,7 @@ var translations = {
8612
8612
  var i18n_default = translations;
8613
8613
 
8614
8614
  // src/revamp/DynamicFlowWise.tsx
8615
- var import_react56 = require("react");
8615
+ var import_react58 = require("react");
8616
8616
  var import_react_intl36 = require("react-intl");
8617
8617
 
8618
8618
  // src/revamp/wise/renderers/AlertRenderer.tsx
@@ -8818,29 +8818,49 @@ var BoxRenderer_default = BoxRenderer;
8818
8818
 
8819
8819
  // src/revamp/wise/renderers/ButtonRenderer.tsx
8820
8820
  var import_components42 = require("@transferwise/components");
8821
+
8822
+ // src/revamp/renderers/LoadingContext.tsx
8823
+ var import_react50 = require("react");
8824
+ var LoadingContext = (0, import_react50.createContext)({ loadingState: "idle" });
8825
+ var LoadingContextProvider = LoadingContext.Provider;
8826
+ var useLoadingContext = () => {
8827
+ const { loadingState } = (0, import_react50.useContext)(LoadingContext);
8828
+ return { loadingState, isLoading: loadingState !== "idle" };
8829
+ };
8830
+
8831
+ // src/revamp/wise/renderers/ButtonRenderer.tsx
8821
8832
  var import_jsx_runtime81 = require("react/jsx-runtime");
8822
8833
  var ButtonRenderer = {
8823
8834
  canRenderType: "button",
8824
- render: ({ control, context, disabled, margin, title, size, onClick }) => {
8825
- const className = getMargin2(margin);
8826
- const priority = mapControl(control);
8827
- const type = priority === "tertiary" ? void 0 : mapContext(context);
8828
- return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
8829
- import_components42.Button,
8830
- {
8831
- block: true,
8832
- className,
8833
- disabled,
8834
- priority: mapControl(control),
8835
- size: mapSize(size),
8836
- type,
8837
- onClick,
8838
- children: title
8839
- }
8840
- );
8841
- }
8835
+ render: ButtonRendererComponent
8842
8836
  };
8843
- var ButtonRenderer_default = ButtonRenderer;
8837
+ function ButtonRendererComponent({
8838
+ control,
8839
+ context,
8840
+ disabled,
8841
+ margin,
8842
+ title,
8843
+ size,
8844
+ onClick
8845
+ }) {
8846
+ const className = getMargin2(margin);
8847
+ const priority = mapControl(control);
8848
+ const type = priority === "tertiary" ? void 0 : mapContext(context);
8849
+ const { isLoading } = useLoadingContext();
8850
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
8851
+ import_components42.Button,
8852
+ {
8853
+ block: true,
8854
+ className,
8855
+ disabled: isLoading || disabled,
8856
+ priority: mapControl(control),
8857
+ size: mapSize(size),
8858
+ type,
8859
+ onClick,
8860
+ children: title
8861
+ }
8862
+ );
8863
+ }
8844
8864
  var mapContext = (context) => {
8845
8865
  switch (context) {
8846
8866
  case "neutral":
@@ -8875,6 +8895,7 @@ var mapSize = (size) => {
8875
8895
  return "md";
8876
8896
  }
8877
8897
  };
8898
+ var ButtonRenderer_default = ButtonRenderer;
8878
8899
 
8879
8900
  // src/revamp/wise/renderers/ColumnsRenderer.tsx
8880
8901
  var import_classnames11 = __toESM(require_classnames());
@@ -9246,21 +9267,25 @@ function NavigationOptionMedia({ icon, image }) {
9246
9267
  var import_jsx_runtime89 = require("react/jsx-runtime");
9247
9268
  var DecisionRenderer = {
9248
9269
  canRenderType: "decision",
9249
- render: ({ margin, options }) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: getMargin2(margin), children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components45.NavigationOptionsList, { children: options.map(({ description, disabled, icon, image, title, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
9270
+ render: DecisionRendererComponent
9271
+ };
9272
+ var DecisionRenderer_default = DecisionRenderer;
9273
+ function DecisionRendererComponent({ margin, options }) {
9274
+ const { isLoading } = useLoadingContext();
9275
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: getMargin2(margin), children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components45.NavigationOptionsList, { children: options.map(({ description, disabled, icon, image, title, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
9250
9276
  import_components45.NavigationOption,
9251
9277
  {
9252
9278
  title,
9253
9279
  content: description,
9254
- disabled,
9280
+ disabled: isLoading || disabled,
9255
9281
  media: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(NavigationOptionMedia, { icon, image }),
9256
9282
  showMediaCircle: false,
9257
9283
  showMediaAtAllSizes: true,
9258
9284
  onClick
9259
9285
  },
9260
9286
  JSON.stringify(title)
9261
- )) }) })
9262
- };
9263
- var DecisionRenderer_default = DecisionRenderer;
9287
+ )) }) });
9288
+ }
9264
9289
 
9265
9290
  // src/revamp/wise/renderers/DividerRenderer.tsx
9266
9291
  var import_jsx_runtime90 = require("react/jsx-runtime");
@@ -9345,7 +9370,7 @@ var HeadingRenderer_default = HeadingRenderer;
9345
9370
 
9346
9371
  // src/revamp/wise/renderers/ImageRenderer.tsx
9347
9372
  var import_components48 = require("@transferwise/components");
9348
- var import_react50 = require("react");
9373
+ var import_react51 = require("react");
9349
9374
  var import_jsx_runtime94 = require("react/jsx-runtime");
9350
9375
  var ImageRenderer = {
9351
9376
  canRenderType: "image",
@@ -9358,9 +9383,9 @@ function ImageRendererComponent({
9358
9383
  size,
9359
9384
  url
9360
9385
  }) {
9361
- const [imageSource, setImageSource] = (0, import_react50.useState)("");
9386
+ const [imageSource, setImageSource] = (0, import_react51.useState)("");
9362
9387
  const httpClient = useHttpClient();
9363
- (0, import_react50.useEffect)(() => {
9388
+ (0, import_react51.useEffect)(() => {
9364
9389
  void getImageSource2(httpClient, url).then(setImageSource);
9365
9390
  }, [url, httpClient]);
9366
9391
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
@@ -9487,7 +9512,7 @@ var MarkdownRenderer_default = MarkdownRenderer;
9487
9512
 
9488
9513
  // src/revamp/wise/renderers/ModalRenderer.tsx
9489
9514
  var import_components53 = require("@transferwise/components");
9490
- var import_react51 = require("react");
9515
+ var import_react52 = require("react");
9491
9516
  var import_jsx_runtime99 = require("react/jsx-runtime");
9492
9517
  var ModalRenderer = {
9493
9518
  canRenderType: "modal",
@@ -9495,7 +9520,7 @@ var ModalRenderer = {
9495
9520
  };
9496
9521
  var ModalRenderer_default = ModalRenderer;
9497
9522
  function DFModal({ content, margin, trigger }) {
9498
- const [visible, setVisible] = (0, import_react51.useState)(false);
9523
+ const [visible, setVisible] = (0, import_react52.useState)(false);
9499
9524
  return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: getMargin2(margin), children: [
9500
9525
  /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components53.Button, { priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
9501
9526
  /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
@@ -9658,9 +9683,9 @@ var import_react_intl32 = require("react-intl");
9658
9683
 
9659
9684
  // src/revamp/wise/renderers/hooks/useSnackBarIfAvailable.ts
9660
9685
  var import_components57 = require("@transferwise/components");
9661
- var import_react52 = require("react");
9686
+ var import_react53 = require("react");
9662
9687
  function useSnackBarIfAvailable2() {
9663
- const context = (0, import_react52.useContext)(import_components57.SnackbarContext);
9688
+ const context = (0, import_react53.useContext)(import_components57.SnackbarContext);
9664
9689
  return context ? context.createSnackbar : () => {
9665
9690
  };
9666
9691
  }
@@ -9709,7 +9734,7 @@ var ParagraphRenderer_default = ParagraphRenderer;
9709
9734
 
9710
9735
  // src/revamp/wise/renderers/RepeatableRenderer.tsx
9711
9736
  var import_components59 = require("@transferwise/components");
9712
- var import_react53 = require("react");
9737
+ var import_react54 = require("react");
9713
9738
  var import_icons3 = require("@transferwise/icons");
9714
9739
  var import_react_intl33 = require("react-intl");
9715
9740
  var import_classnames14 = __toESM(require_classnames());
@@ -9733,7 +9758,7 @@ function Repeatable(props) {
9733
9758
  onRemove
9734
9759
  } = props;
9735
9760
  const { formatMessage } = (0, import_react_intl33.useIntl)();
9736
- const [openModalType, setOpenModalType] = (0, import_react53.useState)(null);
9761
+ const [openModalType, setOpenModalType] = (0, import_react54.useState)(null);
9737
9762
  const onAddItem = () => {
9738
9763
  onAdd();
9739
9764
  setOpenModalType("add");
@@ -10377,7 +10402,7 @@ var getWiseRenderers = () => [
10377
10402
  ];
10378
10403
 
10379
10404
  // src/revamp/DynamicFlowCore.tsx
10380
- var import_react55 = require("react");
10405
+ var import_react57 = require("react");
10381
10406
  var import_react_intl35 = require("react-intl");
10382
10407
 
10383
10408
  // src/revamp/domain/features/events/getAnalyticsEventDispatcher.ts
@@ -10646,8 +10671,85 @@ var CoreContainerRenderer = {
10646
10671
  render: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_jsx_runtime117.Fragment, { children })
10647
10672
  };
10648
10673
 
10674
+ // src/revamp/renderers/StepRenderer.tsx
10675
+ var import_react55 = require("react");
10676
+ var import_jsx_runtime118 = require("react/jsx-runtime");
10677
+ var StepRenderer = {
10678
+ canRenderType: "step",
10679
+ render: StepRendererComponent
10680
+ };
10681
+ function StepRendererComponent({ children, loadingState }) {
10682
+ const value = (0, import_react55.useMemo)(() => ({ loadingState }), [loadingState]);
10683
+ return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(LoadingContextProvider, { value, children });
10684
+ }
10685
+
10649
10686
  // src/revamp/step/Step.tsx
10650
- var import_react54 = require("react");
10687
+ var import_react56 = require("react");
10688
+
10689
+ // src/revamp/domain/features/validation/validation-functions.ts
10690
+ var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
10691
+ var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
10692
+
10693
+ // src/revamp/domain/features/summary/summary-utils.ts
10694
+ var getSummariser = (schema) => (value) => {
10695
+ const { summary, icon, image } = schema;
10696
+ const stringValueOrNull = isString2(value) ? value : null;
10697
+ return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
10698
+ };
10699
+ var getConstSummary = (schema, model) => {
10700
+ const { summary, icon, image } = schema;
10701
+ const value = isString2(model) ? model : null;
10702
+ return summaryIfProvides(summary, { value, icon, image });
10703
+ };
10704
+ var summariseFromChildren = (components) => components.reduce(
10705
+ (acc, component) => mergeSummaries(acc, component.getSummary()),
10706
+ {}
10707
+ );
10708
+ var mergeSummaries = (summaryA, summaryB) => {
10709
+ var _a, _b, _c, _d;
10710
+ return {
10711
+ title: (_a = summaryA.title) != null ? _a : summaryB.title,
10712
+ description: (_b = summaryA.description) != null ? _b : summaryB.description,
10713
+ icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
10714
+ image: (_d = summaryA.image) != null ? _d : summaryB.image
10715
+ };
10716
+ };
10717
+ var summaryIfProvides = (summary, { value, icon, image }) => {
10718
+ if (!summary) {
10719
+ return {};
10720
+ }
10721
+ return {
10722
+ title: summary.providesTitle && value || void 0,
10723
+ description: summary.providesDescription && value || void 0,
10724
+ icon: summary.providesIcon && icon || void 0,
10725
+ image: summary.providesImage && image || void 0
10726
+ };
10727
+ };
10728
+
10729
+ // src/revamp/domain/components/StepDomainComponent.ts
10730
+ var createStepComponent = (containerProps) => __spreadProps(__spreadValues({}, containerProps), {
10731
+ type: "step",
10732
+ getChildren() {
10733
+ return this.components;
10734
+ },
10735
+ async getSubmittableValue() {
10736
+ return getSubmittableData(this.components);
10737
+ },
10738
+ getSummary() {
10739
+ return summariseFromChildren(this.getChildren());
10740
+ },
10741
+ getLocalValue() {
10742
+ return getLocalValues(this.components);
10743
+ },
10744
+ validate() {
10745
+ return validateComponents(this.getChildren());
10746
+ }
10747
+ });
10748
+ var createEmptyStepComponent = () => createStepComponent({
10749
+ uid: "",
10750
+ loadingState: "idle",
10751
+ components: []
10752
+ });
10651
10753
 
10652
10754
  // src/revamp/domain/components/AlertComponent.ts
10653
10755
  var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
@@ -10741,46 +10843,6 @@ var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md
10741
10843
  text
10742
10844
  });
10743
10845
 
10744
- // src/revamp/domain/features/summary/summary-utils.ts
10745
- var getSummariser = (schema) => (value) => {
10746
- const { summary, icon, image } = schema;
10747
- const stringValueOrNull = isString2(value) ? value : null;
10748
- return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
10749
- };
10750
- var getConstSummary = (schema, model) => {
10751
- const { summary, icon, image } = schema;
10752
- const value = isString2(model) ? model : null;
10753
- return summaryIfProvides(summary, { value, icon, image });
10754
- };
10755
- var summariseFromChildren = (components) => components.reduce(
10756
- (acc, component) => mergeSummaries(acc, component.getSummary()),
10757
- {}
10758
- );
10759
- var mergeSummaries = (summaryA, summaryB) => {
10760
- var _a, _b, _c, _d;
10761
- return {
10762
- title: (_a = summaryA.title) != null ? _a : summaryB.title,
10763
- description: (_b = summaryA.description) != null ? _b : summaryB.description,
10764
- icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
10765
- image: (_d = summaryA.image) != null ? _d : summaryB.image
10766
- };
10767
- };
10768
- var summaryIfProvides = (summary, { value, icon, image }) => {
10769
- if (!summary) {
10770
- return {};
10771
- }
10772
- return {
10773
- title: summary.providesTitle && value || void 0,
10774
- description: summary.providesDescription && value || void 0,
10775
- icon: summary.providesIcon && icon || void 0,
10776
- image: summary.providesImage && image || void 0
10777
- };
10778
- };
10779
-
10780
- // src/revamp/domain/features/validation/validation-functions.ts
10781
- var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
10782
- var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
10783
-
10784
10846
  // src/revamp/domain/components/BoxComponent.ts
10785
10847
  var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
10786
10848
  type: "box",
@@ -10826,9 +10888,7 @@ var createButtonComponent = (buttonProps) => __spreadProps(__spreadValues({
10826
10888
 
10827
10889
  // src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
10828
10890
  var buttonLayoutToComponent = (uid, { action, context, control, disabled, margin = "md", pinOrder, size, title }, { onAction, step }) => {
10829
- var _a;
10830
- const refAction = (action == null ? void 0 : action.$ref) ? (_a = step == null ? void 0 : step.actions) == null ? void 0 : _a.find((a) => a.$id === (action == null ? void 0 : action.$ref)) : void 0;
10831
- const mergedAction = __spreadValues(__spreadValues({}, action), refAction);
10891
+ const mergedAction = (action == null ? void 0 : action.$ref) ? __spreadValues(__spreadValues({}, getActionByReference(action.$ref, step == null ? void 0 : step.actions)), action) : action;
10832
10892
  return createButtonComponent({
10833
10893
  uid,
10834
10894
  context: getButtonContext({ context, action: mergedAction }),
@@ -10866,6 +10926,13 @@ var getButtonContext = ({ context, action }) => {
10866
10926
  }
10867
10927
  return (action == null ? void 0 : action.type) ? mapLegacyActionTypeToContext(action.type) : "neutral";
10868
10928
  };
10929
+ var getActionByReference = ($ref, actions = []) => {
10930
+ const action = actions.find((a) => a.$id === $ref);
10931
+ if (!action) {
10932
+ throw new Error("Action reference not found in actions array.");
10933
+ }
10934
+ return action;
10935
+ };
10869
10936
 
10870
10937
  // src/revamp/domain/components/ColumnsComponent.ts
10871
10938
  var createColumnsComponent = (columnsProps) => __spreadProps(__spreadValues({}, columnsProps), {
@@ -11003,6 +11070,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
11003
11070
  }
11004
11071
  update((draft) => {
11005
11072
  draft.errors = [error.message];
11073
+ draft.persistedState.lastSubmitted = null;
11006
11074
  });
11007
11075
  throw error;
11008
11076
  }
@@ -11165,6 +11233,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
11165
11233
  if (performPersistAsync) {
11166
11234
  const persist = getComponentPersistAsync(update, performPersistAsync);
11167
11235
  return __spreadProps(__spreadValues({}, numberComponent), {
11236
+ isPersisted: true,
11168
11237
  onBlur() {
11169
11238
  if (this.validate()) {
11170
11239
  persist(this.persistedState, this.getLocalValue()).catch(() => {
@@ -11875,6 +11944,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
11875
11944
  if (performPersistAsync) {
11876
11945
  const persist = getComponentPersistAsync(update, performPersistAsync);
11877
11946
  return __spreadProps(__spreadValues({}, integerComponent), {
11947
+ isPersisted: true,
11878
11948
  onBlur() {
11879
11949
  if (this.validate()) {
11880
11950
  persist(this.persistedState, this.getLocalValue()).catch(() => {
@@ -11938,27 +12008,35 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
11938
12008
  };
11939
12009
 
11940
12010
  // src/revamp/domain/components/utils/isPartialLocalValueMatch.ts
11941
- var isPartialLocalValueMatch = (partialValue, value) => {
11942
- if (isArray2(partialValue) && isArray2(value)) {
11943
- return partialValue.every(
11944
- (_, index) => isPartialLocalValueMatch(partialValue[index], value[index])
11945
- );
12011
+ var isPartialLocalValueMatch = (partialValue, component) => {
12012
+ if (isArray2(partialValue) && component.type === "repeatable") {
12013
+ const children = component.getChildren();
12014
+ return partialValue.every((value, index) => {
12015
+ const childComponent = children[index];
12016
+ return childComponent ? isPartialLocalValueMatch(value, childComponent) : false;
12017
+ });
11946
12018
  }
11947
- if (isObjectLocalValue(partialValue) && isObjectLocalValue(value)) {
11948
- const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(value)]));
12019
+ if (isObjectLocalValue(partialValue) && component.type === "object") {
12020
+ const allKeys = Array.from(
12021
+ /* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(component.componentMap)])
12022
+ );
11949
12023
  const matchingKeys = allKeys.filter(
11950
- (key) => !isNullish3(partialValue[key]) && !isNullish3(value[key])
12024
+ (key) => !isNullish3(partialValue[key]) && !isNullish3(component.componentMap[key])
12025
+ );
12026
+ return matchingKeys.every(
12027
+ (key) => isPartialLocalValueMatch(partialValue[key], component.componentMap[key])
11951
12028
  );
11952
- return matchingKeys.every((key) => isPartialLocalValueMatch(partialValue[key], value[key]));
11953
12029
  }
11954
- return partialValue === value;
11955
- };
11956
- var pickIndexOfFirstMatch = (arr) => {
11957
- if (arr.length > 0 && arr.every((e) => e === arr[0])) {
11958
- return null;
12030
+ const componentValue = component.getLocalValue();
12031
+ if (partialValue instanceof File && componentValue instanceof File) {
12032
+ return areEquivalentFiles(partialValue, componentValue);
11959
12033
  }
11960
- return arr.findIndex((e) => e);
12034
+ if ("isPersisted" in component && component.isPersisted) {
12035
+ return true;
12036
+ }
12037
+ return partialValue === componentValue;
11961
12038
  };
12039
+ var areEquivalentFiles = (fileA, fileB) => fileA.name === fileB.name && fileA.type === fileB.type && fileA.size === fileB.size;
11962
12040
 
11963
12041
  // src/revamp/domain/components/SelectInputComponent.ts
11964
12042
  var createSelectInputComponent = (selectProps, updateComponent) => {
@@ -11980,11 +12058,10 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
11980
12058
  "summariser"
11981
12059
  ]);
11982
12060
  const children = options.map((option) => option.component);
11983
- const selectedIndex = pickIndexOfFirstMatch(
11984
- options.map(
11985
- (option) => isPartialLocalValueMatch(selectProps.initialValue, option.component.getLocalValue())
11986
- )
12061
+ const matchingOptions = options.map(
12062
+ (option) => isPartialLocalValueMatch(selectProps.initialValue, option.component)
11987
12063
  );
12064
+ const selectedIndex = matchingOptions.filter(isTrue).length === 1 ? matchingOptions.indexOf(true) : null;
11988
12065
  const update = getInputUpdateFunction(uid, updateComponent);
11989
12066
  const getValidationErrors = getLocalValueValidator(checks);
11990
12067
  const getAndSetValidationErrors = (currentValue) => {
@@ -12051,6 +12128,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
12051
12128
  }
12052
12129
  const persist = getComponentPersistAsync(update, performPersistAsync);
12053
12130
  return __spreadProps(__spreadValues({}, selectComponent), {
12131
+ isPersisted: true,
12054
12132
  onSelect(updatedIndex) {
12055
12133
  selectComponent.onSelect.call(this, updatedIndex);
12056
12134
  const isValid = getValidationErrors(this.getLocalValue()).length === 0;
@@ -12064,6 +12142,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
12064
12142
  }
12065
12143
  });
12066
12144
  };
12145
+ var isTrue = (value) => value;
12067
12146
 
12068
12147
  // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
12069
12148
  var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
@@ -12196,6 +12275,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
12196
12275
  if (performPersistAsync) {
12197
12276
  const persist = getComponentPersistAsync(update, performPersistAsync);
12198
12277
  return __spreadProps(__spreadValues({}, dateInputComponent), {
12278
+ isPersisted: true,
12199
12279
  onChange(updatedValue) {
12200
12280
  dateInputComponent.onChange.call(this, updatedValue);
12201
12281
  const isValid = getValidationErrors(updatedValue).length === 0;
@@ -12345,6 +12425,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
12345
12425
  const persist = getComponentPersistAsync(update, performPersistAsync);
12346
12426
  return __spreadProps(__spreadValues({}, uploadComponent), {
12347
12427
  format,
12428
+ isPersisted: true,
12348
12429
  async onUpload(file) {
12349
12430
  update((draft) => {
12350
12431
  draft.errors = [];
@@ -12462,6 +12543,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
12462
12543
  if (performPersistAsync) {
12463
12544
  const persist = getComponentPersistAsync(update, performPersistAsync);
12464
12545
  return __spreadProps(__spreadValues({}, inputComponent), {
12546
+ isPersisted: true,
12465
12547
  onBlur() {
12466
12548
  if (this.validate()) {
12467
12549
  persist(this.persistedState, this.getLocalValue()).catch(() => {
@@ -12811,6 +12893,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
12811
12893
  const persist = getComponentMultiPersistAsync(update, performPersistAsync);
12812
12894
  return __spreadProps(__spreadValues({}, uploadComponent), {
12813
12895
  format,
12896
+ isPersisted: true,
12814
12897
  async onUpload(file, fileId) {
12815
12898
  await uploadComponent.onUpload.call(this, file, fileId);
12816
12899
  const submission = format === "blob" ? file : await toBase642(file);
@@ -12961,6 +13044,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
12961
13044
  if (performPersistAsync) {
12962
13045
  const persist = getComponentPersistAsync(update, performPersistAsync);
12963
13046
  return __spreadProps(__spreadValues({}, booleanComponent), {
13047
+ isPersisted: true,
12964
13048
  onChange(updatedValue) {
12965
13049
  booleanComponent.onChange.call(this, updatedValue);
12966
13050
  persist(this.persistedState, this.getLocalValue()).catch(() => {
@@ -13139,7 +13223,7 @@ var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin
13139
13223
  const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
13140
13224
  const schema = schemas.find((s) => s.$id === id);
13141
13225
  if (!schema) {
13142
- throw new Error("Bad layout schemaId");
13226
+ throw new Error("Schema not found in schemas array.");
13143
13227
  }
13144
13228
  return createFormComponent({
13145
13229
  uid,
@@ -13573,36 +13657,41 @@ var mapLayoutToComponent = (uid, layout, mapperProps) => {
13573
13657
  }
13574
13658
  };
13575
13659
 
13576
- // src/revamp/domain/mappers/mapStepToComponents.ts
13577
- var mapStepToComponents = (_a) => {
13660
+ // src/revamp/domain/mappers/mapStepToComponent.ts
13661
+ var mapStepToComponent = (_a) => {
13578
13662
  var _b = _a, {
13663
+ loadingState,
13579
13664
  displayStepTitle
13580
13665
  } = _b, mapperProps = __objRest(_b, [
13666
+ "loadingState",
13581
13667
  "displayStepTitle"
13582
13668
  ]);
13583
13669
  const { id, key, title, layout = [], errors } = mapperProps.step;
13584
13670
  const stepId = id || key;
13585
13671
  const uid = stepId != null ? stepId : "step";
13586
- const heading = title && displayStepTitle && headingLayoutToComponent(`${uid}.title`, {
13587
- // prefix step id or flow id
13672
+ const heading = title && displayStepTitle ? headingLayoutToComponent(`${uid}.title`, {
13588
13673
  type: "heading",
13589
13674
  text: title,
13590
13675
  align: "center",
13591
13676
  size: "lg"
13592
- });
13593
- const stepError = (errors == null ? void 0 : errors.error) && alertLayoutToComponent(`${uid}.global-error`, {
13677
+ }) : void 0;
13678
+ const stepError = (errors == null ? void 0 : errors.error) ? alertLayoutToComponent(`${uid}.global-error`, {
13594
13679
  type: "alert",
13595
13680
  markdown: errors.error,
13596
13681
  context: "negative"
13597
- });
13598
- const stepComponents = [...heading ? [heading] : [], ...stepError ? [stepError] : []];
13682
+ }) : void 0;
13683
+ const additionalComponents = [...heading ? [heading] : [], ...stepError ? [stepError] : []];
13599
13684
  const layoutComponents = layout.map(
13600
13685
  (layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps)
13601
13686
  );
13602
13687
  if (stepId === void 0) {
13603
13688
  throw new Error("Step must have an id or a key");
13604
13689
  }
13605
- return [...stepComponents, ...layoutComponents];
13690
+ return createStepComponent({
13691
+ uid,
13692
+ loadingState,
13693
+ components: [...additionalComponents, ...layoutComponents]
13694
+ });
13606
13695
  };
13607
13696
 
13608
13697
  // src/revamp/utils/findComponent.ts
@@ -13625,11 +13714,13 @@ var flattenComponents = (components) => components.reduce((acc, component) => {
13625
13714
  }, []);
13626
13715
 
13627
13716
  // src/revamp/step/Step.tsx
13628
- var import_jsx_runtime118 = require("react/jsx-runtime");
13717
+ var import_jsx_runtime119 = require("react/jsx-runtime");
13718
+ var emptyStepComponent = createEmptyStepComponent();
13629
13719
  function Step({
13630
13720
  localValue: initialLocalValue,
13631
13721
  step,
13632
13722
  displayStepTitle = true,
13723
+ loadingState,
13633
13724
  getErrorMessageFunctions,
13634
13725
  render,
13635
13726
  httpClient,
@@ -13639,27 +13730,36 @@ function Step({
13639
13730
  triggerRefresh
13640
13731
  }) {
13641
13732
  var _a;
13642
- const [components, setComponents] = (0, import_react54.useState)([]);
13643
- const componentsRef = (0, import_react54.useRef)([]);
13644
- const updateComponent = (0, import_react54.useCallback)((id, update) => {
13645
- const componentTree = componentsRef.current;
13646
- update(findComponent(componentTree, id));
13647
- setComponents(() => {
13648
- const newComponentTree = [...componentTree];
13649
- componentsRef.current = newComponentTree;
13650
- return newComponentTree;
13733
+ const [stepComponent, setStepComponent] = (0, import_react56.useState)(emptyStepComponent);
13734
+ const stepComponentRef = (0, import_react56.useRef)(emptyStepComponent);
13735
+ const updateComponent = (0, import_react56.useCallback)(
13736
+ (id, update) => {
13737
+ update(findComponent([stepComponentRef.current], id));
13738
+ setStepComponent(() => {
13739
+ const newStepDomainComponent = __spreadValues({}, stepComponentRef.current);
13740
+ stepComponentRef.current = newStepDomainComponent;
13741
+ return newStepDomainComponent;
13742
+ });
13743
+ },
13744
+ []
13745
+ );
13746
+ (0, import_react56.useEffect)(() => {
13747
+ setStepComponent(() => {
13748
+ const newStepDomainComponent = __spreadProps(__spreadValues({}, stepComponentRef.current), { loadingState });
13749
+ stepComponentRef.current = newStepDomainComponent;
13750
+ return newStepDomainComponent;
13651
13751
  });
13652
- }, []);
13653
- const onAction = (0, import_react54.useCallback)(
13752
+ }, [loadingState]);
13753
+ const onAction = (0, import_react56.useCallback)(
13654
13754
  async (action) => {
13655
13755
  var _a2;
13656
13756
  const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
13657
- const canSubmit = skipValidation || validateComponents(componentsRef.current);
13757
+ const canSubmit = skipValidation || stepComponentRef.current.validate();
13658
13758
  if (canSubmit) {
13659
13759
  try {
13660
- const model = await getSubmittableData(componentsRef.current);
13760
+ const model = await stepComponentRef.current.getSubmittableValue();
13661
13761
  const payload = mergeModels(model, (_a2 = action.data) != null ? _a2 : null);
13662
- const localValue = getLocalValues(componentsRef.current);
13762
+ const localValue = stepComponentRef.current.getLocalValue();
13663
13763
  void triggerSubmission(action, payload, localValue);
13664
13764
  } catch (e) {
13665
13765
  if (true) {
@@ -13670,23 +13770,24 @@ function Step({
13670
13770
  },
13671
13771
  [triggerSubmission]
13672
13772
  );
13673
- const onRefresh = (0, import_react54.useCallback)(
13773
+ const onRefresh = (0, import_react56.useCallback)(
13674
13774
  async (schemaId, url) => {
13675
13775
  var _a2;
13676
13776
  const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
13677
13777
  if (refreshUrl) {
13678
- const model = await getSubmittableData(componentsRef.current);
13679
- const localValue = getLocalValues(componentsRef.current);
13778
+ const model = await stepComponentRef.current.getSubmittableValue();
13779
+ const localValue = stepComponentRef.current.getLocalValue();
13680
13780
  void triggerRefresh({ refreshUrl, model, localValue, schemaId });
13681
13781
  }
13682
13782
  },
13683
13783
  [step.refreshUrl, step.refreshFormUrl, triggerRefresh]
13684
13784
  );
13685
- (0, import_react54.useEffect)(() => {
13686
- const initialComponents = mapStepToComponents({
13785
+ (0, import_react56.useEffect)(() => {
13786
+ const initialComponent = mapStepToComponent({
13687
13787
  stepLocalValue: initialLocalValue,
13688
13788
  step,
13689
13789
  displayStepTitle,
13790
+ loadingState,
13690
13791
  updateComponent,
13691
13792
  getErrorMessageFunctions,
13692
13793
  trackEvent,
@@ -13695,13 +13796,12 @@ function Step({
13695
13796
  onAction,
13696
13797
  onRefresh
13697
13798
  });
13698
- setComponents(initialComponents);
13699
- componentsRef.current = initialComponents;
13799
+ setStepComponent(initialComponent);
13800
+ stepComponentRef.current = initialComponent;
13700
13801
  if (step.key) {
13701
13802
  logEvent("warning", 'Step.key is deprecated, please use "id" instead');
13702
13803
  }
13703
13804
  }, [
13704
- initialLocalValue,
13705
13805
  step,
13706
13806
  displayStepTitle,
13707
13807
  updateComponent,
@@ -13712,13 +13812,20 @@ function Step({
13712
13812
  logEvent,
13713
13813
  onRefresh
13714
13814
  ]);
13715
- (0, import_react54.useEffect)(() => {
13815
+ (0, import_react56.useEffect)(() => {
13716
13816
  trackEvent("Step Shown");
13717
13817
  }, [(_a = step.id) != null ? _a : step.key]);
13718
- return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_jsx_runtime118.Fragment, { children: components.map(render) });
13818
+ return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_jsx_runtime119.Fragment, { children: render(stepComponent) });
13719
13819
  }
13720
13820
  var Step_default = Step;
13721
13821
 
13822
+ // src/revamp/renderers/stepComponentToProps.ts
13823
+ var stepComponentToProps = ({ loadingState }, children) => ({
13824
+ type: "step",
13825
+ loadingState,
13826
+ children
13827
+ });
13828
+
13722
13829
  // src/revamp/renderers/mappers/alertComponentToProps.ts
13723
13830
  var alertComponentToProps = ({
13724
13831
  context,
@@ -13855,54 +13962,6 @@ var hiddenComponentToProps = () => ({
13855
13962
  type: "hidden"
13856
13963
  });
13857
13964
 
13858
- // src/revamp/renderers/mappers/searchComponentToProps.ts
13859
- var searchComponentToProps = (component) => {
13860
- const { uid, control, emptyMessage, error, isLoading, margin, query, results, title } = component;
13861
- const onChange = component.onChange.bind(component);
13862
- const onSelect = component.onSelect.bind(component);
13863
- const state = getSearchState({
13864
- emptyMessage,
13865
- error,
13866
- query,
13867
- results,
13868
- onChange,
13869
- onSelect
13870
- });
13871
- return {
13872
- type: "search",
13873
- id: uid,
13874
- control,
13875
- isLoading,
13876
- margin,
13877
- query,
13878
- state,
13879
- title,
13880
- onChange
13881
- };
13882
- };
13883
- var getSearchState = ({
13884
- emptyMessage,
13885
- error,
13886
- query,
13887
- results,
13888
- onChange,
13889
- onSelect
13890
- }) => {
13891
- if (!query) {
13892
- return { type: "pending" };
13893
- }
13894
- if (error) {
13895
- return { type: "error", onRetry: () => onChange(query) };
13896
- }
13897
- if (results.length === 0) {
13898
- return { type: "noResults", message: emptyMessage };
13899
- }
13900
- const rendererResults = results.map((result) => __spreadProps(__spreadValues({}, result), {
13901
- onClick: () => onSelect(result)
13902
- }));
13903
- return { type: "results", results: rendererResults };
13904
- };
13905
-
13906
13965
  // src/revamp/renderers/mappers/imageComponentToProps.ts
13907
13966
  var imageComponentToProps = ({
13908
13967
  accessibilityDescription,
@@ -13973,6 +14032,34 @@ var modalComponentToProps = ({ control, margin, trigger }, components) => ({
13973
14032
  trigger
13974
14033
  });
13975
14034
 
14035
+ // src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
14036
+ var multiUploadInputComponentToProps = (component) => {
14037
+ const { accepts, fileMap, maxSize, minItems, maxItems, uploadLabel } = component;
14038
+ const findIdByValue = (file) => Object.keys(fileMap).find((id) => fileMap[id] === file);
14039
+ const fileList = Object.values(fileMap).map((file) => {
14040
+ var _a;
14041
+ return {
14042
+ id: (_a = findIdByValue(file)) != null ? _a : "",
14043
+ file
14044
+ };
14045
+ });
14046
+ return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload-multi")), {
14047
+ accepts,
14048
+ maxSize,
14049
+ minItems,
14050
+ maxItems,
14051
+ uploadLabel,
14052
+ value: fileList,
14053
+ onUpload: component.onUpload.bind(component),
14054
+ onDelete: component.onDelete.bind(component)
14055
+ });
14056
+ };
14057
+
14058
+ // src/revamp/renderers/mappers/numberInputComponentToProps.ts
14059
+ var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
14060
+ onChange: component.onChange.bind(component)
14061
+ });
14062
+
13976
14063
  // src/revamp/renderers/mappers/objectComponentToProps.ts
13977
14064
  var objectComponentToProps = ({ control, description, help, title }, children) => ({
13978
14065
  type: "form-section",
@@ -13997,34 +14084,6 @@ var paragraphComponentToProps = ({
13997
14084
  text
13998
14085
  });
13999
14086
 
14000
- // src/revamp/renderers/mappers/numberInputComponentToProps.ts
14001
- var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
14002
- onChange: component.onChange.bind(component)
14003
- });
14004
-
14005
- // src/revamp/renderers/mappers/uploadInputComponentToProps.ts
14006
- var uploadInputComponentToProps = (component) => {
14007
- const { accepts, maxSize } = component;
14008
- return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload")), {
14009
- accepts,
14010
- maxSize,
14011
- onUpload: component.onUpload.bind(component)
14012
- });
14013
- };
14014
-
14015
- // src/revamp/renderers/mappers/selectInputComponentToProps.ts
14016
- var selectInputComponentToProps = (component, children) => {
14017
- var _b;
14018
- const { options, selectedIndex, onSelect } = component;
14019
- const _a = inputComponentToProps(component, "input-select"), { value } = _a, props = __objRest(_a, ["value"]);
14020
- return __spreadProps(__spreadValues({}, props), {
14021
- options,
14022
- selectedIndex,
14023
- onSelect: onSelect.bind(component),
14024
- children: (_b = children[selectedIndex != null ? selectedIndex : -1]) != null ? _b : null
14025
- });
14026
- };
14027
-
14028
14087
  // src/revamp/renderers/mappers/repeatableComponentToProps.ts
14029
14088
  var repeatableComponentToProps = (component, children, editableItemChildren) => {
14030
14089
  const {
@@ -14087,6 +14146,67 @@ var reviewComponentToProps = ({
14087
14146
  title
14088
14147
  });
14089
14148
 
14149
+ // src/revamp/renderers/mappers/searchComponentToProps.ts
14150
+ var searchComponentToProps = (component) => {
14151
+ const { uid, control, emptyMessage, error, isLoading, margin, query, results, title } = component;
14152
+ const onChange = component.onChange.bind(component);
14153
+ const onSelect = component.onSelect.bind(component);
14154
+ const state = getSearchState({
14155
+ emptyMessage,
14156
+ error,
14157
+ query,
14158
+ results,
14159
+ onChange,
14160
+ onSelect
14161
+ });
14162
+ return {
14163
+ type: "search",
14164
+ id: uid,
14165
+ control,
14166
+ isLoading,
14167
+ margin,
14168
+ query,
14169
+ state,
14170
+ title,
14171
+ onChange
14172
+ };
14173
+ };
14174
+ var getSearchState = ({
14175
+ emptyMessage,
14176
+ error,
14177
+ query,
14178
+ results,
14179
+ onChange,
14180
+ onSelect
14181
+ }) => {
14182
+ if (!query) {
14183
+ return { type: "pending" };
14184
+ }
14185
+ if (error) {
14186
+ return { type: "error", onRetry: () => onChange(query) };
14187
+ }
14188
+ if (results.length === 0) {
14189
+ return { type: "noResults", message: emptyMessage };
14190
+ }
14191
+ const rendererResults = results.map((result) => __spreadProps(__spreadValues({}, result), {
14192
+ onClick: () => onSelect(result)
14193
+ }));
14194
+ return { type: "results", results: rendererResults };
14195
+ };
14196
+
14197
+ // src/revamp/renderers/mappers/selectInputComponentToProps.ts
14198
+ var selectInputComponentToProps = (component, children) => {
14199
+ var _b;
14200
+ const { options, selectedIndex, onSelect } = component;
14201
+ const _a = inputComponentToProps(component, "input-select"), { value } = _a, props = __objRest(_a, ["value"]);
14202
+ return __spreadProps(__spreadValues({}, props), {
14203
+ options,
14204
+ selectedIndex,
14205
+ onSelect: onSelect.bind(component),
14206
+ children: (_b = children[selectedIndex != null ? selectedIndex : -1]) != null ? _b : null
14207
+ });
14208
+ };
14209
+
14090
14210
  // src/revamp/renderers/mappers/statusListComponentToProps.ts
14091
14211
  var statusListComponentToProps = ({
14092
14212
  control,
@@ -14107,26 +14227,13 @@ var textInputComponentToProps = (component) => __spreadProps(__spreadValues({},
14107
14227
  onChange: component.onChange.bind(component)
14108
14228
  });
14109
14229
 
14110
- // src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
14111
- var multiUploadInputComponentToProps = (component) => {
14112
- const { accepts, fileMap, maxSize, minItems, maxItems, uploadLabel } = component;
14113
- const findIdByValue = (file) => Object.keys(fileMap).find((id) => fileMap[id] === file);
14114
- const fileList = Object.values(fileMap).map((file) => {
14115
- var _a;
14116
- return {
14117
- id: (_a = findIdByValue(file)) != null ? _a : "",
14118
- file
14119
- };
14120
- });
14121
- return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload-multi")), {
14230
+ // src/revamp/renderers/mappers/uploadInputComponentToProps.ts
14231
+ var uploadInputComponentToProps = (component) => {
14232
+ const { accepts, maxSize } = component;
14233
+ return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload")), {
14122
14234
  accepts,
14123
14235
  maxSize,
14124
- minItems,
14125
- maxItems,
14126
- uploadLabel,
14127
- value: fileList,
14128
- onUpload: component.onUpload.bind(component),
14129
- onDelete: component.onDelete.bind(component)
14236
+ onUpload: component.onUpload.bind(component)
14130
14237
  });
14131
14238
  };
14132
14239
 
@@ -14137,6 +14244,8 @@ var componentToRendererProps = (component, nestedContent) => {
14137
14244
  return hiddenComponentToProps();
14138
14245
  }
14139
14246
  switch (component.type) {
14247
+ case "step":
14248
+ return stepComponentToProps(component, children);
14140
14249
  case "alert":
14141
14250
  return alertComponentToProps(component);
14142
14251
  case "all-of":
@@ -14203,7 +14312,7 @@ var componentToRendererProps = (component, nestedContent) => {
14203
14312
  };
14204
14313
 
14205
14314
  // src/revamp/step/utils/getRenderFunction.tsx
14206
- var import_jsx_runtime119 = require("react/jsx-runtime");
14315
+ var import_jsx_runtime120 = require("react/jsx-runtime");
14207
14316
  var getRenderFunction = (renderers2) => {
14208
14317
  function ComponentRenderer(props) {
14209
14318
  const { type } = props;
@@ -14242,7 +14351,7 @@ var getRenderFunction = (renderers2) => {
14242
14351
  children: component.getChildren().map(render)
14243
14352
  };
14244
14353
  };
14245
- const render = (component) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
14354
+ const render = (component) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
14246
14355
  ComponentRenderer,
14247
14356
  __spreadValues({}, componentToRendererProps(component, getNestedContent(component))),
14248
14357
  component.uid
@@ -14337,7 +14446,7 @@ var formatDateOptions = {
14337
14446
  };
14338
14447
 
14339
14448
  // src/revamp/DynamicFlowCore.tsx
14340
- var import_jsx_runtime120 = require("react/jsx-runtime");
14449
+ var import_jsx_runtime121 = require("react/jsx-runtime");
14341
14450
  function DynamicFlowCore(props) {
14342
14451
  var _a;
14343
14452
  const {
@@ -14353,20 +14462,21 @@ function DynamicFlowCore(props) {
14353
14462
  onLog
14354
14463
  } = props;
14355
14464
  const { formatMessage, locale } = (0, import_react_intl35.useIntl)();
14356
- const getErrorMessageFunctions = (0, import_react55.useMemo)(
14465
+ const getErrorMessageFunctions = (0, import_react57.useMemo)(
14357
14466
  () => getSchemaErrorMessageFunction(formatMessage, locale),
14358
14467
  [formatMessage, locale]
14359
14468
  );
14360
- (0, import_react55.useEffect)(() => {
14469
+ (0, import_react57.useEffect)(() => {
14361
14470
  var _a2;
14362
14471
  if (!initialStep && initialAction) {
14363
14472
  void triggerSubmission(initialAction, (_a2 = initialAction.data) != null ? _a2 : {}, null);
14364
14473
  }
14365
14474
  }, []);
14366
- const [step, setStep] = (0, import_react55.useState)(initialStep != null ? initialStep : null);
14367
- const localValueRef = (0, import_react55.useRef)(null);
14368
- const [etag, setEtag] = (0, import_react55.useState)(null);
14369
- const abortControllerRef = (0, import_react55.useRef)(new AbortController());
14475
+ const [step, setStep] = (0, import_react57.useState)(initialStep != null ? initialStep : null);
14476
+ const localValueRef = (0, import_react57.useRef)(null);
14477
+ const [etag, setEtag] = (0, import_react57.useState)(null);
14478
+ const abortControllerRef = (0, import_react57.useRef)(new AbortController());
14479
+ const [loadingState, setLoadingState] = (0, import_react57.useState)(initialStep ? "idle" : "loading");
14370
14480
  const abortCurrentAndGetNewAbortSignal = () => {
14371
14481
  abortControllerRef.current.abort();
14372
14482
  abortControllerRef.current = new AbortController();
@@ -14374,26 +14484,27 @@ function DynamicFlowCore(props) {
14374
14484
  };
14375
14485
  const stepId = (_a = step == null ? void 0 : step.id) != null ? _a : step == null ? void 0 : step.key;
14376
14486
  const stepAnalytics = step == null ? void 0 : step.analytics;
14377
- const trackEvent = (0, import_react55.useMemo)(
14487
+ const trackEvent = (0, import_react57.useMemo)(
14378
14488
  () => getAnalyticsEventDispatcher({ flowId, stepId, analytics: stepAnalytics, onEvent }),
14379
14489
  // eslint-disable-next-line react-hooks/exhaustive-deps
14380
14490
  [flowId, stepId, JSON.stringify(stepAnalytics), onEvent]
14381
14491
  );
14382
- const logEvent = (0, import_react55.useMemo)(() => getLoggingEventDispatcher(onLog), [onLog]);
14383
- (0, import_react55.useEffect)(() => trackEvent("Flow Started"), []);
14384
- const closeWithError = (0, import_react55.useCallback)(
14492
+ const logEvent = (0, import_react57.useMemo)(() => getLoggingEventDispatcher(onLog), [onLog]);
14493
+ (0, import_react57.useEffect)(() => trackEvent("Flow Started"), []);
14494
+ const closeWithError = (0, import_react57.useCallback)(
14385
14495
  (error, analytics) => {
14386
14496
  trackEvent("Flow Failed", __spreadValues({}, analytics));
14387
14497
  onError(error);
14388
14498
  },
14389
14499
  [onError, trackEvent]
14390
14500
  );
14391
- const triggerSubmission = (0, import_react55.useCallback)(
14501
+ const triggerSubmission = (0, import_react57.useCallback)(
14392
14502
  async (action, model, localValue) => {
14393
14503
  if (true) {
14394
14504
  console.log("\u23EF\uFE0F triggerSubmission", JSON.stringify({ action, model }, null, 2));
14395
14505
  }
14396
14506
  try {
14507
+ setLoadingState("loading");
14397
14508
  const command = await executeSubmission({
14398
14509
  action,
14399
14510
  model,
@@ -14410,11 +14521,13 @@ function DynamicFlowCore(props) {
14410
14521
  }
14411
14522
  case "replace-step": {
14412
14523
  localValueRef.current = null;
14524
+ setLoadingState("idle");
14413
14525
  setStep(command.step);
14414
14526
  setEtag(command.etag);
14415
14527
  break;
14416
14528
  }
14417
14529
  case "error": {
14530
+ setLoadingState("idle");
14418
14531
  const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
14419
14532
  const { errors = { error: genericErrorMessage } } = command.body;
14420
14533
  if (step) {
@@ -14438,6 +14551,7 @@ function DynamicFlowCore(props) {
14438
14551
  });
14439
14552
  switch (refreshCommand.type) {
14440
14553
  case "refresh-step":
14554
+ setLoadingState("idle");
14441
14555
  setStep(__spreadProps(__spreadValues({}, refreshCommand.step), { errors }));
14442
14556
  setEtag(refreshCommand.etag);
14443
14557
  break;
@@ -14456,7 +14570,7 @@ function DynamicFlowCore(props) {
14456
14570
  },
14457
14571
  [httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
14458
14572
  );
14459
- const triggerRefresh = (0, import_react55.useCallback)(
14573
+ const triggerRefresh = (0, import_react57.useCallback)(
14460
14574
  async ({
14461
14575
  refreshUrl,
14462
14576
  model,
@@ -14468,6 +14582,7 @@ function DynamicFlowCore(props) {
14468
14582
  }
14469
14583
  try {
14470
14584
  localValueRef.current = localValue;
14585
+ setLoadingState("loading");
14471
14586
  const command = await executeRefresh({
14472
14587
  abortSignal: abortCurrentAndGetNewAbortSignal(),
14473
14588
  url: refreshUrl,
@@ -14477,6 +14592,7 @@ function DynamicFlowCore(props) {
14477
14592
  httpClient,
14478
14593
  trackEvent
14479
14594
  });
14595
+ setLoadingState("idle");
14480
14596
  switch (command.type) {
14481
14597
  case "refresh-step":
14482
14598
  setStep(command.step);
@@ -14495,16 +14611,17 @@ function DynamicFlowCore(props) {
14495
14611
  },
14496
14612
  [etag, httpClient, trackEvent, closeWithError]
14497
14613
  );
14498
- const render = (0, import_react55.useMemo)(
14499
- () => getRenderFunction([CoreContainerRenderer, ...renderers2]),
14614
+ const render = (0, import_react57.useMemo)(
14615
+ () => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
14500
14616
  [renderers2]
14501
14617
  );
14502
- return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(ErrorBoundary_default, { onError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
14618
+ return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ErrorBoundary_default, { onError: closeWithError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
14503
14619
  Step_default,
14504
14620
  {
14505
14621
  displayStepTitle,
14506
14622
  step,
14507
14623
  localValue: localValueRef.current,
14624
+ loadingState,
14508
14625
  getErrorMessageFunctions,
14509
14626
  render,
14510
14627
  httpClient,
@@ -14517,16 +14634,16 @@ function DynamicFlowCore(props) {
14517
14634
  }
14518
14635
 
14519
14636
  // src/revamp/DynamicFlowWise.tsx
14520
- var import_jsx_runtime121 = require("react/jsx-runtime");
14637
+ var import_jsx_runtime122 = require("react/jsx-runtime");
14521
14638
  var renderers = getWiseRenderers();
14522
14639
  function DynamicFlowWise(props) {
14523
14640
  const { httpClient } = props;
14524
14641
  const { locale } = (0, import_react_intl36.useIntl)();
14525
- const wiseHttpClient = (0, import_react56.useMemo)(
14642
+ const wiseHttpClient = (0, import_react58.useMemo)(
14526
14643
  () => makeWiseHttpClient(httpClient, locale),
14527
14644
  [httpClient, locale]
14528
14645
  );
14529
- return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
14646
+ return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
14530
14647
  }
14531
14648
  var DynamicFlowWise_default = DynamicFlowWise;
14532
14649
  var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(