@wise/dynamic-flow-client 3.2.2 → 3.3.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/i18n/tr.json +2 -2
- package/build/main.js +506 -555
- package/build/main.min.js +1 -1
- package/build/main.mjs +508 -557
- package/build/types/legacy/formControl/FormControl.d.ts +4 -1
- package/build/types/legacy/formControl/utils/getAutocompleteString.d.ts +4 -1
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +5 -6
- package/build/types/revamp/domain/components/utils/getComponentForLocalValueKey.d.ts +7 -0
- package/build/types/revamp/domain/features/{events/getAnalyticsEventDispatcher.d.ts → events.d.ts} +3 -7
- package/build/types/revamp/domain/mappers/schema/types.d.ts +2 -2
- package/build/types/revamp/{step/utils → renderers}/getRenderFunction.d.ts +2 -2
- package/build/types/revamp/{step/utils → renderers}/getSchemaErrorMessageFunction.d.ts +1 -1
- package/build/types/revamp/utils/useStableCallback.d.ts +6 -0
- package/package.json +14 -14
- package/build/types/revamp/domain/features/events/getLogggingEventDispatcher.d.ts +0 -4
- package/build/types/revamp/domain/features/events/index.d.ts +0 -2
- package/build/types/revamp/step/Step.d.ts +0 -25
package/build/main.mjs
CHANGED
|
@@ -3478,13 +3478,14 @@ var logInvalidTypeFallbackWarning = ({
|
|
|
3478
3478
|
};
|
|
3479
3479
|
|
|
3480
3480
|
// src/legacy/formControl/utils/getAutocompleteString.ts
|
|
3481
|
-
var getAutocompleteString = (hints) => {
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3484
|
-
return
|
|
3485
|
-
}
|
|
3486
|
-
return
|
|
3487
|
-
};
|
|
3481
|
+
var getAutocompleteString = (hints, { prefix = "", suffix = "" } = {}) => {
|
|
3482
|
+
const autoCompleteString = hints.map((hint) => {
|
|
3483
|
+
const builtHint = `${prefix}${hint}${suffix}`;
|
|
3484
|
+
return isAutocompleteToken(builtHint) ? autocompleteTokenMap[builtHint] : void 0;
|
|
3485
|
+
}).filter((str) => str).join(" ");
|
|
3486
|
+
return autoCompleteString || "off";
|
|
3487
|
+
};
|
|
3488
|
+
var isAutocompleteToken = (str) => Object.keys(autocompleteTokenMap).some((hint) => hint === str);
|
|
3488
3489
|
var autocompleteTokenMap = {
|
|
3489
3490
|
on: "on",
|
|
3490
3491
|
name: "name",
|
|
@@ -3557,15 +3558,12 @@ import { Fragment as Fragment4, jsx as jsx27 } from "react/jsx-runtime";
|
|
|
3557
3558
|
var _FormControl = class _FormControl extends PureComponent {
|
|
3558
3559
|
constructor(props) {
|
|
3559
3560
|
super(props);
|
|
3560
|
-
this.getAutocompleteValue = () => {
|
|
3561
|
+
this.getAutocompleteValue = ({ prefix = "", suffix = "" } = {}) => {
|
|
3561
3562
|
const { autoComplete, autocompleteHint } = this.props;
|
|
3562
3563
|
if (isArray(autocompleteHint)) {
|
|
3563
|
-
return getAutocompleteString(autocompleteHint);
|
|
3564
|
+
return getAutocompleteString(autocompleteHint, { prefix, suffix });
|
|
3564
3565
|
}
|
|
3565
|
-
|
|
3566
|
-
return "on";
|
|
3567
|
-
}
|
|
3568
|
-
return "off";
|
|
3566
|
+
return autoComplete ? "on" : "off";
|
|
3569
3567
|
};
|
|
3570
3568
|
this.handleOnChange = (value, metadata) => {
|
|
3571
3569
|
this.props.onChange(value, void 0, metadata);
|
|
@@ -3796,6 +3794,8 @@ var _FormControl = class _FormControl extends PureComponent {
|
|
|
3796
3794
|
return /* @__PURE__ */ jsx27(
|
|
3797
3795
|
DateInput,
|
|
3798
3796
|
{
|
|
3797
|
+
dayAutoComplete: this.getAutocompleteValue({ suffix: "-day" }),
|
|
3798
|
+
yearAutoComplete: this.getAutocompleteValue({ suffix: "-year" }),
|
|
3799
3799
|
disabled,
|
|
3800
3800
|
size,
|
|
3801
3801
|
value: getSafeDateOrStringValue(value),
|
|
@@ -8008,7 +8008,7 @@ var th_default = {
|
|
|
8008
8008
|
// src/i18n/tr.json
|
|
8009
8009
|
var tr_default = {
|
|
8010
8010
|
"dynamicFlows.ArraySchema.addItem": "Kaydet",
|
|
8011
|
-
"dynamicFlows.ArraySchema.addItemTitle": "\
|
|
8011
|
+
"dynamicFlows.ArraySchema.addItemTitle": "\xD6ge ekle",
|
|
8012
8012
|
"dynamicFlows.ArraySchema.editItem": "Kaydet",
|
|
8013
8013
|
"dynamicFlows.ArraySchema.maxItemsError": "L\xFCtfen {maxItems} veya daha az ekleme yap\u0131n",
|
|
8014
8014
|
"dynamicFlows.ArraySchema.minItemsError": "L\xFCtfen en az {minItems} ekleme yap\u0131n.",
|
|
@@ -8039,7 +8039,7 @@ var tr_default = {
|
|
|
8039
8039
|
"dynamicFlows.DynamicExternal.retryTitle": "Pencereyi yeniden a\xE7",
|
|
8040
8040
|
"dynamicFlows.DynamicParagraph.copied": "Panoya kopyaland\u0131",
|
|
8041
8041
|
"dynamicFlows.DynamicParagraph.copy": "Kopyala",
|
|
8042
|
-
"dynamicFlows.ErrorBoundary.errorAlert": "Bir
|
|
8042
|
+
"dynamicFlows.ErrorBoundary.errorAlert": "Bir sorun olu\u015Ftu.",
|
|
8043
8043
|
"dynamicFlows.ErrorBoundary.retry": "Tekrar dene",
|
|
8044
8044
|
"dynamicFlows.ExternalConfirmation.cancel": "\u0130ptal edin",
|
|
8045
8045
|
"dynamicFlows.ExternalConfirmation.description": "L\xFCtfen yeni bir taray\u0131c\u0131 sekmesinde **{origin}** a\xE7mak istedi\u011Finizi onaylay\u0131n.",
|
|
@@ -8243,7 +8243,7 @@ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
|
|
|
8243
8243
|
return deterministicId || (id ? `radix-${id}` : "");
|
|
8244
8244
|
}
|
|
8245
8245
|
|
|
8246
|
-
// ../../node_modules/.pnpm/@wise+forms@0.3.
|
|
8246
|
+
// ../../node_modules/.pnpm/@wise+forms@0.3.3_@transferwise+components@46.20.1_@types+react@18.0.29_react@18.2.0/node_modules/@wise/forms/dist/index.esm.js
|
|
8247
8247
|
var import_classnames9 = __toESM(require_classnames());
|
|
8248
8248
|
import { InlineAlert as InlineAlert2, Sentiment as Sentiment2, Input as Input2, TextArea } from "@transferwise/components";
|
|
8249
8249
|
import { createContext as createContext6, useContext as useContext7, forwardRef as forwardRef2 } from "react";
|
|
@@ -8255,11 +8255,13 @@ var FormControlDescribedByProvider = FormControlDescribedByContext.Provider;
|
|
|
8255
8255
|
var FormControlInvalidContext = /* @__PURE__ */ createContext6(void 0);
|
|
8256
8256
|
var FormControlInvalidProvider = FormControlInvalidContext.Provider;
|
|
8257
8257
|
var Label = ({
|
|
8258
|
+
id,
|
|
8258
8259
|
htmlFor,
|
|
8259
8260
|
className,
|
|
8260
8261
|
children
|
|
8261
8262
|
}) => {
|
|
8262
8263
|
return /* @__PURE__ */ jsx74("label", {
|
|
8264
|
+
id,
|
|
8263
8265
|
htmlFor,
|
|
8264
8266
|
className: (0, import_classnames9.default)("control-label d-flex flex-column gap-y-1 m-b-0", className),
|
|
8265
8267
|
children
|
|
@@ -8276,7 +8278,7 @@ var Field = ({
|
|
|
8276
8278
|
const hasError = Boolean(error);
|
|
8277
8279
|
const hasHint = Boolean(hint) && !hasError;
|
|
8278
8280
|
const fallbackInputId = $1746a345f3d73bb7$export$f680877a34711e37();
|
|
8279
|
-
const inputId = id != null ? id : fallbackInputId;
|
|
8281
|
+
const inputId = id !== null ? id != null ? id : fallbackInputId : void 0;
|
|
8280
8282
|
const descriptionId = $1746a345f3d73bb7$export$f680877a34711e37();
|
|
8281
8283
|
return /* @__PURE__ */ jsx74(InputIdContextProvider, {
|
|
8282
8284
|
value: inputId,
|
|
@@ -9978,36 +9980,9 @@ var getWiseRenderers = () => [
|
|
|
9978
9980
|
];
|
|
9979
9981
|
|
|
9980
9982
|
// src/revamp/DynamicFlowCore.tsx
|
|
9981
|
-
import { useCallback as useCallback11, useEffect as
|
|
9983
|
+
import { useCallback as useCallback11, useEffect as useEffect23, useMemo as useMemo18, useRef as useRef9, useState as useState30 } from "react";
|
|
9982
9984
|
import { useIntl as useIntl22 } from "react-intl";
|
|
9983
9985
|
|
|
9984
|
-
// src/revamp/domain/features/events/getAnalyticsEventDispatcher.ts
|
|
9985
|
-
var getAnalyticsEventDispatcher = ({
|
|
9986
|
-
flowId,
|
|
9987
|
-
stepId,
|
|
9988
|
-
analytics,
|
|
9989
|
-
onEvent
|
|
9990
|
-
}) => {
|
|
9991
|
-
const metadata = __spreadValues(__spreadValues({
|
|
9992
|
-
flowId
|
|
9993
|
-
}, stepId ? { stepId } : {}), analytics != null ? analytics : {});
|
|
9994
|
-
return (eventName, properties = {}) => {
|
|
9995
|
-
try {
|
|
9996
|
-
onEvent == null ? void 0 : onEvent(`${eventNamePrefix}${eventName}`, __spreadValues(__spreadValues({}, metadata), properties));
|
|
9997
|
-
} catch (e) {
|
|
9998
|
-
}
|
|
9999
|
-
};
|
|
10000
|
-
};
|
|
10001
|
-
var eventNamePrefix = "Dynamic Flow - ";
|
|
10002
|
-
|
|
10003
|
-
// src/revamp/domain/features/events/getLogggingEventDispatcher.ts
|
|
10004
|
-
var getLoggingEventDispatcher = (onLog) => (level, message, extra = {}) => {
|
|
10005
|
-
try {
|
|
10006
|
-
onLog == null ? void 0 : onLog(level, message, extra);
|
|
10007
|
-
} catch (e) {
|
|
10008
|
-
}
|
|
10009
|
-
};
|
|
10010
|
-
|
|
10011
9986
|
// src/revamp/utils/type-validators.ts
|
|
10012
9987
|
var isString2 = (value) => typeof value === "string";
|
|
10013
9988
|
var isNumber3 = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
@@ -10020,87 +9995,12 @@ var isUndefined3 = (value) => typeof value === "undefined";
|
|
|
10020
9995
|
var isNullish3 = (v) => isNull3(v) || isUndefined3(v);
|
|
10021
9996
|
var isFile = (value) => value instanceof File;
|
|
10022
9997
|
|
|
10023
|
-
// src/revamp/flow/response-utils.ts
|
|
10024
|
-
var assertResponseIsValid2 = (response) => {
|
|
10025
|
-
if (!isResponse2(response)) {
|
|
10026
|
-
throw new Error("Incorrect type of response from fetch. Expected object of type Response.");
|
|
10027
|
-
}
|
|
10028
|
-
if (response.bodyUsed) {
|
|
10029
|
-
throw new Error(
|
|
10030
|
-
"The body of the provided Response object has already been used. Every request must respond with a new Response object."
|
|
10031
|
-
);
|
|
10032
|
-
}
|
|
10033
|
-
};
|
|
10034
|
-
var isResponse2 = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
10035
|
-
var parseResponseBodyAsJsonElement = async (response) => {
|
|
10036
|
-
try {
|
|
10037
|
-
return await response.json();
|
|
10038
|
-
} catch (e) {
|
|
10039
|
-
return null;
|
|
10040
|
-
}
|
|
10041
|
-
};
|
|
10042
|
-
function assertActionResponseBody(body) {
|
|
10043
|
-
if (!isObject2(body) || !isObject2(body.action)) {
|
|
10044
|
-
throw new Error(
|
|
10045
|
-
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
10046
|
-
);
|
|
10047
|
-
}
|
|
10048
|
-
}
|
|
10049
|
-
function isErrorResponseBody(body) {
|
|
10050
|
-
return Boolean(
|
|
10051
|
-
isObject2(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
10052
|
-
);
|
|
10053
|
-
}
|
|
10054
|
-
function assertStepResponseBody(body) {
|
|
10055
|
-
if (!isObject2(body)) {
|
|
10056
|
-
throw new Error("Incorrect response body in step response. Expected an object.");
|
|
10057
|
-
}
|
|
10058
|
-
}
|
|
10059
|
-
|
|
10060
|
-
// src/revamp/flow/executeRefresh.ts
|
|
10061
|
-
var executeRefresh = async (props) => {
|
|
10062
|
-
const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
|
|
10063
|
-
trackEvent("Refresh Triggered", { schema: schemaId });
|
|
10064
|
-
try {
|
|
10065
|
-
const response = await httpClient(url != null ? url : "", {
|
|
10066
|
-
method: "POST",
|
|
10067
|
-
body: JSON.stringify(model),
|
|
10068
|
-
headers: __spreadValues({
|
|
10069
|
-
"Content-Type": "application/json"
|
|
10070
|
-
}, etag ? { "If-None-Match": etag } : {}),
|
|
10071
|
-
signal: abortSignal
|
|
10072
|
-
});
|
|
10073
|
-
if (response.status === 304) {
|
|
10074
|
-
trackEvent("Refresh Succeeded", { schema: schemaId });
|
|
10075
|
-
return { type: "noop" };
|
|
10076
|
-
}
|
|
10077
|
-
if (!response.ok) {
|
|
10078
|
-
const responseBody = await parseResponseBodyAsJsonElement(response).catch(() => ({}));
|
|
10079
|
-
const body2 = isErrorResponseBody(responseBody) ? responseBody : {};
|
|
10080
|
-
trackEvent("Refresh Failed", __spreadValues({ schema: schemaId }, body2.analytics));
|
|
10081
|
-
return { type: "error", body: body2 };
|
|
10082
|
-
}
|
|
10083
|
-
const newEtag = response.headers.get("etag") || null;
|
|
10084
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
10085
|
-
assertStepResponseBody(body);
|
|
10086
|
-
trackEvent("Refresh Succeeded", { schema: schemaId });
|
|
10087
|
-
return { type: "refresh-step", step: body, etag: newEtag };
|
|
10088
|
-
} catch (error) {
|
|
10089
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
10090
|
-
trackEvent("Refresh Aborted", { schema: schemaId });
|
|
10091
|
-
return { type: "noop" };
|
|
10092
|
-
}
|
|
10093
|
-
trackEvent("Refresh Failed", { schema: schemaId });
|
|
10094
|
-
return { type: "error", body: {} };
|
|
10095
|
-
}
|
|
10096
|
-
};
|
|
10097
|
-
|
|
10098
9998
|
// src/revamp/utils/type-utils.ts
|
|
10099
9999
|
var hasChildren = (component) => "getChildren" in component && typeof component.getChildren === "function";
|
|
10100
10000
|
var isColumnsComponent = (component) => Object.hasOwnProperty.call(component, "startComponents") && Object.hasOwnProperty.call(component, "endComponents");
|
|
10101
10001
|
var isHiddenComponent = (component) => "hidden" in component && component.hidden;
|
|
10102
10002
|
var isRepeatableComponent = (component) => Object.hasOwnProperty.call(component, "editableComponent");
|
|
10103
|
-
var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value);
|
|
10003
|
+
var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
10104
10004
|
var isObjectModel2 = (model) => model != null && typeof model === "object" && !Array.isArray(model);
|
|
10105
10005
|
var isArrayModel2 = (model) => Array.isArray(model);
|
|
10106
10006
|
var isAllOfSchema2 = (schema) => "allOf" in schema && !isNullish3(schema.allOf);
|
|
@@ -10147,125 +10047,6 @@ var mergeModels = (valueA, valueB) => {
|
|
|
10147
10047
|
return valueB;
|
|
10148
10048
|
};
|
|
10149
10049
|
|
|
10150
|
-
// src/revamp/flow/getResponseType.ts
|
|
10151
|
-
var responseTypes = ["step", "action", "exit"];
|
|
10152
|
-
var getResponseType = async (response) => {
|
|
10153
|
-
var _a, _b;
|
|
10154
|
-
assertResponseIsValid2(response);
|
|
10155
|
-
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
10156
|
-
const type = response.headers.get("X-Df-Response-Type");
|
|
10157
|
-
assertDFResponseType(type);
|
|
10158
|
-
return type;
|
|
10159
|
-
}
|
|
10160
|
-
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
|
|
10161
|
-
return "exit";
|
|
10162
|
-
}
|
|
10163
|
-
const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
|
|
10164
|
-
if (isObject2(jsonBody) && jsonBody.action) {
|
|
10165
|
-
return "action";
|
|
10166
|
-
}
|
|
10167
|
-
return "step";
|
|
10168
|
-
};
|
|
10169
|
-
function assertDFResponseType(type) {
|
|
10170
|
-
if (!responseTypes.includes(type)) {
|
|
10171
|
-
throw new Error(
|
|
10172
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
10173
|
-
);
|
|
10174
|
-
}
|
|
10175
|
-
}
|
|
10176
|
-
|
|
10177
|
-
// src/revamp/flow/executeSubmission.ts
|
|
10178
|
-
var executeSubmission = async (props) => {
|
|
10179
|
-
const { httpClient, trackEvent } = props;
|
|
10180
|
-
const triggerAction = async (action, model, isInitial) => {
|
|
10181
|
-
const { exit, url, method = "POST", result = null, id: actionId } = action;
|
|
10182
|
-
const trackSubmissionEvent = !isInitial ? trackEvent : () => {
|
|
10183
|
-
};
|
|
10184
|
-
trackSubmissionEvent("Action Triggered", { actionId });
|
|
10185
|
-
if (exit && !url) {
|
|
10186
|
-
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
10187
|
-
return { type: "complete", result };
|
|
10188
|
-
}
|
|
10189
|
-
try {
|
|
10190
|
-
const response = await httpClient(url != null ? url : "", {
|
|
10191
|
-
method,
|
|
10192
|
-
body: method === "GET" ? void 0 : JSON.stringify(model),
|
|
10193
|
-
headers: { "Content-Type": "application/json" }
|
|
10194
|
-
});
|
|
10195
|
-
if (!response.ok) {
|
|
10196
|
-
return await handleErrorResponse(response, actionId);
|
|
10197
|
-
}
|
|
10198
|
-
const responseType = await getResponseType(response);
|
|
10199
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
10200
|
-
if (exit) {
|
|
10201
|
-
return { type: "complete", result: mergeModels(result, body) };
|
|
10202
|
-
}
|
|
10203
|
-
switch (responseType) {
|
|
10204
|
-
case "step": {
|
|
10205
|
-
const etag = response.headers.get("etag") || null;
|
|
10206
|
-
assertStepResponseBody(body);
|
|
10207
|
-
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
10208
|
-
return { type: "replace-step", step: body, etag };
|
|
10209
|
-
}
|
|
10210
|
-
case "exit": {
|
|
10211
|
-
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
10212
|
-
return { type: "complete", result: mergeModels(result, body) };
|
|
10213
|
-
}
|
|
10214
|
-
case "action": {
|
|
10215
|
-
assertActionResponseBody(body);
|
|
10216
|
-
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
10217
|
-
return await triggerAction(body.action, null, false);
|
|
10218
|
-
}
|
|
10219
|
-
default: {
|
|
10220
|
-
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
10221
|
-
}
|
|
10222
|
-
}
|
|
10223
|
-
} catch (error) {
|
|
10224
|
-
trackSubmissionEvent("Action Failed", { actionId });
|
|
10225
|
-
throw error;
|
|
10226
|
-
}
|
|
10227
|
-
};
|
|
10228
|
-
const handleErrorResponse = async (response, actionId) => {
|
|
10229
|
-
const body = await parseResponseBodyAsJsonElement(response);
|
|
10230
|
-
if (isErrorResponseBody(body)) {
|
|
10231
|
-
const refreshUrl = body.refreshUrl || body.refreshFormUrl;
|
|
10232
|
-
const { error, validation, analytics } = body;
|
|
10233
|
-
trackEvent("Action Failed", __spreadValues({ actionId }, analytics));
|
|
10234
|
-
const errors = { error, validation };
|
|
10235
|
-
return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics } };
|
|
10236
|
-
}
|
|
10237
|
-
trackEvent("Action Failed", { actionId });
|
|
10238
|
-
return { type: "error", body: {} };
|
|
10239
|
-
};
|
|
10240
|
-
return triggerAction(props.action, props.model, props.isInitial);
|
|
10241
|
-
};
|
|
10242
|
-
|
|
10243
|
-
// src/revamp/renderers/CoreContainerRenderer.tsx
|
|
10244
|
-
import { Fragment as Fragment23, jsx as jsx116 } from "react/jsx-runtime";
|
|
10245
|
-
var CoreContainerRenderer = {
|
|
10246
|
-
canRenderType: "container",
|
|
10247
|
-
render: ({ children }) => /* @__PURE__ */ jsx116(Fragment23, { children })
|
|
10248
|
-
};
|
|
10249
|
-
|
|
10250
|
-
// src/revamp/renderers/StepRenderer.tsx
|
|
10251
|
-
import { useMemo as useMemo17 } from "react";
|
|
10252
|
-
import { jsx as jsx117 } from "react/jsx-runtime";
|
|
10253
|
-
var StepRenderer = {
|
|
10254
|
-
canRenderType: "step",
|
|
10255
|
-
render: StepRendererComponent
|
|
10256
|
-
};
|
|
10257
|
-
function StepRendererComponent({ children, loadingState }) {
|
|
10258
|
-
const value = useMemo17(() => ({ loadingState }), [loadingState]);
|
|
10259
|
-
return /* @__PURE__ */ jsx117(LoadingContextProvider, { value, children });
|
|
10260
|
-
}
|
|
10261
|
-
|
|
10262
|
-
// src/revamp/step/Step.tsx
|
|
10263
|
-
import { useCallback as useCallback10, useEffect as useEffect23, useRef as useRef8, useState as useState30 } from "react";
|
|
10264
|
-
|
|
10265
|
-
// src/revamp/domain/features/validation/validation-functions.ts
|
|
10266
|
-
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
10267
|
-
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
|
|
10268
|
-
|
|
10269
10050
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
10270
10051
|
var getSummariser = (schema) => (value) => {
|
|
10271
10052
|
const { summary, icon, image } = schema;
|
|
@@ -10302,46 +10083,64 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
|
10302
10083
|
};
|
|
10303
10084
|
};
|
|
10304
10085
|
|
|
10305
|
-
// src/revamp/domain/
|
|
10306
|
-
var
|
|
10307
|
-
|
|
10308
|
-
getChildren() {
|
|
10309
|
-
return this.components;
|
|
10310
|
-
},
|
|
10311
|
-
async getSubmittableValue() {
|
|
10312
|
-
return getSubmittableData(this.components);
|
|
10313
|
-
},
|
|
10314
|
-
getSummary() {
|
|
10315
|
-
return summariseFromChildren(this.getChildren());
|
|
10316
|
-
},
|
|
10317
|
-
getLocalValue() {
|
|
10318
|
-
return getLocalValues(this.components);
|
|
10319
|
-
},
|
|
10320
|
-
validate() {
|
|
10321
|
-
return validateComponents(this.getChildren());
|
|
10322
|
-
}
|
|
10323
|
-
});
|
|
10324
|
-
var createEmptyStepComponent = () => createStepComponent({
|
|
10325
|
-
uid: "",
|
|
10326
|
-
loadingState: "idle",
|
|
10327
|
-
components: []
|
|
10328
|
-
});
|
|
10086
|
+
// src/revamp/domain/features/validation/validation-functions.ts
|
|
10087
|
+
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
10088
|
+
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
|
|
10329
10089
|
|
|
10330
|
-
// src/revamp/domain/components/
|
|
10331
|
-
var
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
// Noop
|
|
10338
|
-
validate: () => true
|
|
10339
|
-
});
|
|
10090
|
+
// src/revamp/domain/components/utils/component-utils.ts
|
|
10091
|
+
var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
10092
|
+
updateComponent(uid, (draft) => {
|
|
10093
|
+
const draftState = draft;
|
|
10094
|
+
updateFn(draftState);
|
|
10095
|
+
});
|
|
10096
|
+
};
|
|
10340
10097
|
|
|
10341
|
-
// src/revamp/domain/
|
|
10342
|
-
var
|
|
10343
|
-
|
|
10344
|
-
|
|
10098
|
+
// src/revamp/domain/components/StepDomainComponent.ts
|
|
10099
|
+
var createStepComponent = (stepProps) => {
|
|
10100
|
+
const _a = stepProps, { uid, updateComponent } = _a, rest = __objRest(_a, ["uid", "updateComponent"]);
|
|
10101
|
+
const update = getInputUpdateFunction(uid, updateComponent);
|
|
10102
|
+
return __spreadProps(__spreadValues({
|
|
10103
|
+
uid
|
|
10104
|
+
}, rest), {
|
|
10105
|
+
type: "step",
|
|
10106
|
+
getChildren() {
|
|
10107
|
+
return this.components;
|
|
10108
|
+
},
|
|
10109
|
+
async getSubmittableValue() {
|
|
10110
|
+
return getSubmittableData(this.components);
|
|
10111
|
+
},
|
|
10112
|
+
getSummary() {
|
|
10113
|
+
return summariseFromChildren(this.getChildren());
|
|
10114
|
+
},
|
|
10115
|
+
getLocalValue() {
|
|
10116
|
+
return getLocalValues(this.components);
|
|
10117
|
+
},
|
|
10118
|
+
validate() {
|
|
10119
|
+
return validateComponents(this.getChildren());
|
|
10120
|
+
},
|
|
10121
|
+
setLoadingState(loadingState) {
|
|
10122
|
+
update((draft) => {
|
|
10123
|
+
draft.loadingState = loadingState;
|
|
10124
|
+
});
|
|
10125
|
+
}
|
|
10126
|
+
});
|
|
10127
|
+
};
|
|
10128
|
+
|
|
10129
|
+
// src/revamp/domain/components/AlertComponent.ts
|
|
10130
|
+
var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
|
|
10131
|
+
type: "alert"
|
|
10132
|
+
}, alertProps), {
|
|
10133
|
+
getSubmittableValue: async () => null,
|
|
10134
|
+
getLocalValue: () => null,
|
|
10135
|
+
getSummary: () => ({}),
|
|
10136
|
+
// Noop
|
|
10137
|
+
validate: () => true
|
|
10138
|
+
});
|
|
10139
|
+
|
|
10140
|
+
// src/revamp/domain/mappers/utils/legacy-utils.ts
|
|
10141
|
+
var mapLegacyContext = (context) => {
|
|
10142
|
+
switch (context) {
|
|
10143
|
+
case "success":
|
|
10345
10144
|
return "positive";
|
|
10346
10145
|
case "failure":
|
|
10347
10146
|
return "negative";
|
|
@@ -10582,14 +10381,6 @@ var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
|
10582
10381
|
// src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
10583
10382
|
var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
|
|
10584
10383
|
|
|
10585
|
-
// src/revamp/domain/components/utils/component-utils.ts
|
|
10586
|
-
var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
10587
|
-
updateComponent(uid, (draft) => {
|
|
10588
|
-
const draftState = draft;
|
|
10589
|
-
updateFn(draftState);
|
|
10590
|
-
});
|
|
10591
|
-
};
|
|
10592
|
-
|
|
10593
10384
|
// src/revamp/domain/features/utils/http-utils.ts
|
|
10594
10385
|
function constructPayload({
|
|
10595
10386
|
value,
|
|
@@ -11041,6 +10832,43 @@ var autocompleteTokenMap2 = {
|
|
|
11041
10832
|
pager: "pager"
|
|
11042
10833
|
};
|
|
11043
10834
|
|
|
10835
|
+
// src/revamp/flow/response-utils.ts
|
|
10836
|
+
var assertResponseIsValid2 = (response) => {
|
|
10837
|
+
if (!isResponse2(response)) {
|
|
10838
|
+
throw new Error("Incorrect type of response from fetch. Expected object of type Response.");
|
|
10839
|
+
}
|
|
10840
|
+
if (response.bodyUsed) {
|
|
10841
|
+
throw new Error(
|
|
10842
|
+
"The body of the provided Response object has already been used. Every request must respond with a new Response object."
|
|
10843
|
+
);
|
|
10844
|
+
}
|
|
10845
|
+
};
|
|
10846
|
+
var isResponse2 = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
10847
|
+
var parseResponseBodyAsJsonElement = async (response) => {
|
|
10848
|
+
try {
|
|
10849
|
+
return await response.json();
|
|
10850
|
+
} catch (e) {
|
|
10851
|
+
return null;
|
|
10852
|
+
}
|
|
10853
|
+
};
|
|
10854
|
+
function assertActionResponseBody(body) {
|
|
10855
|
+
if (!isObject2(body) || !isObject2(body.action)) {
|
|
10856
|
+
throw new Error(
|
|
10857
|
+
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
10858
|
+
);
|
|
10859
|
+
}
|
|
10860
|
+
}
|
|
10861
|
+
function isErrorResponseBody(body) {
|
|
10862
|
+
return Boolean(
|
|
10863
|
+
isObject2(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
10864
|
+
);
|
|
10865
|
+
}
|
|
10866
|
+
function assertStepResponseBody(body) {
|
|
10867
|
+
if (!isObject2(body)) {
|
|
10868
|
+
throw new Error("Incorrect response body in step response. Expected an object.");
|
|
10869
|
+
}
|
|
10870
|
+
}
|
|
10871
|
+
|
|
11044
10872
|
// src/revamp/domain/features/utils/response-utils.ts
|
|
11045
10873
|
var getAnalyticsFromErrorResponse = (json) => {
|
|
11046
10874
|
if (!isErrorResponseBody(json)) {
|
|
@@ -11583,6 +11411,22 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
11583
11411
|
);
|
|
11584
11412
|
};
|
|
11585
11413
|
|
|
11414
|
+
// src/revamp/domain/components/utils/getComponentForLocalValueKey.ts
|
|
11415
|
+
var getComponentForLocalValueKey = (key, component) => {
|
|
11416
|
+
if (component.type === "object") {
|
|
11417
|
+
return component.componentMap[key];
|
|
11418
|
+
}
|
|
11419
|
+
if (component.type === "select") {
|
|
11420
|
+
const selectedChild = component.getSelectedChild();
|
|
11421
|
+
return selectedChild ? getComponentForLocalValueKey(key, selectedChild) : null;
|
|
11422
|
+
}
|
|
11423
|
+
const child = hasChildren(component) ? [...component.getChildren()].reverse().find((c) => {
|
|
11424
|
+
const v = c.getLocalValue();
|
|
11425
|
+
return isObjectLocalValue(v) && key in v;
|
|
11426
|
+
}) : void 0;
|
|
11427
|
+
return child ? getComponentForLocalValueKey(key, child) : null;
|
|
11428
|
+
};
|
|
11429
|
+
|
|
11586
11430
|
// src/revamp/domain/components/utils/isPartialLocalValueMatch.ts
|
|
11587
11431
|
var isPartialLocalValueMatch = (partialValue, component) => {
|
|
11588
11432
|
if (isArray2(partialValue) && component.type === "repeatable") {
|
|
@@ -11592,18 +11436,19 @@ var isPartialLocalValueMatch = (partialValue, component) => {
|
|
|
11592
11436
|
return childComponent ? isPartialLocalValueMatch(value, childComponent) : false;
|
|
11593
11437
|
});
|
|
11594
11438
|
}
|
|
11595
|
-
|
|
11439
|
+
const componentValue = component.getLocalValue();
|
|
11440
|
+
if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
|
|
11596
11441
|
const allKeys = Array.from(
|
|
11597
|
-
/* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(
|
|
11442
|
+
/* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(componentValue)])
|
|
11598
11443
|
);
|
|
11599
11444
|
const matchingKeys = allKeys.filter(
|
|
11600
|
-
(key) => !isNullish3(partialValue[key]) && !isNullish3(
|
|
11601
|
-
);
|
|
11602
|
-
return matchingKeys.every(
|
|
11603
|
-
(key) => isPartialLocalValueMatch(partialValue[key], component.componentMap[key])
|
|
11445
|
+
(key) => !isNullish3(partialValue[key]) && !isNullish3(componentValue[key])
|
|
11604
11446
|
);
|
|
11447
|
+
return matchingKeys.every((key) => {
|
|
11448
|
+
const componentForKey = getComponentForLocalValueKey(key, component);
|
|
11449
|
+
return componentForKey ? isPartialLocalValueMatch(partialValue[key], componentForKey) : false;
|
|
11450
|
+
});
|
|
11605
11451
|
}
|
|
11606
|
-
const componentValue = component.getLocalValue();
|
|
11607
11452
|
if (partialValue instanceof File && componentValue instanceof File) {
|
|
11608
11453
|
return areEquivalentFiles(partialValue, componentValue);
|
|
11609
11454
|
}
|
|
@@ -13242,9 +13087,47 @@ var mapStepToComponent = (_a) => {
|
|
|
13242
13087
|
"loadingState",
|
|
13243
13088
|
"displayStepTitle"
|
|
13244
13089
|
]);
|
|
13245
|
-
|
|
13090
|
+
var _a2;
|
|
13091
|
+
const { step, updateComponent } = mapperProps;
|
|
13092
|
+
const { id, key, layout = [] } = step;
|
|
13093
|
+
const refreshUrl = (_a2 = step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
13246
13094
|
const stepId = id || key;
|
|
13095
|
+
if (stepId === void 0) {
|
|
13096
|
+
throw new Error("Step must have an id or a key");
|
|
13097
|
+
}
|
|
13247
13098
|
const uid = stepId != null ? stepId : "step";
|
|
13099
|
+
const onAction = async (action) => {
|
|
13100
|
+
try {
|
|
13101
|
+
await stepComponent.getSubmittableValue();
|
|
13102
|
+
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
13103
|
+
const canSubmit = skipValidation || stepComponent.validate();
|
|
13104
|
+
if (canSubmit) {
|
|
13105
|
+
void mapperProps.onAction(action);
|
|
13106
|
+
}
|
|
13107
|
+
} catch (e) {
|
|
13108
|
+
if (true) {
|
|
13109
|
+
console.log("\u274C:", "Failed to get submittable data");
|
|
13110
|
+
}
|
|
13111
|
+
}
|
|
13112
|
+
};
|
|
13113
|
+
const onRefresh = async (schemaId, url) => mapperProps.onRefresh(schemaId, url != null ? url : refreshUrl);
|
|
13114
|
+
const layoutComponents = layout.map(
|
|
13115
|
+
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, __spreadProps(__spreadValues({}, mapperProps), {
|
|
13116
|
+
onAction,
|
|
13117
|
+
onRefresh
|
|
13118
|
+
}))
|
|
13119
|
+
);
|
|
13120
|
+
const additionalComponents = makeAdditionalComponents(mapperProps.step, uid, displayStepTitle);
|
|
13121
|
+
const stepComponent = createStepComponent({
|
|
13122
|
+
uid,
|
|
13123
|
+
loadingState,
|
|
13124
|
+
components: [...additionalComponents, ...layoutComponents],
|
|
13125
|
+
updateComponent
|
|
13126
|
+
});
|
|
13127
|
+
return stepComponent;
|
|
13128
|
+
};
|
|
13129
|
+
var makeAdditionalComponents = (step, uid, displayStepTitle) => {
|
|
13130
|
+
const { title, errors } = step;
|
|
13248
13131
|
const heading = title && displayStepTitle ? headingLayoutToComponent(`${uid}.title`, {
|
|
13249
13132
|
type: "heading",
|
|
13250
13133
|
text: title,
|
|
@@ -13256,144 +13139,158 @@ var mapStepToComponent = (_a) => {
|
|
|
13256
13139
|
markdown: errors.error,
|
|
13257
13140
|
context: "negative"
|
|
13258
13141
|
}) : void 0;
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13142
|
+
return [...heading ? [heading] : [], ...stepError ? [stepError] : []];
|
|
13143
|
+
};
|
|
13144
|
+
|
|
13145
|
+
// src/revamp/flow/executeRefresh.ts
|
|
13146
|
+
var executeRefresh = async (props) => {
|
|
13147
|
+
const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
|
|
13148
|
+
trackEvent("Refresh Triggered", { schema: schemaId });
|
|
13149
|
+
try {
|
|
13150
|
+
const response = await httpClient(url != null ? url : "", {
|
|
13151
|
+
method: "POST",
|
|
13152
|
+
body: JSON.stringify(model),
|
|
13153
|
+
headers: __spreadValues({
|
|
13154
|
+
"Content-Type": "application/json"
|
|
13155
|
+
}, etag ? { "If-None-Match": etag } : {}),
|
|
13156
|
+
signal: abortSignal
|
|
13157
|
+
});
|
|
13158
|
+
if (response.status === 304) {
|
|
13159
|
+
trackEvent("Refresh Succeeded", { schema: schemaId });
|
|
13160
|
+
return { type: "noop" };
|
|
13161
|
+
}
|
|
13162
|
+
if (!response.ok) {
|
|
13163
|
+
const responseBody = await parseResponseBodyAsJsonElement(response).catch(() => ({}));
|
|
13164
|
+
const body2 = isErrorResponseBody(responseBody) ? responseBody : {};
|
|
13165
|
+
trackEvent("Refresh Failed", __spreadValues({ schema: schemaId }, body2.analytics));
|
|
13166
|
+
return { type: "error", body: body2 };
|
|
13167
|
+
}
|
|
13168
|
+
const newEtag = response.headers.get("etag") || null;
|
|
13169
|
+
const body = await parseResponseBodyAsJsonElement(response);
|
|
13170
|
+
assertStepResponseBody(body);
|
|
13171
|
+
trackEvent("Refresh Succeeded", { schema: schemaId });
|
|
13172
|
+
return { type: "refresh-step", step: body, etag: newEtag };
|
|
13173
|
+
} catch (error) {
|
|
13174
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
13175
|
+
trackEvent("Refresh Aborted", { schema: schemaId });
|
|
13176
|
+
return { type: "noop" };
|
|
13177
|
+
}
|
|
13178
|
+
trackEvent("Refresh Failed", { schema: schemaId });
|
|
13179
|
+
return { type: "error", body: {} };
|
|
13265
13180
|
}
|
|
13266
|
-
return createStepComponent({
|
|
13267
|
-
uid,
|
|
13268
|
-
loadingState,
|
|
13269
|
-
components: [...additionalComponents, ...layoutComponents]
|
|
13270
|
-
});
|
|
13271
13181
|
};
|
|
13272
13182
|
|
|
13273
|
-
// src/revamp/
|
|
13274
|
-
var
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13183
|
+
// src/revamp/flow/getResponseType.ts
|
|
13184
|
+
var responseTypes = ["step", "action", "exit"];
|
|
13185
|
+
var getResponseType = async (response) => {
|
|
13186
|
+
var _a, _b;
|
|
13187
|
+
assertResponseIsValid2(response);
|
|
13188
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
13189
|
+
const type = response.headers.get("X-Df-Response-Type");
|
|
13190
|
+
assertDFResponseType(type);
|
|
13191
|
+
return type;
|
|
13279
13192
|
}
|
|
13280
|
-
if (
|
|
13281
|
-
|
|
13193
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
|
|
13194
|
+
return "exit";
|
|
13282
13195
|
}
|
|
13283
|
-
|
|
13196
|
+
const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
|
|
13197
|
+
if (isObject2(jsonBody) && jsonBody.action) {
|
|
13198
|
+
return "action";
|
|
13199
|
+
}
|
|
13200
|
+
return "step";
|
|
13284
13201
|
};
|
|
13285
|
-
|
|
13286
|
-
if (
|
|
13287
|
-
|
|
13202
|
+
function assertDFResponseType(type) {
|
|
13203
|
+
if (!responseTypes.includes(type)) {
|
|
13204
|
+
throw new Error(
|
|
13205
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
13206
|
+
);
|
|
13288
13207
|
}
|
|
13289
|
-
|
|
13290
|
-
}, []);
|
|
13208
|
+
}
|
|
13291
13209
|
|
|
13292
|
-
// src/revamp/
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
const [stepComponent, setStepComponent] = useState30(emptyStepComponent);
|
|
13310
|
-
const stepComponentRef = useRef8(emptyStepComponent);
|
|
13311
|
-
const updateComponent = useCallback10(
|
|
13312
|
-
(id, update) => {
|
|
13313
|
-
update(findComponent([stepComponentRef.current], id));
|
|
13314
|
-
setStepComponent(() => {
|
|
13315
|
-
const newStepDomainComponent = __spreadValues({}, stepComponentRef.current);
|
|
13316
|
-
stepComponentRef.current = newStepDomainComponent;
|
|
13317
|
-
return newStepDomainComponent;
|
|
13210
|
+
// src/revamp/flow/executeSubmission.ts
|
|
13211
|
+
var executeSubmission = async (props) => {
|
|
13212
|
+
const { httpClient, trackEvent } = props;
|
|
13213
|
+
const triggerAction = async (action, model, isInitial) => {
|
|
13214
|
+
const { exit, url, method = "POST", result = null, id: actionId } = action;
|
|
13215
|
+
const trackSubmissionEvent = !isInitial ? trackEvent : () => {
|
|
13216
|
+
};
|
|
13217
|
+
trackSubmissionEvent("Action Triggered", { actionId });
|
|
13218
|
+
if (exit && !url) {
|
|
13219
|
+
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
13220
|
+
return { type: "complete", result };
|
|
13221
|
+
}
|
|
13222
|
+
try {
|
|
13223
|
+
const response = await httpClient(url != null ? url : "", {
|
|
13224
|
+
method,
|
|
13225
|
+
body: method === "GET" ? void 0 : JSON.stringify(model),
|
|
13226
|
+
headers: { "Content-Type": "application/json" }
|
|
13318
13227
|
});
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
);
|
|
13322
|
-
useEffect23(() => {
|
|
13323
|
-
setStepComponent(() => {
|
|
13324
|
-
const newStepDomainComponent = __spreadProps(__spreadValues({}, stepComponentRef.current), { loadingState });
|
|
13325
|
-
stepComponentRef.current = newStepDomainComponent;
|
|
13326
|
-
return newStepDomainComponent;
|
|
13327
|
-
});
|
|
13328
|
-
}, [loadingState]);
|
|
13329
|
-
const onAction = useCallback10(
|
|
13330
|
-
async (action) => {
|
|
13331
|
-
var _a2;
|
|
13332
|
-
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
13333
|
-
const canSubmit = skipValidation || stepComponentRef.current.validate();
|
|
13334
|
-
if (canSubmit) {
|
|
13335
|
-
try {
|
|
13336
|
-
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13337
|
-
const payload = mergeModels(model, (_a2 = action.data) != null ? _a2 : null);
|
|
13338
|
-
const localValue = stepComponentRef.current.getLocalValue();
|
|
13339
|
-
void triggerSubmission(action, payload, localValue);
|
|
13340
|
-
} catch (e) {
|
|
13341
|
-
if (true) {
|
|
13342
|
-
console.log("\u274C:", "Failed to get submittable data");
|
|
13343
|
-
}
|
|
13344
|
-
}
|
|
13228
|
+
if (!response.ok) {
|
|
13229
|
+
return await handleErrorResponse(response, actionId);
|
|
13345
13230
|
}
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
async (schemaId, url) => {
|
|
13351
|
-
var _a2;
|
|
13352
|
-
const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
13353
|
-
if (refreshUrl) {
|
|
13354
|
-
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13355
|
-
const localValue = stepComponentRef.current.getLocalValue();
|
|
13356
|
-
void triggerRefresh({ refreshUrl, model, localValue, schemaId });
|
|
13231
|
+
const responseType = await getResponseType(response);
|
|
13232
|
+
const body = await parseResponseBodyAsJsonElement(response);
|
|
13233
|
+
if (exit) {
|
|
13234
|
+
return { type: "complete", result: mergeModels(result, body) };
|
|
13357
13235
|
}
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13236
|
+
switch (responseType) {
|
|
13237
|
+
case "step": {
|
|
13238
|
+
const etag = response.headers.get("etag") || null;
|
|
13239
|
+
assertStepResponseBody(body);
|
|
13240
|
+
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
13241
|
+
return { type: "replace-step", step: body, etag };
|
|
13242
|
+
}
|
|
13243
|
+
case "exit": {
|
|
13244
|
+
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
13245
|
+
return { type: "complete", result: mergeModels(result, body) };
|
|
13246
|
+
}
|
|
13247
|
+
case "action": {
|
|
13248
|
+
assertActionResponseBody(body);
|
|
13249
|
+
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
13250
|
+
return await triggerAction(body.action, null, false);
|
|
13251
|
+
}
|
|
13252
|
+
default: {
|
|
13253
|
+
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
13254
|
+
}
|
|
13255
|
+
}
|
|
13256
|
+
} catch (error) {
|
|
13257
|
+
trackSubmissionEvent("Action Failed", { actionId });
|
|
13258
|
+
throw error;
|
|
13379
13259
|
}
|
|
13380
|
-
}
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13260
|
+
};
|
|
13261
|
+
const handleErrorResponse = async (response, actionId) => {
|
|
13262
|
+
const body = await parseResponseBodyAsJsonElement(response);
|
|
13263
|
+
if (isErrorResponseBody(body)) {
|
|
13264
|
+
const refreshUrl = body.refreshUrl || body.refreshFormUrl;
|
|
13265
|
+
const { error, validation, analytics } = body;
|
|
13266
|
+
trackEvent("Action Failed", __spreadValues({ actionId }, analytics));
|
|
13267
|
+
const errors = { error, validation };
|
|
13268
|
+
return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics } };
|
|
13269
|
+
}
|
|
13270
|
+
trackEvent("Action Failed", { actionId });
|
|
13271
|
+
return { type: "error", body: {} };
|
|
13272
|
+
};
|
|
13273
|
+
return triggerAction(props.action, props.model, props.isInitial);
|
|
13274
|
+
};
|
|
13275
|
+
|
|
13276
|
+
// src/revamp/renderers/CoreContainerRenderer.tsx
|
|
13277
|
+
import { Fragment as Fragment23, jsx as jsx116 } from "react/jsx-runtime";
|
|
13278
|
+
var CoreContainerRenderer = {
|
|
13279
|
+
canRenderType: "container",
|
|
13280
|
+
render: ({ children }) => /* @__PURE__ */ jsx116(Fragment23, { children })
|
|
13281
|
+
};
|
|
13282
|
+
|
|
13283
|
+
// src/revamp/renderers/StepRenderer.tsx
|
|
13284
|
+
import { useMemo as useMemo17 } from "react";
|
|
13285
|
+
import { jsx as jsx117 } from "react/jsx-runtime";
|
|
13286
|
+
var StepRenderer = {
|
|
13287
|
+
canRenderType: "step",
|
|
13288
|
+
render: StepRendererComponent
|
|
13289
|
+
};
|
|
13290
|
+
function StepRendererComponent({ children, loadingState }) {
|
|
13291
|
+
const value = useMemo17(() => ({ loadingState }), [loadingState]);
|
|
13292
|
+
return /* @__PURE__ */ jsx117(LoadingContextProvider, { value, children });
|
|
13395
13293
|
}
|
|
13396
|
-
var Step_default = Step;
|
|
13397
13294
|
|
|
13398
13295
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
13399
13296
|
var stepComponentToProps = ({ loadingState }, children) => ({
|
|
@@ -13887,8 +13784,8 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
13887
13784
|
}
|
|
13888
13785
|
};
|
|
13889
13786
|
|
|
13890
|
-
// src/revamp/
|
|
13891
|
-
import { jsx as
|
|
13787
|
+
// src/revamp/renderers/getRenderFunction.tsx
|
|
13788
|
+
import { jsx as jsx118 } from "react/jsx-runtime";
|
|
13892
13789
|
var getRenderFunction = (renderers2) => {
|
|
13893
13790
|
function ComponentRenderer(props) {
|
|
13894
13791
|
const { type } = props;
|
|
@@ -13927,7 +13824,7 @@ var getRenderFunction = (renderers2) => {
|
|
|
13927
13824
|
children: component.getChildren().map(render)
|
|
13928
13825
|
};
|
|
13929
13826
|
};
|
|
13930
|
-
const render = (component) => /* @__PURE__ */
|
|
13827
|
+
const render = (component) => /* @__PURE__ */ jsx118(
|
|
13931
13828
|
ComponentRenderer,
|
|
13932
13829
|
__spreadValues({}, componentToRendererProps(component, getNestedContent(component))),
|
|
13933
13830
|
component.uid
|
|
@@ -13935,7 +13832,7 @@ var getRenderFunction = (renderers2) => {
|
|
|
13935
13832
|
return render;
|
|
13936
13833
|
};
|
|
13937
13834
|
|
|
13938
|
-
// src/revamp/
|
|
13835
|
+
// src/revamp/renderers/getSchemaErrorMessageFunction.ts
|
|
13939
13836
|
import { formatDate as formatDate3 } from "@transferwise/formatting";
|
|
13940
13837
|
function getSchemaErrorMessageFunction(formatMessage, locale) {
|
|
13941
13838
|
return (validationMessages) => createErrorMessageFunctions(validationMessages != null ? validationMessages : {}, formatMessage, locale);
|
|
@@ -14021,196 +13918,250 @@ var formatDateOptions = {
|
|
|
14021
13918
|
dateStyle: "long"
|
|
14022
13919
|
};
|
|
14023
13920
|
|
|
13921
|
+
// src/revamp/utils/findComponent.ts
|
|
13922
|
+
var findComponent = (components, id) => {
|
|
13923
|
+
const flattened = flattenComponents(components);
|
|
13924
|
+
const matching = flattened.filter((component) => component.uid === id);
|
|
13925
|
+
if (matching.length === 1) {
|
|
13926
|
+
return matching[0];
|
|
13927
|
+
}
|
|
13928
|
+
if (matching.length > 1) {
|
|
13929
|
+
throw new Error(`Multiple components with the same uid: ${id}`);
|
|
13930
|
+
}
|
|
13931
|
+
throw new Error(`Failed to find any components with uid: ${id}`);
|
|
13932
|
+
};
|
|
13933
|
+
var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
13934
|
+
if (hasChildren(component)) {
|
|
13935
|
+
return [...acc, component, ...flattenComponents(component.getChildren())];
|
|
13936
|
+
}
|
|
13937
|
+
return [...acc, component];
|
|
13938
|
+
}, []);
|
|
13939
|
+
|
|
13940
|
+
// src/revamp/utils/useStableCallback.tsx
|
|
13941
|
+
import { useCallback as useCallback10, useLayoutEffect, useRef as useRef8 } from "react";
|
|
13942
|
+
function useStableCallback(handler) {
|
|
13943
|
+
const ref = useRef8(handler);
|
|
13944
|
+
useLayoutEffect(() => {
|
|
13945
|
+
ref.current = handler;
|
|
13946
|
+
});
|
|
13947
|
+
return useCallback10((...args) => ref.current ? ref.current(...args) : null, []);
|
|
13948
|
+
}
|
|
13949
|
+
|
|
14024
13950
|
// src/revamp/DynamicFlowCore.tsx
|
|
14025
|
-
import { jsx as
|
|
13951
|
+
import { jsx as jsx119 } from "react/jsx-runtime";
|
|
14026
13952
|
function DynamicFlowCore(props) {
|
|
14027
|
-
|
|
14028
|
-
const
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
initialStep,
|
|
14034
|
-
renderers: renderers2,
|
|
14035
|
-
onCompletion,
|
|
14036
|
-
onError,
|
|
14037
|
-
onEvent,
|
|
14038
|
-
onLog
|
|
14039
|
-
} = props;
|
|
13953
|
+
const _a = props, { flowId, initialAction, initialStep, renderers: renderers2, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "renderers", "displayStepTitle"]);
|
|
13954
|
+
const httpClient = useStableCallback(rest.httpClient);
|
|
13955
|
+
const onCompletion = useStableCallback(rest.onCompletion);
|
|
13956
|
+
const onError = useStableCallback(rest.onError);
|
|
13957
|
+
const onEvent = useStableCallback(rest.onEvent);
|
|
13958
|
+
const onLog = useStableCallback(rest.onLog);
|
|
14040
13959
|
const { formatMessage, locale } = useIntl22();
|
|
14041
13960
|
const getErrorMessageFunctions = useMemo18(
|
|
14042
13961
|
() => getSchemaErrorMessageFunction(formatMessage, locale),
|
|
14043
13962
|
[formatMessage, locale]
|
|
14044
13963
|
);
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
}
|
|
14050
|
-
}, []);
|
|
14051
|
-
const [step, setStep] = useState31(initialStep != null ? initialStep : null);
|
|
14052
|
-
const localValueRef = useRef9(null);
|
|
14053
|
-
const [etag, setEtag] = useState31(null);
|
|
13964
|
+
const [stepComponent, setStepComponent] = useState30(null);
|
|
13965
|
+
const stepComponentRef = useRef9(null);
|
|
13966
|
+
const stepRef = useRef9(initialStep != null ? initialStep : null);
|
|
13967
|
+
const etagRef = useRef9(null);
|
|
14054
13968
|
const abortControllerRef = useRef9(new AbortController());
|
|
14055
|
-
const [loadingState, setLoadingState] = useState31(initialStep ? "idle" : "loading");
|
|
14056
13969
|
const abortCurrentAndGetNewAbortSignal = () => {
|
|
14057
13970
|
abortControllerRef.current.abort();
|
|
14058
13971
|
abortControllerRef.current = new AbortController();
|
|
14059
13972
|
return abortControllerRef.current.signal;
|
|
14060
13973
|
};
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
13974
|
+
useEffect23(() => {
|
|
13975
|
+
trackEvent("Flow Started");
|
|
13976
|
+
if (!initialStep && initialAction) {
|
|
13977
|
+
void onAction(initialAction);
|
|
13978
|
+
}
|
|
13979
|
+
if (initialStep && !initialAction) {
|
|
13980
|
+
initialiseWithStep(initialStep, null);
|
|
13981
|
+
trackEvent("Step Shown");
|
|
13982
|
+
}
|
|
13983
|
+
}, []);
|
|
13984
|
+
const initialiseWithStep = useCallback11(
|
|
13985
|
+
(newStep, etag) => {
|
|
13986
|
+
var _a2, _b;
|
|
13987
|
+
stepRef.current = newStep;
|
|
13988
|
+
etagRef.current = etag;
|
|
13989
|
+
const updateComponent = (id, update) => {
|
|
13990
|
+
const currentStepComponent = stepComponentRef.current;
|
|
13991
|
+
if (currentStepComponent) {
|
|
13992
|
+
update(findComponent([currentStepComponent], id));
|
|
13993
|
+
setStepComponent(() => {
|
|
13994
|
+
const newStepDomainComponent = __spreadValues({}, currentStepComponent);
|
|
13995
|
+
stepComponentRef.current = newStepDomainComponent;
|
|
13996
|
+
return newStepDomainComponent;
|
|
13997
|
+
});
|
|
13998
|
+
}
|
|
13999
|
+
};
|
|
14000
|
+
try {
|
|
14001
|
+
const newStepComponent = mapStepToComponent({
|
|
14002
|
+
stepLocalValue: (_b = (_a2 = stepComponentRef.current) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null,
|
|
14003
|
+
step: newStep,
|
|
14004
|
+
displayStepTitle,
|
|
14005
|
+
loadingState: "idle",
|
|
14006
|
+
updateComponent,
|
|
14007
|
+
getErrorMessageFunctions,
|
|
14008
|
+
trackEvent,
|
|
14009
|
+
logEvent,
|
|
14010
|
+
httpClient,
|
|
14011
|
+
onAction,
|
|
14012
|
+
onRefresh
|
|
14013
|
+
});
|
|
14014
|
+
setStepComponent(() => {
|
|
14015
|
+
stepComponentRef.current = newStepComponent;
|
|
14016
|
+
return newStepComponent;
|
|
14017
|
+
});
|
|
14018
|
+
} catch (error) {
|
|
14019
|
+
closeWithError(error);
|
|
14020
|
+
}
|
|
14021
|
+
},
|
|
14065
14022
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14066
|
-
[
|
|
14023
|
+
[]
|
|
14024
|
+
);
|
|
14025
|
+
const trackEvent = useCallback11(
|
|
14026
|
+
(eventName, properties) => {
|
|
14027
|
+
var _a2, _b, _c, _d;
|
|
14028
|
+
const stepId = (_c = (_a2 = stepRef.current) == null ? void 0 : _a2.id) != null ? _c : (_b = stepRef.current) == null ? void 0 : _b.key;
|
|
14029
|
+
const analytics = (_d = stepRef.current) == null ? void 0 : _d.analytics;
|
|
14030
|
+
const metadata = __spreadValues(__spreadValues(__spreadValues({
|
|
14031
|
+
flowId
|
|
14032
|
+
}, stepId ? { stepId } : {}), analytics), properties);
|
|
14033
|
+
try {
|
|
14034
|
+
onEvent == null ? void 0 : onEvent(`Dynamic Flow - ${eventName}`, __spreadValues({}, metadata));
|
|
14035
|
+
} catch (e) {
|
|
14036
|
+
}
|
|
14037
|
+
},
|
|
14038
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14039
|
+
[]
|
|
14040
|
+
);
|
|
14041
|
+
const logEvent = useCallback11(
|
|
14042
|
+
(level, message, properties) => {
|
|
14043
|
+
try {
|
|
14044
|
+
onLog == null ? void 0 : onLog(level, message, properties != null ? properties : {});
|
|
14045
|
+
} catch (e) {
|
|
14046
|
+
}
|
|
14047
|
+
},
|
|
14048
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14049
|
+
[]
|
|
14067
14050
|
);
|
|
14068
|
-
const logEvent = useMemo18(() => getLoggingEventDispatcher(onLog), [onLog]);
|
|
14069
|
-
useEffect24(() => trackEvent("Flow Started"), []);
|
|
14070
14051
|
const closeWithError = useCallback11(
|
|
14071
14052
|
(error, analytics) => {
|
|
14072
14053
|
trackEvent("Flow Failed", __spreadValues({}, analytics));
|
|
14073
14054
|
onError(error);
|
|
14074
14055
|
},
|
|
14075
|
-
|
|
14056
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14057
|
+
[]
|
|
14076
14058
|
);
|
|
14077
|
-
const
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
const { errors = { error: genericErrorMessage } } = command.body;
|
|
14109
|
-
if (step) {
|
|
14110
|
-
setStep(__spreadProps(__spreadValues({}, step), { errors }));
|
|
14111
|
-
} else {
|
|
14112
|
-
closeWithError(new Error("Initial request failed"), {});
|
|
14113
|
-
}
|
|
14114
|
-
break;
|
|
14059
|
+
const onAction = useCallback11(async (action) => {
|
|
14060
|
+
var _a2, _b, _c, _d, _e;
|
|
14061
|
+
try {
|
|
14062
|
+
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
|
|
14063
|
+
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
14064
|
+
const payload = mergeModels(model, (_d = action.data) != null ? _d : null);
|
|
14065
|
+
const command = await executeSubmission({
|
|
14066
|
+
action,
|
|
14067
|
+
model: payload,
|
|
14068
|
+
isInitial: stepRef.current === null,
|
|
14069
|
+
httpClient,
|
|
14070
|
+
trackEvent
|
|
14071
|
+
});
|
|
14072
|
+
switch (command.type) {
|
|
14073
|
+
case "complete": {
|
|
14074
|
+
onCompletion(command.result);
|
|
14075
|
+
trackEvent("Flow Succeeded");
|
|
14076
|
+
break;
|
|
14077
|
+
}
|
|
14078
|
+
case "replace-step": {
|
|
14079
|
+
initialiseWithStep(command.step, command.etag);
|
|
14080
|
+
trackEvent("Step Shown");
|
|
14081
|
+
break;
|
|
14082
|
+
}
|
|
14083
|
+
case "error": {
|
|
14084
|
+
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
14085
|
+
const { errors = { error: genericErrorMessage } } = command.body;
|
|
14086
|
+
if (stepRef.current) {
|
|
14087
|
+
initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors }), etagRef.current);
|
|
14088
|
+
} else {
|
|
14089
|
+
closeWithError(new Error("Initial request failed"), {});
|
|
14115
14090
|
}
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
}
|
|
14137
|
-
} catch (e) {
|
|
14138
|
-
closeWithError(e, {});
|
|
14091
|
+
break;
|
|
14092
|
+
}
|
|
14093
|
+
case "refresh": {
|
|
14094
|
+
const { refreshUrl, errors = {} } = command.body;
|
|
14095
|
+
try {
|
|
14096
|
+
(_e = stepComponentRef.current) == null ? void 0 : _e.setLoadingState("loading");
|
|
14097
|
+
const refreshCommand = await executeRefresh({
|
|
14098
|
+
abortSignal: abortCurrentAndGetNewAbortSignal(),
|
|
14099
|
+
url: refreshUrl,
|
|
14100
|
+
model,
|
|
14101
|
+
etag: etagRef.current,
|
|
14102
|
+
httpClient,
|
|
14103
|
+
trackEvent
|
|
14104
|
+
});
|
|
14105
|
+
switch (refreshCommand.type) {
|
|
14106
|
+
case "refresh-step":
|
|
14107
|
+
initialiseWithStep(__spreadProps(__spreadValues({}, refreshCommand.step), { errors }), refreshCommand.etag);
|
|
14108
|
+
break;
|
|
14109
|
+
default:
|
|
14110
|
+
throw new Error("Failed to refresh");
|
|
14139
14111
|
}
|
|
14140
|
-
|
|
14112
|
+
} catch (e) {
|
|
14113
|
+
closeWithError(e, {});
|
|
14141
14114
|
}
|
|
14115
|
+
break;
|
|
14142
14116
|
}
|
|
14143
|
-
} catch (error) {
|
|
14144
|
-
closeWithError(error);
|
|
14145
|
-
}
|
|
14146
|
-
},
|
|
14147
|
-
[httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
|
|
14148
|
-
);
|
|
14149
|
-
const triggerRefresh = useCallback11(
|
|
14150
|
-
async ({
|
|
14151
|
-
refreshUrl,
|
|
14152
|
-
model,
|
|
14153
|
-
localValue,
|
|
14154
|
-
schemaId
|
|
14155
|
-
}) => {
|
|
14156
|
-
if (true) {
|
|
14157
|
-
console.log("\u23EF\uFE0F triggerRefresh", JSON.stringify({ refreshUrl, model, schemaId }, null, 2));
|
|
14158
14117
|
}
|
|
14118
|
+
} catch (error) {
|
|
14119
|
+
closeWithError(error);
|
|
14120
|
+
}
|
|
14121
|
+
}, []);
|
|
14122
|
+
const onRefresh = useCallback11(
|
|
14123
|
+
async (schemaId, refreshUrl = "") => {
|
|
14124
|
+
var _a2, _b, _c, _d;
|
|
14159
14125
|
try {
|
|
14160
|
-
|
|
14161
|
-
|
|
14126
|
+
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
|
|
14127
|
+
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
14162
14128
|
const command = await executeRefresh({
|
|
14163
14129
|
abortSignal: abortCurrentAndGetNewAbortSignal(),
|
|
14164
14130
|
url: refreshUrl,
|
|
14165
14131
|
model,
|
|
14166
14132
|
schemaId,
|
|
14167
|
-
etag,
|
|
14133
|
+
etag: etagRef.current,
|
|
14168
14134
|
httpClient,
|
|
14169
14135
|
trackEvent
|
|
14170
14136
|
});
|
|
14171
|
-
setLoadingState("idle");
|
|
14172
14137
|
switch (command.type) {
|
|
14173
14138
|
case "refresh-step":
|
|
14174
|
-
|
|
14175
|
-
setEtag(command.etag);
|
|
14139
|
+
initialiseWithStep(command.step, command.etag);
|
|
14176
14140
|
break;
|
|
14177
14141
|
case "error": {
|
|
14178
14142
|
closeWithError(new Error("Failed to refresh"), command.body.analytics);
|
|
14179
14143
|
break;
|
|
14180
14144
|
}
|
|
14181
14145
|
case "noop":
|
|
14146
|
+
(_d = stepComponentRef.current) == null ? void 0 : _d.setLoadingState("idle");
|
|
14182
14147
|
break;
|
|
14183
14148
|
}
|
|
14184
14149
|
} catch (error) {
|
|
14185
14150
|
closeWithError(error, void 0);
|
|
14186
14151
|
}
|
|
14187
14152
|
},
|
|
14188
|
-
|
|
14153
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14154
|
+
[]
|
|
14189
14155
|
);
|
|
14190
14156
|
const render = useMemo18(
|
|
14191
14157
|
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
14192
14158
|
[renderers2]
|
|
14193
14159
|
);
|
|
14194
|
-
return /* @__PURE__ */
|
|
14195
|
-
Step_default,
|
|
14196
|
-
{
|
|
14197
|
-
displayStepTitle,
|
|
14198
|
-
step,
|
|
14199
|
-
localValue: localValueRef.current,
|
|
14200
|
-
loadingState,
|
|
14201
|
-
getErrorMessageFunctions,
|
|
14202
|
-
render,
|
|
14203
|
-
httpClient,
|
|
14204
|
-
trackEvent,
|
|
14205
|
-
logEvent,
|
|
14206
|
-
triggerSubmission,
|
|
14207
|
-
triggerRefresh
|
|
14208
|
-
}
|
|
14209
|
-
) : null });
|
|
14160
|
+
return /* @__PURE__ */ jsx119(ErrorBoundary_default, { onError: closeWithError, children: stepComponent ? render(stepComponent) : null });
|
|
14210
14161
|
}
|
|
14211
14162
|
|
|
14212
14163
|
// src/revamp/DynamicFlowWise.tsx
|
|
14213
|
-
import { jsx as
|
|
14164
|
+
import { jsx as jsx120 } from "react/jsx-runtime";
|
|
14214
14165
|
var renderers = getWiseRenderers();
|
|
14215
14166
|
function DynamicFlowWise(props) {
|
|
14216
14167
|
const { httpClient } = props;
|
|
@@ -14219,7 +14170,7 @@ function DynamicFlowWise(props) {
|
|
|
14219
14170
|
() => makeWiseHttpClient(httpClient, locale),
|
|
14220
14171
|
[httpClient, locale]
|
|
14221
14172
|
);
|
|
14222
|
-
return /* @__PURE__ */
|
|
14173
|
+
return /* @__PURE__ */ jsx120(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ jsx120(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
|
|
14223
14174
|
}
|
|
14224
14175
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
14225
14176
|
var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
|