@gooddata/sdk-ui-theme-provider 11.53.0-alpha.6 → 11.53.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAWlD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAE7B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;IAEzB;;;;;;OAMG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,EAC1B,QAAQ,EACR,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,cAAc,EACzB,QAAmB,EACnB,0BAAiC,EACjC,0BAAiC,EACpC,EAAE,mBAAmB,2CAwGrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2020-2026 GoodData Corporation
|
|
3
|
-
import { useEffect,
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
4
|
import { useBackend, useWorkspace } from "@gooddata/sdk-ui";
|
|
5
5
|
import { clearCssProperties, setCssProperties } from "../cssProperties.js";
|
|
6
6
|
import { ThemeContextProvider } from "./Context.js";
|
|
@@ -25,9 +25,11 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
|
|
|
25
25
|
const [referenceTheme, setReferenceTheme] = useState(themeParam ?? {});
|
|
26
26
|
const [isLoading, setIsLoading] = useState(false);
|
|
27
27
|
const [status, setStatus] = useState("pending");
|
|
28
|
-
const lastWorkspace = useRef(undefined);
|
|
29
|
-
lastWorkspace.current = workspace;
|
|
30
28
|
useEffect(() => {
|
|
29
|
+
// Marks the in-flight getTheme() as stale once this effect is torn down - either because the
|
|
30
|
+
// workspace/backend changed or because the component unmounted. Without it a late resolution
|
|
31
|
+
// would re-inject the global styles that the unmount cleanup below has just removed.
|
|
32
|
+
let cancelled = false;
|
|
31
33
|
// A malformed theme (e.g. an unparseable color) must never block rendering. Preparing and
|
|
32
34
|
// applying the theme is wrapped so any failure falls back to the default theme and always
|
|
33
35
|
// resolves the loading state, instead of leaving the app stuck on the loading screen.
|
|
@@ -60,7 +62,7 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
|
|
|
60
62
|
// no need to load anything if the themeParam is present
|
|
61
63
|
if (themeParam) {
|
|
62
64
|
applyTheme(themeParam);
|
|
63
|
-
return;
|
|
65
|
+
return undefined;
|
|
64
66
|
}
|
|
65
67
|
const fetchData = async () => {
|
|
66
68
|
if (!backend || !workspace) {
|
|
@@ -71,12 +73,12 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
|
|
|
71
73
|
setStatus("loading");
|
|
72
74
|
try {
|
|
73
75
|
const selectedTheme = await backend.workspace(workspace).styling().getTheme();
|
|
74
|
-
if (
|
|
76
|
+
if (!cancelled) {
|
|
75
77
|
applyTheme(modifier(selectedTheme));
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
catch (error) {
|
|
79
|
-
if (
|
|
81
|
+
if (!cancelled) {
|
|
80
82
|
// covers both the backend fetch and the modifier transformation of the theme
|
|
81
83
|
console.error("Failed to load or process the theme from the backend.", error);
|
|
82
84
|
// reset both channels (context theme and global CSS) to the default theme so
|
|
@@ -90,6 +92,9 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
|
|
|
90
92
|
}
|
|
91
93
|
};
|
|
92
94
|
void fetchData();
|
|
95
|
+
return () => {
|
|
96
|
+
cancelled = true;
|
|
97
|
+
};
|
|
93
98
|
}, [themeParam, workspace, backend, modifier, enableComplementaryPalette]);
|
|
94
99
|
useEffect(() => {
|
|
95
100
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-theme-provider",
|
|
3
|
-
"version": "11.53.0
|
|
3
|
+
"version": "11.53.0",
|
|
4
4
|
"description": "GoodData SDK - Theme provider",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData Corporation",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"postcss-value-parser": "^4.2.0",
|
|
33
33
|
"ts-invariant": "0.10.3",
|
|
34
34
|
"tslib": "2.8.1",
|
|
35
|
-
"@gooddata/sdk-backend-spi": "11.53.0
|
|
36
|
-
"@gooddata/sdk-
|
|
37
|
-
"@gooddata/sdk-
|
|
38
|
-
"@gooddata/util": "11.53.0
|
|
35
|
+
"@gooddata/sdk-backend-spi": "11.53.0",
|
|
36
|
+
"@gooddata/sdk-ui": "11.53.0",
|
|
37
|
+
"@gooddata/sdk-model": "11.53.0",
|
|
38
|
+
"@gooddata/util": "11.53.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@microsoft/api-documenter": "^7.17.0",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"react-dom": "19.1.1",
|
|
74
74
|
"typescript": "5.9.3",
|
|
75
75
|
"vitest": "4.1.8",
|
|
76
|
-
"@gooddata/eslint-config": "11.53.0
|
|
77
|
-
"@gooddata/oxlint-config": "11.53.0
|
|
78
|
-
"@gooddata/reference-workspace": "11.53.0
|
|
79
|
-
"@gooddata/sdk-backend-mockingbird": "11.53.0
|
|
76
|
+
"@gooddata/eslint-config": "11.53.0",
|
|
77
|
+
"@gooddata/oxlint-config": "11.53.0",
|
|
78
|
+
"@gooddata/reference-workspace": "11.53.0",
|
|
79
|
+
"@gooddata/sdk-backend-mockingbird": "11.53.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^18.0.0 || ^19.0.0",
|