@wise/dynamic-flow-client 3.1.1 → 3.2.0-beta-ebb580.38
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 +49 -42
- package/build/main.min.js +1 -1
- package/build/main.mjs +14693 -0
- package/build/types/legacy/formControl/FormControl.d.ts +2 -1
- package/build/types/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.d.ts +1 -1
- package/package.json +33 -32
package/build/main.js
CHANGED
|
@@ -149,10 +149,10 @@ var init_clsx = __esm({
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
// ../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.
|
|
152
|
+
// ../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.9.5_@types+react@18.0.29_react-dom@18.2.0_react@18.2.0/node_modules/@wise/art/dist/index-d9418379.esm.js
|
|
153
153
|
var import_react17, import_jsx_runtime28, unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
|
|
154
154
|
var init_index_d9418379_esm = __esm({
|
|
155
|
-
"../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.
|
|
155
|
+
"../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.9.5_@types+react@18.0.29_react-dom@18.2.0_react@18.2.0/node_modules/@wise/art/dist/index-d9418379.esm.js"() {
|
|
156
156
|
"use strict";
|
|
157
157
|
init_clsx();
|
|
158
158
|
import_react17 = require("react");
|
|
@@ -4414,7 +4414,7 @@ var FormControl = _FormControl;
|
|
|
4414
4414
|
// src/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
4415
4415
|
var import_components14 = require("@transferwise/components");
|
|
4416
4416
|
|
|
4417
|
-
// ../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.
|
|
4417
|
+
// ../../node_modules/.pnpm/@wise+art@2.9.2_@transferwise+neptune-css@14.9.5_@types+react@18.0.29_react-dom@18.2.0_react@18.2.0/node_modules/@wise/art/dist/index.esm.js
|
|
4418
4418
|
init_index_d9418379_esm();
|
|
4419
4419
|
init_clsx();
|
|
4420
4420
|
var import_react18 = require("react");
|
|
@@ -5007,7 +5007,7 @@ function PromotedOneOfRadioControl(props) {
|
|
|
5007
5007
|
const radios = [
|
|
5008
5008
|
__spreadValues({
|
|
5009
5009
|
value: "promoted",
|
|
5010
|
-
// TODO: LOW avoid type assertion below the expression may be nullish, but "label" cannot be
|
|
5010
|
+
// TODO: LOW avoid type assertion below: the expression may be nullish, but "label" cannot be
|
|
5011
5011
|
label: ((_a = promotion.promoted) == null ? void 0 : _a.title) || promotedOneOf.title,
|
|
5012
5012
|
secondary: ((_b = promotion.promoted) == null ? void 0 : _b.description) || promotedOneOf.description
|
|
5013
5013
|
}, getAvatarPropertyForRadioOption(promotedOneOf)),
|
|
@@ -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
|
|
@@ -8680,7 +8680,7 @@ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
|
|
|
8680
8680
|
return deterministicId || (id ? `radix-${id}` : "");
|
|
8681
8681
|
}
|
|
8682
8682
|
|
|
8683
|
-
// ../../node_modules/.pnpm/@wise+forms@0.3.1_@transferwise+components@46.
|
|
8683
|
+
// ../../node_modules/.pnpm/@wise+forms@0.3.1_@transferwise+components@46.17.2_@types+react@18.0.29_react@18.2.0/node_modules/@wise/forms/dist/index.esm.js
|
|
8684
8684
|
var import_components39 = require("@transferwise/components");
|
|
8685
8685
|
var import_classnames9 = __toESM(require_classnames());
|
|
8686
8686
|
var import_react49 = require("react");
|
|
@@ -9962,12 +9962,12 @@ function RadioInputRendererComponent(props) {
|
|
|
9962
9962
|
name: id,
|
|
9963
9963
|
radios: options.map((option, index) => ({
|
|
9964
9964
|
label: option.title,
|
|
9965
|
-
value:
|
|
9965
|
+
value: index,
|
|
9966
9966
|
secondary: option.description,
|
|
9967
9967
|
disabled: option.disabled || disabled,
|
|
9968
9968
|
avatar: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(OptionMedia, { icon: option.icon, image: option.image })
|
|
9969
9969
|
})),
|
|
9970
|
-
selectedValue:
|
|
9970
|
+
selectedValue: selectedIndex != null ? selectedIndex : void 0,
|
|
9971
9971
|
onChange: onSelect
|
|
9972
9972
|
}
|
|
9973
9973
|
) }) }),
|
|
@@ -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);
|
|
@@ -11486,20 +11493,20 @@ var getPerformPersistAsync = ({
|
|
|
11486
11493
|
const { idProperty, param, method, url } = persistAsyncConfig;
|
|
11487
11494
|
const trackFailure = (json) => {
|
|
11488
11495
|
const analytics = getAnalyticsFromErrorResponse(json);
|
|
11489
|
-
trackEvent("PersistAsync Failed", __spreadValues({ schemaId }, analytics));
|
|
11496
|
+
trackEvent("PersistAsync Failed", __spreadValues({ schema: schemaId }, analytics));
|
|
11490
11497
|
};
|
|
11491
11498
|
return async function performPersistAsync({ value, signal }) {
|
|
11492
11499
|
let response;
|
|
11493
11500
|
let json;
|
|
11494
11501
|
try {
|
|
11495
|
-
trackEvent("PersistAsync Triggered", { schemaId });
|
|
11502
|
+
trackEvent("PersistAsync Triggered", { schema: schemaId });
|
|
11496
11503
|
response = await httpClient(
|
|
11497
11504
|
url,
|
|
11498
11505
|
constructPayload({ value, signal, requestConfig: { method, param } })
|
|
11499
11506
|
);
|
|
11500
11507
|
json = await response.json();
|
|
11501
11508
|
if (response.ok && isObject2(json)) {
|
|
11502
|
-
trackEvent("PersistAsync Succeeded", { schemaId });
|
|
11509
|
+
trackEvent("PersistAsync Succeeded", { schema: schemaId });
|
|
11503
11510
|
if (json[idProperty] === void 0) {
|
|
11504
11511
|
logEvent(
|
|
11505
11512
|
"error",
|
|
@@ -11594,12 +11601,12 @@ var getPerformValidationAsync = ({
|
|
|
11594
11601
|
const { method, param, url } = validationAsyncConfig;
|
|
11595
11602
|
const trackFailureAndReturn = (json) => {
|
|
11596
11603
|
const analytics = getAnalyticsFromErrorResponse(json);
|
|
11597
|
-
trackEvent("ValidationAsync Failed", __spreadValues({ schemaId }, analytics));
|
|
11604
|
+
trackEvent("ValidationAsync Failed", __spreadValues({ schema: schemaId }, analytics));
|
|
11598
11605
|
return null;
|
|
11599
11606
|
};
|
|
11600
11607
|
return async function performValidationAsync({ value, signal }) {
|
|
11601
11608
|
let response;
|
|
11602
|
-
trackEvent("ValidationAsync Triggered", { schemaId });
|
|
11609
|
+
trackEvent("ValidationAsync Triggered", { schema: schemaId });
|
|
11603
11610
|
try {
|
|
11604
11611
|
response = await httpClient(
|
|
11605
11612
|
url,
|
|
@@ -11611,12 +11618,12 @@ var getPerformValidationAsync = ({
|
|
|
11611
11618
|
const json = await response.json().catch(() => null);
|
|
11612
11619
|
const message = getValidationMessage(json);
|
|
11613
11620
|
if (response.ok) {
|
|
11614
|
-
trackEvent("ValidationAsync Succeeded", { schemaId });
|
|
11621
|
+
trackEvent("ValidationAsync Succeeded", { schema: schemaId });
|
|
11615
11622
|
return message;
|
|
11616
11623
|
}
|
|
11617
11624
|
if (response.status === 422) {
|
|
11618
11625
|
if (message) {
|
|
11619
|
-
trackEvent("ValidationAsync Succeeded", { schemaId });
|
|
11626
|
+
trackEvent("ValidationAsync Succeeded", { schema: schemaId });
|
|
11620
11627
|
throw new Error(message);
|
|
11621
11628
|
}
|
|
11622
11629
|
}
|
|
@@ -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
|
);
|