@wise/dynamic-flow-client 4.3.6 → 4.3.8
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 +263 -480
- package/build/main.mjs +263 -480
- package/build/types/revamp/domain/components/StatusListComponent.d.ts +0 -2
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/searchComponent/SearchComponent.d.ts +2 -2
- package/build/types/revamp/domain/features/polling/getStepPolling.d.ts +3 -3
- package/build/types/revamp/domain/mappers/layout/alertLayoutToComponent.d.ts +1 -2
- package/build/types/revamp/domain/mappers/layout/decisionLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/layout/listLayoutToComponent.d.ts +1 -2
- package/build/types/revamp/domain/mappers/layout/reviewLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/layout/statusListLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +3 -2
- package/build/types/revamp/domain/mappers/schema/types.d.ts +2 -3
- package/build/types/revamp/domain/mappers/utils/behavior-utils.d.ts +8 -0
- package/build/types/revamp/domain/mappers/utils/call-to-action-utils.d.ts +22 -0
- package/build/types/revamp/domain/types.d.ts +10 -4
- package/build/types/revamp/flow/executePoll.d.ts +5 -4
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
- package/build/types/revamp/useDynamicFlowCore.d.ts +1 -1
- package/package.json +18 -18
- package/build/types/revamp/domain/mappers/utils/inlineAction.d.ts +0 -2
package/build/main.js
CHANGED
|
@@ -1693,7 +1693,7 @@ var stepComponentToProps = ({
|
|
|
1693
1693
|
step,
|
|
1694
1694
|
title,
|
|
1695
1695
|
components,
|
|
1696
|
-
|
|
1696
|
+
onBehavior
|
|
1697
1697
|
}, rendererMapperProps) => {
|
|
1698
1698
|
const childrenProps = components.map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1699
1699
|
return __spreadValues({
|
|
@@ -1710,7 +1710,9 @@ var stepComponentToProps = ({
|
|
|
1710
1710
|
title,
|
|
1711
1711
|
children: childrenProps.map(rendererMapperProps.render),
|
|
1712
1712
|
childrenProps,
|
|
1713
|
-
onAction
|
|
1713
|
+
onAction: (action) => {
|
|
1714
|
+
void onBehavior({ type: "action", action });
|
|
1715
|
+
}
|
|
1714
1716
|
}, rendererMapperProps);
|
|
1715
1717
|
};
|
|
1716
1718
|
|
|
@@ -1811,6 +1813,48 @@ var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
|
|
|
1811
1813
|
var import_react3 = require("react");
|
|
1812
1814
|
var import_react_intl7 = require("react-intl");
|
|
1813
1815
|
|
|
1816
|
+
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1817
|
+
var createRootDomainComponent = () => ({
|
|
1818
|
+
type: "root",
|
|
1819
|
+
uid: "root",
|
|
1820
|
+
stepComponent: null,
|
|
1821
|
+
getChildren() {
|
|
1822
|
+
return this.stepComponent ? [this.stepComponent] : [];
|
|
1823
|
+
},
|
|
1824
|
+
getLocalValue() {
|
|
1825
|
+
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1826
|
+
},
|
|
1827
|
+
async getSubmittableValue() {
|
|
1828
|
+
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
1829
|
+
},
|
|
1830
|
+
getSubmittableValueSync() {
|
|
1831
|
+
return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
|
|
1832
|
+
},
|
|
1833
|
+
getSummary() {
|
|
1834
|
+
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1835
|
+
},
|
|
1836
|
+
validate() {
|
|
1837
|
+
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1838
|
+
},
|
|
1839
|
+
setLoadingState(loadingState) {
|
|
1840
|
+
var _a;
|
|
1841
|
+
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1842
|
+
},
|
|
1843
|
+
getLoadingState() {
|
|
1844
|
+
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1845
|
+
},
|
|
1846
|
+
getTrackEvent() {
|
|
1847
|
+
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1848
|
+
},
|
|
1849
|
+
hasStep() {
|
|
1850
|
+
return Boolean(this.stepComponent);
|
|
1851
|
+
},
|
|
1852
|
+
stop() {
|
|
1853
|
+
var _a;
|
|
1854
|
+
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
|
|
1814
1858
|
// src/revamp/utils/component-utils.ts
|
|
1815
1859
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1816
1860
|
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
@@ -1928,10 +1972,49 @@ var createStepComponent = (stepProps) => {
|
|
|
1928
1972
|
});
|
|
1929
1973
|
};
|
|
1930
1974
|
|
|
1975
|
+
// src/revamp/domain/mappers/utils/behavior-utils.ts
|
|
1976
|
+
var getDomainLayerBehavior = ({
|
|
1977
|
+
action,
|
|
1978
|
+
behavior
|
|
1979
|
+
}, stepActions) => {
|
|
1980
|
+
if (behavior) {
|
|
1981
|
+
return normaliseBehavior(behavior, stepActions);
|
|
1982
|
+
}
|
|
1983
|
+
if (action) {
|
|
1984
|
+
return actionToBehavior(action, stepActions);
|
|
1985
|
+
}
|
|
1986
|
+
return { type: "none" };
|
|
1987
|
+
};
|
|
1988
|
+
var skipValidation = (behavior) => behavior.type === "action" ? __spreadProps(__spreadValues({}, behavior), { action: __spreadProps(__spreadValues({}, behavior.action), { skipValidation: true }) }) : behavior;
|
|
1989
|
+
var normaliseBehavior = (behavior, stepActions) => {
|
|
1990
|
+
if ("type" in behavior) {
|
|
1991
|
+
return behavior;
|
|
1992
|
+
}
|
|
1993
|
+
if ("action" in behavior && behavior.action) {
|
|
1994
|
+
return actionToBehavior(behavior.action, stepActions);
|
|
1995
|
+
}
|
|
1996
|
+
if ("link" in behavior && behavior.link) {
|
|
1997
|
+
return { type: "link", url: behavior.link.url };
|
|
1998
|
+
}
|
|
1999
|
+
return { type: "none" };
|
|
2000
|
+
};
|
|
2001
|
+
var actionToBehavior = (action, stepActions) => ({
|
|
2002
|
+
type: "action",
|
|
2003
|
+
action: inlineAction(action, stepActions)
|
|
2004
|
+
});
|
|
2005
|
+
var inlineAction = (action, stepActions = []) => action.$ref ? __spreadValues(__spreadValues({}, getActionByReference(action.$ref, stepActions)), action) : action;
|
|
2006
|
+
var getActionByReference = ($ref, actions = []) => {
|
|
2007
|
+
const action = actions.find((a) => a.$id === $ref);
|
|
2008
|
+
if (!action) {
|
|
2009
|
+
throw new Error("Action reference not found in actions array.");
|
|
2010
|
+
}
|
|
2011
|
+
return action;
|
|
2012
|
+
};
|
|
2013
|
+
|
|
1931
2014
|
// src/revamp/domain/features/polling/getStepPolling.ts
|
|
1932
2015
|
var getStepPolling = ({
|
|
1933
2016
|
pollingConfig,
|
|
1934
|
-
|
|
2017
|
+
onBehavior,
|
|
1935
2018
|
onPoll
|
|
1936
2019
|
}) => {
|
|
1937
2020
|
const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
|
|
@@ -1939,20 +2022,20 @@ var getStepPolling = ({
|
|
|
1939
2022
|
if (delay == null) {
|
|
1940
2023
|
throw new Error("Polling configuration must include delay or interval");
|
|
1941
2024
|
}
|
|
1942
|
-
const
|
|
2025
|
+
const onErrorBehavior = skipValidation(getDomainLayerBehavior(onError, []));
|
|
1943
2026
|
let attempts = 0;
|
|
1944
2027
|
const poll = () => {
|
|
1945
2028
|
attempts += 1;
|
|
1946
2029
|
abortController.abort();
|
|
1947
2030
|
abortController = new AbortController();
|
|
1948
2031
|
const { signal } = abortController;
|
|
1949
|
-
onPoll(url,
|
|
2032
|
+
onPoll(url, onErrorBehavior, signal).then((result) => {
|
|
1950
2033
|
if (result) {
|
|
1951
2034
|
stop();
|
|
1952
2035
|
return;
|
|
1953
2036
|
}
|
|
1954
2037
|
if (attempts >= maxAttempts && !signal.aborted) {
|
|
1955
|
-
void
|
|
2038
|
+
void onBehavior(onErrorBehavior);
|
|
1956
2039
|
stop();
|
|
1957
2040
|
}
|
|
1958
2041
|
}).catch(() => {
|
|
@@ -1966,19 +2049,21 @@ var getStepPolling = ({
|
|
|
1966
2049
|
poll();
|
|
1967
2050
|
return { stop };
|
|
1968
2051
|
};
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
if ("action" in onError && onError.action) {
|
|
1979
|
-
return onError.action;
|
|
2052
|
+
|
|
2053
|
+
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
2054
|
+
var ONE_SECOND = 1e3;
|
|
2055
|
+
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
2056
|
+
const targetTime = new Date(refreshAfter).getTime();
|
|
2057
|
+
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
2058
|
+
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
1980
2059
|
}
|
|
1981
|
-
|
|
2060
|
+
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
2061
|
+
const timeout = setTimeout(() => {
|
|
2062
|
+
void onRefresh("refreshAfter");
|
|
2063
|
+
}, timeLeft);
|
|
2064
|
+
return {
|
|
2065
|
+
stop: () => clearTimeout(timeout)
|
|
2066
|
+
};
|
|
1982
2067
|
};
|
|
1983
2068
|
|
|
1984
2069
|
// src/revamp/domain/components/AlertComponent.ts
|
|
@@ -1993,6 +2078,45 @@ var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
|
|
|
1993
2078
|
validate: () => true
|
|
1994
2079
|
});
|
|
1995
2080
|
|
|
2081
|
+
// src/revamp/domain/mappers/utils/call-to-action-utils.ts
|
|
2082
|
+
var getDomainLayerCallToAction = (callToAction, onBehavior, stepActions) => {
|
|
2083
|
+
if (!callToAction) {
|
|
2084
|
+
return void 0;
|
|
2085
|
+
}
|
|
2086
|
+
const { title = "", accessibilityDescription, action, behavior } = callToAction;
|
|
2087
|
+
return getCallToAction(
|
|
2088
|
+
{ title, accessibilityDescription },
|
|
2089
|
+
getDomainLayerBehavior({ action, behavior }, stepActions),
|
|
2090
|
+
onBehavior
|
|
2091
|
+
);
|
|
2092
|
+
};
|
|
2093
|
+
var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior) => {
|
|
2094
|
+
const onClick = () => {
|
|
2095
|
+
void onBehavior(behavior);
|
|
2096
|
+
};
|
|
2097
|
+
switch (behavior.type) {
|
|
2098
|
+
case "action": {
|
|
2099
|
+
return {
|
|
2100
|
+
type: "action",
|
|
2101
|
+
title: title != null ? title : "",
|
|
2102
|
+
accessibilityDescription,
|
|
2103
|
+
onClick
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
case "link": {
|
|
2107
|
+
return {
|
|
2108
|
+
type: "link",
|
|
2109
|
+
title: title != null ? title : "",
|
|
2110
|
+
href: behavior.url,
|
|
2111
|
+
accessibilityDescription,
|
|
2112
|
+
onClick
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
default:
|
|
2116
|
+
return void 0;
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
|
|
1996
2120
|
// src/revamp/domain/mappers/utils/legacy-utils.ts
|
|
1997
2121
|
var mapLegacyContext = (context) => {
|
|
1998
2122
|
switch (context) {
|
|
@@ -2045,67 +2169,18 @@ var legacyActionTypeToControl = {
|
|
|
2045
2169
|
var mapLegacyActionTypeToControl = (type) => type && type in legacyActionTypeToControl ? legacyActionTypeToControl[type] : "secondary";
|
|
2046
2170
|
|
|
2047
2171
|
// src/revamp/domain/mappers/layout/alertLayoutToComponent.ts
|
|
2048
|
-
var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context = "neutral", callToAction }, {
|
|
2172
|
+
var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context = "neutral", callToAction }, { onBehavior, step }) => {
|
|
2173
|
+
var _a;
|
|
2174
|
+
const cta = callToAction ? getDomainLayerCallToAction(callToAction, onBehavior, (_a = step.actions) != null ? _a : []) : void 0;
|
|
2049
2175
|
return createAlertComponent({
|
|
2050
2176
|
uid,
|
|
2051
2177
|
control,
|
|
2052
2178
|
markdown,
|
|
2053
2179
|
margin,
|
|
2054
|
-
callToAction:
|
|
2180
|
+
callToAction: cta,
|
|
2055
2181
|
context: mapLegacyContext(context)
|
|
2056
2182
|
});
|
|
2057
2183
|
};
|
|
2058
|
-
var getComponentCallToAction = (callToAction, onAction) => {
|
|
2059
|
-
if (!callToAction) {
|
|
2060
|
-
return void 0;
|
|
2061
|
-
}
|
|
2062
|
-
const { accessibilityDescription, behavior, title } = callToAction;
|
|
2063
|
-
if ("type" in behavior) {
|
|
2064
|
-
switch (behavior.type) {
|
|
2065
|
-
case "action": {
|
|
2066
|
-
const { action } = behavior;
|
|
2067
|
-
return {
|
|
2068
|
-
type: "action",
|
|
2069
|
-
accessibilityDescription,
|
|
2070
|
-
title,
|
|
2071
|
-
onClick: () => {
|
|
2072
|
-
void onAction(action);
|
|
2073
|
-
}
|
|
2074
|
-
};
|
|
2075
|
-
}
|
|
2076
|
-
case "link": {
|
|
2077
|
-
return {
|
|
2078
|
-
type: "link",
|
|
2079
|
-
accessibilityDescription,
|
|
2080
|
-
href: behavior.url,
|
|
2081
|
-
title
|
|
2082
|
-
};
|
|
2083
|
-
}
|
|
2084
|
-
default:
|
|
2085
|
-
return void 0;
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
if (behavior.link) {
|
|
2089
|
-
const { url } = behavior.link;
|
|
2090
|
-
return {
|
|
2091
|
-
type: "link",
|
|
2092
|
-
accessibilityDescription,
|
|
2093
|
-
href: url,
|
|
2094
|
-
title
|
|
2095
|
-
};
|
|
2096
|
-
}
|
|
2097
|
-
if (behavior.action) {
|
|
2098
|
-
const { action } = behavior;
|
|
2099
|
-
return {
|
|
2100
|
-
type: "action",
|
|
2101
|
-
accessibilityDescription,
|
|
2102
|
-
title,
|
|
2103
|
-
onClick: () => {
|
|
2104
|
-
void onAction(action);
|
|
2105
|
-
}
|
|
2106
|
-
};
|
|
2107
|
-
}
|
|
2108
|
-
};
|
|
2109
2184
|
|
|
2110
2185
|
// src/revamp/domain/components/BoxComponent.ts
|
|
2111
2186
|
var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
|
|
@@ -2154,75 +2229,24 @@ var createButtonComponent = (buttonProps) => __spreadProps(__spreadValues({
|
|
|
2154
2229
|
validate: () => true
|
|
2155
2230
|
});
|
|
2156
2231
|
|
|
2157
|
-
// src/revamp/domain/mappers/utils/inlineAction.ts
|
|
2158
|
-
var inlineAction = (action, stepActions = []) => action.$ref ? __spreadValues(__spreadValues({}, getActionByReference(action.$ref, stepActions)), action) : action;
|
|
2159
|
-
var getActionByReference = ($ref, actions = []) => {
|
|
2160
|
-
const action = actions.find((a) => a.$id === $ref);
|
|
2161
|
-
if (!action) {
|
|
2162
|
-
throw new Error("Action reference not found in actions array.");
|
|
2163
|
-
}
|
|
2164
|
-
return action;
|
|
2165
|
-
};
|
|
2166
|
-
|
|
2167
2232
|
// src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
|
|
2168
2233
|
var buttonLayoutToComponent = (uid, button, mapperProps) => {
|
|
2169
|
-
if (button.behavior) {
|
|
2170
|
-
return buttonLayoutToComponentWithBehavior(
|
|
2171
|
-
uid,
|
|
2172
|
-
__spreadProps(__spreadValues({}, button), { behavior: button.behavior }),
|
|
2173
|
-
mapperProps
|
|
2174
|
-
);
|
|
2175
|
-
}
|
|
2176
|
-
if (button.action) {
|
|
2234
|
+
if (!button.behavior && button.action) {
|
|
2177
2235
|
return buttonLayoutToComponentWithAction(
|
|
2178
2236
|
uid,
|
|
2179
2237
|
__spreadProps(__spreadValues({}, button), { action: button.action }),
|
|
2180
2238
|
mapperProps
|
|
2181
2239
|
);
|
|
2182
2240
|
}
|
|
2183
|
-
return
|
|
2241
|
+
return buttonLayoutToComponentWithBehavior(uid, button, mapperProps);
|
|
2184
2242
|
};
|
|
2185
2243
|
var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
2186
|
-
|
|
2187
|
-
const {
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
}
|
|
2193
|
-
if ("type" in behavior) {
|
|
2194
|
-
switch (behavior.type) {
|
|
2195
|
-
case "action": {
|
|
2196
|
-
const action2 = inlineAction(behavior.action, step == null ? void 0 : step.actions);
|
|
2197
|
-
return () => {
|
|
2198
|
-
void onAction(action2);
|
|
2199
|
-
};
|
|
2200
|
-
}
|
|
2201
|
-
case "link": {
|
|
2202
|
-
const { url } = behavior;
|
|
2203
|
-
return () => {
|
|
2204
|
-
onLink(url);
|
|
2205
|
-
};
|
|
2206
|
-
}
|
|
2207
|
-
default:
|
|
2208
|
-
return () => {
|
|
2209
|
-
};
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
const { action, link } = behavior;
|
|
2213
|
-
const inlinedAction = action ? inlineAction(action, step == null ? void 0 : step.actions) : null;
|
|
2214
|
-
if (inlinedAction) {
|
|
2215
|
-
return () => {
|
|
2216
|
-
void onAction(inlinedAction);
|
|
2217
|
-
};
|
|
2218
|
-
}
|
|
2219
|
-
if (link) {
|
|
2220
|
-
return () => {
|
|
2221
|
-
onLink(link.url);
|
|
2222
|
-
};
|
|
2223
|
-
}
|
|
2224
|
-
return () => {
|
|
2225
|
-
};
|
|
2244
|
+
var _a;
|
|
2245
|
+
const { onBehavior } = mapperProps;
|
|
2246
|
+
const { context, control, disabled, margin = "md", pinOrder, size, title } = button;
|
|
2247
|
+
const behavior = getDomainLayerBehavior(button, (_a = mapperProps.step.actions) != null ? _a : []);
|
|
2248
|
+
const onClick = () => {
|
|
2249
|
+
void onBehavior(behavior);
|
|
2226
2250
|
};
|
|
2227
2251
|
return createButtonComponent({
|
|
2228
2252
|
uid,
|
|
@@ -2233,16 +2257,16 @@ var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
|
2233
2257
|
pinOrder,
|
|
2234
2258
|
size,
|
|
2235
2259
|
title: title != null ? title : "",
|
|
2236
|
-
onClick
|
|
2260
|
+
onClick
|
|
2237
2261
|
});
|
|
2238
2262
|
};
|
|
2239
2263
|
var buttonLayoutToComponentWithAction = (uid, button, mapperProps) => {
|
|
2240
|
-
const {
|
|
2264
|
+
const { onBehavior, step } = mapperProps;
|
|
2241
2265
|
const { context, control, disabled, margin = "md", pinOrder, size, title } = button;
|
|
2242
2266
|
const { action } = button;
|
|
2243
2267
|
const inlinedAction = action ? inlineAction(action, step == null ? void 0 : step.actions) : {};
|
|
2244
2268
|
const onClick = () => {
|
|
2245
|
-
void
|
|
2269
|
+
void onBehavior({ type: "action", action: inlinedAction });
|
|
2246
2270
|
};
|
|
2247
2271
|
return createButtonComponent({
|
|
2248
2272
|
uid,
|
|
@@ -2256,21 +2280,6 @@ var buttonLayoutToComponentWithAction = (uid, button, mapperProps) => {
|
|
|
2256
2280
|
onClick
|
|
2257
2281
|
});
|
|
2258
2282
|
};
|
|
2259
|
-
var buttonLayoutToComponentWithNoop = (uid, button) => {
|
|
2260
|
-
const { context, control, disabled, margin = "md", pinOrder, size, title } = button;
|
|
2261
|
-
return createButtonComponent({
|
|
2262
|
-
uid,
|
|
2263
|
-
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
2264
|
-
control,
|
|
2265
|
-
disabled: disabled != null ? disabled : false,
|
|
2266
|
-
margin,
|
|
2267
|
-
pinOrder,
|
|
2268
|
-
size,
|
|
2269
|
-
title: title != null ? title : "",
|
|
2270
|
-
onClick: () => {
|
|
2271
|
-
}
|
|
2272
|
-
});
|
|
2273
|
-
};
|
|
2274
2283
|
var getButtonTitle = ({ title, action }) => {
|
|
2275
2284
|
var _a;
|
|
2276
2285
|
return (_a = title != null ? title : action == null ? void 0 : action.title) != null ? _a : "";
|
|
@@ -2350,54 +2359,24 @@ var decisionLayoutToComponent = (uid, {
|
|
|
2350
2359
|
margin = "md",
|
|
2351
2360
|
options,
|
|
2352
2361
|
title
|
|
2353
|
-
},
|
|
2362
|
+
}, { onBehavior, step }) => createDecisionComponent({
|
|
2354
2363
|
uid,
|
|
2355
2364
|
control,
|
|
2356
2365
|
margin,
|
|
2357
2366
|
options: options.map((option) => {
|
|
2358
|
-
var _a;
|
|
2367
|
+
var _a, _b;
|
|
2368
|
+
const behavior = getDomainLayerBehavior(option, (_a = step.actions) != null ? _a : []);
|
|
2359
2369
|
return __spreadProps(__spreadValues({}, option), {
|
|
2360
|
-
disabled: (
|
|
2361
|
-
href:
|
|
2370
|
+
disabled: (_b = option.disabled) != null ? _b : false,
|
|
2371
|
+
href: behavior.type === "link" ? behavior.url : void 0,
|
|
2362
2372
|
image: mapSpecImage(option.image),
|
|
2363
|
-
onClick:
|
|
2373
|
+
onClick: () => {
|
|
2374
|
+
void onBehavior(behavior);
|
|
2375
|
+
}
|
|
2364
2376
|
});
|
|
2365
2377
|
}),
|
|
2366
2378
|
title
|
|
2367
2379
|
});
|
|
2368
|
-
var getHref = (option) => {
|
|
2369
|
-
const { behavior } = option;
|
|
2370
|
-
if (behavior && "type" in behavior && behavior.type === "link") {
|
|
2371
|
-
return behavior.url;
|
|
2372
|
-
}
|
|
2373
|
-
return void 0;
|
|
2374
|
-
};
|
|
2375
|
-
var getOnClick = (option, { step, onAction, onLink }) => {
|
|
2376
|
-
const { behavior } = option;
|
|
2377
|
-
if (!behavior && option.action) {
|
|
2378
|
-
const action = inlineAction(option.action, step == null ? void 0 : step.actions);
|
|
2379
|
-
return () => {
|
|
2380
|
-
void onAction(action);
|
|
2381
|
-
};
|
|
2382
|
-
}
|
|
2383
|
-
if (behavior && "type" in behavior) {
|
|
2384
|
-
switch (behavior.type) {
|
|
2385
|
-
case "action": {
|
|
2386
|
-
const action = inlineAction(behavior.action, step == null ? void 0 : step.actions);
|
|
2387
|
-
return () => {
|
|
2388
|
-
void onAction(action);
|
|
2389
|
-
};
|
|
2390
|
-
}
|
|
2391
|
-
case "link": {
|
|
2392
|
-
return () => {
|
|
2393
|
-
void onLink(behavior.url);
|
|
2394
|
-
};
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
return () => {
|
|
2399
|
-
};
|
|
2400
|
-
};
|
|
2401
2380
|
|
|
2402
2381
|
// src/revamp/domain/components/DividerComponent.ts
|
|
2403
2382
|
var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
@@ -5407,9 +5386,9 @@ var createReviewComponent = (reviewProps) => __spreadProps(__spreadValues({
|
|
|
5407
5386
|
});
|
|
5408
5387
|
|
|
5409
5388
|
// src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
|
|
5410
|
-
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, {
|
|
5389
|
+
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onBehavior, step }) => createReviewComponent({
|
|
5411
5390
|
uid,
|
|
5412
|
-
callToAction: getReviewAction({
|
|
5391
|
+
callToAction: getReviewAction({ onBehavior, callToAction, action, stepActions: step.actions }),
|
|
5413
5392
|
control: getOrientationControl({ control, orientation }),
|
|
5414
5393
|
fields: fields.map((field) => {
|
|
5415
5394
|
var _a;
|
|
@@ -5418,83 +5397,20 @@ var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, marg
|
|
|
5418
5397
|
margin,
|
|
5419
5398
|
title
|
|
5420
5399
|
});
|
|
5421
|
-
var getReviewAction = ({
|
|
5400
|
+
var getReviewAction = ({
|
|
5401
|
+
onBehavior,
|
|
5402
|
+
callToAction,
|
|
5403
|
+
action,
|
|
5404
|
+
stepActions = []
|
|
5405
|
+
}) => {
|
|
5422
5406
|
if (callToAction) {
|
|
5423
|
-
|
|
5424
|
-
if (behavior) {
|
|
5425
|
-
if ("type" in behavior) {
|
|
5426
|
-
switch (behavior.type) {
|
|
5427
|
-
case "action": {
|
|
5428
|
-
const { action: behaviorAction2 } = behavior;
|
|
5429
|
-
return {
|
|
5430
|
-
accessibilityDescription,
|
|
5431
|
-
title,
|
|
5432
|
-
onClick: () => {
|
|
5433
|
-
void onAction(behaviorAction2);
|
|
5434
|
-
}
|
|
5435
|
-
};
|
|
5436
|
-
}
|
|
5437
|
-
case "link": {
|
|
5438
|
-
const { url } = behavior;
|
|
5439
|
-
return {
|
|
5440
|
-
accessibilityDescription,
|
|
5441
|
-
href: url,
|
|
5442
|
-
title,
|
|
5443
|
-
onClick: () => {
|
|
5444
|
-
onLink(url);
|
|
5445
|
-
}
|
|
5446
|
-
};
|
|
5447
|
-
}
|
|
5448
|
-
default:
|
|
5449
|
-
return void 0;
|
|
5450
|
-
}
|
|
5451
|
-
}
|
|
5452
|
-
const { action: behaviorAction, link } = behavior;
|
|
5453
|
-
if (behaviorAction) {
|
|
5454
|
-
return {
|
|
5455
|
-
accessibilityDescription,
|
|
5456
|
-
title,
|
|
5457
|
-
onClick: () => {
|
|
5458
|
-
void onAction(behaviorAction);
|
|
5459
|
-
}
|
|
5460
|
-
};
|
|
5461
|
-
}
|
|
5462
|
-
if (link) {
|
|
5463
|
-
return {
|
|
5464
|
-
accessibilityDescription,
|
|
5465
|
-
href: link.url,
|
|
5466
|
-
title,
|
|
5467
|
-
onClick: () => {
|
|
5468
|
-
onLink(link.url);
|
|
5469
|
-
}
|
|
5470
|
-
};
|
|
5471
|
-
}
|
|
5472
|
-
return {
|
|
5473
|
-
accessibilityDescription,
|
|
5474
|
-
title,
|
|
5475
|
-
onClick: () => {
|
|
5476
|
-
}
|
|
5477
|
-
};
|
|
5478
|
-
}
|
|
5479
|
-
if (ctaAction) {
|
|
5480
|
-
return {
|
|
5481
|
-
title,
|
|
5482
|
-
onClick: () => {
|
|
5483
|
-
void onAction(ctaAction);
|
|
5484
|
-
}
|
|
5485
|
-
};
|
|
5486
|
-
}
|
|
5487
|
-
return {
|
|
5488
|
-
title,
|
|
5489
|
-
onClick: () => {
|
|
5490
|
-
}
|
|
5491
|
-
};
|
|
5407
|
+
return getDomainLayerCallToAction(callToAction, onBehavior, stepActions);
|
|
5492
5408
|
}
|
|
5493
5409
|
if (action == null ? void 0 : action.title) {
|
|
5494
5410
|
return {
|
|
5495
5411
|
title: action.title,
|
|
5496
5412
|
onClick: () => {
|
|
5497
|
-
void
|
|
5413
|
+
void onBehavior({ type: "action", action });
|
|
5498
5414
|
}
|
|
5499
5415
|
};
|
|
5500
5416
|
}
|
|
@@ -5515,7 +5431,7 @@ var getOrientationControl = ({
|
|
|
5515
5431
|
|
|
5516
5432
|
// src/revamp/domain/components/searchComponent/SearchComponent.ts
|
|
5517
5433
|
var DEBOUNCE_TIME = 400;
|
|
5518
|
-
var createSearchComponent = (searchProps, performSearch,
|
|
5434
|
+
var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
|
|
5519
5435
|
const { uid, control, emptyMessage, margin, title } = searchProps;
|
|
5520
5436
|
const update = getInputUpdateFunction(uid, updateComponent);
|
|
5521
5437
|
let abortController = new AbortController();
|
|
@@ -5546,7 +5462,7 @@ var createSearchComponent = (searchProps, performSearch, onAction, updateCompone
|
|
|
5546
5462
|
};
|
|
5547
5463
|
const onSelect = ({ type, value }) => {
|
|
5548
5464
|
if (type === "action") {
|
|
5549
|
-
void
|
|
5465
|
+
void onBehavior({ type: "action", action: value });
|
|
5550
5466
|
} else {
|
|
5551
5467
|
update((draft) => {
|
|
5552
5468
|
draft.query = value.query;
|
|
@@ -5636,7 +5552,7 @@ var hashRequest = (query, config) => JSON.stringify({ query, config });
|
|
|
5636
5552
|
|
|
5637
5553
|
// src/revamp/domain/mappers/layout/searchLayoutToComponent.ts
|
|
5638
5554
|
var searchLayoutToComponent = (uid, { control, emptyMessage = "", method, param, title, url, margin = "md" }, mapperProps) => {
|
|
5639
|
-
const { httpClient,
|
|
5555
|
+
const { httpClient, onBehavior, updateComponent } = mapperProps;
|
|
5640
5556
|
const search = getPerformSearchFunction(httpClient, { method, param, url });
|
|
5641
5557
|
return createSearchComponent(
|
|
5642
5558
|
{
|
|
@@ -5647,7 +5563,7 @@ var searchLayoutToComponent = (uid, { control, emptyMessage = "", method, param,
|
|
|
5647
5563
|
title
|
|
5648
5564
|
},
|
|
5649
5565
|
search,
|
|
5650
|
-
|
|
5566
|
+
onBehavior,
|
|
5651
5567
|
updateComponent
|
|
5652
5568
|
);
|
|
5653
5569
|
};
|
|
@@ -5665,87 +5581,21 @@ var createStatusListComponent = (statusListProps) => __spreadProps(__spreadValue
|
|
|
5665
5581
|
});
|
|
5666
5582
|
|
|
5667
5583
|
// src/revamp/domain/mappers/layout/statusListLayoutToComponent.ts
|
|
5668
|
-
var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, {
|
|
5584
|
+
var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, { onBehavior, step }) => createStatusListComponent({
|
|
5669
5585
|
uid,
|
|
5670
5586
|
control,
|
|
5671
|
-
items: items.map((item) =>
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5587
|
+
items: items.map((item) => {
|
|
5588
|
+
var _a;
|
|
5589
|
+
const callToAction = getDomainLayerCallToAction(
|
|
5590
|
+
item.callToAction,
|
|
5591
|
+
onBehavior,
|
|
5592
|
+
(_a = step.actions) != null ? _a : []
|
|
5593
|
+
);
|
|
5594
|
+
return __spreadProps(__spreadValues({}, item), { callToAction });
|
|
5595
|
+
}),
|
|
5675
5596
|
margin,
|
|
5676
5597
|
title
|
|
5677
5598
|
});
|
|
5678
|
-
var getItemHref = (callToAction) => {
|
|
5679
|
-
var _a;
|
|
5680
|
-
if (!callToAction) {
|
|
5681
|
-
return void 0;
|
|
5682
|
-
}
|
|
5683
|
-
const { behavior } = callToAction;
|
|
5684
|
-
if ("type" in behavior) {
|
|
5685
|
-
return void 0;
|
|
5686
|
-
}
|
|
5687
|
-
return (_a = behavior == null ? void 0 : behavior.link) == null ? void 0 : _a.url;
|
|
5688
|
-
};
|
|
5689
|
-
var getItemCallToAction = (callToAction, onAction, onLink) => {
|
|
5690
|
-
if (!callToAction) {
|
|
5691
|
-
return void 0;
|
|
5692
|
-
}
|
|
5693
|
-
const { accessibilityDescription, behavior, title } = callToAction;
|
|
5694
|
-
if ("type" in behavior) {
|
|
5695
|
-
switch (behavior.type) {
|
|
5696
|
-
case "action": {
|
|
5697
|
-
const { action } = behavior;
|
|
5698
|
-
return {
|
|
5699
|
-
accessibilityDescription,
|
|
5700
|
-
title,
|
|
5701
|
-
onClick: () => {
|
|
5702
|
-
void onAction(action);
|
|
5703
|
-
}
|
|
5704
|
-
};
|
|
5705
|
-
}
|
|
5706
|
-
case "link": {
|
|
5707
|
-
const { url } = behavior;
|
|
5708
|
-
return {
|
|
5709
|
-
accessibilityDescription,
|
|
5710
|
-
href: url,
|
|
5711
|
-
title,
|
|
5712
|
-
onClick: () => {
|
|
5713
|
-
void onLink(url);
|
|
5714
|
-
}
|
|
5715
|
-
};
|
|
5716
|
-
}
|
|
5717
|
-
default:
|
|
5718
|
-
return void 0;
|
|
5719
|
-
}
|
|
5720
|
-
}
|
|
5721
|
-
if (behavior.action) {
|
|
5722
|
-
const { action } = behavior;
|
|
5723
|
-
return {
|
|
5724
|
-
accessibilityDescription,
|
|
5725
|
-
title,
|
|
5726
|
-
onClick: () => {
|
|
5727
|
-
void onAction(action);
|
|
5728
|
-
}
|
|
5729
|
-
};
|
|
5730
|
-
}
|
|
5731
|
-
if (behavior.link) {
|
|
5732
|
-
const { url } = behavior.link;
|
|
5733
|
-
return {
|
|
5734
|
-
accessibilityDescription,
|
|
5735
|
-
href: url,
|
|
5736
|
-
title,
|
|
5737
|
-
onClick: () => {
|
|
5738
|
-
void onLink(url);
|
|
5739
|
-
}
|
|
5740
|
-
};
|
|
5741
|
-
}
|
|
5742
|
-
return {
|
|
5743
|
-
accessibilityDescription,
|
|
5744
|
-
title,
|
|
5745
|
-
onClick: () => {
|
|
5746
|
-
}
|
|
5747
|
-
};
|
|
5748
|
-
};
|
|
5749
5599
|
|
|
5750
5600
|
// src/revamp/domain/mappers/layout/deprecatedListLayoutToComponent.ts
|
|
5751
5601
|
var deprecatedListLayoutToComponent = (uid, { control, items, margin = "md", title }) => createStatusListComponent({
|
|
@@ -5785,48 +5635,19 @@ var createListComponent = (listProps) => __spreadProps(__spreadValues({
|
|
|
5785
5635
|
});
|
|
5786
5636
|
|
|
5787
5637
|
// src/revamp/domain/mappers/layout/listLayoutToComponent.ts
|
|
5788
|
-
var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md", title }, mapperProps) =>
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
}
|
|
5802
|
-
const { accessibilityDescription, behavior, title } = callToAction;
|
|
5803
|
-
if ("type" in behavior) {
|
|
5804
|
-
switch (behavior.type) {
|
|
5805
|
-
case "action": {
|
|
5806
|
-
const { action } = behavior;
|
|
5807
|
-
return {
|
|
5808
|
-
type: "action",
|
|
5809
|
-
accessibilityDescription,
|
|
5810
|
-
title,
|
|
5811
|
-
onClick: () => {
|
|
5812
|
-
void onAction(action);
|
|
5813
|
-
}
|
|
5814
|
-
};
|
|
5815
|
-
}
|
|
5816
|
-
case "link": {
|
|
5817
|
-
return {
|
|
5818
|
-
type: "link",
|
|
5819
|
-
accessibilityDescription,
|
|
5820
|
-
href: behavior.url,
|
|
5821
|
-
title,
|
|
5822
|
-
onClick: () => {
|
|
5823
|
-
void onLink(behavior.url);
|
|
5824
|
-
}
|
|
5825
|
-
};
|
|
5826
|
-
}
|
|
5827
|
-
}
|
|
5828
|
-
}
|
|
5829
|
-
return void 0;
|
|
5638
|
+
var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md", title }, mapperProps) => {
|
|
5639
|
+
var _a;
|
|
5640
|
+
const { step, onBehavior } = mapperProps;
|
|
5641
|
+
return createListComponent({
|
|
5642
|
+
uid,
|
|
5643
|
+
control,
|
|
5644
|
+
items: items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
5645
|
+
image: mapSpecImage(item.image)
|
|
5646
|
+
})),
|
|
5647
|
+
callToAction: getDomainLayerCallToAction(callToAction, onBehavior, (_a = step.actions) != null ? _a : []),
|
|
5648
|
+
margin,
|
|
5649
|
+
title
|
|
5650
|
+
});
|
|
5830
5651
|
};
|
|
5831
5652
|
|
|
5832
5653
|
// src/revamp/domain/mappers/mapLayoutToComponent.ts
|
|
@@ -5911,22 +5732,6 @@ var getUnreferencedSchemas = (step) => {
|
|
|
5911
5732
|
);
|
|
5912
5733
|
};
|
|
5913
5734
|
|
|
5914
|
-
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
5915
|
-
var ONE_SECOND = 1e3;
|
|
5916
|
-
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
5917
|
-
const targetTime = new Date(refreshAfter).getTime();
|
|
5918
|
-
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
5919
|
-
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
5920
|
-
}
|
|
5921
|
-
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
5922
|
-
const timeout = setTimeout(() => {
|
|
5923
|
-
void onRefresh("refreshAfter");
|
|
5924
|
-
}, timeLeft);
|
|
5925
|
-
return {
|
|
5926
|
-
stop: () => clearTimeout(timeout)
|
|
5927
|
-
};
|
|
5928
|
-
};
|
|
5929
|
-
|
|
5930
5735
|
// src/revamp/domain/mappers/mapStepToComponent.ts
|
|
5931
5736
|
var mapStepToComponent = (_a) => {
|
|
5932
5737
|
var _b = _a, {
|
|
@@ -5934,13 +5739,15 @@ var mapStepToComponent = (_a) => {
|
|
|
5934
5739
|
loadingState,
|
|
5935
5740
|
displayStepTitle,
|
|
5936
5741
|
trackEvent,
|
|
5937
|
-
onPoll
|
|
5742
|
+
onPoll,
|
|
5743
|
+
onBehavior
|
|
5938
5744
|
} = _b, restProps = __objRest(_b, [
|
|
5939
5745
|
"uid",
|
|
5940
5746
|
"loadingState",
|
|
5941
5747
|
"displayStepTitle",
|
|
5942
5748
|
"trackEvent",
|
|
5943
|
-
"onPoll"
|
|
5749
|
+
"onPoll",
|
|
5750
|
+
"onBehavior"
|
|
5944
5751
|
]);
|
|
5945
5752
|
var _a2, _b2;
|
|
5946
5753
|
const { step, updateComponent } = restProps;
|
|
@@ -5961,7 +5768,10 @@ var mapStepToComponent = (_a) => {
|
|
|
5961
5768
|
const back = backNavigation ? {
|
|
5962
5769
|
title: backNavigation.title,
|
|
5963
5770
|
onClick: () => {
|
|
5964
|
-
void
|
|
5771
|
+
void onBehavior({
|
|
5772
|
+
type: "action",
|
|
5773
|
+
action: __spreadProps(__spreadValues({}, backNavigation.action), { skipValidation: true })
|
|
5774
|
+
});
|
|
5965
5775
|
}
|
|
5966
5776
|
} : void 0;
|
|
5967
5777
|
const refreshUrl = (_b2 = step.refreshUrl) != null ? _b2 : step.refreshFormUrl;
|
|
@@ -5970,24 +5780,10 @@ var mapStepToComponent = (_a) => {
|
|
|
5970
5780
|
throw new Error("Step must have an id or a key");
|
|
5971
5781
|
}
|
|
5972
5782
|
const uid = `${rootUid}.${stepId != null ? stepId : "step"}`;
|
|
5973
|
-
const onAction = async (action) => {
|
|
5974
|
-
try {
|
|
5975
|
-
await stepComponent.getSubmittableValue();
|
|
5976
|
-
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
5977
|
-
const canSubmit = skipValidation || stepComponent.validate();
|
|
5978
|
-
if (canSubmit) {
|
|
5979
|
-
void restProps.onAction(action);
|
|
5980
|
-
}
|
|
5981
|
-
} catch (e) {
|
|
5982
|
-
if (true) {
|
|
5983
|
-
console.log("\u274C:", "Failed to get submittable data");
|
|
5984
|
-
}
|
|
5985
|
-
}
|
|
5986
|
-
};
|
|
5987
5783
|
const onRefresh = async (schemaId, url) => restProps.onRefresh(schemaId, url != null ? url : refreshUrl);
|
|
5988
|
-
const stepPolling = polling ? getStepPolling({ pollingConfig: polling,
|
|
5784
|
+
const stepPolling = polling ? getStepPolling({ pollingConfig: polling, onBehavior, onPoll }) : void 0;
|
|
5989
5785
|
const stepRefreshAfter = refreshAfter ? getStepRefreshAfter({ refreshAfter, onRefresh }) : void 0;
|
|
5990
|
-
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent,
|
|
5786
|
+
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
|
|
5991
5787
|
const unreferencedSchemaFormComponents = mapUnreferencedSchemas(mapperProps);
|
|
5992
5788
|
const layoutComponents = layout.map(
|
|
5993
5789
|
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps)
|
|
@@ -6008,7 +5804,7 @@ var mapStepToComponent = (_a) => {
|
|
|
6008
5804
|
step,
|
|
6009
5805
|
updateComponent,
|
|
6010
5806
|
trackEvent,
|
|
6011
|
-
|
|
5807
|
+
onBehavior
|
|
6012
5808
|
});
|
|
6013
5809
|
return stepComponent;
|
|
6014
5810
|
};
|
|
@@ -6049,7 +5845,7 @@ function assertDFResponseType(type) {
|
|
|
6049
5845
|
|
|
6050
5846
|
// src/revamp/flow/executePoll.ts
|
|
6051
5847
|
var executePoll = async (props) => {
|
|
6052
|
-
const {
|
|
5848
|
+
const { errorBehavior, signal, url, httpClient, trackEvent } = props;
|
|
6053
5849
|
try {
|
|
6054
5850
|
const response = await httpClient(url != null ? url : "", {
|
|
6055
5851
|
method: "GET",
|
|
@@ -6057,7 +5853,7 @@ var executePoll = async (props) => {
|
|
|
6057
5853
|
});
|
|
6058
5854
|
if (!response.ok) {
|
|
6059
5855
|
trackEvent("Polling Failed", { url, statusCode: response.status, variant: "revamp" });
|
|
6060
|
-
return { type: "
|
|
5856
|
+
return { type: "behavior", behavior: errorBehavior };
|
|
6061
5857
|
}
|
|
6062
5858
|
const responseType = getResponseTypeFromHeader(response);
|
|
6063
5859
|
const body = await parseResponseBodyAsJsonElement(response);
|
|
@@ -6073,19 +5869,19 @@ var executePoll = async (props) => {
|
|
|
6073
5869
|
}
|
|
6074
5870
|
case "action": {
|
|
6075
5871
|
assertActionResponseBody(body);
|
|
6076
|
-
return { type: "action", action: body.action };
|
|
5872
|
+
return { type: "behavior", behavior: { type: "action", action: body.action } };
|
|
6077
5873
|
}
|
|
6078
5874
|
default: {
|
|
6079
5875
|
if (isActionResponseBody(body)) {
|
|
6080
|
-
return { type: "action", action: body.action };
|
|
5876
|
+
return { type: "behavior", behavior: { type: "action", action: body.action } };
|
|
6081
5877
|
}
|
|
6082
5878
|
return { type: "continue" };
|
|
6083
5879
|
}
|
|
6084
5880
|
}
|
|
6085
|
-
} catch (
|
|
6086
|
-
return { type: "
|
|
5881
|
+
} catch (e) {
|
|
5882
|
+
return { type: "behavior", behavior: errorBehavior };
|
|
6087
5883
|
}
|
|
6088
|
-
} catch (
|
|
5884
|
+
} catch (e) {
|
|
6089
5885
|
return { type: "continue" };
|
|
6090
5886
|
}
|
|
6091
5887
|
};
|
|
@@ -6464,48 +6260,6 @@ function useStableCallback(handler) {
|
|
|
6464
6260
|
return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6465
6261
|
}
|
|
6466
6262
|
|
|
6467
|
-
// src/revamp/domain/components/RootDomainComponent.ts
|
|
6468
|
-
var createRootDomainComponent = () => ({
|
|
6469
|
-
type: "root",
|
|
6470
|
-
uid: "root",
|
|
6471
|
-
stepComponent: null,
|
|
6472
|
-
getChildren() {
|
|
6473
|
-
return this.stepComponent ? [this.stepComponent] : [];
|
|
6474
|
-
},
|
|
6475
|
-
getLocalValue() {
|
|
6476
|
-
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
6477
|
-
},
|
|
6478
|
-
async getSubmittableValue() {
|
|
6479
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
6480
|
-
},
|
|
6481
|
-
getSubmittableValueSync() {
|
|
6482
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
|
|
6483
|
-
},
|
|
6484
|
-
getSummary() {
|
|
6485
|
-
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
6486
|
-
},
|
|
6487
|
-
validate() {
|
|
6488
|
-
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
6489
|
-
},
|
|
6490
|
-
setLoadingState(loadingState) {
|
|
6491
|
-
var _a;
|
|
6492
|
-
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
6493
|
-
},
|
|
6494
|
-
getLoadingState() {
|
|
6495
|
-
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
6496
|
-
},
|
|
6497
|
-
getTrackEvent() {
|
|
6498
|
-
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
6499
|
-
},
|
|
6500
|
-
hasStep() {
|
|
6501
|
-
return Boolean(this.stepComponent);
|
|
6502
|
-
},
|
|
6503
|
-
stop() {
|
|
6504
|
-
var _a;
|
|
6505
|
-
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
6506
|
-
}
|
|
6507
|
-
});
|
|
6508
|
-
|
|
6509
6263
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6510
6264
|
function useDynamicFlowCore(props) {
|
|
6511
6265
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6586,10 +6340,9 @@ function useDynamicFlowCore(props) {
|
|
|
6586
6340
|
trackEvent,
|
|
6587
6341
|
logEvent,
|
|
6588
6342
|
httpClient,
|
|
6589
|
-
|
|
6343
|
+
onBehavior,
|
|
6590
6344
|
onRefresh,
|
|
6591
6345
|
onPoll,
|
|
6592
|
-
onLink,
|
|
6593
6346
|
onValueChange
|
|
6594
6347
|
});
|
|
6595
6348
|
updateComponent(rootComponentRef.current.uid, (draft) => {
|
|
@@ -6643,6 +6396,36 @@ function useDynamicFlowCore(props) {
|
|
|
6643
6396
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6644
6397
|
[]
|
|
6645
6398
|
);
|
|
6399
|
+
const onBehavior = (0, import_react3.useCallback)(async (behavior) => {
|
|
6400
|
+
switch (behavior.type) {
|
|
6401
|
+
case "action": {
|
|
6402
|
+
try {
|
|
6403
|
+
const { action } = behavior;
|
|
6404
|
+
await rootComponentRef.current.getSubmittableValue();
|
|
6405
|
+
const skipValidation2 = action.method === "GET" || Boolean(action.skipValidation);
|
|
6406
|
+
const canSubmit = skipValidation2 || rootComponentRef.current.validate();
|
|
6407
|
+
if (canSubmit) {
|
|
6408
|
+
void onAction(action);
|
|
6409
|
+
}
|
|
6410
|
+
} catch (e) {
|
|
6411
|
+
if (true) {
|
|
6412
|
+
console.log("\u274C:", "Failed to get submittable data");
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
break;
|
|
6416
|
+
}
|
|
6417
|
+
case "link": {
|
|
6418
|
+
onLink(behavior.url);
|
|
6419
|
+
break;
|
|
6420
|
+
}
|
|
6421
|
+
// case 'modal':
|
|
6422
|
+
// return undefined;
|
|
6423
|
+
// case 'dismiss':
|
|
6424
|
+
// return undefined;
|
|
6425
|
+
case "none":
|
|
6426
|
+
break;
|
|
6427
|
+
}
|
|
6428
|
+
}, []);
|
|
6646
6429
|
const onAction = (0, import_react3.useCallback)(async (action) => {
|
|
6647
6430
|
var _a2;
|
|
6648
6431
|
try {
|
|
@@ -6751,11 +6534,11 @@ function useDynamicFlowCore(props) {
|
|
|
6751
6534
|
[]
|
|
6752
6535
|
);
|
|
6753
6536
|
const onPoll = (0, import_react3.useCallback)(
|
|
6754
|
-
async (url,
|
|
6537
|
+
async (url, errorBehavior, signal) => {
|
|
6755
6538
|
const command = await executePoll({
|
|
6756
6539
|
httpClient,
|
|
6757
6540
|
url,
|
|
6758
|
-
|
|
6541
|
+
errorBehavior,
|
|
6759
6542
|
signal,
|
|
6760
6543
|
trackEvent: trackCoreEvent
|
|
6761
6544
|
});
|
|
@@ -6763,8 +6546,8 @@ function useDynamicFlowCore(props) {
|
|
|
6763
6546
|
case "replace-step":
|
|
6764
6547
|
createStep(command.step, command.etag);
|
|
6765
6548
|
return true;
|
|
6766
|
-
case "
|
|
6767
|
-
void
|
|
6549
|
+
case "behavior":
|
|
6550
|
+
void onBehavior(command.behavior);
|
|
6768
6551
|
return true;
|
|
6769
6552
|
case "complete":
|
|
6770
6553
|
onCompletion(command.result);
|
|
@@ -11737,7 +11520,7 @@ function DynamicReview({ component: review, onAction }) {
|
|
|
11737
11520
|
const { action: behaviorAction2 } = behavior;
|
|
11738
11521
|
return {
|
|
11739
11522
|
text: title != null ? title : "",
|
|
11740
|
-
onClick: behaviorAction2 ?
|
|
11523
|
+
onClick: behaviorAction2 ? getOnClick(behaviorAction2) : void 0
|
|
11741
11524
|
};
|
|
11742
11525
|
}
|
|
11743
11526
|
case "link": {
|
|
@@ -11752,7 +11535,7 @@ function DynamicReview({ component: review, onAction }) {
|
|
|
11752
11535
|
if (behaviorAction) {
|
|
11753
11536
|
return {
|
|
11754
11537
|
text: title != null ? title : "",
|
|
11755
|
-
onClick: behaviorAction ?
|
|
11538
|
+
onClick: behaviorAction ? getOnClick(behaviorAction) : void 0
|
|
11756
11539
|
};
|
|
11757
11540
|
}
|
|
11758
11541
|
if (link) {
|
|
@@ -11764,10 +11547,10 @@ function DynamicReview({ component: review, onAction }) {
|
|
|
11764
11547
|
}
|
|
11765
11548
|
return {
|
|
11766
11549
|
text: title != null ? title : "",
|
|
11767
|
-
onClick: action ?
|
|
11550
|
+
onClick: action ? getOnClick(action) : void 0
|
|
11768
11551
|
};
|
|
11769
11552
|
};
|
|
11770
|
-
const
|
|
11553
|
+
const getOnClick = (action) => {
|
|
11771
11554
|
return (event) => {
|
|
11772
11555
|
event.preventDefault();
|
|
11773
11556
|
if (action) {
|
|
@@ -11777,7 +11560,7 @@ function DynamicReview({ component: review, onAction }) {
|
|
|
11777
11560
|
};
|
|
11778
11561
|
const orientation = getDefinitionListLayout(review);
|
|
11779
11562
|
const callToAction = review.callToAction ? getReviewAction2(review.callToAction) : null;
|
|
11780
|
-
const legacyCallToAction = !callToAction && review.action ? { text: (_a = review.action.title) != null ? _a : "", onClick:
|
|
11563
|
+
const legacyCallToAction = !callToAction && review.action ? { text: (_a = review.action.title) != null ? _a : "", onClick: getOnClick(review.action) } : null;
|
|
11781
11564
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: margin, children: [
|
|
11782
11565
|
review.title && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components30.Header, { title: review.title, action: (_b = callToAction != null ? callToAction : legacyCallToAction) != null ? _b : void 0 }),
|
|
11783
11566
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: margin, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components30.DefinitionList, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
@@ -13835,14 +13618,14 @@ var DynamicFlowComponent = ({
|
|
|
13835
13618
|
dispatchEventAndComplete(action.result);
|
|
13836
13619
|
return;
|
|
13837
13620
|
}
|
|
13838
|
-
const { data, method, skipValidation } = action;
|
|
13621
|
+
const { data, method, skipValidation: skipValidation2 } = action;
|
|
13839
13622
|
const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
|
|
13840
13623
|
if (isSubmissionMethod(method)) {
|
|
13841
13624
|
setFormErrors(null);
|
|
13842
|
-
if (!
|
|
13625
|
+
if (!skipValidation2) {
|
|
13843
13626
|
setSubmitted(true);
|
|
13844
13627
|
}
|
|
13845
|
-
if (modelIsValid ||
|
|
13628
|
+
if (modelIsValid || skipValidation2) {
|
|
13846
13629
|
await performAction(action, submissionData);
|
|
13847
13630
|
}
|
|
13848
13631
|
} else {
|