@wise/dynamic-flow-client-internal 5.13.3 → 5.14.0-experimental-context-menu-version-6a043b0

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
@@ -120,6 +120,12 @@ import { makeHttpClient } from "@wise/dynamic-flow-client";
120
120
  // src/dynamicFlow/DynamicFlow.tsx
121
121
  import { useDynamicFlow } from "@wise/dynamic-flow-client";
122
122
 
123
+ // src/dynamicFlow/telemetry/app-version.ts
124
+ var appVersion = (
125
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
126
+ typeof process !== "undefined" ? "5.13.4" : "0.0.0"
127
+ );
128
+
123
129
  // src/dynamicFlow/context-menu/useContextMenu.tsx
124
130
  import { useCallback, useEffect, useState } from "react";
125
131
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -182,15 +188,21 @@ var useDFContextMenu = (controller) => {
182
188
  };
183
189
  const getEncodedCurrentStep = () => {
184
190
  const step = controller.getCurrentStep();
185
- return step ? toBase64(JSON.stringify(step, null, 2)) : null;
191
+ return step ? toBase64(JSON.stringify(recursivelyRemoveNullUndefined(step), null, 2)) : null;
186
192
  };
187
193
  const getEncodedCurrentStepWithModel = async () => {
188
194
  const step = await getCurrentStepWithModel();
189
- return step ? toBase64(JSON.stringify(step, null, 2)) : null;
195
+ return step ? toBase64(JSON.stringify(recursivelyRemoveNullUndefined(step), null, 2)) : null;
190
196
  };
191
197
  return useContextMenu({
192
198
  title: "DynamicFlow Menu (Dev/Staging only)",
193
199
  items: isDevOrStaging() ? [
200
+ {
201
+ label: `DF client version: ${appVersion}`,
202
+ onClick: () => {
203
+ copyToClipboard(`@wise/dynamic-flow-client-internal@${appVersion}`);
204
+ }
205
+ },
194
206
  {
195
207
  label: "Open in Sandbox",
196
208
  onClick: () => {
@@ -228,9 +240,13 @@ var openInSandbox = (base64Step) => {
228
240
  window.open(`https://df.wise.com/sandbox#${base64Step}`, "_blank");
229
241
  }
230
242
  };
231
- var copyToClipboard = (step) => {
232
- if (step) {
233
- void navigator.clipboard.writeText(JSON.stringify(step, null, 2));
243
+ var copyToClipboard = (value) => {
244
+ if (typeof value === "string") {
245
+ void navigator.clipboard.writeText(value);
246
+ return;
247
+ }
248
+ if (value) {
249
+ void navigator.clipboard.writeText(JSON.stringify(value, null, 2));
234
250
  }
235
251
  };
236
252
  var isDevOrStaging = () => {
@@ -250,16 +266,22 @@ var isDevOrStaging = () => {
250
266
  return false;
251
267
  }
252
268
  };
269
+ var recursivelyRemoveNullUndefined = (element) => {
270
+ if (Array.isArray(element)) {
271
+ return element.map(recursivelyRemoveNullUndefined);
272
+ }
273
+ if (element !== null && typeof element === "object") {
274
+ return Object.entries(element).reduce(
275
+ (acc, [key, value]) => value !== null && value !== void 0 ? __spreadProps(__spreadValues({}, acc), { [key]: recursivelyRemoveNullUndefined(value) }) : acc,
276
+ {}
277
+ );
278
+ }
279
+ return element;
280
+ };
253
281
 
254
282
  // src/dynamicFlow/useWiseToCoreProps.tsx
255
283
  import { useMemo as useMemo2 } from "react";
256
284
 
257
- // src/dynamicFlow/telemetry/app-version.ts
258
- var appVersion = (
259
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
260
- typeof process !== "undefined" ? "5.13.3" : "0.0.0"
261
- );
262
-
263
285
  // src/dynamicFlow/telemetry/getLogEvent.ts
264
286
  var getLogEvent = (onLog) => (level, message, extra) => {
265
287
  const extraWithVersion = __spreadProps(__spreadValues({}, extra), {
@@ -435,7 +457,7 @@ function AddressValidationButtonComponent(props) {
435
457
  block: true,
436
458
  disabled,
437
459
  priority: "primary",
438
- size: "md",
460
+ size: "lg",
439
461
  loading: spinny,
440
462
  onClick: () => {
441
463
  setSpinny(true);
@@ -3560,14 +3582,103 @@ var useCustomTheme = (theme, trackEvent) => {
3560
3582
  }, []);
3561
3583
  };
3562
3584
 
3585
+ // ../renderers/src/step/StepFooter.tsx
3586
+ import { Button as Button7 } from "@transferwise/components";
3587
+ import { useEffect as useEffect10, useRef, useState as useState12 } from "react";
3588
+ import { useIntl as useIntl14 } from "react-intl";
3589
+
3590
+ // ../renderers/src/messages/step.messages.ts
3591
+ import { defineMessages as defineMessages11 } from "react-intl";
3592
+ var step_messages_default = defineMessages11({
3593
+ scrollToBottom: {
3594
+ id: "df.wise.step.scrollToBottom",
3595
+ defaultMessage: "Scroll to bottom",
3596
+ description: "Label for a button that appears when the content of a step is too long and the user needs to scroll to the bottom to see all the content."
3597
+ }
3598
+ });
3599
+
3600
+ // ../renderers/src/step/StepFooter.tsx
3601
+ import { Fragment as Fragment13, jsx as jsx76, jsxs as jsxs26 } from "react/jsx-runtime";
3602
+ var SCROLL_TO_BOTTOM = "scroll-to-bottom";
3603
+ var StepFooter = ({ footer, tags }) => {
3604
+ if (tags == null ? void 0 : tags.includes(SCROLL_TO_BOTTOM)) {
3605
+ return /* @__PURE__ */ jsx76(FooterWithScrollButton, { footer });
3606
+ }
3607
+ return /* @__PURE__ */ jsx76(DefaultFooter, { footer });
3608
+ };
3609
+ var DefaultFooter = ({ footer }) => {
3610
+ const hasFooter = footer && Array.isArray(footer) && footer.length > 0;
3611
+ return hasFooter ? /* @__PURE__ */ jsx76("div", { className: "df-step-fixed__footer", children: footer }) : void 0;
3612
+ };
3613
+ var FooterWithScrollButton = ({ footer }) => {
3614
+ const { formatMessage } = useIntl14();
3615
+ const endOfLayoutRef = useRef(null);
3616
+ const isElementVisible = useIsElementVisible(endOfLayoutRef);
3617
+ const scrollButton = /* @__PURE__ */ jsx76(
3618
+ Button7,
3619
+ {
3620
+ className: "m-b-1",
3621
+ v2: true,
3622
+ block: true,
3623
+ priority: "tertiary",
3624
+ onClick: () => {
3625
+ var _a;
3626
+ (_a = endOfLayoutRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
3627
+ },
3628
+ children: formatMessage(step_messages_default.scrollToBottom)
3629
+ }
3630
+ );
3631
+ const hasStepFooterContent = footer && Array.isArray(footer) && footer.length > 0;
3632
+ if (isElementVisible && !hasStepFooterContent) {
3633
+ return /* @__PURE__ */ jsx76("div", { ref: endOfLayoutRef, "aria-hidden": "true" });
3634
+ }
3635
+ return /* @__PURE__ */ jsxs26(Fragment13, { children: [
3636
+ /* @__PURE__ */ jsx76("div", { ref: endOfLayoutRef, "aria-hidden": "true" }),
3637
+ /* @__PURE__ */ jsxs26("div", { className: "df-step-fixed__footer", children: [
3638
+ !isElementVisible && scrollButton,
3639
+ footer
3640
+ ] })
3641
+ ] });
3642
+ };
3643
+ var useIsElementVisible = (elementRef) => {
3644
+ const [isVisible, setIsVisible] = useState12(false);
3645
+ useEffect10(() => {
3646
+ const element = elementRef.current;
3647
+ if (!element) return;
3648
+ const observer = new IntersectionObserver(([entry]) => {
3649
+ setIsVisible(entry.isIntersecting);
3650
+ });
3651
+ observer.observe(element);
3652
+ return () => observer.disconnect();
3653
+ }, [elementRef]);
3654
+ return isVisible;
3655
+ };
3656
+
3657
+ // ../renderers/src/step/StepHeader.tsx
3658
+ import { Title as Title2 } from "@transferwise/components";
3659
+ import { Fragment as Fragment14, jsx as jsx77, jsxs as jsxs27 } from "react/jsx-runtime";
3660
+ var StepHeader = ({ title, description, tags }) => {
3661
+ const { titleType, alignmentClassName } = getHeaderStyle(tags);
3662
+ return /* @__PURE__ */ jsxs27(Fragment14, { children: [
3663
+ title ? /* @__PURE__ */ jsx77(Title2, { as: "h1", type: titleType, className: `${alignmentClassName} m-b-2`, children: title }) : void 0,
3664
+ description ? /* @__PURE__ */ jsx77("p", { className: `${alignmentClassName} np-text-body-large`, children: description }) : void 0
3665
+ ] });
3666
+ };
3667
+ var getHeaderStyle = (tags) => {
3668
+ if (tags == null ? void 0 : tags.includes("root-screen")) {
3669
+ return { titleType: "title-screen", alignmentClassName: "text-xs-left" };
3670
+ }
3671
+ return { titleType: "title-section", alignmentClassName: "text-xs-center" };
3672
+ };
3673
+
3563
3674
  // ../renderers/src/step/topbar/BackButton.tsx
3564
3675
  import { IconButton } from "@transferwise/components";
3565
3676
  import { ArrowLeft } from "@transferwise/icons";
3566
- import { useIntl as useIntl14 } from "react-intl";
3677
+ import { useIntl as useIntl15 } from "react-intl";
3567
3678
 
3568
3679
  // ../renderers/src/messages/back.messages.ts
3569
- import { defineMessages as defineMessages11 } from "react-intl";
3570
- var back_messages_default = defineMessages11({
3680
+ import { defineMessages as defineMessages12 } from "react-intl";
3681
+ var back_messages_default = defineMessages12({
3571
3682
  back: {
3572
3683
  id: "df.wise.back.label",
3573
3684
  defaultMessage: "Back",
@@ -3576,30 +3687,30 @@ var back_messages_default = defineMessages11({
3576
3687
  });
3577
3688
 
3578
3689
  // ../renderers/src/step/topbar/BackButton.tsx
3579
- import { jsx as jsx76, jsxs as jsxs26 } from "react/jsx-runtime";
3690
+ import { jsx as jsx78, jsxs as jsxs28 } from "react/jsx-runtime";
3580
3691
  function BackButton({ title, onClick }) {
3581
- const { formatMessage } = useIntl14();
3582
- return /* @__PURE__ */ jsxs26(IconButton, { className: "df-back-button", priority: "tertiary", onClick, children: [
3583
- /* @__PURE__ */ jsx76("span", { className: "sr-only", children: title != null ? title : formatMessage(back_messages_default.back) }),
3584
- /* @__PURE__ */ jsx76(ArrowLeft, {})
3692
+ const { formatMessage } = useIntl15();
3693
+ return /* @__PURE__ */ jsxs28(IconButton, { className: "df-back-button", priority: "tertiary", onClick, children: [
3694
+ /* @__PURE__ */ jsx78("span", { className: "sr-only", children: title != null ? title : formatMessage(back_messages_default.back) }),
3695
+ /* @__PURE__ */ jsx78(ArrowLeft, {})
3585
3696
  ] });
3586
3697
  }
3587
3698
 
3588
3699
  // ../renderers/src/step/topbar/Toolbar.tsx
3589
- import { Button as Button7, IconButton as IconButton2 } from "@transferwise/components";
3590
- import { jsx as jsx77, jsxs as jsxs27 } from "react/jsx-runtime";
3700
+ import { Button as Button8, IconButton as IconButton2 } from "@transferwise/components";
3701
+ import { jsx as jsx79, jsxs as jsxs29 } from "react/jsx-runtime";
3591
3702
  var Toolbar = ({ items }) => {
3592
- return (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ jsx77("div", { className: "df-toolbar", children: items.map((item, index) => /* @__PURE__ */ jsx77(ToolbarButton, __spreadValues({}, item), `${item.type}-${index}-${item.title}`)) }) : null;
3703
+ return (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ jsx79("div", { className: "df-toolbar", children: items.map((item, index) => /* @__PURE__ */ jsx79(ToolbarButton, __spreadValues({}, item), `${item.type}-${index}-${item.title}`)) }) : null;
3593
3704
  };
3594
3705
  function ToolbarButton(props) {
3595
- return prefersMedia(props.control) ? /* @__PURE__ */ jsx77(MediaToolbarButton, __spreadValues({}, props)) : /* @__PURE__ */ jsx77(TextToolbarButton, __spreadValues({}, props));
3706
+ return prefersMedia(props.control) ? /* @__PURE__ */ jsx79(MediaToolbarButton, __spreadValues({}, props)) : /* @__PURE__ */ jsx79(TextToolbarButton, __spreadValues({}, props));
3596
3707
  }
3597
3708
  function MediaToolbarButton(props) {
3598
3709
  var _a;
3599
3710
  const { context, control, media, accessibilityDescription, disabled, onClick } = props;
3600
3711
  const priority = getIconButtonPriority(control);
3601
3712
  const type = getSentiment2(context);
3602
- return /* @__PURE__ */ jsxs27(
3713
+ return /* @__PURE__ */ jsxs29(
3603
3714
  IconButton2,
3604
3715
  {
3605
3716
  className: "df-toolbar-button",
@@ -3609,7 +3720,7 @@ function MediaToolbarButton(props) {
3609
3720
  type,
3610
3721
  onClick,
3611
3722
  children: [
3612
- accessibilityDescription ? /* @__PURE__ */ jsx77("span", { className: "sr-only", children: accessibilityDescription }) : null,
3723
+ accessibilityDescription ? /* @__PURE__ */ jsx79("span", { className: "sr-only", children: accessibilityDescription }) : null,
3613
3724
  media ? (_a = getAddonStartMedia(media)) == null ? void 0 : _a.value : null
3614
3725
  ]
3615
3726
  }
@@ -3620,8 +3731,8 @@ function TextToolbarButton(props) {
3620
3731
  const addonStart = media ? getAddonStartMedia(media) : void 0;
3621
3732
  const priority = getPriority2(control);
3622
3733
  const sentiment = getSentiment2(context);
3623
- return /* @__PURE__ */ jsx77(
3624
- Button7,
3734
+ return /* @__PURE__ */ jsx79(
3735
+ Button8,
3625
3736
  {
3626
3737
  v2: true,
3627
3738
  size: "sm",
@@ -3650,140 +3761,51 @@ var getIconButtonPriority = (control) => {
3650
3761
  };
3651
3762
 
3652
3763
  // ../renderers/src/step/topbar/TopBar.tsx
3653
- import { jsx as jsx78, jsxs as jsxs28 } from "react/jsx-runtime";
3764
+ import { jsx as jsx80, jsxs as jsxs30 } from "react/jsx-runtime";
3654
3765
  function TopBar({ back, toolbar }) {
3655
- return back || toolbar ? /* @__PURE__ */ jsxs28("div", { className: "d-flex m-b-2", children: [
3656
- back ? /* @__PURE__ */ jsx78(BackButton, __spreadValues({}, back)) : null,
3657
- toolbar ? /* @__PURE__ */ jsx78(Toolbar, __spreadValues({}, toolbar)) : null
3766
+ return back || toolbar ? /* @__PURE__ */ jsxs30("div", { className: "d-flex m-b-2", children: [
3767
+ back ? /* @__PURE__ */ jsx80(BackButton, __spreadValues({}, back)) : null,
3768
+ toolbar ? /* @__PURE__ */ jsx80(Toolbar, __spreadValues({}, toolbar)) : null
3658
3769
  ] }) : null;
3659
3770
  }
3660
3771
 
3661
- // ../renderers/src/step/StepFooter.tsx
3662
- import { Button as Button8 } from "@transferwise/components";
3663
- import { useEffect as useEffect10, useRef, useState as useState12 } from "react";
3664
- import { useIntl as useIntl15 } from "react-intl";
3665
-
3666
- // ../renderers/src/messages/step.messages.ts
3667
- import { defineMessages as defineMessages12 } from "react-intl";
3668
- var step_messages_default = defineMessages12({
3669
- scrollToBottom: {
3670
- id: "df.wise.step.scrollToBottom",
3671
- defaultMessage: "Scroll to bottom",
3672
- description: "Label for a button that appears when the content of a step is too long and the user needs to scroll to the bottom to see all the content."
3673
- }
3674
- });
3675
-
3676
- // ../renderers/src/step/StepFooter.tsx
3677
- import { Fragment as Fragment13, jsx as jsx79, jsxs as jsxs29 } from "react/jsx-runtime";
3678
- var SCROLL_TO_BOTTOM = "scroll-to-bottom";
3679
- var StepFooter = ({ footer, tags }) => {
3680
- if (tags == null ? void 0 : tags.includes(SCROLL_TO_BOTTOM)) {
3681
- return /* @__PURE__ */ jsx79(FooterWithScrollButton, { footer });
3682
- }
3683
- return /* @__PURE__ */ jsx79(DefaultFooter, { footer });
3684
- };
3685
- var DefaultFooter = ({ footer }) => {
3686
- const hasFooter = footer && Array.isArray(footer) && footer.length > 0;
3687
- return hasFooter ? /* @__PURE__ */ jsx79("div", { className: "df-step-fixed__footer", children: footer }) : void 0;
3688
- };
3689
- var FooterWithScrollButton = ({ footer }) => {
3690
- const { formatMessage } = useIntl15();
3691
- const endOfLayoutRef = useRef(null);
3692
- const isElementVisible = useIsElementVisible(endOfLayoutRef);
3693
- const scrollButton = /* @__PURE__ */ jsx79(
3694
- Button8,
3695
- {
3696
- className: "m-b-1",
3697
- v2: true,
3698
- block: true,
3699
- priority: "tertiary",
3700
- onClick: () => {
3701
- var _a;
3702
- (_a = endOfLayoutRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
3703
- },
3704
- children: formatMessage(step_messages_default.scrollToBottom)
3705
- }
3706
- );
3707
- const hasStepFooterContent = footer && Array.isArray(footer) && footer.length > 0;
3708
- if (isElementVisible && !hasStepFooterContent) {
3709
- return /* @__PURE__ */ jsx79("div", { ref: endOfLayoutRef, "aria-hidden": "true" });
3710
- }
3711
- return /* @__PURE__ */ jsxs29(Fragment13, { children: [
3712
- /* @__PURE__ */ jsx79("div", { ref: endOfLayoutRef, "aria-hidden": "true" }),
3713
- /* @__PURE__ */ jsxs29("div", { className: "df-step-fixed__footer", children: [
3714
- !isElementVisible && scrollButton,
3715
- footer
3716
- ] })
3717
- ] });
3718
- };
3719
- var useIsElementVisible = (elementRef) => {
3720
- const [isVisible, setIsVisible] = useState12(false);
3721
- useEffect10(() => {
3722
- const element = elementRef.current;
3723
- if (!element) return;
3724
- const observer = new IntersectionObserver(([entry]) => {
3725
- setIsVisible(entry.isIntersecting);
3726
- });
3727
- observer.observe(element);
3728
- return () => observer.disconnect();
3729
- }, [elementRef]);
3730
- return isVisible;
3731
- };
3732
-
3733
3772
  // ../renderers/src/step/SplashCelebrationStepRenderer.tsx
3734
- import { jsx as jsx80, jsxs as jsxs30 } from "react/jsx-runtime";
3773
+ import { jsx as jsx81, jsxs as jsxs31 } from "react/jsx-runtime";
3735
3774
  var SplashCelebrationStepRenderer = {
3736
3775
  canRenderType: "step",
3737
3776
  canRender: ({ control }) => control === "splash-celebration",
3738
3777
  render: SplashCelebrationStepRendererComponent
3739
3778
  };
3740
3779
  function SplashCelebrationStepRendererComponent(props) {
3741
- const { back, toolbar, children, footer, tags, trackEvent } = props;
3780
+ const { back, title, description, toolbar, children, footer, tags, trackEvent } = props;
3742
3781
  useCustomTheme("forest-green", trackEvent);
3743
- return /* @__PURE__ */ jsxs30("div", { className: "splash-screen m-t-5", children: [
3744
- /* @__PURE__ */ jsx80(TopBar, { back, toolbar }),
3782
+ return /* @__PURE__ */ jsxs31("div", { className: "splash-screen m-t-5", children: [
3783
+ /* @__PURE__ */ jsx81(TopBar, { back, toolbar }),
3784
+ title || description ? /* @__PURE__ */ jsx81("div", { className: "m-b-4", children: /* @__PURE__ */ jsx81(StepHeader, { title, description, tags }) }) : void 0,
3745
3785
  children,
3746
- /* @__PURE__ */ jsx80(StepFooter, { footer, tags })
3786
+ /* @__PURE__ */ jsx81(StepFooter, { footer, tags })
3747
3787
  ] });
3748
3788
  }
3749
3789
 
3750
3790
  // ../renderers/src/step/SplashStepRenderer.tsx
3751
- import { jsx as jsx81, jsxs as jsxs31 } from "react/jsx-runtime";
3791
+ import { jsx as jsx82, jsxs as jsxs32 } from "react/jsx-runtime";
3752
3792
  var SplashStepRenderer = {
3753
3793
  canRenderType: "step",
3754
3794
  canRender: ({ control }) => control === "splash",
3755
3795
  render: SplashStepRendererComponent
3756
3796
  };
3757
3797
  function SplashStepRendererComponent(props) {
3758
- const { back, toolbar, children, footer, tags } = props;
3759
- return /* @__PURE__ */ jsxs31("div", { className: "splash-screen m-t-5", children: [
3760
- /* @__PURE__ */ jsx81(TopBar, { back, toolbar }),
3798
+ const { back, title, description, toolbar, children, footer, tags } = props;
3799
+ return /* @__PURE__ */ jsxs32("div", { className: "splash-screen m-t-5", children: [
3800
+ /* @__PURE__ */ jsx82(TopBar, { back, toolbar }),
3801
+ title || description ? /* @__PURE__ */ jsx82("div", { className: "m-b-4", children: /* @__PURE__ */ jsx82(StepHeader, { title, description, tags }) }) : void 0,
3761
3802
  children,
3762
- /* @__PURE__ */ jsx81(StepFooter, { footer, tags })
3803
+ /* @__PURE__ */ jsx82(StepFooter, { footer, tags })
3763
3804
  ] });
3764
3805
  }
3765
3806
 
3766
3807
  // ../renderers/src/step/StepRenderer.tsx
3767
3808
  import { Alert as Alert2 } from "@transferwise/components";
3768
-
3769
- // ../renderers/src/step/StepHeader.tsx
3770
- import { Title as Title2 } from "@transferwise/components";
3771
- import { Fragment as Fragment14, jsx as jsx82, jsxs as jsxs32 } from "react/jsx-runtime";
3772
- var StepHeader = ({ title, description, tags }) => {
3773
- const { titleType, alignmentClassName } = getHeaderStyle(tags);
3774
- return /* @__PURE__ */ jsxs32(Fragment14, { children: [
3775
- title ? /* @__PURE__ */ jsx82(Title2, { as: "h1", type: titleType, className: `${alignmentClassName} m-b-2`, children: title }) : void 0,
3776
- description ? /* @__PURE__ */ jsx82("p", { className: `${alignmentClassName} np-text-body-large`, children: description }) : void 0
3777
- ] });
3778
- };
3779
- var getHeaderStyle = (tags) => {
3780
- if (tags == null ? void 0 : tags.includes("root-screen")) {
3781
- return { titleType: "title-screen", alignmentClassName: "text-xs-left" };
3782
- }
3783
- return { titleType: "title-section", alignmentClassName: "text-xs-center" };
3784
- };
3785
-
3786
- // ../renderers/src/step/StepRenderer.tsx
3787
3809
  import { jsx as jsx83, jsxs as jsxs33 } from "react/jsx-runtime";
3788
3810
  var StepRenderer = {
3789
3811
  canRenderType: "step",