@wise/dynamic-flow-client 4.3.14 → 4.4.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 +210 -74
- package/build/main.mjs +210 -74
- package/build/types/revamp/domain/components/AlertComponent.d.ts +2 -14
- package/build/types/revamp/domain/components/ListComponent.d.ts +3 -16
- package/build/types/revamp/domain/components/ModalContentComponent.d.ts +11 -0
- package/build/types/revamp/domain/components/RootDomainComponent.d.ts +4 -0
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +6 -0
- package/build/types/revamp/domain/mappers/layout/modalToContent.d.ts +4 -0
- package/build/types/revamp/domain/mappers/utils/call-to-action-utils.d.ts +1 -13
- package/build/types/revamp/domain/types.d.ts +16 -5
- 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/modalContentComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
- package/package.json +11 -11
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];
|
|
@@ -1681,20 +1682,20 @@ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__s
|
|
|
1681
1682
|
});
|
|
1682
1683
|
|
|
1683
1684
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
1684
|
-
var stepComponentToProps = ({
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
const childrenProps =
|
|
1685
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1686
|
+
const {
|
|
1687
|
+
uid,
|
|
1688
|
+
back,
|
|
1689
|
+
control,
|
|
1690
|
+
description,
|
|
1691
|
+
error,
|
|
1692
|
+
external,
|
|
1693
|
+
loadingState,
|
|
1694
|
+
step,
|
|
1695
|
+
title,
|
|
1696
|
+
onBehavior
|
|
1697
|
+
} = component;
|
|
1698
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1698
1699
|
return __spreadValues({
|
|
1699
1700
|
type: "step",
|
|
1700
1701
|
id: step.id,
|
|
@@ -1726,6 +1727,21 @@ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
|
1726
1727
|
};
|
|
1727
1728
|
};
|
|
1728
1729
|
|
|
1730
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1731
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1732
|
+
const { uid, open, title, close } = component;
|
|
1733
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1734
|
+
return __spreadValues({
|
|
1735
|
+
uid,
|
|
1736
|
+
type: "modal-content",
|
|
1737
|
+
open,
|
|
1738
|
+
title,
|
|
1739
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1740
|
+
childrenProps,
|
|
1741
|
+
onClose: close.bind(component)
|
|
1742
|
+
}, rendererMapperProps);
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1729
1745
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1730
1746
|
var componentToRendererProps = (component, rendererMapperProps) => {
|
|
1731
1747
|
if (isHiddenComponent(component)) {
|
|
@@ -1776,6 +1792,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1776
1792
|
return markdownComponentToProps(component, rendererMapperProps);
|
|
1777
1793
|
case "modal":
|
|
1778
1794
|
return modalComponentToProps(component, rendererMapperProps);
|
|
1795
|
+
case "modal-content":
|
|
1796
|
+
return modalContentComponentToProps(component, rendererMapperProps);
|
|
1779
1797
|
case "multi-select":
|
|
1780
1798
|
return multiSelectInputComponentToProps(component, rendererMapperProps);
|
|
1781
1799
|
case "multi-upload":
|
|
@@ -1820,6 +1838,37 @@ var getInputUpdateFunction = (updateComponent) => {
|
|
|
1820
1838
|
};
|
|
1821
1839
|
};
|
|
1822
1840
|
|
|
1841
|
+
// src/revamp/utils/component-utils.ts
|
|
1842
|
+
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1843
|
+
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
1844
|
+
);
|
|
1845
|
+
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
1846
|
+
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
1847
|
+
var mergeLocalValues = (valueA, valueB) => {
|
|
1848
|
+
if (valueA === null) {
|
|
1849
|
+
return valueB;
|
|
1850
|
+
}
|
|
1851
|
+
if (valueB === null) {
|
|
1852
|
+
return valueA;
|
|
1853
|
+
}
|
|
1854
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
1855
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1856
|
+
}
|
|
1857
|
+
return valueB;
|
|
1858
|
+
};
|
|
1859
|
+
var mergeModels = (valueA, valueB) => {
|
|
1860
|
+
if (valueA === null) {
|
|
1861
|
+
return valueB;
|
|
1862
|
+
}
|
|
1863
|
+
if (valueB === null) {
|
|
1864
|
+
return valueA;
|
|
1865
|
+
}
|
|
1866
|
+
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
1867
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1868
|
+
}
|
|
1869
|
+
return valueB;
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1823
1872
|
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1824
1873
|
var createRootDomainComponent = (updateComponent) => {
|
|
1825
1874
|
const update = getInputUpdateFunction(updateComponent);
|
|
@@ -1830,17 +1879,29 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1830
1879
|
_update(updateFn) {
|
|
1831
1880
|
update(this, updateFn);
|
|
1832
1881
|
},
|
|
1882
|
+
dismissAllModals() {
|
|
1883
|
+
var _a;
|
|
1884
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
|
|
1885
|
+
},
|
|
1886
|
+
dismissModal() {
|
|
1887
|
+
var _a;
|
|
1888
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
|
|
1889
|
+
},
|
|
1890
|
+
showModal(modal) {
|
|
1891
|
+
var _a;
|
|
1892
|
+
(_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
|
|
1893
|
+
},
|
|
1833
1894
|
getChildren() {
|
|
1834
|
-
return this.stepComponent ? [this.stepComponent] : [];
|
|
1895
|
+
return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
|
|
1835
1896
|
},
|
|
1836
1897
|
getLocalValue() {
|
|
1837
1898
|
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1838
1899
|
},
|
|
1839
1900
|
async getSubmittableValue() {
|
|
1840
|
-
return this.stepComponent ? this.stepComponent.
|
|
1901
|
+
return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1841
1902
|
},
|
|
1842
1903
|
getSubmittableValueSync() {
|
|
1843
|
-
return this.stepComponent ? this.stepComponent.
|
|
1904
|
+
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1844
1905
|
},
|
|
1845
1906
|
getSummary() {
|
|
1846
1907
|
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
@@ -1874,37 +1935,6 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1874
1935
|
return rootComponent;
|
|
1875
1936
|
};
|
|
1876
1937
|
|
|
1877
|
-
// src/revamp/utils/component-utils.ts
|
|
1878
|
-
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1879
|
-
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
1880
|
-
);
|
|
1881
|
-
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
1882
|
-
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
1883
|
-
var mergeLocalValues = (valueA, valueB) => {
|
|
1884
|
-
if (valueA === null) {
|
|
1885
|
-
return valueB;
|
|
1886
|
-
}
|
|
1887
|
-
if (valueB === null) {
|
|
1888
|
-
return valueA;
|
|
1889
|
-
}
|
|
1890
|
-
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
1891
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1892
|
-
}
|
|
1893
|
-
return valueB;
|
|
1894
|
-
};
|
|
1895
|
-
var mergeModels = (valueA, valueB) => {
|
|
1896
|
-
if (valueA === null) {
|
|
1897
|
-
return valueB;
|
|
1898
|
-
}
|
|
1899
|
-
if (valueB === null) {
|
|
1900
|
-
return valueA;
|
|
1901
|
-
}
|
|
1902
|
-
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
1903
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1904
|
-
}
|
|
1905
|
-
return valueB;
|
|
1906
|
-
};
|
|
1907
|
-
|
|
1908
1938
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
1909
1939
|
var getSummariser = (schema) => (value) => {
|
|
1910
1940
|
const { summary, icon, image } = schema;
|
|
@@ -1953,12 +1983,30 @@ var createStepComponent = (stepProps) => {
|
|
|
1953
1983
|
uid
|
|
1954
1984
|
}, rest), {
|
|
1955
1985
|
type: "step",
|
|
1986
|
+
modals: [],
|
|
1987
|
+
dismissModal() {
|
|
1988
|
+
var _a2;
|
|
1989
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
1990
|
+
},
|
|
1991
|
+
dismissAllModals() {
|
|
1992
|
+
this._update((draft) => {
|
|
1993
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
1994
|
+
});
|
|
1995
|
+
},
|
|
1996
|
+
showModal(modal) {
|
|
1997
|
+
this._update((draft) => {
|
|
1998
|
+
draft.modals = [...draft.modals, modal];
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
1956
2001
|
_update(updateFn) {
|
|
1957
2002
|
update(this, updateFn);
|
|
1958
2003
|
},
|
|
1959
2004
|
getChildren() {
|
|
1960
2005
|
return this.components;
|
|
1961
2006
|
},
|
|
2007
|
+
getModals() {
|
|
2008
|
+
return this.modals;
|
|
2009
|
+
},
|
|
1962
2010
|
async getSubmittableValue() {
|
|
1963
2011
|
return getSubmittableData(this.components);
|
|
1964
2012
|
},
|
|
@@ -1982,6 +2030,9 @@ var createStepComponent = (stepProps) => {
|
|
|
1982
2030
|
stop() {
|
|
1983
2031
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
1984
2032
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
2033
|
+
this._update((draft) => {
|
|
2034
|
+
draft.modals = [];
|
|
2035
|
+
});
|
|
1985
2036
|
}
|
|
1986
2037
|
});
|
|
1987
2038
|
return component;
|
|
@@ -2110,9 +2161,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2110
2161
|
void onBehavior(behavior);
|
|
2111
2162
|
};
|
|
2112
2163
|
switch (behavior.type) {
|
|
2113
|
-
case "action":
|
|
2164
|
+
case "action":
|
|
2165
|
+
case "modal":
|
|
2166
|
+
case "dismiss": {
|
|
2114
2167
|
return {
|
|
2115
|
-
type:
|
|
2168
|
+
type: behavior.type,
|
|
2116
2169
|
title: title != null ? title : "",
|
|
2117
2170
|
accessibilityDescription,
|
|
2118
2171
|
onClick
|
|
@@ -3000,6 +3053,16 @@ function assertActionResponseBody(body) {
|
|
|
3000
3053
|
);
|
|
3001
3054
|
}
|
|
3002
3055
|
}
|
|
3056
|
+
function assertModalResponseBody(body) {
|
|
3057
|
+
if (isObject(body)) {
|
|
3058
|
+
if ("content" in body && isArray(body.content)) {
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
throw new Error(
|
|
3063
|
+
"Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
3003
3066
|
function isErrorResponseBody(body) {
|
|
3004
3067
|
return Boolean(
|
|
3005
3068
|
isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
@@ -3678,6 +3741,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3678
3741
|
},
|
|
3679
3742
|
// noop
|
|
3680
3743
|
onSelect(updatedIndex) {
|
|
3744
|
+
if (updatedIndex === this.selectedIndex) {
|
|
3745
|
+
return;
|
|
3746
|
+
}
|
|
3681
3747
|
if (updatedIndex !== null && this.analyticsId) {
|
|
3682
3748
|
selectProps.trackEvent("OneOf Selected", {
|
|
3683
3749
|
oneOfId: this.analyticsId,
|
|
@@ -5867,7 +5933,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5867
5933
|
};
|
|
5868
5934
|
|
|
5869
5935
|
// src/revamp/flow/getResponseType.ts
|
|
5870
|
-
var responseTypes = ["step", "action", "exit"];
|
|
5936
|
+
var responseTypes = ["step", "action", "exit", "modal"];
|
|
5871
5937
|
var getResponseType = async (response) => {
|
|
5872
5938
|
assertResponseIsValid(response);
|
|
5873
5939
|
const headerResponseType = getResponseTypeFromHeader(response);
|
|
@@ -5895,7 +5961,7 @@ var getResponseTypeFromHeader = (response) => {
|
|
|
5895
5961
|
function assertDFResponseType(type) {
|
|
5896
5962
|
if (!responseTypes.includes(type)) {
|
|
5897
5963
|
throw new Error(
|
|
5898
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
5964
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
|
|
5899
5965
|
);
|
|
5900
5966
|
}
|
|
5901
5967
|
}
|
|
@@ -6050,6 +6116,10 @@ var executeSubmission = async (props) => {
|
|
|
6050
6116
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6051
6117
|
return await triggerAction(body.action, null, false);
|
|
6052
6118
|
}
|
|
6119
|
+
case "modal": {
|
|
6120
|
+
assertModalResponseBody(body);
|
|
6121
|
+
return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
|
|
6122
|
+
}
|
|
6053
6123
|
default: {
|
|
6054
6124
|
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
6055
6125
|
}
|
|
@@ -6294,6 +6364,55 @@ function useStableCallback(handler) {
|
|
|
6294
6364
|
return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6295
6365
|
}
|
|
6296
6366
|
|
|
6367
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6368
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6369
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
6370
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6371
|
+
type: "modal-content",
|
|
6372
|
+
open: true
|
|
6373
|
+
}, modalProps), {
|
|
6374
|
+
_update(updateFn) {
|
|
6375
|
+
update(this, updateFn);
|
|
6376
|
+
},
|
|
6377
|
+
getChildren() {
|
|
6378
|
+
return this.components;
|
|
6379
|
+
},
|
|
6380
|
+
getLocalValue() {
|
|
6381
|
+
return getLocalValues(this.getChildren());
|
|
6382
|
+
},
|
|
6383
|
+
async getSubmittableValue() {
|
|
6384
|
+
return getSubmittableData(this.getChildren());
|
|
6385
|
+
},
|
|
6386
|
+
getSubmittableValueSync() {
|
|
6387
|
+
return getSubmittableDataSync(this.getChildren());
|
|
6388
|
+
},
|
|
6389
|
+
getSummary() {
|
|
6390
|
+
return summariseFromChildren(this.getChildren());
|
|
6391
|
+
},
|
|
6392
|
+
validate() {
|
|
6393
|
+
return validateComponents(this.getChildren());
|
|
6394
|
+
},
|
|
6395
|
+
close() {
|
|
6396
|
+
update(this, (draft) => {
|
|
6397
|
+
draft.open = false;
|
|
6398
|
+
});
|
|
6399
|
+
}
|
|
6400
|
+
});
|
|
6401
|
+
return modalContentComponent;
|
|
6402
|
+
};
|
|
6403
|
+
|
|
6404
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6405
|
+
var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
|
|
6406
|
+
{
|
|
6407
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
6408
|
+
title,
|
|
6409
|
+
components: content.map(
|
|
6410
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
|
|
6411
|
+
)
|
|
6412
|
+
},
|
|
6413
|
+
mapperProps.updateComponent
|
|
6414
|
+
);
|
|
6415
|
+
|
|
6297
6416
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6298
6417
|
function useDynamicFlowCore(props) {
|
|
6299
6418
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6343,6 +6462,20 @@ function useDynamicFlowCore(props) {
|
|
|
6343
6462
|
var _a2;
|
|
6344
6463
|
initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
|
|
6345
6464
|
}, []);
|
|
6465
|
+
const getMapperProps = () => ({
|
|
6466
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6467
|
+
displayStepTitle,
|
|
6468
|
+
loadingState: "idle",
|
|
6469
|
+
updateComponent: () => rerender(),
|
|
6470
|
+
getErrorMessageFunctions,
|
|
6471
|
+
trackEvent,
|
|
6472
|
+
logEvent,
|
|
6473
|
+
httpClient,
|
|
6474
|
+
onBehavior,
|
|
6475
|
+
onRefresh,
|
|
6476
|
+
onPoll,
|
|
6477
|
+
onValueChange
|
|
6478
|
+
});
|
|
6346
6479
|
const initialiseWithStep = (0, import_react3.useCallback)(
|
|
6347
6480
|
(newStep, etag, localValue) => {
|
|
6348
6481
|
rootComponentRef.current.stop();
|
|
@@ -6355,24 +6488,11 @@ function useDynamicFlowCore(props) {
|
|
|
6355
6488
|
});
|
|
6356
6489
|
}
|
|
6357
6490
|
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
|
-
);
|
|
6491
|
+
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6492
|
+
stepLocalValue: localValue,
|
|
6493
|
+
step: newStep
|
|
6494
|
+
}, getMapperProps()));
|
|
6495
|
+
rootComponentRef.current.setStep(newStepComponent);
|
|
6376
6496
|
} catch (error) {
|
|
6377
6497
|
closeWithError(error);
|
|
6378
6498
|
}
|
|
@@ -6424,6 +6544,7 @@ function useDynamicFlowCore(props) {
|
|
|
6424
6544
|
const onBehavior = (0, import_react3.useCallback)(async (behavior) => {
|
|
6425
6545
|
switch (behavior.type) {
|
|
6426
6546
|
case "action": {
|
|
6547
|
+
rootComponentRef.current.dismissAllModals();
|
|
6427
6548
|
try {
|
|
6428
6549
|
const { action } = behavior;
|
|
6429
6550
|
await rootComponentRef.current.getSubmittableValue();
|
|
@@ -6443,10 +6564,20 @@ function useDynamicFlowCore(props) {
|
|
|
6443
6564
|
onLink(behavior.url);
|
|
6444
6565
|
break;
|
|
6445
6566
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6567
|
+
case "modal":
|
|
6568
|
+
if (stepRef.current) {
|
|
6569
|
+
rootComponentRef.current.showModal(
|
|
6570
|
+
modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
|
|
6571
|
+
step: stepRef.current,
|
|
6572
|
+
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6573
|
+
}, getMapperProps()))
|
|
6574
|
+
);
|
|
6575
|
+
}
|
|
6576
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6577
|
+
break;
|
|
6578
|
+
case "dismiss":
|
|
6579
|
+
rootComponentRef.current.dismissModal();
|
|
6580
|
+
break;
|
|
6450
6581
|
case "none":
|
|
6451
6582
|
break;
|
|
6452
6583
|
}
|
|
@@ -6511,6 +6642,11 @@ function useDynamicFlowCore(props) {
|
|
|
6511
6642
|
void onRefresh(void 0, refreshUrl, errors);
|
|
6512
6643
|
break;
|
|
6513
6644
|
}
|
|
6645
|
+
case "behavior": {
|
|
6646
|
+
void onBehavior(command.behavior);
|
|
6647
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6648
|
+
break;
|
|
6649
|
+
}
|
|
6514
6650
|
}
|
|
6515
6651
|
} catch (error) {
|
|
6516
6652
|
closeWithError(error);
|
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];
|
|
@@ -1638,20 +1639,20 @@ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__s
|
|
|
1638
1639
|
});
|
|
1639
1640
|
|
|
1640
1641
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
1641
|
-
var stepComponentToProps = ({
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
}
|
|
1654
|
-
const childrenProps =
|
|
1642
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1643
|
+
const {
|
|
1644
|
+
uid,
|
|
1645
|
+
back,
|
|
1646
|
+
control,
|
|
1647
|
+
description,
|
|
1648
|
+
error,
|
|
1649
|
+
external,
|
|
1650
|
+
loadingState,
|
|
1651
|
+
step,
|
|
1652
|
+
title,
|
|
1653
|
+
onBehavior
|
|
1654
|
+
} = component;
|
|
1655
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1655
1656
|
return __spreadValues({
|
|
1656
1657
|
type: "step",
|
|
1657
1658
|
id: step.id,
|
|
@@ -1683,6 +1684,21 @@ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
|
1683
1684
|
};
|
|
1684
1685
|
};
|
|
1685
1686
|
|
|
1687
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1688
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1689
|
+
const { uid, open, title, close } = component;
|
|
1690
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1691
|
+
return __spreadValues({
|
|
1692
|
+
uid,
|
|
1693
|
+
type: "modal-content",
|
|
1694
|
+
open,
|
|
1695
|
+
title,
|
|
1696
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1697
|
+
childrenProps,
|
|
1698
|
+
onClose: close.bind(component)
|
|
1699
|
+
}, rendererMapperProps);
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1686
1702
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1687
1703
|
var componentToRendererProps = (component, rendererMapperProps) => {
|
|
1688
1704
|
if (isHiddenComponent(component)) {
|
|
@@ -1733,6 +1749,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1733
1749
|
return markdownComponentToProps(component, rendererMapperProps);
|
|
1734
1750
|
case "modal":
|
|
1735
1751
|
return modalComponentToProps(component, rendererMapperProps);
|
|
1752
|
+
case "modal-content":
|
|
1753
|
+
return modalContentComponentToProps(component, rendererMapperProps);
|
|
1736
1754
|
case "multi-select":
|
|
1737
1755
|
return multiSelectInputComponentToProps(component, rendererMapperProps);
|
|
1738
1756
|
case "multi-upload":
|
|
@@ -1777,6 +1795,37 @@ var getInputUpdateFunction = (updateComponent) => {
|
|
|
1777
1795
|
};
|
|
1778
1796
|
};
|
|
1779
1797
|
|
|
1798
|
+
// src/revamp/utils/component-utils.ts
|
|
1799
|
+
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1800
|
+
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
1801
|
+
);
|
|
1802
|
+
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
1803
|
+
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
1804
|
+
var mergeLocalValues = (valueA, valueB) => {
|
|
1805
|
+
if (valueA === null) {
|
|
1806
|
+
return valueB;
|
|
1807
|
+
}
|
|
1808
|
+
if (valueB === null) {
|
|
1809
|
+
return valueA;
|
|
1810
|
+
}
|
|
1811
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
1812
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1813
|
+
}
|
|
1814
|
+
return valueB;
|
|
1815
|
+
};
|
|
1816
|
+
var mergeModels = (valueA, valueB) => {
|
|
1817
|
+
if (valueA === null) {
|
|
1818
|
+
return valueB;
|
|
1819
|
+
}
|
|
1820
|
+
if (valueB === null) {
|
|
1821
|
+
return valueA;
|
|
1822
|
+
}
|
|
1823
|
+
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
1824
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1825
|
+
}
|
|
1826
|
+
return valueB;
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1780
1829
|
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1781
1830
|
var createRootDomainComponent = (updateComponent) => {
|
|
1782
1831
|
const update = getInputUpdateFunction(updateComponent);
|
|
@@ -1787,17 +1836,29 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1787
1836
|
_update(updateFn) {
|
|
1788
1837
|
update(this, updateFn);
|
|
1789
1838
|
},
|
|
1839
|
+
dismissAllModals() {
|
|
1840
|
+
var _a;
|
|
1841
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
|
|
1842
|
+
},
|
|
1843
|
+
dismissModal() {
|
|
1844
|
+
var _a;
|
|
1845
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
|
|
1846
|
+
},
|
|
1847
|
+
showModal(modal) {
|
|
1848
|
+
var _a;
|
|
1849
|
+
(_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
|
|
1850
|
+
},
|
|
1790
1851
|
getChildren() {
|
|
1791
|
-
return this.stepComponent ? [this.stepComponent] : [];
|
|
1852
|
+
return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
|
|
1792
1853
|
},
|
|
1793
1854
|
getLocalValue() {
|
|
1794
1855
|
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1795
1856
|
},
|
|
1796
1857
|
async getSubmittableValue() {
|
|
1797
|
-
return this.stepComponent ? this.stepComponent.
|
|
1858
|
+
return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1798
1859
|
},
|
|
1799
1860
|
getSubmittableValueSync() {
|
|
1800
|
-
return this.stepComponent ? this.stepComponent.
|
|
1861
|
+
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1801
1862
|
},
|
|
1802
1863
|
getSummary() {
|
|
1803
1864
|
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
@@ -1831,37 +1892,6 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1831
1892
|
return rootComponent;
|
|
1832
1893
|
};
|
|
1833
1894
|
|
|
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;
|
|
1863
|
-
};
|
|
1864
|
-
|
|
1865
1895
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
1866
1896
|
var getSummariser = (schema) => (value) => {
|
|
1867
1897
|
const { summary, icon, image } = schema;
|
|
@@ -1910,12 +1940,30 @@ var createStepComponent = (stepProps) => {
|
|
|
1910
1940
|
uid
|
|
1911
1941
|
}, rest), {
|
|
1912
1942
|
type: "step",
|
|
1943
|
+
modals: [],
|
|
1944
|
+
dismissModal() {
|
|
1945
|
+
var _a2;
|
|
1946
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
1947
|
+
},
|
|
1948
|
+
dismissAllModals() {
|
|
1949
|
+
this._update((draft) => {
|
|
1950
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
1951
|
+
});
|
|
1952
|
+
},
|
|
1953
|
+
showModal(modal) {
|
|
1954
|
+
this._update((draft) => {
|
|
1955
|
+
draft.modals = [...draft.modals, modal];
|
|
1956
|
+
});
|
|
1957
|
+
},
|
|
1913
1958
|
_update(updateFn) {
|
|
1914
1959
|
update(this, updateFn);
|
|
1915
1960
|
},
|
|
1916
1961
|
getChildren() {
|
|
1917
1962
|
return this.components;
|
|
1918
1963
|
},
|
|
1964
|
+
getModals() {
|
|
1965
|
+
return this.modals;
|
|
1966
|
+
},
|
|
1919
1967
|
async getSubmittableValue() {
|
|
1920
1968
|
return getSubmittableData(this.components);
|
|
1921
1969
|
},
|
|
@@ -1939,6 +1987,9 @@ var createStepComponent = (stepProps) => {
|
|
|
1939
1987
|
stop() {
|
|
1940
1988
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
1941
1989
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
1990
|
+
this._update((draft) => {
|
|
1991
|
+
draft.modals = [];
|
|
1992
|
+
});
|
|
1942
1993
|
}
|
|
1943
1994
|
});
|
|
1944
1995
|
return component;
|
|
@@ -2067,9 +2118,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2067
2118
|
void onBehavior(behavior);
|
|
2068
2119
|
};
|
|
2069
2120
|
switch (behavior.type) {
|
|
2070
|
-
case "action":
|
|
2121
|
+
case "action":
|
|
2122
|
+
case "modal":
|
|
2123
|
+
case "dismiss": {
|
|
2071
2124
|
return {
|
|
2072
|
-
type:
|
|
2125
|
+
type: behavior.type,
|
|
2073
2126
|
title: title != null ? title : "",
|
|
2074
2127
|
accessibilityDescription,
|
|
2075
2128
|
onClick
|
|
@@ -2957,6 +3010,16 @@ function assertActionResponseBody(body) {
|
|
|
2957
3010
|
);
|
|
2958
3011
|
}
|
|
2959
3012
|
}
|
|
3013
|
+
function assertModalResponseBody(body) {
|
|
3014
|
+
if (isObject(body)) {
|
|
3015
|
+
if ("content" in body && isArray(body.content)) {
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
throw new Error(
|
|
3020
|
+
"Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
|
|
3021
|
+
);
|
|
3022
|
+
}
|
|
2960
3023
|
function isErrorResponseBody(body) {
|
|
2961
3024
|
return Boolean(
|
|
2962
3025
|
isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
@@ -3635,6 +3698,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3635
3698
|
},
|
|
3636
3699
|
// noop
|
|
3637
3700
|
onSelect(updatedIndex) {
|
|
3701
|
+
if (updatedIndex === this.selectedIndex) {
|
|
3702
|
+
return;
|
|
3703
|
+
}
|
|
3638
3704
|
if (updatedIndex !== null && this.analyticsId) {
|
|
3639
3705
|
selectProps.trackEvent("OneOf Selected", {
|
|
3640
3706
|
oneOfId: this.analyticsId,
|
|
@@ -5824,7 +5890,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5824
5890
|
};
|
|
5825
5891
|
|
|
5826
5892
|
// src/revamp/flow/getResponseType.ts
|
|
5827
|
-
var responseTypes = ["step", "action", "exit"];
|
|
5893
|
+
var responseTypes = ["step", "action", "exit", "modal"];
|
|
5828
5894
|
var getResponseType = async (response) => {
|
|
5829
5895
|
assertResponseIsValid(response);
|
|
5830
5896
|
const headerResponseType = getResponseTypeFromHeader(response);
|
|
@@ -5852,7 +5918,7 @@ var getResponseTypeFromHeader = (response) => {
|
|
|
5852
5918
|
function assertDFResponseType(type) {
|
|
5853
5919
|
if (!responseTypes.includes(type)) {
|
|
5854
5920
|
throw new Error(
|
|
5855
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
5921
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
|
|
5856
5922
|
);
|
|
5857
5923
|
}
|
|
5858
5924
|
}
|
|
@@ -6007,6 +6073,10 @@ var executeSubmission = async (props) => {
|
|
|
6007
6073
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6008
6074
|
return await triggerAction(body.action, null, false);
|
|
6009
6075
|
}
|
|
6076
|
+
case "modal": {
|
|
6077
|
+
assertModalResponseBody(body);
|
|
6078
|
+
return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
|
|
6079
|
+
}
|
|
6010
6080
|
default: {
|
|
6011
6081
|
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
6012
6082
|
}
|
|
@@ -6251,6 +6321,55 @@ function useStableCallback(handler) {
|
|
|
6251
6321
|
return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6252
6322
|
}
|
|
6253
6323
|
|
|
6324
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6325
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6326
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
6327
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6328
|
+
type: "modal-content",
|
|
6329
|
+
open: true
|
|
6330
|
+
}, modalProps), {
|
|
6331
|
+
_update(updateFn) {
|
|
6332
|
+
update(this, updateFn);
|
|
6333
|
+
},
|
|
6334
|
+
getChildren() {
|
|
6335
|
+
return this.components;
|
|
6336
|
+
},
|
|
6337
|
+
getLocalValue() {
|
|
6338
|
+
return getLocalValues(this.getChildren());
|
|
6339
|
+
},
|
|
6340
|
+
async getSubmittableValue() {
|
|
6341
|
+
return getSubmittableData(this.getChildren());
|
|
6342
|
+
},
|
|
6343
|
+
getSubmittableValueSync() {
|
|
6344
|
+
return getSubmittableDataSync(this.getChildren());
|
|
6345
|
+
},
|
|
6346
|
+
getSummary() {
|
|
6347
|
+
return summariseFromChildren(this.getChildren());
|
|
6348
|
+
},
|
|
6349
|
+
validate() {
|
|
6350
|
+
return validateComponents(this.getChildren());
|
|
6351
|
+
},
|
|
6352
|
+
close() {
|
|
6353
|
+
update(this, (draft) => {
|
|
6354
|
+
draft.open = false;
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
});
|
|
6358
|
+
return modalContentComponent;
|
|
6359
|
+
};
|
|
6360
|
+
|
|
6361
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6362
|
+
var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
|
|
6363
|
+
{
|
|
6364
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
6365
|
+
title,
|
|
6366
|
+
components: content.map(
|
|
6367
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
|
|
6368
|
+
)
|
|
6369
|
+
},
|
|
6370
|
+
mapperProps.updateComponent
|
|
6371
|
+
);
|
|
6372
|
+
|
|
6254
6373
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6255
6374
|
function useDynamicFlowCore(props) {
|
|
6256
6375
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6300,6 +6419,20 @@ function useDynamicFlowCore(props) {
|
|
|
6300
6419
|
var _a2;
|
|
6301
6420
|
initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
|
|
6302
6421
|
}, []);
|
|
6422
|
+
const getMapperProps = () => ({
|
|
6423
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6424
|
+
displayStepTitle,
|
|
6425
|
+
loadingState: "idle",
|
|
6426
|
+
updateComponent: () => rerender(),
|
|
6427
|
+
getErrorMessageFunctions,
|
|
6428
|
+
trackEvent,
|
|
6429
|
+
logEvent,
|
|
6430
|
+
httpClient,
|
|
6431
|
+
onBehavior,
|
|
6432
|
+
onRefresh,
|
|
6433
|
+
onPoll,
|
|
6434
|
+
onValueChange
|
|
6435
|
+
});
|
|
6303
6436
|
const initialiseWithStep = useCallback2(
|
|
6304
6437
|
(newStep, etag, localValue) => {
|
|
6305
6438
|
rootComponentRef.current.stop();
|
|
@@ -6312,24 +6445,11 @@ function useDynamicFlowCore(props) {
|
|
|
6312
6445
|
});
|
|
6313
6446
|
}
|
|
6314
6447
|
try {
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
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
|
-
);
|
|
6448
|
+
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6449
|
+
stepLocalValue: localValue,
|
|
6450
|
+
step: newStep
|
|
6451
|
+
}, getMapperProps()));
|
|
6452
|
+
rootComponentRef.current.setStep(newStepComponent);
|
|
6333
6453
|
} catch (error) {
|
|
6334
6454
|
closeWithError(error);
|
|
6335
6455
|
}
|
|
@@ -6381,6 +6501,7 @@ function useDynamicFlowCore(props) {
|
|
|
6381
6501
|
const onBehavior = useCallback2(async (behavior) => {
|
|
6382
6502
|
switch (behavior.type) {
|
|
6383
6503
|
case "action": {
|
|
6504
|
+
rootComponentRef.current.dismissAllModals();
|
|
6384
6505
|
try {
|
|
6385
6506
|
const { action } = behavior;
|
|
6386
6507
|
await rootComponentRef.current.getSubmittableValue();
|
|
@@ -6400,10 +6521,20 @@ function useDynamicFlowCore(props) {
|
|
|
6400
6521
|
onLink(behavior.url);
|
|
6401
6522
|
break;
|
|
6402
6523
|
}
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6524
|
+
case "modal":
|
|
6525
|
+
if (stepRef.current) {
|
|
6526
|
+
rootComponentRef.current.showModal(
|
|
6527
|
+
modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
|
|
6528
|
+
step: stepRef.current,
|
|
6529
|
+
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6530
|
+
}, getMapperProps()))
|
|
6531
|
+
);
|
|
6532
|
+
}
|
|
6533
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6534
|
+
break;
|
|
6535
|
+
case "dismiss":
|
|
6536
|
+
rootComponentRef.current.dismissModal();
|
|
6537
|
+
break;
|
|
6407
6538
|
case "none":
|
|
6408
6539
|
break;
|
|
6409
6540
|
}
|
|
@@ -6468,6 +6599,11 @@ function useDynamicFlowCore(props) {
|
|
|
6468
6599
|
void onRefresh(void 0, refreshUrl, errors);
|
|
6469
6600
|
break;
|
|
6470
6601
|
}
|
|
6602
|
+
case "behavior": {
|
|
6603
|
+
void onBehavior(command.behavior);
|
|
6604
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6605
|
+
break;
|
|
6606
|
+
}
|
|
6471
6607
|
}
|
|
6472
6608
|
} catch (error) {
|
|
6473
6609
|
closeWithError(error);
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import type { Context, LayoutComponent } from '../types';
|
|
1
|
+
import type { CallToAction, Context, LayoutComponent } from '../types';
|
|
2
2
|
export type AlertComponent = LayoutComponent & {
|
|
3
3
|
type: 'alert';
|
|
4
4
|
markdown: string;
|
|
5
5
|
context: Context;
|
|
6
|
-
callToAction?:
|
|
7
|
-
};
|
|
8
|
-
export type AlertCallToActionLink = {
|
|
9
|
-
type: 'link';
|
|
10
|
-
accessibilityDescription?: string;
|
|
11
|
-
href: string;
|
|
12
|
-
title: string;
|
|
13
|
-
};
|
|
14
|
-
export type AlertCallToAction = {
|
|
15
|
-
type: 'action';
|
|
16
|
-
accessibilityDescription?: string;
|
|
17
|
-
title: string;
|
|
18
|
-
onClick: () => void;
|
|
6
|
+
callToAction?: CallToAction;
|
|
19
7
|
};
|
|
20
8
|
export declare const createAlertComponent: (alertProps: Pick<AlertComponent, "uid" | "callToAction" | "context" | "control" | "margin" | "markdown">) => AlertComponent;
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import { Icon } from
|
|
2
|
-
import { Image, LayoutComponent } from
|
|
1
|
+
import { Icon } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import { CallToAction, Image, LayoutComponent } from '../types';
|
|
3
3
|
export type ListComponent = LayoutComponent & {
|
|
4
4
|
type: 'list';
|
|
5
5
|
items: ListItem[];
|
|
6
6
|
title?: string;
|
|
7
|
-
callToAction?:
|
|
8
|
-
};
|
|
9
|
-
export type ListCallToActionLink = {
|
|
10
|
-
type: 'link';
|
|
11
|
-
accessibilityDescription?: string;
|
|
12
|
-
href: string;
|
|
13
|
-
title: string;
|
|
14
|
-
onClick: () => void;
|
|
15
|
-
};
|
|
16
|
-
export type ListCallToActionAction = {
|
|
17
|
-
type: 'action';
|
|
18
|
-
accessibilityDescription?: string;
|
|
19
|
-
title: string;
|
|
20
|
-
onClick: () => void;
|
|
7
|
+
callToAction?: CallToAction;
|
|
21
8
|
};
|
|
22
9
|
export type ListItem = {
|
|
23
10
|
icon?: Icon;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DomainComponent, BaseComponent, LocalValue, UpdateComponent } from '../types';
|
|
2
|
+
export type ModalContentComponent = BaseComponent & {
|
|
3
|
+
type: 'modal-content';
|
|
4
|
+
components: DomainComponent[];
|
|
5
|
+
open: boolean;
|
|
6
|
+
title?: string;
|
|
7
|
+
getChildren: () => DomainComponent[];
|
|
8
|
+
getLocalValue: () => LocalValue;
|
|
9
|
+
close: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const createModalContentComponent: (modalProps: Pick<ModalContentComponent, "uid" | "components" | "title">, updateComponent: UpdateComponent) => ModalContentComponent;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { AnalyticsEventDispatcher } from '../features/events';
|
|
2
2
|
import { BaseComponent, DomainComponent, LoadingState, LocalValue, UpdateComponent } from '../types';
|
|
3
3
|
import { StepDomainComponent } from './StepDomainComponent';
|
|
4
|
+
import { ModalContentComponent } from './ModalContentComponent';
|
|
4
5
|
export type RootDomainComponent = BaseComponent & {
|
|
5
6
|
type: 'root';
|
|
6
7
|
stepComponent: StepDomainComponent | null;
|
|
8
|
+
dismissAllModals: () => void;
|
|
9
|
+
dismissModal: () => void;
|
|
10
|
+
showModal: (modal: ModalContentComponent) => void;
|
|
7
11
|
getChildren: () => DomainComponent[];
|
|
8
12
|
getLocalValue: () => LocalValue;
|
|
9
13
|
getLoadingState: () => LoadingState;
|
|
@@ -3,6 +3,7 @@ import type { Step } from '@wise/dynamic-flow-types/build/next';
|
|
|
3
3
|
import type { AnalyticsEventDispatcher } from '../features/events';
|
|
4
4
|
import type { StepPolling } from '../features/polling/getStepPolling';
|
|
5
5
|
import { StepRefreshAfter } from '../features/refreshAfter/getStepRefreshAfter';
|
|
6
|
+
import { ModalContentComponent } from './ModalContentComponent';
|
|
6
7
|
export type StepDomainComponent = BaseComponent & {
|
|
7
8
|
type: 'step';
|
|
8
9
|
back?: BackNavigation;
|
|
@@ -14,7 +15,12 @@ export type StepDomainComponent = BaseComponent & {
|
|
|
14
15
|
loadingState: LoadingState;
|
|
15
16
|
step: Step;
|
|
16
17
|
title?: string;
|
|
18
|
+
modals: ModalContentComponent[];
|
|
19
|
+
dismissModal: () => void;
|
|
20
|
+
dismissAllModals: () => void;
|
|
21
|
+
showModal: (modal: ModalContentComponent) => void;
|
|
17
22
|
getChildren: () => DomainComponent[];
|
|
23
|
+
getModals: () => ModalContentComponent[];
|
|
18
24
|
getLocalValue: () => LocalValue;
|
|
19
25
|
setLoadingState: (loadingState: LoadingState) => void;
|
|
20
26
|
onBehavior: OnBehavior;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ModalBehavior } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import { MapperProps } from '../schema/types';
|
|
3
|
+
import { ModalContentComponent } from '../../components/ModalContentComponent';
|
|
4
|
+
export declare const modalToContent: (uid: string, { content, title }: ModalBehavior, mapperProps: MapperProps) => ModalContentComponent;
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { Action, Behavior as SpecBehavior } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
-
import { OnBehavior } from '../../types';
|
|
3
|
-
type CallToAction = {
|
|
4
|
-
type: 'action';
|
|
5
|
-
title: string;
|
|
6
|
-
accessibilityDescription?: string;
|
|
7
|
-
onClick: () => void;
|
|
8
|
-
} | {
|
|
9
|
-
type: 'link';
|
|
10
|
-
title: string;
|
|
11
|
-
accessibilityDescription?: string;
|
|
12
|
-
href: string;
|
|
13
|
-
onClick: () => void;
|
|
14
|
-
};
|
|
2
|
+
import { CallToAction, OnBehavior } from '../../types';
|
|
15
3
|
type SpecCallToAction = {
|
|
16
4
|
title?: string;
|
|
17
5
|
accessibilityDescription?: string;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Action, Icon, JsonElement, Margin, Model } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
-
import type { ActionBehavior } from '@wise/dynamic-flow-types/build/next/feature/ActionBehavior';
|
|
3
|
-
import type { LinkBehavior } from '@wise/dynamic-flow-types/build/next/feature/LinkBehavior';
|
|
1
|
+
import type { Action, Icon, JsonElement, Margin, Model, ActionBehavior, LinkBehavior, DismissBehavior, ModalBehavior } from '@wise/dynamic-flow-types/build/next';
|
|
4
2
|
import type { AlertComponent } from './components/AlertComponent';
|
|
5
3
|
import type { AllOfComponent } from './components/AllOfComponent';
|
|
6
4
|
import type { BooleanInputComponent } from './components/BooleanInputComponent';
|
|
@@ -36,14 +34,27 @@ import type { StepDomainComponent } from './components/StepDomainComponent';
|
|
|
36
34
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
37
35
|
import type { TupleComponent } from './components/TupleComponent';
|
|
38
36
|
import type { UploadInputComponent } from './components/UploadInputComponent';
|
|
39
|
-
|
|
37
|
+
import { ModalContentComponent } from './components/ModalContentComponent';
|
|
38
|
+
export type DomainComponent = RootDomainComponent | StepDomainComponent | AlertComponent | AllOfComponent | BooleanInputComponent | BoxComponent | ButtonComponent | ColumnsComponent | ConstComponent | ContainerComponent | DateInputComponent | DecisionComponent | DividerComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | IntegerInputComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalComponent | ModalContentComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | ParagraphComponent | RepeatableComponent | ReviewComponent | SearchComponent | SelectInputComponent | StatusListComponent | TextInputComponent | TupleComponent | UploadInputComponent;
|
|
40
39
|
export type LocalValue = LocalValuePrimitive | LocalValueObject | LocalValueArray;
|
|
41
40
|
export type LocalValuePrimitive = string | number | boolean | File | null;
|
|
42
41
|
export interface LocalValueObject extends Record<string, LocalValuePrimitive | LocalValueObject | LocalValueArray> {
|
|
43
42
|
}
|
|
44
43
|
export interface LocalValueArray extends Array<LocalValuePrimitive | LocalValueObject | LocalValueArray> {
|
|
45
44
|
}
|
|
46
|
-
export type
|
|
45
|
+
export type CallToAction = {
|
|
46
|
+
type: 'action' | 'modal' | 'dismiss';
|
|
47
|
+
title: string;
|
|
48
|
+
accessibilityDescription?: string;
|
|
49
|
+
onClick: () => void;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'link';
|
|
52
|
+
title: string;
|
|
53
|
+
accessibilityDescription?: string;
|
|
54
|
+
href: string;
|
|
55
|
+
onClick: () => void;
|
|
56
|
+
};
|
|
57
|
+
export type Behavior = ActionBehavior | LinkBehavior | ModalBehavior | DismissBehavior | {
|
|
47
58
|
type: 'none';
|
|
48
59
|
};
|
|
49
60
|
export type BaseComponent = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Action, ErrorResponseBody, Model, Step } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
|
|
3
|
+
import type { Behavior } from '../domain/types';
|
|
3
4
|
type Command = {
|
|
4
5
|
type: 'complete';
|
|
5
6
|
result: Model;
|
|
@@ -20,6 +21,9 @@ type Command = {
|
|
|
20
21
|
refreshUrl: string;
|
|
21
22
|
errors?: Step['errors'];
|
|
22
23
|
};
|
|
24
|
+
} | {
|
|
25
|
+
type: 'behavior';
|
|
26
|
+
behavior: Behavior;
|
|
23
27
|
};
|
|
24
28
|
export declare const executeSubmission: (props: {
|
|
25
29
|
action: Action;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const responseTypes: readonly ["step", "action", "exit"];
|
|
1
|
+
declare const responseTypes: readonly ["step", "action", "exit", "modal"];
|
|
2
2
|
export type ResponseType = (typeof responseTypes)[number];
|
|
3
3
|
/**
|
|
4
4
|
* Returns either 'step', 'action', or 'exit' based on the response headers and body.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ActionResponseBody, ErrorResponseBody, JsonElement, Step } from '@wise/dynamic-flow-types/build/next';
|
|
1
|
+
import type { ActionResponseBody, ErrorResponseBody, JsonElement, ModalBehavior, Step } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
export declare const assertResponseIsValid: (response: unknown) => void;
|
|
3
3
|
export declare const parseResponseBodyAsJsonElement: (response: Response) => Promise<JsonElement>;
|
|
4
4
|
export declare function isActionResponseBody(body: unknown): body is ActionResponseBody;
|
|
5
5
|
export declare function assertActionResponseBody(body: unknown): asserts body is ActionResponseBody;
|
|
6
|
+
export declare function assertModalResponseBody(body: unknown): asserts body is Omit<ModalBehavior, 'type'>;
|
|
6
7
|
export declare function isErrorResponseBody(body: unknown): body is ErrorResponseBody;
|
|
7
8
|
export declare function assertErrorResponseBody(body: unknown): asserts body is ErrorResponseBody;
|
|
8
9
|
export declare function assertStepResponseBody(body: unknown): asserts body is Step;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ModalContentRendererProps } from '@wise/dynamic-flow-types/build/renderers';
|
|
2
|
+
import { ModalContentComponent } from '../../domain/components/ModalContentComponent';
|
|
3
|
+
import { RendererMapperProps } from './componentToRendererProps';
|
|
4
|
+
export declare const modalContentComponentToProps: (component: ModalContentComponent, rendererMapperProps: RendererMapperProps) => ModalContentRendererProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { StepRendererProps } from '@wise/dynamic-flow-types/build/renderers';
|
|
2
2
|
import type { StepDomainComponent } from '../domain/components/StepDomainComponent';
|
|
3
3
|
import { type RendererMapperProps } from './mappers/componentToRendererProps';
|
|
4
|
-
export declare const stepComponentToProps: (
|
|
4
|
+
export declare const stepComponentToProps: (component: StepDomainComponent, rendererMapperProps: RendererMapperProps) => StepRendererProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.js",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@testing-library/jest-dom": "6.6.3",
|
|
54
54
|
"@testing-library/react": "16.3.0",
|
|
55
55
|
"@testing-library/user-event": "14.6.1",
|
|
56
|
-
"@transferwise/components": "46.
|
|
56
|
+
"@transferwise/components": "46.96.0",
|
|
57
57
|
"@transferwise/formatting": "^2.13.1",
|
|
58
|
-
"@transferwise/icons": "3.
|
|
59
|
-
"@transferwise/neptune-css": "14.24.
|
|
60
|
-
"@types/node": "22.
|
|
58
|
+
"@transferwise/icons": "3.20.0",
|
|
59
|
+
"@transferwise/neptune-css": "14.24.2",
|
|
60
|
+
"@types/node": "22.15.3",
|
|
61
61
|
"@types/jest": "29.5.14",
|
|
62
62
|
"@types/react": "18.3.20",
|
|
63
63
|
"@types/react-dom": "18.3.6",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@wise/art": "2.20.0",
|
|
66
66
|
"@wise/components-theming": "^1.6.2",
|
|
67
67
|
"babel-jest": "29.7.0",
|
|
68
|
-
"esbuild": "0.25.
|
|
68
|
+
"esbuild": "0.25.3",
|
|
69
69
|
"jest": "29.7.0",
|
|
70
70
|
"jest-environment-jsdom": "29.7.0",
|
|
71
71
|
"jest-fetch-mock": "^3.0.3",
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
"react-dom": "18.3.1",
|
|
79
79
|
"react-intl": "6.8.9",
|
|
80
80
|
"storybook": "^8.6.12",
|
|
81
|
-
"stylelint": "16.
|
|
81
|
+
"stylelint": "16.19.1",
|
|
82
82
|
"stylelint-config-standard": "36.0.1",
|
|
83
83
|
"stylelint-no-unsupported-browser-features": "8.0.4",
|
|
84
84
|
"stylelint-value-no-unknown-custom-properties": "6.0.1",
|
|
85
85
|
"tsx": "4.19.3",
|
|
86
86
|
"typescript": "5.8.3",
|
|
87
|
-
"webpack": "5.99.
|
|
88
|
-
"@wise/dynamic-flow-
|
|
89
|
-
"@wise/dynamic-flow-
|
|
87
|
+
"webpack": "5.99.7",
|
|
88
|
+
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
89
|
+
"@wise/dynamic-flow-renderers": "0.0.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@transferwise/components": "^46.92.0",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"classnames": "2.5.1",
|
|
103
103
|
"react-webcam": "^7.2.0",
|
|
104
104
|
"screenfull": "^5.2.0",
|
|
105
|
-
"@wise/dynamic-flow-types": "3.
|
|
105
|
+
"@wise/dynamic-flow-types": "3.2.0"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|