@wise/dynamic-flow-client 3.1.0 → 3.1.2
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 +100 -57
- package/build/main.min.js +1 -1
- package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/utils/isPartialLocalValueMatch.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/buttonLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/layout/formLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/types.d.ts +1 -0
- package/package.json +2 -2
package/build/main.js
CHANGED
|
@@ -8612,7 +8612,7 @@ var translations = {
|
|
|
8612
8612
|
var i18n_default = translations;
|
|
8613
8613
|
|
|
8614
8614
|
// src/revamp/DynamicFlowWise.tsx
|
|
8615
|
-
var
|
|
8615
|
+
var import_react59 = require("react");
|
|
8616
8616
|
var import_react_intl36 = require("react-intl");
|
|
8617
8617
|
|
|
8618
8618
|
// src/revamp/wise/renderers/AlertRenderer.tsx
|
|
@@ -9977,6 +9977,7 @@ function RadioInputRendererComponent(props) {
|
|
|
9977
9977
|
|
|
9978
9978
|
// src/revamp/wise/renderers/SelectInputRenderer/TabInputRendererComponent.tsx
|
|
9979
9979
|
var import_components63 = require("@transferwise/components");
|
|
9980
|
+
var import_react55 = require("react");
|
|
9980
9981
|
var import_jsx_runtime108 = require("react/jsx-runtime");
|
|
9981
9982
|
function TabInputRendererComponent(props) {
|
|
9982
9983
|
const {
|
|
@@ -9991,6 +9992,11 @@ function TabInputRendererComponent(props) {
|
|
|
9991
9992
|
selectedIndex,
|
|
9992
9993
|
onSelect
|
|
9993
9994
|
} = props;
|
|
9995
|
+
(0, import_react55.useEffect)(() => {
|
|
9996
|
+
if (!isValidIndex(selectedIndex, options.length)) {
|
|
9997
|
+
onSelect(0);
|
|
9998
|
+
}
|
|
9999
|
+
}, [selectedIndex, onSelect, options.length]);
|
|
9994
10000
|
return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(import_jsx_runtime108.Fragment, { children: [
|
|
9995
10001
|
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(FieldInput_default, { id, label, help, description, error, children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
|
|
9996
10002
|
import_components63.Tabs,
|
|
@@ -10010,6 +10016,7 @@ function TabInputRendererComponent(props) {
|
|
|
10010
10016
|
children
|
|
10011
10017
|
] });
|
|
10012
10018
|
}
|
|
10019
|
+
var isValidIndex = (index, options) => index !== null && index >= 0 && index < options;
|
|
10013
10020
|
|
|
10014
10021
|
// src/revamp/wise/renderers/SelectInputRenderer/SelectInputRendererComponent.tsx
|
|
10015
10022
|
var import_components65 = require("@transferwise/components");
|
|
@@ -10402,7 +10409,7 @@ var getWiseRenderers = () => [
|
|
|
10402
10409
|
];
|
|
10403
10410
|
|
|
10404
10411
|
// src/revamp/DynamicFlowCore.tsx
|
|
10405
|
-
var
|
|
10412
|
+
var import_react58 = require("react");
|
|
10406
10413
|
var import_react_intl35 = require("react-intl");
|
|
10407
10414
|
|
|
10408
10415
|
// src/revamp/domain/features/events/getAnalyticsEventDispatcher.ts
|
|
@@ -10672,19 +10679,19 @@ var CoreContainerRenderer = {
|
|
|
10672
10679
|
};
|
|
10673
10680
|
|
|
10674
10681
|
// src/revamp/renderers/StepRenderer.tsx
|
|
10675
|
-
var
|
|
10682
|
+
var import_react56 = require("react");
|
|
10676
10683
|
var import_jsx_runtime118 = require("react/jsx-runtime");
|
|
10677
10684
|
var StepRenderer = {
|
|
10678
10685
|
canRenderType: "step",
|
|
10679
10686
|
render: StepRendererComponent
|
|
10680
10687
|
};
|
|
10681
10688
|
function StepRendererComponent({ children, loadingState }) {
|
|
10682
|
-
const value = (0,
|
|
10689
|
+
const value = (0, import_react56.useMemo)(() => ({ loadingState }), [loadingState]);
|
|
10683
10690
|
return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(LoadingContextProvider, { value, children });
|
|
10684
10691
|
}
|
|
10685
10692
|
|
|
10686
10693
|
// src/revamp/step/Step.tsx
|
|
10687
|
-
var
|
|
10694
|
+
var import_react57 = require("react");
|
|
10688
10695
|
|
|
10689
10696
|
// src/revamp/domain/features/validation/validation-functions.ts
|
|
10690
10697
|
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
@@ -10887,19 +10894,22 @@ var createButtonComponent = (buttonProps) => __spreadProps(__spreadValues({
|
|
|
10887
10894
|
});
|
|
10888
10895
|
|
|
10889
10896
|
// src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
|
|
10890
|
-
var buttonLayoutToComponent = (uid, { action, context, control, disabled, margin = "md", pinOrder, size, title }, { onAction }) =>
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10897
|
+
var buttonLayoutToComponent = (uid, { action, context, control, disabled, margin = "md", pinOrder, size, title }, { onAction, step }) => {
|
|
10898
|
+
const mergedAction = (action == null ? void 0 : action.$ref) ? __spreadValues(__spreadValues({}, getActionByReference(action.$ref, step == null ? void 0 : step.actions)), action) : action;
|
|
10899
|
+
return createButtonComponent({
|
|
10900
|
+
uid,
|
|
10901
|
+
context: getButtonContext({ context, action: mergedAction }),
|
|
10902
|
+
control: getButtonControl({ control, action: mergedAction }),
|
|
10903
|
+
disabled: getButtonDisabled({ disabled, action: mergedAction }),
|
|
10904
|
+
margin,
|
|
10905
|
+
pinOrder,
|
|
10906
|
+
size,
|
|
10907
|
+
title: getButtonTitle({ title, action: mergedAction }),
|
|
10908
|
+
onClick: () => {
|
|
10909
|
+
void onAction(mergedAction);
|
|
10910
|
+
}
|
|
10911
|
+
});
|
|
10912
|
+
};
|
|
10903
10913
|
var getButtonTitle = ({ title, action }) => {
|
|
10904
10914
|
var _a;
|
|
10905
10915
|
return (_a = title != null ? title : action == null ? void 0 : action.title) != null ? _a : "";
|
|
@@ -10923,6 +10933,13 @@ var getButtonContext = ({ context, action }) => {
|
|
|
10923
10933
|
}
|
|
10924
10934
|
return (action == null ? void 0 : action.type) ? mapLegacyActionTypeToContext(action.type) : "neutral";
|
|
10925
10935
|
};
|
|
10936
|
+
var getActionByReference = ($ref, actions = []) => {
|
|
10937
|
+
const action = actions.find((a) => a.$id === $ref);
|
|
10938
|
+
if (!action) {
|
|
10939
|
+
throw new Error("Action reference not found in actions array.");
|
|
10940
|
+
}
|
|
10941
|
+
return action;
|
|
10942
|
+
};
|
|
10926
10943
|
|
|
10927
10944
|
// src/revamp/domain/components/ColumnsComponent.ts
|
|
10928
10945
|
var createColumnsComponent = (columnsProps) => __spreadProps(__spreadValues({}, columnsProps), {
|
|
@@ -11060,6 +11077,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
11060
11077
|
}
|
|
11061
11078
|
update((draft) => {
|
|
11062
11079
|
draft.errors = [error.message];
|
|
11080
|
+
draft.persistedState.lastSubmitted = null;
|
|
11063
11081
|
});
|
|
11064
11082
|
throw error;
|
|
11065
11083
|
}
|
|
@@ -11222,6 +11240,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
11222
11240
|
if (performPersistAsync) {
|
|
11223
11241
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
11224
11242
|
return __spreadProps(__spreadValues({}, numberComponent), {
|
|
11243
|
+
isPersisted: true,
|
|
11225
11244
|
onBlur() {
|
|
11226
11245
|
if (this.validate()) {
|
|
11227
11246
|
persist(this.persistedState, this.getLocalValue()).catch(() => {
|
|
@@ -11932,6 +11951,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
11932
11951
|
if (performPersistAsync) {
|
|
11933
11952
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
11934
11953
|
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
11954
|
+
isPersisted: true,
|
|
11935
11955
|
onBlur() {
|
|
11936
11956
|
if (this.validate()) {
|
|
11937
11957
|
persist(this.persistedState, this.getLocalValue()).catch(() => {
|
|
@@ -11995,21 +12015,35 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
11995
12015
|
};
|
|
11996
12016
|
|
|
11997
12017
|
// src/revamp/domain/components/utils/isPartialLocalValueMatch.ts
|
|
11998
|
-
var isPartialLocalValueMatch = (partialValue,
|
|
11999
|
-
if (isArray2(partialValue) &&
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12018
|
+
var isPartialLocalValueMatch = (partialValue, component) => {
|
|
12019
|
+
if (isArray2(partialValue) && component.type === "repeatable") {
|
|
12020
|
+
const children = component.getChildren();
|
|
12021
|
+
return partialValue.every((value, index) => {
|
|
12022
|
+
const childComponent = children[index];
|
|
12023
|
+
return childComponent ? isPartialLocalValueMatch(value, childComponent) : false;
|
|
12024
|
+
});
|
|
12003
12025
|
}
|
|
12004
|
-
if (isObjectLocalValue(partialValue) &&
|
|
12005
|
-
const allKeys = Array.from(
|
|
12026
|
+
if (isObjectLocalValue(partialValue) && component.type === "object") {
|
|
12027
|
+
const allKeys = Array.from(
|
|
12028
|
+
/* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(component.componentMap)])
|
|
12029
|
+
);
|
|
12006
12030
|
const matchingKeys = allKeys.filter(
|
|
12007
|
-
(key) => !isNullish3(partialValue[key]) && !isNullish3(
|
|
12031
|
+
(key) => !isNullish3(partialValue[key]) && !isNullish3(component.componentMap[key])
|
|
12032
|
+
);
|
|
12033
|
+
return matchingKeys.every(
|
|
12034
|
+
(key) => isPartialLocalValueMatch(partialValue[key], component.componentMap[key])
|
|
12008
12035
|
);
|
|
12009
|
-
return matchingKeys.every((key) => isPartialLocalValueMatch(partialValue[key], value[key]));
|
|
12010
12036
|
}
|
|
12011
|
-
|
|
12037
|
+
const componentValue = component.getLocalValue();
|
|
12038
|
+
if (partialValue instanceof File && componentValue instanceof File) {
|
|
12039
|
+
return areEquivalentFiles(partialValue, componentValue);
|
|
12040
|
+
}
|
|
12041
|
+
if ("isPersisted" in component && component.isPersisted) {
|
|
12042
|
+
return true;
|
|
12043
|
+
}
|
|
12044
|
+
return partialValue === componentValue;
|
|
12012
12045
|
};
|
|
12046
|
+
var areEquivalentFiles = (fileA, fileB) => fileA.name === fileB.name && fileA.type === fileB.type && fileA.size === fileB.size;
|
|
12013
12047
|
|
|
12014
12048
|
// src/revamp/domain/components/SelectInputComponent.ts
|
|
12015
12049
|
var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
@@ -12031,9 +12065,10 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
12031
12065
|
"summariser"
|
|
12032
12066
|
]);
|
|
12033
12067
|
const children = options.map((option) => option.component);
|
|
12034
|
-
const
|
|
12035
|
-
(option) => isPartialLocalValueMatch(selectProps.initialValue, option.component
|
|
12068
|
+
const matchingOptions = options.map(
|
|
12069
|
+
(option) => isPartialLocalValueMatch(selectProps.initialValue, option.component)
|
|
12036
12070
|
);
|
|
12071
|
+
const selectedIndex = matchingOptions.filter(isTrue).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
12037
12072
|
const update = getInputUpdateFunction(uid, updateComponent);
|
|
12038
12073
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
12039
12074
|
const getAndSetValidationErrors = (currentValue) => {
|
|
@@ -12100,6 +12135,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
12100
12135
|
}
|
|
12101
12136
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
12102
12137
|
return __spreadProps(__spreadValues({}, selectComponent), {
|
|
12138
|
+
isPersisted: true,
|
|
12103
12139
|
onSelect(updatedIndex) {
|
|
12104
12140
|
selectComponent.onSelect.call(this, updatedIndex);
|
|
12105
12141
|
const isValid = getValidationErrors(this.getLocalValue()).length === 0;
|
|
@@ -12113,6 +12149,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
12113
12149
|
}
|
|
12114
12150
|
});
|
|
12115
12151
|
};
|
|
12152
|
+
var isTrue = (value) => value;
|
|
12116
12153
|
|
|
12117
12154
|
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
12118
12155
|
var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
@@ -12245,6 +12282,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
12245
12282
|
if (performPersistAsync) {
|
|
12246
12283
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
12247
12284
|
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
12285
|
+
isPersisted: true,
|
|
12248
12286
|
onChange(updatedValue) {
|
|
12249
12287
|
dateInputComponent.onChange.call(this, updatedValue);
|
|
12250
12288
|
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
@@ -12394,6 +12432,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
12394
12432
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
12395
12433
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
12396
12434
|
format,
|
|
12435
|
+
isPersisted: true,
|
|
12397
12436
|
async onUpload(file) {
|
|
12398
12437
|
update((draft) => {
|
|
12399
12438
|
draft.errors = [];
|
|
@@ -12511,6 +12550,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
12511
12550
|
if (performPersistAsync) {
|
|
12512
12551
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
12513
12552
|
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
12553
|
+
isPersisted: true,
|
|
12514
12554
|
onBlur() {
|
|
12515
12555
|
if (this.validate()) {
|
|
12516
12556
|
persist(this.persistedState, this.getLocalValue()).catch(() => {
|
|
@@ -12860,6 +12900,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
12860
12900
|
const persist = getComponentMultiPersistAsync(update, performPersistAsync);
|
|
12861
12901
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
12862
12902
|
format,
|
|
12903
|
+
isPersisted: true,
|
|
12863
12904
|
async onUpload(file, fileId) {
|
|
12864
12905
|
await uploadComponent.onUpload.call(this, file, fileId);
|
|
12865
12906
|
const submission = format === "blob" ? file : await toBase642(file);
|
|
@@ -13010,6 +13051,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
13010
13051
|
if (performPersistAsync) {
|
|
13011
13052
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
13012
13053
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
13054
|
+
isPersisted: true,
|
|
13013
13055
|
onChange(updatedValue) {
|
|
13014
13056
|
booleanComponent.onChange.call(this, updatedValue);
|
|
13015
13057
|
persist(this.persistedState, this.getLocalValue()).catch(() => {
|
|
@@ -13182,12 +13224,13 @@ var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formPr
|
|
|
13182
13224
|
});
|
|
13183
13225
|
|
|
13184
13226
|
// src/revamp/domain/mappers/layout/formLayoutToComponent.ts
|
|
13185
|
-
var formLayoutToComponent = (uid, { schemaId, control, margin = "md" }, mapperProps) => {
|
|
13227
|
+
var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin = "md" }, mapperProps) => {
|
|
13186
13228
|
const { step, stepLocalValue } = mapperProps;
|
|
13187
13229
|
const { model, errors, schemas } = step;
|
|
13188
|
-
const
|
|
13230
|
+
const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
|
|
13231
|
+
const schema = schemas.find((s) => s.$id === id);
|
|
13189
13232
|
if (!schema) {
|
|
13190
|
-
throw new Error("
|
|
13233
|
+
throw new Error("Schema not found in schemas array.");
|
|
13191
13234
|
}
|
|
13192
13235
|
return createFormComponent({
|
|
13193
13236
|
uid,
|
|
@@ -13694,9 +13737,9 @@ function Step({
|
|
|
13694
13737
|
triggerRefresh
|
|
13695
13738
|
}) {
|
|
13696
13739
|
var _a;
|
|
13697
|
-
const [stepComponent, setStepComponent] = (0,
|
|
13698
|
-
const stepComponentRef = (0,
|
|
13699
|
-
const updateComponent = (0,
|
|
13740
|
+
const [stepComponent, setStepComponent] = (0, import_react57.useState)(emptyStepComponent);
|
|
13741
|
+
const stepComponentRef = (0, import_react57.useRef)(emptyStepComponent);
|
|
13742
|
+
const updateComponent = (0, import_react57.useCallback)(
|
|
13700
13743
|
(id, update) => {
|
|
13701
13744
|
update(findComponent([stepComponentRef.current], id));
|
|
13702
13745
|
setStepComponent(() => {
|
|
@@ -13707,14 +13750,14 @@ function Step({
|
|
|
13707
13750
|
},
|
|
13708
13751
|
[]
|
|
13709
13752
|
);
|
|
13710
|
-
(0,
|
|
13753
|
+
(0, import_react57.useEffect)(() => {
|
|
13711
13754
|
setStepComponent(() => {
|
|
13712
13755
|
const newStepDomainComponent = __spreadProps(__spreadValues({}, stepComponentRef.current), { loadingState });
|
|
13713
13756
|
stepComponentRef.current = newStepDomainComponent;
|
|
13714
13757
|
return newStepDomainComponent;
|
|
13715
13758
|
});
|
|
13716
13759
|
}, [loadingState]);
|
|
13717
|
-
const onAction = (0,
|
|
13760
|
+
const onAction = (0, import_react57.useCallback)(
|
|
13718
13761
|
async (action) => {
|
|
13719
13762
|
var _a2;
|
|
13720
13763
|
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
@@ -13734,7 +13777,7 @@ function Step({
|
|
|
13734
13777
|
},
|
|
13735
13778
|
[triggerSubmission]
|
|
13736
13779
|
);
|
|
13737
|
-
const onRefresh = (0,
|
|
13780
|
+
const onRefresh = (0, import_react57.useCallback)(
|
|
13738
13781
|
async (schemaId, url) => {
|
|
13739
13782
|
var _a2;
|
|
13740
13783
|
const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
@@ -13746,7 +13789,7 @@ function Step({
|
|
|
13746
13789
|
},
|
|
13747
13790
|
[step.refreshUrl, step.refreshFormUrl, triggerRefresh]
|
|
13748
13791
|
);
|
|
13749
|
-
(0,
|
|
13792
|
+
(0, import_react57.useEffect)(() => {
|
|
13750
13793
|
const initialComponent = mapStepToComponent({
|
|
13751
13794
|
stepLocalValue: initialLocalValue,
|
|
13752
13795
|
step,
|
|
@@ -13776,7 +13819,7 @@ function Step({
|
|
|
13776
13819
|
logEvent,
|
|
13777
13820
|
onRefresh
|
|
13778
13821
|
]);
|
|
13779
|
-
(0,
|
|
13822
|
+
(0, import_react57.useEffect)(() => {
|
|
13780
13823
|
trackEvent("Step Shown");
|
|
13781
13824
|
}, [(_a = step.id) != null ? _a : step.key]);
|
|
13782
13825
|
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_jsx_runtime119.Fragment, { children: render(stepComponent) });
|
|
@@ -14426,21 +14469,21 @@ function DynamicFlowCore(props) {
|
|
|
14426
14469
|
onLog
|
|
14427
14470
|
} = props;
|
|
14428
14471
|
const { formatMessage, locale } = (0, import_react_intl35.useIntl)();
|
|
14429
|
-
const getErrorMessageFunctions = (0,
|
|
14472
|
+
const getErrorMessageFunctions = (0, import_react58.useMemo)(
|
|
14430
14473
|
() => getSchemaErrorMessageFunction(formatMessage, locale),
|
|
14431
14474
|
[formatMessage, locale]
|
|
14432
14475
|
);
|
|
14433
|
-
(0,
|
|
14476
|
+
(0, import_react58.useEffect)(() => {
|
|
14434
14477
|
var _a2;
|
|
14435
14478
|
if (!initialStep && initialAction) {
|
|
14436
14479
|
void triggerSubmission(initialAction, (_a2 = initialAction.data) != null ? _a2 : {}, null);
|
|
14437
14480
|
}
|
|
14438
14481
|
}, []);
|
|
14439
|
-
const [step, setStep] = (0,
|
|
14440
|
-
const localValueRef = (0,
|
|
14441
|
-
const [etag, setEtag] = (0,
|
|
14442
|
-
const abortControllerRef = (0,
|
|
14443
|
-
const [loadingState, setLoadingState] = (0,
|
|
14482
|
+
const [step, setStep] = (0, import_react58.useState)(initialStep != null ? initialStep : null);
|
|
14483
|
+
const localValueRef = (0, import_react58.useRef)(null);
|
|
14484
|
+
const [etag, setEtag] = (0, import_react58.useState)(null);
|
|
14485
|
+
const abortControllerRef = (0, import_react58.useRef)(new AbortController());
|
|
14486
|
+
const [loadingState, setLoadingState] = (0, import_react58.useState)(initialStep ? "idle" : "loading");
|
|
14444
14487
|
const abortCurrentAndGetNewAbortSignal = () => {
|
|
14445
14488
|
abortControllerRef.current.abort();
|
|
14446
14489
|
abortControllerRef.current = new AbortController();
|
|
@@ -14448,21 +14491,21 @@ function DynamicFlowCore(props) {
|
|
|
14448
14491
|
};
|
|
14449
14492
|
const stepId = (_a = step == null ? void 0 : step.id) != null ? _a : step == null ? void 0 : step.key;
|
|
14450
14493
|
const stepAnalytics = step == null ? void 0 : step.analytics;
|
|
14451
|
-
const trackEvent = (0,
|
|
14494
|
+
const trackEvent = (0, import_react58.useMemo)(
|
|
14452
14495
|
() => getAnalyticsEventDispatcher({ flowId, stepId, analytics: stepAnalytics, onEvent }),
|
|
14453
14496
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14454
14497
|
[flowId, stepId, JSON.stringify(stepAnalytics), onEvent]
|
|
14455
14498
|
);
|
|
14456
|
-
const logEvent = (0,
|
|
14457
|
-
(0,
|
|
14458
|
-
const closeWithError = (0,
|
|
14499
|
+
const logEvent = (0, import_react58.useMemo)(() => getLoggingEventDispatcher(onLog), [onLog]);
|
|
14500
|
+
(0, import_react58.useEffect)(() => trackEvent("Flow Started"), []);
|
|
14501
|
+
const closeWithError = (0, import_react58.useCallback)(
|
|
14459
14502
|
(error, analytics) => {
|
|
14460
14503
|
trackEvent("Flow Failed", __spreadValues({}, analytics));
|
|
14461
14504
|
onError(error);
|
|
14462
14505
|
},
|
|
14463
14506
|
[onError, trackEvent]
|
|
14464
14507
|
);
|
|
14465
|
-
const triggerSubmission = (0,
|
|
14508
|
+
const triggerSubmission = (0, import_react58.useCallback)(
|
|
14466
14509
|
async (action, model, localValue) => {
|
|
14467
14510
|
if (true) {
|
|
14468
14511
|
console.log("\u23EF\uFE0F triggerSubmission", JSON.stringify({ action, model }, null, 2));
|
|
@@ -14534,7 +14577,7 @@ function DynamicFlowCore(props) {
|
|
|
14534
14577
|
},
|
|
14535
14578
|
[httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
|
|
14536
14579
|
);
|
|
14537
|
-
const triggerRefresh = (0,
|
|
14580
|
+
const triggerRefresh = (0, import_react58.useCallback)(
|
|
14538
14581
|
async ({
|
|
14539
14582
|
refreshUrl,
|
|
14540
14583
|
model,
|
|
@@ -14575,11 +14618,11 @@ function DynamicFlowCore(props) {
|
|
|
14575
14618
|
},
|
|
14576
14619
|
[etag, httpClient, trackEvent, closeWithError]
|
|
14577
14620
|
);
|
|
14578
|
-
const render = (0,
|
|
14621
|
+
const render = (0, import_react58.useMemo)(
|
|
14579
14622
|
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
14580
14623
|
[renderers2]
|
|
14581
14624
|
);
|
|
14582
|
-
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ErrorBoundary_default, { onError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
14625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ErrorBoundary_default, { onError: closeWithError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
14583
14626
|
Step_default,
|
|
14584
14627
|
{
|
|
14585
14628
|
displayStepTitle,
|
|
@@ -14603,7 +14646,7 @@ var renderers = getWiseRenderers();
|
|
|
14603
14646
|
function DynamicFlowWise(props) {
|
|
14604
14647
|
const { httpClient } = props;
|
|
14605
14648
|
const { locale } = (0, import_react_intl36.useIntl)();
|
|
14606
|
-
const wiseHttpClient = (0,
|
|
14649
|
+
const wiseHttpClient = (0, import_react59.useMemo)(
|
|
14607
14650
|
() => makeWiseHttpClient(httpClient, locale),
|
|
14608
14651
|
[httpClient, locale]
|
|
14609
14652
|
);
|