@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.mjs CHANGED
@@ -5586,7 +5586,7 @@ var addQueryParameter = (url, key, value) => {
5586
5586
 
5587
5587
  // src/legacy/layout/search/DynamicSearch.tsx
5588
5588
  var import_classnames9 = __toESM(require_classnames());
5589
- import { Typeahead } from "@transferwise/components";
5589
+ import { Markdown as Markdown3, Typeahead } from "@transferwise/components";
5590
5590
  import { jsx as jsx55, jsxs as jsxs21 } from "react/jsx-runtime";
5591
5591
  var DEBOUNCE_TIME = 400;
5592
5592
  function DynamicSearch({ component, onAction }) {
@@ -5632,7 +5632,15 @@ function DynamicSearch({ component, onAction }) {
5632
5632
  name: "typeahead-input-name",
5633
5633
  size: "md",
5634
5634
  maxHeight: 100,
5635
- footer: /* @__PURE__ */ jsx55(TypeaheadFooter, { state: status, results, onRetrySearch }),
5635
+ footer: /* @__PURE__ */ jsx55(
5636
+ TypeaheadFooter,
5637
+ {
5638
+ state: status,
5639
+ results,
5640
+ emptyMessage,
5641
+ onRetrySearch
5642
+ }
5643
+ ),
5636
5644
  multiple: false,
5637
5645
  clearable: false,
5638
5646
  addon: /* @__PURE__ */ jsx55(Search, { size: 24 }),
@@ -5669,10 +5677,11 @@ function mapResultToTypeaheadOption(result) {
5669
5677
  function TypeaheadFooter({
5670
5678
  results,
5671
5679
  state,
5672
- onRetrySearch
5680
+ onRetrySearch,
5681
+ emptyMessage
5673
5682
  }) {
5674
5683
  if (state === "success" && results.length === 0) {
5675
- return /* @__PURE__ */ jsx55("p", { className: "m-t-2 m-x-2", children: "No results found" });
5684
+ return /* @__PURE__ */ jsx55(Markdown3, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: emptyMessage });
5676
5685
  }
5677
5686
  if (state === "error" && results.length === 0) {
5678
5687
  return /* @__PURE__ */ jsx55("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ jsx55(ErrorResult, { onRetrySearch }) });
@@ -8520,7 +8529,7 @@ var Field = ({
8520
8529
  };
8521
8530
 
8522
8531
  // src/revamp/wise/renderers/components/Help.tsx
8523
- import { Info as Info2, Markdown as Markdown3 } from "@transferwise/components";
8532
+ import { Info as Info2, Markdown as Markdown4 } from "@transferwise/components";
8524
8533
  import { useIntl as useIntl19 } from "react-intl";
8525
8534
  import { jsx as jsx76 } from "react/jsx-runtime";
8526
8535
  function Help2({ help }) {
@@ -8529,7 +8538,7 @@ function Help2({ help }) {
8529
8538
  Info2,
8530
8539
  {
8531
8540
  className: "m-l-1",
8532
- content: /* @__PURE__ */ jsx76(Markdown3, { config: { link: { target: "_blank" } }, children: help }),
8541
+ content: /* @__PURE__ */ jsx76(Markdown4, { config: { link: { target: "_blank" } }, children: help }),
8533
8542
  presentation: "POPOVER",
8534
8543
  size: "sm",
8535
8544
  "aria-label": intl.formatMessage(help_messages_default.helpAria)
@@ -9282,11 +9291,11 @@ var LoadingIndicatorRenderer = {
9282
9291
  var LoadingIndicatorRenderer_default = LoadingIndicatorRenderer;
9283
9292
 
9284
9293
  // src/revamp/wise/renderers/MarkdownRenderer.tsx
9285
- import { Markdown as Markdown4 } from "@transferwise/components";
9294
+ import { Markdown as Markdown5 } from "@transferwise/components";
9286
9295
  import { jsx as jsx98 } from "react/jsx-runtime";
9287
9296
  var MarkdownRenderer = {
9288
9297
  canRenderType: "markdown",
9289
- render: ({ content, align, margin }) => /* @__PURE__ */ jsx98("div", { className: getTextAlignmentAndMargin2({ align, margin }), children: /* @__PURE__ */ jsx98(Markdown4, { config: { link: { target: "_blank" } }, children: content }) })
9298
+ render: ({ content, align, margin }) => /* @__PURE__ */ jsx98("div", { className: getTextAlignmentAndMargin2({ align, margin }), children: /* @__PURE__ */ jsx98(Markdown5, { config: { link: { target: "_blank" } }, children: content }) })
9290
9299
  };
9291
9300
  var MarkdownRenderer_default = MarkdownRenderer;
9292
9301
 
@@ -9619,7 +9628,7 @@ function ItemSummaryOption2({
9619
9628
  var RepeatableRenderer_default = RepeatableRenderer;
9620
9629
 
9621
9630
  // src/revamp/wise/renderers/SearchRenderer/BlockSearchRendererComponent.tsx
9622
- import { Input as Input6, NavigationOption as NavigationOption7, NavigationOptionsList as NavigationOptionsList4 } from "@transferwise/components";
9631
+ import { Input as Input6, Markdown as Markdown6, NavigationOption as NavigationOption7, NavigationOptionsList as NavigationOptionsList4 } from "@transferwise/components";
9623
9632
 
9624
9633
  // src/revamp/wise/renderers/SearchRenderer/ErrorResult.tsx
9625
9634
  import { useIntl as useIntl22 } from "react-intl";
@@ -9695,7 +9704,7 @@ function SearchResultContent({
9695
9704
  }
9696
9705
  }
9697
9706
  function EmptySearchResult({ state }) {
9698
- return /* @__PURE__ */ jsx106("p", { className: "m-t-2", children: state.message });
9707
+ return /* @__PURE__ */ jsx106(Markdown6, { className: "m-t-2", config: { link: { target: "_blank" } }, children: state.message });
9699
9708
  }
9700
9709
  function SearchResults2({
9701
9710
  state
@@ -9722,7 +9731,7 @@ function SearchResults2({
9722
9731
  var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
9723
9732
 
9724
9733
  // src/revamp/wise/renderers/SearchRenderer/InlineSearchRendererComponent.tsx
9725
- import { Typeahead as Typeahead2 } from "@transferwise/components";
9734
+ import { Markdown as Markdown7, Typeahead as Typeahead2 } from "@transferwise/components";
9726
9735
  import { Search as Search2 } from "@transferwise/icons";
9727
9736
  import { useState as useState32 } from "react";
9728
9737
  import { jsx as jsx107, jsxs as jsxs43 } from "react/jsx-runtime";
@@ -9785,7 +9794,7 @@ function mapResultToTypeaheadOption2(result) {
9785
9794
  }
9786
9795
  function TypeaheadFooter2({ state, isLoading }) {
9787
9796
  if (state.type === "noResults") {
9788
- return /* @__PURE__ */ jsx107("p", { className: "m-t-2 m-x-2", children: "No results found" });
9797
+ return /* @__PURE__ */ jsx107(Markdown7, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: state.message });
9789
9798
  }
9790
9799
  if (state.type === "error") {
9791
9800
  return /* @__PURE__ */ jsx107("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ jsx107(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 refreshUrl = (_a2 = step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
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: method === "GET" ? void 0 : JSON.stringify(model),
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,
@@ -18785,7 +18811,7 @@ import { useMemo as useMemo18 } from "react";
18785
18811
 
18786
18812
  // src/revamp/renderers/step/ExternalConfirmationDialog.tsx
18787
18813
  import { useIntl as useIntl23 } from "react-intl";
18788
- import { Button as Button11, Markdown as Markdown5 } from "@transferwise/components";
18814
+ import { Button as Button11, Markdown as Markdown8 } from "@transferwise/components";
18789
18815
  import { jsx as jsx122, jsxs as jsxs49 } from "react/jsx-runtime";
18790
18816
  function ExternalConfirmationDialog({
18791
18817
  external,
@@ -18794,7 +18820,7 @@ function ExternalConfirmationDialog({
18794
18820
  const { formatMessage } = useIntl23();
18795
18821
  return /* @__PURE__ */ jsx122("div", { className: "df-box-renderer-fixed-width", children: /* @__PURE__ */ jsxs49("div", { className: "df-box-renderer-width-lg", children: [
18796
18822
  /* @__PURE__ */ jsx122("h2", { className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.title) }),
18797
- /* @__PURE__ */ jsx122(Markdown5, { config: { link: { target: "_blank" } }, className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.description, { origin: getOrigin2(external.url) }) }),
18823
+ /* @__PURE__ */ jsx122(Markdown8, { config: { link: { target: "_blank" } }, className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.description, { origin: getOrigin2(external.url) }) }),
18798
18824
  /* @__PURE__ */ jsx122("div", { className: "df-box-renderer-fixed-width", children: /* @__PURE__ */ jsxs49("div", { className: "df-box-renderer-width-lg", children: [
18799
18825
  /* @__PURE__ */ jsx122(
18800
18826
  Button11,
@@ -18838,20 +18864,47 @@ function useExternal2(url) {
18838
18864
  return { requiresUserConfirmation, dismissConfirmation };
18839
18865
  }
18840
18866
 
18867
+ // src/revamp/renderers/step/BackButton.tsx
18868
+ import { Avatar as Avatar7 } from "@transferwise/components";
18869
+ import { ArrowLeft as ArrowLeft2 } from "@transferwise/icons";
18870
+ import { jsx as jsx123, jsxs as jsxs50 } from "react/jsx-runtime";
18871
+ function BackButton2({ title, onClick }) {
18872
+ return /* @__PURE__ */ jsxs50(
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__ */ jsx123("span", { className: "sr-only", children: title }),
18884
+ /* @__PURE__ */ jsx123(Avatar7, { type: "icon", children: /* @__PURE__ */ jsx123(ArrowLeft2, { size: "24" }) })
18885
+ ]
18886
+ }
18887
+ );
18888
+ }
18889
+ var BackButton_default2 = BackButton2;
18890
+
18841
18891
  // src/revamp/renderers/step/StepRenderer.tsx
18842
- import { jsx as jsx123 } from "react/jsx-runtime";
18892
+ import { jsx as jsx124, jsxs as jsxs51 } from "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 = useMemo18(() => ({ 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__ */ jsx123(ExternalConfirmationDialog, { external, onClose: dismissConfirmation });
18902
+ return /* @__PURE__ */ jsx124(ExternalConfirmationDialog, { external, onClose: dismissConfirmation });
18853
18903
  }
18854
- return /* @__PURE__ */ jsx123(StepRendererContextProvider, { value, children });
18904
+ return /* @__PURE__ */ jsxs51(StepRendererContextProvider, { value, children: [
18905
+ back ? /* @__PURE__ */ jsx124(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
- import { jsx as jsx124 } from "react/jsx-runtime";
18940
+ import { jsx as jsx125 } from "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
  useEffect25(() => {
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 = useCallback11(async (action) => {
19006
- var _a2, _b, _c, _d;
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: payload,
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__ */ jsx124(ErrorBoundary_default, { onError: closeWithError, children: stepComponent ? render(stepComponent) : null });
19143
+ return /* @__PURE__ */ jsx125(ErrorBoundary_default, { onError: closeWithError, children: stepComponent ? render(stepComponent) : null });
19092
19144
  }
19093
19145
 
19094
19146
  // src/revamp/DynamicFlowWise.tsx
19095
- import { jsx as jsx125 } from "react/jsx-runtime";
19147
+ import { jsx as jsx126 } from "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__ */ jsx125(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ jsx125(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
19156
+ return /* @__PURE__ */ jsx126(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ jsx126(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
19105
19157
  }
19106
19158
  var DynamicFlowWise_default = DynamicFlowWise;
19107
19159
  var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
@@ -4,6 +4,7 @@ import type { AnalyticsEventDispatcher } from '../features/events';
4
4
  import type { StepPolling } from '../features/polling/getStepPolling';
5
5
  export type StepDomainComponent = BaseComponent & {
6
6
  type: 'step';
7
+ back?: BackNavigation;
7
8
  components: DomainComponent[];
8
9
  external?: Step['external'];
9
10
  loadingState: LoadingState;
@@ -13,7 +14,12 @@ export type StepDomainComponent = BaseComponent & {
13
14
  stop: () => void;
14
15
  trackEvent: AnalyticsEventDispatcher<string>;
15
16
  };
16
- export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "external" | "components" | "loadingState" | "uid" | "trackEvent"> & {
17
+ type BackNavigation = {
18
+ title?: string;
19
+ onClick: () => void;
20
+ };
21
+ export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "external" | "components" | "back" | "loadingState" | "uid" | "trackEvent"> & {
17
22
  stepPolling?: StepPolling | undefined;
18
23
  updateComponent: UpdateComponent;
19
24
  }) => StepDomainComponent;
25
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { StepRendererProps } from '../types';
2
+ declare function BackButton({ title, onClick }: NonNullable<StepRendererProps['back']>): JSX.Element;
3
+ export default BackButton;
@@ -1,4 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { StepDomainComponent } from '../domain/components/StepDomainComponent';
3
3
  import type { StepRendererProps } from './types';
4
- export declare const stepComponentToProps: ({ external, loadingState, trackEvent }: StepDomainComponent, children: ReactNode) => StepRendererProps;
4
+ export declare const stepComponentToProps: ({ back, external, loadingState, trackEvent }: StepDomainComponent, children: ReactNode) => StepRendererProps;
@@ -25,6 +25,10 @@ export type RendererProps = StepRendererProps | CoreContainerRendererProps | Ale
25
25
  export type StepRendererProps = {
26
26
  type: 'step';
27
27
  control?: string;
28
+ back?: {
29
+ title?: string;
30
+ onClick: () => void;
31
+ };
28
32
  external?: {
29
33
  url: string;
30
34
  };
@@ -148,7 +152,6 @@ export type SearchRendererProps = {
148
152
  type: 'search';
149
153
  control?: string;
150
154
  id: string;
151
- emptyMessage?: string;
152
155
  isLoading: boolean;
153
156
  margin: Margin;
154
157
  query: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -92,7 +92,7 @@
92
92
  "classnames": "2.5.1",
93
93
  "react-webcam": "^7.2.0",
94
94
  "screenfull": "^5.2.0",
95
- "@wise/dynamic-flow-types": "2.13.0"
95
+ "@wise/dynamic-flow-types": "2.14.0"
96
96
  },
97
97
  "scripts": {
98
98
  "dev": "storybook dev -p 3003",