@transferwise/components 0.0.0-experimental-63cdd4d → 0.0.0-experimental-84d7c27

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.
Files changed (76) hide show
  1. package/build/index.esm.js +140 -159
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +140 -159
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/actionButton/ActionButton.css +1 -1
  7. package/build/styles/chips/Chip.css +1 -1
  8. package/build/styles/circularButton/CircularButton.css +1 -1
  9. package/build/styles/common/Option/Option.css +1 -1
  10. package/build/styles/common/bottomSheet/BottomSheet.css +1 -1
  11. package/build/styles/common/closeButton/CloseButton.css +1 -1
  12. package/build/styles/dateLookup/DateLookup.css +1 -1
  13. package/build/styles/drawer/Drawer.css +1 -1
  14. package/build/styles/flowNavigation/FlowNavigation.css +1 -1
  15. package/build/styles/main.css +1 -1
  16. package/build/styles/overlayHeader/OverlayHeader.css +1 -1
  17. package/build/styles/statusIcon/StatusIcon.css +1 -1
  18. package/build/styles/summary/Summary.css +1 -1
  19. package/build/styles/typeahead/Typeahead.css +1 -1
  20. package/build/styles/uploadInput/UploadInput.css +1 -1
  21. package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
  22. package/build/types/common/propsValues/breakpoint.d.ts +0 -1
  23. package/build/types/common/propsValues/breakpoint.d.ts.map +1 -1
  24. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  25. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  26. package/build/types/test-utils/story-config.d.ts +1 -11
  27. package/build/types/test-utils/story-config.d.ts.map +1 -1
  28. package/package.json +3 -3
  29. package/src/actionButton/ActionButton.css +1 -1
  30. package/src/actionButton/ActionButton.less +1 -5
  31. package/src/chips/Chip.css +1 -1
  32. package/src/chips/Chip.less +0 -8
  33. package/src/circularButton/CircularButton.css +1 -1
  34. package/src/circularButton/CircularButton.less +3 -9
  35. package/src/common/Option/Option.css +1 -1
  36. package/src/common/Option/Option.less +0 -6
  37. package/src/common/bottomSheet/BottomSheet.css +1 -1
  38. package/src/common/bottomSheet/BottomSheet.less +1 -1
  39. package/src/common/bottomSheet/BottomSheet.spec.tsx +1 -4
  40. package/src/common/bottomSheet/BottomSheet.story.tsx +0 -4
  41. package/src/common/bottomSheet/BottomSheet.tsx +1 -10
  42. package/src/common/closeButton/CloseButton.css +1 -1
  43. package/src/common/closeButton/CloseButton.less +0 -12
  44. package/src/common/hooks/useMedia.spec.ts +17 -3
  45. package/src/common/propsValues/breakpoint.ts +0 -1
  46. package/src/dateLookup/DateLookup.css +1 -1
  47. package/src/dateLookup/DateLookup.js +3 -7
  48. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -3
  49. package/src/dateLookup/DateLookup.less +0 -6
  50. package/src/dateLookup/DateLookup.story.js +1 -6
  51. package/src/dateLookup/DateLookup.testingLibrary.spec.js +1 -3
  52. package/src/dateLookup/DateLookup.view.spec.js +0 -4
  53. package/src/dateLookup/dateHeader/DateHeader.js +2 -4
  54. package/src/drawer/Drawer.css +1 -1
  55. package/src/drawer/Drawer.less +0 -6
  56. package/src/drawer/Drawer.story.js +2 -42
  57. package/src/flowNavigation/FlowNavigation.css +1 -1
  58. package/src/inputs/SelectInput.tsx +1 -1
  59. package/src/main.css +1 -1
  60. package/src/modal/Modal.tsx +2 -2
  61. package/src/overlayHeader/OverlayHeader.css +1 -1
  62. package/src/popover/Popover.spec.js +1 -3
  63. package/src/select/Select.spec.js +9 -6
  64. package/src/statusIcon/StatusIcon.css +1 -1
  65. package/src/statusIcon/StatusIcon.less +0 -10
  66. package/src/summary/Summary.css +1 -1
  67. package/src/summary/Summary.less +1 -1
  68. package/src/test-utils/index.js +0 -1
  69. package/src/test-utils/story-config.ts +7 -21
  70. package/src/typeahead/Typeahead.css +1 -1
  71. package/src/typeahead/Typeahead.less +6 -5
  72. package/src/uploadInput/UploadInput.css +1 -1
  73. package/src/uploadInput/UploadInput.less +1 -5
  74. package/build/types/test-utils/window-mock.d.ts +0 -2
  75. package/build/types/test-utils/window-mock.d.ts.map +0 -1
  76. package/src/test-utils/window-mock.ts +0 -19
@@ -13,11 +13,11 @@ import { CSSTransition } from 'react-transition-group';
13
13
  import { createPortal } from 'react-dom';
14
14
  import { FocusScope } from '@react-aria/focus';
15
15
  import mergeRefs from 'react-merge-refs';
16
- import { useSyncExternalStore } from 'use-sync-external-store/shim';
17
16
  import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
18
17
  import { usePopper } from 'react-popper';
19
18
  import { Transition, Listbox } from '@headlessui/react';
20
19
  import mergeProps from 'merge-props';
20
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
21
21
  import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
22
22
  import { usePreventScroll } from '@react-aria/overlays';
23
23
  import { Illustration } from '@wise/art';
@@ -158,7 +158,6 @@ var Priority;
158
158
 
159
159
  var Breakpoint;
160
160
  (function (Breakpoint) {
161
- Breakpoint[Breakpoint["ZOOM_400"] = 385] = "ZOOM_400";
162
161
  Breakpoint[Breakpoint["EXTRA_SMALL"] = 480] = "EXTRA_SMALL";
163
162
  Breakpoint[Breakpoint["SMALL"] = 576] = "SMALL";
164
163
  Breakpoint[Breakpoint["MEDIUM"] = 768] = "MEDIUM";
@@ -1707,6 +1706,58 @@ const DimmerContentWrapper = ({
1707
1706
  };
1708
1707
  var Dimmer$1 = withNextPortalWrapper(Dimmer);
1709
1708
 
1709
+ const EXIT_ANIMATION = 350;
1710
+ const SlidingPanel = /*#__PURE__*/forwardRef(({
1711
+ children,
1712
+ className,
1713
+ open,
1714
+ position,
1715
+ showSlidingPanelBorder,
1716
+ slidingPanelPositionFixed,
1717
+ ...rest
1718
+ }, reference) => {
1719
+ /** @type {RefObject<HTMLDivElement>} */
1720
+ const localReference = useRef(null);
1721
+ return /*#__PURE__*/jsx(CSSTransition, {
1722
+ ...rest,
1723
+ nodeRef: localReference,
1724
+ in: open
1725
+ // Wait for animation to finish before unmount.
1726
+ ,
1727
+ timeout: {
1728
+ enter: 0,
1729
+ exit: EXIT_ANIMATION
1730
+ },
1731
+ classNames: classNames(`sliding-panel--open-${position}`, showSlidingPanelBorder && `sliding-panel--border-${position}`, {
1732
+ 'sliding-panel--fixed': slidingPanelPositionFixed
1733
+ }, 'sliding-panel'),
1734
+ appear: true,
1735
+ unmountOnExit: true,
1736
+ children: /*#__PURE__*/jsx("div", {
1737
+ ref: mergeRefs([reference, localReference]),
1738
+ className: classNames('sliding-panel', `sliding-panel--open-${position}`, className),
1739
+ children: children
1740
+ })
1741
+ });
1742
+ });
1743
+ SlidingPanel.propTypes = {
1744
+ children: PropTypes.node,
1745
+ className: PropTypes.string,
1746
+ open: PropTypes.bool,
1747
+ position: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
1748
+ showSlidingPanelBorder: PropTypes.bool,
1749
+ slidingPanelPositionFixed: PropTypes.bool
1750
+ };
1751
+ SlidingPanel.defaultProps = {
1752
+ children: null,
1753
+ className: undefined,
1754
+ open: false,
1755
+ position: 'left',
1756
+ showSlidingPanelBorder: false,
1757
+ slidingPanelPositionFixed: false
1758
+ };
1759
+ var SlidingPanel$1 = SlidingPanel;
1760
+
1710
1761
  const THROTTLE_MS = 100;
1711
1762
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
1712
1763
  const useClientWidth = ({
@@ -1877,137 +1928,6 @@ const useLayout = () => {
1877
1928
  };
1878
1929
  };
1879
1930
 
1880
- const EXIT_ANIMATION = 350;
1881
- const SlidingPanel = /*#__PURE__*/forwardRef(({
1882
- children,
1883
- className,
1884
- open,
1885
- position,
1886
- showSlidingPanelBorder,
1887
- slidingPanelPositionFixed,
1888
- ...rest
1889
- }, reference) => {
1890
- /** @type {RefObject<HTMLDivElement>} */
1891
- const localReference = useRef(null);
1892
- return /*#__PURE__*/jsx(CSSTransition, {
1893
- ...rest,
1894
- nodeRef: localReference,
1895
- in: open
1896
- // Wait for animation to finish before unmount.
1897
- ,
1898
- timeout: {
1899
- enter: 0,
1900
- exit: EXIT_ANIMATION
1901
- },
1902
- classNames: classNames(`sliding-panel--open-${position}`, showSlidingPanelBorder && `sliding-panel--border-${position}`, {
1903
- 'sliding-panel--fixed': slidingPanelPositionFixed
1904
- }, 'sliding-panel'),
1905
- appear: true,
1906
- unmountOnExit: true,
1907
- children: /*#__PURE__*/jsx("div", {
1908
- ref: mergeRefs([reference, localReference]),
1909
- className: classNames('sliding-panel', `sliding-panel--open-${position}`, className),
1910
- children: children
1911
- })
1912
- });
1913
- });
1914
- SlidingPanel.propTypes = {
1915
- children: PropTypes.node,
1916
- className: PropTypes.string,
1917
- open: PropTypes.bool,
1918
- position: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
1919
- showSlidingPanelBorder: PropTypes.bool,
1920
- slidingPanelPositionFixed: PropTypes.bool
1921
- };
1922
- SlidingPanel.defaultProps = {
1923
- children: null,
1924
- className: undefined,
1925
- open: false,
1926
- position: 'left',
1927
- showSlidingPanelBorder: false,
1928
- slidingPanelPositionFixed: false
1929
- };
1930
- var SlidingPanel$1 = SlidingPanel;
1931
-
1932
- const Drawer = ({
1933
- children,
1934
- className,
1935
- footerContent,
1936
- headerTitle,
1937
- onClose,
1938
- open,
1939
- position
1940
- }) => {
1941
- logActionRequiredIf('Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.', !onClose);
1942
- const {
1943
- isMobile
1944
- } = useLayout();
1945
- return /*#__PURE__*/jsx(Dimmer$1, {
1946
- open: open,
1947
- onClose: onClose,
1948
- children: /*#__PURE__*/jsx(SlidingPanel$1, {
1949
- open: open,
1950
- position: isMobile ? Position.BOTTOM : position,
1951
- children: /*#__PURE__*/jsxs("div", {
1952
- className: classNames('np-drawer', className),
1953
- role: "dialog",
1954
- children: [/*#__PURE__*/jsxs("div", {
1955
- className: classNames('np-drawer-header', {
1956
- 'np-drawer-header--withborder': headerTitle
1957
- }),
1958
- children: [headerTitle && /*#__PURE__*/jsx(Title, {
1959
- type: Typography.TITLE_BODY,
1960
- children: headerTitle
1961
- }), /*#__PURE__*/jsx(CloseButton, {
1962
- onClick: onClose
1963
- })]
1964
- }), children && /*#__PURE__*/jsx("div", {
1965
- className: classNames('np-drawer-content'),
1966
- children: children
1967
- }), footerContent && /*#__PURE__*/jsx("div", {
1968
- className: classNames('np-drawer-footer'),
1969
- children: footerContent
1970
- })]
1971
- })
1972
- })
1973
- });
1974
- };
1975
- Drawer.propTypes = {
1976
- /** The content to appear in the drawer body. */
1977
- children: PropTypes.node,
1978
- className: PropTypes.string,
1979
- /** The content to appear in the drawer footer. */
1980
- footerContent: PropTypes.node,
1981
- /** The content to appear in the drawer header. */
1982
- headerTitle: PropTypes.node,
1983
- /** The action to perform on close click. */
1984
- onClose: PropTypes.func,
1985
- /** The status of Drawer either open or not. */
1986
- open: PropTypes.bool,
1987
- /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
1988
- position: PropTypes.oneOf(['left', 'right', 'bottom'])
1989
- };
1990
- Drawer.defaultProps = {
1991
- children: null,
1992
- className: undefined,
1993
- footerContent: null,
1994
- headerTitle: null,
1995
- onClose: null,
1996
- open: false,
1997
- position: Position.RIGHT
1998
- };
1999
- var Drawer$1 = Drawer;
2000
-
2001
- function useMedia(query) {
2002
- return useSyncExternalStore(onStoreChange => {
2003
- const mediaQueryList = window.matchMedia(query);
2004
- mediaQueryList.addEventListener('change', onStoreChange);
2005
- return () => {
2006
- mediaQueryList.removeEventListener('change', onStoreChange);
2007
- };
2008
- }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
2009
- }
2010
-
2011
1931
  const INITIAL_Y_POSITION = 0;
2012
1932
  const CONTENT_SCROLL_THRESHOLD = 1;
2013
1933
  const MOVE_OFFSET_THRESHOLD = 50;
@@ -2135,13 +2055,7 @@ const BottomSheet$1 = props => {
2135
2055
  maxHeight: `calc(${screenHeight} - ${safeZoneHeight} - ${topbarHeight})`
2136
2056
  };
2137
2057
  }
2138
- const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
2139
- return is400Zoom ? /*#__PURE__*/jsx(Drawer$1, {
2140
- open: props.open,
2141
- className: props.className,
2142
- onClose: close,
2143
- children: props.children
2144
- }) : /*#__PURE__*/jsx(Dimmer$1, {
2058
+ return /*#__PURE__*/jsx(Dimmer$1, {
2145
2059
  open: props.open,
2146
2060
  fadeContentOnEnter: true,
2147
2061
  fadeContentOnExit: true,
@@ -3497,11 +3411,8 @@ const DateHeader = ({
3497
3411
  dateMode
3498
3412
  }) => {
3499
3413
  const intl = useIntl();
3500
- const {
3501
- isMobile
3502
- } = useLayout();
3503
3414
  return /*#__PURE__*/jsxs("div", {
3504
- className: classNames('text-xs-center', !isMobile && ['clearfix', 'p-y-1']),
3415
+ className: "text-xs-center p-t-1 p-b-2 clearfix",
3505
3416
  children: [/*#__PURE__*/jsx("div", {
3506
3417
  className: "pull-left-single-direction",
3507
3418
  children: /*#__PURE__*/jsx("button", {
@@ -4097,8 +4008,7 @@ class DateLookup extends PureComponent {
4097
4008
  viewMonth: (props.value || new Date()).getMonth(),
4098
4009
  viewYear: (props.value || new Date()).getFullYear(),
4099
4010
  open: false,
4100
- mode: MODE.DAY,
4101
- isMobile: false
4011
+ mode: MODE.DAY
4102
4012
  };
4103
4013
  }
4104
4014
  static getDerivedStateFromProps(props, state) {
@@ -4133,10 +4043,6 @@ class DateLookup extends PureComponent {
4133
4043
  if (+this.props.value !== +previousProps.value && this.state.open) {
4134
4044
  this.focusOn('.active');
4135
4045
  }
4136
- this.mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);
4137
- this.setState({
4138
- isMobile: this.mediaQuery.matches
4139
- });
4140
4046
  }
4141
4047
  componentWillUnmount() {
4142
4048
  // Prevents memory leak by cleaning state.
@@ -4269,17 +4175,14 @@ class DateLookup extends PureComponent {
4269
4175
  max,
4270
4176
  viewMonth,
4271
4177
  viewYear,
4272
- mode,
4273
- isMobile
4178
+ mode
4274
4179
  } = this.state;
4275
4180
  const {
4276
4181
  placeholder,
4277
4182
  monthFormat
4278
4183
  } = this.props;
4279
4184
  return /*#__PURE__*/jsxs("div", {
4280
- className: classNames({
4281
- 'p-a-1': !isMobile
4282
- }),
4185
+ className: "p-a-1",
4283
4186
  children: [mode === MODE.DAY && /*#__PURE__*/jsx(DayCalendar$1, {
4284
4187
  selectedDate,
4285
4188
  min,
@@ -4787,6 +4690,75 @@ function Display({
4787
4690
  });
4788
4691
  }
4789
4692
 
4693
+ const Drawer = ({
4694
+ children,
4695
+ className,
4696
+ footerContent,
4697
+ headerTitle,
4698
+ onClose,
4699
+ open,
4700
+ position
4701
+ }) => {
4702
+ logActionRequiredIf('Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.', !onClose);
4703
+ const {
4704
+ isMobile
4705
+ } = useLayout();
4706
+ return /*#__PURE__*/jsx(Dimmer$1, {
4707
+ open: open,
4708
+ onClose: onClose,
4709
+ children: /*#__PURE__*/jsx(SlidingPanel$1, {
4710
+ open: open,
4711
+ position: isMobile ? Position.BOTTOM : position,
4712
+ children: /*#__PURE__*/jsxs("div", {
4713
+ className: classNames('np-drawer', className),
4714
+ role: "dialog",
4715
+ children: [/*#__PURE__*/jsxs("div", {
4716
+ className: classNames('np-drawer-header', {
4717
+ 'np-drawer-header--withborder': headerTitle
4718
+ }),
4719
+ children: [headerTitle && /*#__PURE__*/jsx(Title, {
4720
+ type: Typography.TITLE_BODY,
4721
+ children: headerTitle
4722
+ }), /*#__PURE__*/jsx(CloseButton, {
4723
+ onClick: onClose
4724
+ })]
4725
+ }), children && /*#__PURE__*/jsx("div", {
4726
+ className: classNames('np-drawer-content'),
4727
+ children: children
4728
+ }), footerContent && /*#__PURE__*/jsx("div", {
4729
+ className: classNames('np-drawer-footer'),
4730
+ children: footerContent
4731
+ })]
4732
+ })
4733
+ })
4734
+ });
4735
+ };
4736
+ Drawer.propTypes = {
4737
+ /** The content to appear in the drawer body. */
4738
+ children: PropTypes.node,
4739
+ className: PropTypes.string,
4740
+ /** The content to appear in the drawer footer. */
4741
+ footerContent: PropTypes.node,
4742
+ /** The content to appear in the drawer header. */
4743
+ headerTitle: PropTypes.node,
4744
+ /** The action to perform on close click. */
4745
+ onClose: PropTypes.func,
4746
+ /** The status of Drawer either open or not. */
4747
+ open: PropTypes.bool,
4748
+ /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
4749
+ position: PropTypes.oneOf(['left', 'right', 'bottom'])
4750
+ };
4751
+ Drawer.defaultProps = {
4752
+ children: null,
4753
+ className: undefined,
4754
+ footerContent: null,
4755
+ headerTitle: null,
4756
+ onClose: null,
4757
+ open: false,
4758
+ position: Position.RIGHT
4759
+ };
4760
+ var Drawer$1 = Drawer;
4761
+
4790
4762
  const DropFade = ({
4791
4763
  children,
4792
4764
  show
@@ -5919,14 +5891,13 @@ const Modal = ({
5919
5891
  }) => {
5920
5892
  const checkSpecialClasses = classToCheck => className?.split(' ').includes(classToCheck);
5921
5893
  const {
5922
- isMobile,
5923
- isMedium: isTablet
5894
+ isMobile
5924
5895
  } = useLayout();
5925
5896
  // These should be replaced with props in breaking change.
5926
5897
  const isCompact = checkSpecialClasses('compact');
5927
5898
  const noDivider = checkSpecialClasses('no-divider');
5928
5899
  const contentReference = useRef(null);
5929
- return isMobile || isTablet ? /*#__PURE__*/jsx(Drawer$1, {
5900
+ return isMobile ? /*#__PURE__*/jsx(Drawer$1, {
5930
5901
  open: open,
5931
5902
  headerTitle: title,
5932
5903
  footerContent: footer,
@@ -6349,6 +6320,16 @@ const SearchInput = /*#__PURE__*/forwardRef(function SearchInput({
6349
6320
  });
6350
6321
  });
6351
6322
 
6323
+ function useMedia(query) {
6324
+ return useSyncExternalStore(onStoreChange => {
6325
+ const mediaQueryList = window.matchMedia(query);
6326
+ mediaQueryList.addEventListener('change', onStoreChange);
6327
+ return () => {
6328
+ mediaQueryList.removeEventListener('change', onStoreChange);
6329
+ };
6330
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
6331
+ }
6332
+
6352
6333
  function useScreenSize(size) {
6353
6334
  return useMedia(`(min-width: ${size}px)`);
6354
6335
  }
@@ -6609,7 +6590,7 @@ function Popover({
6609
6590
  }
6610
6591
 
6611
6592
  function searchableString(value) {
6612
- return value.trim().replace(/\s+/gu, ' ').toLowerCase();
6593
+ return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
6613
6594
  }
6614
6595
  function inferSearchableStrings(value) {
6615
6596
  if (typeof value === 'string') {