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

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.js CHANGED
@@ -6633,7 +6633,6 @@ 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_WithDisplayFormat = __toESM(require("@transferwise/components/build/WithDisplayFormat/WithDisplayFormat"));
6637
6636
  var import_jsx_runtime100 = require("react/jsx-runtime");
6638
6637
  var commonKeys = [
6639
6638
  "autoComplete",
@@ -6643,15 +6642,18 @@ var commonKeys = [
6643
6642
  "disabled",
6644
6643
  "displayFormat",
6645
6644
  "id",
6645
+ "maxLength",
6646
+ "minLength",
6646
6647
  "onBlur",
6647
6648
  "onFocus",
6648
6649
  "placeholder",
6650
+ "required",
6649
6651
  "value"
6650
6652
  ];
6651
6653
  function VariableTextInput(inputProps) {
6652
6654
  const { id, value, control, displayFormat, onChange } = inputProps;
6653
6655
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6654
- if (control === "ssn-input" || displayFormat === "***-***-***" || displayFormat === "***-**-****") {
6656
+ if (control === "ssn-input" || (displayFormat == null ? void 0 : displayFormat.includes("*"))) {
6655
6657
  return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6656
6658
  }
6657
6659
  switch (control) {
@@ -6687,13 +6689,57 @@ function TextInput(props) {
6687
6689
  return displayFormat ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { type, onChange: (e) => onChange(e.target.value) }));
6688
6690
  }
6689
6691
  function SsnInput(props) {
6690
- const _a = props, { onChange, type: _type } = _a, commonProps = __objRest(_a, ["onChange", "type"]);
6692
+ const _a = props, {
6693
+ displayFormat = "",
6694
+ maxLength,
6695
+ minLength: _minLength,
6696
+ onChange,
6697
+ type: _type,
6698
+ value = ""
6699
+ } = _a, commonProps = __objRest(_a, [
6700
+ "displayFormat",
6701
+ "maxLength",
6702
+ "minLength",
6703
+ "onChange",
6704
+ "type",
6705
+ "value"
6706
+ ]);
6707
+ const maxDigits = displayFormat.split("").filter((character) => character === "*").length || maxLength || Infinity;
6708
+ const maskedValue = displayFormat ? displayFormat.split("").reduce(
6709
+ ({ display, digitsUsed }, character) => {
6710
+ if (character === "*") {
6711
+ return digitsUsed < value.length ? { display: `${display}\u2022`, digitsUsed: digitsUsed + 1 } : { display, digitsUsed };
6712
+ }
6713
+ return digitsUsed > 0 && digitsUsed < value.length ? { display: `${display}${character}`, digitsUsed } : { display, digitsUsed };
6714
+ },
6715
+ { display: "", digitsUsed: 0 }
6716
+ ).display : "\u2022".repeat(value.length);
6691
6717
  return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6692
6718
  "input",
6693
6719
  __spreadProps(__spreadValues({}, commonProps), {
6694
6720
  className: "form-control np-form-control np-form-control--size-auto np-input np-input--shape-rectangle",
6695
- type: "password",
6696
- onChange: (event) => onChange(event.target.value.replace(/[^0-9]/g, ""))
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}`);
6732
+ }
6733
+ } else if (event.key === "Backspace") {
6734
+ event.preventDefault();
6735
+ onChange(rawValue.slice(0, -1));
6736
+ }
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));
6742
+ }
6697
6743
  })
6698
6744
  );
6699
6745
  }
package/build/main.mjs CHANGED
@@ -6628,7 +6628,6 @@ import {
6628
6628
  TextArea,
6629
6629
  TextareaWithDisplayFormat
6630
6630
  } from "@transferwise/components";
6631
- import WithDisplayFormatModule from "@transferwise/components/build/WithDisplayFormat/WithDisplayFormat";
6632
6631
  import { jsx as jsx100 } from "react/jsx-runtime";
6633
6632
  var commonKeys = [
6634
6633
  "autoComplete",
@@ -6638,15 +6637,18 @@ var commonKeys = [
6638
6637
  "disabled",
6639
6638
  "displayFormat",
6640
6639
  "id",
6640
+ "maxLength",
6641
+ "minLength",
6641
6642
  "onBlur",
6642
6643
  "onFocus",
6643
6644
  "placeholder",
6645
+ "required",
6644
6646
  "value"
6645
6647
  ];
6646
6648
  function VariableTextInput(inputProps) {
6647
6649
  const { id, value, control, displayFormat, onChange } = inputProps;
6648
6650
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6649
- if (control === "ssn-input" || displayFormat === "***-***-***" || displayFormat === "***-**-****") {
6651
+ if (control === "ssn-input" || (displayFormat == null ? void 0 : displayFormat.includes("*"))) {
6650
6652
  return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6651
6653
  }
6652
6654
  switch (control) {
@@ -6682,13 +6684,57 @@ function TextInput(props) {
6682
6684
  return displayFormat ? /* @__PURE__ */ jsx100(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ jsx100(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { type, onChange: (e) => onChange(e.target.value) }));
6683
6685
  }
6684
6686
  function SsnInput(props) {
6685
- const _a = props, { onChange, type: _type } = _a, commonProps = __objRest(_a, ["onChange", "type"]);
6687
+ const _a = props, {
6688
+ displayFormat = "",
6689
+ maxLength,
6690
+ minLength: _minLength,
6691
+ onChange,
6692
+ type: _type,
6693
+ value = ""
6694
+ } = _a, commonProps = __objRest(_a, [
6695
+ "displayFormat",
6696
+ "maxLength",
6697
+ "minLength",
6698
+ "onChange",
6699
+ "type",
6700
+ "value"
6701
+ ]);
6702
+ const maxDigits = displayFormat.split("").filter((character) => character === "*").length || maxLength || Infinity;
6703
+ const maskedValue = displayFormat ? displayFormat.split("").reduce(
6704
+ ({ display, digitsUsed }, character) => {
6705
+ if (character === "*") {
6706
+ return digitsUsed < value.length ? { display: `${display}\u2022`, digitsUsed: digitsUsed + 1 } : { display, digitsUsed };
6707
+ }
6708
+ return digitsUsed > 0 && digitsUsed < value.length ? { display: `${display}${character}`, digitsUsed } : { display, digitsUsed };
6709
+ },
6710
+ { display: "", digitsUsed: 0 }
6711
+ ).display : "\u2022".repeat(value.length);
6686
6712
  return /* @__PURE__ */ jsx100(
6687
6713
  "input",
6688
6714
  __spreadProps(__spreadValues({}, commonProps), {
6689
6715
  className: "form-control np-form-control np-form-control--size-auto np-input np-input--shape-rectangle",
6690
- type: "password",
6691
- onChange: (event) => onChange(event.target.value.replace(/[^0-9]/g, ""))
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}`);
6727
+ }
6728
+ } else if (event.key === "Backspace") {
6729
+ event.preventDefault();
6730
+ onChange(rawValue.slice(0, -1));
6731
+ }
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));
6737
+ }
6692
6738
  })
6693
6739
  );
6694
6740
  }