@gooddata/sdk-ui-theme-provider 10.17.0-alpha.7 → 10.17.0-alpha.9

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 (185) hide show
  1. package/esm/ThemeProvider/ScopedThemeProvider.d.ts +67 -0
  2. package/esm/ThemeProvider/ScopedThemeProvider.d.ts.map +1 -0
  3. package/esm/ThemeProvider/ScopedThemeProvider.js +77 -0
  4. package/esm/ThemeProvider/ScopedThemeProvider.js.map +1 -0
  5. package/esm/cssProperties.d.ts +4 -4
  6. package/esm/cssProperties.d.ts.map +1 -1
  7. package/esm/cssProperties.js +79 -23
  8. package/esm/cssProperties.js.map +1 -1
  9. package/esm/defaultThemes/blueLight.d.ts +6 -0
  10. package/esm/defaultThemes/blueLight.d.ts.map +1 -0
  11. package/esm/defaultThemes/blueLight.js +112 -0
  12. package/esm/defaultThemes/blueLight.js.map +1 -0
  13. package/esm/defaultThemes/greenDark.d.ts +6 -0
  14. package/esm/defaultThemes/greenDark.d.ts.map +1 -0
  15. package/esm/defaultThemes/greenDark.js +42 -0
  16. package/esm/defaultThemes/greenDark.js.map +1 -0
  17. package/esm/defaultThemes/indigo.d.ts +9 -0
  18. package/esm/defaultThemes/indigo.d.ts.map +1 -0
  19. package/esm/defaultThemes/indigo.js +161 -0
  20. package/esm/defaultThemes/indigo.js.map +1 -0
  21. package/esm/defaultThemes/indigoDark.d.ts +6 -0
  22. package/esm/defaultThemes/indigoDark.d.ts.map +1 -0
  23. package/esm/defaultThemes/indigoDark.js +28 -0
  24. package/esm/defaultThemes/indigoDark.js.map +1 -0
  25. package/esm/defaultThemes/pinkLight.d.ts +6 -0
  26. package/esm/defaultThemes/pinkLight.d.ts.map +1 -0
  27. package/esm/defaultThemes/pinkLight.js +85 -0
  28. package/esm/defaultThemes/pinkLight.js.map +1 -0
  29. package/esm/defaultThemes/pompelmoLight.d.ts +6 -0
  30. package/esm/defaultThemes/pompelmoLight.d.ts.map +1 -0
  31. package/esm/defaultThemes/pompelmoLight.js +117 -0
  32. package/esm/defaultThemes/pompelmoLight.js.map +1 -0
  33. package/esm/defaultThemes/redLightTheme.d.ts +6 -0
  34. package/esm/defaultThemes/redLightTheme.d.ts.map +1 -0
  35. package/esm/defaultThemes/redLightTheme.js +114 -0
  36. package/esm/defaultThemes/redLightTheme.js.map +1 -0
  37. package/esm/derivedColors.d.ts.map +1 -1
  38. package/esm/derivedColors.js +6 -1
  39. package/esm/derivedColors.js.map +1 -1
  40. package/esm/index.d.ts +2 -0
  41. package/esm/index.d.ts.map +1 -1
  42. package/esm/index.js +1 -0
  43. package/esm/index.js.map +1 -1
  44. package/esm/internal.d.ts +9 -0
  45. package/esm/internal.d.ts.map +1 -0
  46. package/esm/internal.js +10 -0
  47. package/esm/internal.js.map +1 -0
  48. package/esm/node.d.ts +17 -0
  49. package/esm/node.d.ts.map +1 -0
  50. package/esm/node.js +52 -0
  51. package/esm/node.js.map +1 -0
  52. package/esm/sdk-ui-theme-provider.d.ts +64 -0
  53. package/esm/variablesSpec/DefaultThemePreview.d.ts +7 -0
  54. package/esm/variablesSpec/DefaultThemePreview.d.ts.map +1 -0
  55. package/esm/variablesSpec/DefaultThemePreview.js +116 -0
  56. package/esm/variablesSpec/DefaultThemePreview.js.map +1 -0
  57. package/esm/variablesSpec/allThemeCssVariables.d.ts +6 -0
  58. package/esm/variablesSpec/allThemeCssVariables.d.ts.map +1 -0
  59. package/esm/variablesSpec/allThemeCssVariables.js +72 -0
  60. package/esm/variablesSpec/allThemeCssVariables.js.map +1 -0
  61. package/esm/variablesSpec/deprecated/palette-base.d.ts +3 -0
  62. package/esm/variablesSpec/deprecated/palette-base.d.ts.map +1 -0
  63. package/esm/variablesSpec/deprecated/palette-base.js +78 -0
  64. package/esm/variablesSpec/deprecated/palette-base.js.map +1 -0
  65. package/esm/variablesSpec/generate/generateDefaultScssThemeContent.d.ts +7 -0
  66. package/esm/variablesSpec/generate/generateDefaultScssThemeContent.d.ts.map +1 -0
  67. package/esm/variablesSpec/generate/generateDefaultScssThemeContent.js +56 -0
  68. package/esm/variablesSpec/generate/generateDefaultScssThemeContent.js.map +1 -0
  69. package/esm/variablesSpec/generate/generateDefaultTypeScriptThemeContent.d.ts +7 -0
  70. package/esm/variablesSpec/generate/generateDefaultTypeScriptThemeContent.d.ts.map +1 -0
  71. package/esm/variablesSpec/generate/generateDefaultTypeScriptThemeContent.js +28 -0
  72. package/esm/variablesSpec/generate/generateDefaultTypeScriptThemeContent.js.map +1 -0
  73. package/esm/variablesSpec/inconsistent/inconsistent.d.ts +3 -0
  74. package/esm/variablesSpec/inconsistent/inconsistent.d.ts.map +1 -0
  75. package/esm/variablesSpec/inconsistent/inconsistent.js +275 -0
  76. package/esm/variablesSpec/inconsistent/inconsistent.js.map +1 -0
  77. package/esm/variablesSpec/internal/button.d.ts +3 -0
  78. package/esm/variablesSpec/internal/button.d.ts.map +1 -0
  79. package/esm/variablesSpec/internal/button.js +18 -0
  80. package/esm/variablesSpec/internal/button.js.map +1 -0
  81. package/esm/variablesSpec/internal/font.d.ts +3 -0
  82. package/esm/variablesSpec/internal/font.d.ts.map +1 -0
  83. package/esm/variablesSpec/internal/font.js +8 -0
  84. package/esm/variablesSpec/internal/font.js.map +1 -0
  85. package/esm/variablesSpec/internal/icon.d.ts +3 -0
  86. package/esm/variablesSpec/internal/icon.d.ts.map +1 -0
  87. package/esm/variablesSpec/internal/icon.js +8 -0
  88. package/esm/variablesSpec/internal/icon.js.map +1 -0
  89. package/esm/variablesSpec/internal/modeler.d.ts +3 -0
  90. package/esm/variablesSpec/internal/modeler.d.ts.map +1 -0
  91. package/esm/variablesSpec/internal/modeler.js +13 -0
  92. package/esm/variablesSpec/internal/modeler.js.map +1 -0
  93. package/esm/variablesSpec/internal/spacing.d.ts +3 -0
  94. package/esm/variablesSpec/internal/spacing.d.ts.map +1 -0
  95. package/esm/variablesSpec/internal/spacing.js +33 -0
  96. package/esm/variablesSpec/internal/spacing.js.map +1 -0
  97. package/esm/variablesSpec/internal/transition.d.ts +3 -0
  98. package/esm/variablesSpec/internal/transition.d.ts.map +1 -0
  99. package/esm/variablesSpec/internal/transition.js +8 -0
  100. package/esm/variablesSpec/internal/transition.js.map +1 -0
  101. package/esm/variablesSpec/theme/analytical-designer.d.ts +3 -0
  102. package/esm/variablesSpec/theme/analytical-designer.d.ts.map +1 -0
  103. package/esm/variablesSpec/theme/analytical-designer.js +9 -0
  104. package/esm/variablesSpec/theme/analytical-designer.js.map +1 -0
  105. package/esm/variablesSpec/theme/button.d.ts +3 -0
  106. package/esm/variablesSpec/theme/button.d.ts.map +1 -0
  107. package/esm/variablesSpec/theme/button.js +24 -0
  108. package/esm/variablesSpec/theme/button.js.map +1 -0
  109. package/esm/variablesSpec/theme/chart.d.ts +3 -0
  110. package/esm/variablesSpec/theme/chart.d.ts.map +1 -0
  111. package/esm/variablesSpec/theme/chart.js +70 -0
  112. package/esm/variablesSpec/theme/chart.js.map +1 -0
  113. package/esm/variablesSpec/theme/dashboard.d.ts +3 -0
  114. package/esm/variablesSpec/theme/dashboard.d.ts.map +1 -0
  115. package/esm/variablesSpec/theme/dashboard.js +243 -0
  116. package/esm/variablesSpec/theme/dashboard.js.map +1 -0
  117. package/esm/variablesSpec/theme/kpi.d.ts +3 -0
  118. package/esm/variablesSpec/theme/kpi.d.ts.map +1 -0
  119. package/esm/variablesSpec/theme/kpi.js +33 -0
  120. package/esm/variablesSpec/theme/kpi.js.map +1 -0
  121. package/esm/variablesSpec/theme/modal.d.ts +3 -0
  122. package/esm/variablesSpec/theme/modal.d.ts.map +1 -0
  123. package/esm/variablesSpec/theme/modal.js +47 -0
  124. package/esm/variablesSpec/theme/modal.js.map +1 -0
  125. package/esm/variablesSpec/theme/palette-base.d.ts +3 -0
  126. package/esm/variablesSpec/theme/palette-base.d.ts.map +1 -0
  127. package/esm/variablesSpec/theme/palette-base.js +33 -0
  128. package/esm/variablesSpec/theme/palette-base.js.map +1 -0
  129. package/esm/variablesSpec/theme/palette-complementary.d.ts +3 -0
  130. package/esm/variablesSpec/theme/palette-complementary.d.ts.map +1 -0
  131. package/esm/variablesSpec/theme/palette-complementary.js +63 -0
  132. package/esm/variablesSpec/theme/palette-complementary.js.map +1 -0
  133. package/esm/variablesSpec/theme/table.d.ts +3 -0
  134. package/esm/variablesSpec/theme/table.d.ts.map +1 -0
  135. package/esm/variablesSpec/theme/table.js +69 -0
  136. package/esm/variablesSpec/theme/table.js.map +1 -0
  137. package/esm/variablesSpec/theme/tooltip.d.ts +3 -0
  138. package/esm/variablesSpec/theme/tooltip.d.ts.map +1 -0
  139. package/esm/variablesSpec/theme/tooltip.js +15 -0
  140. package/esm/variablesSpec/theme/tooltip.js.map +1 -0
  141. package/esm/variablesSpec/theme/typography.d.ts +3 -0
  142. package/esm/variablesSpec/theme/typography.d.ts.map +1 -0
  143. package/esm/variablesSpec/theme/typography.js +15 -0
  144. package/esm/variablesSpec/theme/typography.js.map +1 -0
  145. package/esm/variablesSpec/theme-derived/palette-base-derived.d.ts +3 -0
  146. package/esm/variablesSpec/theme-derived/palette-base-derived.d.ts.map +1 -0
  147. package/esm/variablesSpec/theme-derived/palette-base-derived.js +275 -0
  148. package/esm/variablesSpec/theme-derived/palette-base-derived.js.map +1 -0
  149. package/esm/variablesSpec/theme-derived/palette-complementary-derived.d.ts +3 -0
  150. package/esm/variablesSpec/theme-derived/palette-complementary-derived.d.ts.map +1 -0
  151. package/esm/variablesSpec/theme-derived/palette-complementary-derived.js +36 -0
  152. package/esm/variablesSpec/theme-derived/palette-complementary-derived.js.map +1 -0
  153. package/esm/variablesSpec/theme-derived/shadow-derived.d.ts +3 -0
  154. package/esm/variablesSpec/theme-derived/shadow-derived.d.ts.map +1 -0
  155. package/esm/variablesSpec/theme-derived/shadow-derived.js +11 -0
  156. package/esm/variablesSpec/theme-derived/shadow-derived.js.map +1 -0
  157. package/esm/variablesSpec/types.d.ts +104 -0
  158. package/esm/variablesSpec/types.d.ts.map +1 -0
  159. package/esm/variablesSpec/types.js +3 -0
  160. package/esm/variablesSpec/types.js.map +1 -0
  161. package/esm/variablesSpec/validate/log.d.ts +17 -0
  162. package/esm/variablesSpec/validate/log.d.ts.map +1 -0
  163. package/esm/variablesSpec/validate/log.js +30 -0
  164. package/esm/variablesSpec/validate/log.js.map +1 -0
  165. package/esm/variablesSpec/validate/main.d.ts +7 -0
  166. package/esm/variablesSpec/validate/main.d.ts.map +1 -0
  167. package/esm/variablesSpec/validate/main.js +41 -0
  168. package/esm/variablesSpec/validate/main.js.map +1 -0
  169. package/esm/variablesSpec/validate/parse.d.ts +7 -0
  170. package/esm/variablesSpec/validate/parse.d.ts.map +1 -0
  171. package/esm/variablesSpec/validate/parse.js +61 -0
  172. package/esm/variablesSpec/validate/parse.js.map +1 -0
  173. package/esm/variablesSpec/validate/types.d.ts +25 -0
  174. package/esm/variablesSpec/validate/types.d.ts.map +1 -0
  175. package/esm/variablesSpec/validate/types.js +3 -0
  176. package/esm/variablesSpec/validate/types.js.map +1 -0
  177. package/esm/variablesSpec/validate/utils.d.ts +6 -0
  178. package/esm/variablesSpec/validate/utils.d.ts.map +1 -0
  179. package/esm/variablesSpec/validate/utils.js +21 -0
  180. package/esm/variablesSpec/validate/utils.js.map +1 -0
  181. package/esm/variablesSpec/validate/validate.d.ts +42 -0
  182. package/esm/variablesSpec/validate/validate.d.ts.map +1 -0
  183. package/esm/variablesSpec/validate/validate.js +133 -0
  184. package/esm/variablesSpec/validate/validate.js.map +1 -0
  185. package/package.json +15 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/variablesSpec/validate/parse.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,OAAiB,MAAM,SAAS,CAAC;AACxC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAAC,QAAgB,EAAE,WAA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AAE,CAAC;gBAE7B,MAAM,YAAY,GACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBAEzF,SAAS,CAAC,IAAI,CAAC;oBACX,YAAY;oBACZ,YAAY;iBACf,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Specific variable usage in CSS.
3
+ *
4
+ * Example:
5
+ * var(--gd-palette-complementary-0, #fff)
6
+ * is represented as
7
+ * \{
8
+ * variableName: "--gd-palette-complementary-0",
9
+ * defaultValue: "#fff"
10
+ * \}
11
+ *
12
+ * @internal
13
+ */
14
+ export type CssVariableUsage = {
15
+ /**
16
+ * Name of the variable
17
+ */
18
+ variableName: string;
19
+ /**
20
+ * Default value of the variable.
21
+ * If the usage has no default value, it will be `null`.
22
+ */
23
+ defaultValue: string | null;
24
+ };
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/variablesSpec/validate/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ // (C) 2024 GoodData Corporation
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/variablesSpec/validate/types.ts"],"names":[],"mappings":"AAAA,gCAAgC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Group collection by unique key.
3
+ * Throws error if duplicate keys are detected.
4
+ */
5
+ export declare function groupByUnique<T, K extends string>(collection: T[], getUniqueKey: (item: T) => K): Record<K, T>;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/variablesSpec/validate/utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAC7C,UAAU,EAAE,CAAC,EAAE,EACf,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAC7B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAcd"}
@@ -0,0 +1,21 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import groupBy from "lodash/groupBy.js";
3
+ /**
4
+ * Group collection by unique key.
5
+ * Throws error if duplicate keys are detected.
6
+ */
7
+ export function groupByUnique(collection, getUniqueKey) {
8
+ const grouped = groupBy(collection, getUniqueKey);
9
+ const result = {};
10
+ for (const [key, values] of Object.entries(grouped)) {
11
+ if (!values || values.length === 0 || !values[0]) {
12
+ throw new Error(`No values found for key: "${key}"`);
13
+ }
14
+ else if (values.length > 1) {
15
+ throw new Error(`Duplicate keys detected for key: "${key}"`);
16
+ }
17
+ result[key] = values[0]; // Extract the single value
18
+ }
19
+ return result;
20
+ }
21
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/variablesSpec/validate/utils.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,aAAa,CACzB,UAAe,EACf,YAA4B;IAE5B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAClD,MAAM,MAAM,GAAiB,EAAkB,CAAC;IAEhD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,GAAG,CAAC,CAAC;QACzD,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,GAAG,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,CAAC,GAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B;IAC7D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { ThemeCssVariable } from "../types.js";
2
+ import { CssVariableUsage } from "./types.js";
3
+ /**
4
+ * Validation that was skipped.
5
+ * @internal
6
+ */
7
+ type SkipValidationResult = {
8
+ type: "skip";
9
+ variableUsage: CssVariableUsage;
10
+ variableSpecification: ThemeCssVariable;
11
+ };
12
+ /**
13
+ * Validation that was successful.
14
+ * @internal
15
+ */
16
+ type OkValidationResult = {
17
+ type: "ok";
18
+ variableUsage: CssVariableUsage;
19
+ variableSpecification: ThemeCssVariable;
20
+ };
21
+ /**
22
+ * Validation that failed.
23
+ * @internal
24
+ */
25
+ type ErrorValidationResult = {
26
+ type: "error";
27
+ error: string;
28
+ variableUsage: CssVariableUsage;
29
+ variableSpecification?: ThemeCssVariable;
30
+ };
31
+ /**
32
+ * Validate all variable usages against their specifications and return the results.
33
+ * @internal
34
+ */
35
+ export declare function validateAllVariableUsages(allVariableUsages: CssVariableUsage[]): {
36
+ failed: ErrorValidationResult[];
37
+ skipped: SkipValidationResult[];
38
+ success: OkValidationResult[];
39
+ allValidationsCount: number;
40
+ };
41
+ export {};
42
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/variablesSpec/validate/validate.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,gBAAgB,EAGnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,gBAAgB,CAAC;IAChC,qBAAqB,EAAE,gBAAgB,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,aAAa,EAAE,gBAAgB,CAAC;IAChC,qBAAqB,EAAE,gBAAgB,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,gBAAgB,CAAC;IAChC,qBAAqB,CAAC,EAAE,gBAAgB,CAAC;CAC5C,CAAC;AAQF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,iBAAiB,EAAE,gBAAgB,EAAE;;;;;EAwC9E"}
@@ -0,0 +1,133 @@
1
+ // (C) 2024 GoodData Corporation
2
+ import { allThemeCssVariables } from "../allThemeCssVariables.js";
3
+ import { groupByUnique } from "./utils.js";
4
+ /**
5
+ * Validate all variable usages against their specifications and return the results.
6
+ * @internal
7
+ */
8
+ export function validateAllVariableUsages(allVariableUsages) {
9
+ // Group all specifications by variable name
10
+ const variableSpecificationByVariableName = groupByUnique(allThemeCssVariables, (v) => v.variableName);
11
+ const failed = [];
12
+ const skipped = [];
13
+ const success = [];
14
+ for (const variableUsage of allVariableUsages) {
15
+ // Get specification relevant for the CSS variable usage
16
+ const variableSpecification = variableSpecificationByVariableName[variableUsage.variableName];
17
+ // Validate the CSS variable usage against the specification
18
+ const validationResult = validateVariableUsage(variableUsage, variableSpecification);
19
+ if (validationResult.type === "skip") {
20
+ skipped.push(validationResult);
21
+ }
22
+ else if (validationResult.type === "error") {
23
+ failed.push(validationResult);
24
+ }
25
+ else if (validationResult.type === "ok") {
26
+ success.push(validationResult);
27
+ }
28
+ else {
29
+ throw new Error(`Unhandled validation result: ${JSON.stringify(validationResult, null, 2)}`);
30
+ }
31
+ }
32
+ const allValidationsCount = failed.length + skipped.length + success.length;
33
+ if (allValidationsCount !== allVariableUsages.length) {
34
+ throw new Error(`Validations count ${allValidationsCount} does not match the number of variable usages ${allVariableUsages.length}`);
35
+ }
36
+ return {
37
+ failed,
38
+ skipped,
39
+ success,
40
+ allValidationsCount,
41
+ };
42
+ }
43
+ /**
44
+ * Validate variable usage, according to its specification.
45
+ */
46
+ function validateVariableUsage(variableUsage, variableSpecification) {
47
+ if (!variableSpecification) {
48
+ if (variableUsage.variableName.startsWith("--gd")) {
49
+ return errorValidationResult(`Variable specification for ${variableUsage.variableName} is missing! Used value: ${variableUsage.defaultValue}`, variableUsage);
50
+ }
51
+ else {
52
+ // Do not validate external variables
53
+ return skippedValidationResult(variableUsage, variableSpecification);
54
+ }
55
+ }
56
+ if (variableSpecification.type === "deprecated") {
57
+ return validateDeprecatedVariableUsage(variableUsage, variableSpecification);
58
+ }
59
+ else if (variableSpecification.type === "inconsistent") {
60
+ return validateInconsistentVariableUsage(variableUsage, variableSpecification);
61
+ }
62
+ else if (["theme", "derived", "internal"].includes(variableSpecification.type)) {
63
+ return validateThemeVariableUsage(variableUsage, variableSpecification);
64
+ }
65
+ throw new Error(`Unhandled exception: ${JSON.stringify(variableUsage, null, 2)} ${JSON.stringify(variableSpecification, null, 2)}`);
66
+ }
67
+ /**
68
+ * Deprecated variable usage validation.
69
+ * It should:
70
+ * - not be used in the CSS
71
+ */
72
+ function validateDeprecatedVariableUsage(variableUsage, variableSpecification) {
73
+ return errorValidationResult(`CSS variable ${variableUsage.variableName} is deprecated, but found in the CSS!`, variableUsage, variableSpecification);
74
+ }
75
+ /**
76
+ * Inconsistent variable usage validation.
77
+ * It should either:
78
+ * - not have default value specified in the CSS
79
+ * - have default value that matches inconsistent defaults in the specification
80
+ */
81
+ function validateInconsistentVariableUsage(variableUsage, variableSpecification) {
82
+ if (!variableUsage.defaultValue) {
83
+ return skippedValidationResult(variableUsage, variableSpecification);
84
+ }
85
+ else if (!variableSpecification.inconsistentDefaults.some((d) => normalizeCssVariableValue(d) === normalizeCssVariableValue(variableUsage.defaultValue))) {
86
+ return errorValidationResult(`CSS variable ${normalizeCssVariableValue(variableUsage.variableName)} has default value ${normalizeCssVariableValue(variableUsage.defaultValue)}, which is missing in the specification!`, variableUsage, variableSpecification);
87
+ }
88
+ return okValidationResult(variableUsage, variableSpecification);
89
+ }
90
+ /**
91
+ * Theme variable usage validation.
92
+ * It should either:
93
+ * - be skipped (when skipDefaultValueValidation is set to true in the specification)
94
+ * - not have default value specified in the CSS
95
+ * - have default value that matches default value in the specification
96
+ */
97
+ function validateThemeVariableUsage(variableUsage, variableSpecification) {
98
+ if ("skipDefaultValueValidation" in variableSpecification &&
99
+ variableSpecification.skipDefaultValueValidation) {
100
+ return skippedValidationResult(variableUsage, variableSpecification);
101
+ }
102
+ else if (variableUsage.defaultValue !== null &&
103
+ normalizeCssVariableValue(variableUsage.defaultValue) !==
104
+ normalizeCssVariableValue(variableSpecification.defaultValue)) {
105
+ return errorValidationResult(`Css variable ${variableUsage.variableName} has different default value ${normalizeCssVariableValue(variableUsage.defaultValue)} in the CSS than in the specification ${normalizeCssVariableValue(variableSpecification.defaultValue)}!`, variableUsage, variableSpecification);
106
+ }
107
+ return okValidationResult(variableUsage, variableSpecification);
108
+ }
109
+ /**
110
+ * Validation result that was skipped.
111
+ */
112
+ function skippedValidationResult(variableUsage, variableSpecification) {
113
+ return { type: "skip", variableUsage, variableSpecification };
114
+ }
115
+ /**
116
+ * Validation result that was successful.
117
+ */
118
+ function okValidationResult(variableUsage, variableSpecification) {
119
+ return { type: "ok", variableUsage, variableSpecification };
120
+ }
121
+ /**
122
+ * Validation result that failed.
123
+ */
124
+ function errorValidationResult(error, variableUsage, variableSpecification) {
125
+ return { type: "error", error, variableUsage, variableSpecification };
126
+ }
127
+ /**
128
+ * Minified CSS can have 0. replaced with ., and missing white spaces, so we need to normalize the value.
129
+ */
130
+ function normalizeCssVariableValue(value) {
131
+ return value.replace("0.", ".").replace(/\s+/g, "");
132
+ }
133
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/variablesSpec/validate/validate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAgD3C;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,iBAAqC;IAC3E,4CAA4C;IAC5C,MAAM,mCAAmC,GAAG,aAAa,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAEvG,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAyB,EAAE,CAAC;IAEzC,KAAK,MAAM,aAAa,IAAI,iBAAiB,EAAE,CAAC;QAC5C,wDAAwD;QACxD,MAAM,qBAAqB,GAAG,mCAAmC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAE9F,4DAA4D;QAC5D,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;QAErF,IAAI,gBAAgB,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,CAAC;aAAM,IAAI,gBAAgB,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;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C,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-ui-theme-provider",
3
- "version": "10.17.0-alpha.7",
3
+ "version": "10.17.0-alpha.9",
4
4
  "description": "GoodData SDK - Theme provider",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,11 @@
10
10
  "author": "GoodData Corporation",
11
11
  "license": "MIT",
12
12
  "type": "module",
13
- "exports": "./esm/index.js",
13
+ "exports": {
14
+ ".": "./esm/index.js",
15
+ "./node": "./esm/node.js",
16
+ "./internal": "./esm/internal.js"
17
+ },
14
18
  "types": "./esm/index.d.ts",
15
19
  "sideEffects": false,
16
20
  "files": [
@@ -20,13 +24,17 @@
20
24
  "esm/**/*.map"
21
25
  ],
22
26
  "dependencies": {
27
+ "chalk": "^4.1.1",
28
+ "glob": "^11.0.0",
23
29
  "lodash": "^4.17.21",
30
+ "postcss": "^8.4.49",
31
+ "postcss-value-parser": "^4.2.0",
24
32
  "polished": "^3.6.7",
25
33
  "ts-invariant": "^0.7.5",
26
34
  "tslib": "^2.5.0",
27
- "@gooddata/sdk-model": "10.17.0-alpha.7",
28
- "@gooddata/sdk-backend-spi": "10.17.0-alpha.7",
29
- "@gooddata/sdk-ui": "10.17.0-alpha.7"
35
+ "@gooddata/sdk-backend-spi": "10.17.0-alpha.9",
36
+ "@gooddata/sdk-model": "10.17.0-alpha.9",
37
+ "@gooddata/sdk-ui": "10.17.0-alpha.9"
30
38
  },
31
39
  "peerDependencies": {
32
40
  "react": "^16.10.0 || ^17.0.0 || ^18.0.0",
@@ -65,8 +73,8 @@
65
73
  "react-dom": "^18.2.0",
66
74
  "typescript": "5.3.3",
67
75
  "vitest": "1.0.4",
68
- "@gooddata/reference-workspace": "10.17.0-alpha.7",
69
- "@gooddata/sdk-backend-mockingbird": "10.17.0-alpha.7"
76
+ "@gooddata/reference-workspace": "10.17.0-alpha.9",
77
+ "@gooddata/sdk-backend-mockingbird": "10.17.0-alpha.9"
70
78
  },
71
79
  "scripts": {
72
80
  "clean": "rm -rf ci dist esm coverage *.log tsconfig.tsbuildinfo",