@transferwise/components 46.29.0 → 46.29.1

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/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
- import React__default, { forwardRef, cloneElement, useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect, createContext, useContext, useImperativeHandle, createElement, Component, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
4
+ import React__default, { forwardRef, cloneElement, useState, useEffect, useRef, useMemo, useCallback, createContext, useContext, useImperativeHandle, createElement, Component, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
5
5
  import { useId } from '@radix-ui/react-id';
6
6
  import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
7
7
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
@@ -19,7 +19,6 @@ import { CSSTransition } from 'react-transition-group';
19
19
  import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
20
20
  import { createPortal } from 'react-dom';
21
21
  import { usePopper } from 'react-popper';
22
- import throttle from 'lodash.throttle';
23
22
  import { Flag, Illustration } from '@wise/art';
24
23
  import clamp$2 from 'lodash.clamp';
25
24
  import debounce from 'lodash.debounce';
@@ -1459,41 +1458,6 @@ const DimmerContentWrapper = ({
1459
1458
  };
1460
1459
  var Dimmer$1 = withNextPortalWrapper(Dimmer);
1461
1460
 
1462
- const THROTTLE_MS = 100;
1463
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
1464
- const useClientWidth = ({
1465
- ref,
1466
- throttleMs = THROTTLE_MS
1467
- }) => {
1468
- const [clientWidth, setClientWidth] = useState(null);
1469
- useIsomorphicLayoutEffect(() => {
1470
- // eslint-disable-next-line unicorn/consistent-function-scoping
1471
- const updateClientWidth = () => {
1472
- if (ref) {
1473
- // when `ref` is a window
1474
- if ('innerWidth' in ref) {
1475
- setClientWidth(ref.innerWidth);
1476
- }
1477
- // when `ref` is an element
1478
- else if (ref.current) {
1479
- setClientWidth(ref.current.clientWidth);
1480
- }
1481
- }
1482
- };
1483
- // This assignment saves a reference to the function so it will be the same passed to both addEventListener removeEventListener.
1484
- // If throttle gets passed directly to both add and removeEventListenet the results will be that the event
1485
- // won't get removed even if the component is unmounted.
1486
- const attachedFunction = throttle(updateClientWidth, throttleMs);
1487
- window.addEventListener('resize', attachedFunction, true);
1488
- // using requestAnimationFrame to perform the calculation before the next repaint
1489
- // getting width earlier causes issues in animations when used with react-transition-group
1490
- window.requestAnimationFrame(updateClientWidth);
1491
- return () => window.removeEventListener('resize', attachedFunction, true);
1492
- }, []);
1493
- return [clientWidth];
1494
- };
1495
- useClientWidth.THROTTLE_MS = THROTTLE_MS;
1496
-
1497
1461
  const useConditionalListener = ({
1498
1462
  attachListener,
1499
1463
  callback,
@@ -4814,49 +4778,41 @@ const FlowNavigation = ({
4814
4778
  onGoBack,
4815
4779
  steps
4816
4780
  }) => {
4817
- const reference = useRef(null);
4818
4781
  const intl = useIntl();
4819
- const [clientWidth] = useClientWidth({
4820
- ref: reference
4821
- });
4822
4782
  const closeButton = onClose != null && /*#__PURE__*/jsx(CloseButton, {
4823
4783
  size: "lg",
4824
4784
  onClick: onClose
4825
4785
  });
4826
- const isSmall = clientWidth != null && clientWidth < Breakpoint.SMALL;
4827
- const isLarge = clientWidth != null && clientWidth >= Breakpoint.LARGE;
4786
+ const screenSm = useScreenSize(Breakpoint.SMALL);
4787
+ const screenLg = useScreenSize(Breakpoint.LARGE);
4828
4788
  const newAvatar = done ? null : avatar;
4829
4789
  const displayGoBack = onGoBack != null && activeStep > 0;
4830
4790
  return /*#__PURE__*/jsx("div", {
4831
- ref: reference,
4832
4791
  className: classNames('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
4833
4792
  'np-flow-navigation--border-bottom': !done
4834
4793
  }),
4835
4794
  children: /*#__PURE__*/jsx(FlowHeader, {
4836
- className: classNames('np-flow-navigation__content p-x-3', {
4837
- 'np-flow-navigation--hidden': !clientWidth,
4838
- 'np-flow-navigation--xs-max': isSmall,
4795
+ className: classNames('np-flow-navigation__content p-x-3', screenSm == null ? 'np-flow-navigation--hidden' : {
4796
+ 'np-flow-navigation--xs-max': !screenSm,
4839
4797
  // Size switches on parent container which may or may not have the same size as the window.
4840
- 'np-flow-navigation--sm': clientWidth != null && clientWidth >= Breakpoint.SMALL,
4841
- 'np-flow-navigation--lg': isLarge
4798
+ 'np-flow-navigation--sm': screenSm,
4799
+ 'np-flow-navigation--lg': screenLg
4842
4800
  }),
4843
4801
  leftContent: /*#__PURE__*/jsxs(Fragment, {
4844
- children: [isSmall && displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
4802
+ children: [!screenSm && displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
4845
4803
  "aria-label": intl.formatMessage(messages$7.back),
4846
4804
  onClick: onGoBack
4847
4805
  }) : /*#__PURE__*/jsx("div", {
4848
4806
  className: "np-flow-header__left",
4849
4807
  children: logo
4850
- }), isSmall && /*#__PURE__*/jsx(AnimatedLabel, {
4808
+ }), !screenSm && /*#__PURE__*/jsx(AnimatedLabel, {
4851
4809
  className: "m-x-1",
4852
4810
  labels: steps.map(step => step.label),
4853
4811
  activeLabel: activeStep
4854
4812
  })]
4855
4813
  }),
4856
4814
  rightContent: /*#__PURE__*/jsxs("div", {
4857
- className: classNames('np-flow-header__right', 'd-flex', 'align-items-center', 'justify-content-end', {
4858
- 'order-2': isLarge
4859
- }),
4815
+ className: "np-flow-header__right d-flex align-items-center justify-content-end order-2--lg",
4860
4816
  children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
4861
4817
  className: "m-x-1"
4862
4818
  }), closeButton]
@@ -4866,7 +4822,7 @@ const FlowNavigation = ({
4866
4822
  steps: steps,
4867
4823
  className: classNames('np-flow-navigation__stepper')
4868
4824
  }),
4869
- layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout.VERTICAL : Layout.HORIZONTAL
4825
+ layout: !screenLg ? Layout.VERTICAL : Layout.HORIZONTAL
4870
4826
  })
4871
4827
  });
4872
4828
  };
@@ -13600,7 +13556,7 @@ var hu = {
13600
13556
  "neptune.Upload.psProcessingText": "Feltöltés...",
13601
13557
  "neptune.Upload.usButtonText": "Vagy válaszd ki a fájlt",
13602
13558
  "neptune.Upload.usDropMessage": "Húzd ide a fájlokat a feltöltéshez",
13603
- "neptune.Upload.usPlaceholder": "Húzz ide egy legfeljebb {maxSize} MB méretű fájlt",
13559
+ "neptune.Upload.usPlaceholder": "Húzz ide egy legfeljebb {maxSize}MB méretű fájlt",
13604
13560
  "neptune.UploadButton.allFileTypes": "Összes fájltípus",
13605
13561
  "neptune.UploadButton.dropFiles": "Húzd a fájlokat ide a feltöltéshez",
13606
13562
  "neptune.UploadButton.instructions": "{fileTypes}, legfeljebb {size}MB",