igniteui-theming 25.1.0 → 25.2.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.
Files changed (128) hide show
  1. package/dist/index.d.ts +75 -0
  2. package/dist/index.js +12 -0
  3. package/dist/json/components/bootstrap.json +1 -0
  4. package/dist/json/components/fluent.json +1 -0
  5. package/dist/json/components/indigo.json +1 -0
  6. package/dist/json/components/material.json +1 -0
  7. package/{json → dist/json}/components/themes.json +31 -1
  8. package/dist/mcp/generators/css.d.ts +7 -4
  9. package/dist/mcp/generators/css.js +129 -104
  10. package/dist/mcp/generators/sass.js +227 -254
  11. package/dist/mcp/index.js +259 -323
  12. package/dist/mcp/knowledge/color-usage.js +524 -502
  13. package/dist/mcp/knowledge/colors.js +61 -50
  14. package/dist/mcp/knowledge/component-metadata.js +697 -598
  15. package/dist/mcp/knowledge/component-themes.js +70 -57
  16. package/dist/mcp/knowledge/custom-palettes.js +4 -9
  17. package/dist/mcp/knowledge/docs/colors/guidance.js +4 -0
  18. package/dist/mcp/knowledge/docs/colors/usage.js +4 -0
  19. package/dist/mcp/knowledge/docs/layout/functions/border-radius.js +4 -0
  20. package/dist/mcp/knowledge/docs/layout/functions/pad.js +4 -0
  21. package/dist/mcp/knowledge/docs/layout/functions/sizable.js +4 -0
  22. package/dist/mcp/knowledge/docs/layout/mixins/sizable.js +4 -0
  23. package/dist/mcp/knowledge/docs/layout/mixins/sizing.js +4 -0
  24. package/dist/mcp/knowledge/docs/layout/mixins/spacing.js +4 -0
  25. package/dist/mcp/knowledge/docs/layout/overview.js +4 -0
  26. package/dist/mcp/knowledge/docs/setup/platform.js +4 -0
  27. package/dist/mcp/knowledge/elevations.d.ts +1 -1
  28. package/dist/mcp/knowledge/elevations.js +26 -12
  29. package/dist/mcp/knowledge/index.js +23 -87
  30. package/dist/mcp/knowledge/layout-docs.d.ts +1 -1
  31. package/dist/mcp/knowledge/multipliers.js +5 -0
  32. package/dist/mcp/knowledge/palettes.js +29 -17
  33. package/dist/mcp/knowledge/platforms/angular.js +98 -120
  34. package/dist/mcp/knowledge/platforms/blazor.js +39 -34
  35. package/dist/mcp/knowledge/platforms/common.js +83 -68
  36. package/dist/mcp/knowledge/platforms/index.js +265 -242
  37. package/dist/mcp/knowledge/platforms/react.js +43 -35
  38. package/dist/mcp/knowledge/platforms/webcomponents.js +266 -292
  39. package/dist/mcp/knowledge/sass-api.js +1 -0
  40. package/dist/mcp/knowledge/typography.js +13 -5
  41. package/dist/mcp/resources/index.js +1 -0
  42. package/dist/mcp/resources/presets.js +409 -508
  43. package/dist/mcp/theming/dist/json/colors/meta/multipliers.js +50 -0
  44. package/dist/mcp/theming/dist/json/colors/presets/palettes.js +85 -0
  45. package/dist/mcp/theming/dist/json/components/themes.js +5792 -0
  46. package/dist/mcp/theming/dist/json/elevations/indigo.js +29 -0
  47. package/dist/mcp/theming/dist/json/elevations/material.js +3 -0
  48. package/dist/mcp/theming/dist/json/typography/presets/typescales.js +621 -0
  49. package/dist/mcp/tools/descriptions.js +98 -154
  50. package/dist/mcp/tools/handlers/color.js +58 -56
  51. package/dist/mcp/tools/handlers/component-theme.js +163 -225
  52. package/dist/mcp/tools/handlers/component-tokens.js +159 -219
  53. package/dist/mcp/tools/handlers/custom-palette.js +138 -179
  54. package/dist/mcp/tools/handlers/elevations.js +27 -28
  55. package/dist/mcp/tools/handlers/index.js +11 -0
  56. package/dist/mcp/tools/handlers/layout.js +125 -176
  57. package/dist/mcp/tools/handlers/palette.js +105 -120
  58. package/dist/mcp/tools/handlers/platform.js +289 -311
  59. package/dist/mcp/tools/handlers/resource.js +22 -31
  60. package/dist/mcp/tools/handlers/theme.js +86 -103
  61. package/dist/mcp/tools/handlers/typography.js +29 -30
  62. package/dist/mcp/tools/index.js +13 -0
  63. package/dist/mcp/tools/schemas.js +239 -218
  64. package/dist/mcp/utils/color.js +277 -239
  65. package/dist/mcp/utils/preprocessing.js +57 -30
  66. package/dist/mcp/utils/result.js +43 -45
  67. package/dist/mcp/utils/sass.js +271 -191
  68. package/dist/mcp/utils/theming-resolve.d.ts +19 -0
  69. package/dist/mcp/utils/theming-resolve.js +57 -0
  70. package/dist/mcp/utils/types.js +96 -53
  71. package/dist/mcp/validators/custom-palette.js +218 -243
  72. package/dist/mcp/validators/index.js +3 -0
  73. package/dist/mcp/validators/palette.js +231 -229
  74. package/dist/tailwind/utilities/bootstrap.css +1 -0
  75. package/dist/tailwind/utilities/fluent.css +1 -0
  76. package/dist/tailwind/utilities/indigo.css +1 -0
  77. package/dist/tailwind/utilities/material.css +1 -0
  78. package/package.json +45 -64
  79. package/sass/json/README.md +12 -7
  80. package/sass/themes/_mixins.scss +1 -0
  81. package/sass/themes/components/button-group/_button-group-theme.scss +42 -0
  82. package/sass/themes/components/grid/_grid-theme.scss +1 -1
  83. package/sass/themes/schemas/components/dark/_button-group.scss +173 -50
  84. package/sass/themes/schemas/components/dark/_grid.scss +0 -16
  85. package/sass/themes/schemas/components/light/_button-group.scss +221 -99
  86. package/sass/themes/schemas/components/light/_grid.scss +14 -20
  87. package/LICENSE +0 -21
  88. package/README.md +0 -391
  89. package/dist/mcp/json/colors/presets/palettes.json.js +0 -13
  90. package/dist/mcp/json/components/themes.json.js +0 -143
  91. package/dist/mcp/json/elevations/indigo.json.js +0 -8
  92. package/dist/mcp/json/elevations/material.json.js +0 -8
  93. package/dist/mcp/json/typography/presets/typescales.json.js +0 -17
  94. package/dist/mcp/knowledge/docs/colors/guidance.md.js +0 -4
  95. package/dist/mcp/knowledge/docs/colors/usage.md.js +0 -4
  96. package/dist/mcp/knowledge/docs/layout/functions/border-radius.md.js +0 -4
  97. package/dist/mcp/knowledge/docs/layout/functions/pad.md.js +0 -4
  98. package/dist/mcp/knowledge/docs/layout/functions/sizable.md.js +0 -4
  99. package/dist/mcp/knowledge/docs/layout/mixins/sizable.md.js +0 -4
  100. package/dist/mcp/knowledge/docs/layout/mixins/sizing.md.js +0 -4
  101. package/dist/mcp/knowledge/docs/layout/mixins/spacing.md.js +0 -4
  102. package/dist/mcp/knowledge/docs/layout/overview.md.js +0 -4
  103. package/dist/mcp/knowledge/docs/setup/platform.md.js +0 -4
  104. package/dist/mcp/vite-env.d.ts +0 -18
  105. package/index.js +0 -5
  106. package/json/components/bootstrap.json +0 -1
  107. package/json/components/fluent.json +0 -1
  108. package/json/components/indigo.json +0 -1
  109. package/json/components/material.json +0 -1
  110. package/tailwind/utilities/bootstrap.css +0 -1
  111. package/tailwind/utilities/fluent.css +0 -1
  112. package/tailwind/utilities/indigo.css +0 -1
  113. package/tailwind/utilities/material.css +0 -1
  114. /package/{json → dist/json}/colors/meta/multipliers.json +0 -0
  115. /package/{json → dist/json}/colors/meta/palette.json +0 -0
  116. /package/{json → dist/json}/colors/presets/palettes.json +0 -0
  117. /package/{json → dist/json}/elevations/indigo.json +0 -0
  118. /package/{json → dist/json}/elevations/material.json +0 -0
  119. /package/{json → dist/json}/typography/presets/typescales.json +0 -0
  120. /package/{tailwind → dist/tailwind}/themes/base.css +0 -0
  121. /package/{tailwind → dist/tailwind}/themes/dark/bootstrap.css +0 -0
  122. /package/{tailwind → dist/tailwind}/themes/dark/fluent.css +0 -0
  123. /package/{tailwind → dist/tailwind}/themes/dark/indigo.css +0 -0
  124. /package/{tailwind → dist/tailwind}/themes/dark/material.css +0 -0
  125. /package/{tailwind → dist/tailwind}/themes/light/bootstrap.css +0 -0
  126. /package/{tailwind → dist/tailwind}/themes/light/fluent.css +0 -0
  127. /package/{tailwind → dist/tailwind}/themes/light/indigo.css +0 -0
  128. /package/{tailwind → dist/tailwind}/themes/light/material.css +0 -0
@@ -1,23 +1,35 @@
1
- import * as path from "node:path";
2
- import { fileURLToPath } from "node:url";
1
+ import { themingImporter } from "../utils/theming-resolve.js";
3
2
  import * as sass from "sass-embedded";
4
- const __filename$1 = fileURLToPath(import.meta.url);
5
- const __dirname$1 = path.dirname(__filename$1);
6
- const PACKAGE_ROOT = path.resolve(__dirname$1, "..", "..", "..");
3
+ //#region src/generators/css.ts
4
+ /**
5
+ * Generate CSS custom properties for a standard palette.
6
+ *
7
+ * This function compiles Sass code that uses the palette() function and
8
+ * @include palette() mixin, then returns the compiled CSS output.
9
+ *
10
+ * @example
11
+ * const result = await generatePaletteCss({
12
+ * primary: '#1976d2',
13
+ * secondary: '#ff9800',
14
+ * surface: '#fafafa',
15
+ * variant: 'light'
16
+ * });
17
+ * // result.css contains :root { --ig-primary-50: ...; --ig-primary-100: ...; ... }
18
+ */
7
19
  async function generatePaletteCss(options) {
8
- const variant = options.variant ?? "light";
9
- const paletteArgs = [
10
- `$primary: ${options.primary}`,
11
- `$secondary: ${options.secondary}`,
12
- `$surface: ${options.surface}`
13
- ];
14
- if (options.gray) paletteArgs.push(`$gray: ${options.gray}`);
15
- if (options.info) paletteArgs.push(`$info: ${options.info}`);
16
- if (options.success) paletteArgs.push(`$success: ${options.success}`);
17
- if (options.warn) paletteArgs.push(`$warn: ${options.warn}`);
18
- if (options.error) paletteArgs.push(`$error: ${options.error}`);
19
- const sassCode = `
20
- @use 'sass/color' as *;
20
+ const variant = options.variant ?? "light";
21
+ const paletteArgs = [
22
+ `$primary: ${options.primary}`,
23
+ `$secondary: ${options.secondary}`,
24
+ `$surface: ${options.surface}`
25
+ ];
26
+ if (options.gray) paletteArgs.push(`$gray: ${options.gray}`);
27
+ if (options.info) paletteArgs.push(`$info: ${options.info}`);
28
+ if (options.success) paletteArgs.push(`$success: ${options.success}`);
29
+ if (options.warn) paletteArgs.push(`$warn: ${options.warn}`);
30
+ if (options.error) paletteArgs.push(`$error: ${options.error}`);
31
+ const sassCode = `
32
+ @use 'igniteui-theming/sass/color' as *;
21
33
 
22
34
  $palette: palette(
23
35
  ${paletteArgs.join(",\n ")}
@@ -25,83 +37,101 @@ $palette: palette(
25
37
 
26
38
  @include palette($palette);
27
39
  `;
28
- try {
29
- const loadPaths = options._loadPaths ?? [PACKAGE_ROOT];
30
- const result = await sass.compileStringAsync(sassCode, {
31
- loadPaths,
32
- style: "expanded"
33
- });
34
- return {
35
- css: result.css,
36
- description: `Generated CSS custom properties for a ${variant} palette with primary color ${options.primary}`
37
- };
38
- } catch (error) {
39
- const message = error instanceof Error ? error.message : String(error);
40
- throw new Error(`Failed to compile palette CSS: ${message}`);
41
- }
40
+ try {
41
+ const importers = options._importers ?? [themingImporter];
42
+ return {
43
+ css: (await sass.compileStringAsync(sassCode, {
44
+ importers,
45
+ style: "expanded"
46
+ })).css,
47
+ description: `Generated CSS custom properties for a ${variant} palette with primary color ${options.primary}`
48
+ };
49
+ } catch (error) {
50
+ const message = error instanceof Error ? error.message : String(error);
51
+ throw new Error(`Failed to compile palette CSS: ${message}`);
52
+ }
42
53
  }
54
+ /**
55
+ * Generate CSS custom properties for a custom palette.
56
+ *
57
+ * This function generates Sass code for the custom palette structure
58
+ * (using either shades() function or explicit values), compiles it,
59
+ * and returns the CSS output.
60
+ */
43
61
  async function generateCustomPaletteCss(options) {
44
- const variant = options.variant ?? "light";
45
- const { generateCustomPaletteCode } = await import("../utils/sass.js");
46
- const paletteLines = generateCustomPaletteCode({
47
- variant,
48
- variableName: "custom",
49
- surfaceColor: options.surfaceColor,
50
- colors: options.colors
51
- });
52
- const sassCode = `
53
- @use 'sass/color' as *;
62
+ const variant = options.variant ?? "light";
63
+ const { generateCustomPaletteCode } = await import("../utils/sass.js");
64
+ const sassCode = `
65
+ @use 'igniteui-theming/sass/color' as *;
54
66
 
55
- ${paletteLines.join("\n")}
67
+ ${generateCustomPaletteCode({
68
+ variant,
69
+ variableName: "custom",
70
+ surfaceColor: options.surfaceColor,
71
+ colors: options.colors
72
+ }).join("\n")}
56
73
 
57
74
  @include palette($custom-palette);
58
75
  `;
59
- try {
60
- const loadPaths = options._loadPaths ?? [PACKAGE_ROOT];
61
- const result = await sass.compileStringAsync(sassCode, {
62
- loadPaths,
63
- style: "expanded"
64
- });
65
- return {
66
- css: result.css,
67
- description: `Generated CSS custom properties for a custom ${variant} palette`
68
- };
69
- } catch (error) {
70
- const message = error instanceof Error ? error.message : String(error);
71
- throw new Error(`Failed to compile custom palette CSS: ${message}`);
72
- }
76
+ try {
77
+ const importers = options._importers ?? [themingImporter];
78
+ return {
79
+ css: (await sass.compileStringAsync(sassCode, {
80
+ importers,
81
+ style: "expanded"
82
+ })).css,
83
+ description: `Generated CSS custom properties for a custom ${variant} palette`
84
+ };
85
+ } catch (error) {
86
+ const message = error instanceof Error ? error.message : String(error);
87
+ throw new Error(`Failed to compile custom palette CSS: ${message}`);
88
+ }
73
89
  }
90
+ /**
91
+ * Format CSS output for display.
92
+ * Adds a header comment and ensures consistent formatting.
93
+ */
74
94
  function formatCssOutput(css, description) {
75
- const header = `/* Generated by Ignite UI Theming MCP Server */
95
+ return `/* Generated by Ignite UI Theming MCP Server */
76
96
  /* ${description} */
77
- `;
78
- return header + css;
97
+ ` + css;
79
98
  }
99
+ /**
100
+ * Generate CSS custom properties for a component theme.
101
+ *
102
+ * This function compiles Sass code that uses the component theme function
103
+ * and @include tokens() mixin, then returns the compiled CSS output.
104
+ *
105
+ * @example
106
+ * const result = await generateComponentThemeCss({
107
+ * platform: 'webcomponents',
108
+ * designSystem: 'bootstrap',
109
+ * variant: 'light',
110
+ * component: 'button',
111
+ * tokens: { background: '#1976d2', 'text-color': 'white' },
112
+ * selector: 'igc-button'
113
+ * });
114
+ * // result.css contains: igc-button { --ig-button-background: var(--ig-button-background, #1976d2); ... }
115
+ */
80
116
  async function generateComponentThemeCss(options) {
81
- const { getComponentTheme, getComponentSelector, SCHEMA_PRESETS } = await import("../knowledge/index.js");
82
- const { toVariableName } = await import("../utils/sass.js");
83
- const theme = getComponentTheme(options.component);
84
- if (!theme) {
85
- throw new Error(`Unknown component: ${options.component}`);
86
- }
87
- const designSystem = options.designSystem ?? "material";
88
- const variant = options.variant ?? "light";
89
- const themeFn = theme.themeFunctionName;
90
- const themeName = options.name ? `$${toVariableName(options.name)}` : `$custom-${options.component}-theme`;
91
- const schemaVar = SCHEMA_PRESETS[variant][designSystem];
92
- const tokenArgs = [`$schema: ${schemaVar}`];
93
- for (const [tokenName, value] of Object.entries(options.tokens)) {
94
- const stringValue = typeof value === "number" ? String(value) : value;
95
- tokenArgs.push(`$${tokenName}: ${stringValue}`);
96
- }
97
- const defaultSelectors = getComponentSelector(
98
- options.component,
99
- options.platform
100
- );
101
- const selector = options.selector || (defaultSelectors.length > 0 ? defaultSelectors[0] : options.component);
102
- const sassCode = `
103
- @use 'sass/themes' as *;
104
- @use 'sass/themes/schemas' as *;
117
+ const { getComponentTheme, getComponentSelector, SCHEMA_PRESETS } = await import("../knowledge/index.js");
118
+ const { toVariableName } = await import("../utils/sass.js");
119
+ const theme = getComponentTheme(options.component);
120
+ if (!theme) throw new Error(`Unknown component: ${options.component}`);
121
+ const designSystem = options.designSystem ?? "material";
122
+ const variant = options.variant ?? "light";
123
+ const themeFn = theme.themeFunctionName;
124
+ const themeName = options.name ? `$${toVariableName(options.name)}` : `$custom-${options.component}-theme`;
125
+ const tokenArgs = [`$schema: ${SCHEMA_PRESETS[variant][designSystem]}`];
126
+ for (const [tokenName, value] of Object.entries(options.tokens)) {
127
+ const stringValue = typeof value === "number" ? String(value) : value;
128
+ tokenArgs.push(`$${tokenName}: ${stringValue}`);
129
+ }
130
+ const defaultSelectors = getComponentSelector(options.component, options.platform);
131
+ const selector = options.selector || (defaultSelectors.length > 0 ? defaultSelectors[0] : options.component);
132
+ const sassCode = `
133
+ @use 'igniteui-theming/sass/themes' as *;
134
+ @use 'igniteui-theming/sass/themes/schemas' as *;
105
135
 
106
136
  // Custom ${options.component} theme
107
137
  ${themeName}: ${themeFn}(
@@ -113,24 +143,19 @@ ${selector} {
113
143
  @include tokens(${themeName});
114
144
  }
115
145
  `;
116
- try {
117
- const loadPaths = options._loadPaths ?? [PACKAGE_ROOT];
118
- const result = await sass.compileStringAsync(sassCode, {
119
- loadPaths,
120
- style: "expanded"
121
- });
122
- return {
123
- css: result.css,
124
- description: `Generated CSS custom properties for ${options.component} component with ${Object.keys(options.tokens).length} token(s) using ${designSystem} design system (${variant} variant)`
125
- };
126
- } catch (error) {
127
- const message = error instanceof Error ? error.message : String(error);
128
- throw new Error(`Failed to compile component theme CSS: ${message}`);
129
- }
146
+ try {
147
+ const importers = options._importers ?? [themingImporter];
148
+ return {
149
+ css: (await sass.compileStringAsync(sassCode, {
150
+ importers,
151
+ style: "expanded"
152
+ })).css,
153
+ description: `Generated CSS custom properties for ${options.component} component with ${Object.keys(options.tokens).length} token(s) using ${designSystem} design system (${variant} variant)`
154
+ };
155
+ } catch (error) {
156
+ const message = error instanceof Error ? error.message : String(error);
157
+ throw new Error(`Failed to compile component theme CSS: ${message}`);
158
+ }
130
159
  }
131
- export {
132
- formatCssOutput,
133
- generateComponentThemeCss,
134
- generateCustomPaletteCss,
135
- generatePaletteCss
136
- };
160
+ //#endregion
161
+ export { formatCssOutput, generateComponentThemeCss, generateCustomPaletteCss, generatePaletteCss };