@wise/dynamic-flow-client-internal 5.29.0-experimental-6048bca → 5.29.0-experimental-cadf60b

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
@@ -1808,10 +1808,6 @@ var isIOSWebKit = () => {
1808
1808
  const mtp = navigator.maxTouchPoints;
1809
1809
  return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
1810
1810
  };
1811
- var getRect = (element) => {
1812
- const { offsetWidth, offsetHeight } = element;
1813
- return { width: offsetWidth, height: offsetHeight };
1814
- };
1815
1811
  var defaultKeyExtractor = (index) => index;
1816
1812
  var defaultRangeExtractor = (range) => {
1817
1813
  const start = Math.max(range.startIndex - range.overscan, 0);
@@ -1823,43 +1819,6 @@ var defaultRangeExtractor = (range) => {
1823
1819
  }
1824
1820
  return arr;
1825
1821
  };
1826
- var observeElementRect = (instance, cb) => {
1827
- const element = instance.scrollElement;
1828
- if (!element) {
1829
- return;
1830
- }
1831
- const targetWindow = instance.targetWindow;
1832
- if (!targetWindow) {
1833
- return;
1834
- }
1835
- const handler = (rect) => {
1836
- const { width, height } = rect;
1837
- cb({ width: Math.round(width), height: Math.round(height) });
1838
- };
1839
- handler(getRect(element));
1840
- if (!targetWindow.ResizeObserver) {
1841
- return () => {
1842
- };
1843
- }
1844
- const observer = new targetWindow.ResizeObserver((entries) => {
1845
- const run = () => {
1846
- const entry = entries[0];
1847
- if (entry == null ? void 0 : entry.borderBoxSize) {
1848
- const box = entry.borderBoxSize[0];
1849
- if (box) {
1850
- handler({ width: box.inlineSize, height: box.blockSize });
1851
- return;
1852
- }
1853
- }
1854
- handler(getRect(element));
1855
- };
1856
- instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
1857
- });
1858
- observer.observe(element, { box: "border-box" });
1859
- return () => {
1860
- observer.unobserve(element);
1861
- };
1862
- };
1863
1822
  var addEventListenerOptions = {
1864
1823
  passive: true
1865
1824
  };
@@ -1913,10 +1872,6 @@ var observeOffset = (instance, cb, readOffset) => {
1913
1872
  fallback == null ? void 0 : fallback.cancel();
1914
1873
  };
1915
1874
  };
1916
- var observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
1917
- const { horizontal, isRtl } = instance.options;
1918
- return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
1919
- });
1920
1875
  var observeWindowOffset = (instance, cb) => observeOffset(
1921
1876
  instance,
1922
1877
  cb,
@@ -1959,7 +1914,6 @@ var scrollWithAdjustments = (offset, {
1959
1914
  });
1960
1915
  };
1961
1916
  var windowScroll = scrollWithAdjustments;
1962
- var elementScroll = scrollWithAdjustments;
1963
1917
  var Virtualizer = class {
1964
1918
  constructor(opts) {
1965
1919
  this.unsubs = [];
@@ -3202,13 +3156,6 @@ function useVirtualizerBase(_a) {
3202
3156
  });
3203
3157
  return instance;
3204
3158
  }
3205
- function useVirtualizer(options) {
3206
- return useVirtualizerBase(__spreadValues({
3207
- observeElementRect,
3208
- observeElementOffset,
3209
- scrollToFn: elementScroll
3210
- }, options));
3211
- }
3212
3159
  function useWindowVirtualizer(options) {
3213
3160
  return useVirtualizerBase(__spreadValues({
3214
3161
  getScrollElement: () => typeof document !== "undefined" ? window : null,
@@ -3281,7 +3228,7 @@ var FooterWithScrollButton = ({ footer }) => {
3281
3228
  ] })
3282
3229
  ] });
3283
3230
  };
3284
- var useIsElementVisible = (elementRef, root = null) => {
3231
+ var useIsElementVisible = (elementRef) => {
3285
3232
  const [isVisible, setIsVisible] = (0, import_react8.useState)(false);
3286
3233
  (0, import_react8.useEffect)(() => {
3287
3234
  const element = elementRef.current;
@@ -3290,11 +3237,11 @@ var useIsElementVisible = (elementRef, root = null) => {
3290
3237
  ([entry]) => {
3291
3238
  setIsVisible(entry.isIntersecting);
3292
3239
  },
3293
- { root, rootMargin: "1px" }
3240
+ { rootMargin: "1px" }
3294
3241
  );
3295
3242
  observer.observe(element);
3296
3243
  return () => observer.disconnect();
3297
- }, [elementRef, root]);
3244
+ }, [elementRef]);
3298
3245
  return isVisible;
3299
3246
  };
3300
3247
 
@@ -3316,40 +3263,12 @@ var collection_messages_default = (0, import_react_intl8.defineMessages)({
3316
3263
  }
3317
3264
  });
3318
3265
 
3319
- // ../renderers/src/CollectionRenderer/components/getScrollableAncestor.ts
3320
- var SCROLLABLE_OVERFLOW_VALUES = /* @__PURE__ */ new Set(["auto", "overlay", "scroll"]);
3321
- var getScrollableAncestor = (element) => {
3322
- var _a;
3323
- const view = element == null ? void 0 : element.ownerDocument.defaultView;
3324
- let ancestor = (_a = element == null ? void 0 : element.parentElement) != null ? _a : null;
3325
- if (!view) {
3326
- return null;
3327
- }
3328
- while (ancestor) {
3329
- const { overflowY } = view.getComputedStyle(ancestor);
3330
- const hasScrollableOverflow = SCROLLABLE_OVERFLOW_VALUES.has(overflowY);
3331
- if (hasScrollableOverflow && ancestor.scrollHeight > ancestor.clientHeight) {
3332
- return ancestor;
3333
- }
3334
- ancestor = ancestor.parentElement;
3335
- }
3336
- return null;
3337
- };
3338
-
3339
3266
  // ../renderers/src/CollectionRenderer/components/ContentComponent.tsx
3340
3267
  var import_jsx_runtime36 = require("react/jsx-runtime");
3341
3268
  var ContentComponent = (props) => {
3342
3269
  const { state, status, SectionHeader, Item } = props;
3343
- const contentRef = (0, import_react9.useRef)(null);
3344
- const [scrollElement, setScrollElement] = (0, import_react9.useState)(null);
3345
- (0, import_react9.useLayoutEffect)(() => {
3346
- const nextScrollElement = getScrollableAncestor(contentRef.current);
3347
- setScrollElement(
3348
- (currentScrollElement) => currentScrollElement === nextScrollElement ? currentScrollElement : nextScrollElement
3349
- );
3350
- }, []);
3351
3270
  const endOfContentRef = (0, import_react9.useRef)(null);
3352
- const isBottomVisible = useIsElementVisible(endOfContentRef, scrollElement);
3271
+ const isBottomVisible = useIsElementVisible(endOfContentRef);
3353
3272
  (0, import_react9.useEffect)(() => {
3354
3273
  const shouldAutoLoad = isBottomVisible && status.type === "idle" && state.afterSectionsProps.length === 0;
3355
3274
  if (shouldAutoLoad && status.loadMore) {
@@ -3381,90 +3300,51 @@ var ContentComponent = (props) => {
3381
3300
  var _a, _b;
3382
3301
  listOffsetRef.current = (_b = (_a = listRef.current) == null ? void 0 : _a.offsetTop) != null ? _b : 0;
3383
3302
  });
3384
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ref: contentRef, children: [
3303
+ const virtualizer = useWindowVirtualizer({
3304
+ count: stateCount,
3305
+ estimateSize: () => 120,
3306
+ overscan: 10,
3307
+ // eslint-disable-next-line react-hooks/refs
3308
+ scrollMargin: listOffsetRef.current
3309
+ });
3310
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ref: listRef, children: [
3385
3311
  state.beforeSections,
3386
- scrollElement ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3387
- ElementVirtualizedItems,
3388
- {
3389
- Item,
3390
- SectionHeader,
3391
- items,
3392
- scrollElement,
3393
- stateCount
3394
- }
3395
- ) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3396
- WindowVirtualizedItems,
3312
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3313
+ "div",
3397
3314
  {
3398
- Item,
3399
- SectionHeader,
3400
- items,
3401
- stateCount
3315
+ style: {
3316
+ height: `${virtualizer.getTotalSize()}px`,
3317
+ width: "100%",
3318
+ position: "relative"
3319
+ },
3320
+ children: virtualizer.getVirtualItems().map((item) => {
3321
+ const i = items[item.index];
3322
+ if (!i) {
3323
+ return null;
3324
+ }
3325
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3326
+ "div",
3327
+ {
3328
+ ref: virtualizer.measureElement,
3329
+ "data-index": item.index,
3330
+ style: {
3331
+ position: "absolute",
3332
+ top: 0,
3333
+ left: 0,
3334
+ width: "100%",
3335
+ transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
3336
+ },
3337
+ children: i.type === "header" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SectionHeader, __spreadValues({}, i)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Item, __spreadValues({}, i.item))
3338
+ },
3339
+ item.key
3340
+ );
3341
+ })
3402
3342
  }
3403
3343
  ),
3404
3344
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ref: endOfContentRef, className: "d-flex m-x-auto m-y-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PaginationComponent, { status, state }) }),
3405
3345
  state.afterSections
3406
3346
  ] });
3407
3347
  };
3408
- var WindowVirtualizedItems = (props) => {
3409
- const { stateCount } = props;
3410
- const virtualItemsRef = (0, import_react9.useRef)(null);
3411
- const virtualizer = useWindowVirtualizer({
3412
- count: stateCount,
3413
- estimateSize: () => 120,
3414
- overscan: 10
3415
- });
3416
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(VirtualizedItems, __spreadProps(__spreadValues({}, props), { virtualItemsRef, virtualizer }));
3417
- };
3418
- var ElementVirtualizedItems = (props) => {
3419
- const { scrollElement, stateCount } = props;
3420
- const virtualItemsRef = (0, import_react9.useRef)(null);
3421
- const virtualizer = useVirtualizer({
3422
- count: stateCount,
3423
- getScrollElement: () => scrollElement,
3424
- estimateSize: () => 120,
3425
- overscan: 10
3426
- });
3427
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(VirtualizedItems, __spreadProps(__spreadValues({}, props), { virtualItemsRef, virtualizer }));
3428
- };
3429
- var VirtualizedItems = ({
3430
- Item,
3431
- SectionHeader,
3432
- items,
3433
- virtualItemsRef,
3434
- virtualizer
3435
- }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3436
- "div",
3437
- {
3438
- ref: virtualItemsRef,
3439
- style: {
3440
- height: `${virtualizer.getTotalSize()}px`,
3441
- width: "100%",
3442
- position: "relative"
3443
- },
3444
- children: virtualizer.getVirtualItems().map((item) => {
3445
- const i = items[item.index];
3446
- if (!i) {
3447
- return null;
3448
- }
3449
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3450
- "div",
3451
- {
3452
- ref: virtualizer.measureElement,
3453
- "data-index": item.index,
3454
- style: {
3455
- position: "absolute",
3456
- top: 0,
3457
- left: 0,
3458
- width: "100%",
3459
- transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
3460
- },
3461
- children: i.type === "header" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SectionHeader, __spreadValues({}, i)) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Item, __spreadValues({}, i.item))
3462
- },
3463
- item.key
3464
- );
3465
- })
3466
- }
3467
- );
3468
3348
  var PaginationComponent = ({
3469
3349
  status,
3470
3350
  state
@@ -6753,6 +6633,7 @@ var import_components69 = require("@transferwise/components");
6753
6633
 
6754
6634
  // ../renderers/src/components/VariableTextInput.tsx
6755
6635
  var import_components68 = require("@transferwise/components");
6636
+ var import_WithDisplayFormat = __toESM(require("@transferwise/components/build/WithDisplayFormat/WithDisplayFormat"));
6756
6637
  var import_jsx_runtime100 = require("react/jsx-runtime");
6757
6638
  var commonKeys = [
6758
6639
  "autoComplete",
@@ -6768,13 +6649,18 @@ var commonKeys = [
6768
6649
  "value"
6769
6650
  ];
6770
6651
  function VariableTextInput(inputProps) {
6771
- const { id, value, control, onChange } = inputProps;
6652
+ const { id, value, control, displayFormat, onChange } = inputProps;
6772
6653
  const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
6654
+ if (control === "ssn-input" || displayFormat === "***-***-***" || displayFormat === "***-**-****") {
6655
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6656
+ }
6773
6657
  switch (control) {
6774
6658
  case "email":
6775
6659
  return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
6776
6660
  case "password":
6777
6661
  return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
6662
+ case "ssn-input":
6663
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(SsnInput, __spreadProps(__spreadValues({}, commonProps), { onChange }));
6778
6664
  case "numeric": {
6779
6665
  const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
6780
6666
  return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
@@ -6795,10 +6681,21 @@ function VariableTextInput(inputProps) {
6795
6681
  }
6796
6682
  }
6797
6683
  function TextInput(props) {
6798
- const _a = props, { control, displayFormat, onChange } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange"]);
6684
+ const _a = props, { control, displayFormat, onChange, type } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange", "type"]);
6799
6685
  const InputWithPattern = control === "textarea" ? import_components68.TextareaWithDisplayFormat : import_components68.InputWithDisplayFormat;
6800
6686
  const InputWithoutPattern = control === "textarea" ? import_components68.TextArea : import_components68.Input;
6801
- 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), { onChange: (e) => onChange(e.target.value) }));
6687
+ 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
+ }
6689
+ function SsnInput(props) {
6690
+ const _a = props, { onChange, type: _type } = _a, commonProps = __objRest(_a, ["onChange", "type"]);
6691
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
6692
+ "input",
6693
+ __spreadProps(__spreadValues({}, commonProps), {
6694
+ 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, ""))
6697
+ })
6698
+ );
6802
6699
  }
6803
6700
 
6804
6701
  // ../renderers/src/TextInputRenderer.tsx