@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.
- package/build/main.js +351 -106
- package/build/main.mjs +351 -106
- package/build/types/revamp/domain/components/AlertComponent.d.ts +2 -14
- package/build/types/revamp/domain/components/DecisionComponent.d.ts +4 -1
- package/build/types/revamp/domain/components/ListComponent.d.ts +7 -19
- package/build/types/revamp/domain/components/ModalContentComponent.d.ts +11 -0
- package/build/types/revamp/domain/components/ReviewComponent.d.ts +8 -8
- package/build/types/revamp/domain/components/RootDomainComponent.d.ts +5 -1
- package/build/types/revamp/domain/components/step/ExternalConfirmationComponent.d.ts +12 -0
- package/build/types/revamp/domain/components/{StepDomainComponent.d.ts → step/StepDomainComponent.d.ts} +13 -6
- package/build/types/revamp/domain/mappers/layout/modalToContent.d.ts +4 -0
- package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/utils/call-to-action-utils.d.ts +1 -13
- package/build/types/revamp/domain/mappers/utils/legacy-utils.d.ts +3 -3
- package/build/types/revamp/domain/mappers/utils/utils.d.ts +4 -0
- package/build/types/revamp/domain/types.d.ts +31 -6
- package/build/types/revamp/flow/executeSubmission.d.ts +4 -0
- package/build/types/revamp/flow/getResponseType.d.ts +1 -1
- package/build/types/revamp/flow/response-utils.d.ts +2 -1
- package/build/types/revamp/renderers/mappers/externalComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/mappers/modalContentComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +2 -2
- package/package.json +9 -9
package/build/main.js
CHANGED
|
@@ -1084,6 +1084,7 @@ function getChildren(node) {
|
|
|
1084
1084
|
case "form":
|
|
1085
1085
|
case "section":
|
|
1086
1086
|
case "step":
|
|
1087
|
+
case "modal-content":
|
|
1087
1088
|
return node.childrenProps;
|
|
1088
1089
|
case "columns":
|
|
1089
1090
|
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
@@ -1116,6 +1117,7 @@ function getChildren(node) {
|
|
|
1116
1117
|
case "status-list":
|
|
1117
1118
|
case "input-text":
|
|
1118
1119
|
case "input-upload":
|
|
1120
|
+
case "external-confirmation":
|
|
1119
1121
|
return [];
|
|
1120
1122
|
}
|
|
1121
1123
|
}
|
|
@@ -1538,7 +1540,10 @@ var repeatableComponentToProps = (component, rendererMapperProps) => {
|
|
|
1538
1540
|
};
|
|
1539
1541
|
|
|
1540
1542
|
// src/revamp/renderers/mappers/reviewComponentToProps.ts
|
|
1541
|
-
var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "
|
|
1543
|
+
var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadProps(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), {
|
|
1544
|
+
fields: component.fields.map(mapField)
|
|
1545
|
+
}), rendererMapperProps);
|
|
1546
|
+
var mapField = (field) => __spreadValues({}, field);
|
|
1542
1547
|
|
|
1543
1548
|
// src/revamp/domain/mappers/utils/image.ts
|
|
1544
1549
|
var mapSpecImage = (image) => {
|
|
@@ -1674,27 +1679,32 @@ var tupleComponentToProps = (component, rendererMapperProps) => {
|
|
|
1674
1679
|
|
|
1675
1680
|
// src/revamp/renderers/mappers/listComponentToProps.ts
|
|
1676
1681
|
var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
|
|
1677
|
-
items: component.items.map(
|
|
1678
|
-
var item = __objRest(_a, []);
|
|
1679
|
-
return __spreadValues({}, item);
|
|
1680
|
-
})
|
|
1682
|
+
items: component.items.map(mapItem)
|
|
1681
1683
|
});
|
|
1684
|
+
var mapItem = (item) => {
|
|
1685
|
+
var _a, _b;
|
|
1686
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1687
|
+
// populate deprecated fields
|
|
1688
|
+
subtitle: item.description,
|
|
1689
|
+
value: (_a = item.supportingValues) == null ? void 0 : _a.value,
|
|
1690
|
+
subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
|
|
1691
|
+
});
|
|
1692
|
+
};
|
|
1682
1693
|
|
|
1683
1694
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
1684
|
-
var stepComponentToProps = ({
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
const childrenProps = components.map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1695
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1696
|
+
const {
|
|
1697
|
+
uid,
|
|
1698
|
+
back,
|
|
1699
|
+
control,
|
|
1700
|
+
description,
|
|
1701
|
+
error,
|
|
1702
|
+
loadingState,
|
|
1703
|
+
step,
|
|
1704
|
+
title,
|
|
1705
|
+
onBehavior
|
|
1706
|
+
} = component;
|
|
1707
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1698
1708
|
return __spreadValues({
|
|
1699
1709
|
type: "step",
|
|
1700
1710
|
id: step.id,
|
|
@@ -1703,7 +1713,6 @@ var stepComponentToProps = ({
|
|
|
1703
1713
|
control,
|
|
1704
1714
|
description,
|
|
1705
1715
|
error,
|
|
1706
|
-
external,
|
|
1707
1716
|
loadingState,
|
|
1708
1717
|
step,
|
|
1709
1718
|
title,
|
|
@@ -1718,12 +1727,40 @@ var stepComponentToProps = ({
|
|
|
1718
1727
|
// src/revamp/renderers/mappers/rootComponentToProps.ts
|
|
1719
1728
|
var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
1720
1729
|
const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
|
|
1721
|
-
return {
|
|
1730
|
+
return __spreadValues({
|
|
1722
1731
|
type: "root",
|
|
1723
1732
|
uid: rootComponent.uid,
|
|
1724
1733
|
children: childrenProps.map(rendererMapperProps.render),
|
|
1725
1734
|
childrenProps
|
|
1726
|
-
};
|
|
1735
|
+
}, rendererMapperProps);
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1738
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1739
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1740
|
+
const { uid, open, title, close } = component;
|
|
1741
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1742
|
+
return __spreadValues({
|
|
1743
|
+
uid,
|
|
1744
|
+
type: "modal-content",
|
|
1745
|
+
open,
|
|
1746
|
+
title,
|
|
1747
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1748
|
+
childrenProps,
|
|
1749
|
+
onClose: close.bind(component)
|
|
1750
|
+
}, rendererMapperProps);
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1753
|
+
// src/revamp/renderers/mappers/externalComponentToProps.ts
|
|
1754
|
+
var externalComponentToProps = (component, rendererMapperProps) => {
|
|
1755
|
+
return __spreadValues({
|
|
1756
|
+
type: "external-confirmation",
|
|
1757
|
+
uid: component.uid,
|
|
1758
|
+
url: component.url,
|
|
1759
|
+
status: component.status,
|
|
1760
|
+
onSuccess: component.onSuccess.bind(component),
|
|
1761
|
+
onFailure: component.onFailure.bind(component),
|
|
1762
|
+
onCancel: component.onCancel.bind(component)
|
|
1763
|
+
}, rendererMapperProps);
|
|
1727
1764
|
};
|
|
1728
1765
|
|
|
1729
1766
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
@@ -1756,6 +1793,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1756
1793
|
return decisionComponentToProps(component, rendererMapperProps);
|
|
1757
1794
|
case "divider":
|
|
1758
1795
|
return dividerComponentToProps(component, rendererMapperProps);
|
|
1796
|
+
case "external-confirmation":
|
|
1797
|
+
return externalComponentToProps(component, rendererMapperProps);
|
|
1759
1798
|
case "form":
|
|
1760
1799
|
return formComponentToProps(component, rendererMapperProps);
|
|
1761
1800
|
case "heading":
|
|
@@ -1776,6 +1815,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1776
1815
|
return markdownComponentToProps(component, rendererMapperProps);
|
|
1777
1816
|
case "modal":
|
|
1778
1817
|
return modalComponentToProps(component, rendererMapperProps);
|
|
1818
|
+
case "modal-content":
|
|
1819
|
+
return modalContentComponentToProps(component, rendererMapperProps);
|
|
1779
1820
|
case "multi-select":
|
|
1780
1821
|
return multiSelectInputComponentToProps(component, rendererMapperProps);
|
|
1781
1822
|
case "multi-upload":
|
|
@@ -1820,6 +1861,37 @@ var getInputUpdateFunction = (updateComponent) => {
|
|
|
1820
1861
|
};
|
|
1821
1862
|
};
|
|
1822
1863
|
|
|
1864
|
+
// src/revamp/utils/component-utils.ts
|
|
1865
|
+
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1866
|
+
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
1867
|
+
);
|
|
1868
|
+
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
1869
|
+
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
1870
|
+
var mergeLocalValues = (valueA, valueB) => {
|
|
1871
|
+
if (valueA === null) {
|
|
1872
|
+
return valueB;
|
|
1873
|
+
}
|
|
1874
|
+
if (valueB === null) {
|
|
1875
|
+
return valueA;
|
|
1876
|
+
}
|
|
1877
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
1878
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1879
|
+
}
|
|
1880
|
+
return valueB;
|
|
1881
|
+
};
|
|
1882
|
+
var mergeModels = (valueA, valueB) => {
|
|
1883
|
+
if (valueA === null) {
|
|
1884
|
+
return valueB;
|
|
1885
|
+
}
|
|
1886
|
+
if (valueB === null) {
|
|
1887
|
+
return valueA;
|
|
1888
|
+
}
|
|
1889
|
+
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
1890
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1891
|
+
}
|
|
1892
|
+
return valueB;
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1823
1895
|
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1824
1896
|
var createRootDomainComponent = (updateComponent) => {
|
|
1825
1897
|
const update = getInputUpdateFunction(updateComponent);
|
|
@@ -1830,17 +1902,29 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1830
1902
|
_update(updateFn) {
|
|
1831
1903
|
update(this, updateFn);
|
|
1832
1904
|
},
|
|
1905
|
+
dismissAllModals() {
|
|
1906
|
+
var _a;
|
|
1907
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
|
|
1908
|
+
},
|
|
1909
|
+
dismissModal() {
|
|
1910
|
+
var _a;
|
|
1911
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
|
|
1912
|
+
},
|
|
1913
|
+
showModal(modal) {
|
|
1914
|
+
var _a;
|
|
1915
|
+
(_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
|
|
1916
|
+
},
|
|
1833
1917
|
getChildren() {
|
|
1834
|
-
return this.stepComponent ? [this.stepComponent] : [];
|
|
1918
|
+
return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
|
|
1835
1919
|
},
|
|
1836
1920
|
getLocalValue() {
|
|
1837
1921
|
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1838
1922
|
},
|
|
1839
1923
|
async getSubmittableValue() {
|
|
1840
|
-
return this.stepComponent ? this.stepComponent.
|
|
1924
|
+
return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1841
1925
|
},
|
|
1842
1926
|
getSubmittableValueSync() {
|
|
1843
|
-
return this.stepComponent ? this.stepComponent.
|
|
1927
|
+
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1844
1928
|
},
|
|
1845
1929
|
getSummary() {
|
|
1846
1930
|
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
@@ -1874,35 +1958,38 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1874
1958
|
return rootComponent;
|
|
1875
1959
|
};
|
|
1876
1960
|
|
|
1877
|
-
// src/revamp/
|
|
1878
|
-
var
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
};
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1961
|
+
// src/revamp/domain/components/step/ExternalConfirmationComponent.ts
|
|
1962
|
+
var createExternalConfirmation = (uid, url, updateComponent) => {
|
|
1963
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1964
|
+
return {
|
|
1965
|
+
type: "external-confirmation",
|
|
1966
|
+
uid,
|
|
1967
|
+
url,
|
|
1968
|
+
status: "initial",
|
|
1969
|
+
onSuccess() {
|
|
1970
|
+
update(this, (draft) => {
|
|
1971
|
+
draft.status = "success";
|
|
1972
|
+
});
|
|
1973
|
+
},
|
|
1974
|
+
onFailure() {
|
|
1975
|
+
if (this.status === "initial") {
|
|
1976
|
+
update(this, (draft) => {
|
|
1977
|
+
draft.status = "failure";
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
},
|
|
1981
|
+
onCancel() {
|
|
1982
|
+
update(this, (draft) => {
|
|
1983
|
+
draft.status = "dismissed";
|
|
1984
|
+
});
|
|
1985
|
+
},
|
|
1986
|
+
getSubmittableValue: async () => null,
|
|
1987
|
+
getSubmittableValueSync: () => null,
|
|
1988
|
+
getLocalValue: () => null,
|
|
1989
|
+
getSummary: () => ({}),
|
|
1990
|
+
// Noop
|
|
1991
|
+
validate: () => true
|
|
1992
|
+
};
|
|
1906
1993
|
};
|
|
1907
1994
|
|
|
1908
1995
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
@@ -1945,7 +2032,7 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
|
1945
2032
|
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
1946
2033
|
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
1947
2034
|
|
|
1948
|
-
// src/revamp/domain/components/StepDomainComponent.ts
|
|
2035
|
+
// src/revamp/domain/components/step/StepDomainComponent.ts
|
|
1949
2036
|
var createStepComponent = (stepProps) => {
|
|
1950
2037
|
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
1951
2038
|
const update = getInputUpdateFunction(updateComponent);
|
|
@@ -1953,11 +2040,29 @@ var createStepComponent = (stepProps) => {
|
|
|
1953
2040
|
uid
|
|
1954
2041
|
}, rest), {
|
|
1955
2042
|
type: "step",
|
|
2043
|
+
modals: [],
|
|
2044
|
+
dismissModal() {
|
|
2045
|
+
var _a2;
|
|
2046
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
2047
|
+
},
|
|
2048
|
+
dismissAllModals() {
|
|
2049
|
+
this._update((draft) => {
|
|
2050
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
2051
|
+
});
|
|
2052
|
+
},
|
|
2053
|
+
showModal(modal) {
|
|
2054
|
+
this._update((draft) => {
|
|
2055
|
+
draft.modals = [...draft.modals, modal];
|
|
2056
|
+
});
|
|
2057
|
+
},
|
|
1956
2058
|
_update(updateFn) {
|
|
1957
2059
|
update(this, updateFn);
|
|
1958
2060
|
},
|
|
1959
2061
|
getChildren() {
|
|
1960
|
-
return this.components;
|
|
2062
|
+
return this.externalConfirmation ? [...this.components, this.externalConfirmation] : this.components;
|
|
2063
|
+
},
|
|
2064
|
+
getModals() {
|
|
2065
|
+
return this.modals;
|
|
1961
2066
|
},
|
|
1962
2067
|
async getSubmittableValue() {
|
|
1963
2068
|
return getSubmittableData(this.components);
|
|
@@ -1982,6 +2087,9 @@ var createStepComponent = (stepProps) => {
|
|
|
1982
2087
|
stop() {
|
|
1983
2088
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
1984
2089
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
2090
|
+
this._update((draft) => {
|
|
2091
|
+
draft.modals = [];
|
|
2092
|
+
});
|
|
1985
2093
|
}
|
|
1986
2094
|
});
|
|
1987
2095
|
return component;
|
|
@@ -2110,9 +2218,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2110
2218
|
void onBehavior(behavior);
|
|
2111
2219
|
};
|
|
2112
2220
|
switch (behavior.type) {
|
|
2113
|
-
case "action":
|
|
2221
|
+
case "action":
|
|
2222
|
+
case "modal":
|
|
2223
|
+
case "dismiss": {
|
|
2114
2224
|
return {
|
|
2115
|
-
type:
|
|
2225
|
+
type: behavior.type,
|
|
2116
2226
|
title: title != null ? title : "",
|
|
2117
2227
|
accessibilityDescription,
|
|
2118
2228
|
onClick
|
|
@@ -2368,6 +2478,27 @@ var createDecisionComponent = (decisionProps) => __spreadProps(__spreadValues({
|
|
|
2368
2478
|
validate: () => true
|
|
2369
2479
|
});
|
|
2370
2480
|
|
|
2481
|
+
// src/revamp/domain/mappers/utils/utils.ts
|
|
2482
|
+
var mapInlineAlert = (alert) => {
|
|
2483
|
+
return alert ? {
|
|
2484
|
+
content: alert.content,
|
|
2485
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
2486
|
+
} : void 0;
|
|
2487
|
+
};
|
|
2488
|
+
var mapAdditionalInfo = (info, onBehavior) => {
|
|
2489
|
+
if (info) {
|
|
2490
|
+
const behavior = getDomainLayerBehavior(info, []);
|
|
2491
|
+
return {
|
|
2492
|
+
text: info.text,
|
|
2493
|
+
accessibilityDescription: info.accessibilityDescription,
|
|
2494
|
+
onClick: () => {
|
|
2495
|
+
void onBehavior(behavior);
|
|
2496
|
+
}
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
return void 0;
|
|
2500
|
+
};
|
|
2501
|
+
|
|
2371
2502
|
// src/revamp/domain/mappers/layout/decisionLayoutToComponent.ts
|
|
2372
2503
|
var decisionLayoutToComponent = (uid, {
|
|
2373
2504
|
control,
|
|
@@ -2378,20 +2509,22 @@ var decisionLayoutToComponent = (uid, {
|
|
|
2378
2509
|
uid,
|
|
2379
2510
|
control,
|
|
2380
2511
|
margin,
|
|
2381
|
-
options: options.map((option) =>
|
|
2382
|
-
var _a, _b;
|
|
2383
|
-
const behavior = getDomainLayerBehavior(option, (_a = step.actions) != null ? _a : []);
|
|
2384
|
-
return __spreadProps(__spreadValues({}, option), {
|
|
2385
|
-
disabled: (_b = option.disabled) != null ? _b : false,
|
|
2386
|
-
href: behavior.type === "link" ? behavior.url : void 0,
|
|
2387
|
-
image: mapSpecImage(option.image),
|
|
2388
|
-
onClick: () => {
|
|
2389
|
-
void onBehavior(behavior);
|
|
2390
|
-
}
|
|
2391
|
-
});
|
|
2392
|
-
}),
|
|
2512
|
+
options: options.map((option) => mapOption(option, onBehavior, step.actions)),
|
|
2393
2513
|
title
|
|
2394
2514
|
});
|
|
2515
|
+
var mapOption = (option, onBehavior, stepActions = []) => {
|
|
2516
|
+
var _a;
|
|
2517
|
+
const behavior = getDomainLayerBehavior(option, stepActions);
|
|
2518
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
2519
|
+
disabled: (_a = option.disabled) != null ? _a : false,
|
|
2520
|
+
href: behavior.type === "link" ? behavior.url : void 0,
|
|
2521
|
+
image: mapSpecImage(option.image),
|
|
2522
|
+
inlineAlert: mapInlineAlert(option.inlineAlert),
|
|
2523
|
+
onClick: () => {
|
|
2524
|
+
void onBehavior(behavior);
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
};
|
|
2395
2528
|
|
|
2396
2529
|
// src/revamp/domain/components/DividerComponent.ts
|
|
2397
2530
|
var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
@@ -3000,6 +3133,16 @@ function assertActionResponseBody(body) {
|
|
|
3000
3133
|
);
|
|
3001
3134
|
}
|
|
3002
3135
|
}
|
|
3136
|
+
function assertModalResponseBody(body) {
|
|
3137
|
+
if (isObject(body)) {
|
|
3138
|
+
if ("content" in body && isArray(body.content)) {
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
throw new Error(
|
|
3143
|
+
"Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3003
3146
|
function isErrorResponseBody(body) {
|
|
3004
3147
|
return Boolean(
|
|
3005
3148
|
isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
@@ -3678,6 +3821,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3678
3821
|
},
|
|
3679
3822
|
// noop
|
|
3680
3823
|
onSelect(updatedIndex) {
|
|
3824
|
+
if (updatedIndex === this.selectedIndex) {
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3681
3827
|
if (updatedIndex !== null && this.analyticsId) {
|
|
3682
3828
|
selectProps.trackEvent("OneOf Selected", {
|
|
3683
3829
|
oneOfId: this.analyticsId,
|
|
@@ -5439,16 +5585,13 @@ var createReviewComponent = (reviewProps) => __spreadProps(__spreadValues({
|
|
|
5439
5585
|
// src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
|
|
5440
5586
|
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onBehavior, step }) => createReviewComponent({
|
|
5441
5587
|
uid,
|
|
5442
|
-
callToAction:
|
|
5588
|
+
callToAction: getCallToAction2({ onBehavior, callToAction, action, stepActions: step.actions }),
|
|
5443
5589
|
control: getOrientationControl({ control, orientation }),
|
|
5444
|
-
fields: fields.map((field) => {
|
|
5445
|
-
var _a;
|
|
5446
|
-
return __spreadProps(__spreadValues({}, field), { help: (_a = field.help) == null ? void 0 : _a.markdown });
|
|
5447
|
-
}),
|
|
5590
|
+
fields: fields.map((field) => mapReviewField(field, { onBehavior, step })),
|
|
5448
5591
|
margin,
|
|
5449
5592
|
title
|
|
5450
5593
|
});
|
|
5451
|
-
var
|
|
5594
|
+
var getCallToAction2 = ({
|
|
5452
5595
|
onBehavior,
|
|
5453
5596
|
callToAction,
|
|
5454
5597
|
action,
|
|
@@ -5459,6 +5602,7 @@ var getReviewAction = ({
|
|
|
5459
5602
|
}
|
|
5460
5603
|
if (action == null ? void 0 : action.title) {
|
|
5461
5604
|
return {
|
|
5605
|
+
type: "action",
|
|
5462
5606
|
title: action.title,
|
|
5463
5607
|
onClick: () => {
|
|
5464
5608
|
void onBehavior({ type: "action", action });
|
|
@@ -5479,6 +5623,20 @@ var getOrientationControl = ({
|
|
|
5479
5623
|
}
|
|
5480
5624
|
return void 0;
|
|
5481
5625
|
};
|
|
5626
|
+
var mapReviewField = (field, { onBehavior, step }) => {
|
|
5627
|
+
var _a, _b;
|
|
5628
|
+
return __spreadProps(__spreadValues({}, field), {
|
|
5629
|
+
image: mapSpecImage(field.image),
|
|
5630
|
+
help: (_a = field.help) == null ? void 0 : _a.markdown,
|
|
5631
|
+
inlineAlert: mapInlineAlert(field.inlineAlert),
|
|
5632
|
+
additionalInfo: mapAdditionalInfo(field.additionalInfo, onBehavior),
|
|
5633
|
+
callToAction: getCallToAction2({
|
|
5634
|
+
onBehavior,
|
|
5635
|
+
callToAction: field.callToAction,
|
|
5636
|
+
stepActions: (_b = step.actions) != null ? _b : []
|
|
5637
|
+
})
|
|
5638
|
+
});
|
|
5639
|
+
};
|
|
5482
5640
|
|
|
5483
5641
|
// src/revamp/domain/components/searchComponent/SearchComponent.ts
|
|
5484
5642
|
var DEBOUNCE_TIME = 400;
|
|
@@ -5698,14 +5856,30 @@ var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md",
|
|
|
5698
5856
|
return createListComponent({
|
|
5699
5857
|
uid,
|
|
5700
5858
|
control,
|
|
5701
|
-
items: items.map((item) =>
|
|
5702
|
-
image: mapSpecImage(item.image)
|
|
5703
|
-
})),
|
|
5859
|
+
items: items.map((item) => mapItem2(item, mapperProps)),
|
|
5704
5860
|
callToAction: getDomainLayerCallToAction(callToAction, onBehavior, (_a = step.actions) != null ? _a : []),
|
|
5705
5861
|
margin,
|
|
5706
5862
|
title
|
|
5707
5863
|
});
|
|
5708
5864
|
};
|
|
5865
|
+
var mapItem2 = (item, mapperProps) => {
|
|
5866
|
+
var _b;
|
|
5867
|
+
const _a = item, { value, subvalue, subtitle } = _a, rest = __objRest(_a, ["value", "subvalue", "subtitle"]);
|
|
5868
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
5869
|
+
description: (_b = item.description) != null ? _b : subtitle,
|
|
5870
|
+
image: mapSpecImage(item.image),
|
|
5871
|
+
supportingValues: mapSupportingValues(item),
|
|
5872
|
+
additionalInfo: mapAdditionalInfo(item.additionalInfo, mapperProps.onBehavior),
|
|
5873
|
+
inlineAlert: mapInlineAlert(item.inlineAlert)
|
|
5874
|
+
});
|
|
5875
|
+
};
|
|
5876
|
+
var mapSupportingValues = (item) => {
|
|
5877
|
+
const { value, subvalue, supportingValues } = item;
|
|
5878
|
+
if (supportingValues) {
|
|
5879
|
+
return supportingValues;
|
|
5880
|
+
}
|
|
5881
|
+
return value || subvalue ? { value, subvalue } : void 0;
|
|
5882
|
+
};
|
|
5709
5883
|
|
|
5710
5884
|
// src/revamp/domain/mappers/mapLayoutToComponent.ts
|
|
5711
5885
|
var mapLayoutToComponent = (uid, layout, mapperProps) => {
|
|
@@ -5840,6 +6014,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5840
6014
|
const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
|
|
5841
6015
|
const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onBehavior, onPoll }) : void 0;
|
|
5842
6016
|
const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
|
|
6017
|
+
const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
|
|
5843
6018
|
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
|
|
5844
6019
|
const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
|
|
5845
6020
|
const layoutComponents = layout.map(
|
|
@@ -5853,7 +6028,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5853
6028
|
control,
|
|
5854
6029
|
description,
|
|
5855
6030
|
error: errors == null ? void 0 : errors.error,
|
|
5856
|
-
|
|
6031
|
+
externalConfirmation,
|
|
5857
6032
|
loadingState,
|
|
5858
6033
|
stepPolling,
|
|
5859
6034
|
stepRefreshAfter,
|
|
@@ -5867,7 +6042,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5867
6042
|
};
|
|
5868
6043
|
|
|
5869
6044
|
// src/revamp/flow/getResponseType.ts
|
|
5870
|
-
var responseTypes = ["step", "action", "exit"];
|
|
6045
|
+
var responseTypes = ["step", "action", "exit", "modal"];
|
|
5871
6046
|
var getResponseType = async (response) => {
|
|
5872
6047
|
assertResponseIsValid(response);
|
|
5873
6048
|
const headerResponseType = getResponseTypeFromHeader(response);
|
|
@@ -5895,7 +6070,7 @@ var getResponseTypeFromHeader = (response) => {
|
|
|
5895
6070
|
function assertDFResponseType(type) {
|
|
5896
6071
|
if (!responseTypes.includes(type)) {
|
|
5897
6072
|
throw new Error(
|
|
5898
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
6073
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
|
|
5899
6074
|
);
|
|
5900
6075
|
}
|
|
5901
6076
|
}
|
|
@@ -6050,6 +6225,10 @@ var executeSubmission = async (props) => {
|
|
|
6050
6225
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6051
6226
|
return await triggerAction(body.action, null, false);
|
|
6052
6227
|
}
|
|
6228
|
+
case "modal": {
|
|
6229
|
+
assertModalResponseBody(body);
|
|
6230
|
+
return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
|
|
6231
|
+
}
|
|
6053
6232
|
default: {
|
|
6054
6233
|
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
6055
6234
|
}
|
|
@@ -6294,6 +6473,55 @@ function useStableCallback(handler) {
|
|
|
6294
6473
|
return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6295
6474
|
}
|
|
6296
6475
|
|
|
6476
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6477
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6478
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
6479
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6480
|
+
type: "modal-content",
|
|
6481
|
+
open: true
|
|
6482
|
+
}, modalProps), {
|
|
6483
|
+
_update(updateFn) {
|
|
6484
|
+
update(this, updateFn);
|
|
6485
|
+
},
|
|
6486
|
+
getChildren() {
|
|
6487
|
+
return this.components;
|
|
6488
|
+
},
|
|
6489
|
+
getLocalValue() {
|
|
6490
|
+
return getLocalValues(this.getChildren());
|
|
6491
|
+
},
|
|
6492
|
+
async getSubmittableValue() {
|
|
6493
|
+
return getSubmittableData(this.getChildren());
|
|
6494
|
+
},
|
|
6495
|
+
getSubmittableValueSync() {
|
|
6496
|
+
return getSubmittableDataSync(this.getChildren());
|
|
6497
|
+
},
|
|
6498
|
+
getSummary() {
|
|
6499
|
+
return summariseFromChildren(this.getChildren());
|
|
6500
|
+
},
|
|
6501
|
+
validate() {
|
|
6502
|
+
return validateComponents(this.getChildren());
|
|
6503
|
+
},
|
|
6504
|
+
close() {
|
|
6505
|
+
update(this, (draft) => {
|
|
6506
|
+
draft.open = false;
|
|
6507
|
+
});
|
|
6508
|
+
}
|
|
6509
|
+
});
|
|
6510
|
+
return modalContentComponent;
|
|
6511
|
+
};
|
|
6512
|
+
|
|
6513
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6514
|
+
var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
|
|
6515
|
+
{
|
|
6516
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
6517
|
+
title,
|
|
6518
|
+
components: content.map(
|
|
6519
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
|
|
6520
|
+
)
|
|
6521
|
+
},
|
|
6522
|
+
mapperProps.updateComponent
|
|
6523
|
+
);
|
|
6524
|
+
|
|
6297
6525
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6298
6526
|
function useDynamicFlowCore(props) {
|
|
6299
6527
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6343,6 +6571,20 @@ function useDynamicFlowCore(props) {
|
|
|
6343
6571
|
var _a2;
|
|
6344
6572
|
initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
|
|
6345
6573
|
}, []);
|
|
6574
|
+
const getMapperProps = () => ({
|
|
6575
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6576
|
+
displayStepTitle,
|
|
6577
|
+
loadingState: "idle",
|
|
6578
|
+
updateComponent: () => rerender(),
|
|
6579
|
+
getErrorMessageFunctions,
|
|
6580
|
+
trackEvent,
|
|
6581
|
+
logEvent,
|
|
6582
|
+
httpClient,
|
|
6583
|
+
onBehavior,
|
|
6584
|
+
onRefresh,
|
|
6585
|
+
onPoll,
|
|
6586
|
+
onValueChange
|
|
6587
|
+
});
|
|
6346
6588
|
const initialiseWithStep = (0, import_react3.useCallback)(
|
|
6347
6589
|
(newStep, etag, localValue) => {
|
|
6348
6590
|
rootComponentRef.current.stop();
|
|
@@ -6355,24 +6597,11 @@ function useDynamicFlowCore(props) {
|
|
|
6355
6597
|
});
|
|
6356
6598
|
}
|
|
6357
6599
|
try {
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
displayStepTitle,
|
|
6364
|
-
loadingState: "idle",
|
|
6365
|
-
updateComponent: () => rerender(),
|
|
6366
|
-
getErrorMessageFunctions,
|
|
6367
|
-
trackEvent,
|
|
6368
|
-
logEvent,
|
|
6369
|
-
httpClient,
|
|
6370
|
-
onBehavior,
|
|
6371
|
-
onRefresh,
|
|
6372
|
-
onPoll,
|
|
6373
|
-
onValueChange
|
|
6374
|
-
})
|
|
6375
|
-
);
|
|
6600
|
+
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6601
|
+
stepLocalValue: localValue,
|
|
6602
|
+
step: newStep
|
|
6603
|
+
}, getMapperProps()));
|
|
6604
|
+
rootComponentRef.current.setStep(newStepComponent);
|
|
6376
6605
|
} catch (error) {
|
|
6377
6606
|
closeWithError(error);
|
|
6378
6607
|
}
|
|
@@ -6424,6 +6653,7 @@ function useDynamicFlowCore(props) {
|
|
|
6424
6653
|
const onBehavior = (0, import_react3.useCallback)(async (behavior) => {
|
|
6425
6654
|
switch (behavior.type) {
|
|
6426
6655
|
case "action": {
|
|
6656
|
+
rootComponentRef.current.dismissAllModals();
|
|
6427
6657
|
try {
|
|
6428
6658
|
const { action } = behavior;
|
|
6429
6659
|
await rootComponentRef.current.getSubmittableValue();
|
|
@@ -6443,10 +6673,20 @@ function useDynamicFlowCore(props) {
|
|
|
6443
6673
|
onLink(behavior.url);
|
|
6444
6674
|
break;
|
|
6445
6675
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6676
|
+
case "modal":
|
|
6677
|
+
if (stepRef.current) {
|
|
6678
|
+
rootComponentRef.current.showModal(
|
|
6679
|
+
modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
|
|
6680
|
+
step: stepRef.current,
|
|
6681
|
+
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6682
|
+
}, getMapperProps()))
|
|
6683
|
+
);
|
|
6684
|
+
}
|
|
6685
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6686
|
+
break;
|
|
6687
|
+
case "dismiss":
|
|
6688
|
+
rootComponentRef.current.dismissModal();
|
|
6689
|
+
break;
|
|
6450
6690
|
case "none":
|
|
6451
6691
|
break;
|
|
6452
6692
|
}
|
|
@@ -6511,6 +6751,11 @@ function useDynamicFlowCore(props) {
|
|
|
6511
6751
|
void onRefresh(void 0, refreshUrl, errors);
|
|
6512
6752
|
break;
|
|
6513
6753
|
}
|
|
6754
|
+
case "behavior": {
|
|
6755
|
+
void onBehavior(command.behavior);
|
|
6756
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6757
|
+
break;
|
|
6758
|
+
}
|
|
6514
6759
|
}
|
|
6515
6760
|
} catch (error) {
|
|
6516
6761
|
closeWithError(error);
|
|
@@ -11536,7 +11781,7 @@ var getDefinitionListLayout = (review) => {
|
|
|
11536
11781
|
function DynamicReview({ component: review, onAction }) {
|
|
11537
11782
|
var _a, _b;
|
|
11538
11783
|
const margin = getMargin(review.margin || "xs");
|
|
11539
|
-
const
|
|
11784
|
+
const getReviewAction = (callToAction2) => {
|
|
11540
11785
|
const { title, action, behavior } = callToAction2;
|
|
11541
11786
|
if (behavior) {
|
|
11542
11787
|
if ("type" in behavior) {
|
|
@@ -11584,7 +11829,7 @@ function DynamicReview({ component: review, onAction }) {
|
|
|
11584
11829
|
};
|
|
11585
11830
|
};
|
|
11586
11831
|
const orientation = getDefinitionListLayout(review);
|
|
11587
|
-
const callToAction = review.callToAction ?
|
|
11832
|
+
const callToAction = review.callToAction ? getReviewAction(review.callToAction) : null;
|
|
11588
11833
|
const legacyCallToAction = !callToAction && review.action ? { text: (_a = review.action.title) != null ? _a : "", onClick: getOnClick(review.action) } : null;
|
|
11589
11834
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: margin, children: [
|
|
11590
11835
|
review.title && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components30.Header, { title: review.title, action: (_b = callToAction != null ? callToAction : legacyCallToAction) != null ? _b : void 0 }),
|