@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/cjs5/index.js
CHANGED
|
@@ -1687,27 +1687,29 @@ const resolveThemeColors = (options) => {
|
|
|
1687
1687
|
},
|
|
1688
1688
|
});
|
|
1689
1689
|
};
|
|
1690
|
-
const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, }) => {
|
|
1691
|
-
var _a, _b;
|
|
1692
|
-
|
|
1693
|
-
const
|
|
1694
|
-
const
|
|
1695
|
-
|
|
1690
|
+
const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, darkOptions, lightOptions, }) => {
|
|
1691
|
+
var _a, _b, _c;
|
|
1692
|
+
const parentContext = react.useContext(InvertableThemeContext);
|
|
1693
|
+
const clonedOptions = cloneDeep__default["default"]((_a = options !== null && options !== void 0 ? options : parentContext.options) !== null && _a !== void 0 ? _a : {});
|
|
1694
|
+
const clonedDarkOptions = cloneDeep__default["default"]((_b = darkOptions !== null && darkOptions !== void 0 ? darkOptions : darkTheme) !== null && _b !== void 0 ? _b : parentContext.darkOptions);
|
|
1695
|
+
const clonedLightOptions = cloneDeep__default["default"](lightOptions !== null && lightOptions !== void 0 ? lightOptions : parentContext.lightOptions);
|
|
1696
|
+
clonedOptions.palette = (_c = clonedOptions.palette) !== null && _c !== void 0 ? _c : {};
|
|
1696
1697
|
if (invert) {
|
|
1697
1698
|
clonedOptions.palette.mode = clonedOptions.palette.mode === 'dark' ? 'light' : 'dark';
|
|
1698
1699
|
}
|
|
1699
1700
|
if (dark !== undefined) {
|
|
1700
1701
|
clonedOptions.palette.mode = dark ? 'dark' : 'light';
|
|
1701
1702
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1705
|
-
let themeOptions = merge__default["default"](clonedOptions, internalDarkTheme);
|
|
1703
|
+
const modeOptions = clonedOptions.palette.mode === 'dark' ? clonedDarkOptions : clonedLightOptions;
|
|
1704
|
+
let themeOptions = merge__default["default"]({}, clonedOptions, modeOptions);
|
|
1706
1705
|
if (resolve) {
|
|
1707
1706
|
themeOptions = resolveThemeColors(themeOptions);
|
|
1708
1707
|
}
|
|
1709
1708
|
const theme = noResponsiveFonts ? styles$1.createTheme(themeOptions) : material.responsiveFontSizes(styles$1.createTheme(themeOptions));
|
|
1710
|
-
|
|
1709
|
+
const Provider = () => {
|
|
1710
|
+
return (jsxRuntime.jsx(InvertableThemeContext.Provider, Object.assign({ value: { darkOptions: clonedDarkOptions, lightOptions: clonedLightOptions, options: clonedOptions } }, { children: jsxRuntime.jsx(material.ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0));
|
|
1711
|
+
};
|
|
1712
|
+
return scoped ? (jsxRuntime.jsx(material.ScopedCssBaseline, { children: jsxRuntime.jsx(Provider, {}, void 0) }, void 0)) : (jsxRuntime.jsx(Provider, {}, void 0));
|
|
1711
1713
|
};
|
|
1712
1714
|
|
|
1713
1715
|
// The point of this component it to return to the top of the page on any router navigate
|
|
@@ -1803,6 +1805,20 @@ const useBreakpoint = () => {
|
|
|
1803
1805
|
}
|
|
1804
1806
|
};
|
|
1805
1807
|
|
|
1808
|
+
const useInterval = (callback, delay) => {
|
|
1809
|
+
const intervalRef = react.useRef(-1);
|
|
1810
|
+
const savedCallback = react.useRef(callback);
|
|
1811
|
+
react.useEffect(() => {
|
|
1812
|
+
savedCallback.current = callback;
|
|
1813
|
+
}, [callback]);
|
|
1814
|
+
react.useEffect(() => {
|
|
1815
|
+
const tick = () => savedCallback.current();
|
|
1816
|
+
intervalRef.current = window.setInterval(tick, delay);
|
|
1817
|
+
return () => window.clearInterval(intervalRef.current);
|
|
1818
|
+
}, [delay]);
|
|
1819
|
+
return intervalRef;
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1806
1822
|
const useLocalStorage = (key, defaultValue) => {
|
|
1807
1823
|
const [storedValue, setStoredValue] = react.useState(() => {
|
|
1808
1824
|
try {
|
|
@@ -1877,6 +1893,20 @@ const useSpacing = (value) => {
|
|
|
1877
1893
|
return theme.spacing(typeof value === 'string' ? parseInt(value) : value);
|
|
1878
1894
|
};
|
|
1879
1895
|
|
|
1896
|
+
const useTimeout = (callback, delay) => {
|
|
1897
|
+
const timeoutRef = react.useRef(-1);
|
|
1898
|
+
const savedCallback = react.useRef(callback);
|
|
1899
|
+
react.useEffect(() => {
|
|
1900
|
+
savedCallback.current = callback;
|
|
1901
|
+
}, [callback]);
|
|
1902
|
+
react.useEffect(() => {
|
|
1903
|
+
const tick = () => savedCallback.current();
|
|
1904
|
+
timeoutRef.current = window.setTimeout(tick, delay);
|
|
1905
|
+
return () => window.clearTimeout(timeoutRef.current);
|
|
1906
|
+
}, [delay]);
|
|
1907
|
+
return timeoutRef;
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1880
1910
|
const useUserEvents = () => {
|
|
1881
1911
|
const { userEvents } = react.useContext(UserEventsContext);
|
|
1882
1912
|
if (!userEvents) {
|
|
@@ -1887,13 +1917,13 @@ const useUserEvents = () => {
|
|
|
1887
1917
|
|
|
1888
1918
|
let supportsWebP = undefined;
|
|
1889
1919
|
const useWebP = (webp, alt) => {
|
|
1890
|
-
const [img, setImg] = react.useState(
|
|
1920
|
+
const [img, setImg] = react.useState();
|
|
1891
1921
|
useAsyncEffect((mounted) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1892
1922
|
if (supportsWebP === undefined) {
|
|
1893
1923
|
supportsWebP = yield getSupportsWebP();
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1924
|
+
}
|
|
1925
|
+
if (mounted()) {
|
|
1926
|
+
setImg(supportsWebP ? webp : alt);
|
|
1897
1927
|
}
|
|
1898
1928
|
}), [supportsWebP]);
|
|
1899
1929
|
return img;
|
|
@@ -2343,10 +2373,12 @@ exports.setSessionStorageObject = setSessionStorageObject;
|
|
|
2343
2373
|
exports.useAsyncEffect = useAsyncEffect;
|
|
2344
2374
|
exports.useBreakpoint = useBreakpoint;
|
|
2345
2375
|
exports.useCookieConsent = useCookieConsent;
|
|
2376
|
+
exports.useInterval = useInterval;
|
|
2346
2377
|
exports.useLocalStorage = useLocalStorage;
|
|
2347
2378
|
exports.useMounted = useMounted;
|
|
2348
2379
|
exports.useNavigateToEthAddress = useNavigateToEthAddress;
|
|
2349
2380
|
exports.useSpacing = useSpacing;
|
|
2381
|
+
exports.useTimeout = useTimeout;
|
|
2350
2382
|
exports.useUserEvents = useUserEvents;
|
|
2351
2383
|
exports.useWebP = useWebP;
|
|
2352
2384
|
exports.useWindowSize = useWindowSize;
|