@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.
- package/dist/cjs5/components/InvertableThemeProvider/InvertableTheme.d.ts +2 -0
- package/dist/cjs5/components/InvertableThemeProvider/InvertableThemeProviderProps.d.ts +5 -0
- package/dist/cjs5/index.js +17 -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/index.js +17 -15
- 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/index.js +17 -15
- 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/index.js +17 -15
- package/dist/esm5/index.js.map +1 -1
- 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/index.js +17 -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/index.js +17 -15
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +21 -21
- 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/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
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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,MAAM,kBAAkB,CAAA;AACxC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAGjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAqB,EAAE,EAAE;;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,OAAO,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE;QACxB,OAAO,EAAE;YACP,IAAI,EAAE;gBACJ,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gBACnE,SAAS,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;aACxE;SACF;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA2C,CAAC,EAC9E,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,KAAK,EACd,MAAM,GAAG,KAAK,EACd,iBAAiB,EACjB,SAAS,
|
|
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,MAAM,kBAAkB,CAAA;AACxC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAGjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAqB,EAAE,EAAE;;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,OAAO,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE;QACxB,OAAO,EAAE;YACP,IAAI,EAAE;gBACJ,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,0CAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gBACnE,SAAS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CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAA;IAElG,IAAI,YAAY,GAAG,KAAK,CAAC,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;IAExD,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,MAAM,QAAQ,GAAa,GAAG,EAAE;QAC9B,OAAO,CACL,KAAC,sBAAsB,CAAC,QAAQ,kBAC9B,KAAK,EAAE,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,EAAE,gBAEnG,KAAC,aAAa,kBAAC,KAAK,EAAE,KAAK,gBAAG,QAAQ,YAAiB,YACvB,CACnC,CAAA;IACH,CAAC,CAAA;IAED,OAAO,MAAM,CAAC,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 };
|
|
@@ -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 };
|
package/dist/esm2015/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
|
|
@@ -1877,13 +1879,13 @@ const useUserEvents = () => {
|
|
|
1877
1879
|
|
|
1878
1880
|
let supportsWebP = undefined;
|
|
1879
1881
|
const useWebP = (webp, alt) => {
|
|
1880
|
-
const [img, setImg] = useState(
|
|
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
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1886
|
+
}
|
|
1887
|
+
if (mounted()) {
|
|
1888
|
+
setImg(supportsWebP ? webp : alt);
|
|
1887
1889
|
}
|
|
1888
1890
|
}), [supportsWebP]);
|
|
1889
1891
|
return img;
|