@gooddata/sdk-ui-theme-provider 11.47.0-alpha.4 → 11.47.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.
@@ -13,6 +13,15 @@ export interface IThemeContextProviderProps {
13
13
  * When undefined, no theme is applied and default styling is used.
14
14
  */
15
15
  theme: ITheme | undefined;
16
+ /**
17
+ * Theme of record for computations that must not depend on application-specific
18
+ * presentation adjustments (e.g. a stripped complementary palette).
19
+ *
20
+ * @remarks
21
+ * When undefined, the reference from an enclosing provider is inherited,
22
+ * falling back to the theme itself.
23
+ */
24
+ referenceTheme?: ITheme;
16
25
  /**
17
26
  * Flag telling whether the theme object is being loaded or not
18
27
  * @deprecated use themeStatus instead
@@ -40,7 +49,7 @@ export interface IThemeContextProviderProps {
40
49
  *
41
50
  * @public
42
51
  */
43
- export declare function ThemeContextProvider({ children, theme, themeIsLoading, themeStatus, isScopeThemed }: IThemeContextProviderProps): import("react/jsx-runtime").JSX.Element;
52
+ export declare function ThemeContextProvider({ children, theme, referenceTheme, themeIsLoading, themeStatus, isScopeThemed }: IThemeContextProviderProps): import("react/jsx-runtime").JSX.Element;
44
53
  /**
45
54
  * Hook for reaching the theme from context.
46
55
  *
@@ -61,6 +70,17 @@ export declare function ThemeContextProvider({ children, theme, themeIsLoading,
61
70
  * @public
62
71
  */
63
72
  export declare const useTheme: (theme?: ITheme | undefined) => ITheme | undefined;
73
+ /**
74
+ * Hook for reaching the reference theme from context.
75
+ *
76
+ * @remarks
77
+ * The reference theme is the workspace theme prepared with the complementary palette enabled,
78
+ * regardless of how the application presents itself. Use it for computations that must be
79
+ * consistent across applications (e.g. color derivation); use {@link useTheme} for presentation.
80
+ *
81
+ * @public
82
+ */
83
+ export declare const useReferenceTheme: () => ITheme | undefined;
64
84
  /**
65
85
  * Hook that returns whether the current theme is dark
66
86
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/Context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KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAC5B,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC,CAIpE"}
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- // (C) 2019-2025 GoodData Corporation
2
+ // (C) 2019-2026 GoodData Corporation
3
3
  import { createContext, useContext } from "react";
4
4
  import { wrapDisplayName } from "@gooddata/sdk-ui";
5
5
  import { isDarkTheme } from "./isDarkTheme.js";
6
6
  const ThemeContext = createContext(undefined);
7
7
  ThemeContext.displayName = "ThemeContext";
8
+ const ThemeReferenceContext = createContext(undefined);
9
+ ThemeReferenceContext.displayName = "ThemeReferenceContext";
8
10
  const ThemeIsLoadingContext = createContext(undefined);
9
11
  ThemeIsLoadingContext.displayName = "ThemeIsLoadingContext";
10
12
  const ThemeIsScopeThemedContext = createContext(undefined);
@@ -16,8 +18,11 @@ ThemeStatusContext.displayName = "ThemeStatusContext";
16
18
  *
17
19
  * @public
18
20
  */
19
- export function ThemeContextProvider({ children, theme, themeIsLoading, themeStatus, isScopeThemed, }) {
20
- return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(ThemeIsLoadingContext.Provider, { value: themeIsLoading, children: _jsx(ThemeIsScopeThemedContext.Provider, { value: isScopeThemed, children: _jsx(ThemeStatusContext.Provider, { value: themeStatus, children: children }) }) }) }));
21
+ export function ThemeContextProvider({ children, theme, referenceTheme, themeIsLoading, themeStatus, isScopeThemed, }) {
22
+ // nested providers re-providing only the presentation theme must not shadow
23
+ // an outer reference theme (e.g. chart internals re-wrap the stripped theme in AD)
24
+ const outerReferenceTheme = useContext(ThemeReferenceContext);
25
+ return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(ThemeReferenceContext.Provider, { value: referenceTheme ?? outerReferenceTheme ?? theme, children: _jsx(ThemeIsLoadingContext.Provider, { value: themeIsLoading, children: _jsx(ThemeIsScopeThemedContext.Provider, { value: isScopeThemed, children: _jsx(ThemeStatusContext.Provider, { value: themeStatus, children: children }) }) }) }) }));
21
26
  }
22
27
  /**
23
28
  * Hook for reaching the theme from context.
@@ -42,6 +47,19 @@ export const useTheme = (theme) => {
42
47
  const themeFromContext = useContext(ThemeContext);
43
48
  return theme ?? themeFromContext;
44
49
  };
50
+ /**
51
+ * Hook for reaching the reference theme from context.
52
+ *
53
+ * @remarks
54
+ * The reference theme is the workspace theme prepared with the complementary palette enabled,
55
+ * regardless of how the application presents itself. Use it for computations that must be
56
+ * consistent across applications (e.g. color derivation); use {@link useTheme} for presentation.
57
+ *
58
+ * @public
59
+ */
60
+ export const useReferenceTheme = () => {
61
+ return useContext(ThemeReferenceContext);
62
+ };
45
63
  /**
46
64
  * Hook that returns whether the current theme is dark
47
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedThemeProvider.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/ScopedThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAQlD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;;;;;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;;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ACpC,EAAE,yBAAyB,2CAwF3B"}
@@ -22,6 +22,7 @@ export function ScopedThemeProvider({ children, theme: themeParam, backend: back
22
22
  const workspace = useWorkspace(workspaceParam);
23
23
  const [scopeId] = useState(`font${Math.random().toString(36).substring(2, 15)}`);
24
24
  const [theme, setTheme] = useState(themeParam ?? {});
25
+ const [referenceTheme, setReferenceTheme] = useState(themeParam ?? {});
25
26
  const [isLoading, setIsLoading] = useState(false);
26
27
  const [status, setStatus] = useState("pending");
27
28
  const [scope, setScope] = useState();
@@ -32,6 +33,7 @@ export function ScopedThemeProvider({ children, theme: themeParam, backend: back
32
33
  if (themeParam) {
33
34
  const preparedTheme = prepareTheme(themeParam, enableComplementaryPalette);
34
35
  setTheme(preparedTheme);
36
+ setReferenceTheme(enableComplementaryPalette ? preparedTheme : prepareTheme(themeParam, true));
35
37
  setStatus("success");
36
38
  clearCssProperties(true, scope ?? undefined, scopeId);
37
39
  setCssProperties(preparedTheme, isDarkTheme(preparedTheme), true, scope ?? undefined, scopeId);
@@ -49,6 +51,7 @@ export function ScopedThemeProvider({ children, theme: themeParam, backend: back
49
51
  const modifiedTheme = modifier(selectedTheme);
50
52
  const preparedTheme = prepareTheme(modifiedTheme, enableComplementaryPalette);
51
53
  setTheme(preparedTheme);
54
+ setReferenceTheme(enableComplementaryPalette ? preparedTheme : prepareTheme(modifiedTheme, true));
52
55
  clearCssProperties(true, scope ?? undefined, scopeId);
53
56
  setCssProperties(preparedTheme, isDarkTheme(preparedTheme), true, scope ?? undefined, scopeId);
54
57
  setIsLoading(false);
@@ -64,7 +67,7 @@ export function ScopedThemeProvider({ children, theme: themeParam, backend: back
64
67
  }
65
68
  };
66
69
  }, [removeGlobalStylesOnUnmout, scope, scopeId]);
67
- return (_jsx(ThemeContextProvider, { theme: theme, isScopeThemed: true, themeIsLoading: isLoading, themeStatus: status, children: _jsx("div", { ref: (el) => {
70
+ return (_jsx(ThemeContextProvider, { theme: theme, referenceTheme: referenceTheme, isScopeThemed: true, themeIsLoading: isLoading, themeStatus: status, children: _jsx("div", { ref: (el) => {
68
71
  if (el) {
69
72
  setScope(el);
70
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,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,2CAoFrB"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpE,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,2CAkGrB"}
@@ -22,6 +22,7 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
22
22
  const backend = useBackend(backendParam);
23
23
  const workspace = useWorkspace(workspaceParam);
24
24
  const [theme, setTheme] = useState(themeParam ?? {});
25
+ const [referenceTheme, setReferenceTheme] = useState(themeParam ?? {});
25
26
  const [isLoading, setIsLoading] = useState(false);
26
27
  const [status, setStatus] = useState("pending");
27
28
  const lastWorkspace = useRef(undefined);
@@ -33,7 +34,13 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
33
34
  const applyTheme = (themeToApply) => {
34
35
  try {
35
36
  const preparedTheme = prepareTheme(themeToApply, enableComplementaryPalette);
37
+ // theme of record: always prepared with the complementary palette, so consumers
38
+ // computing from it get the same values in every application
39
+ const preparedReferenceTheme = enableComplementaryPalette
40
+ ? preparedTheme
41
+ : prepareTheme(themeToApply, true);
36
42
  setTheme(preparedTheme);
43
+ setReferenceTheme(preparedReferenceTheme);
37
44
  clearCssProperties();
38
45
  setCssProperties(preparedTheme, isDarkTheme(preparedTheme));
39
46
  }
@@ -42,6 +49,7 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
42
49
  // reset both channels (context theme and global CSS) to the default theme so
43
50
  // context consumers stay consistent with the cleared CSS variables
44
51
  setTheme({});
52
+ setReferenceTheme({});
45
53
  clearCssProperties();
46
54
  }
47
55
  finally {
@@ -74,6 +82,7 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
74
82
  // reset both channels (context theme and global CSS) to the default theme so
75
83
  // context consumers stay consistent with the cleared CSS variables
76
84
  setTheme({});
85
+ setReferenceTheme({});
77
86
  clearCssProperties();
78
87
  setIsLoading(false);
79
88
  setStatus("success");
@@ -89,5 +98,5 @@ export function ThemeProvider({ children, theme: themeParam, backend: backendPar
89
98
  }
90
99
  };
91
100
  }, [removeGlobalStylesOnUnmout]);
92
- return (_jsx(ThemeContextProvider, { theme: theme, themeIsLoading: isLoading, themeStatus: status, children: children }));
101
+ return (_jsx(ThemeContextProvider, { theme: theme, referenceTheme: referenceTheme, themeIsLoading: isLoading, themeStatus: status, children: children }));
93
102
  }
package/esm/index.d.ts CHANGED
@@ -13,6 +13,6 @@ export { ThemeProvider, type IThemeProviderProps, type ThemeModifier, } from "./
13
13
  export { ScopedThemeProvider, type IScopedThemeProviderProps } from "./ThemeProvider/ScopedThemeProvider.js";
14
14
  export { ConditionalScopedThemeProvider } from "./ThemeProvider/ConditionalScopedThemeProvider.js";
15
15
  export { isDarkTheme } from "./ThemeProvider/isDarkTheme.js";
16
- export { withTheme, useTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, type IThemeContextProviderProps, type ThemeStatus, } from "./ThemeProvider/Context.js";
16
+ export { withTheme, useTheme, useReferenceTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, type IThemeContextProviderProps, type ThemeStatus, } from "./ThemeProvider/Context.js";
17
17
  export { isValidThemeColor, findInvalidThemeColors, type IInvalidThemeColor } from "./colorValidation.js";
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EACH,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAC7G,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACH,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,WAAW,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EACH,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAC7G,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACH,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,WAAW,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/esm/index.js CHANGED
@@ -15,5 +15,5 @@ export { ThemeProvider, } from "./ThemeProvider/ThemeProvider.js";
15
15
  export { ScopedThemeProvider } from "./ThemeProvider/ScopedThemeProvider.js";
16
16
  export { ConditionalScopedThemeProvider } from "./ThemeProvider/ConditionalScopedThemeProvider.js";
17
17
  export { isDarkTheme } from "./ThemeProvider/isDarkTheme.js";
18
- export { withTheme, useTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, } from "./ThemeProvider/Context.js";
18
+ export { withTheme, useTheme, useReferenceTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, } from "./ThemeProvider/Context.js";
19
19
  export { isValidThemeColor, findInvalidThemeColors } from "./colorValidation.js";
@@ -140,6 +140,15 @@ export declare interface IThemeContextProviderProps {
140
140
  * When undefined, no theme is applied and default styling is used.
141
141
  */
142
142
  theme: ITheme | undefined;
143
+ /**
144
+ * Theme of record for computations that must not depend on application-specific
145
+ * presentation adjustments (e.g. a stripped complementary palette).
146
+ *
147
+ * @remarks
148
+ * When undefined, the reference from an enclosing provider is inherited,
149
+ * falling back to the theme itself.
150
+ */
151
+ referenceTheme?: ITheme;
143
152
  /**
144
153
  * Flag telling whether the theme object is being loaded or not
145
154
  * @deprecated use themeStatus instead
@@ -232,7 +241,7 @@ export declare function ScopedThemeProvider({ children, theme: themeParam, backe
232
241
  *
233
242
  * @public
234
243
  */
235
- export declare function ThemeContextProvider({ children, theme, themeIsLoading, themeStatus, isScopeThemed }: IThemeContextProviderProps): JSX.Element;
244
+ export declare function ThemeContextProvider({ children, theme, referenceTheme, themeIsLoading, themeStatus, isScopeThemed }: IThemeContextProviderProps): JSX.Element;
236
245
 
237
246
  /**
238
247
  * @public
@@ -271,6 +280,18 @@ export declare const useIsDarkTheme: () => boolean;
271
280
  */
272
281
  export declare const useIsScopeThemed: () => boolean | undefined;
273
282
 
283
+ /**
284
+ * Hook for reaching the reference theme from context.
285
+ *
286
+ * @remarks
287
+ * The reference theme is the workspace theme prepared with the complementary palette enabled,
288
+ * regardless of how the application presents itself. Use it for computations that must be
289
+ * consistent across applications (e.g. color derivation); use {@link useTheme} for presentation.
290
+ *
291
+ * @public
292
+ */
293
+ export declare const useReferenceTheme: () => ITheme | undefined;
294
+
274
295
  /**
275
296
  * Hook for reaching the theme from context.
276
297
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-ui-theme-provider",
3
- "version": "11.47.0-alpha.4",
3
+ "version": "11.47.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.47.0-alpha.4",
36
- "@gooddata/sdk-model": "11.47.0-alpha.4",
37
- "@gooddata/sdk-ui": "11.47.0-alpha.4",
38
- "@gooddata/util": "11.47.0-alpha.4"
35
+ "@gooddata/sdk-backend-spi": "11.47.0",
36
+ "@gooddata/util": "11.47.0",
37
+ "@gooddata/sdk-model": "11.47.0",
38
+ "@gooddata/sdk-ui": "11.47.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.47.0-alpha.4",
77
- "@gooddata/oxlint-config": "11.47.0-alpha.4",
78
- "@gooddata/reference-workspace": "11.47.0-alpha.4",
79
- "@gooddata/sdk-backend-mockingbird": "11.47.0-alpha.4"
76
+ "@gooddata/eslint-config": "11.47.0",
77
+ "@gooddata/oxlint-config": "11.47.0",
78
+ "@gooddata/reference-workspace": "11.47.0",
79
+ "@gooddata/sdk-backend-mockingbird": "11.47.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "react": "^18.0.0 || ^19.0.0",