@wise/dynamic-flow-client-internal 5.30.1-experimental-1e1196b → 5.31.0-experimental-a2135d6

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
@@ -6768,9 +6768,11 @@ function ChipsTabsRendererComponent({ margin, tabs, control, tags }) {
6768
6768
 
6769
6769
  // ../renderers/src/TextInputRenderer.tsx
6770
6770
  import { InputGroup as InputGroup5 } from "@transferwise/components";
6771
+ import { useState as useState21 } from "react";
6771
6772
 
6772
6773
  // ../renderers/src/components/VariableTextInput.tsx
6773
6774
  import {
6775
+ IconButton as IconButton4,
6774
6776
  Input as Input6,
6775
6777
  InputWithDisplayFormat,
6776
6778
  PhoneNumberInput,
@@ -6801,7 +6803,7 @@ function formatSsnValue(rawValue, displayFormat, isVisible) {
6801
6803
  if (!displayFormat) {
6802
6804
  return isVisible ? rawValue : "\u2022".repeat(rawValue.length);
6803
6805
  }
6804
- return displayFormat.split("").reduce(
6806
+ const formattedValue = displayFormat.split("").reduce(
6805
6807
  ({ display, digitsUsed }, character) => {
6806
6808
  if (character === "*") {
6807
6809
  return digitsUsed < rawValue.length ? {
@@ -6813,6 +6815,9 @@ function formatSsnValue(rawValue, displayFormat, isVisible) {
6813
6815
  },
6814
6816
  { display: "", digitsUsed: 0 }
6815
6817
  ).display;
6818
+ const displayFormatDigitCount = displayFormat.split("").filter((character) => character === "*").length;
6819
+ const extraValue = rawValue.slice(displayFormatDigitCount);
6820
+ return `${formattedValue}${isVisible ? extraValue : "\u2022".repeat(extraValue.length)}`;
6816
6821
  }
6817
6822
  function getRawOffset(displayValue, displayOffset, rawValueLength) {
6818
6823
  return Math.min(
@@ -6820,18 +6825,15 @@ function getRawOffset(displayValue, displayOffset, rawValueLength) {
6820
6825
  rawValueLength
6821
6826
  );
6822
6827
  }
6823
- function replaceSsnSelection(rawValue, displayValue, insertedValue, start, end, maxDigits) {
6828
+ function replaceSsnSelection(rawValue, displayValue, insertedValue, start, end) {
6824
6829
  const startOffset = getRawOffset(displayValue, start, rawValue.length);
6825
6830
  const endOffset = getRawOffset(displayValue, end, rawValue.length);
6826
- const selectedLength = endOffset - startOffset;
6827
- const availableCapacity = Math.max(0, maxDigits - (rawValue.length - selectedLength));
6828
- const acceptedInsertedValue = insertedValue.slice(0, availableCapacity);
6829
- if (!acceptedInsertedValue) {
6831
+ if (!insertedValue) {
6830
6832
  return void 0;
6831
6833
  }
6832
6834
  return {
6833
- value: `${rawValue.slice(0, startOffset)}${acceptedInsertedValue}${rawValue.slice(endOffset)}`,
6834
- caret: startOffset + acceptedInsertedValue.length
6835
+ value: `${rawValue.slice(0, startOffset)}${insertedValue}${rawValue.slice(endOffset)}`,
6836
+ caret: startOffset + insertedValue.length
6835
6837
  };
6836
6838
  }
6837
6839
  function deleteSsnSelection(rawValue, displayValue, start, end, backward) {
@@ -6868,7 +6870,7 @@ function getDisplayOffset(displayValue, rawOffset) {
6868
6870
  }
6869
6871
 
6870
6872
  // ../renderers/src/components/VariableTextInput.tsx
6871
- import { jsx as jsx100, jsxs as jsxs40 } from "react/jsx-runtime";
6873
+ import { jsx as jsx100 } from "react/jsx-runtime";
6872
6874
  var commonKeys = [
6873
6875
  "autoComplete",
6874
6876
  "autoCapitalize",
@@ -6883,16 +6885,15 @@ var commonKeys = [
6883
6885
  "value"
6884
6886
  ];
6885
6887
  function VariableTextInput(inputProps) {
6886
- const { id, value, control, onChange } = inputProps;
6888
+ const { id, value, control, onChange, isSsnVisible } = inputProps;
6887
6889
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6888
- if (control === "ssn-input") {
6889
- return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { maxLength: inputProps.maxLength, onChange }));
6890
- }
6891
6890
  switch (control) {
6892
6891
  case "email":
6893
6892
  return /* @__PURE__ */ jsx100(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
6894
6893
  case "password":
6895
6894
  return /* @__PURE__ */ jsx100(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
6895
+ case "ssn-input":
6896
+ return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { isVisible: isSsnVisible, onChange }));
6896
6897
  case "numeric": {
6897
6898
  const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
6898
6899
  return /* @__PURE__ */ jsx100(
@@ -6912,6 +6913,23 @@ function VariableTextInput(inputProps) {
6912
6913
  }
6913
6914
  }
6914
6915
  }
6916
+ function SsnInputToggle({
6917
+ isVisible,
6918
+ onClick
6919
+ }) {
6920
+ const { formatMessage } = useIntl21();
6921
+ return /* @__PURE__ */ jsx100(
6922
+ IconButton4,
6923
+ {
6924
+ priority: "minimal",
6925
+ size: 24,
6926
+ "aria-label": formatMessage(isVisible ? ssn_input_messages_default.hideValue : ssn_input_messages_default.showValue),
6927
+ "aria-pressed": isVisible,
6928
+ onClick,
6929
+ children: isVisible ? /* @__PURE__ */ jsx100(EyeShut, { size: 24 }) : /* @__PURE__ */ jsx100(Eye, { size: 24 })
6930
+ }
6931
+ );
6932
+ }
6915
6933
  function TextInput(props) {
6916
6934
  const _a = props, { control, displayFormat, onChange, type } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange", "type"]);
6917
6935
  const InputWithPattern = control === "textarea" ? TextareaWithDisplayFormat : InputWithDisplayFormat;
@@ -6919,26 +6937,11 @@ function TextInput(props) {
6919
6937
  return displayFormat ? /* @__PURE__ */ jsx100(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ jsx100(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { type, onChange: (e) => onChange(e.target.value) }));
6920
6938
  }
6921
6939
  function SsnInput(props) {
6922
- const _a = props, {
6923
- displayFormat = "",
6924
- maxLength,
6925
- onChange,
6926
- type: _type,
6927
- value = ""
6928
- } = _a, commonProps = __objRest(_a, [
6929
- "displayFormat",
6930
- "maxLength",
6931
- "onChange",
6932
- "type",
6933
- "value"
6934
- ]);
6935
- const { formatMessage } = useIntl21();
6936
- const [isVisible, setIsVisible] = useState20(false);
6940
+ const _a = props, { displayFormat = "", isVisible = false, onChange, value = "" } = _a, commonProps = __objRest(_a, ["displayFormat", "isVisible", "onChange", "value"]);
6937
6941
  const [editVersion, setEditVersion] = useState20(0);
6938
6942
  const inputRef = useRef5(null);
6939
6943
  const selection = useRef5({ start: 0, end: 0 });
6940
6944
  const pendingCaret = useRef5(null);
6941
- const maxDigits = displayFormat.split("").filter((character) => character === "*").length || maxLength || Infinity;
6942
6945
  const rawValue = value.replace(/\D/g, "");
6943
6946
  const formattedValue = formatSsnValue(rawValue, displayFormat, isVisible);
6944
6947
  const scheduleCaret = (rawOffset) => {
@@ -6946,14 +6949,7 @@ function SsnInput(props) {
6946
6949
  setEditVersion((version) => version + 1);
6947
6950
  };
6948
6951
  const replaceSelection = (insertedValue, start, end) => {
6949
- const result = replaceSsnSelection(
6950
- rawValue,
6951
- formattedValue,
6952
- insertedValue,
6953
- start,
6954
- end,
6955
- maxDigits
6956
- );
6952
+ const result = replaceSsnSelection(rawValue, formattedValue, insertedValue, start, end);
6957
6953
  if (!result) {
6958
6954
  return;
6959
6955
  }
@@ -6975,134 +6971,140 @@ function SsnInput(props) {
6975
6971
  );
6976
6972
  pendingCaret.current = null;
6977
6973
  }, [editVersion, formattedValue, rawValue]);
6978
- return /* @__PURE__ */ jsxs40("div", { className: "df-ssn-input-wrapper", children: [
6979
- /* @__PURE__ */ jsx100(
6980
- "input",
6981
- __spreadProps(__spreadValues({
6982
- ref: inputRef
6983
- }, commonProps), {
6984
- className: "form-control np-form-control np-input np-input--shape-rectangle df-ssn-input",
6985
- type: "text",
6986
- inputMode: "numeric",
6987
- maxLength: displayFormat.length || maxLength,
6988
- value: formattedValue,
6989
- onChange: (event) => {
6990
- const nextValue = event.currentTarget.value;
6991
- const inputType = event.nativeEvent.inputType;
6992
- const start = selection.current.start;
6993
- const end = selection.current.end;
6994
- if (isVisible || /^\d+$/.test(nextValue)) {
6995
- const nextRawValue = nextValue.replace(/\D/g, "").slice(0, maxDigits);
6996
- scheduleCaret(nextRawValue.length);
6997
- onChange(nextRawValue);
6998
- } else if ((inputType == null ? void 0 : inputType.startsWith("delete")) || nextValue.length < formattedValue.length) {
6999
- deleteSelection(start, end, inputType === "deleteContentBackward");
7000
- } else {
7001
- replaceSelection(nextValue.replace(/\D/g, ""), start, end);
7002
- }
7003
- },
7004
- onSelect: (event) => {
7005
- var _a2, _b;
7006
- selection.current = {
7007
- start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7008
- end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7009
- };
7010
- },
7011
- onKeyDown: (event) => {
7012
- var _a2, _b;
7013
- selection.current = {
7014
- start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7015
- end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7016
- };
7017
- if (/^\d$/.test(event.key)) {
7018
- event.preventDefault();
7019
- replaceSelection(event.key, selection.current.start, selection.current.end);
7020
- } else if (event.key === "Backspace") {
7021
- event.preventDefault();
7022
- deleteSelection(selection.current.start, selection.current.end, true);
7023
- } else if (event.key === "Delete") {
7024
- event.preventDefault();
7025
- deleteSelection(selection.current.start, selection.current.end, false);
7026
- }
7027
- },
7028
- onPaste: (event) => {
7029
- var _a2, _b;
6974
+ return /* @__PURE__ */ jsx100(
6975
+ "input",
6976
+ __spreadProps(__spreadValues({
6977
+ ref: inputRef
6978
+ }, commonProps), {
6979
+ className: "form-control np-form-control np-input np-input--shape-rectangle",
6980
+ type: "text",
6981
+ inputMode: "numeric",
6982
+ value: formattedValue,
6983
+ onChange: (event) => {
6984
+ const nextValue = event.currentTarget.value;
6985
+ const inputType = event.nativeEvent.inputType;
6986
+ const start = selection.current.start;
6987
+ const end = selection.current.end;
6988
+ if (isVisible || /^\d+$/.test(nextValue)) {
6989
+ const nextRawValue = nextValue.replace(/\D/g, "");
6990
+ scheduleCaret(nextRawValue.length);
6991
+ onChange(nextRawValue);
6992
+ } else if ((inputType == null ? void 0 : inputType.startsWith("delete")) || nextValue.length < formattedValue.length) {
6993
+ deleteSelection(start, end, inputType === "deleteContentBackward");
6994
+ } else {
6995
+ replaceSelection(nextValue.replace(/\D/g, ""), start, end);
6996
+ }
6997
+ },
6998
+ onSelect: (event) => {
6999
+ var _a2, _b;
7000
+ selection.current = {
7001
+ start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7002
+ end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7003
+ };
7004
+ },
7005
+ onKeyDown: (event) => {
7006
+ var _a2, _b;
7007
+ selection.current = {
7008
+ start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7009
+ end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7010
+ };
7011
+ if (/^\d$/.test(event.key)) {
7030
7012
  event.preventDefault();
7031
- selection.current = {
7032
- start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7033
- end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7034
- };
7035
- const pastedValue = event.clipboardData.getData("text").replace(/\D/g, "");
7036
- replaceSelection(pastedValue, selection.current.start, selection.current.end);
7013
+ replaceSelection(event.key, selection.current.start, selection.current.end);
7014
+ } else if (event.key === "Backspace") {
7015
+ event.preventDefault();
7016
+ deleteSelection(selection.current.start, selection.current.end, true);
7017
+ } else if (event.key === "Delete") {
7018
+ event.preventDefault();
7019
+ deleteSelection(selection.current.start, selection.current.end, false);
7037
7020
  }
7038
- })
7039
- ),
7040
- /* @__PURE__ */ jsx100(
7041
- "button",
7042
- {
7043
- type: "button",
7044
- className: "df-ssn-input-toggle",
7045
- "aria-label": formatMessage(isVisible ? ssn_input_messages_default.hideValue : ssn_input_messages_default.showValue),
7046
- "aria-pressed": isVisible,
7047
- onClick: () => setIsVisible((visible) => !visible),
7048
- children: isVisible ? /* @__PURE__ */ jsx100(EyeShut, { size: 24 }) : /* @__PURE__ */ jsx100(Eye, { size: 24 })
7021
+ },
7022
+ onPaste: (event) => {
7023
+ var _a2, _b;
7024
+ event.preventDefault();
7025
+ selection.current = {
7026
+ start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
7027
+ end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
7028
+ };
7029
+ const pastedValue = event.clipboardData.getData("text").replace(/\D/g, "");
7030
+ replaceSelection(pastedValue, selection.current.start, selection.current.end);
7049
7031
  }
7050
- )
7051
- ] });
7032
+ })
7033
+ );
7052
7034
  }
7053
7035
 
7054
7036
  // ../renderers/src/TextInputRenderer.tsx
7055
7037
  import { jsx as jsx101 } from "react/jsx-runtime";
7056
7038
  var TextInputRenderer = {
7057
7039
  canRenderType: "input-text",
7058
- render: (props) => {
7059
- const _a = props, {
7040
+ render: (props) => /* @__PURE__ */ jsx101(TextInputRendererComponent, __spreadValues({}, props))
7041
+ };
7042
+ function TextInputRendererComponent(props) {
7043
+ const [isSsnVisible, setIsSsnVisible] = useState21(false);
7044
+ const _a = props, {
7045
+ id,
7046
+ title,
7047
+ description,
7048
+ help,
7049
+ media,
7050
+ validationState,
7051
+ value: initialValue,
7052
+ onChange
7053
+ } = _a, rest = __objRest(_a, [
7054
+ "id",
7055
+ "title",
7056
+ "description",
7057
+ "help",
7058
+ "media",
7059
+ "validationState",
7060
+ "value",
7061
+ "onChange"
7062
+ ]);
7063
+ const value = initialValue != null ? initialValue : "";
7064
+ const isSsnInput = props.control === "ssn-input";
7065
+ const inputProps = __spreadProps(__spreadValues({}, rest), {
7066
+ value,
7067
+ id,
7068
+ isSsnVisible,
7069
+ onChange: (newValue) => {
7070
+ if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
7071
+ onChange(newValue);
7072
+ }
7073
+ }
7074
+ });
7075
+ return /* @__PURE__ */ jsx101(
7076
+ FieldInput_default,
7077
+ {
7060
7078
  id,
7061
- title,
7079
+ label: title,
7062
7080
  description,
7081
+ validation: validationState,
7082
+ inlineAlert: props.inlineAlert,
7083
+ loadingState: props.fieldLoadingState,
7063
7084
  help,
7064
- media,
7065
- validationState,
7066
- value: initialValue,
7067
- onChange
7068
- } = _a, rest = __objRest(_a, [
7069
- "id",
7070
- "title",
7071
- "description",
7072
- "help",
7073
- "media",
7074
- "validationState",
7075
- "value",
7076
- "onChange"
7077
- ]);
7078
- const value = initialValue != null ? initialValue : "";
7079
- const inputProps = __spreadProps(__spreadValues({}, rest), {
7080
- value,
7081
- id,
7082
- onChange: (newValue) => {
7083
- if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
7084
- onChange(newValue);
7085
+ features: props.features,
7086
+ control: props.control,
7087
+ tags: props.tags,
7088
+ children: /* @__PURE__ */ jsx101(
7089
+ InputGroup5,
7090
+ {
7091
+ addonStart: getInputGroupAddonStart(media),
7092
+ addonEnd: isSsnInput ? {
7093
+ interactive: true,
7094
+ content: /* @__PURE__ */ jsx101(
7095
+ SsnInputToggle,
7096
+ {
7097
+ isVisible: isSsnVisible,
7098
+ onClick: () => setIsSsnVisible((visible) => !visible)
7099
+ }
7100
+ )
7101
+ } : void 0,
7102
+ children: /* @__PURE__ */ jsx101(VariableTextInput, __spreadValues({}, inputProps))
7085
7103
  }
7086
- }
7087
- });
7088
- return /* @__PURE__ */ jsx101(
7089
- FieldInput_default,
7090
- {
7091
- id,
7092
- label: title,
7093
- description,
7094
- validation: validationState,
7095
- inlineAlert: props.inlineAlert,
7096
- loadingState: props.fieldLoadingState,
7097
- help,
7098
- features: props.features,
7099
- control: props.control,
7100
- tags: props.tags,
7101
- children: /* @__PURE__ */ jsx101(InputGroup5, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx101(VariableTextInput, __spreadValues({}, inputProps)) })
7102
- }
7103
- );
7104
- }
7105
- };
7104
+ )
7105
+ }
7106
+ );
7107
+ }
7106
7108
  var TextInputRenderer_default = TextInputRenderer;
7107
7109
 
7108
7110
  // ../renderers/src/UpdatableRenderer.tsx
@@ -7260,7 +7262,7 @@ var LargeUploadRenderer = {
7260
7262
  // ../renderers/src/UpsellRenderer.tsx
7261
7263
  var import_classnames35 = __toESM(require_classnames());
7262
7264
  import { Nudge } from "@transferwise/components";
7263
- import { useState as useState21 } from "react";
7265
+ import { useState as useState22 } from "react";
7264
7266
  import { jsx as jsx104 } from "react/jsx-runtime";
7265
7267
  var UpsellRenderer = {
7266
7268
  canRenderType: "upsell",
@@ -7268,7 +7270,7 @@ var UpsellRenderer = {
7268
7270
  };
7269
7271
  function UpsellRendererComponent(props) {
7270
7272
  const { text, callToAction, media, margin, onDismiss, control, tags } = props;
7271
- const [isVisible, setIsVisible] = useState21(true);
7273
+ const [isVisible, setIsVisible] = useState22(true);
7272
7274
  return isVisible ? /* @__PURE__ */ jsx104(
7273
7275
  Nudge,
7274
7276
  {
@@ -7615,13 +7617,13 @@ var openLinkInNewTab = (url) => {
7615
7617
  };
7616
7618
 
7617
7619
  // src/dynamicFlow/DynamicFlow.tsx
7618
- import { jsxs as jsxs41 } from "react/jsx-runtime";
7620
+ import { jsxs as jsxs40 } from "react/jsx-runtime";
7619
7621
  function DynamicFlow(props) {
7620
7622
  const { className = "" } = props;
7621
7623
  const dfProps = useWiseToCoreProps(props);
7622
7624
  const df = useDynamicFlow(dfProps);
7623
7625
  const { onContextMenu, contextMenu } = useDFContextMenu(df.controller);
7624
- return /* @__PURE__ */ jsxs41("div", { className, onContextMenu, children: [
7626
+ return /* @__PURE__ */ jsxs40("div", { className, onContextMenu, children: [
7625
7627
  df.view,
7626
7628
  contextMenu
7627
7629
  ] });
@@ -7811,6 +7813,8 @@ var en_default = {
7811
7813
  "df.wise.group.currencies-with-account-details": "Currencies with account details",
7812
7814
  "df.wise.group.popular": "Popular",
7813
7815
  "df.wise.group.recent": "Recent",
7816
+ "df.wise.ssnInput.hideValue": "Hide value",
7817
+ "df.wise.ssnInput.showValue": "Show value",
7814
7818
  "df.wise.step.scrollToBottom": "Scroll to bottom"
7815
7819
  };
7816
7820