@xylabs/sdk-react 2.9.28 → 2.9.32

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.
Files changed (35) hide show
  1. package/dist/cjs5/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  2. package/dist/cjs5/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  3. package/dist/cjs5/index.js +17 -15
  4. package/dist/cjs5/index.js.map +1 -1
  5. package/dist/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  6. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js +13 -11
  7. package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js.map +1 -1
  8. package/dist/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  9. package/dist/esm2015/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  10. package/dist/esm2015/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  11. package/dist/esm2015/index.js +17 -15
  12. package/dist/esm2015/index.js.map +1 -1
  13. package/dist/esm2017/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  14. package/dist/esm2017/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  15. package/dist/esm2017/index.js +17 -15
  16. package/dist/esm2017/index.js.map +1 -1
  17. package/dist/esm5/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  18. package/dist/esm5/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  19. package/dist/esm5/index.js +17 -15
  20. package/dist/esm5/index.js.map +1 -1
  21. package/dist/hooks/useWebP.js +4 -4
  22. package/dist/hooks/useWebP.js.map +1 -1
  23. package/dist/node/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  24. package/dist/node/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  25. package/dist/node/index.js +17 -15
  26. package/dist/node/index.js.map +1 -1
  27. package/dist/node-esm/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
  28. package/dist/node-esm/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
  29. package/dist/node-esm/index.js +17 -15
  30. package/dist/node-esm/index.js.map +1 -1
  31. package/package.json +21 -21
  32. package/src/components/InvertableThemeProvider/InvertableTheme.tsx +2 -0
  33. package/src/components/InvertableThemeProvider/InvertableThemeProvider.tsx +20 -13
  34. package/src/components/InvertableThemeProvider/InvertableThemeProviderProps.ts +5 -0
  35. package/src/hooks/useWebP.tsx +4 -6
@@ -17,26 +17,28 @@ export const resolveThemeColors = (options) => {
17
17
  },
18
18
  });
19
19
  };
20
- export const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, }) => {
21
- var _a, _b;
22
- let internalDarkTheme = {};
23
- const contextInvertableTheme = useContext(InvertableThemeContext);
24
- const clonedOptions = cloneDeep((_a = options !== null && options !== void 0 ? options : contextInvertableTheme.options) !== null && _a !== void 0 ? _a : {});
25
- clonedOptions.palette = (_b = clonedOptions.palette) !== null && _b !== void 0 ? _b : {};
20
+ export const InvertableThemeProvider = ({ options, children, dark, resolve = false, scoped = false, invert = false, noResponsiveFonts, darkTheme, darkOptions, lightOptions, }) => {
21
+ var _a, _b, _c;
22
+ const parentContext = useContext(InvertableThemeContext);
23
+ const clonedOptions = cloneDeep((_a = options !== null && options !== void 0 ? options : parentContext.options) !== null && _a !== void 0 ? _a : {});
24
+ const clonedDarkOptions = cloneDeep((_b = darkOptions !== null && darkOptions !== void 0 ? darkOptions : darkTheme) !== null && _b !== void 0 ? _b : parentContext.darkOptions);
25
+ const clonedLightOptions = cloneDeep(lightOptions !== null && lightOptions !== void 0 ? lightOptions : parentContext.lightOptions);
26
+ clonedOptions.palette = (_c = clonedOptions.palette) !== null && _c !== void 0 ? _c : {};
26
27
  if (invert) {
27
28
  clonedOptions.palette.mode = clonedOptions.palette.mode === 'dark' ? 'light' : 'dark';
28
29
  }
29
30
  if (dark !== undefined) {
30
31
  clonedOptions.palette.mode = dark ? 'dark' : 'light';
31
32
  }
32
- if (clonedOptions.palette.mode === 'dark' && (darkTheme === null || darkTheme === void 0 ? void 0 : darkTheme.palette)) {
33
- internalDarkTheme = darkTheme;
34
- }
35
- let themeOptions = merge(clonedOptions, internalDarkTheme);
33
+ const modeOptions = clonedOptions.palette.mode === 'dark' ? clonedDarkOptions : clonedLightOptions;
34
+ let themeOptions = merge({}, clonedOptions, modeOptions);
36
35
  if (resolve) {
37
36
  themeOptions = resolveThemeColors(themeOptions);
38
37
  }
39
38
  const theme = noResponsiveFonts ? createTheme(themeOptions) : responsiveFontSizes(createTheme(themeOptions));
40
- return scoped ? (_jsx(ScopedCssBaseline, { children: _jsx(InvertableThemeContext.Provider, Object.assign({ value: { options: clonedOptions } }, { children: _jsx(ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0) }, void 0)) : (_jsx(InvertableThemeContext.Provider, Object.assign({ value: { options: clonedOptions } }, { children: _jsx(ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0));
39
+ const Provider = () => {
40
+ 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));
41
+ };
42
+ return scoped ? (_jsx(ScopedCssBaseline, { children: _jsx(Provider, {}, void 0) }, void 0)) : (_jsx(Provider, {}, void 0));
41
43
  };
42
44
  //# sourceMappingURL=InvertableThemeProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InvertableThemeProvider.js","sourceRoot":"","sources":["../../../src/components/InvertableThemeProvider/InvertableThemeProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAS,aAAa,EAAE,MAAM,eAAe,CAAA;AAC5F,OAAO,EAAE,WAAW,EAAgB,MAAM,sBAAsB,CAAA;AAChE,OAAO,SAAS,MAA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AAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;KACtF;IAED,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,aAAa,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;KACrD;IAED,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,KAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAA,EAAE;QAC/D,iBAAiB,GAAG,SAAS,CAAA;KAC9B;IAED,IAAI,YAAY,GAAG,KAAK,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAA;IAE1D,IAAI,OAAO,EAAE;QACX,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAA;KAChD;IAED,MAAM,KAAK,GAAU,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAA;IAEnH,OAAO,MAAM,CAAC,CAAC,CAAC,CACd,KAAC,iBAAiB,cAChB,KAAC,sBAAsB,CAAC,QAAQ,kBAAC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,gBAChE,KAAC,aAAa,kBAAC,KAAK,EAAE,KAAK,gBAAG,QAAQ,YAAiB,YACvB,WAChB,CACrB,CAAC,CAAC,CAAC,CACF,KAAC,sBAAsB,CAAC,QAAQ,kBAAC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,gBAChE,KAAC,aAAa,kBAAC,KAAK,EAAE,KAAK,gBAAG,QAAQ,YAAiB,YACvB,CACnC,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"InvertableThemeProvider.js","sourceRoot":"","sources":["../../../src/components/InvertableThemeProvider/InvertableThemeProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAS,aAAa,EAAE,MA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CAAC,CAAC,CACd,KAAC,iBAAiB,cAChB,KAAC,QAAQ,aAAG,WACM,CACrB,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,aAAG,CACb,CAAA;AACH,CAAC,CAAA"}
@@ -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,5 +1,7 @@
1
1
  import { ThemeOptions } from '@mui/material';
2
2
  interface InvertableTheme {
3
3
  options: ThemeOptions;
4
+ lightOptions?: ThemeOptions;
5
+ darkOptions?: ThemeOptions;
4
6
  }
5
7
  export type { InvertableTheme };
@@ -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 };
@@ -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
- let internalDarkTheme = {};
1683
- const contextInvertableTheme = useContext(InvertableThemeContext);
1684
- const clonedOptions = cloneDeep((_a = options !== null && options !== void 0 ? options : contextInvertableTheme.options) !== null && _a !== void 0 ? _a : {});
1685
- clonedOptions.palette = (_b = clonedOptions.palette) !== null && _b !== void 0 ? _b : {};
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
- if (clonedOptions.palette.mode === 'dark' && (darkTheme === null || darkTheme === void 0 ? void 0 : darkTheme.palette)) {
1693
- internalDarkTheme = darkTheme;
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
- return scoped ? (jsx(ScopedCssBaseline, { children: jsx(InvertableThemeContext.Provider, Object.assign({ value: { options: clonedOptions } }, { children: jsx(ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0) }, void 0)) : (jsx(InvertableThemeContext.Provider, Object.assign({ value: { options: clonedOptions } }, { children: jsx(ThemeProvider, Object.assign({ theme: theme }, { children: children }), void 0) }), void 0));
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
@@ -1877,13 +1879,13 @@ const useUserEvents = () => {
1877
1879
 
1878
1880
  let supportsWebP = undefined;
1879
1881
  const useWebP = (webp, alt) => {
1880
- const [img, setImg] = useState(supportsWebP === true ? webp : supportsWebP === false ? alt : undefined);
1882
+ const [img, setImg] = useState();
1881
1883
  useAsyncEffect((mounted) => __awaiter(void 0, void 0, void 0, function* () {
1882
1884
  if (supportsWebP === undefined) {
1883
1885
  supportsWebP = yield getSupportsWebP();
1884
- if (mounted()) {
1885
- setImg(supportsWebP ? webp : alt);
1886
- }
1886
+ }
1887
+ if (mounted()) {
1888
+ setImg(supportsWebP ? webp : alt);
1887
1889
  }
1888
1890
  }), [supportsWebP]);
1889
1891
  return img;