@wise/dynamic-flow-client-internal 5.20.0 → 5.21.0

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
@@ -127,7 +127,7 @@ import { useDynamicFlow } from "@wise/dynamic-flow-client";
127
127
  // src/dynamicFlow/telemetry/app-version.ts
128
128
  var appVersion = (
129
129
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
130
- typeof process !== "undefined" ? "5.20.0" : "0.0.0"
130
+ typeof process !== "undefined" ? "5.21.0" : "0.0.0"
131
131
  );
132
132
 
133
133
  // src/dynamicFlow/context-menu/useContextMenu.tsx
@@ -385,7 +385,7 @@ var BoxRenderer = {
385
385
  const contents = /* @__PURE__ */ jsx3(
386
386
  "div",
387
387
  {
388
- className: (0, import_classnames.default)({
388
+ className: (0, import_classnames.default)("df-box-renderer", {
389
389
  "df-box-renderer-border": hasBorder,
390
390
  [`df-box-renderer-width-${width}`]: hasFixedWidth,
391
391
  [getMargin(margin)]: !hasFixedWidth
@@ -851,11 +851,24 @@ var getPriority = (control, tags) => {
851
851
  return control && isButtonPriority(control) ? control : "secondary";
852
852
  };
853
853
 
854
+ // ../renderers/src/CheckboxInputRenderer.tsx
855
+ import { Checkbox, ListItem as ListItem3 } from "@transferwise/components";
856
+
854
857
  // ../renderers/src/components/FieldInput.tsx
855
858
  import { Field } from "@transferwise/components";
856
- import { useEffect as useEffect4, useRef } from "react";
857
859
 
858
- // ../renderers/src/utils/scroll-to-if-not-visible.ts
860
+ // ../renderers/src/utils/useScrollToError.ts
861
+ import { useEffect as useEffect4, useRef } from "react";
862
+ var useScrollToError = (validationState, features) => {
863
+ const ref = useRef(null);
864
+ const enabled = (features == null ? void 0 : features.scrollToError) !== false;
865
+ useEffect4(() => {
866
+ if ((validationState == null ? void 0 : validationState.status) === "invalid" && (validationState == null ? void 0 : validationState.message) && enabled) {
867
+ scrollToIfNotVisible(ref.current);
868
+ }
869
+ }, [validationState == null ? void 0 : validationState.status, validationState == null ? void 0 : validationState.message, enabled]);
870
+ return { ref };
871
+ };
859
872
  var scrollToIfNotVisible = (ref) => {
860
873
  const rect = ref == null ? void 0 : ref.getBoundingClientRect();
861
874
  if (!ref || !rect) {
@@ -919,22 +932,16 @@ function FieldInput({
919
932
  inlineAlert,
920
933
  features
921
934
  }) {
935
+ var _a;
922
936
  const labelContent = label && help ? /* @__PURE__ */ jsx19(LabelContentWithHelp, { text: label, help }) : label;
923
- const message = validation == null ? void 0 : validation.message;
924
- const ref = useRef(null);
925
- const shouldScrollToError = features.scrollToError !== false;
926
- useEffect4(() => {
927
- if (message && shouldScrollToError) {
928
- scrollToIfNotVisible(ref.current);
929
- }
930
- }, [message, shouldScrollToError]);
937
+ const { ref } = useScrollToError(validation, features);
931
938
  return /* @__PURE__ */ jsx19("div", { ref, children: /* @__PURE__ */ jsx19(
932
939
  Field,
933
940
  {
934
941
  id,
935
942
  label: labelContent,
936
943
  description,
937
- message: message != null ? message : inlineAlert == null ? void 0 : inlineAlert.content,
944
+ message: (_a = validation == null ? void 0 : validation.message) != null ? _a : inlineAlert == null ? void 0 : inlineAlert.content,
938
945
  messageLoading: loadingState !== "idle",
939
946
  sentiment: mapStatusToSentiment(validation, inlineAlert == null ? void 0 : inlineAlert.context),
940
947
  children
@@ -954,33 +961,30 @@ var mapStatusToSentiment = (validation, defaultContext) => {
954
961
  };
955
962
  var FieldInput_default = FieldInput;
956
963
 
957
- // ../renderers/src/CheckboxInputRenderer.tsx
958
- import { Checkbox, ListItem as ListItem3 } from "@transferwise/components";
959
-
960
- // ../renderers/src/utils/listItem/getMedia.tsx
961
- import { jsx as jsx20 } from "react/jsx-runtime";
962
- var getMedia = (media, preferAvatar) => media ? /* @__PURE__ */ jsx20(OptionMedia, { media, preferAvatar }) : void 0;
963
-
964
964
  // ../renderers/src/utils/listItem/getAdditionalText.tsx
965
965
  import { ListItem } from "@transferwise/components";
966
- import { jsx as jsx21 } from "react/jsx-runtime";
966
+ import { jsx as jsx20 } from "react/jsx-runtime";
967
967
  var getAdditionalText = (additionalText) => {
968
968
  if (!additionalText) {
969
969
  return void 0;
970
970
  }
971
- return /* @__PURE__ */ jsx21(ListItem.AdditionalInfo, { children: additionalText });
971
+ return /* @__PURE__ */ jsx20(ListItem.AdditionalInfo, { children: additionalText });
972
972
  };
973
973
 
974
+ // ../renderers/src/utils/listItem/getInlineAlert.tsx
975
+ import { ListItem as ListItem2 } from "@transferwise/components";
976
+ import { jsx as jsx21 } from "react/jsx-runtime";
977
+ var getInlineAlert = (inlineAlert) => inlineAlert ? /* @__PURE__ */ jsx21(ListItem2.Prompt, { sentiment: inlineAlert == null ? void 0 : inlineAlert.context, children: inlineAlert.content }) : void 0;
978
+
979
+ // ../renderers/src/utils/listItem/getMedia.tsx
980
+ import { jsx as jsx22 } from "react/jsx-runtime";
981
+ var getMedia = (media, preferAvatar) => media ? /* @__PURE__ */ jsx22(OptionMedia, { media, preferAvatar }) : void 0;
982
+
974
983
  // ../renderers/src/utils/listItem/getSupportingValues.ts
975
984
  var getSupportingValues = (supportingValues) => {
976
985
  return __spreadValues(__spreadValues({}, (supportingValues == null ? void 0 : supportingValues.value) ? { valueTitle: supportingValues.value } : {}), (supportingValues == null ? void 0 : supportingValues.subvalue) ? { valueSubtitle: supportingValues.subvalue } : {});
977
986
  };
978
987
 
979
- // ../renderers/src/utils/listItem/getInlineAlert.tsx
980
- import { ListItem as ListItem2 } from "@transferwise/components";
981
- import { jsx as jsx22 } from "react/jsx-runtime";
982
- var getInlineAlert = (inlineAlert) => inlineAlert ? /* @__PURE__ */ jsx22(ListItem2.Prompt, { sentiment: inlineAlert == null ? void 0 : inlineAlert.context, children: inlineAlert.content }) : void 0;
983
-
984
988
  // ../renderers/src/CheckboxInputRenderer.tsx
985
989
  import { jsx as jsx23 } from "react/jsx-runtime";
986
990
  var CheckboxInputRenderer = {
@@ -1044,9 +1048,11 @@ var CheckboxItemComponent = (props) => {
1044
1048
  title,
1045
1049
  validationState,
1046
1050
  value,
1051
+ features,
1047
1052
  onChange
1048
1053
  } = props;
1049
- return /* @__PURE__ */ jsx23(
1054
+ const { ref } = useScrollToError(validationState, features);
1055
+ return /* @__PURE__ */ jsx23("div", { ref, children: /* @__PURE__ */ jsx23(
1050
1056
  ListItem3,
1051
1057
  __spreadValues({
1052
1058
  title,
@@ -1057,7 +1063,7 @@ var CheckboxItemComponent = (props) => {
1057
1063
  prompt: getInlineAlertOrValidation(validationState, inlineAlert),
1058
1064
  control: /* @__PURE__ */ jsx23(ListItem3.Checkbox, { checked: value, onChange: () => onChange(!value) })
1059
1065
  }, getSupportingValues(supportingValues))
1060
- );
1066
+ ) });
1061
1067
  };
1062
1068
  var SwitchItemComponent = (props) => {
1063
1069
  const {
@@ -1070,9 +1076,11 @@ var SwitchItemComponent = (props) => {
1070
1076
  title,
1071
1077
  validationState,
1072
1078
  value,
1079
+ features,
1073
1080
  onChange
1074
1081
  } = props;
1075
- return /* @__PURE__ */ jsx23(
1082
+ const { ref } = useScrollToError(validationState, features);
1083
+ return /* @__PURE__ */ jsx23("div", { ref, children: /* @__PURE__ */ jsx23(
1076
1084
  ListItem3,
1077
1085
  __spreadValues({
1078
1086
  title,
@@ -1083,7 +1091,7 @@ var SwitchItemComponent = (props) => {
1083
1091
  prompt: getInlineAlertOrValidation(validationState, inlineAlert),
1084
1092
  control: /* @__PURE__ */ jsx23(ListItem3.Switch, { checked: value, onClick: () => onChange(!value) })
1085
1093
  }, getSupportingValues(supportingValues))
1086
- );
1094
+ ) });
1087
1095
  };
1088
1096
  var getInlineAlertOrValidation = (validationState, inlineAlert) => {
1089
1097
  if ((validationState == null ? void 0 : validationState.status) === "invalid") {
@@ -2495,7 +2503,6 @@ import { Status, UploadInput } from "@transferwise/components";
2495
2503
  // ../renderers/src/components/UploadFieldInput.tsx
2496
2504
  var import_classnames4 = __toESM(require_classnames());
2497
2505
  import { InlineAlert as InlineAlert2 } from "@transferwise/components";
2498
- import { useEffect as useEffect8, useRef as useRef2 } from "react";
2499
2506
  import { jsx as jsx57, jsxs as jsxs12 } from "react/jsx-runtime";
2500
2507
  function UploadFieldInput({
2501
2508
  id,
@@ -2508,14 +2515,7 @@ function UploadFieldInput({
2508
2515
  }) {
2509
2516
  const labelContent = label && help ? /* @__PURE__ */ jsx57(LabelContentWithHelp, { text: label, help }) : label;
2510
2517
  const descriptionId = description ? `${id}-description` : void 0;
2511
- const message = validation == null ? void 0 : validation.message;
2512
- const ref = useRef2(null);
2513
- const shouldScrollToError = features.scrollToError !== false;
2514
- useEffect8(() => {
2515
- if (message && shouldScrollToError) {
2516
- scrollToIfNotVisible(ref.current);
2517
- }
2518
- }, [message, shouldScrollToError]);
2518
+ const { ref } = useScrollToError(validation, features);
2519
2519
  return /* @__PURE__ */ jsxs12(
2520
2520
  "div",
2521
2521
  {
@@ -2811,6 +2811,7 @@ function Repeatable(props) {
2811
2811
  description,
2812
2812
  editableItem,
2813
2813
  editItemTitle,
2814
+ features,
2814
2815
  items,
2815
2816
  title,
2816
2817
  validationState,
@@ -2821,6 +2822,7 @@ function Repeatable(props) {
2821
2822
  } = props;
2822
2823
  const { formatMessage } = useIntl9();
2823
2824
  const [openModalType, setOpenModalType] = useState9(null);
2825
+ const { ref } = useScrollToError(validationState, features);
2824
2826
  const onAddItem = () => {
2825
2827
  onAdd();
2826
2828
  setOpenModalType("add");
@@ -2843,29 +2845,31 @@ function Repeatable(props) {
2843
2845
  setOpenModalType(null);
2844
2846
  };
2845
2847
  return /* @__PURE__ */ jsxs14(Fragment5, { children: [
2846
- title && /* @__PURE__ */ jsx62(Header6, { title }),
2847
- description && /* @__PURE__ */ jsx62("p", { children: description }),
2848
- /* @__PURE__ */ jsxs14(
2849
- "div",
2850
- {
2851
- className: (0, import_classnames6.default)("form-group", {
2852
- "has-error": (validationState == null ? void 0 : validationState.status) === "invalid"
2853
- }),
2854
- children: [
2855
- items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ jsx62(ItemSummaryOption, { item, onClick: () => onEditItem(index) }, item.id)),
2856
- /* @__PURE__ */ jsx62(
2857
- NavigationOption,
2858
- {
2859
- media: /* @__PURE__ */ jsx62(Plus, {}),
2860
- title: addItemTitle || formatMessage(repeatable_messages_default.addItemTitle),
2861
- showMediaAtAllSizes: true,
2862
- onClick: () => onAddItem()
2863
- }
2864
- ),
2865
- (validationState == null ? void 0 : validationState.status) === "invalid" && /* @__PURE__ */ jsx62(InlineAlert3, { type: "negative", children: validationState.message })
2866
- ]
2867
- }
2868
- ),
2848
+ /* @__PURE__ */ jsxs14("div", { ref, children: [
2849
+ title && /* @__PURE__ */ jsx62(Header6, { title }),
2850
+ description && /* @__PURE__ */ jsx62("p", { children: description }),
2851
+ /* @__PURE__ */ jsxs14(
2852
+ "div",
2853
+ {
2854
+ className: (0, import_classnames6.default)("form-group", {
2855
+ "has-error": (validationState == null ? void 0 : validationState.status) === "invalid"
2856
+ }),
2857
+ children: [
2858
+ items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ jsx62(ItemSummaryOption, { item, onClick: () => onEditItem(index) }, item.id)),
2859
+ /* @__PURE__ */ jsx62(
2860
+ NavigationOption,
2861
+ {
2862
+ media: /* @__PURE__ */ jsx62(Plus, {}),
2863
+ title: addItemTitle || formatMessage(repeatable_messages_default.addItemTitle),
2864
+ showMediaAtAllSizes: true,
2865
+ onClick: () => onAddItem()
2866
+ }
2867
+ ),
2868
+ (validationState == null ? void 0 : validationState.status) === "invalid" && /* @__PURE__ */ jsx62(InlineAlert3, { type: "negative", children: validationState.message })
2869
+ ]
2870
+ }
2871
+ )
2872
+ ] }),
2869
2873
  /* @__PURE__ */ jsx62(
2870
2874
  Modal4,
2871
2875
  {
@@ -3381,7 +3385,7 @@ function RadioInputRendererComponent(props) {
3381
3385
 
3382
3386
  // ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
3383
3387
  import { Tabs } from "@transferwise/components";
3384
- import { useEffect as useEffect9 } from "react";
3388
+ import { useEffect as useEffect8 } from "react";
3385
3389
  import { Fragment as Fragment9, jsx as jsx71, jsxs as jsxs21 } from "react/jsx-runtime";
3386
3390
  function TabInputRendererComponent(props) {
3387
3391
  const {
@@ -3397,7 +3401,7 @@ function TabInputRendererComponent(props) {
3397
3401
  validationState,
3398
3402
  onSelect
3399
3403
  } = props;
3400
- useEffect9(() => {
3404
+ useEffect8(() => {
3401
3405
  if (!isValidIndex2(selectedIndex, options.length)) {
3402
3406
  onSelect(0);
3403
3407
  }
@@ -3513,7 +3517,7 @@ function SelectInputRendererComponent(props) {
3513
3517
  }
3514
3518
 
3515
3519
  // ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
3516
- import { useEffect as useEffect10 } from "react";
3520
+ import { useEffect as useEffect9 } from "react";
3517
3521
  import { SegmentedControl } from "@transferwise/components";
3518
3522
  import { Fragment as Fragment11, jsx as jsx73, jsxs as jsxs23 } from "react/jsx-runtime";
3519
3523
  function SegmentedInputRendererComponent(props) {
@@ -3529,7 +3533,7 @@ function SegmentedInputRendererComponent(props) {
3529
3533
  validationState,
3530
3534
  onSelect
3531
3535
  } = props;
3532
- useEffect10(() => {
3536
+ useEffect9(() => {
3533
3537
  if (!isValidIndex3(selectedIndex, options.length)) {
3534
3538
  onSelect(0);
3535
3539
  }
@@ -3568,13 +3572,14 @@ var isValidIndex3 = (index, options) => index !== null && index >= 0 && index <
3568
3572
 
3569
3573
  // ../renderers/src/SelectInputRenderer/RadioItemRendererComponent.tsx
3570
3574
  import { Header as Header8, InlineAlert as InlineAlert4, List as List2, ListItem as ListItem11 } from "@transferwise/components";
3571
- import { Fragment as Fragment12, jsx as jsx74, jsxs as jsxs24 } from "react/jsx-runtime";
3575
+ import { jsx as jsx74, jsxs as jsxs24 } from "react/jsx-runtime";
3572
3576
  function RadioItemRendererComponent(props) {
3573
3577
  const {
3574
3578
  id,
3575
3579
  children,
3576
3580
  description: rootDescription,
3577
3581
  disabled: rootDisabled,
3582
+ features,
3578
3583
  help,
3579
3584
  title: rootTitle,
3580
3585
  options,
@@ -3582,7 +3587,8 @@ function RadioItemRendererComponent(props) {
3582
3587
  validationState,
3583
3588
  onSelect
3584
3589
  } = props;
3585
- return /* @__PURE__ */ jsxs24(Fragment12, { children: [
3590
+ const { ref } = useScrollToError(validationState, features);
3591
+ return /* @__PURE__ */ jsxs24("div", { ref, children: [
3586
3592
  rootTitle && /* @__PURE__ */ jsx74(
3587
3593
  Header8,
3588
3594
  {
@@ -3695,12 +3701,12 @@ var StatusListRenderer_default = StatusListRenderer;
3695
3701
 
3696
3702
  // ../renderers/src/utils/useCustomTheme.ts
3697
3703
  import { useTheme } from "@wise/components-theming";
3698
- import { useEffect as useEffect11, useMemo } from "react";
3704
+ import { useEffect as useEffect10, useMemo } from "react";
3699
3705
  var ThemeRequiredEventName = "Theme Required";
3700
3706
  var useCustomTheme = (theme, trackEvent) => {
3701
3707
  const theming = useTheme();
3702
3708
  const previousTheme = useMemo(() => theming.theme, []);
3703
- useEffect11(() => {
3709
+ useEffect10(() => {
3704
3710
  theming.setTheme(theme);
3705
3711
  trackEvent(ThemeRequiredEventName, { theme });
3706
3712
  return theme !== previousTheme ? () => {
@@ -3713,7 +3719,7 @@ var useCustomTheme = (theme, trackEvent) => {
3713
3719
 
3714
3720
  // ../renderers/src/step/StepFooter.tsx
3715
3721
  import { Button as Button7 } from "@transferwise/components";
3716
- import { useEffect as useEffect12, useRef as useRef3, useState as useState12 } from "react";
3722
+ import { useEffect as useEffect11, useRef as useRef2, useState as useState12 } from "react";
3717
3723
  import { useIntl as useIntl14 } from "react-intl";
3718
3724
 
3719
3725
  // ../renderers/src/messages/step.messages.ts
@@ -3727,7 +3733,7 @@ var step_messages_default = defineMessages11({
3727
3733
  });
3728
3734
 
3729
3735
  // ../renderers/src/step/StepFooter.tsx
3730
- import { Fragment as Fragment13, jsx as jsx77, jsxs as jsxs26 } from "react/jsx-runtime";
3736
+ import { Fragment as Fragment12, jsx as jsx77, jsxs as jsxs26 } from "react/jsx-runtime";
3731
3737
  var SCROLL_TO_BOTTOM = "scroll-to-bottom";
3732
3738
  var StepFooter = ({ footer, tags }) => {
3733
3739
  if (tags == null ? void 0 : tags.includes(SCROLL_TO_BOTTOM)) {
@@ -3741,7 +3747,7 @@ var DefaultFooter = ({ footer }) => {
3741
3747
  };
3742
3748
  var FooterWithScrollButton = ({ footer }) => {
3743
3749
  const { formatMessage } = useIntl14();
3744
- const endOfLayoutRef = useRef3(null);
3750
+ const endOfLayoutRef = useRef2(null);
3745
3751
  const isElementVisible = useIsElementVisible(endOfLayoutRef);
3746
3752
  const scrollButton = /* @__PURE__ */ jsx77(
3747
3753
  Button7,
@@ -3761,7 +3767,7 @@ var FooterWithScrollButton = ({ footer }) => {
3761
3767
  if (isElementVisible && !hasStepFooterContent) {
3762
3768
  return /* @__PURE__ */ jsx77("div", { ref: endOfLayoutRef, "aria-hidden": "true" });
3763
3769
  }
3764
- return /* @__PURE__ */ jsxs26(Fragment13, { children: [
3770
+ return /* @__PURE__ */ jsxs26(Fragment12, { children: [
3765
3771
  /* @__PURE__ */ jsx77("div", { ref: endOfLayoutRef, "aria-hidden": "true" }),
3766
3772
  /* @__PURE__ */ jsxs26("div", { className: "df-step-fixed__footer", children: [
3767
3773
  !isElementVisible && scrollButton,
@@ -3771,7 +3777,7 @@ var FooterWithScrollButton = ({ footer }) => {
3771
3777
  };
3772
3778
  var useIsElementVisible = (elementRef) => {
3773
3779
  const [isVisible, setIsVisible] = useState12(false);
3774
- useEffect12(() => {
3780
+ useEffect11(() => {
3775
3781
  const element = elementRef.current;
3776
3782
  if (!element) return;
3777
3783
  const observer = new IntersectionObserver(([entry]) => {
@@ -3785,10 +3791,10 @@ var useIsElementVisible = (elementRef) => {
3785
3791
 
3786
3792
  // ../renderers/src/step/StepHeader.tsx
3787
3793
  import { Title as Title2 } from "@transferwise/components";
3788
- import { Fragment as Fragment14, jsx as jsx78, jsxs as jsxs27 } from "react/jsx-runtime";
3794
+ import { Fragment as Fragment13, jsx as jsx78, jsxs as jsxs27 } from "react/jsx-runtime";
3789
3795
  var StepHeader = ({ title, description, tags }) => {
3790
3796
  const { titleType, alignmentClassName } = getHeaderStyle(tags);
3791
- return /* @__PURE__ */ jsxs27(Fragment14, { children: [
3797
+ return /* @__PURE__ */ jsxs27(Fragment13, { children: [
3792
3798
  title ? /* @__PURE__ */ jsx78(Title2, { as: "h1", type: titleType, className: `${alignmentClassName} m-b-2`, children: title }) : void 0,
3793
3799
  description ? /* @__PURE__ */ jsx78("p", { className: `${alignmentClassName} np-text-body-large`, children: description }) : void 0
3794
3800
  ] });