@wise/dynamic-flow-client 3.6.0 → 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 +80 -25
- package/build/main.min.js +1 -1
- package/build/main.mjs +89 -34
- package/build/types/legacy/formControl/FormControl.d.ts +1 -0
- 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
|
@@ -2515,7 +2515,7 @@ function ControlFeedback(props) {
|
|
|
2515
2515
|
const validationMessages = __spreadValues(__spreadValues(__spreadValues({}, defaultValidationMessages), props.validationMessages), props.schema.validationMessages);
|
|
2516
2516
|
const isErrorVisible = (props.submitted || !props.changed) && Boolean(props.errors);
|
|
2517
2517
|
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && Boolean((_a = props.validations) == null ? void 0 : _a.length);
|
|
2518
|
-
const isDescriptionVisible = props.schema.description && !isErrorVisible && !isValidationVisible;
|
|
2518
|
+
const isDescriptionVisible = props.schema.type !== "boolean" && props.schema.description && !isErrorVisible && !isValidationVisible;
|
|
2519
2519
|
const hasInfoMessage = Boolean(props.infoMessage);
|
|
2520
2520
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { id: props.id, children: [
|
|
2521
2521
|
isErrorVisible ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.InlineAlert, { type: "error", children: props.errors }) : null,
|
|
@@ -3869,6 +3869,7 @@ var _FormControl = class _FormControl extends import_react19.PureComponent {
|
|
|
3869
3869
|
size,
|
|
3870
3870
|
uploadProps,
|
|
3871
3871
|
label,
|
|
3872
|
+
description,
|
|
3872
3873
|
monthFormat,
|
|
3873
3874
|
// FIXME pass id to all components that accept it
|
|
3874
3875
|
id,
|
|
@@ -3896,6 +3897,7 @@ var _FormControl = class _FormControl extends import_react19.PureComponent {
|
|
|
3896
3897
|
checked: getSafeBooleanValue(value, { coerceValue: true }),
|
|
3897
3898
|
disabled,
|
|
3898
3899
|
label,
|
|
3900
|
+
secondary: description,
|
|
3899
3901
|
required,
|
|
3900
3902
|
readOnly,
|
|
3901
3903
|
onChange: this.handleOnChange,
|
|
@@ -4294,6 +4296,7 @@ function SchemaFormControl(props) {
|
|
|
4294
4296
|
id,
|
|
4295
4297
|
name: id,
|
|
4296
4298
|
label: schema.title,
|
|
4299
|
+
description: schema.description,
|
|
4297
4300
|
options: options || [],
|
|
4298
4301
|
placeholder: schema.placeholder,
|
|
4299
4302
|
autoComplete: !schema.help,
|
|
@@ -5635,7 +5638,15 @@ function DynamicSearch({ component, onAction }) {
|
|
|
5635
5638
|
name: "typeahead-input-name",
|
|
5636
5639
|
size: "md",
|
|
5637
5640
|
maxHeight: 100,
|
|
5638
|
-
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
|
+
),
|
|
5639
5650
|
multiple: false,
|
|
5640
5651
|
clearable: false,
|
|
5641
5652
|
addon: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_icons2.Search, { size: 24 }),
|
|
@@ -5672,10 +5683,11 @@ function mapResultToTypeaheadOption(result) {
|
|
|
5672
5683
|
function TypeaheadFooter({
|
|
5673
5684
|
results,
|
|
5674
5685
|
state,
|
|
5675
|
-
onRetrySearch
|
|
5686
|
+
onRetrySearch,
|
|
5687
|
+
emptyMessage
|
|
5676
5688
|
}) {
|
|
5677
5689
|
if (state === "success" && results.length === 0) {
|
|
5678
|
-
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 });
|
|
5679
5691
|
}
|
|
5680
5692
|
if (state === "error" && results.length === 0) {
|
|
5681
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 }) });
|
|
@@ -8565,8 +8577,8 @@ var BooleanInputRenderer = {
|
|
|
8565
8577
|
canRenderType: "input-boolean",
|
|
8566
8578
|
render: (props) => {
|
|
8567
8579
|
const _a = props, { id, control, label = "", description, help, error, type, value } = _a, rest = __objRest(_a, ["id", "control", "label", "description", "help", "error", "type", "value"]);
|
|
8568
|
-
const checkboxProps = __spreadProps(__spreadValues({}, rest), { label, checked: value });
|
|
8569
|
-
return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(FieldInput_default, { id, label: "", description, error, help, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components43.Checkbox, __spreadValues({ id }, checkboxProps)) });
|
|
8580
|
+
const checkboxProps = __spreadProps(__spreadValues({}, rest), { label, secondary: description, checked: value });
|
|
8581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(FieldInput_default, { id, label: "", description: "", error, help, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components43.Checkbox, __spreadValues({ id }, checkboxProps)) });
|
|
8570
8582
|
}
|
|
8571
8583
|
};
|
|
8572
8584
|
var BooleanInputRenderer_default = BooleanInputRenderer;
|
|
@@ -9698,7 +9710,7 @@ function SearchResultContent({
|
|
|
9698
9710
|
}
|
|
9699
9711
|
}
|
|
9700
9712
|
function EmptySearchResult({ state }) {
|
|
9701
|
-
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 });
|
|
9702
9714
|
}
|
|
9703
9715
|
function SearchResults2({
|
|
9704
9716
|
state
|
|
@@ -9788,7 +9800,7 @@ function mapResultToTypeaheadOption2(result) {
|
|
|
9788
9800
|
}
|
|
9789
9801
|
function TypeaheadFooter2({ state, isLoading }) {
|
|
9790
9802
|
if (state.type === "noResults") {
|
|
9791
|
-
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 });
|
|
9792
9804
|
}
|
|
9793
9805
|
if (state.type === "error") {
|
|
9794
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 }) });
|
|
@@ -17945,10 +17957,17 @@ var mapStepToComponent = (_a) => {
|
|
|
17945
17957
|
"displayStepTitle",
|
|
17946
17958
|
"trackEvent"
|
|
17947
17959
|
]);
|
|
17948
|
-
var _a2;
|
|
17960
|
+
var _a2, _b2;
|
|
17949
17961
|
const { httpClient, step, updateComponent } = restProps;
|
|
17950
|
-
const { id, external, key, layout = [], polling } = step;
|
|
17951
|
-
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;
|
|
17952
17971
|
const stepId = id || key;
|
|
17953
17972
|
if (stepId === void 0) {
|
|
17954
17973
|
throw new Error("Step must have an id or a key");
|
|
@@ -17981,6 +18000,7 @@ var mapStepToComponent = (_a) => {
|
|
|
17981
18000
|
const stepComponent = createStepComponent({
|
|
17982
18001
|
uid,
|
|
17983
18002
|
components: [...additionalComponents, ...layoutComponents],
|
|
18003
|
+
back,
|
|
17984
18004
|
external,
|
|
17985
18005
|
loadingState,
|
|
17986
18006
|
stepPolling,
|
|
@@ -18083,9 +18103,17 @@ var executeSubmission = async (props) => {
|
|
|
18083
18103
|
return { type: "complete", result };
|
|
18084
18104
|
}
|
|
18085
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
|
+
};
|
|
18086
18114
|
const response = await httpClient(url != null ? url : "", {
|
|
18087
18115
|
method,
|
|
18088
|
-
body:
|
|
18116
|
+
body: makeRequestBody(),
|
|
18089
18117
|
headers: { "Content-Type": "application/json" }
|
|
18090
18118
|
});
|
|
18091
18119
|
if (!response.ok) {
|
|
@@ -18144,8 +18172,9 @@ var CoreContainerRenderer = {
|
|
|
18144
18172
|
};
|
|
18145
18173
|
|
|
18146
18174
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
18147
|
-
var stepComponentToProps = ({ external, loadingState, trackEvent }, children) => ({
|
|
18175
|
+
var stepComponentToProps = ({ back, external, loadingState, trackEvent }, children) => ({
|
|
18148
18176
|
type: "step",
|
|
18177
|
+
back,
|
|
18149
18178
|
external,
|
|
18150
18179
|
loadingState,
|
|
18151
18180
|
trackEvent,
|
|
@@ -18835,20 +18864,47 @@ function useExternal2(url) {
|
|
|
18835
18864
|
return { requiresUserConfirmation, dismissConfirmation };
|
|
18836
18865
|
}
|
|
18837
18866
|
|
|
18838
|
-
// 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");
|
|
18839
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");
|
|
18840
18893
|
var StepRenderer = {
|
|
18841
18894
|
canRenderType: "step",
|
|
18842
18895
|
render: StepRendererComponent
|
|
18843
18896
|
};
|
|
18844
18897
|
function StepRendererComponent(props) {
|
|
18845
|
-
const { loadingState, external, trackEvent, children } = props;
|
|
18898
|
+
const { back, loadingState, external, trackEvent, children } = props;
|
|
18846
18899
|
const value = (0, import_react60.useMemo)(() => ({ loadingState, trackEvent }), [loadingState, trackEvent]);
|
|
18847
18900
|
const { requiresUserConfirmation, dismissConfirmation } = useExternal2(external == null ? void 0 : external.url);
|
|
18848
18901
|
if ((external == null ? void 0 : external.url) && requiresUserConfirmation) {
|
|
18849
|
-
return /* @__PURE__ */ (0,
|
|
18902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(ExternalConfirmationDialog, { external, onClose: dismissConfirmation });
|
|
18850
18903
|
}
|
|
18851
|
-
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
|
+
] });
|
|
18852
18908
|
}
|
|
18853
18909
|
|
|
18854
18910
|
// src/revamp/utils/findComponent.ts
|
|
@@ -18881,7 +18937,7 @@ function useStableCallback(handler) {
|
|
|
18881
18937
|
}
|
|
18882
18938
|
|
|
18883
18939
|
// src/revamp/DynamicFlowCore.tsx
|
|
18884
|
-
var
|
|
18940
|
+
var import_jsx_runtime126 = require("react/jsx-runtime");
|
|
18885
18941
|
function DynamicFlowCore(props) {
|
|
18886
18942
|
const _a = props, { flowId, initialAction, initialStep, renderers: renderers2, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "renderers", "displayStepTitle"]);
|
|
18887
18943
|
const httpClient = useStableCallback(rest.httpClient);
|
|
@@ -18907,7 +18963,7 @@ function DynamicFlowCore(props) {
|
|
|
18907
18963
|
(0, import_react62.useEffect)(() => {
|
|
18908
18964
|
trackCoreEvent("Initiated");
|
|
18909
18965
|
if (!initialStep && initialAction) {
|
|
18910
|
-
void onAction(initialAction);
|
|
18966
|
+
void onAction(__spreadValues({ method: "GET" }, initialAction));
|
|
18911
18967
|
}
|
|
18912
18968
|
if (initialStep && !initialAction) {
|
|
18913
18969
|
initialiseWithStep(initialStep, null);
|
|
@@ -19000,14 +19056,13 @@ function DynamicFlowCore(props) {
|
|
|
19000
19056
|
[]
|
|
19001
19057
|
);
|
|
19002
19058
|
const onAction = (0, import_react62.useCallback)(async (action) => {
|
|
19003
|
-
var _a2, _b, _c
|
|
19059
|
+
var _a2, _b, _c;
|
|
19004
19060
|
try {
|
|
19005
19061
|
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
|
|
19006
19062
|
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
19007
|
-
const payload = mergeModels(model, (_d = action.data) != null ? _d : null);
|
|
19008
19063
|
const command = await executeSubmission({
|
|
19009
19064
|
action,
|
|
19010
|
-
model
|
|
19065
|
+
model,
|
|
19011
19066
|
isInitial: stepRef.current === null,
|
|
19012
19067
|
httpClient,
|
|
19013
19068
|
trackEvent: trackCoreEvent
|
|
@@ -19085,11 +19140,11 @@ function DynamicFlowCore(props) {
|
|
|
19085
19140
|
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
19086
19141
|
[renderers2]
|
|
19087
19142
|
);
|
|
19088
|
-
return /* @__PURE__ */ (0,
|
|
19143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(ErrorBoundary_default, { onError: closeWithError, children: stepComponent ? render(stepComponent) : null });
|
|
19089
19144
|
}
|
|
19090
19145
|
|
|
19091
19146
|
// src/revamp/DynamicFlowWise.tsx
|
|
19092
|
-
var
|
|
19147
|
+
var import_jsx_runtime127 = require("react/jsx-runtime");
|
|
19093
19148
|
var renderers = getWiseRenderers();
|
|
19094
19149
|
function DynamicFlowWise(props) {
|
|
19095
19150
|
const { httpClient } = props;
|
|
@@ -19098,7 +19153,7 @@ function DynamicFlowWise(props) {
|
|
|
19098
19153
|
() => makeWiseHttpClient(httpClient, locale),
|
|
19099
19154
|
[httpClient, locale]
|
|
19100
19155
|
);
|
|
19101
|
-
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 })) });
|
|
19102
19157
|
}
|
|
19103
19158
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
19104
19159
|
var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
|