@xylabs/sdk-react 2.9.29 → 2.9.33
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/dist/cjs5/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/cjs5/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/cjs5/hooks/index.d.ts +2 -0
- package/dist/cjs5/hooks/useInterval.d.ts +2 -0
- package/dist/cjs5/hooks/useTimeout.d.ts +2 -0
- package/dist/cjs5/index.js +47 -15
- package/dist/cjs5/index.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js +13 -11
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/esm2015/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/esm2015/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/esm2015/hooks/index.d.ts +2 -0
- package/dist/esm2015/hooks/useInterval.d.ts +2 -0
- package/dist/esm2015/hooks/useTimeout.d.ts +2 -0
- package/dist/esm2015/index.js +46 -16
- package/dist/esm2015/index.js.map +1 -1
- package/dist/esm2017/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/esm2017/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/esm2017/hooks/index.d.ts +2 -0
- package/dist/esm2017/hooks/useInterval.d.ts +2 -0
- package/dist/esm2017/hooks/useTimeout.d.ts +2 -0
- package/dist/esm2017/index.js +46 -16
- package/dist/esm2017/index.js.map +1 -1
- package/dist/esm5/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/esm5/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/esm5/hooks/index.d.ts +2 -0
- package/dist/esm5/hooks/useInterval.d.ts +2 -0
- package/dist/esm5/hooks/useTimeout.d.ts +2 -0
- package/dist/esm5/index.js +46 -16
- package/dist/esm5/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useInterval.d.ts +2 -0
- package/dist/hooks/useInterval.js +15 -0
- package/dist/hooks/useInterval.js.map +1 -0
- package/dist/hooks/useTimeout.d.ts +2 -0
- package/dist/hooks/useTimeout.js +15 -0
- package/dist/hooks/useTimeout.js.map +1 -0
- package/dist/hooks/useWebP.js +4 -4
- package/dist/hooks/useWebP.js.map +1 -1
- package/dist/node/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/node/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/node/hooks/index.d.ts +2 -0
- package/dist/node/hooks/useInterval.d.ts +2 -0
- package/dist/node/hooks/useTimeout.d.ts +2 -0
- package/dist/node/index.js +47 -15
- package/dist/node/index.js.map +1 -1
- package/dist/node-esm/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/node-esm/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/node-esm/hooks/index.d.ts +2 -0
- package/dist/node-esm/hooks/useInterval.d.ts +2 -0
- package/dist/node-esm/hooks/useTimeout.d.ts +2 -0
- package/dist/node-esm/index.js +46 -16
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +15 -15
- package/src/components/InvertableThemeProvider/InvertableTheme.tsx +2 -0
- package/src/components/InvertableThemeProvider/InvertableThemeProvider.tsx +20 -13
- package/src/components/InvertableThemeProvider/InvertableThemeProviderProps.ts +5 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useInterval.ts +19 -0
- package/src/hooks/useTimeout.ts +19 -0
- package/src/hooks/useWebP.tsx +4 -6
|
@@ -5,7 +5,12 @@ interface InvertableThemeProviderProps {
|
|
|
5
5
|
invert?: boolean;
|
|
6
6
|
noResponsiveFonts?: boolean;
|
|
7
7
|
options?: ThemeOptions;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use darkOptions instead
|
|
10
|
+
*/
|
|
8
11
|
darkTheme?: ThemeOptions;
|
|
12
|
+
darkOptions?: ThemeOptions;
|
|
13
|
+
lightOptions?: ThemeOptions;
|
|
9
14
|
resolve?: boolean;
|
|
10
15
|
}
|
|
11
16
|
export type { InvertableThemeProviderProps };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './useBreakpoint';
|
|
2
|
+
export * from './useInterval';
|
|
2
3
|
export * from './useLocalStorage';
|
|
3
4
|
export * from './useMediaQuery';
|
|
4
5
|
export * from './useMounted';
|
|
5
6
|
export * from './useNavigateToEthAddress';
|
|
6
7
|
export * from './useSpacing';
|
|
8
|
+
export * from './useTimeout';
|
|
7
9
|
export * from './useUserEvents';
|
|
8
10
|
export * from './useWebP';
|
|
9
11
|
export * from './useWindowSize';
|
package/dist/esm2017/index.js
CHANGED
|
@@ -1677,27 +1677,29 @@ const resolveThemeColors = (options) => {
|
|
|
1677
1677
|
},
|
|
1678
1678
|
});
|
|
1679
1679
|
};
|
|
1680
|
-
const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, }) => {
|
|
1681
|
-
var _a, _b;
|
|
1682
|
-
|
|
1683
|
-
const
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1680
|
+
const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, darkOptions, lightOptions, }) => {
|
|
1681
|
+
var _a, _b, _c;
|
|
1682
|
+
const parentContext = useContext(InvertableThemeContext);
|
|
1683
|
+
const clonedOptions = cloneDeep((_a = options !== null && options !== void 0 ? options : parentContext.options) !== null && _a !== void 0 ? _a : {});
|
|
1684
|
+
const clonedDarkOptions = cloneDeep((_b = darkOptions !== null && darkOptions !== void 0 ? darkOptions : darkTheme) !== null && _b !== void 0 ? _b : parentContext.darkOptions);
|
|
1685
|
+
const clonedLightOptions = cloneDeep(lightOptions !== null && lightOptions !== void 0 ? lightOptions : parentContext.lightOptions);
|
|
1686
|
+
clonedOptions.palette = (_c = clonedOptions.palette) !== null && _c !== void 0 ? _c : {};
|
|
1686
1687
|
if (invert) {
|
|
1687
1688
|
clonedOptions.palette.mode = clonedOptions.palette.mode === 'dark' ? 'light' : 'dark';
|
|
1688
1689
|
}
|
|
1689
1690
|
if (dark !== undefined) {
|
|
1690
1691
|
clonedOptions.palette.mode = dark ? 'dark' : 'light';
|
|
1691
1692
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
}
|
|
1695
|
-
let themeOptions = merge(clonedOptions, internalDarkTheme);
|
|
1693
|
+
const modeOptions = clonedOptions.palette.mode === 'dark' ? clonedDarkOptions : clonedLightOptions;
|
|
1694
|
+
let themeOptions = merge({}, clonedOptions, modeOptions);
|
|
1696
1695
|
if (resolve) {
|
|
1697
1696
|
themeOptions = resolveThemeColors(themeOptions);
|
|
1698
1697
|
}
|
|
1699
1698
|
const theme = noResponsiveFonts ? createTheme(themeOptions) : responsiveFontSizes(createTheme(themeOptions));
|
|
1700
|
-
|
|
1699
|
+
const Provider = () => {
|
|
1700
|
+
return (jsx(InvertableThemeContext.Provider, Object.assign({ value: { darkOptions: clonedDarkOptions, lightOptions: clonedLightOptions, options: clonedOptions } }, { children: jsx(ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0));
|
|
1701
|
+
};
|
|
1702
|
+
return scoped ? (jsx(ScopedCssBaseline, { children: jsx(Provider, {}, void 0) }, void 0)) : (jsx(Provider, {}, void 0));
|
|
1701
1703
|
};
|
|
1702
1704
|
|
|
1703
1705
|
// The point of this component it to return to the top of the page on any router navigate
|
|
@@ -1793,6 +1795,20 @@ const useBreakpoint = () => {
|
|
|
1793
1795
|
}
|
|
1794
1796
|
};
|
|
1795
1797
|
|
|
1798
|
+
const useInterval = (callback, delay) => {
|
|
1799
|
+
const intervalRef = useRef(-1);
|
|
1800
|
+
const savedCallback = useRef(callback);
|
|
1801
|
+
useEffect(() => {
|
|
1802
|
+
savedCallback.current = callback;
|
|
1803
|
+
}, [callback]);
|
|
1804
|
+
useEffect(() => {
|
|
1805
|
+
const tick = () => savedCallback.current();
|
|
1806
|
+
intervalRef.current = window.setInterval(tick, delay);
|
|
1807
|
+
return () => window.clearInterval(intervalRef.current);
|
|
1808
|
+
}, [delay]);
|
|
1809
|
+
return intervalRef;
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1796
1812
|
const useLocalStorage = (key, defaultValue) => {
|
|
1797
1813
|
const [storedValue, setStoredValue] = useState(() => {
|
|
1798
1814
|
try {
|
|
@@ -1867,6 +1883,20 @@ const useSpacing = (value) => {
|
|
|
1867
1883
|
return theme.spacing(typeof value === 'string' ? parseInt(value) : value);
|
|
1868
1884
|
};
|
|
1869
1885
|
|
|
1886
|
+
const useTimeout = (callback, delay) => {
|
|
1887
|
+
const timeoutRef = useRef(-1);
|
|
1888
|
+
const savedCallback = useRef(callback);
|
|
1889
|
+
useEffect(() => {
|
|
1890
|
+
savedCallback.current = callback;
|
|
1891
|
+
}, [callback]);
|
|
1892
|
+
useEffect(() => {
|
|
1893
|
+
const tick = () => savedCallback.current();
|
|
1894
|
+
timeoutRef.current = window.setTimeout(tick, delay);
|
|
1895
|
+
return () => window.clearTimeout(timeoutRef.current);
|
|
1896
|
+
}, [delay]);
|
|
1897
|
+
return timeoutRef;
|
|
1898
|
+
};
|
|
1899
|
+
|
|
1870
1900
|
const useUserEvents = () => {
|
|
1871
1901
|
const { userEvents } = useContext(UserEventsContext);
|
|
1872
1902
|
if (!userEvents) {
|
|
@@ -1877,13 +1907,13 @@ const useUserEvents = () => {
|
|
|
1877
1907
|
|
|
1878
1908
|
let supportsWebP = undefined;
|
|
1879
1909
|
const useWebP = (webp, alt) => {
|
|
1880
|
-
const [img, setImg] = useState(
|
|
1910
|
+
const [img, setImg] = useState();
|
|
1881
1911
|
useAsyncEffect((mounted) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1882
1912
|
if (supportsWebP === undefined) {
|
|
1883
1913
|
supportsWebP = yield getSupportsWebP();
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1914
|
+
}
|
|
1915
|
+
if (mounted()) {
|
|
1916
|
+
setImg(supportsWebP ? webp : alt);
|
|
1887
1917
|
}
|
|
1888
1918
|
}), [supportsWebP]);
|
|
1889
1919
|
return img;
|
|
@@ -2247,5 +2277,5 @@ const TokenAmount = (_a) => {
|
|
|
2247
2277
|
return (jsx(ButtonEx, Object.assign({ style: Object.assign({ backgroundColor: statusColor }, style), variant: "outlined", onClick: onButtonClick }, props, { children: jsxs(FlexRow, Object.assign({ justifyContent: "space-between", width: "100%", busy: amount === undefined, busySize: 16 }, { children: [jsxs(FlexRow, { children: [logo ? jsx("img", { src: img, height: 24 }, void 0) : null, label ? (jsx(Typography, Object.assign({ marginRight: 1, marginLeft: logo ? 1 : 0, noWrap: true, fontFamily: textFontFamily, variant: "caption" }, { children: label }), void 0)) : null] }, void 0), jsx(Typography, Object.assign({ color: textColor, noWrap: true, fontFamily: textFontFamily, variant: "body1", style: { textTransform: 'none' } }, { children: amountString }), void 0)] }), void 0) }), void 0));
|
|
2248
2278
|
};
|
|
2249
2279
|
|
|
2250
|
-
export { ActionStatusType, AppBarEx, Background, BasePage, BreadcrumbsEx, BusyBox, ButtonEx, ContactPointOption, CookieConsent, CookieConsentBody, CookieConsentContext, CookieConsentLoader, CoverProgress, DebugUserEventsContext, DripCustomEvent, DripStandardEvents, ErrorDialog, EthAccount, EthersContext, EthersLoader, Experiment, Experiments, ExperimentsDebugger, FacebookCustomEvent, FacebookStandardEvents, Fbq, FlexCol, FlexGrowCol, FlexGrowRow, FlexRow, GoogleBaseEvent, GoogleCustomEvent, GoogleStandardEvents, GoogleUserEventHandler, Gtag, Gtm, HoverScale, Identicon, InvertableThemeProvider, ItemAvailability, LinkToEx, MapCategoryType, MenuEx, MessageDialog, NetworkSettingsContext, NetworkSettingsLoader, NumberStatus, PixelDebugger, PixelDebuggerProvider, PixelDebuggerToggle, Portal, QuickTipButton, Rdt, RedditCustomEvent, RedditStandardEvents, RedirectWithQuery, Referrer, RichResult, ScrollToTop, ScrollToTopButton, SelectEx, SnapTr, SnapchatStandardEvents, TiktokCustomEvent, TiktokStandardEvents, TokenAmount, Ttq, UserEventsContext, UserEventsLoader, XyBaseEvent, XyCustomEvent, XyUserEventHandler, XyoUserEventHandler, enableProfileLogging, getApiStage, getLocalStorageObject, getSessionStorageObject, isLocalhost, profileBlock, profileResults, resolveThemeColors, setLocalStorageObject, setSessionStorageObject, useAsyncEffect, useBreakpoint, useCookieConsent, useLocalStorage, useMounted, useNavigateToEthAddress, useSpacing, useUserEvents, useWebP, useWindowSize };
|
|
2280
|
+
export { ActionStatusType, AppBarEx, Background, BasePage, BreadcrumbsEx, BusyBox, ButtonEx, ContactPointOption, CookieConsent, CookieConsentBody, CookieConsentContext, CookieConsentLoader, CoverProgress, DebugUserEventsContext, DripCustomEvent, DripStandardEvents, ErrorDialog, EthAccount, EthersContext, EthersLoader, Experiment, Experiments, ExperimentsDebugger, FacebookCustomEvent, FacebookStandardEvents, Fbq, FlexCol, FlexGrowCol, FlexGrowRow, FlexRow, GoogleBaseEvent, GoogleCustomEvent, GoogleStandardEvents, GoogleUserEventHandler, Gtag, Gtm, HoverScale, Identicon, InvertableThemeProvider, ItemAvailability, LinkToEx, MapCategoryType, MenuEx, MessageDialog, NetworkSettingsContext, NetworkSettingsLoader, NumberStatus, PixelDebugger, PixelDebuggerProvider, PixelDebuggerToggle, Portal, QuickTipButton, Rdt, RedditCustomEvent, RedditStandardEvents, RedirectWithQuery, Referrer, RichResult, ScrollToTop, ScrollToTopButton, SelectEx, SnapTr, SnapchatStandardEvents, TiktokCustomEvent, TiktokStandardEvents, TokenAmount, Ttq, UserEventsContext, UserEventsLoader, XyBaseEvent, XyCustomEvent, XyUserEventHandler, XyoUserEventHandler, enableProfileLogging, getApiStage, getLocalStorageObject, getSessionStorageObject, isLocalhost, profileBlock, profileResults, resolveThemeColors, setLocalStorageObject, setSessionStorageObject, useAsyncEffect, useBreakpoint, useCookieConsent, useInterval, useLocalStorage, useMounted, useNavigateToEthAddress, useSpacing, useTimeout, useUserEvents, useWebP, useWindowSize };
|
|
2251
2281
|
//# sourceMappingURL=index.js.map
|