@transferwise/components 45.28.1 → 46.0.0

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.
@@ -1847,43 +1847,36 @@ const useHasIntersected = ({
1847
1847
  return [hasIntersected];
1848
1848
  };
1849
1849
 
1850
+ function useMedia(query) {
1851
+ return useSyncExternalStore(onStoreChange => {
1852
+ const mediaQueryList = window.matchMedia(query);
1853
+ mediaQueryList.addEventListener('change', onStoreChange);
1854
+ return () => {
1855
+ mediaQueryList.removeEventListener('change', onStoreChange);
1856
+ };
1857
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
1858
+ }
1859
+
1860
+ function useScreenSize(size) {
1861
+ return useMedia(`(min-width: ${size}px)`);
1862
+ }
1863
+
1864
+ /**
1865
+ * @deprecated Prefer `useScreenSize` instead.
1866
+ */
1850
1867
  const useLayout = () => {
1851
- const windowReference = typeof window === 'undefined' ? undefined : window;
1852
- const [breakpoint, setBreakpoint] = useState();
1853
- const [clientWidth] = useClientWidth({
1854
- ref: windowReference
1855
- });
1856
- useEffect(() => {
1857
- if (!clientWidth) {
1858
- return;
1859
- }
1860
- if (clientWidth <= Breakpoint.EXTRA_SMALL) {
1861
- setBreakpoint(Breakpoint.EXTRA_SMALL);
1862
- return;
1863
- }
1864
- if (Breakpoint.EXTRA_SMALL < clientWidth && clientWidth <= Breakpoint.SMALL) {
1865
- setBreakpoint(Breakpoint.SMALL);
1866
- return;
1867
- }
1868
- if (Breakpoint.SMALL < clientWidth && clientWidth <= Breakpoint.MEDIUM) {
1869
- setBreakpoint(Breakpoint.MEDIUM);
1870
- return;
1871
- }
1872
- if (Breakpoint.MEDIUM < clientWidth && clientWidth <= Breakpoint.LARGE) {
1873
- setBreakpoint(Breakpoint.LARGE);
1874
- return;
1875
- }
1876
- if (Breakpoint.LARGE < clientWidth) {
1877
- setBreakpoint(Breakpoint.EXTRA_LARGE);
1878
- }
1879
- }, [clientWidth]);
1868
+ const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
1869
+ const screenSm = useScreenSize(Breakpoint.SMALL);
1870
+ const screenMd = useScreenSize(Breakpoint.MEDIUM);
1871
+ const screenLg = useScreenSize(Breakpoint.LARGE);
1872
+ const screenXl = useScreenSize(Breakpoint.EXTRA_LARGE);
1880
1873
  return {
1881
- isMobile: !!breakpoint && [Breakpoint.EXTRA_SMALL, Breakpoint.SMALL].includes(breakpoint),
1882
- isExtraSmall: breakpoint === Breakpoint.EXTRA_SMALL,
1883
- isSmall: breakpoint === Breakpoint.SMALL,
1884
- isMedium: breakpoint === Breakpoint.MEDIUM,
1885
- isLarge: breakpoint === Breakpoint.LARGE,
1886
- isExtraLarge: breakpoint === Breakpoint.EXTRA_LARGE
1874
+ isMobile: screenSm != null ? !screenSm : undefined,
1875
+ isExtraSmall: screenXs,
1876
+ isSmall: screenSm,
1877
+ isMedium: screenMd,
1878
+ isLarge: screenLg,
1879
+ isExtraLarge: screenXl
1887
1880
  };
1888
1881
  };
1889
1882
 
@@ -2008,16 +2001,6 @@ Drawer.defaultProps = {
2008
2001
  };
2009
2002
  var Drawer$1 = Drawer;
2010
2003
 
2011
- function useMedia(query) {
2012
- return useSyncExternalStore(onStoreChange => {
2013
- const mediaQueryList = window.matchMedia(query);
2014
- mediaQueryList.addEventListener('change', onStoreChange);
2015
- return () => {
2016
- mediaQueryList.removeEventListener('change', onStoreChange);
2017
- };
2018
- }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
2019
- }
2020
-
2021
2004
  const INITIAL_Y_POSITION = 0;
2022
2005
  const CONTENT_SCROLL_THRESHOLD = 1;
2023
2006
  const MOVE_OFFSET_THRESHOLD = 50;
@@ -6026,14 +6009,13 @@ const Modal = ({
6026
6009
  }) => {
6027
6010
  const checkSpecialClasses = classToCheck => className?.split(' ').includes(classToCheck);
6028
6011
  const {
6029
- isMobile,
6030
- isMedium: isTablet
6012
+ isMedium
6031
6013
  } = useLayout();
6032
6014
  // These should be replaced with props in breaking change.
6033
6015
  const isCompact = checkSpecialClasses('compact');
6034
6016
  const noDivider = checkSpecialClasses('no-divider');
6035
6017
  const contentReference = useRef(null);
6036
- return isMobile || isTablet ? /*#__PURE__*/jsx(Drawer$1, {
6018
+ return !isMedium ? /*#__PURE__*/jsx(Drawer$1, {
6037
6019
  open: open,
6038
6020
  headerTitle: title,
6039
6021
  footerContent: footer,
@@ -6467,10 +6449,6 @@ const SearchInput = /*#__PURE__*/forwardRef(function SearchInput({
6467
6449
  });
6468
6450
  });
6469
6451
 
6470
- function useScreenSize(size) {
6471
- return useMedia(`(min-width: ${size}px)`);
6472
- }
6473
-
6474
6452
  const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWithOverrides({
6475
6453
  __overrides: {
6476
6454
  as: Element,
@@ -15625,5 +15603,5 @@ const translations = {
15625
15603
  'zh-HK': zhHK
15626
15604
  };
15627
15605
 
15628
- export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron$1 as Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat$1 as InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput$1 as PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useSnackbar };
15606
+ export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron$1 as Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat$1 as InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput$1 as PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15629
15607
  //# sourceMappingURL=index.esm.js.map