@wise/dynamic-flow-client 4.5.7 → 4.6.0

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
@@ -1090,6 +1090,7 @@ function getChildren(node) {
1090
1090
  case "form-section":
1091
1091
  case "step":
1092
1092
  case "modal-content":
1093
+ case "section":
1093
1094
  return node.childrenProps;
1094
1095
  case "columns":
1095
1096
  return [...node.startChildrenProps, ...node.endChildrenProps];
@@ -1715,6 +1716,17 @@ var getSearchState = ({
1715
1716
  return { type: "results", results: rendererResults };
1716
1717
  };
1717
1718
 
1719
+ // src/revamp/renderers/mappers/sectionComponentToProps.ts
1720
+ var sectionComponentToProps = (component, rendererMapperProps) => {
1721
+ const childrenProps = component.components.map(
1722
+ (c) => componentToRendererProps(c, rendererMapperProps)
1723
+ );
1724
+ return __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "title", "margin", "control", "callToAction")), rendererMapperProps), {
1725
+ children: childrenProps.map(rendererMapperProps.render),
1726
+ childrenProps
1727
+ });
1728
+ };
1729
+
1718
1730
  // src/revamp/renderers/mappers/selectInputComponentToProps.ts
1719
1731
  var selectInputComponentToProps = (component, rendererMapperProps) => {
1720
1732
  const { autoComplete, options, selectedIndex, onSelect } = component;
@@ -1852,6 +1864,8 @@ var getComponentProps = (component, rendererMapperProps) => {
1852
1864
  return reviewComponentToProps(component, rendererMapperProps);
1853
1865
  case "search":
1854
1866
  return searchComponentToProps(component, rendererMapperProps);
1867
+ case "section":
1868
+ return sectionComponentToProps(component, rendererMapperProps);
1855
1869
  case "select":
1856
1870
  return selectInputComponentToProps(component, rendererMapperProps);
1857
1871
  case "status-list":
@@ -1944,6 +1958,10 @@ var createRootDomainComponent = (updateComponent) => {
1944
1958
  this._update((draft) => {
1945
1959
  draft.stepComponent = stepComponent;
1946
1960
  });
1961
+ },
1962
+ getRefreshUrl() {
1963
+ var _a, _b, _c, _d;
1964
+ return (_d = (_c = (_a = this.stepComponent) == null ? void 0 : _a.step.refreshUrl) != null ? _c : (_b = this.stepComponent) == null ? void 0 : _b.step.refreshFormUrl) != null ? _d : null;
1947
1965
  }
1948
1966
  };
1949
1967
  return rootComponent;
@@ -2808,6 +2826,35 @@ var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }
2808
2826
  title
2809
2827
  });
2810
2828
 
2829
+ // src/revamp/domain/components/SectionComponent.ts
2830
+ var createSectionComponent = (props) => {
2831
+ return __spreadProps(__spreadValues({}, props), {
2832
+ type: "section",
2833
+ getChildren() {
2834
+ return this.components;
2835
+ }
2836
+ });
2837
+ };
2838
+
2839
+ // src/revamp/domain/mappers/layout/sectionLayoutToComponent.ts
2840
+ var sectionLayoutToComponent = (uid, { control, title, components, callToAction, margin = "md" }, mapperProps, schemaComponents) => {
2841
+ var _a;
2842
+ return createSectionComponent({
2843
+ uid,
2844
+ control,
2845
+ title,
2846
+ components: components.map(
2847
+ (component, index) => mapLayoutToComponent(`${uid}.section-${index}`, component, mapperProps, schemaComponents)
2848
+ ),
2849
+ margin,
2850
+ callToAction: getDomainLayerCallToAction(
2851
+ callToAction,
2852
+ mapperProps.onBehavior,
2853
+ (_a = mapperProps.step.actions) != null ? _a : []
2854
+ )
2855
+ });
2856
+ };
2857
+
2811
2858
  // src/revamp/domain/mappers/mapLayoutToComponent.ts
2812
2859
  var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
2813
2860
  switch (layout.type) {
@@ -2847,6 +2894,8 @@ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
2847
2894
  return reviewLayoutToComponent(uid, layout, mapperProps);
2848
2895
  case "search":
2849
2896
  return searchLayoutToComponent(uid, layout, mapperProps);
2897
+ case "section":
2898
+ return sectionLayoutToComponent(uid, layout, mapperProps, schemaComponents);
2850
2899
  case "status-list":
2851
2900
  return statusListLayoutToComponent(uid, layout, mapperProps);
2852
2901
  default:
@@ -3025,14 +3074,14 @@ var getStepPolling = ({
3025
3074
 
3026
3075
  // src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
3027
3076
  var ONE_SECOND = 1e3;
3028
- var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
3077
+ var getStepRefreshAfter = ({ refreshAfter, onBehavior }) => {
3029
3078
  const targetTime = new Date(refreshAfter).getTime();
3030
3079
  if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
3031
3080
  throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
3032
3081
  }
3033
3082
  const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
3034
3083
  const timeout = setTimeout(() => {
3035
- void onRefresh("refreshAfter");
3084
+ void onBehavior({ type: "refresh", schemaId: "refreshAfter" });
3036
3085
  }, timeLeft);
3037
3086
  return {
3038
3087
  stop: () => clearTimeout(timeout)
@@ -3181,13 +3230,17 @@ var isOrWasValid = (getErrors, previous, current) => {
3181
3230
  };
3182
3231
 
3183
3232
  // src/revamp/domain/features/refresh/getPerformRefresh.ts
3184
- var getPerformRefresh = (schema, onRefresh) => {
3233
+ var getPerformRefresh = (schema, onBehavior) => {
3185
3234
  var _a, _b;
3186
3235
  if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
3187
3236
  const { $id, analyticsId, refreshUrl, refreshFormUrl } = schema;
3188
3237
  const schemaId = analyticsId != null ? analyticsId : $id;
3189
3238
  return () => {
3190
- void onRefresh(schemaId, refreshUrl != null ? refreshUrl : refreshFormUrl);
3239
+ void onBehavior({
3240
+ type: "refresh",
3241
+ schemaId,
3242
+ url: refreshUrl != null ? refreshUrl : refreshFormUrl
3243
+ });
3191
3244
  };
3192
3245
  }
3193
3246
  return void 0;
@@ -3712,69 +3765,6 @@ var getPerformPersisAsyncFn = (schemaMapperProps, mapperProps) => {
3712
3765
  };
3713
3766
  var schemaHasValidationMessages = (schema) => Boolean("validationMessages" in schema && schema.validationMessages);
3714
3767
 
3715
- // src/revamp/domain/features/summary/summary-utils.ts
3716
- var getSummariser = (schema) => (value) => {
3717
- const { summary, icon, image } = schema;
3718
- const stringValueOrNull = isString(value) ? value : null;
3719
- return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
3720
- };
3721
- var getConstSummary = (schema, model) => {
3722
- const { summary, icon, image } = schema;
3723
- const value = isString(model) ? model : null;
3724
- return summaryIfProvides(summary, { value, icon, image });
3725
- };
3726
- var summariseFromChildren = (components) => components.reduce(
3727
- (acc, component) => mergeSummaries(acc, component.getSummary()),
3728
- {}
3729
- );
3730
- var mergeSummaries = (summaryA, summaryB) => {
3731
- var _a, _b, _c, _d;
3732
- return {
3733
- title: (_a = summaryA.title) != null ? _a : summaryB.title,
3734
- description: (_b = summaryA.description) != null ? _b : summaryB.description,
3735
- icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
3736
- image: (_d = summaryA.image) != null ? _d : summaryB.image
3737
- };
3738
- };
3739
- var summaryIfProvides = (summary, { value, icon, image }) => {
3740
- if (!summary) {
3741
- return {};
3742
- }
3743
- return {
3744
- title: summary.providesTitle && value || void 0,
3745
- description: summary.providesDescription && value || void 0,
3746
- icon: summary.providesIcon && icon || void 0,
3747
- image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
3748
- };
3749
- };
3750
-
3751
- // src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
3752
- var mapCommonSchemaProps = (schemaMapperProps) => {
3753
- var _a;
3754
- const { uid, schemaId, schema, required, validationErrors } = schemaMapperProps;
3755
- const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3756
- return __spreadValues(__spreadValues(__spreadValues({
3757
- uid,
3758
- id: $id != null ? $id : uid,
3759
- schemaId,
3760
- analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
3761
- control,
3762
- description,
3763
- disabled: schemaHasDisabled(schema) ? schema.disabled : false,
3764
- errors: isString(validationErrors) ? [validationErrors] : void 0,
3765
- hidden: Boolean(hidden),
3766
- icon,
3767
- image: mapSpecImage(image),
3768
- keywords,
3769
- required: Boolean(required),
3770
- title,
3771
- summariser: getSummariser(schema)
3772
- }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3773
- };
3774
- var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3775
- var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
3776
- var schemaHasPlaceholder = (schema) => Boolean("placeholder" in schema && schema.placeholder);
3777
-
3778
3768
  // src/revamp/domain/features/validationAsync/getPerformValidationAsync.ts
3779
3769
  var getPerformValidationAsync = ({
3780
3770
  httpClient,
@@ -3852,11 +3842,74 @@ var getValidationAsyncFn = (schemaMapperProps, mapperProps) => {
3852
3842
  };
3853
3843
  var schemaHasValidationAsync = (schema) => Boolean("validationAsync" in schema && schema.validationAsync);
3854
3844
 
3845
+ // src/revamp/domain/features/summary/summary-utils.ts
3846
+ var getSummariser = (schema) => (value) => {
3847
+ const { summary, icon, image } = schema;
3848
+ const stringValueOrNull = isString(value) ? value : null;
3849
+ return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
3850
+ };
3851
+ var getConstSummary = (schema, model) => {
3852
+ const { summary, icon, image } = schema;
3853
+ const value = isString(model) ? model : null;
3854
+ return summaryIfProvides(summary, { value, icon, image });
3855
+ };
3856
+ var summariseFromChildren = (components) => components.reduce(
3857
+ (acc, component) => mergeSummaries(acc, component.getSummary()),
3858
+ {}
3859
+ );
3860
+ var mergeSummaries = (summaryA, summaryB) => {
3861
+ var _a, _b, _c, _d;
3862
+ return {
3863
+ title: (_a = summaryA.title) != null ? _a : summaryB.title,
3864
+ description: (_b = summaryA.description) != null ? _b : summaryB.description,
3865
+ icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
3866
+ image: (_d = summaryA.image) != null ? _d : summaryB.image
3867
+ };
3868
+ };
3869
+ var summaryIfProvides = (summary, { value, icon, image }) => {
3870
+ if (!summary) {
3871
+ return {};
3872
+ }
3873
+ return {
3874
+ title: summary.providesTitle && value || void 0,
3875
+ description: summary.providesDescription && value || void 0,
3876
+ icon: summary.providesIcon && icon || void 0,
3877
+ image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
3878
+ };
3879
+ };
3880
+
3881
+ // src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
3882
+ var mapCommonSchemaProps = (schemaMapperProps) => {
3883
+ var _a;
3884
+ const { uid, schemaId, schema, required, validationErrors } = schemaMapperProps;
3885
+ const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3886
+ return __spreadValues(__spreadValues(__spreadValues({
3887
+ uid,
3888
+ id: $id != null ? $id : uid,
3889
+ schemaId,
3890
+ analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
3891
+ control,
3892
+ description,
3893
+ disabled: schemaHasDisabled(schema) ? schema.disabled : false,
3894
+ errors: isString(validationErrors) ? [validationErrors] : void 0,
3895
+ hidden: Boolean(hidden),
3896
+ icon,
3897
+ image: mapSpecImage(image),
3898
+ keywords,
3899
+ required: Boolean(required),
3900
+ title,
3901
+ summariser: getSummariser(schema)
3902
+ }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3903
+ };
3904
+ var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3905
+ var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
3906
+ var schemaHasPlaceholder = (schema) => Boolean("placeholder" in schema && schema.placeholder);
3907
+
3855
3908
  // src/revamp/domain/mappers/schema/numberSchemaToComponent.ts
3856
3909
  var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3857
3910
  const { schema, model, localValue, required = false } = schemaMapperProps;
3858
3911
  const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
3859
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
3912
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
3860
3913
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3861
3914
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
3862
3915
  schemaMapperProps,
@@ -3883,7 +3936,7 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3883
3936
  persistedState,
3884
3937
  validationAsyncState,
3885
3938
  performPersistAsync,
3886
- performRefresh: getPerformRefresh(schema, onRefresh),
3939
+ performRefresh: getPerformRefresh(schema, onBehavior),
3887
3940
  performValidationAsync,
3888
3941
  onValueChange
3889
3942
  }),
@@ -4502,7 +4555,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4502
4555
  };
4503
4556
  });
4504
4557
  const { maxItems, minItems, title, validationMessages } = schema;
4505
- const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4558
+ const { getErrorMessageFunctions, onBehavior, onValueChange, updateComponent } = mapperProps;
4506
4559
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4507
4560
  const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4508
4561
  schemaMapperProps,
@@ -4525,7 +4578,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4525
4578
  title,
4526
4579
  validationAsyncState,
4527
4580
  performValidationAsync,
4528
- performRefresh: getPerformRefresh(schema, onRefresh),
4581
+ performRefresh: getPerformRefresh(schema, onBehavior),
4529
4582
  onValueChange
4530
4583
  }),
4531
4584
  updateComponent
@@ -4864,8 +4917,8 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4864
4917
  var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
4865
4918
  const { schema, localValue, model } = schemaMapperProps;
4866
4919
  const { default: defaultValue } = schema;
4867
- const { updateComponent, onRefresh, onValueChange } = mapperProps;
4868
- const performRefresh = getPerformRefresh(schema, onRefresh);
4920
+ const { updateComponent, onBehavior, onValueChange } = mapperProps;
4921
+ const performRefresh = getPerformRefresh(schema, onBehavior);
4869
4922
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4870
4923
  schemaMapperProps,
4871
4924
  mapperProps
@@ -5047,7 +5100,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
5047
5100
  var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
5048
5101
  const { schema, localValue, model, required = false } = schemaMapperProps;
5049
5102
  const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
5050
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5103
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5051
5104
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5052
5105
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5053
5106
  schemaMapperProps,
@@ -5075,7 +5128,7 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
5075
5128
  value,
5076
5129
  validationAsyncState,
5077
5130
  performPersistAsync,
5078
- performRefresh: getPerformRefresh(schema, onRefresh),
5131
+ performRefresh: getPerformRefresh(schema, onBehavior),
5079
5132
  performValidationAsync,
5080
5133
  onValueChange
5081
5134
  }),
@@ -5354,7 +5407,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
5354
5407
  )
5355
5408
  };
5356
5409
  });
5357
- const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
5410
+ const { getErrorMessageFunctions, updateComponent, trackEvent, onBehavior, onValueChange } = mapperProps;
5358
5411
  const { validationMessages } = schema;
5359
5412
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5360
5413
  return createSelectInputComponent(
@@ -5363,7 +5416,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
5363
5416
  checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
5364
5417
  options,
5365
5418
  initialModel,
5366
- performRefresh: getPerformRefresh(schema, onRefresh),
5419
+ performRefresh: getPerformRefresh(schema, onBehavior),
5367
5420
  onValueChange,
5368
5421
  trackEvent
5369
5422
  }),
@@ -5494,7 +5547,7 @@ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5494
5547
  maximum: maximumDate,
5495
5548
  suggestions
5496
5549
  } = schema;
5497
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5550
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5498
5551
  const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
5499
5552
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5500
5553
  schemaMapperProps,
@@ -5526,7 +5579,7 @@ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5526
5579
  persistedState,
5527
5580
  validationAsyncState,
5528
5581
  performPersistAsync,
5529
- performRefresh: getPerformRefresh(schema, onRefresh),
5582
+ performRefresh: getPerformRefresh(schema, onBehavior),
5530
5583
  performValidationAsync,
5531
5584
  onValueChange
5532
5585
  }),
@@ -5539,7 +5592,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5539
5592
  var _a;
5540
5593
  const { schema, localValue, model, required = false } = schemaMapperProps;
5541
5594
  const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
5542
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5595
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5543
5596
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5544
5597
  const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5545
5598
  const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
@@ -5562,7 +5615,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5562
5615
  value,
5563
5616
  persistedState,
5564
5617
  performPersistAsync,
5565
- performRefresh: getPerformRefresh(schema, onRefresh),
5618
+ performRefresh: getPerformRefresh(schema, onBehavior),
5566
5619
  onValueChange
5567
5620
  }),
5568
5621
  updateComponent
@@ -5698,7 +5751,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5698
5751
  suggestions,
5699
5752
  validationMessages
5700
5753
  } = schema;
5701
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
5754
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange, logEvent } = mapperProps;
5702
5755
  const controlForLegacyFormat = getControlForLegacyFormat(format);
5703
5756
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5704
5757
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
@@ -5735,7 +5788,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5735
5788
  persistedState,
5736
5789
  validationAsyncState,
5737
5790
  performPersistAsync,
5738
- performRefresh: getPerformRefresh(schema, onRefresh),
5791
+ performRefresh: getPerformRefresh(schema, onBehavior),
5739
5792
  performValidationAsync,
5740
5793
  onValueChange
5741
5794
  }),
@@ -5856,7 +5909,7 @@ var mapStepToComponent = (_a) => {
5856
5909
  "onPoll",
5857
5910
  "onBehavior"
5858
5911
  ]);
5859
- var _a2, _b2;
5912
+ var _a2;
5860
5913
  const { step, stepLocalValue, updateComponent } = restProps;
5861
5914
  const {
5862
5915
  id,
@@ -5881,17 +5934,15 @@ var mapStepToComponent = (_a) => {
5881
5934
  });
5882
5935
  }
5883
5936
  } : void 0;
5884
- const refreshUrl = (_b2 = step.refreshUrl) != null ? _b2 : step.refreshFormUrl;
5885
5937
  const stepId = id || key;
5886
5938
  if (stepId === void 0) {
5887
5939
  throw new Error("Step must have an id or a key");
5888
5940
  }
5889
5941
  const uid = `${rootUid}.${stepId != null ? stepId : "step"}`;
5890
- const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
5891
5942
  const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onBehavior, onPoll }) : void 0;
5892
- const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
5943
+ const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onBehavior }) : void 0;
5893
5944
  const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
5894
- const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
5945
+ const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior });
5895
5946
  const referencedSchemaIds = getReferencedSchemaId(step);
5896
5947
  const schemaComponents = mapStepSchemas(
5897
5948
  uid,
@@ -6445,7 +6496,6 @@ function useDynamicFlowCore(props) {
6445
6496
  logEvent,
6446
6497
  httpClient,
6447
6498
  onBehavior,
6448
- onRefresh,
6449
6499
  onPoll,
6450
6500
  onValueChange
6451
6501
  });
@@ -6528,6 +6578,10 @@ function useDynamicFlowCore(props) {
6528
6578
  }
6529
6579
  break;
6530
6580
  }
6581
+ case "refresh": {
6582
+ await onRefresh(behavior.schemaId, behavior.url);
6583
+ break;
6584
+ }
6531
6585
  case "link": {
6532
6586
  onLink(behavior.url);
6533
6587
  break;
@@ -6626,14 +6680,14 @@ function useDynamicFlowCore(props) {
6626
6680
  }
6627
6681
  }, []);
6628
6682
  const onRefresh = (0, import_react3.useCallback)(
6629
- async (schemaId, refreshUrl = "", errorsOverride) => {
6630
- var _a2;
6683
+ async (schemaId, refreshUrl, errorsOverride) => {
6684
+ var _a2, _b;
6631
6685
  try {
6632
6686
  rootComponentRef.current.setLoadingState("refreshing");
6633
6687
  const model = (_a2 = await rootComponentRef.current.getSubmittableValue()) != null ? _a2 : null;
6634
6688
  const command = await executeRefresh({
6635
6689
  abortSignal: abortCurrentAndGetNewAbortSignal(),
6636
- url: refreshUrl,
6690
+ url: (_b = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _b : "",
6637
6691
  model,
6638
6692
  schemaId,
6639
6693
  etag: etagRef.current,
package/build/main.mjs CHANGED
@@ -1047,6 +1047,7 @@ function getChildren(node) {
1047
1047
  case "form-section":
1048
1048
  case "step":
1049
1049
  case "modal-content":
1050
+ case "section":
1050
1051
  return node.childrenProps;
1051
1052
  case "columns":
1052
1053
  return [...node.startChildrenProps, ...node.endChildrenProps];
@@ -1672,6 +1673,17 @@ var getSearchState = ({
1672
1673
  return { type: "results", results: rendererResults };
1673
1674
  };
1674
1675
 
1676
+ // src/revamp/renderers/mappers/sectionComponentToProps.ts
1677
+ var sectionComponentToProps = (component, rendererMapperProps) => {
1678
+ const childrenProps = component.components.map(
1679
+ (c) => componentToRendererProps(c, rendererMapperProps)
1680
+ );
1681
+ return __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "title", "margin", "control", "callToAction")), rendererMapperProps), {
1682
+ children: childrenProps.map(rendererMapperProps.render),
1683
+ childrenProps
1684
+ });
1685
+ };
1686
+
1675
1687
  // src/revamp/renderers/mappers/selectInputComponentToProps.ts
1676
1688
  var selectInputComponentToProps = (component, rendererMapperProps) => {
1677
1689
  const { autoComplete, options, selectedIndex, onSelect } = component;
@@ -1809,6 +1821,8 @@ var getComponentProps = (component, rendererMapperProps) => {
1809
1821
  return reviewComponentToProps(component, rendererMapperProps);
1810
1822
  case "search":
1811
1823
  return searchComponentToProps(component, rendererMapperProps);
1824
+ case "section":
1825
+ return sectionComponentToProps(component, rendererMapperProps);
1812
1826
  case "select":
1813
1827
  return selectInputComponentToProps(component, rendererMapperProps);
1814
1828
  case "status-list":
@@ -1901,6 +1915,10 @@ var createRootDomainComponent = (updateComponent) => {
1901
1915
  this._update((draft) => {
1902
1916
  draft.stepComponent = stepComponent;
1903
1917
  });
1918
+ },
1919
+ getRefreshUrl() {
1920
+ var _a, _b, _c, _d;
1921
+ return (_d = (_c = (_a = this.stepComponent) == null ? void 0 : _a.step.refreshUrl) != null ? _c : (_b = this.stepComponent) == null ? void 0 : _b.step.refreshFormUrl) != null ? _d : null;
1904
1922
  }
1905
1923
  };
1906
1924
  return rootComponent;
@@ -2765,6 +2783,35 @@ var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }
2765
2783
  title
2766
2784
  });
2767
2785
 
2786
+ // src/revamp/domain/components/SectionComponent.ts
2787
+ var createSectionComponent = (props) => {
2788
+ return __spreadProps(__spreadValues({}, props), {
2789
+ type: "section",
2790
+ getChildren() {
2791
+ return this.components;
2792
+ }
2793
+ });
2794
+ };
2795
+
2796
+ // src/revamp/domain/mappers/layout/sectionLayoutToComponent.ts
2797
+ var sectionLayoutToComponent = (uid, { control, title, components, callToAction, margin = "md" }, mapperProps, schemaComponents) => {
2798
+ var _a;
2799
+ return createSectionComponent({
2800
+ uid,
2801
+ control,
2802
+ title,
2803
+ components: components.map(
2804
+ (component, index) => mapLayoutToComponent(`${uid}.section-${index}`, component, mapperProps, schemaComponents)
2805
+ ),
2806
+ margin,
2807
+ callToAction: getDomainLayerCallToAction(
2808
+ callToAction,
2809
+ mapperProps.onBehavior,
2810
+ (_a = mapperProps.step.actions) != null ? _a : []
2811
+ )
2812
+ });
2813
+ };
2814
+
2768
2815
  // src/revamp/domain/mappers/mapLayoutToComponent.ts
2769
2816
  var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
2770
2817
  switch (layout.type) {
@@ -2804,6 +2851,8 @@ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
2804
2851
  return reviewLayoutToComponent(uid, layout, mapperProps);
2805
2852
  case "search":
2806
2853
  return searchLayoutToComponent(uid, layout, mapperProps);
2854
+ case "section":
2855
+ return sectionLayoutToComponent(uid, layout, mapperProps, schemaComponents);
2807
2856
  case "status-list":
2808
2857
  return statusListLayoutToComponent(uid, layout, mapperProps);
2809
2858
  default:
@@ -2982,14 +3031,14 @@ var getStepPolling = ({
2982
3031
 
2983
3032
  // src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
2984
3033
  var ONE_SECOND = 1e3;
2985
- var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
3034
+ var getStepRefreshAfter = ({ refreshAfter, onBehavior }) => {
2986
3035
  const targetTime = new Date(refreshAfter).getTime();
2987
3036
  if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
2988
3037
  throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
2989
3038
  }
2990
3039
  const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
2991
3040
  const timeout = setTimeout(() => {
2992
- void onRefresh("refreshAfter");
3041
+ void onBehavior({ type: "refresh", schemaId: "refreshAfter" });
2993
3042
  }, timeLeft);
2994
3043
  return {
2995
3044
  stop: () => clearTimeout(timeout)
@@ -3138,13 +3187,17 @@ var isOrWasValid = (getErrors, previous, current) => {
3138
3187
  };
3139
3188
 
3140
3189
  // src/revamp/domain/features/refresh/getPerformRefresh.ts
3141
- var getPerformRefresh = (schema, onRefresh) => {
3190
+ var getPerformRefresh = (schema, onBehavior) => {
3142
3191
  var _a, _b;
3143
3192
  if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
3144
3193
  const { $id, analyticsId, refreshUrl, refreshFormUrl } = schema;
3145
3194
  const schemaId = analyticsId != null ? analyticsId : $id;
3146
3195
  return () => {
3147
- void onRefresh(schemaId, refreshUrl != null ? refreshUrl : refreshFormUrl);
3196
+ void onBehavior({
3197
+ type: "refresh",
3198
+ schemaId,
3199
+ url: refreshUrl != null ? refreshUrl : refreshFormUrl
3200
+ });
3148
3201
  };
3149
3202
  }
3150
3203
  return void 0;
@@ -3669,69 +3722,6 @@ var getPerformPersisAsyncFn = (schemaMapperProps, mapperProps) => {
3669
3722
  };
3670
3723
  var schemaHasValidationMessages = (schema) => Boolean("validationMessages" in schema && schema.validationMessages);
3671
3724
 
3672
- // src/revamp/domain/features/summary/summary-utils.ts
3673
- var getSummariser = (schema) => (value) => {
3674
- const { summary, icon, image } = schema;
3675
- const stringValueOrNull = isString(value) ? value : null;
3676
- return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
3677
- };
3678
- var getConstSummary = (schema, model) => {
3679
- const { summary, icon, image } = schema;
3680
- const value = isString(model) ? model : null;
3681
- return summaryIfProvides(summary, { value, icon, image });
3682
- };
3683
- var summariseFromChildren = (components) => components.reduce(
3684
- (acc, component) => mergeSummaries(acc, component.getSummary()),
3685
- {}
3686
- );
3687
- var mergeSummaries = (summaryA, summaryB) => {
3688
- var _a, _b, _c, _d;
3689
- return {
3690
- title: (_a = summaryA.title) != null ? _a : summaryB.title,
3691
- description: (_b = summaryA.description) != null ? _b : summaryB.description,
3692
- icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
3693
- image: (_d = summaryA.image) != null ? _d : summaryB.image
3694
- };
3695
- };
3696
- var summaryIfProvides = (summary, { value, icon, image }) => {
3697
- if (!summary) {
3698
- return {};
3699
- }
3700
- return {
3701
- title: summary.providesTitle && value || void 0,
3702
- description: summary.providesDescription && value || void 0,
3703
- icon: summary.providesIcon && icon || void 0,
3704
- image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
3705
- };
3706
- };
3707
-
3708
- // src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
3709
- var mapCommonSchemaProps = (schemaMapperProps) => {
3710
- var _a;
3711
- const { uid, schemaId, schema, required, validationErrors } = schemaMapperProps;
3712
- const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3713
- return __spreadValues(__spreadValues(__spreadValues({
3714
- uid,
3715
- id: $id != null ? $id : uid,
3716
- schemaId,
3717
- analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
3718
- control,
3719
- description,
3720
- disabled: schemaHasDisabled(schema) ? schema.disabled : false,
3721
- errors: isString(validationErrors) ? [validationErrors] : void 0,
3722
- hidden: Boolean(hidden),
3723
- icon,
3724
- image: mapSpecImage(image),
3725
- keywords,
3726
- required: Boolean(required),
3727
- title,
3728
- summariser: getSummariser(schema)
3729
- }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3730
- };
3731
- var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3732
- var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
3733
- var schemaHasPlaceholder = (schema) => Boolean("placeholder" in schema && schema.placeholder);
3734
-
3735
3725
  // src/revamp/domain/features/validationAsync/getPerformValidationAsync.ts
3736
3726
  var getPerformValidationAsync = ({
3737
3727
  httpClient,
@@ -3809,11 +3799,74 @@ var getValidationAsyncFn = (schemaMapperProps, mapperProps) => {
3809
3799
  };
3810
3800
  var schemaHasValidationAsync = (schema) => Boolean("validationAsync" in schema && schema.validationAsync);
3811
3801
 
3802
+ // src/revamp/domain/features/summary/summary-utils.ts
3803
+ var getSummariser = (schema) => (value) => {
3804
+ const { summary, icon, image } = schema;
3805
+ const stringValueOrNull = isString(value) ? value : null;
3806
+ return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
3807
+ };
3808
+ var getConstSummary = (schema, model) => {
3809
+ const { summary, icon, image } = schema;
3810
+ const value = isString(model) ? model : null;
3811
+ return summaryIfProvides(summary, { value, icon, image });
3812
+ };
3813
+ var summariseFromChildren = (components) => components.reduce(
3814
+ (acc, component) => mergeSummaries(acc, component.getSummary()),
3815
+ {}
3816
+ );
3817
+ var mergeSummaries = (summaryA, summaryB) => {
3818
+ var _a, _b, _c, _d;
3819
+ return {
3820
+ title: (_a = summaryA.title) != null ? _a : summaryB.title,
3821
+ description: (_b = summaryA.description) != null ? _b : summaryB.description,
3822
+ icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
3823
+ image: (_d = summaryA.image) != null ? _d : summaryB.image
3824
+ };
3825
+ };
3826
+ var summaryIfProvides = (summary, { value, icon, image }) => {
3827
+ if (!summary) {
3828
+ return {};
3829
+ }
3830
+ return {
3831
+ title: summary.providesTitle && value || void 0,
3832
+ description: summary.providesDescription && value || void 0,
3833
+ icon: summary.providesIcon && icon || void 0,
3834
+ image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
3835
+ };
3836
+ };
3837
+
3838
+ // src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
3839
+ var mapCommonSchemaProps = (schemaMapperProps) => {
3840
+ var _a;
3841
+ const { uid, schemaId, schema, required, validationErrors } = schemaMapperProps;
3842
+ const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3843
+ return __spreadValues(__spreadValues(__spreadValues({
3844
+ uid,
3845
+ id: $id != null ? $id : uid,
3846
+ schemaId,
3847
+ analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
3848
+ control,
3849
+ description,
3850
+ disabled: schemaHasDisabled(schema) ? schema.disabled : false,
3851
+ errors: isString(validationErrors) ? [validationErrors] : void 0,
3852
+ hidden: Boolean(hidden),
3853
+ icon,
3854
+ image: mapSpecImage(image),
3855
+ keywords,
3856
+ required: Boolean(required),
3857
+ title,
3858
+ summariser: getSummariser(schema)
3859
+ }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3860
+ };
3861
+ var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3862
+ var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
3863
+ var schemaHasPlaceholder = (schema) => Boolean("placeholder" in schema && schema.placeholder);
3864
+
3812
3865
  // src/revamp/domain/mappers/schema/numberSchemaToComponent.ts
3813
3866
  var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3814
3867
  const { schema, model, localValue, required = false } = schemaMapperProps;
3815
3868
  const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
3816
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
3869
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
3817
3870
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3818
3871
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
3819
3872
  schemaMapperProps,
@@ -3840,7 +3893,7 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3840
3893
  persistedState,
3841
3894
  validationAsyncState,
3842
3895
  performPersistAsync,
3843
- performRefresh: getPerformRefresh(schema, onRefresh),
3896
+ performRefresh: getPerformRefresh(schema, onBehavior),
3844
3897
  performValidationAsync,
3845
3898
  onValueChange
3846
3899
  }),
@@ -4459,7 +4512,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4459
4512
  };
4460
4513
  });
4461
4514
  const { maxItems, minItems, title, validationMessages } = schema;
4462
- const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4515
+ const { getErrorMessageFunctions, onBehavior, onValueChange, updateComponent } = mapperProps;
4463
4516
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4464
4517
  const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4465
4518
  schemaMapperProps,
@@ -4482,7 +4535,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4482
4535
  title,
4483
4536
  validationAsyncState,
4484
4537
  performValidationAsync,
4485
- performRefresh: getPerformRefresh(schema, onRefresh),
4538
+ performRefresh: getPerformRefresh(schema, onBehavior),
4486
4539
  onValueChange
4487
4540
  }),
4488
4541
  updateComponent
@@ -4821,8 +4874,8 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4821
4874
  var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
4822
4875
  const { schema, localValue, model } = schemaMapperProps;
4823
4876
  const { default: defaultValue } = schema;
4824
- const { updateComponent, onRefresh, onValueChange } = mapperProps;
4825
- const performRefresh = getPerformRefresh(schema, onRefresh);
4877
+ const { updateComponent, onBehavior, onValueChange } = mapperProps;
4878
+ const performRefresh = getPerformRefresh(schema, onBehavior);
4826
4879
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4827
4880
  schemaMapperProps,
4828
4881
  mapperProps
@@ -5004,7 +5057,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
5004
5057
  var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
5005
5058
  const { schema, localValue, model, required = false } = schemaMapperProps;
5006
5059
  const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
5007
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5060
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5008
5061
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5009
5062
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5010
5063
  schemaMapperProps,
@@ -5032,7 +5085,7 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
5032
5085
  value,
5033
5086
  validationAsyncState,
5034
5087
  performPersistAsync,
5035
- performRefresh: getPerformRefresh(schema, onRefresh),
5088
+ performRefresh: getPerformRefresh(schema, onBehavior),
5036
5089
  performValidationAsync,
5037
5090
  onValueChange
5038
5091
  }),
@@ -5311,7 +5364,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
5311
5364
  )
5312
5365
  };
5313
5366
  });
5314
- const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
5367
+ const { getErrorMessageFunctions, updateComponent, trackEvent, onBehavior, onValueChange } = mapperProps;
5315
5368
  const { validationMessages } = schema;
5316
5369
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5317
5370
  return createSelectInputComponent(
@@ -5320,7 +5373,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
5320
5373
  checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
5321
5374
  options,
5322
5375
  initialModel,
5323
- performRefresh: getPerformRefresh(schema, onRefresh),
5376
+ performRefresh: getPerformRefresh(schema, onBehavior),
5324
5377
  onValueChange,
5325
5378
  trackEvent
5326
5379
  }),
@@ -5451,7 +5504,7 @@ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5451
5504
  maximum: maximumDate,
5452
5505
  suggestions
5453
5506
  } = schema;
5454
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5507
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5455
5508
  const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
5456
5509
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5457
5510
  schemaMapperProps,
@@ -5483,7 +5536,7 @@ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5483
5536
  persistedState,
5484
5537
  validationAsyncState,
5485
5538
  performPersistAsync,
5486
- performRefresh: getPerformRefresh(schema, onRefresh),
5539
+ performRefresh: getPerformRefresh(schema, onBehavior),
5487
5540
  performValidationAsync,
5488
5541
  onValueChange
5489
5542
  }),
@@ -5496,7 +5549,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5496
5549
  var _a;
5497
5550
  const { schema, localValue, model, required = false } = schemaMapperProps;
5498
5551
  const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
5499
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5552
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange } = mapperProps;
5500
5553
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5501
5554
  const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5502
5555
  const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
@@ -5519,7 +5572,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5519
5572
  value,
5520
5573
  persistedState,
5521
5574
  performPersistAsync,
5522
- performRefresh: getPerformRefresh(schema, onRefresh),
5575
+ performRefresh: getPerformRefresh(schema, onBehavior),
5523
5576
  onValueChange
5524
5577
  }),
5525
5578
  updateComponent
@@ -5655,7 +5708,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5655
5708
  suggestions,
5656
5709
  validationMessages
5657
5710
  } = schema;
5658
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
5711
+ const { getErrorMessageFunctions, updateComponent, onBehavior, onValueChange, logEvent } = mapperProps;
5659
5712
  const controlForLegacyFormat = getControlForLegacyFormat(format);
5660
5713
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5661
5714
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
@@ -5692,7 +5745,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5692
5745
  persistedState,
5693
5746
  validationAsyncState,
5694
5747
  performPersistAsync,
5695
- performRefresh: getPerformRefresh(schema, onRefresh),
5748
+ performRefresh: getPerformRefresh(schema, onBehavior),
5696
5749
  performValidationAsync,
5697
5750
  onValueChange
5698
5751
  }),
@@ -5813,7 +5866,7 @@ var mapStepToComponent = (_a) => {
5813
5866
  "onPoll",
5814
5867
  "onBehavior"
5815
5868
  ]);
5816
- var _a2, _b2;
5869
+ var _a2;
5817
5870
  const { step, stepLocalValue, updateComponent } = restProps;
5818
5871
  const {
5819
5872
  id,
@@ -5838,17 +5891,15 @@ var mapStepToComponent = (_a) => {
5838
5891
  });
5839
5892
  }
5840
5893
  } : void 0;
5841
- const refreshUrl = (_b2 = step.refreshUrl) != null ? _b2 : step.refreshFormUrl;
5842
5894
  const stepId = id || key;
5843
5895
  if (stepId === void 0) {
5844
5896
  throw new Error("Step must have an id or a key");
5845
5897
  }
5846
5898
  const uid = `${rootUid}.${stepId != null ? stepId : "step"}`;
5847
- const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
5848
5899
  const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onBehavior, onPoll }) : void 0;
5849
- const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
5900
+ const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onBehavior }) : void 0;
5850
5901
  const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
5851
- const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
5902
+ const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior });
5852
5903
  const referencedSchemaIds = getReferencedSchemaId(step);
5853
5904
  const schemaComponents = mapStepSchemas(
5854
5905
  uid,
@@ -6402,7 +6453,6 @@ function useDynamicFlowCore(props) {
6402
6453
  logEvent,
6403
6454
  httpClient,
6404
6455
  onBehavior,
6405
- onRefresh,
6406
6456
  onPoll,
6407
6457
  onValueChange
6408
6458
  });
@@ -6485,6 +6535,10 @@ function useDynamicFlowCore(props) {
6485
6535
  }
6486
6536
  break;
6487
6537
  }
6538
+ case "refresh": {
6539
+ await onRefresh(behavior.schemaId, behavior.url);
6540
+ break;
6541
+ }
6488
6542
  case "link": {
6489
6543
  onLink(behavior.url);
6490
6544
  break;
@@ -6583,14 +6637,14 @@ function useDynamicFlowCore(props) {
6583
6637
  }
6584
6638
  }, []);
6585
6639
  const onRefresh = useCallback2(
6586
- async (schemaId, refreshUrl = "", errorsOverride) => {
6587
- var _a2;
6640
+ async (schemaId, refreshUrl, errorsOverride) => {
6641
+ var _a2, _b;
6588
6642
  try {
6589
6643
  rootComponentRef.current.setLoadingState("refreshing");
6590
6644
  const model = (_a2 = await rootComponentRef.current.getSubmittableValue()) != null ? _a2 : null;
6591
6645
  const command = await executeRefresh({
6592
6646
  abortSignal: abortCurrentAndGetNewAbortSignal(),
6593
- url: refreshUrl,
6647
+ url: (_b = refreshUrl != null ? refreshUrl : rootComponentRef.current.getRefreshUrl()) != null ? _b : "",
6594
6648
  model,
6595
6649
  schemaId,
6596
6650
  etag: etagRef.current,
@@ -2,7 +2,7 @@ import type { DynamicFlowProps } from '../../dynamic-flow-types';
2
2
  type LoadingState = 'idle' | 'initial' | 'refresh' | 'submission';
3
3
  export declare function useLoader(loaderConfig: DynamicFlowProps['loaderConfig'], initialState: LoadingState): {
4
4
  isLoading: boolean;
5
- setLoadingState: import("react").Dispatch<import("react").SetStateAction<"initial" | "idle" | "submission" | "refresh">>;
5
+ setLoadingState: import("react").Dispatch<import("react").SetStateAction<"initial" | "idle" | "refresh" | "submission">>;
6
6
  loader: import("react/jsx-runtime").JSX.Element | null;
7
7
  };
8
8
  export {};
@@ -20,5 +20,6 @@ export type RootDomainComponent = BaseComponent & {
20
20
  hasStep: () => boolean;
21
21
  stop: () => void;
22
22
  setStep: (stepComponent: StepDomainComponent) => void;
23
+ getRefreshUrl: () => string | null;
23
24
  };
24
25
  export declare const createRootDomainComponent: (updateComponent: UpdateComponent) => RootDomainComponent;
@@ -0,0 +1,9 @@
1
+ import { BaseLayoutComponent, DomainComponent, CallToAction } from "../types";
2
+ export type SectionComponent = BaseLayoutComponent & {
3
+ type: 'section';
4
+ title: string;
5
+ components: DomainComponent[];
6
+ callToAction?: CallToAction;
7
+ getChildren: () => DomainComponent[];
8
+ };
9
+ export declare const createSectionComponent: (props: Pick<SectionComponent, "uid" | "title" | "control" | "components" | "callToAction" | "margin">) => SectionComponent;
@@ -1,4 +1,4 @@
1
- import type { BaseLayoutComponent } from '../types';
1
+ import type { BaseLayoutComponent, CallToAction } from '../types';
2
2
  export type StatusListComponent = BaseLayoutComponent & {
3
3
  type: 'status-list';
4
4
  items: StatusListItem[];
@@ -13,12 +13,7 @@ export type StatusListItem = {
13
13
  text: string;
14
14
  };
15
15
  status?: 'not-done' | 'pending' | 'done';
16
- callToAction?: StatusListItemCallToAction;
16
+ callToAction?: CallToAction;
17
17
  tag?: string;
18
18
  };
19
- export type StatusListItemCallToAction = {
20
- accessibilityDescription?: string;
21
- title: string;
22
- onClick: () => void;
23
- };
24
19
  export declare const createStatusListComponent: (statusListProps: Pick<StatusListComponent, "uid" | "control" | "items" | "margin" | "title">) => StatusListComponent;
@@ -1,7 +1,7 @@
1
1
  import type { Schema } from '@wise/dynamic-flow-types/build/next';
2
- import type { LocalValue, OnRefresh } from '../../types';
2
+ import type { LocalValue, OnBehavior } from '../../types';
3
3
  export type PerformRefresh = () => void;
4
- export declare const getPerformRefresh: (schema: Schema, onRefresh: OnRefresh) => PerformRefresh | undefined;
4
+ export declare const getPerformRefresh: (schema: Schema, onBehavior: OnBehavior) => PerformRefresh | undefined;
5
5
  type DebouncedPerformRefresh<V extends LocalValue> = {
6
6
  (prevValue: V, updatedValue: V): void;
7
7
  cancel: () => void;
@@ -1,10 +1,10 @@
1
- import { OnRefresh } from '../../types';
1
+ import { OnBehavior } from '../../types';
2
2
  export type StepRefreshAfter = {
3
3
  stop: () => void;
4
4
  };
5
5
  type Props = {
6
6
  refreshAfter: string;
7
- onRefresh: OnRefresh;
7
+ onBehavior: OnBehavior;
8
8
  };
9
- export declare const getStepRefreshAfter: ({ refreshAfter, onRefresh }: Props) => StepRefreshAfter;
9
+ export declare const getStepRefreshAfter: ({ refreshAfter, onBehavior }: Props) => StepRefreshAfter;
10
10
  export {};
@@ -0,0 +1,5 @@
1
+ import { SectionLayout } from '@wise/dynamic-flow-types/build/next';
2
+ import { SectionComponent } from '../../components/SectionComponent';
3
+ import { SchemaComponent } from '../../types';
4
+ import { MapperProps } from '../schema/types';
5
+ export declare const sectionLayoutToComponent: (uid: string, { control, title, components, callToAction, margin }: SectionLayout, mapperProps: MapperProps, schemaComponents: SchemaComponent[]) => SectionComponent;
@@ -1,4 +1,4 @@
1
- import type { OneOfSchema, ArraySchemaList, Model } from '@wise/dynamic-flow-types/build/next';
1
+ import type { ArraySchemaList, Model, OneOfSchema } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { MapperProps, SchemaMapperProps } from '../types';
3
3
  export declare const arraySchemaToMultiSelectComponent: (schemaMapperProps: SchemaMapperProps & {
4
4
  schema: ArraySchemaList & {
@@ -10,12 +10,10 @@ export declare const getMockMapperProps: (mapperProps?: Partial<MapperProps>) =>
10
10
  getErrorMessageFunctions: import("../../types").GetErrorMessageFunctions | jest.Mock<any, any, any>;
11
11
  httpClient: typeof fetch | jest.Mock<any, any, any>;
12
12
  onBehavior: import("../../../types").OnBehavior | jest.Mock<any, any, any>;
13
- onRefresh: import("../../../types").OnRefresh | jest.Mock<any, any, any>;
14
13
  onValueChange: import("../../../types").OnValueChange | jest.Mock<any, any, any>;
15
14
  updateComponent: import("../../../types").UpdateComponent | jest.Mock<any, any, any>;
16
15
  trackEvent: import("../../../features/events").AnalyticsEventDispatcher | jest.Mock<any, any, any>;
17
16
  logEvent: import("../../../features/events").LoggingEventDispatcher | jest.Mock<any, any, any>;
18
- onAction: jest.Mock<any, any, any>;
19
17
  onLink: jest.Mock<any, any, any>;
20
18
  };
21
19
  export declare const getMockSchemaMapperProps: <S extends Schema>(schemaMapperProps: Partial<SchemaMapperProps> & {
@@ -1,7 +1,7 @@
1
1
  import type { Step as DFStep, Model, Schema, ValidationError } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { HttpClient } from '../../../types';
3
3
  import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../../features/events';
4
- import type { LocalValue, OnBehavior, OnRefresh, OnValueChange, UpdateComponent } from '../../types';
4
+ import type { LocalValue, OnBehavior, OnValueChange, UpdateComponent } from '../../types';
5
5
  import type { GetErrorMessageFunctions, PersistAsyncConfig } from '../types';
6
6
  export type MapperProps = {
7
7
  stepLocalValue: LocalValue;
@@ -9,7 +9,6 @@ export type MapperProps = {
9
9
  getErrorMessageFunctions: GetErrorMessageFunctions;
10
10
  httpClient: HttpClient;
11
11
  onBehavior: OnBehavior;
12
- onRefresh: OnRefresh;
13
12
  onValueChange: OnValueChange;
14
13
  updateComponent: UpdateComponent;
15
14
  trackEvent: AnalyticsEventDispatcher;
@@ -29,6 +29,7 @@ import type { RepeatableComponent } from './components/RepeatableComponent';
29
29
  import type { ReviewComponent } from './components/ReviewComponent';
30
30
  import type { RootDomainComponent } from './components/RootDomainComponent';
31
31
  import type { SearchComponent } from './components/searchComponent/SearchComponent';
32
+ import type { SectionComponent } from './components/SectionComponent';
32
33
  import type { SelectInputComponent } from './components/SelectInputComponent';
33
34
  import type { StatusListComponent } from './components/StatusListComponent';
34
35
  import type { ExternalConfirmationComponent } from './components/step/ExternalConfirmationComponent';
@@ -38,7 +39,7 @@ import type { TupleComponent } from './components/TupleComponent';
38
39
  import type { UploadInputComponent } from './components/UploadInputComponent';
39
40
  export type DomainComponent = SchemaComponent | LayoutComponent | RootDomainComponent | StepDomainComponent;
40
41
  export type SchemaComponent = AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent;
41
- export type LayoutComponent = AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalComponent | ModalContentComponent | ParagraphComponent | ReviewComponent | SearchComponent | StatusListComponent;
42
+ export type LayoutComponent = AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalComponent | ModalContentComponent | ParagraphComponent | ReviewComponent | SearchComponent | SectionComponent | StatusListComponent;
42
43
  export type LocalValue = LocalValuePrimitive | LocalValueObject | LocalValueArray;
43
44
  export type LocalValuePrimitive = string | number | boolean | File | null;
44
45
  export interface LocalValueObject extends Record<string, LocalValuePrimitive | LocalValueObject | LocalValueArray> {
@@ -57,9 +58,14 @@ export type CallToAction = {
57
58
  href: string;
58
59
  onClick: () => void;
59
60
  };
60
- export type Behavior = ActionBehavior | LinkBehavior | ModalBehavior | DismissBehavior | {
61
+ export type Behavior = ActionBehavior | RefreshBehavior | LinkBehavior | ModalBehavior | DismissBehavior | {
61
62
  type: 'none';
62
63
  };
64
+ type RefreshBehavior = {
65
+ type: 'refresh';
66
+ schemaId?: string;
67
+ url?: string;
68
+ };
63
69
  export type BaseComponent = {
64
70
  type: string;
65
71
  uid: string;
@@ -107,7 +113,6 @@ export type BaseInputComponent<LV extends LocalValue> = BaseSchemaComponent<LV>
107
113
  export type UpdateComponent = () => void;
108
114
  export type OnBehavior = (behavior: Behavior) => Promise<void>;
109
115
  export type OnAction = (action: Action) => Promise<void>;
110
- export type OnRefresh = (schemaId: string | undefined, url?: string) => Promise<void> | void;
111
116
  export type OnPoll = (url: string, errorBehavior: Behavior, signal: AbortSignal) => Promise<boolean>;
112
117
  export type OnLink = (url: string) => boolean;
113
118
  export type OnValueChange = () => void;
@@ -161,3 +166,4 @@ export type SupportingValues = {
161
166
  value?: string;
162
167
  subvalue?: string;
163
168
  };
169
+ export {};
@@ -0,0 +1,4 @@
1
+ import { SectionRendererProps } from '@wise/dynamic-flow-types/build/renderers';
2
+ import { SectionComponent } from '../../domain/components/SectionComponent';
3
+ import { RendererMapperProps } from './componentToRendererProps';
4
+ export declare const sectionComponentToProps: (component: SectionComponent, rendererMapperProps: RendererMapperProps) => SectionRendererProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "4.5.7",
3
+ "version": "4.6.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",
@@ -36,19 +36,12 @@
36
36
  "@babel/preset-env": "7.27.2",
37
37
  "@babel/preset-react": "7.27.1",
38
38
  "@babel/preset-typescript": "7.27.1",
39
- "@chromatic-com/storybook": "3.2.6",
39
+ "@chromatic-com/storybook": "4.0.0",
40
40
  "@formatjs/cli": "^6.7.1",
41
- "@storybook/addon-a11y": "^8.6.14",
42
- "@storybook/addon-actions": "^8.6.14",
43
- "@storybook/addon-essentials": "^8.6.14",
44
- "@storybook/addon-interactions": "^8.6.14",
45
- "@storybook/addon-links": "^8.6.14",
46
- "@storybook/addon-webpack5-compiler-babel": "^3.0.6",
47
- "@storybook/manager-api": "^8.6.14",
48
- "@storybook/react": "^8.6.14",
49
- "@storybook/react-webpack5": "^8.6.14",
50
- "@storybook/test": "^8.6.14",
51
- "@storybook/types": "^8.6.14",
41
+ "@storybook/addon-a11y": "^9.0.4",
42
+ "@storybook/addon-docs": "^9.0.4",
43
+ "@storybook/addon-links": "^9.0.4",
44
+ "@storybook/react-vite": "9.0.4",
52
45
  "@testing-library/dom": "10.4.0",
53
46
  "@testing-library/jest-dom": "6.6.3",
54
47
  "@testing-library/react": "16.3.0",
@@ -57,8 +50,8 @@
57
50
  "@transferwise/formatting": "^2.13.1",
58
51
  "@transferwise/icons": "3.22.0",
59
52
  "@transferwise/neptune-css": "14.24.4",
60
- "@types/node": "22.15.23",
61
53
  "@types/jest": "29.5.14",
54
+ "@types/node": "22.15.23",
62
55
  "@types/react": "18.3.23",
63
56
  "@types/react-dom": "18.3.7",
64
57
  "@types/react-intl": "3.0.0",
@@ -66,6 +59,7 @@
66
59
  "@wise/components-theming": "^1.6.3",
67
60
  "babel-jest": "29.7.0",
68
61
  "esbuild": "0.25.5",
62
+ "eslint-plugin-storybook": "9.0.4",
69
63
  "jest": "29.7.0",
70
64
  "jest-environment-jsdom": "29.7.0",
71
65
  "jest-fetch-mock": "^3.0.3",
@@ -77,14 +71,13 @@
77
71
  "react": "18.3.1",
78
72
  "react-dom": "18.3.1",
79
73
  "react-intl": "6.8.9",
80
- "storybook": "^8.6.14",
74
+ "storybook": "^9.0.4",
81
75
  "stylelint": "16.19.1",
82
76
  "stylelint-config-standard": "36.0.1",
83
77
  "stylelint-no-unsupported-browser-features": "8.0.4",
84
78
  "stylelint-value-no-unknown-custom-properties": "6.0.1",
85
79
  "tsx": "4.19.4",
86
80
  "typescript": "5.8.3",
87
- "webpack": "5.99.9",
88
81
  "@wise/dynamic-flow-fixtures": "0.0.1",
89
82
  "@wise/dynamic-flow-renderers": "0.0.0"
90
83
  },
@@ -102,7 +95,7 @@
102
95
  "classnames": "2.5.1",
103
96
  "react-webcam": "^7.2.0",
104
97
  "screenfull": "^5.2.0",
105
- "@wise/dynamic-flow-types": "3.3.5"
98
+ "@wise/dynamic-flow-types": "3.4.0"
106
99
  },
107
100
  "scripts": {
108
101
  "dev": "pnpm build:visual-tests && storybook dev -p 3003",
@@ -123,6 +116,7 @@
123
116
  "lint": "npm-run-all lint:ts lint:css",
124
117
  "lint:ts": "eslint 'src/**/*.{js,jsx,ts,tsx}' --quiet",
125
118
  "lint:css": "stylelint './src/**/*.css'",
126
- "build-storybook": "pnpm build:visual-tests && storybook build -c .storybook --disable-telemetry"
119
+ "build-storybook": "pnpm build:visual-tests && storybook build -c .storybook --disable-telemetry",
120
+ "audit-i18n": "tsx ./scripts/audit-i18n.mjs"
127
121
  }
128
122
  }