@gooddata/sdk-ui-theme-provider 11.65.0-alpha.8 → 11.65.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.
- package/README.md +1 -1
- package/esm/documentsTheme.d.ts +10 -0
- package/esm/documentsTheme.d.ts.map +1 -1
- package/esm/documentsTheme.js +30 -5
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -1
- package/esm/paletteColors.d.ts +15 -0
- package/esm/paletteColors.d.ts.map +1 -0
- package/esm/paletteColors.js +34 -0
- package/esm/sdk-ui-theme-provider.d.ts +27 -0
- package/esm/variablesSpec/internal/spacing.d.ts.map +1 -1
- package/esm/variablesSpec/internal/spacing.js +6 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -11,6 +11,6 @@ This project implements the Theming support (see [documentation](https://sdk.goo
|
|
|
11
11
|
|
|
12
12
|
## License
|
|
13
13
|
|
|
14
|
-
(C) 2017-
|
|
14
|
+
(C) 2017-2026 GoodData Corporation
|
|
15
15
|
|
|
16
16
|
This project is under MIT License. See [LICENSE](https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui-theme-provider/LICENSE).
|
package/esm/documentsTheme.d.ts
CHANGED
|
@@ -5,6 +5,16 @@ import { type ITheme } from "@gooddata/sdk-model";
|
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export declare function documentsThemeCssValues(documents: unknown): object | "";
|
|
8
|
+
/**
|
|
9
|
+
* Whether a document drawn with the theme has a color for the id in the list: one built in, or one the
|
|
10
|
+
* theme states with a value the provider writes.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* A reference to a color the theme lists but writes no value for still counts as set.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDocumentsThemeColorSet(theme: ITheme | undefined, list: string, id: string): boolean;
|
|
8
18
|
/**
|
|
9
19
|
* The paths in the documents section where a length is written with a unit, which documents ignore.
|
|
10
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentsTheme.d.ts","sourceRoot":"","sources":["../src/documentsTheme.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"documentsTheme.d.ts","sourceRoot":"","sources":["../src/documentsTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,MAAM,EAGd,MAAM,qBAAqB,CAAC;AAsJ7B;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,EAAE,CA6BvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAcrG;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAmBhF"}
|
package/esm/documentsTheme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
|
-
import { getPublisherThemeReferencePathV2 } from "@gooddata/sdk-model";
|
|
2
|
+
import { getPublisherThemePaletteReferenceV2, getPublisherThemeReferencePathV2, } from "@gooddata/sdk-model";
|
|
3
|
+
import { paletteCssVariable } from "./paletteColors.js";
|
|
3
4
|
// Document lengths are px on the page canvas, emitted bare for the renderer to scale. A value that
|
|
4
5
|
// starts like a number without being one carries a unit, which documents do not accept.
|
|
5
6
|
const NUMBER = /^[+-]?(\d+(\.\d+)?|\.\d+)$/;
|
|
@@ -22,7 +23,6 @@ const BUILT_IN_COLOR_IDS = {
|
|
|
22
23
|
texts: ["default", "muted", "inverse", "accent"],
|
|
23
24
|
lines: ["default", "accent"],
|
|
24
25
|
};
|
|
25
|
-
const PALETTE_NAMES = ["primary", "success", "error", "warning"];
|
|
26
26
|
const SPACING_KINDS = ["gap", "padding"];
|
|
27
27
|
const SPACING_STEPS = ["compact", "normal", "spacious"];
|
|
28
28
|
// `full` is built in: the renderer resolves it and the theme never sets it.
|
|
@@ -49,13 +49,14 @@ function themeColorIds(documents, list) {
|
|
|
49
49
|
}
|
|
50
50
|
// A reference becomes the variable of the value it names, and only when that variable exists.
|
|
51
51
|
function themeReferenceCss(value, documents) {
|
|
52
|
+
const palette = getPublisherThemePaletteReferenceV2(value);
|
|
53
|
+
if (palette !== undefined) {
|
|
54
|
+
return `var(${paletteCssVariable(palette)})`;
|
|
55
|
+
}
|
|
52
56
|
const [group, name, step, ...rest] = getPublisherThemeReferencePathV2(value) ?? [];
|
|
53
57
|
if (rest.length > 0 || name === undefined) {
|
|
54
58
|
return "";
|
|
55
59
|
}
|
|
56
|
-
if (group === "palette" && step === undefined && PALETTE_NAMES.includes(name)) {
|
|
57
|
-
return `var(--gd-palette-${name}-base)`;
|
|
58
|
-
}
|
|
59
60
|
if (group === "colors" &&
|
|
60
61
|
isColorList(name) &&
|
|
61
62
|
step !== undefined &&
|
|
@@ -151,6 +152,30 @@ export function documentsThemeCssValues(documents) {
|
|
|
151
152
|
},
|
|
152
153
|
};
|
|
153
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Whether a document drawn with the theme has a color for the id in the list: one built in, or one the
|
|
157
|
+
* theme states with a value the provider writes.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* A reference to a color the theme lists but writes no value for still counts as set.
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
export function isDocumentsThemeColorSet(theme, list, id) {
|
|
165
|
+
if (!isColorList(list)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (BUILT_IN_COLOR_IDS[list].includes(id)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
const documents = theme?.documents;
|
|
172
|
+
if (!isObject(documents)) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
const colors = isObject(documents["colors"]) ? documents["colors"][list] : undefined;
|
|
176
|
+
const byId = colorsById(colors, documents);
|
|
177
|
+
return Object.prototype.hasOwnProperty.call(byId, id) && byId[id] !== "";
|
|
178
|
+
}
|
|
154
179
|
/**
|
|
155
180
|
* The paths in the documents section where a length is written with a unit, which documents ignore.
|
|
156
181
|
*
|
package/esm/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export { ConditionalScopedThemeProvider } from "./ThemeProvider/ConditionalScope
|
|
|
15
15
|
export { isDarkTheme } from "./ThemeProvider/isDarkTheme.js";
|
|
16
16
|
export { withTheme, useTheme, useReferenceTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, type IThemeContextProviderProps, type ThemeStatus, } from "./ThemeProvider/Context.js";
|
|
17
17
|
export { isValidThemeColor, findInvalidThemeColors, findMissingRequiredThemeColors, type IInvalidThemeColor, } from "./colorValidation.js";
|
|
18
|
-
export { findDocumentLengthsWithUnits } from "./documentsTheme.js";
|
|
18
|
+
export { findDocumentLengthsWithUnits, isDocumentsThemeColorSet } from "./documentsTheme.js";
|
|
19
|
+
export { paletteCssVariable, paletteDefaultColor } from "./paletteColors.js";
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -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,EA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|
@@ -17,4 +17,5 @@ export { ConditionalScopedThemeProvider } from "./ThemeProvider/ConditionalScope
|
|
|
17
17
|
export { isDarkTheme } from "./ThemeProvider/isDarkTheme.js";
|
|
18
18
|
export { withTheme, useTheme, useReferenceTheme, useThemeIsLoading, useIsScopeThemed, useThemeStatus, useIsDarkTheme, ThemeContextProvider, } from "./ThemeProvider/Context.js";
|
|
19
19
|
export { isValidThemeColor, findInvalidThemeColors, findMissingRequiredThemeColors, } from "./colorValidation.js";
|
|
20
|
-
export { findDocumentLengthsWithUnits } from "./documentsTheme.js";
|
|
20
|
+
export { findDocumentLengthsWithUnits, isDocumentsThemeColorSet } from "./documentsTheme.js";
|
|
21
|
+
export { paletteCssVariable, paletteDefaultColor } from "./paletteColors.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PublisherThemePaletteReferenceV2 } from "@gooddata/sdk-model";
|
|
2
|
+
/**
|
|
3
|
+
* The CSS variable the theme writes the palette color to.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function paletteCssVariable(reference: PublisherThemePaletteReferenceV2): string;
|
|
8
|
+
/**
|
|
9
|
+
* The color the platform draws for the palette color where the theme states none, as the default
|
|
10
|
+
* stylesheet does.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function paletteDefaultColor(reference: PublisherThemePaletteReferenceV2): string;
|
|
15
|
+
//# sourceMappingURL=paletteColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paletteColors.d.ts","sourceRoot":"","sources":["../src/paletteColors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAK5E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,gCAAgC,GAAG,MAAM,CAMtF;AAQD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,gCAAgC,GAAG,MAAM,CAWvF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { paletteBaseThemeVariables } from "./variablesSpec/theme/palette-base.js";
|
|
3
|
+
import { paletteComplementaryThemeVariables } from "./variablesSpec/theme/palette-complementary.js";
|
|
4
|
+
/**
|
|
5
|
+
* The CSS variable the theme writes the palette color to.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function paletteCssVariable(reference) {
|
|
10
|
+
if (reference.type === "complementary") {
|
|
11
|
+
// The provider numbers these by key position; getComplementaryPalette keeps c0 to c9 in order.
|
|
12
|
+
return `--gd-palette-complementary-${reference.step.slice(1)}`;
|
|
13
|
+
}
|
|
14
|
+
return `--gd-palette-${reference.family}-base`;
|
|
15
|
+
}
|
|
16
|
+
const PALETTE_DEFAULTS = new Map([...paletteBaseThemeVariables, ...paletteComplementaryThemeVariables].map(({ variableName, defaultValue }) => [variableName, defaultValue]));
|
|
17
|
+
/**
|
|
18
|
+
* The color the platform draws for the palette color where the theme states none, as the default
|
|
19
|
+
* stylesheet does.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export function paletteDefaultColor(reference) {
|
|
24
|
+
// Info's stylesheet default is primary's variable, which a chart cannot read.
|
|
25
|
+
if (reference.type === "family" && reference.family === "info") {
|
|
26
|
+
return paletteDefaultColor({ type: "family", family: "primary" });
|
|
27
|
+
}
|
|
28
|
+
const variable = paletteCssVariable(reference);
|
|
29
|
+
const color = PALETTE_DEFAULTS.get(variable);
|
|
30
|
+
if (color === undefined || color === null) {
|
|
31
|
+
throw new Error(`The theme variables state no default for ${variable}.`);
|
|
32
|
+
}
|
|
33
|
+
return color;
|
|
34
|
+
}
|
|
@@ -14,6 +14,7 @@ import { IAnalyticalBackend } from '@gooddata/sdk-backend-spi';
|
|
|
14
14
|
import { ITheme } from '@gooddata/sdk-model';
|
|
15
15
|
import { IThemeHeader } from '@gooddata/sdk-model';
|
|
16
16
|
import { JSX } from 'react/jsx-runtime';
|
|
17
|
+
import { PublisherThemePaletteReferenceV2 } from '@gooddata/sdk-model';
|
|
17
18
|
import { ReactNode } from 'react';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -141,6 +142,17 @@ export declare interface IScopedThemeProviderProps {
|
|
|
141
142
|
*/
|
|
142
143
|
export declare const isDarkTheme: (theme: ITheme | undefined) => boolean;
|
|
143
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Whether a document drawn with the theme has a color for the id in the list: one built in, or one the
|
|
147
|
+
* theme states with a value the provider writes.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* A reference to a color the theme lists but writes no value for still counts as set.
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
export declare function isDocumentsThemeColorSet(theme: ITheme | undefined, list: string, id: string): boolean;
|
|
155
|
+
|
|
144
156
|
/**
|
|
145
157
|
* Returns true if the provided value is a color string that the `polished` library can parse
|
|
146
158
|
* (hex, rgb(a), hsl(a) or a named color).
|
|
@@ -255,6 +267,21 @@ export declare interface IThemeProviderProps {
|
|
|
255
267
|
children?: ReactNode;
|
|
256
268
|
}
|
|
257
269
|
|
|
270
|
+
/**
|
|
271
|
+
* The CSS variable the theme writes the palette color to.
|
|
272
|
+
*
|
|
273
|
+
* @internal
|
|
274
|
+
*/
|
|
275
|
+
export declare function paletteCssVariable(reference: PublisherThemePaletteReferenceV2): string;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The color the platform draws for the palette color where the theme states none, as the default
|
|
279
|
+
* stylesheet does.
|
|
280
|
+
*
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
export declare function paletteDefaultColor(reference: PublisherThemePaletteReferenceV2): string;
|
|
284
|
+
|
|
258
285
|
/**
|
|
259
286
|
* ScopedThemeProvider is an experimental component that is not yet ready for production use.
|
|
260
287
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../../src/variablesSpec/internal/spacing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../../src/variablesSpec/internal/spacing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,6BAA6B,EAAE,wBAAwB,EAwDnE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// (C) 2024-2026 GoodData Corporation
|
|
1
2
|
export const internalSpacingThemeVariables = [
|
|
2
3
|
{
|
|
3
4
|
type: "internal",
|
|
@@ -49,4 +50,9 @@ export const internalSpacingThemeVariables = [
|
|
|
49
50
|
variableName: "--gd-spacing-34px",
|
|
50
51
|
defaultValue: "34px",
|
|
51
52
|
},
|
|
53
|
+
{
|
|
54
|
+
type: "internal",
|
|
55
|
+
variableName: "--gd-spacing-30px",
|
|
56
|
+
defaultValue: "30px",
|
|
57
|
+
},
|
|
52
58
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-theme-provider",
|
|
3
|
-
"version": "11.65.0
|
|
3
|
+
"version": "11.65.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.65.0
|
|
36
|
-
"@gooddata/sdk-model": "11.65.0
|
|
37
|
-
"@gooddata/sdk-ui": "11.65.0
|
|
38
|
-
"@gooddata/util": "11.65.0
|
|
35
|
+
"@gooddata/sdk-backend-spi": "11.65.0",
|
|
36
|
+
"@gooddata/sdk-model": "11.65.0",
|
|
37
|
+
"@gooddata/sdk-ui": "11.65.0",
|
|
38
|
+
"@gooddata/util": "11.65.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@microsoft/api-documenter": "7.30.16",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"react-dom": "19.1.1",
|
|
70
70
|
"typescript": "7.0.2",
|
|
71
71
|
"vitest": "5.0.4",
|
|
72
|
-
"@gooddata/
|
|
73
|
-
"@gooddata/
|
|
74
|
-
"@gooddata/
|
|
75
|
-
"@gooddata/sdk-backend-mockingbird": "11.65.0
|
|
72
|
+
"@gooddata/oxlint-config": "11.65.0",
|
|
73
|
+
"@gooddata/eslint-config": "11.65.0",
|
|
74
|
+
"@gooddata/reference-workspace": "11.65.0",
|
|
75
|
+
"@gooddata/sdk-backend-mockingbird": "11.65.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react": "^18.0.0 || ^19.0.0",
|