@wise/dynamic-flow-client 3.6.1 → 3.6.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 +74 -22
- package/build/main.min.js +1 -1
- package/build/main.mjs +83 -31
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +7 -1
- package/build/types/revamp/renderers/step/BackButton.d.ts +3 -0
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
- package/build/types/revamp/renderers/types.d.ts +4 -1
- package/package.json +2 -2
package/build/main.js
CHANGED
|
@@ -5638,7 +5638,15 @@ function DynamicSearch({ component, onAction }) {
|
|
|
5638
5638
|
name: "typeahead-input-name",
|
|
5639
5639
|
size: "md",
|
|
5640
5640
|
maxHeight: 100,
|
|
5641
|
-
footer: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5641
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5642
|
+
TypeaheadFooter,
|
|
5643
|
+
{
|
|
5644
|
+
state: status,
|
|
5645
|
+
results,
|
|
5646
|
+
emptyMessage,
|
|
5647
|
+
onRetrySearch
|
|
5648
|
+
}
|
|
5649
|
+
),
|
|
5642
5650
|
multiple: false,
|
|
5643
5651
|
clearable: false,
|
|
5644
5652
|
addon: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_icons2.Search, { size: 24 }),
|
|
@@ -5675,10 +5683,11 @@ function mapResultToTypeaheadOption(result) {
|
|
|
5675
5683
|
function TypeaheadFooter({
|
|
5676
5684
|
results,
|
|
5677
5685
|
state,
|
|
5678
|
-
onRetrySearch
|
|
5686
|
+
onRetrySearch,
|
|
5687
|
+
emptyMessage
|
|
5679
5688
|
}) {
|
|
5680
5689
|
if (state === "success" && results.length === 0) {
|
|
5681
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_components32.Markdown, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: emptyMessage });
|
|
5682
5691
|
}
|
|
5683
5692
|
if (state === "error" && results.length === 0) {
|
|
5684
5693
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ErrorResult, { onRetrySearch }) });
|
|
@@ -9701,7 +9710,7 @@ function SearchResultContent({
|
|
|
9701
9710
|
}
|
|
9702
9711
|
}
|
|
9703
9712
|
function EmptySearchResult({ state }) {
|
|
9704
|
-
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
|
|
9713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components62.Markdown, { className: "m-t-2", config: { link: { target: "_blank" } }, children: state.message });
|
|
9705
9714
|
}
|
|
9706
9715
|
function SearchResults2({
|
|
9707
9716
|
state
|
|
@@ -9791,7 +9800,7 @@ function mapResultToTypeaheadOption2(result) {
|
|
|
9791
9800
|
}
|
|
9792
9801
|
function TypeaheadFooter2({ state, isLoading }) {
|
|
9793
9802
|
if (state.type === "noResults") {
|
|
9794
|
-
return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
|
|
9803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components63.Markdown, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: state.message });
|
|
9795
9804
|
}
|
|
9796
9805
|
if (state.type === "error") {
|
|
9797
9806
|
return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(ErrorResult2, { state }) });
|
|
@@ -17948,10 +17957,17 @@ var mapStepToComponent = (_a) => {
|
|
|
17948
17957
|
"displayStepTitle",
|
|
17949
17958
|
"trackEvent"
|
|
17950
17959
|
]);
|
|
17951
|
-
var _a2;
|
|
17960
|
+
var _a2, _b2;
|
|
17952
17961
|
const { httpClient, step, updateComponent } = restProps;
|
|
17953
|
-
const { id, external, key, layout = [], polling } = step;
|
|
17954
|
-
const
|
|
17962
|
+
const { id, navigation, external, key, layout = [], polling } = step;
|
|
17963
|
+
const backNavigation = (_a2 = navigation == null ? void 0 : navigation.back) != null ? _a2 : navigation == null ? void 0 : navigation.backButton;
|
|
17964
|
+
const back = backNavigation ? {
|
|
17965
|
+
title: backNavigation.title,
|
|
17966
|
+
onClick: () => {
|
|
17967
|
+
void restProps.onAction(__spreadProps(__spreadValues({}, backNavigation.action), { skipValidation: true }));
|
|
17968
|
+
}
|
|
17969
|
+
} : void 0;
|
|
17970
|
+
const refreshUrl = (_b2 = step.refreshUrl) != null ? _b2 : step.refreshFormUrl;
|
|
17955
17971
|
const stepId = id || key;
|
|
17956
17972
|
if (stepId === void 0) {
|
|
17957
17973
|
throw new Error("Step must have an id or a key");
|
|
@@ -17984,6 +18000,7 @@ var mapStepToComponent = (_a) => {
|
|
|
17984
18000
|
const stepComponent = createStepComponent({
|
|
17985
18001
|
uid,
|
|
17986
18002
|
components: [...additionalComponents, ...layoutComponents],
|
|
18003
|
+
back,
|
|
17987
18004
|
external,
|
|
17988
18005
|
loadingState,
|
|
17989
18006
|
stepPolling,
|
|
@@ -18086,9 +18103,17 @@ var executeSubmission = async (props) => {
|
|
|
18086
18103
|
return { type: "complete", result };
|
|
18087
18104
|
}
|
|
18088
18105
|
try {
|
|
18106
|
+
const makeRequestBody = () => {
|
|
18107
|
+
var _a;
|
|
18108
|
+
if (method === "GET") {
|
|
18109
|
+
return void 0;
|
|
18110
|
+
}
|
|
18111
|
+
const payload = mergeModels(model, (_a = action.data) != null ? _a : null);
|
|
18112
|
+
return payload !== null ? JSON.stringify(payload) : null;
|
|
18113
|
+
};
|
|
18089
18114
|
const response = await httpClient(url != null ? url : "", {
|
|
18090
18115
|
method,
|
|
18091
|
-
body:
|
|
18116
|
+
body: makeRequestBody(),
|
|
18092
18117
|
headers: { "Content-Type": "application/json" }
|
|
18093
18118
|
});
|
|
18094
18119
|
if (!response.ok) {
|
|
@@ -18147,8 +18172,9 @@ var CoreContainerRenderer = {
|
|
|
18147
18172
|
};
|
|
18148
18173
|
|
|
18149
18174
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
18150
|
-
var stepComponentToProps = ({ external, loadingState, trackEvent }, children) => ({
|
|
18175
|
+
var stepComponentToProps = ({ back, external, loadingState, trackEvent }, children) => ({
|
|
18151
18176
|
type: "step",
|
|
18177
|
+
back,
|
|
18152
18178
|
external,
|
|
18153
18179
|
loadingState,
|
|
18154
18180
|
trackEvent,
|
|
@@ -18838,20 +18864,47 @@ function useExternal2(url) {
|
|
|
18838
18864
|
return { requiresUserConfirmation, dismissConfirmation };
|
|
18839
18865
|
}
|
|
18840
18866
|
|
|
18841
|
-
// src/revamp/renderers/step/
|
|
18867
|
+
// src/revamp/renderers/step/BackButton.tsx
|
|
18868
|
+
var import_components74 = require("@transferwise/components");
|
|
18869
|
+
var import_icons6 = require("@transferwise/icons");
|
|
18842
18870
|
var import_jsx_runtime124 = require("react/jsx-runtime");
|
|
18871
|
+
function BackButton2({ title, onClick }) {
|
|
18872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime124.jsxs)(
|
|
18873
|
+
"a",
|
|
18874
|
+
{
|
|
18875
|
+
href: "/",
|
|
18876
|
+
className: "df-back-btn",
|
|
18877
|
+
"aria-label": title,
|
|
18878
|
+
onClick: (event) => {
|
|
18879
|
+
event.preventDefault();
|
|
18880
|
+
onClick();
|
|
18881
|
+
},
|
|
18882
|
+
children: [
|
|
18883
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsx)("span", { className: "sr-only", children: title }),
|
|
18884
|
+
/* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components74.Avatar, { type: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_icons6.ArrowLeft, { size: "24" }) })
|
|
18885
|
+
]
|
|
18886
|
+
}
|
|
18887
|
+
);
|
|
18888
|
+
}
|
|
18889
|
+
var BackButton_default2 = BackButton2;
|
|
18890
|
+
|
|
18891
|
+
// src/revamp/renderers/step/StepRenderer.tsx
|
|
18892
|
+
var import_jsx_runtime125 = require("react/jsx-runtime");
|
|
18843
18893
|
var StepRenderer = {
|
|
18844
18894
|
canRenderType: "step",
|
|
18845
18895
|
render: StepRendererComponent
|
|
18846
18896
|
};
|
|
18847
18897
|
function StepRendererComponent(props) {
|
|
18848
|
-
const { loadingState, external, trackEvent, children } = props;
|
|
18898
|
+
const { back, loadingState, external, trackEvent, children } = props;
|
|
18849
18899
|
const value = (0, import_react60.useMemo)(() => ({ loadingState, trackEvent }), [loadingState, trackEvent]);
|
|
18850
18900
|
const { requiresUserConfirmation, dismissConfirmation } = useExternal2(external == null ? void 0 : external.url);
|
|
18851
18901
|
if ((external == null ? void 0 : external.url) && requiresUserConfirmation) {
|
|
18852
|
-
return /* @__PURE__ */ (0,
|
|
18902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(ExternalConfirmationDialog, { external, onClose: dismissConfirmation });
|
|
18853
18903
|
}
|
|
18854
|
-
return /* @__PURE__ */ (0,
|
|
18904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(StepRendererContextProvider, { value, children: [
|
|
18905
|
+
back ? /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(BackButton_default2, __spreadValues({}, back)) : null,
|
|
18906
|
+
children
|
|
18907
|
+
] });
|
|
18855
18908
|
}
|
|
18856
18909
|
|
|
18857
18910
|
// src/revamp/utils/findComponent.ts
|
|
@@ -18884,7 +18937,7 @@ function useStableCallback(handler) {
|
|
|
18884
18937
|
}
|
|
18885
18938
|
|
|
18886
18939
|
// src/revamp/DynamicFlowCore.tsx
|
|
18887
|
-
var
|
|
18940
|
+
var import_jsx_runtime126 = require("react/jsx-runtime");
|
|
18888
18941
|
function DynamicFlowCore(props) {
|
|
18889
18942
|
const _a = props, { flowId, initialAction, initialStep, renderers: renderers2, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "renderers", "displayStepTitle"]);
|
|
18890
18943
|
const httpClient = useStableCallback(rest.httpClient);
|
|
@@ -18910,7 +18963,7 @@ function DynamicFlowCore(props) {
|
|
|
18910
18963
|
(0, import_react62.useEffect)(() => {
|
|
18911
18964
|
trackCoreEvent("Initiated");
|
|
18912
18965
|
if (!initialStep && initialAction) {
|
|
18913
|
-
void onAction(initialAction);
|
|
18966
|
+
void onAction(__spreadValues({ method: "GET" }, initialAction));
|
|
18914
18967
|
}
|
|
18915
18968
|
if (initialStep && !initialAction) {
|
|
18916
18969
|
initialiseWithStep(initialStep, null);
|
|
@@ -19003,14 +19056,13 @@ function DynamicFlowCore(props) {
|
|
|
19003
19056
|
[]
|
|
19004
19057
|
);
|
|
19005
19058
|
const onAction = (0, import_react62.useCallback)(async (action) => {
|
|
19006
|
-
var _a2, _b, _c
|
|
19059
|
+
var _a2, _b, _c;
|
|
19007
19060
|
try {
|
|
19008
19061
|
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
|
|
19009
19062
|
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
19010
|
-
const payload = mergeModels(model, (_d = action.data) != null ? _d : null);
|
|
19011
19063
|
const command = await executeSubmission({
|
|
19012
19064
|
action,
|
|
19013
|
-
model
|
|
19065
|
+
model,
|
|
19014
19066
|
isInitial: stepRef.current === null,
|
|
19015
19067
|
httpClient,
|
|
19016
19068
|
trackEvent: trackCoreEvent
|
|
@@ -19088,11 +19140,11 @@ function DynamicFlowCore(props) {
|
|
|
19088
19140
|
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
19089
19141
|
[renderers2]
|
|
19090
19142
|
);
|
|
19091
|
-
return /* @__PURE__ */ (0,
|
|
19143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(ErrorBoundary_default, { onError: closeWithError, children: stepComponent ? render(stepComponent) : null });
|
|
19092
19144
|
}
|
|
19093
19145
|
|
|
19094
19146
|
// src/revamp/DynamicFlowWise.tsx
|
|
19095
|
-
var
|
|
19147
|
+
var import_jsx_runtime127 = require("react/jsx-runtime");
|
|
19096
19148
|
var renderers = getWiseRenderers();
|
|
19097
19149
|
function DynamicFlowWise(props) {
|
|
19098
19150
|
const { httpClient } = props;
|
|
@@ -19101,7 +19153,7 @@ function DynamicFlowWise(props) {
|
|
|
19101
19153
|
() => makeWiseHttpClient(httpClient, locale),
|
|
19102
19154
|
[httpClient, locale]
|
|
19103
19155
|
);
|
|
19104
|
-
return /* @__PURE__ */ (0,
|
|
19156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
|
|
19105
19157
|
}
|
|
19106
19158
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
19107
19159
|
var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
|