@transferwise/components 45.28.1 → 46.0.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.esm.js +45 -61
- package/build/index.esm.js.map +1 -1
- package/build/index.js +45 -60
- package/build/index.js.map +1 -1
- package/build/types/common/hooks/useLayout/useLayout.d.ts +9 -6
- package/build/types/common/hooks/useLayout/useLayout.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/hooks/useLayout/useLayout.ts +21 -49
- package/src/common/responsivePanel/ResponsivePanel.spec.js +3 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +1 -19
- package/src/dateLookup/dateHeader/DateHeader.spec.js +2 -0
- package/src/drawer/Drawer.rtl.spec.js +3 -1
- package/src/drawer/Drawer.spec.js +2 -0
- package/src/index.ts +1 -0
- package/src/info/Info.spec.js +7 -11
- package/src/modal/Modal.rtl.spec.js +3 -1
- package/src/modal/Modal.spec.js +2 -0
- package/src/modal/Modal.tsx +2 -2
- package/src/moneyInput/MoneyInput.js +18 -8
- package/src/ssr.spec.js +1 -0
- package/src/uploadInput/UploadInput.spec.tsx +3 -1
package/build/index.esm.js
CHANGED
|
@@ -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
|
|
1852
|
-
const
|
|
1853
|
-
const
|
|
1854
|
-
|
|
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:
|
|
1882
|
-
isExtraSmall:
|
|
1883
|
-
isSmall:
|
|
1884
|
-
isMedium:
|
|
1885
|
-
isLarge:
|
|
1886
|
-
isExtraLarge:
|
|
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
|
-
|
|
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
|
|
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,
|
|
@@ -8036,20 +8014,26 @@ class MoneyInput extends Component {
|
|
|
8036
8014
|
maxLengthOverride
|
|
8037
8015
|
} = this.props;
|
|
8038
8016
|
const selectOptions = this.getSelectOptions();
|
|
8039
|
-
const
|
|
8017
|
+
const getFirstSelectItem = () => {
|
|
8040
8018
|
if (selectOptions.length !== 0) {
|
|
8041
|
-
const
|
|
8042
|
-
if (
|
|
8043
|
-
return
|
|
8019
|
+
const firstItem = selectOptions[0];
|
|
8020
|
+
if (firstItem.type === 'option') {
|
|
8021
|
+
return {
|
|
8022
|
+
hasOneCurrency: selectOptions.length === 1,
|
|
8023
|
+
currency: firstItem.value.currency
|
|
8024
|
+
};
|
|
8044
8025
|
}
|
|
8045
|
-
if (
|
|
8046
|
-
return
|
|
8026
|
+
if (firstItem.type === 'group') {
|
|
8027
|
+
return {
|
|
8028
|
+
hasOneCurrency: firstItem.options.length === 1,
|
|
8029
|
+
currency: firstItem.options[0].value.currency
|
|
8030
|
+
};
|
|
8047
8031
|
}
|
|
8048
8032
|
}
|
|
8049
8033
|
return null;
|
|
8050
8034
|
};
|
|
8051
|
-
const
|
|
8052
|
-
const isFixedCurrency = !this.state.searchQuery && (
|
|
8035
|
+
const firstSelectItem = getFirstSelectItem();
|
|
8036
|
+
const isFixedCurrency = !this.state.searchQuery && (firstSelectItem?.hasOneCurrency && firstSelectItem?.currency === selectedCurrency.currency || !onCurrencyChange);
|
|
8053
8037
|
const disabled = !this.props.onAmountChange;
|
|
8054
8038
|
return /*#__PURE__*/jsxs("div", {
|
|
8055
8039
|
className: classNames(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
@@ -15625,5 +15609,5 @@ const translations = {
|
|
|
15625
15609
|
'zh-HK': zhHK
|
|
15626
15610
|
};
|
|
15627
15611
|
|
|
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 };
|
|
15612
|
+
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
15613
|
//# sourceMappingURL=index.esm.js.map
|