@wise/dynamic-flow-client 3.1.1 → 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 +35 -28
- package/build/main.min.js +1 -1
- package/package.json +1 -1
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);
|
|
@@ -13730,9 +13737,9 @@ function Step({
|
|
|
13730
13737
|
triggerRefresh
|
|
13731
13738
|
}) {
|
|
13732
13739
|
var _a;
|
|
13733
|
-
const [stepComponent, setStepComponent] = (0,
|
|
13734
|
-
const stepComponentRef = (0,
|
|
13735
|
-
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)(
|
|
13736
13743
|
(id, update) => {
|
|
13737
13744
|
update(findComponent([stepComponentRef.current], id));
|
|
13738
13745
|
setStepComponent(() => {
|
|
@@ -13743,14 +13750,14 @@ function Step({
|
|
|
13743
13750
|
},
|
|
13744
13751
|
[]
|
|
13745
13752
|
);
|
|
13746
|
-
(0,
|
|
13753
|
+
(0, import_react57.useEffect)(() => {
|
|
13747
13754
|
setStepComponent(() => {
|
|
13748
13755
|
const newStepDomainComponent = __spreadProps(__spreadValues({}, stepComponentRef.current), { loadingState });
|
|
13749
13756
|
stepComponentRef.current = newStepDomainComponent;
|
|
13750
13757
|
return newStepDomainComponent;
|
|
13751
13758
|
});
|
|
13752
13759
|
}, [loadingState]);
|
|
13753
|
-
const onAction = (0,
|
|
13760
|
+
const onAction = (0, import_react57.useCallback)(
|
|
13754
13761
|
async (action) => {
|
|
13755
13762
|
var _a2;
|
|
13756
13763
|
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
@@ -13770,7 +13777,7 @@ function Step({
|
|
|
13770
13777
|
},
|
|
13771
13778
|
[triggerSubmission]
|
|
13772
13779
|
);
|
|
13773
|
-
const onRefresh = (0,
|
|
13780
|
+
const onRefresh = (0, import_react57.useCallback)(
|
|
13774
13781
|
async (schemaId, url) => {
|
|
13775
13782
|
var _a2;
|
|
13776
13783
|
const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
@@ -13782,7 +13789,7 @@ function Step({
|
|
|
13782
13789
|
},
|
|
13783
13790
|
[step.refreshUrl, step.refreshFormUrl, triggerRefresh]
|
|
13784
13791
|
);
|
|
13785
|
-
(0,
|
|
13792
|
+
(0, import_react57.useEffect)(() => {
|
|
13786
13793
|
const initialComponent = mapStepToComponent({
|
|
13787
13794
|
stepLocalValue: initialLocalValue,
|
|
13788
13795
|
step,
|
|
@@ -13812,7 +13819,7 @@ function Step({
|
|
|
13812
13819
|
logEvent,
|
|
13813
13820
|
onRefresh
|
|
13814
13821
|
]);
|
|
13815
|
-
(0,
|
|
13822
|
+
(0, import_react57.useEffect)(() => {
|
|
13816
13823
|
trackEvent("Step Shown");
|
|
13817
13824
|
}, [(_a = step.id) != null ? _a : step.key]);
|
|
13818
13825
|
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_jsx_runtime119.Fragment, { children: render(stepComponent) });
|
|
@@ -14462,21 +14469,21 @@ function DynamicFlowCore(props) {
|
|
|
14462
14469
|
onLog
|
|
14463
14470
|
} = props;
|
|
14464
14471
|
const { formatMessage, locale } = (0, import_react_intl35.useIntl)();
|
|
14465
|
-
const getErrorMessageFunctions = (0,
|
|
14472
|
+
const getErrorMessageFunctions = (0, import_react58.useMemo)(
|
|
14466
14473
|
() => getSchemaErrorMessageFunction(formatMessage, locale),
|
|
14467
14474
|
[formatMessage, locale]
|
|
14468
14475
|
);
|
|
14469
|
-
(0,
|
|
14476
|
+
(0, import_react58.useEffect)(() => {
|
|
14470
14477
|
var _a2;
|
|
14471
14478
|
if (!initialStep && initialAction) {
|
|
14472
14479
|
void triggerSubmission(initialAction, (_a2 = initialAction.data) != null ? _a2 : {}, null);
|
|
14473
14480
|
}
|
|
14474
14481
|
}, []);
|
|
14475
|
-
const [step, setStep] = (0,
|
|
14476
|
-
const localValueRef = (0,
|
|
14477
|
-
const [etag, setEtag] = (0,
|
|
14478
|
-
const abortControllerRef = (0,
|
|
14479
|
-
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");
|
|
14480
14487
|
const abortCurrentAndGetNewAbortSignal = () => {
|
|
14481
14488
|
abortControllerRef.current.abort();
|
|
14482
14489
|
abortControllerRef.current = new AbortController();
|
|
@@ -14484,21 +14491,21 @@ function DynamicFlowCore(props) {
|
|
|
14484
14491
|
};
|
|
14485
14492
|
const stepId = (_a = step == null ? void 0 : step.id) != null ? _a : step == null ? void 0 : step.key;
|
|
14486
14493
|
const stepAnalytics = step == null ? void 0 : step.analytics;
|
|
14487
|
-
const trackEvent = (0,
|
|
14494
|
+
const trackEvent = (0, import_react58.useMemo)(
|
|
14488
14495
|
() => getAnalyticsEventDispatcher({ flowId, stepId, analytics: stepAnalytics, onEvent }),
|
|
14489
14496
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14490
14497
|
[flowId, stepId, JSON.stringify(stepAnalytics), onEvent]
|
|
14491
14498
|
);
|
|
14492
|
-
const logEvent = (0,
|
|
14493
|
-
(0,
|
|
14494
|
-
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)(
|
|
14495
14502
|
(error, analytics) => {
|
|
14496
14503
|
trackEvent("Flow Failed", __spreadValues({}, analytics));
|
|
14497
14504
|
onError(error);
|
|
14498
14505
|
},
|
|
14499
14506
|
[onError, trackEvent]
|
|
14500
14507
|
);
|
|
14501
|
-
const triggerSubmission = (0,
|
|
14508
|
+
const triggerSubmission = (0, import_react58.useCallback)(
|
|
14502
14509
|
async (action, model, localValue) => {
|
|
14503
14510
|
if (true) {
|
|
14504
14511
|
console.log("\u23EF\uFE0F triggerSubmission", JSON.stringify({ action, model }, null, 2));
|
|
@@ -14570,7 +14577,7 @@ function DynamicFlowCore(props) {
|
|
|
14570
14577
|
},
|
|
14571
14578
|
[httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
|
|
14572
14579
|
);
|
|
14573
|
-
const triggerRefresh = (0,
|
|
14580
|
+
const triggerRefresh = (0, import_react58.useCallback)(
|
|
14574
14581
|
async ({
|
|
14575
14582
|
refreshUrl,
|
|
14576
14583
|
model,
|
|
@@ -14611,7 +14618,7 @@ function DynamicFlowCore(props) {
|
|
|
14611
14618
|
},
|
|
14612
14619
|
[etag, httpClient, trackEvent, closeWithError]
|
|
14613
14620
|
);
|
|
14614
|
-
const render = (0,
|
|
14621
|
+
const render = (0, import_react58.useMemo)(
|
|
14615
14622
|
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
14616
14623
|
[renderers2]
|
|
14617
14624
|
);
|
|
@@ -14639,7 +14646,7 @@ var renderers = getWiseRenderers();
|
|
|
14639
14646
|
function DynamicFlowWise(props) {
|
|
14640
14647
|
const { httpClient } = props;
|
|
14641
14648
|
const { locale } = (0, import_react_intl36.useIntl)();
|
|
14642
|
-
const wiseHttpClient = (0,
|
|
14649
|
+
const wiseHttpClient = (0, import_react59.useMemo)(
|
|
14643
14650
|
() => makeWiseHttpClient(httpClient, locale),
|
|
14644
14651
|
[httpClient, locale]
|
|
14645
14652
|
);
|