@wise/dynamic-flow-client 4.3.14 → 4.5.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.
Files changed (23) hide show
  1. package/build/main.js +351 -106
  2. package/build/main.mjs +351 -106
  3. package/build/types/revamp/domain/components/AlertComponent.d.ts +2 -14
  4. package/build/types/revamp/domain/components/DecisionComponent.d.ts +4 -1
  5. package/build/types/revamp/domain/components/ListComponent.d.ts +7 -19
  6. package/build/types/revamp/domain/components/ModalContentComponent.d.ts +11 -0
  7. package/build/types/revamp/domain/components/ReviewComponent.d.ts +8 -8
  8. package/build/types/revamp/domain/components/RootDomainComponent.d.ts +5 -1
  9. package/build/types/revamp/domain/components/step/ExternalConfirmationComponent.d.ts +12 -0
  10. package/build/types/revamp/domain/components/{StepDomainComponent.d.ts → step/StepDomainComponent.d.ts} +13 -6
  11. package/build/types/revamp/domain/mappers/layout/modalToContent.d.ts +4 -0
  12. package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +1 -1
  13. package/build/types/revamp/domain/mappers/utils/call-to-action-utils.d.ts +1 -13
  14. package/build/types/revamp/domain/mappers/utils/legacy-utils.d.ts +3 -3
  15. package/build/types/revamp/domain/mappers/utils/utils.d.ts +4 -0
  16. package/build/types/revamp/domain/types.d.ts +31 -6
  17. package/build/types/revamp/flow/executeSubmission.d.ts +4 -0
  18. package/build/types/revamp/flow/getResponseType.d.ts +1 -1
  19. package/build/types/revamp/flow/response-utils.d.ts +2 -1
  20. package/build/types/revamp/renderers/mappers/externalComponentToProps.d.ts +4 -0
  21. package/build/types/revamp/renderers/mappers/modalContentComponentToProps.d.ts +4 -0
  22. package/build/types/revamp/renderers/stepComponentToProps.d.ts +2 -2
  23. package/package.json +9 -9
package/build/main.mjs CHANGED
@@ -1041,6 +1041,7 @@ function getChildren(node) {
1041
1041
  case "form":
1042
1042
  case "section":
1043
1043
  case "step":
1044
+ case "modal-content":
1044
1045
  return node.childrenProps;
1045
1046
  case "columns":
1046
1047
  return [...node.startChildrenProps, ...node.endChildrenProps];
@@ -1073,6 +1074,7 @@ function getChildren(node) {
1073
1074
  case "status-list":
1074
1075
  case "input-text":
1075
1076
  case "input-upload":
1077
+ case "external-confirmation":
1076
1078
  return [];
1077
1079
  }
1078
1080
  }
@@ -1495,7 +1497,10 @@ var repeatableComponentToProps = (component, rendererMapperProps) => {
1495
1497
  };
1496
1498
 
1497
1499
  // src/revamp/renderers/mappers/reviewComponentToProps.ts
1498
- var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "fields", "margin", "title")), rendererMapperProps);
1500
+ var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadProps(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), {
1501
+ fields: component.fields.map(mapField)
1502
+ }), rendererMapperProps);
1503
+ var mapField = (field) => __spreadValues({}, field);
1499
1504
 
1500
1505
  // src/revamp/domain/mappers/utils/image.ts
1501
1506
  var mapSpecImage = (image) => {
@@ -1631,27 +1636,32 @@ var tupleComponentToProps = (component, rendererMapperProps) => {
1631
1636
 
1632
1637
  // src/revamp/renderers/mappers/listComponentToProps.ts
1633
1638
  var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
1634
- items: component.items.map((_a) => {
1635
- var item = __objRest(_a, []);
1636
- return __spreadValues({}, item);
1637
- })
1639
+ items: component.items.map(mapItem)
1638
1640
  });
1641
+ var mapItem = (item) => {
1642
+ var _a, _b;
1643
+ return __spreadProps(__spreadValues({}, item), {
1644
+ // populate deprecated fields
1645
+ subtitle: item.description,
1646
+ value: (_a = item.supportingValues) == null ? void 0 : _a.value,
1647
+ subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
1648
+ });
1649
+ };
1639
1650
 
1640
1651
  // src/revamp/renderers/stepComponentToProps.ts
1641
- var stepComponentToProps = ({
1642
- uid,
1643
- back,
1644
- control,
1645
- description,
1646
- error,
1647
- external,
1648
- loadingState,
1649
- step,
1650
- title,
1651
- components,
1652
- onBehavior
1653
- }, rendererMapperProps) => {
1654
- const childrenProps = components.map((c) => componentToRendererProps(c, rendererMapperProps));
1652
+ var stepComponentToProps = (component, rendererMapperProps) => {
1653
+ const {
1654
+ uid,
1655
+ back,
1656
+ control,
1657
+ description,
1658
+ error,
1659
+ loadingState,
1660
+ step,
1661
+ title,
1662
+ onBehavior
1663
+ } = component;
1664
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1655
1665
  return __spreadValues({
1656
1666
  type: "step",
1657
1667
  id: step.id,
@@ -1660,7 +1670,6 @@ var stepComponentToProps = ({
1660
1670
  control,
1661
1671
  description,
1662
1672
  error,
1663
- external,
1664
1673
  loadingState,
1665
1674
  step,
1666
1675
  title,
@@ -1675,12 +1684,40 @@ var stepComponentToProps = ({
1675
1684
  // src/revamp/renderers/mappers/rootComponentToProps.ts
1676
1685
  var rootComponentToProps = (rootComponent, rendererMapperProps) => {
1677
1686
  const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
1678
- return {
1687
+ return __spreadValues({
1679
1688
  type: "root",
1680
1689
  uid: rootComponent.uid,
1681
1690
  children: childrenProps.map(rendererMapperProps.render),
1682
1691
  childrenProps
1683
- };
1692
+ }, rendererMapperProps);
1693
+ };
1694
+
1695
+ // src/revamp/renderers/mappers/modalContentComponentToProps.ts
1696
+ var modalContentComponentToProps = (component, rendererMapperProps) => {
1697
+ const { uid, open, title, close } = component;
1698
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1699
+ return __spreadValues({
1700
+ uid,
1701
+ type: "modal-content",
1702
+ open,
1703
+ title,
1704
+ children: childrenProps.map(rendererMapperProps.render),
1705
+ childrenProps,
1706
+ onClose: close.bind(component)
1707
+ }, rendererMapperProps);
1708
+ };
1709
+
1710
+ // src/revamp/renderers/mappers/externalComponentToProps.ts
1711
+ var externalComponentToProps = (component, rendererMapperProps) => {
1712
+ return __spreadValues({
1713
+ type: "external-confirmation",
1714
+ uid: component.uid,
1715
+ url: component.url,
1716
+ status: component.status,
1717
+ onSuccess: component.onSuccess.bind(component),
1718
+ onFailure: component.onFailure.bind(component),
1719
+ onCancel: component.onCancel.bind(component)
1720
+ }, rendererMapperProps);
1684
1721
  };
1685
1722
 
1686
1723
  // src/revamp/renderers/mappers/componentToRendererProps.ts
@@ -1713,6 +1750,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
1713
1750
  return decisionComponentToProps(component, rendererMapperProps);
1714
1751
  case "divider":
1715
1752
  return dividerComponentToProps(component, rendererMapperProps);
1753
+ case "external-confirmation":
1754
+ return externalComponentToProps(component, rendererMapperProps);
1716
1755
  case "form":
1717
1756
  return formComponentToProps(component, rendererMapperProps);
1718
1757
  case "heading":
@@ -1733,6 +1772,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
1733
1772
  return markdownComponentToProps(component, rendererMapperProps);
1734
1773
  case "modal":
1735
1774
  return modalComponentToProps(component, rendererMapperProps);
1775
+ case "modal-content":
1776
+ return modalContentComponentToProps(component, rendererMapperProps);
1736
1777
  case "multi-select":
1737
1778
  return multiSelectInputComponentToProps(component, rendererMapperProps);
1738
1779
  case "multi-upload":
@@ -1777,6 +1818,37 @@ var getInputUpdateFunction = (updateComponent) => {
1777
1818
  };
1778
1819
  };
1779
1820
 
1821
+ // src/revamp/utils/component-utils.ts
1822
+ var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
1823
+ (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
1824
+ );
1825
+ var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
1826
+ var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
1827
+ var mergeLocalValues = (valueA, valueB) => {
1828
+ if (valueA === null) {
1829
+ return valueB;
1830
+ }
1831
+ if (valueB === null) {
1832
+ return valueA;
1833
+ }
1834
+ if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
1835
+ return __spreadValues(__spreadValues({}, valueA), valueB);
1836
+ }
1837
+ return valueB;
1838
+ };
1839
+ var mergeModels = (valueA, valueB) => {
1840
+ if (valueA === null) {
1841
+ return valueB;
1842
+ }
1843
+ if (valueB === null) {
1844
+ return valueA;
1845
+ }
1846
+ if (isObjectModel(valueA) && isObjectModel(valueB)) {
1847
+ return __spreadValues(__spreadValues({}, valueA), valueB);
1848
+ }
1849
+ return valueB;
1850
+ };
1851
+
1780
1852
  // src/revamp/domain/components/RootDomainComponent.ts
1781
1853
  var createRootDomainComponent = (updateComponent) => {
1782
1854
  const update = getInputUpdateFunction(updateComponent);
@@ -1787,17 +1859,29 @@ var createRootDomainComponent = (updateComponent) => {
1787
1859
  _update(updateFn) {
1788
1860
  update(this, updateFn);
1789
1861
  },
1862
+ dismissAllModals() {
1863
+ var _a;
1864
+ (_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
1865
+ },
1866
+ dismissModal() {
1867
+ var _a;
1868
+ (_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
1869
+ },
1870
+ showModal(modal) {
1871
+ var _a;
1872
+ (_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
1873
+ },
1790
1874
  getChildren() {
1791
- return this.stepComponent ? [this.stepComponent] : [];
1875
+ return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
1792
1876
  },
1793
1877
  getLocalValue() {
1794
1878
  return this.stepComponent ? this.stepComponent.getLocalValue() : null;
1795
1879
  },
1796
1880
  async getSubmittableValue() {
1797
- return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
1881
+ return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
1798
1882
  },
1799
1883
  getSubmittableValueSync() {
1800
- return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
1884
+ return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
1801
1885
  },
1802
1886
  getSummary() {
1803
1887
  return this.stepComponent ? this.stepComponent.getSummary() : {};
@@ -1831,35 +1915,38 @@ var createRootDomainComponent = (updateComponent) => {
1831
1915
  return rootComponent;
1832
1916
  };
1833
1917
 
1834
- // src/revamp/utils/component-utils.ts
1835
- var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
1836
- (values) => values.reduce((acc, value) => mergeModels(acc, value), null)
1837
- );
1838
- var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
1839
- var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
1840
- var mergeLocalValues = (valueA, valueB) => {
1841
- if (valueA === null) {
1842
- return valueB;
1843
- }
1844
- if (valueB === null) {
1845
- return valueA;
1846
- }
1847
- if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
1848
- return __spreadValues(__spreadValues({}, valueA), valueB);
1849
- }
1850
- return valueB;
1851
- };
1852
- var mergeModels = (valueA, valueB) => {
1853
- if (valueA === null) {
1854
- return valueB;
1855
- }
1856
- if (valueB === null) {
1857
- return valueA;
1858
- }
1859
- if (isObjectModel(valueA) && isObjectModel(valueB)) {
1860
- return __spreadValues(__spreadValues({}, valueA), valueB);
1861
- }
1862
- return valueB;
1918
+ // src/revamp/domain/components/step/ExternalConfirmationComponent.ts
1919
+ var createExternalConfirmation = (uid, url, updateComponent) => {
1920
+ const update = getInputUpdateFunction(updateComponent);
1921
+ return {
1922
+ type: "external-confirmation",
1923
+ uid,
1924
+ url,
1925
+ status: "initial",
1926
+ onSuccess() {
1927
+ update(this, (draft) => {
1928
+ draft.status = "success";
1929
+ });
1930
+ },
1931
+ onFailure() {
1932
+ if (this.status === "initial") {
1933
+ update(this, (draft) => {
1934
+ draft.status = "failure";
1935
+ });
1936
+ }
1937
+ },
1938
+ onCancel() {
1939
+ update(this, (draft) => {
1940
+ draft.status = "dismissed";
1941
+ });
1942
+ },
1943
+ getSubmittableValue: async () => null,
1944
+ getSubmittableValueSync: () => null,
1945
+ getLocalValue: () => null,
1946
+ getSummary: () => ({}),
1947
+ // Noop
1948
+ validate: () => true
1949
+ };
1863
1950
  };
1864
1951
 
1865
1952
  // src/revamp/domain/features/summary/summary-utils.ts
@@ -1902,7 +1989,7 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
1902
1989
  var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
1903
1990
  var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
1904
1991
 
1905
- // src/revamp/domain/components/StepDomainComponent.ts
1992
+ // src/revamp/domain/components/step/StepDomainComponent.ts
1906
1993
  var createStepComponent = (stepProps) => {
1907
1994
  const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
1908
1995
  const update = getInputUpdateFunction(updateComponent);
@@ -1910,11 +1997,29 @@ var createStepComponent = (stepProps) => {
1910
1997
  uid
1911
1998
  }, rest), {
1912
1999
  type: "step",
2000
+ modals: [],
2001
+ dismissModal() {
2002
+ var _a2;
2003
+ (_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
2004
+ },
2005
+ dismissAllModals() {
2006
+ this._update((draft) => {
2007
+ draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
2008
+ });
2009
+ },
2010
+ showModal(modal) {
2011
+ this._update((draft) => {
2012
+ draft.modals = [...draft.modals, modal];
2013
+ });
2014
+ },
1913
2015
  _update(updateFn) {
1914
2016
  update(this, updateFn);
1915
2017
  },
1916
2018
  getChildren() {
1917
- return this.components;
2019
+ return this.externalConfirmation ? [...this.components, this.externalConfirmation] : this.components;
2020
+ },
2021
+ getModals() {
2022
+ return this.modals;
1918
2023
  },
1919
2024
  async getSubmittableValue() {
1920
2025
  return getSubmittableData(this.components);
@@ -1939,6 +2044,9 @@ var createStepComponent = (stepProps) => {
1939
2044
  stop() {
1940
2045
  stepPolling == null ? void 0 : stepPolling.stop();
1941
2046
  stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
2047
+ this._update((draft) => {
2048
+ draft.modals = [];
2049
+ });
1942
2050
  }
1943
2051
  });
1944
2052
  return component;
@@ -2067,9 +2175,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
2067
2175
  void onBehavior(behavior);
2068
2176
  };
2069
2177
  switch (behavior.type) {
2070
- case "action": {
2178
+ case "action":
2179
+ case "modal":
2180
+ case "dismiss": {
2071
2181
  return {
2072
- type: "action",
2182
+ type: behavior.type,
2073
2183
  title: title != null ? title : "",
2074
2184
  accessibilityDescription,
2075
2185
  onClick
@@ -2325,6 +2435,27 @@ var createDecisionComponent = (decisionProps) => __spreadProps(__spreadValues({
2325
2435
  validate: () => true
2326
2436
  });
2327
2437
 
2438
+ // src/revamp/domain/mappers/utils/utils.ts
2439
+ var mapInlineAlert = (alert) => {
2440
+ return alert ? {
2441
+ content: alert.content,
2442
+ context: alert.context ? mapLegacyContext(alert.context) : "neutral"
2443
+ } : void 0;
2444
+ };
2445
+ var mapAdditionalInfo = (info, onBehavior) => {
2446
+ if (info) {
2447
+ const behavior = getDomainLayerBehavior(info, []);
2448
+ return {
2449
+ text: info.text,
2450
+ accessibilityDescription: info.accessibilityDescription,
2451
+ onClick: () => {
2452
+ void onBehavior(behavior);
2453
+ }
2454
+ };
2455
+ }
2456
+ return void 0;
2457
+ };
2458
+
2328
2459
  // src/revamp/domain/mappers/layout/decisionLayoutToComponent.ts
2329
2460
  var decisionLayoutToComponent = (uid, {
2330
2461
  control,
@@ -2335,20 +2466,22 @@ var decisionLayoutToComponent = (uid, {
2335
2466
  uid,
2336
2467
  control,
2337
2468
  margin,
2338
- options: options.map((option) => {
2339
- var _a, _b;
2340
- const behavior = getDomainLayerBehavior(option, (_a = step.actions) != null ? _a : []);
2341
- return __spreadProps(__spreadValues({}, option), {
2342
- disabled: (_b = option.disabled) != null ? _b : false,
2343
- href: behavior.type === "link" ? behavior.url : void 0,
2344
- image: mapSpecImage(option.image),
2345
- onClick: () => {
2346
- void onBehavior(behavior);
2347
- }
2348
- });
2349
- }),
2469
+ options: options.map((option) => mapOption(option, onBehavior, step.actions)),
2350
2470
  title
2351
2471
  });
2472
+ var mapOption = (option, onBehavior, stepActions = []) => {
2473
+ var _a;
2474
+ const behavior = getDomainLayerBehavior(option, stepActions);
2475
+ return __spreadProps(__spreadValues({}, option), {
2476
+ disabled: (_a = option.disabled) != null ? _a : false,
2477
+ href: behavior.type === "link" ? behavior.url : void 0,
2478
+ image: mapSpecImage(option.image),
2479
+ inlineAlert: mapInlineAlert(option.inlineAlert),
2480
+ onClick: () => {
2481
+ void onBehavior(behavior);
2482
+ }
2483
+ });
2484
+ };
2352
2485
 
2353
2486
  // src/revamp/domain/components/DividerComponent.ts
2354
2487
  var createDividerComponent = (props) => __spreadProps(__spreadValues({
@@ -2957,6 +3090,16 @@ function assertActionResponseBody(body) {
2957
3090
  );
2958
3091
  }
2959
3092
  }
3093
+ function assertModalResponseBody(body) {
3094
+ if (isObject(body)) {
3095
+ if ("content" in body && isArray(body.content)) {
3096
+ return;
3097
+ }
3098
+ }
3099
+ throw new Error(
3100
+ "Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
3101
+ );
3102
+ }
2960
3103
  function isErrorResponseBody(body) {
2961
3104
  return Boolean(
2962
3105
  isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
@@ -3635,6 +3778,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3635
3778
  },
3636
3779
  // noop
3637
3780
  onSelect(updatedIndex) {
3781
+ if (updatedIndex === this.selectedIndex) {
3782
+ return;
3783
+ }
3638
3784
  if (updatedIndex !== null && this.analyticsId) {
3639
3785
  selectProps.trackEvent("OneOf Selected", {
3640
3786
  oneOfId: this.analyticsId,
@@ -5396,16 +5542,13 @@ var createReviewComponent = (reviewProps) => __spreadProps(__spreadValues({
5396
5542
  // src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
5397
5543
  var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onBehavior, step }) => createReviewComponent({
5398
5544
  uid,
5399
- callToAction: getReviewAction({ onBehavior, callToAction, action, stepActions: step.actions }),
5545
+ callToAction: getCallToAction2({ onBehavior, callToAction, action, stepActions: step.actions }),
5400
5546
  control: getOrientationControl({ control, orientation }),
5401
- fields: fields.map((field) => {
5402
- var _a;
5403
- return __spreadProps(__spreadValues({}, field), { help: (_a = field.help) == null ? void 0 : _a.markdown });
5404
- }),
5547
+ fields: fields.map((field) => mapReviewField(field, { onBehavior, step })),
5405
5548
  margin,
5406
5549
  title
5407
5550
  });
5408
- var getReviewAction = ({
5551
+ var getCallToAction2 = ({
5409
5552
  onBehavior,
5410
5553
  callToAction,
5411
5554
  action,
@@ -5416,6 +5559,7 @@ var getReviewAction = ({
5416
5559
  }
5417
5560
  if (action == null ? void 0 : action.title) {
5418
5561
  return {
5562
+ type: "action",
5419
5563
  title: action.title,
5420
5564
  onClick: () => {
5421
5565
  void onBehavior({ type: "action", action });
@@ -5436,6 +5580,20 @@ var getOrientationControl = ({
5436
5580
  }
5437
5581
  return void 0;
5438
5582
  };
5583
+ var mapReviewField = (field, { onBehavior, step }) => {
5584
+ var _a, _b;
5585
+ return __spreadProps(__spreadValues({}, field), {
5586
+ image: mapSpecImage(field.image),
5587
+ help: (_a = field.help) == null ? void 0 : _a.markdown,
5588
+ inlineAlert: mapInlineAlert(field.inlineAlert),
5589
+ additionalInfo: mapAdditionalInfo(field.additionalInfo, onBehavior),
5590
+ callToAction: getCallToAction2({
5591
+ onBehavior,
5592
+ callToAction: field.callToAction,
5593
+ stepActions: (_b = step.actions) != null ? _b : []
5594
+ })
5595
+ });
5596
+ };
5439
5597
 
5440
5598
  // src/revamp/domain/components/searchComponent/SearchComponent.ts
5441
5599
  var DEBOUNCE_TIME = 400;
@@ -5655,14 +5813,30 @@ var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md",
5655
5813
  return createListComponent({
5656
5814
  uid,
5657
5815
  control,
5658
- items: items.map((item) => __spreadProps(__spreadValues({}, item), {
5659
- image: mapSpecImage(item.image)
5660
- })),
5816
+ items: items.map((item) => mapItem2(item, mapperProps)),
5661
5817
  callToAction: getDomainLayerCallToAction(callToAction, onBehavior, (_a = step.actions) != null ? _a : []),
5662
5818
  margin,
5663
5819
  title
5664
5820
  });
5665
5821
  };
5822
+ var mapItem2 = (item, mapperProps) => {
5823
+ var _b;
5824
+ const _a = item, { value, subvalue, subtitle } = _a, rest = __objRest(_a, ["value", "subvalue", "subtitle"]);
5825
+ return __spreadProps(__spreadValues({}, rest), {
5826
+ description: (_b = item.description) != null ? _b : subtitle,
5827
+ image: mapSpecImage(item.image),
5828
+ supportingValues: mapSupportingValues(item),
5829
+ additionalInfo: mapAdditionalInfo(item.additionalInfo, mapperProps.onBehavior),
5830
+ inlineAlert: mapInlineAlert(item.inlineAlert)
5831
+ });
5832
+ };
5833
+ var mapSupportingValues = (item) => {
5834
+ const { value, subvalue, supportingValues } = item;
5835
+ if (supportingValues) {
5836
+ return supportingValues;
5837
+ }
5838
+ return value || subvalue ? { value, subvalue } : void 0;
5839
+ };
5666
5840
 
5667
5841
  // src/revamp/domain/mappers/mapLayoutToComponent.ts
5668
5842
  var mapLayoutToComponent = (uid, layout, mapperProps) => {
@@ -5797,6 +5971,7 @@ var mapStepToComponent = (_a) => {
5797
5971
  const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
5798
5972
  const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onBehavior, onPoll }) : void 0;
5799
5973
  const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
5974
+ const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
5800
5975
  const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
5801
5976
  const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
5802
5977
  const layoutComponents = layout.map(
@@ -5810,7 +5985,7 @@ var mapStepToComponent = (_a) => {
5810
5985
  control,
5811
5986
  description,
5812
5987
  error: errors == null ? void 0 : errors.error,
5813
- external,
5988
+ externalConfirmation,
5814
5989
  loadingState,
5815
5990
  stepPolling,
5816
5991
  stepRefreshAfter,
@@ -5824,7 +5999,7 @@ var mapStepToComponent = (_a) => {
5824
5999
  };
5825
6000
 
5826
6001
  // src/revamp/flow/getResponseType.ts
5827
- var responseTypes = ["step", "action", "exit"];
6002
+ var responseTypes = ["step", "action", "exit", "modal"];
5828
6003
  var getResponseType = async (response) => {
5829
6004
  assertResponseIsValid(response);
5830
6005
  const headerResponseType = getResponseTypeFromHeader(response);
@@ -5852,7 +6027,7 @@ var getResponseTypeFromHeader = (response) => {
5852
6027
  function assertDFResponseType(type) {
5853
6028
  if (!responseTypes.includes(type)) {
5854
6029
  throw new Error(
5855
- "Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
6030
+ "Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
5856
6031
  );
5857
6032
  }
5858
6033
  }
@@ -6007,6 +6182,10 @@ var executeSubmission = async (props) => {
6007
6182
  trackSubmissionEvent("Action Succeeded", { actionId });
6008
6183
  return await triggerAction(body.action, null, false);
6009
6184
  }
6185
+ case "modal": {
6186
+ assertModalResponseBody(body);
6187
+ return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
6188
+ }
6010
6189
  default: {
6011
6190
  throw new Error(`Unsupported response type: ${String(responseType)}`);
6012
6191
  }
@@ -6251,6 +6430,55 @@ function useStableCallback(handler) {
6251
6430
  return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
6252
6431
  }
6253
6432
 
6433
+ // src/revamp/domain/components/ModalContentComponent.ts
6434
+ var createModalContentComponent = (modalProps, updateComponent) => {
6435
+ const update = getInputUpdateFunction(updateComponent);
6436
+ const modalContentComponent = __spreadProps(__spreadValues({
6437
+ type: "modal-content",
6438
+ open: true
6439
+ }, modalProps), {
6440
+ _update(updateFn) {
6441
+ update(this, updateFn);
6442
+ },
6443
+ getChildren() {
6444
+ return this.components;
6445
+ },
6446
+ getLocalValue() {
6447
+ return getLocalValues(this.getChildren());
6448
+ },
6449
+ async getSubmittableValue() {
6450
+ return getSubmittableData(this.getChildren());
6451
+ },
6452
+ getSubmittableValueSync() {
6453
+ return getSubmittableDataSync(this.getChildren());
6454
+ },
6455
+ getSummary() {
6456
+ return summariseFromChildren(this.getChildren());
6457
+ },
6458
+ validate() {
6459
+ return validateComponents(this.getChildren());
6460
+ },
6461
+ close() {
6462
+ update(this, (draft) => {
6463
+ draft.open = false;
6464
+ });
6465
+ }
6466
+ });
6467
+ return modalContentComponent;
6468
+ };
6469
+
6470
+ // src/revamp/domain/mappers/layout/modalToContent.ts
6471
+ var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
6472
+ {
6473
+ uid: `${uid}-modal-${getRandomId()}`,
6474
+ title,
6475
+ components: content.map(
6476
+ (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
6477
+ )
6478
+ },
6479
+ mapperProps.updateComponent
6480
+ );
6481
+
6254
6482
  // src/revamp/useDynamicFlowCore.tsx
6255
6483
  function useDynamicFlowCore(props) {
6256
6484
  const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
@@ -6300,6 +6528,20 @@ function useDynamicFlowCore(props) {
6300
6528
  var _a2;
6301
6529
  initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
6302
6530
  }, []);
6531
+ const getMapperProps = () => ({
6532
+ uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
6533
+ displayStepTitle,
6534
+ loadingState: "idle",
6535
+ updateComponent: () => rerender(),
6536
+ getErrorMessageFunctions,
6537
+ trackEvent,
6538
+ logEvent,
6539
+ httpClient,
6540
+ onBehavior,
6541
+ onRefresh,
6542
+ onPoll,
6543
+ onValueChange
6544
+ });
6303
6545
  const initialiseWithStep = useCallback2(
6304
6546
  (newStep, etag, localValue) => {
6305
6547
  rootComponentRef.current.stop();
@@ -6312,24 +6554,11 @@ function useDynamicFlowCore(props) {
6312
6554
  });
6313
6555
  }
6314
6556
  try {
6315
- rootComponentRef.current.setStep(
6316
- mapStepToComponent({
6317
- uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
6318
- stepLocalValue: localValue,
6319
- step: newStep,
6320
- displayStepTitle,
6321
- loadingState: "idle",
6322
- updateComponent: () => rerender(),
6323
- getErrorMessageFunctions,
6324
- trackEvent,
6325
- logEvent,
6326
- httpClient,
6327
- onBehavior,
6328
- onRefresh,
6329
- onPoll,
6330
- onValueChange
6331
- })
6332
- );
6557
+ const newStepComponent = mapStepToComponent(__spreadValues({
6558
+ stepLocalValue: localValue,
6559
+ step: newStep
6560
+ }, getMapperProps()));
6561
+ rootComponentRef.current.setStep(newStepComponent);
6333
6562
  } catch (error) {
6334
6563
  closeWithError(error);
6335
6564
  }
@@ -6381,6 +6610,7 @@ function useDynamicFlowCore(props) {
6381
6610
  const onBehavior = useCallback2(async (behavior) => {
6382
6611
  switch (behavior.type) {
6383
6612
  case "action": {
6613
+ rootComponentRef.current.dismissAllModals();
6384
6614
  try {
6385
6615
  const { action } = behavior;
6386
6616
  await rootComponentRef.current.getSubmittableValue();
@@ -6400,10 +6630,20 @@ function useDynamicFlowCore(props) {
6400
6630
  onLink(behavior.url);
6401
6631
  break;
6402
6632
  }
6403
- // case 'modal':
6404
- // return undefined;
6405
- // case 'dismiss':
6406
- // return undefined;
6633
+ case "modal":
6634
+ if (stepRef.current) {
6635
+ rootComponentRef.current.showModal(
6636
+ modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
6637
+ step: stepRef.current,
6638
+ stepLocalValue: rootComponentRef.current.getLocalValue()
6639
+ }, getMapperProps()))
6640
+ );
6641
+ }
6642
+ rootComponentRef.current.setLoadingState("idle");
6643
+ break;
6644
+ case "dismiss":
6645
+ rootComponentRef.current.dismissModal();
6646
+ break;
6407
6647
  case "none":
6408
6648
  break;
6409
6649
  }
@@ -6468,6 +6708,11 @@ function useDynamicFlowCore(props) {
6468
6708
  void onRefresh(void 0, refreshUrl, errors);
6469
6709
  break;
6470
6710
  }
6711
+ case "behavior": {
6712
+ void onBehavior(command.behavior);
6713
+ rootComponentRef.current.setLoadingState("idle");
6714
+ break;
6715
+ }
6471
6716
  }
6472
6717
  } catch (error) {
6473
6718
  closeWithError(error);
@@ -11508,7 +11753,7 @@ var getDefinitionListLayout = (review) => {
11508
11753
  function DynamicReview({ component: review, onAction }) {
11509
11754
  var _a, _b;
11510
11755
  const margin = getMargin(review.margin || "xs");
11511
- const getReviewAction2 = (callToAction2) => {
11756
+ const getReviewAction = (callToAction2) => {
11512
11757
  const { title, action, behavior } = callToAction2;
11513
11758
  if (behavior) {
11514
11759
  if ("type" in behavior) {
@@ -11556,7 +11801,7 @@ function DynamicReview({ component: review, onAction }) {
11556
11801
  };
11557
11802
  };
11558
11803
  const orientation = getDefinitionListLayout(review);
11559
- const callToAction = review.callToAction ? getReviewAction2(review.callToAction) : null;
11804
+ const callToAction = review.callToAction ? getReviewAction(review.callToAction) : null;
11560
11805
  const legacyCallToAction = !callToAction && review.action ? { text: (_a = review.action.title) != null ? _a : "", onClick: getOnClick(review.action) } : null;
11561
11806
  return /* @__PURE__ */ jsxs19("div", { className: margin, children: [
11562
11807
  review.title && /* @__PURE__ */ jsx57(Header8, { title: review.title, action: (_b = callToAction != null ? callToAction : legacyCallToAction) != null ? _b : void 0 }),