@wise/dynamic-flow-client-internal 5.29.0-experimental-3acf859 → 5.29.0-experimental-9e4b087

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.css CHANGED
@@ -387,6 +387,31 @@
387
387
  .df-prefer-container-queries {
388
388
  container-type: inline-size;
389
389
  }
390
+
391
+ .df-ssn-input-wrapper {
392
+ position: relative;
393
+ }
394
+
395
+ .df-ssn-input {
396
+ padding-right: 3.5rem;
397
+ }
398
+
399
+ .df-ssn-input-toggle {
400
+ align-items: center;
401
+ background: transparent;
402
+ border: 0;
403
+ color: inherit;
404
+ cursor: pointer;
405
+ display: flex;
406
+ height: 100%;
407
+ justify-content: center;
408
+ padding: 0;
409
+ position: absolute;
410
+ right: 0;
411
+ top: 0;
412
+ width: 3.5rem;
413
+ }
414
+
390
415
  .df-context-menu {
391
416
  position: fixed;
392
417
  z-index: 10;
package/build/main.js CHANGED
@@ -336,7 +336,7 @@ var recursivelyRemoveNullish = (element) => {
336
336
  };
337
337
 
338
338
  // src/dynamicFlow/useWiseToCoreProps.tsx
339
- var import_react30 = require("react");
339
+ var import_react31 = require("react");
340
340
 
341
341
  // src/dynamicFlow/getMergedRenderers.tsx
342
342
  var import_dynamic_flow_client2 = require("@wise/dynamic-flow-client");
@@ -6633,6 +6633,8 @@ var import_components69 = require("@transferwise/components");
6633
6633
 
6634
6634
  // ../renderers/src/components/VariableTextInput.tsx
6635
6635
  var import_components68 = require("@transferwise/components");
6636
+ var import_icons7 = require("@transferwise/icons");
6637
+ var import_react27 = require("react");
6636
6638
  var import_jsx_runtime100 = require("react/jsx-runtime");
6637
6639
  var commonKeys = [
6638
6640
  "autoComplete",
@@ -6642,19 +6644,16 @@ var commonKeys = [
6642
6644
  "disabled",
6643
6645
  "displayFormat",
6644
6646
  "id",
6645
- "maxLength",
6646
- "minLength",
6647
6647
  "onBlur",
6648
6648
  "onFocus",
6649
6649
  "placeholder",
6650
- "required",
6651
6650
  "value"
6652
6651
  ];
6653
6652
  function VariableTextInput(inputProps) {
6654
6653
  const { id, value, control, displayFormat, onChange } = inputProps;
6655
6654
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6656
6655
  if (control === "ssn-input" || (displayFormat == null ? void 0 : displayFormat.includes("*"))) {
6657
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6656
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(SsnInput, __spreadProps(__spreadValues({}, commonProps), { maxLength: inputProps.maxLength, onChange }));
6658
6657
  }
6659
6658
  switch (control) {
6660
6659
  case "email":
@@ -6692,56 +6691,70 @@ function SsnInput(props) {
6692
6691
  const _a = props, {
6693
6692
  displayFormat = "",
6694
6693
  maxLength,
6695
- minLength: _minLength,
6696
6694
  onChange,
6697
6695
  type: _type,
6698
6696
  value = ""
6699
6697
  } = _a, commonProps = __objRest(_a, [
6700
6698
  "displayFormat",
6701
6699
  "maxLength",
6702
- "minLength",
6703
6700
  "onChange",
6704
6701
  "type",
6705
6702
  "value"
6706
6703
  ]);
6704
+ const [isVisible, setIsVisible] = (0, import_react27.useState)(false);
6707
6705
  const maxDigits = displayFormat.split("").filter((character) => character === "*").length || maxLength || Infinity;
6708
- const maskedValue = displayFormat ? displayFormat.split("").reduce(
6706
+ const formattedValue = displayFormat ? displayFormat.split("").reduce(
6709
6707
  ({ display, digitsUsed }, character) => {
6710
6708
  if (character === "*") {
6711
- return digitsUsed < value.length ? { display: `${display}\u2022`, digitsUsed: digitsUsed + 1 } : { display, digitsUsed };
6709
+ return digitsUsed < value.length ? {
6710
+ display: `${display}${isVisible ? value[digitsUsed] : "\u2022"}`,
6711
+ digitsUsed: digitsUsed + 1
6712
+ } : { display, digitsUsed };
6712
6713
  }
6713
6714
  return digitsUsed > 0 && digitsUsed < value.length ? { display: `${display}${character}`, digitsUsed } : { display, digitsUsed };
6714
6715
  },
6715
6716
  { display: "", digitsUsed: 0 }
6716
- ).display : "\u2022".repeat(value.length);
6717
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6718
- "input",
6719
- __spreadProps(__spreadValues({}, commonProps), {
6720
- className: "form-control np-form-control np-form-control--size-auto np-input np-input--shape-rectangle",
6721
- type: "text",
6722
- inputMode: "numeric",
6723
- maxLength: displayFormat.length || maxLength,
6724
- value: maskedValue,
6725
- onChange: () => void 0,
6726
- onKeyDown: (event) => {
6727
- const rawValue = value.replace(/[^0-9]/g, "");
6728
- if (/^[0-9]$/.test(event.key)) {
6729
- event.preventDefault();
6730
- if (rawValue.length < maxDigits) {
6731
- onChange(`${rawValue}${event.key}`);
6717
+ ).display : isVisible ? value : "\u2022".repeat(value.length);
6718
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "df-ssn-input-wrapper", children: [
6719
+ /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6720
+ "input",
6721
+ __spreadProps(__spreadValues({}, commonProps), {
6722
+ className: "form-control np-form-control np-input np-input--shape-rectangle df-ssn-input",
6723
+ type: "text",
6724
+ inputMode: "numeric",
6725
+ maxLength: displayFormat.length || maxLength,
6726
+ value: formattedValue,
6727
+ onChange: () => void 0,
6728
+ onKeyDown: (event) => {
6729
+ const rawValue = value.replace(/\D/g, "");
6730
+ if (/^\d$/.test(event.key)) {
6731
+ event.preventDefault();
6732
+ if (rawValue.length < maxDigits) {
6733
+ onChange(`${rawValue}${event.key}`);
6734
+ }
6735
+ } else if (event.key === "Backspace") {
6736
+ event.preventDefault();
6737
+ onChange(rawValue.slice(0, -1));
6732
6738
  }
6733
- } else if (event.key === "Backspace") {
6739
+ },
6740
+ onPaste: (event) => {
6734
6741
  event.preventDefault();
6735
- onChange(rawValue.slice(0, -1));
6742
+ const pastedValue = event.clipboardData.getData("text").replace(/\D/g, "");
6743
+ onChange(`${value}${pastedValue}`.replace(/\D/g, "").slice(0, maxDigits));
6736
6744
  }
6737
- },
6738
- onPaste: (event) => {
6739
- event.preventDefault();
6740
- const pastedValue = event.clipboardData.getData("text").replace(/[^0-9]/g, "");
6741
- onChange(`${value}${pastedValue}`.replace(/[^0-9]/g, "").slice(0, maxDigits));
6745
+ })
6746
+ ),
6747
+ /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6748
+ "button",
6749
+ {
6750
+ type: "button",
6751
+ className: "df-ssn-input-toggle",
6752
+ "aria-label": isVisible ? "Hide value" : "Show value",
6753
+ onClick: () => setIsVisible((visible) => !visible),
6754
+ children: isVisible ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_icons7.EyeShut, { size: 24 }) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_icons7.Eye, { size: 24 })
6742
6755
  }
6743
- })
6744
- );
6756
+ )
6757
+ ] });
6745
6758
  }
6746
6759
 
6747
6760
  // ../renderers/src/TextInputRenderer.tsx
@@ -6953,7 +6966,7 @@ var LargeUploadRenderer = {
6953
6966
  // ../renderers/src/UpsellRenderer.tsx
6954
6967
  var import_components71 = require("@transferwise/components");
6955
6968
  var import_classnames35 = __toESM(require_classnames());
6956
- var import_react27 = require("react");
6969
+ var import_react28 = require("react");
6957
6970
  var import_jsx_runtime104 = require("react/jsx-runtime");
6958
6971
  var UpsellRenderer = {
6959
6972
  canRenderType: "upsell",
@@ -6961,7 +6974,7 @@ var UpsellRenderer = {
6961
6974
  };
6962
6975
  function UpsellRendererComponent(props) {
6963
6976
  const { text, callToAction, media, margin, onDismiss, control, tags } = props;
6964
- const [isVisible, setIsVisible] = (0, import_react27.useState)(true);
6977
+ const [isVisible, setIsVisible] = (0, import_react28.useState)(true);
6965
6978
  return isVisible ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
6966
6979
  import_components71.Nudge,
6967
6980
  {
@@ -7190,7 +7203,7 @@ var customEventsToAnalytics = {
7190
7203
  };
7191
7204
 
7192
7205
  // src/dynamicFlow/useOnCopy.tsx
7193
- var import_react28 = require("react");
7206
+ var import_react29 = require("react");
7194
7207
  var import_react_intl36 = require("react-intl");
7195
7208
 
7196
7209
  // src/dynamicFlow/messages.ts
@@ -7212,7 +7225,7 @@ var messages_default = (0, import_react_intl35.defineMessages)({
7212
7225
  var useOnCopy = () => {
7213
7226
  const { formatMessage } = (0, import_react_intl36.useIntl)();
7214
7227
  const createSnackBar = useSnackBarIfAvailable();
7215
- return (0, import_react28.useCallback)(
7228
+ return (0, import_react29.useCallback)(
7216
7229
  (copiedContent) => {
7217
7230
  if (copiedContent) {
7218
7231
  createSnackBar({ text: formatMessage(messages_default.copied) });
@@ -7225,11 +7238,11 @@ var useOnCopy = () => {
7225
7238
  };
7226
7239
 
7227
7240
  // src/dynamicFlow/useWiseHttpClient.tsx
7228
- var import_react29 = require("react");
7241
+ var import_react30 = require("react");
7229
7242
  var import_react_intl37 = require("react-intl");
7230
7243
  var useWiseHttpClient = (httpClient) => {
7231
7244
  const { locale } = (0, import_react_intl37.useIntl)();
7232
- return (0, import_react29.useCallback)(
7245
+ return (0, import_react30.useCallback)(
7233
7246
  async (input, init = {}) => {
7234
7247
  const headers = new Headers(init.headers);
7235
7248
  headers.set("accept-language", locale);
@@ -7270,10 +7283,10 @@ var useWiseToCoreProps = (props) => {
7270
7283
  onLog
7271
7284
  } = props;
7272
7285
  const httpClient = useWiseHttpClient(customFetch);
7273
- const mergedRenderers = (0, import_react30.useMemo)(() => getMergedRenderers(props), [renderers]);
7286
+ const mergedRenderers = (0, import_react31.useMemo)(() => getMergedRenderers(props), [renderers]);
7274
7287
  const createSnackBar = useCreateSnackBar();
7275
- const logEvent = (0, import_react30.useMemo)(() => getLogEvent(onLog), [onLog]);
7276
- const trackEvent = (0, import_react30.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
7288
+ const logEvent = (0, import_react31.useMemo)(() => getLogEvent(onLog), [onLog]);
7289
+ const trackEvent = (0, import_react31.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
7277
7290
  const onCopy = useOnCopy();
7278
7291
  return __spreadProps(__spreadValues({}, props), {
7279
7292
  httpClient,
@@ -7321,14 +7334,14 @@ function DynamicFlow(props) {
7321
7334
  }
7322
7335
 
7323
7336
  // src/dynamicFlow/DynamicFlowWithRef.tsx
7324
- var import_react31 = require("react");
7337
+ var import_react32 = require("react");
7325
7338
  var import_dynamic_flow_client5 = require("@wise/dynamic-flow-client");
7326
7339
  var import_jsx_runtime109 = require("react/jsx-runtime");
7327
- var DynamicFlowWithRef = (0, import_react31.forwardRef)(function DynamicFlowWithRef2(props, ref) {
7340
+ var DynamicFlowWithRef = (0, import_react32.forwardRef)(function DynamicFlowWithRef2(props, ref) {
7328
7341
  const { className = "" } = props;
7329
7342
  const dfProps = useWiseToCoreProps(props);
7330
7343
  const df = (0, import_dynamic_flow_client5.useDynamicFlow)(dfProps);
7331
- (0, import_react31.useImperativeHandle)(
7344
+ (0, import_react32.useImperativeHandle)(
7332
7345
  ref,
7333
7346
  () => ({
7334
7347
  getValue: () => {
package/build/main.mjs CHANGED
@@ -6628,7 +6628,9 @@ import {
6628
6628
  TextArea,
6629
6629
  TextareaWithDisplayFormat
6630
6630
  } from "@transferwise/components";
6631
- import { jsx as jsx100 } from "react/jsx-runtime";
6631
+ import { Eye, EyeShut } from "@transferwise/icons";
6632
+ import { useState as useState19 } from "react";
6633
+ import { jsx as jsx100, jsxs as jsxs40 } from "react/jsx-runtime";
6632
6634
  var commonKeys = [
6633
6635
  "autoComplete",
6634
6636
  "autoCapitalize",
@@ -6637,19 +6639,16 @@ var commonKeys = [
6637
6639
  "disabled",
6638
6640
  "displayFormat",
6639
6641
  "id",
6640
- "maxLength",
6641
- "minLength",
6642
6642
  "onBlur",
6643
6643
  "onFocus",
6644
6644
  "placeholder",
6645
- "required",
6646
6645
  "value"
6647
6646
  ];
6648
6647
  function VariableTextInput(inputProps) {
6649
6648
  const { id, value, control, displayFormat, onChange } = inputProps;
6650
6649
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6651
6650
  if (control === "ssn-input" || (displayFormat == null ? void 0 : displayFormat.includes("*"))) {
6652
- return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6651
+ return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { maxLength: inputProps.maxLength, onChange }));
6653
6652
  }
6654
6653
  switch (control) {
6655
6654
  case "email":
@@ -6687,56 +6686,70 @@ function SsnInput(props) {
6687
6686
  const _a = props, {
6688
6687
  displayFormat = "",
6689
6688
  maxLength,
6690
- minLength: _minLength,
6691
6689
  onChange,
6692
6690
  type: _type,
6693
6691
  value = ""
6694
6692
  } = _a, commonProps = __objRest(_a, [
6695
6693
  "displayFormat",
6696
6694
  "maxLength",
6697
- "minLength",
6698
6695
  "onChange",
6699
6696
  "type",
6700
6697
  "value"
6701
6698
  ]);
6699
+ const [isVisible, setIsVisible] = useState19(false);
6702
6700
  const maxDigits = displayFormat.split("").filter((character) => character === "*").length || maxLength || Infinity;
6703
- const maskedValue = displayFormat ? displayFormat.split("").reduce(
6701
+ const formattedValue = displayFormat ? displayFormat.split("").reduce(
6704
6702
  ({ display, digitsUsed }, character) => {
6705
6703
  if (character === "*") {
6706
- return digitsUsed < value.length ? { display: `${display}\u2022`, digitsUsed: digitsUsed + 1 } : { display, digitsUsed };
6704
+ return digitsUsed < value.length ? {
6705
+ display: `${display}${isVisible ? value[digitsUsed] : "\u2022"}`,
6706
+ digitsUsed: digitsUsed + 1
6707
+ } : { display, digitsUsed };
6707
6708
  }
6708
6709
  return digitsUsed > 0 && digitsUsed < value.length ? { display: `${display}${character}`, digitsUsed } : { display, digitsUsed };
6709
6710
  },
6710
6711
  { display: "", digitsUsed: 0 }
6711
- ).display : "\u2022".repeat(value.length);
6712
- return /* @__PURE__ */ jsx100(
6713
- "input",
6714
- __spreadProps(__spreadValues({}, commonProps), {
6715
- className: "form-control np-form-control np-form-control--size-auto np-input np-input--shape-rectangle",
6716
- type: "text",
6717
- inputMode: "numeric",
6718
- maxLength: displayFormat.length || maxLength,
6719
- value: maskedValue,
6720
- onChange: () => void 0,
6721
- onKeyDown: (event) => {
6722
- const rawValue = value.replace(/[^0-9]/g, "");
6723
- if (/^[0-9]$/.test(event.key)) {
6724
- event.preventDefault();
6725
- if (rawValue.length < maxDigits) {
6726
- onChange(`${rawValue}${event.key}`);
6712
+ ).display : isVisible ? value : "\u2022".repeat(value.length);
6713
+ return /* @__PURE__ */ jsxs40("div", { className: "df-ssn-input-wrapper", children: [
6714
+ /* @__PURE__ */ jsx100(
6715
+ "input",
6716
+ __spreadProps(__spreadValues({}, commonProps), {
6717
+ className: "form-control np-form-control np-input np-input--shape-rectangle df-ssn-input",
6718
+ type: "text",
6719
+ inputMode: "numeric",
6720
+ maxLength: displayFormat.length || maxLength,
6721
+ value: formattedValue,
6722
+ onChange: () => void 0,
6723
+ onKeyDown: (event) => {
6724
+ const rawValue = value.replace(/\D/g, "");
6725
+ if (/^\d$/.test(event.key)) {
6726
+ event.preventDefault();
6727
+ if (rawValue.length < maxDigits) {
6728
+ onChange(`${rawValue}${event.key}`);
6729
+ }
6730
+ } else if (event.key === "Backspace") {
6731
+ event.preventDefault();
6732
+ onChange(rawValue.slice(0, -1));
6727
6733
  }
6728
- } else if (event.key === "Backspace") {
6734
+ },
6735
+ onPaste: (event) => {
6729
6736
  event.preventDefault();
6730
- onChange(rawValue.slice(0, -1));
6737
+ const pastedValue = event.clipboardData.getData("text").replace(/\D/g, "");
6738
+ onChange(`${value}${pastedValue}`.replace(/\D/g, "").slice(0, maxDigits));
6731
6739
  }
6732
- },
6733
- onPaste: (event) => {
6734
- event.preventDefault();
6735
- const pastedValue = event.clipboardData.getData("text").replace(/[^0-9]/g, "");
6736
- onChange(`${value}${pastedValue}`.replace(/[^0-9]/g, "").slice(0, maxDigits));
6740
+ })
6741
+ ),
6742
+ /* @__PURE__ */ jsx100(
6743
+ "button",
6744
+ {
6745
+ type: "button",
6746
+ className: "df-ssn-input-toggle",
6747
+ "aria-label": isVisible ? "Hide value" : "Show value",
6748
+ onClick: () => setIsVisible((visible) => !visible),
6749
+ children: isVisible ? /* @__PURE__ */ jsx100(EyeShut, { size: 24 }) : /* @__PURE__ */ jsx100(Eye, { size: 24 })
6737
6750
  }
6738
- })
6739
- );
6751
+ )
6752
+ ] });
6740
6753
  }
6741
6754
 
6742
6755
  // ../renderers/src/TextInputRenderer.tsx
@@ -6948,7 +6961,7 @@ var LargeUploadRenderer = {
6948
6961
  // ../renderers/src/UpsellRenderer.tsx
6949
6962
  var import_classnames35 = __toESM(require_classnames());
6950
6963
  import { Nudge } from "@transferwise/components";
6951
- import { useState as useState19 } from "react";
6964
+ import { useState as useState20 } from "react";
6952
6965
  import { jsx as jsx104 } from "react/jsx-runtime";
6953
6966
  var UpsellRenderer = {
6954
6967
  canRenderType: "upsell",
@@ -6956,7 +6969,7 @@ var UpsellRenderer = {
6956
6969
  };
6957
6970
  function UpsellRendererComponent(props) {
6958
6971
  const { text, callToAction, media, margin, onDismiss, control, tags } = props;
6959
- const [isVisible, setIsVisible] = useState19(true);
6972
+ const [isVisible, setIsVisible] = useState20(true);
6960
6973
  return isVisible ? /* @__PURE__ */ jsx104(
6961
6974
  Nudge,
6962
6975
  {
@@ -7303,13 +7316,13 @@ var openLinkInNewTab = (url) => {
7303
7316
  };
7304
7317
 
7305
7318
  // src/dynamicFlow/DynamicFlow.tsx
7306
- import { jsxs as jsxs40 } from "react/jsx-runtime";
7319
+ import { jsxs as jsxs41 } from "react/jsx-runtime";
7307
7320
  function DynamicFlow(props) {
7308
7321
  const { className = "" } = props;
7309
7322
  const dfProps = useWiseToCoreProps(props);
7310
7323
  const df = useDynamicFlow(dfProps);
7311
7324
  const { onContextMenu, contextMenu } = useDFContextMenu(df.controller);
7312
- return /* @__PURE__ */ jsxs40("div", { className, onContextMenu, children: [
7325
+ return /* @__PURE__ */ jsxs41("div", { className, onContextMenu, children: [
7313
7326
  df.view,
7314
7327
  contextMenu
7315
7328
  ] });