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.
- package/dist/index.d.ts +75 -0
- package/dist/index.js +12 -0
- package/dist/json/components/bootstrap.json +1 -0
- package/dist/json/components/fluent.json +1 -0
- package/dist/json/components/indigo.json +1 -0
- package/dist/json/components/material.json +1 -0
- package/{json → dist/json}/components/themes.json +31 -1
- package/dist/mcp/generators/css.d.ts +7 -4
- package/dist/mcp/generators/css.js +129 -104
- package/dist/mcp/generators/sass.js +227 -254
- package/dist/mcp/index.js +259 -323
- package/dist/mcp/knowledge/color-usage.js +524 -502
- package/dist/mcp/knowledge/colors.js +61 -50
- package/dist/mcp/knowledge/component-metadata.js +697 -598
- package/dist/mcp/knowledge/component-themes.js +70 -57
- package/dist/mcp/knowledge/custom-palettes.js +4 -9
- package/dist/mcp/knowledge/docs/colors/guidance.js +4 -0
- package/dist/mcp/knowledge/docs/colors/usage.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/border-radius.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/pad.js +4 -0
- package/dist/mcp/knowledge/docs/layout/functions/sizable.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/sizable.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/sizing.js +4 -0
- package/dist/mcp/knowledge/docs/layout/mixins/spacing.js +4 -0
- package/dist/mcp/knowledge/docs/layout/overview.js +4 -0
- package/dist/mcp/knowledge/docs/setup/platform.js +4 -0
- package/dist/mcp/knowledge/elevations.d.ts +1 -1
- package/dist/mcp/knowledge/elevations.js +26 -12
- package/dist/mcp/knowledge/index.js +23 -87
- package/dist/mcp/knowledge/layout-docs.d.ts +1 -1
- package/dist/mcp/knowledge/multipliers.js +5 -0
- package/dist/mcp/knowledge/palettes.js +29 -17
- package/dist/mcp/knowledge/platforms/angular.js +98 -120
- package/dist/mcp/knowledge/platforms/blazor.js +39 -34
- package/dist/mcp/knowledge/platforms/common.js +83 -68
- package/dist/mcp/knowledge/platforms/index.js +265 -242
- package/dist/mcp/knowledge/platforms/react.js +43 -35
- package/dist/mcp/knowledge/platforms/webcomponents.js +266 -292
- package/dist/mcp/knowledge/sass-api.js +1 -0
- package/dist/mcp/knowledge/typography.js +13 -5
- package/dist/mcp/resources/index.js +1 -0
- package/dist/mcp/resources/presets.js +409 -508
- package/dist/mcp/theming/dist/json/colors/meta/multipliers.js +50 -0
- package/dist/mcp/theming/dist/json/colors/presets/palettes.js +85 -0
- package/dist/mcp/theming/dist/json/components/themes.js +5792 -0
- package/dist/mcp/theming/dist/json/elevations/indigo.js +29 -0
- package/dist/mcp/theming/dist/json/elevations/material.js +3 -0
- package/dist/mcp/theming/dist/json/typography/presets/typescales.js +621 -0
- package/dist/mcp/tools/descriptions.js +98 -154
- package/dist/mcp/tools/handlers/color.js +58 -56
- package/dist/mcp/tools/handlers/component-theme.js +163 -225
- package/dist/mcp/tools/handlers/component-tokens.js +159 -219
- package/dist/mcp/tools/handlers/custom-palette.js +138 -179
- package/dist/mcp/tools/handlers/elevations.js +27 -28
- package/dist/mcp/tools/handlers/index.js +11 -0
- package/dist/mcp/tools/handlers/layout.js +125 -176
- package/dist/mcp/tools/handlers/palette.js +105 -120
- package/dist/mcp/tools/handlers/platform.js +289 -311
- package/dist/mcp/tools/handlers/resource.js +22 -31
- package/dist/mcp/tools/handlers/theme.js +86 -103
- package/dist/mcp/tools/handlers/typography.js +29 -30
- package/dist/mcp/tools/index.js +13 -0
- package/dist/mcp/tools/schemas.js +239 -218
- package/dist/mcp/utils/color.js +277 -239
- package/dist/mcp/utils/preprocessing.js +57 -30
- package/dist/mcp/utils/result.js +43 -45
- package/dist/mcp/utils/sass.js +271 -191
- package/dist/mcp/utils/theming-resolve.d.ts +19 -0
- package/dist/mcp/utils/theming-resolve.js +57 -0
- package/dist/mcp/utils/types.js +96 -53
- package/dist/mcp/validators/custom-palette.js +218 -243
- package/dist/mcp/validators/index.js +3 -0
- package/dist/mcp/validators/palette.js +231 -229
- package/dist/tailwind/utilities/bootstrap.css +1 -0
- package/dist/tailwind/utilities/fluent.css +1 -0
- package/dist/tailwind/utilities/indigo.css +1 -0
- package/dist/tailwind/utilities/material.css +1 -0
- package/package.json +45 -64
- package/sass/json/README.md +12 -7
- package/sass/themes/_mixins.scss +1 -0
- package/sass/themes/components/button-group/_button-group-theme.scss +42 -0
- package/sass/themes/components/grid/_grid-theme.scss +1 -1
- package/sass/themes/schemas/components/dark/_button-group.scss +173 -50
- package/sass/themes/schemas/components/dark/_grid.scss +0 -16
- package/sass/themes/schemas/components/light/_button-group.scss +221 -99
- package/sass/themes/schemas/components/light/_grid.scss +14 -20
- package/LICENSE +0 -21
- package/README.md +0 -391
- package/dist/mcp/json/colors/presets/palettes.json.js +0 -13
- package/dist/mcp/json/components/themes.json.js +0 -143
- package/dist/mcp/json/elevations/indigo.json.js +0 -8
- package/dist/mcp/json/elevations/material.json.js +0 -8
- package/dist/mcp/json/typography/presets/typescales.json.js +0 -17
- package/dist/mcp/knowledge/docs/colors/guidance.md.js +0 -4
- package/dist/mcp/knowledge/docs/colors/usage.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/border-radius.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/pad.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/functions/sizable.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/sizable.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/sizing.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/mixins/spacing.md.js +0 -4
- package/dist/mcp/knowledge/docs/layout/overview.md.js +0 -4
- package/dist/mcp/knowledge/docs/setup/platform.md.js +0 -4
- package/dist/mcp/vite-env.d.ts +0 -18
- package/index.js +0 -5
- package/json/components/bootstrap.json +0 -1
- package/json/components/fluent.json +0 -1
- package/json/components/indigo.json +0 -1
- package/json/components/material.json +0 -1
- package/tailwind/utilities/bootstrap.css +0 -1
- package/tailwind/utilities/fluent.css +0 -1
- package/tailwind/utilities/indigo.css +0 -1
- package/tailwind/utilities/material.css +0 -1
- /package/{json → dist/json}/colors/meta/multipliers.json +0 -0
- /package/{json → dist/json}/colors/meta/palette.json +0 -0
- /package/{json → dist/json}/colors/presets/palettes.json +0 -0
- /package/{json → dist/json}/elevations/indigo.json +0 -0
- /package/{json → dist/json}/elevations/material.json +0 -0
- /package/{json → dist/json}/typography/presets/typescales.json +0 -0
- /package/{tailwind → dist/tailwind}/themes/base.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/bootstrap.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/fluent.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/indigo.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/dark/material.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/bootstrap.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/fluent.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/indigo.css +0 -0
- /package/{tailwind → dist/tailwind}/themes/light/material.css +0 -0
|
@@ -1,197 +1,146 @@
|
|
|
1
|
-
import "../../knowledge/
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
large: 3
|
|
1
|
+
import { COMPONENT_METADATA, getComponentPlatformAvailability, getComponentSelector } from "../../knowledge/component-metadata.js";
|
|
2
|
+
import "../../knowledge/index.js";
|
|
3
|
+
//#region src/tools/handlers/layout.ts
|
|
4
|
+
/**
|
|
5
|
+
* Handlers for layout scale tools: set_size, set_spacing, set_roundness.
|
|
6
|
+
*/
|
|
7
|
+
var SIZE_KEYWORDS = {
|
|
8
|
+
small: 1,
|
|
9
|
+
medium: 2,
|
|
10
|
+
large: 3
|
|
12
11
|
};
|
|
13
12
|
function normalizeComponentName(component) {
|
|
14
|
-
|
|
13
|
+
return component ? component.toLowerCase().trim() : null;
|
|
15
14
|
}
|
|
16
15
|
function buildSelectorList(value) {
|
|
17
|
-
|
|
16
|
+
return Array.isArray(value) ? value : [value];
|
|
18
17
|
}
|
|
19
18
|
function resolveScope(component, scope, platform) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
error: `**Error:** Component "${component}" not found.
|
|
19
|
+
const notes = [];
|
|
20
|
+
if (component) {
|
|
21
|
+
const normalized = normalizeComponentName(component);
|
|
22
|
+
if (!normalized || !COMPONENT_METADATA[normalized]) {
|
|
23
|
+
const available = Object.keys(COMPONENT_METADATA);
|
|
24
|
+
const suggestions = normalized ? available.filter((name) => name.includes(normalized)).slice(0, 10) : [];
|
|
25
|
+
const list = suggestions.length > 0 ? suggestions : available.slice(0, 15);
|
|
26
|
+
return { error: `**Error:** Component "${component}" not found.
|
|
29
27
|
|
|
30
28
|
${suggestions.length > 0 ? "**Similar components:**" : "**Available components:**"}
|
|
31
|
-
${list.map((name) => `- ${name}`).join("\n")}`
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
selectors: Array.from(new Set(selectors)),
|
|
69
|
-
notes,
|
|
70
|
-
scopeLabel: `component "${normalized}"`
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (scope) {
|
|
74
|
-
return {
|
|
75
|
-
selectors: [scope],
|
|
76
|
-
notes,
|
|
77
|
-
scopeLabel: `scope "${scope}"`
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
selectors: [":root"],
|
|
82
|
-
notes,
|
|
83
|
-
scopeLabel: "global scope (:root)"
|
|
84
|
-
};
|
|
29
|
+
${list.map((name) => `- ${name}`).join("\n")}` };
|
|
30
|
+
}
|
|
31
|
+
if (scope) notes.push("Scope ignored because component was provided.");
|
|
32
|
+
const selectorsEntry = COMPONENT_METADATA[normalized].selectors;
|
|
33
|
+
let selectors = [];
|
|
34
|
+
if (platform && platform !== "generic") {
|
|
35
|
+
selectors = getComponentSelector(normalized, platform);
|
|
36
|
+
if (selectors.length === 0) {
|
|
37
|
+
const availability = getComponentPlatformAvailability(normalized);
|
|
38
|
+
const availablePlatforms = [];
|
|
39
|
+
if (availability?.angular) availablePlatforms.push("angular");
|
|
40
|
+
if (availability?.webcomponents) availablePlatforms.push("webcomponents");
|
|
41
|
+
return { error: `**Error:** Component "${component}" is not available on platform "${platform}".
|
|
42
|
+
${availablePlatforms.length > 0 ? `Available platforms: ${availablePlatforms.join(", ")}.` : ""}` };
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
if (selectorsEntry.angular) selectors = selectors.concat(buildSelectorList(selectorsEntry.angular));
|
|
46
|
+
if (selectorsEntry.webcomponents) selectors = selectors.concat(buildSelectorList(selectorsEntry.webcomponents));
|
|
47
|
+
if (selectorsEntry.angular && selectorsEntry.webcomponents) notes.push("Platform not specified; output includes Angular and Web Components selectors.");
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
selectors: Array.from(new Set(selectors)),
|
|
51
|
+
notes,
|
|
52
|
+
scopeLabel: `component "${normalized}"`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (scope) return {
|
|
56
|
+
selectors: [scope],
|
|
57
|
+
notes,
|
|
58
|
+
scopeLabel: `scope "${scope}"`
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
selectors: [":root"],
|
|
62
|
+
notes,
|
|
63
|
+
scopeLabel: "global scope (:root)"
|
|
64
|
+
};
|
|
85
65
|
}
|
|
86
66
|
function formatSelectorBlock(selectors, declarations) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
];
|
|
94
|
-
return lines.join("\n");
|
|
67
|
+
return [
|
|
68
|
+
selectors.join(",\n"),
|
|
69
|
+
"{",
|
|
70
|
+
...declarations.map((line) => ` ${line}`),
|
|
71
|
+
"}"
|
|
72
|
+
].join("\n");
|
|
95
73
|
}
|
|
96
74
|
function buildResponse(description, output, code, notes, guidance) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
content: [
|
|
110
|
-
{
|
|
111
|
-
type: "text",
|
|
112
|
-
text: responseParts.join("\n")
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
};
|
|
75
|
+
const responseParts = [description];
|
|
76
|
+
if (notes.length > 0) responseParts.push("", ...notes);
|
|
77
|
+
if (guidance.length > 0) responseParts.push("", ...guidance);
|
|
78
|
+
responseParts.push("");
|
|
79
|
+
responseParts.push(output === "sass" ? "```scss" : "```css");
|
|
80
|
+
responseParts.push(code);
|
|
81
|
+
responseParts.push("```");
|
|
82
|
+
return { content: [{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: responseParts.join("\n")
|
|
85
|
+
}] };
|
|
116
86
|
}
|
|
117
87
|
function coerceSizeValue(size) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
88
|
+
if (typeof size === "number") return {
|
|
89
|
+
display: String(size),
|
|
90
|
+
value: size
|
|
91
|
+
};
|
|
92
|
+
const value = SIZE_KEYWORDS[size.toLowerCase()];
|
|
93
|
+
return {
|
|
94
|
+
display: `${size} (${value})`,
|
|
95
|
+
value
|
|
96
|
+
};
|
|
124
97
|
}
|
|
125
98
|
async function handleSetSize(params) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const guidance = output === "sass" ? [
|
|
140
|
-
"Sass note: sizable() requires @include sizable() in component styles.",
|
|
141
|
-
"Components map --ig-size to --component-size internally."
|
|
142
|
-
] : [];
|
|
143
|
-
return buildResponse(description, output, code, notes, guidance);
|
|
99
|
+
const { component, scope, platform, size, output = "css" } = params;
|
|
100
|
+
const resolution = resolveScope(component, scope, platform);
|
|
101
|
+
if ("error" in resolution) return {
|
|
102
|
+
content: [{
|
|
103
|
+
type: "text",
|
|
104
|
+
text: resolution.error
|
|
105
|
+
}],
|
|
106
|
+
isError: true
|
|
107
|
+
};
|
|
108
|
+
const { selectors, notes, scopeLabel } = resolution;
|
|
109
|
+
const { display, value } = coerceSizeValue(size);
|
|
110
|
+
const code = formatSelectorBlock(selectors, [`--ig-size: ${value};`]);
|
|
111
|
+
return buildResponse(`Set size to ${display} in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: sizable() requires @include sizable() in component styles.", "Components map --ig-size to --component-size internally."] : []);
|
|
144
112
|
}
|
|
145
113
|
async function handleSetSpacing(params) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const { selectors, notes, scopeLabel } = resolution;
|
|
163
|
-
const declarations = [];
|
|
164
|
-
if (spacing !== void 0) declarations.push(`--ig-spacing: ${spacing};`);
|
|
165
|
-
if (inline !== void 0)
|
|
166
|
-
declarations.push(`--ig-spacing-inline: ${inline};`);
|
|
167
|
-
if (block !== void 0) declarations.push(`--ig-spacing-block: ${block};`);
|
|
168
|
-
const code = formatSelectorBlock(selectors, declarations);
|
|
169
|
-
const description = `Set spacing in ${scopeLabel}.`;
|
|
170
|
-
const guidance = output === "sass" ? [
|
|
171
|
-
"Sass note: pad() functions require @include spacing() once at root scope."
|
|
172
|
-
] : [];
|
|
173
|
-
return buildResponse(description, output, code, notes, guidance);
|
|
114
|
+
const { component, scope, platform, spacing, inline, block, output = "css" } = params;
|
|
115
|
+
const resolution = resolveScope(component, scope, platform);
|
|
116
|
+
if ("error" in resolution) return {
|
|
117
|
+
content: [{
|
|
118
|
+
type: "text",
|
|
119
|
+
text: resolution.error
|
|
120
|
+
}],
|
|
121
|
+
isError: true
|
|
122
|
+
};
|
|
123
|
+
const { selectors, notes, scopeLabel } = resolution;
|
|
124
|
+
const declarations = [];
|
|
125
|
+
if (spacing !== void 0) declarations.push(`--ig-spacing: ${spacing};`);
|
|
126
|
+
if (inline !== void 0) declarations.push(`--ig-spacing-inline: ${inline};`);
|
|
127
|
+
if (block !== void 0) declarations.push(`--ig-spacing-block: ${block};`);
|
|
128
|
+
const code = formatSelectorBlock(selectors, declarations);
|
|
129
|
+
return buildResponse(`Set spacing in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: pad() functions require @include spacing() once at root scope."] : []);
|
|
174
130
|
}
|
|
175
131
|
async function handleSetRoundness(params) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const guidance = output === "sass" ? [
|
|
189
|
-
"Sass note: border-radius() responds to --ig-radius-factor without extra mixins."
|
|
190
|
-
] : [];
|
|
191
|
-
return buildResponse(description, output, code, notes, guidance);
|
|
132
|
+
const { component, scope, platform, radiusFactor, output = "css" } = params;
|
|
133
|
+
const resolution = resolveScope(component, scope, platform);
|
|
134
|
+
if ("error" in resolution) return {
|
|
135
|
+
content: [{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: resolution.error
|
|
138
|
+
}],
|
|
139
|
+
isError: true
|
|
140
|
+
};
|
|
141
|
+
const { selectors, notes, scopeLabel } = resolution;
|
|
142
|
+
const code = formatSelectorBlock(selectors, [`--ig-radius-factor: ${radiusFactor};`]);
|
|
143
|
+
return buildResponse(`Set roundness factor to ${radiusFactor} in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: border-radius() responds to --ig-radius-factor without extra mixins."] : []);
|
|
192
144
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
handleSetSize,
|
|
196
|
-
handleSetSpacing
|
|
197
|
-
};
|
|
145
|
+
//#endregion
|
|
146
|
+
export { handleSetRoundness, handleSetSize, handleSetSpacing };
|
|
@@ -1,127 +1,112 @@
|
|
|
1
|
-
import { generatePaletteCss, formatCssOutput } from "../../generators/css.js";
|
|
2
|
-
import { generatePalette } from "../../generators/sass.js";
|
|
3
1
|
import { PLATFORM_METADATA } from "../../knowledge/platforms/index.js";
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import "../../
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { generatePalette } from "../../generators/sass.js";
|
|
3
|
+
import { formatCssOutput, generatePaletteCss } from "../../generators/css.js";
|
|
4
|
+
import { formatValidationResult, generateWarningComments, validatePaletteColors } from "../../validators/palette.js";
|
|
5
|
+
import "../../validators/index.js";
|
|
6
|
+
//#region src/tools/handlers/palette.ts
|
|
7
|
+
/**
|
|
8
|
+
* Handler for create_palette tool.
|
|
9
|
+
*/
|
|
11
10
|
async function handleCreatePalette(params) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return handleSassOutput(params, validation);
|
|
11
|
+
const variant = params.variant ?? "light";
|
|
12
|
+
const output = params.output ?? "sass";
|
|
13
|
+
const validation = await validatePaletteColors({
|
|
14
|
+
variant,
|
|
15
|
+
surface: params.surface,
|
|
16
|
+
gray: params.gray
|
|
17
|
+
});
|
|
18
|
+
if (output === "css") return handleCssOutput(params, validation);
|
|
19
|
+
return handleSassOutput(params, validation);
|
|
23
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Handle CSS output format - generates CSS custom properties directly.
|
|
23
|
+
*/
|
|
24
24
|
async function handleCssOutput(params, validation) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: `**Error generating CSS palette**
|
|
65
|
-
|
|
66
|
-
${message}`
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
};
|
|
70
|
-
}
|
|
25
|
+
try {
|
|
26
|
+
const result = await generatePaletteCss({
|
|
27
|
+
primary: params.primary,
|
|
28
|
+
secondary: params.secondary,
|
|
29
|
+
surface: params.surface,
|
|
30
|
+
gray: params.gray,
|
|
31
|
+
info: params.info,
|
|
32
|
+
success: params.success,
|
|
33
|
+
warn: params.warn,
|
|
34
|
+
error: params.error,
|
|
35
|
+
variant: params.variant
|
|
36
|
+
});
|
|
37
|
+
const formattedCss = formatCssOutput(result.css, result.description);
|
|
38
|
+
const responseParts = [result.description];
|
|
39
|
+
responseParts.push("");
|
|
40
|
+
responseParts.push("Output format: CSS custom properties");
|
|
41
|
+
const validationText = formatValidationResult(validation);
|
|
42
|
+
if (validationText) {
|
|
43
|
+
responseParts.push("");
|
|
44
|
+
responseParts.push(validationText);
|
|
45
|
+
}
|
|
46
|
+
responseParts.push("");
|
|
47
|
+
responseParts.push("```css");
|
|
48
|
+
responseParts.push(formattedCss.trimEnd());
|
|
49
|
+
responseParts.push("```");
|
|
50
|
+
return { content: [{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: responseParts.join("\n")
|
|
53
|
+
}] };
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return { content: [{
|
|
56
|
+
type: "text",
|
|
57
|
+
text: `**Error generating CSS palette**\n\n${error instanceof Error ? error.message : String(error)}`
|
|
58
|
+
}] };
|
|
59
|
+
}
|
|
71
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Handle Sass output format - generates Sass code using the palette() function.
|
|
63
|
+
*/
|
|
72
64
|
function handleSassOutput(params, validation) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
type: "text",
|
|
120
|
-
text: responseParts.join("\n")
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
};
|
|
65
|
+
const result = generatePalette({
|
|
66
|
+
platform: params.platform,
|
|
67
|
+
licensed: params.licensed,
|
|
68
|
+
primary: params.primary,
|
|
69
|
+
secondary: params.secondary,
|
|
70
|
+
surface: params.surface,
|
|
71
|
+
gray: params.gray,
|
|
72
|
+
info: params.info,
|
|
73
|
+
success: params.success,
|
|
74
|
+
warn: params.warn,
|
|
75
|
+
error: params.error,
|
|
76
|
+
variant: params.variant,
|
|
77
|
+
name: params.name
|
|
78
|
+
});
|
|
79
|
+
let finalCode = result.code;
|
|
80
|
+
if (!validation.isValid) {
|
|
81
|
+
const warningComments = generateWarningComments(validation);
|
|
82
|
+
if (warningComments.length > 0) {
|
|
83
|
+
const lines = finalCode.split("\n");
|
|
84
|
+
const useIndex = lines.findIndex((line) => line.startsWith("@use '") || line.startsWith("@use \""));
|
|
85
|
+
if (useIndex > 0) {
|
|
86
|
+
lines.splice(useIndex, 0, ...warningComments, "");
|
|
87
|
+
finalCode = lines.join("\n");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const responseParts = [result.description];
|
|
92
|
+
const platformNote = params.platform ? `Platform: ${PLATFORM_METADATA[params.platform]?.name ?? params.platform}` : "Platform: Not specified (generic output). Specify `platform` for optimized code.";
|
|
93
|
+
responseParts.push("");
|
|
94
|
+
responseParts.push(platformNote);
|
|
95
|
+
const validationText = formatValidationResult(validation);
|
|
96
|
+
if (validationText) {
|
|
97
|
+
responseParts.push("");
|
|
98
|
+
responseParts.push(validationText);
|
|
99
|
+
}
|
|
100
|
+
responseParts.push("");
|
|
101
|
+
responseParts.push(`Variables created: ${result.variables.join(", ")}`);
|
|
102
|
+
responseParts.push("");
|
|
103
|
+
responseParts.push("```scss");
|
|
104
|
+
responseParts.push(finalCode.trimEnd());
|
|
105
|
+
responseParts.push("```");
|
|
106
|
+
return { content: [{
|
|
107
|
+
type: "text",
|
|
108
|
+
text: responseParts.join("\n")
|
|
109
|
+
}] };
|
|
124
110
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
111
|
+
//#endregion
|
|
112
|
+
export { handleCreatePalette };
|