@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.js
CHANGED
|
@@ -1881,43 +1881,36 @@ const useHasIntersected = ({
|
|
|
1881
1881
|
return [hasIntersected];
|
|
1882
1882
|
};
|
|
1883
1883
|
|
|
1884
|
+
function useMedia(query) {
|
|
1885
|
+
return shim.useSyncExternalStore(onStoreChange => {
|
|
1886
|
+
const mediaQueryList = window.matchMedia(query);
|
|
1887
|
+
mediaQueryList.addEventListener('change', onStoreChange);
|
|
1888
|
+
return () => {
|
|
1889
|
+
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
1890
|
+
};
|
|
1891
|
+
}, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
function useScreenSize(size) {
|
|
1895
|
+
return useMedia(`(min-width: ${size}px)`);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* @deprecated Prefer `useScreenSize` instead.
|
|
1900
|
+
*/
|
|
1884
1901
|
const useLayout = () => {
|
|
1885
|
-
const
|
|
1886
|
-
const
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
React.useEffect(() => {
|
|
1891
|
-
if (!clientWidth) {
|
|
1892
|
-
return;
|
|
1893
|
-
}
|
|
1894
|
-
if (clientWidth <= exports.Breakpoint.EXTRA_SMALL) {
|
|
1895
|
-
setBreakpoint(exports.Breakpoint.EXTRA_SMALL);
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
if (exports.Breakpoint.EXTRA_SMALL < clientWidth && clientWidth <= exports.Breakpoint.SMALL) {
|
|
1899
|
-
setBreakpoint(exports.Breakpoint.SMALL);
|
|
1900
|
-
return;
|
|
1901
|
-
}
|
|
1902
|
-
if (exports.Breakpoint.SMALL < clientWidth && clientWidth <= exports.Breakpoint.MEDIUM) {
|
|
1903
|
-
setBreakpoint(exports.Breakpoint.MEDIUM);
|
|
1904
|
-
return;
|
|
1905
|
-
}
|
|
1906
|
-
if (exports.Breakpoint.MEDIUM < clientWidth && clientWidth <= exports.Breakpoint.LARGE) {
|
|
1907
|
-
setBreakpoint(exports.Breakpoint.LARGE);
|
|
1908
|
-
return;
|
|
1909
|
-
}
|
|
1910
|
-
if (exports.Breakpoint.LARGE < clientWidth) {
|
|
1911
|
-
setBreakpoint(exports.Breakpoint.EXTRA_LARGE);
|
|
1912
|
-
}
|
|
1913
|
-
}, [clientWidth]);
|
|
1902
|
+
const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
|
|
1903
|
+
const screenSm = useScreenSize(exports.Breakpoint.SMALL);
|
|
1904
|
+
const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
|
|
1905
|
+
const screenLg = useScreenSize(exports.Breakpoint.LARGE);
|
|
1906
|
+
const screenXl = useScreenSize(exports.Breakpoint.EXTRA_LARGE);
|
|
1914
1907
|
return {
|
|
1915
|
-
isMobile:
|
|
1916
|
-
isExtraSmall:
|
|
1917
|
-
isSmall:
|
|
1918
|
-
isMedium:
|
|
1919
|
-
isLarge:
|
|
1920
|
-
isExtraLarge:
|
|
1908
|
+
isMobile: screenSm != null ? !screenSm : undefined,
|
|
1909
|
+
isExtraSmall: screenXs,
|
|
1910
|
+
isSmall: screenSm,
|
|
1911
|
+
isMedium: screenMd,
|
|
1912
|
+
isLarge: screenLg,
|
|
1913
|
+
isExtraLarge: screenXl
|
|
1921
1914
|
};
|
|
1922
1915
|
};
|
|
1923
1916
|
|
|
@@ -2042,16 +2035,6 @@ Drawer.defaultProps = {
|
|
|
2042
2035
|
};
|
|
2043
2036
|
var Drawer$1 = Drawer;
|
|
2044
2037
|
|
|
2045
|
-
function useMedia(query) {
|
|
2046
|
-
return shim.useSyncExternalStore(onStoreChange => {
|
|
2047
|
-
const mediaQueryList = window.matchMedia(query);
|
|
2048
|
-
mediaQueryList.addEventListener('change', onStoreChange);
|
|
2049
|
-
return () => {
|
|
2050
|
-
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
2051
|
-
};
|
|
2052
|
-
}, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
2038
|
const INITIAL_Y_POSITION = 0;
|
|
2056
2039
|
const CONTENT_SCROLL_THRESHOLD = 1;
|
|
2057
2040
|
const MOVE_OFFSET_THRESHOLD = 50;
|
|
@@ -6060,14 +6043,13 @@ const Modal = ({
|
|
|
6060
6043
|
}) => {
|
|
6061
6044
|
const checkSpecialClasses = classToCheck => className?.split(' ').includes(classToCheck);
|
|
6062
6045
|
const {
|
|
6063
|
-
|
|
6064
|
-
isMedium: isTablet
|
|
6046
|
+
isMedium
|
|
6065
6047
|
} = useLayout();
|
|
6066
6048
|
// These should be replaced with props in breaking change.
|
|
6067
6049
|
const isCompact = checkSpecialClasses('compact');
|
|
6068
6050
|
const noDivider = checkSpecialClasses('no-divider');
|
|
6069
6051
|
const contentReference = React.useRef(null);
|
|
6070
|
-
return
|
|
6052
|
+
return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
|
|
6071
6053
|
open: open,
|
|
6072
6054
|
headerTitle: title,
|
|
6073
6055
|
footerContent: footer,
|
|
@@ -6501,10 +6483,6 @@ const SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput({
|
|
|
6501
6483
|
});
|
|
6502
6484
|
});
|
|
6503
6485
|
|
|
6504
|
-
function useScreenSize(size) {
|
|
6505
|
-
return useMedia(`(min-width: ${size}px)`);
|
|
6506
|
-
}
|
|
6507
|
-
|
|
6508
6486
|
const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function PolymorphicWithOverrides({
|
|
6509
6487
|
__overrides: {
|
|
6510
6488
|
as: Element,
|
|
@@ -8070,20 +8048,26 @@ class MoneyInput extends React.Component {
|
|
|
8070
8048
|
maxLengthOverride
|
|
8071
8049
|
} = this.props;
|
|
8072
8050
|
const selectOptions = this.getSelectOptions();
|
|
8073
|
-
const
|
|
8051
|
+
const getFirstSelectItem = () => {
|
|
8074
8052
|
if (selectOptions.length !== 0) {
|
|
8075
|
-
const
|
|
8076
|
-
if (
|
|
8077
|
-
return
|
|
8053
|
+
const firstItem = selectOptions[0];
|
|
8054
|
+
if (firstItem.type === 'option') {
|
|
8055
|
+
return {
|
|
8056
|
+
hasOneCurrency: selectOptions.length === 1,
|
|
8057
|
+
currency: firstItem.value.currency
|
|
8058
|
+
};
|
|
8078
8059
|
}
|
|
8079
|
-
if (
|
|
8080
|
-
return
|
|
8060
|
+
if (firstItem.type === 'group') {
|
|
8061
|
+
return {
|
|
8062
|
+
hasOneCurrency: firstItem.options.length === 1,
|
|
8063
|
+
currency: firstItem.options[0].value.currency
|
|
8064
|
+
};
|
|
8081
8065
|
}
|
|
8082
8066
|
}
|
|
8083
8067
|
return null;
|
|
8084
8068
|
};
|
|
8085
|
-
const
|
|
8086
|
-
const isFixedCurrency = !this.state.searchQuery && (
|
|
8069
|
+
const firstSelectItem = getFirstSelectItem();
|
|
8070
|
+
const isFixedCurrency = !this.state.searchQuery && (firstSelectItem?.hasOneCurrency && firstSelectItem?.currency === selectedCurrency.currency || !onCurrencyChange);
|
|
8087
8071
|
const disabled = !this.props.onAmountChange;
|
|
8088
8072
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
8089
8073
|
className: classNames__default.default(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
@@ -15762,5 +15746,6 @@ exports.isServerSide = isServerSide;
|
|
|
15762
15746
|
exports.translations = translations;
|
|
15763
15747
|
exports.useDirection = useDirection;
|
|
15764
15748
|
exports.useLayout = useLayout;
|
|
15749
|
+
exports.useScreenSize = useScreenSize;
|
|
15765
15750
|
exports.useSnackbar = useSnackbar;
|
|
15766
15751
|
//# sourceMappingURL=index.js.map
|