inai-react-components 0.1.4 → 0.1.5
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/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +121 -2
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +22 -2
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAChD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd,CAQA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE;IAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,iBAAiB,EAAE,CAAA;CAAE,EAC1G,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,iBAAiB,GAAG,IAAI,CAc1B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C,MAAM,CAUR;AAED,wBAAsB,MAAM,CAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,CAsHpB;AAuBD,wBAAsB,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BtE"}
|
package/dist/commands/add.js
CHANGED
|
@@ -5,6 +5,7 @@ import ora from "ora";
|
|
|
5
5
|
import prompts from "prompts";
|
|
6
6
|
import { readComponentsJson, readRegistryJson, } from "./status.js";
|
|
7
7
|
import { resolveRegistryDir } from "../utils/registry-resolver.js";
|
|
8
|
+
import { normalizeThemeCss, getLocalTailwindCssTemplate, getLegacyTailwindCssTemplate, } from "./init.js";
|
|
8
9
|
/**
|
|
9
10
|
* Parse a component spec like "button", "block/auth-login", or "template/admin-dashboard"
|
|
10
11
|
* into its type prefix and name.
|
|
@@ -190,6 +191,105 @@ export async function addCommand(componentSpec) {
|
|
|
190
191
|
process.exit(1);
|
|
191
192
|
}
|
|
192
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Discover available themes from the registry's tokens directory.
|
|
196
|
+
*/
|
|
197
|
+
function discoverThemes(registryDir) {
|
|
198
|
+
const themesDir = path.join(registryDir, "packages", "tokens", "src", "themes");
|
|
199
|
+
if (fs.existsSync(themesDir)) {
|
|
200
|
+
return fs
|
|
201
|
+
.readdirSync(themesDir)
|
|
202
|
+
.filter((f) => f.endsWith(".css"))
|
|
203
|
+
.map((f) => f.replace(/\.css$/, ""))
|
|
204
|
+
.sort();
|
|
205
|
+
}
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Switch the project's theme. Copies the new theme CSS (normalized),
|
|
210
|
+
* updates components.json, and regenerates the CSS entry point.
|
|
211
|
+
*/
|
|
212
|
+
async function changeTheme(rootDir, registryDir) {
|
|
213
|
+
const componentsJson = readComponentsJson(rootDir);
|
|
214
|
+
const currentTheme = componentsJson.theme ?? "monday";
|
|
215
|
+
const themes = discoverThemes(registryDir);
|
|
216
|
+
if (themes.length === 0) {
|
|
217
|
+
console.log(chalk.red("No themes found in registry."));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const currentIdx = themes.indexOf(currentTheme);
|
|
221
|
+
const response = await prompts({
|
|
222
|
+
type: "select",
|
|
223
|
+
name: "theme",
|
|
224
|
+
message: `Select a theme ${chalk.dim(`(current: ${currentTheme})`)}`,
|
|
225
|
+
choices: themes.map((t) => ({
|
|
226
|
+
title: t === currentTheme ? `${t} ${chalk.green("(current)")}` : t,
|
|
227
|
+
value: t,
|
|
228
|
+
})),
|
|
229
|
+
initial: currentIdx >= 0 ? currentIdx : 0,
|
|
230
|
+
});
|
|
231
|
+
if (!response.theme) {
|
|
232
|
+
console.log(chalk.yellow("\nTheme change cancelled."));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const newTheme = response.theme;
|
|
236
|
+
if (newTheme === currentTheme) {
|
|
237
|
+
console.log(chalk.dim("\nTheme unchanged."));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const spinner = ora(`Switching theme to "${newTheme}"...`).start();
|
|
241
|
+
try {
|
|
242
|
+
const tokensSrc = path.join(registryDir, "packages", "tokens", "src");
|
|
243
|
+
const isRemote = !!componentsJson.registrySource;
|
|
244
|
+
if (isRemote) {
|
|
245
|
+
// Remote mode: copy and normalize theme file
|
|
246
|
+
const themesSrc = path.join(tokensSrc, "themes");
|
|
247
|
+
const themesDest = path.join(rootDir, "src", "styles", "tokens", "themes");
|
|
248
|
+
// Remove old theme file
|
|
249
|
+
const oldThemeFile = path.join(themesDest, `${currentTheme}.css`);
|
|
250
|
+
if (fs.existsSync(oldThemeFile)) {
|
|
251
|
+
fs.unlinkSync(oldThemeFile);
|
|
252
|
+
}
|
|
253
|
+
// Copy and normalize new theme
|
|
254
|
+
const newThemeSrc = path.join(themesSrc, `${newTheme}.css`);
|
|
255
|
+
if (fs.existsSync(newThemeSrc)) {
|
|
256
|
+
fs.mkdirSync(themesDest, { recursive: true });
|
|
257
|
+
const rawCss = fs.readFileSync(newThemeSrc, "utf-8");
|
|
258
|
+
const normalizedCss = normalizeThemeCss(rawCss, newTheme);
|
|
259
|
+
fs.writeFileSync(path.join(themesDest, `${newTheme}.css`), normalizedCss);
|
|
260
|
+
}
|
|
261
|
+
// Regenerate index.css
|
|
262
|
+
const font = componentsJson.font ?? { body: "outfit", heading: "outfit" };
|
|
263
|
+
const radius = componentsJson.radius ?? 0.5;
|
|
264
|
+
const cssPath = path.join(rootDir, "src", "index.css");
|
|
265
|
+
fs.writeFileSync(cssPath, getLocalTailwindCssTemplate(newTheme, font.body, font.heading, radius));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
// Local mode: just regenerate index.css with new import
|
|
269
|
+
const font = componentsJson.font ?? { body: "outfit", heading: "outfit" };
|
|
270
|
+
const radius = componentsJson.radius ?? 0.5;
|
|
271
|
+
const cssPath = path.join(rootDir, "src", "index.css");
|
|
272
|
+
fs.writeFileSync(cssPath, getLegacyTailwindCssTemplate(newTheme, font.body, font.heading, radius));
|
|
273
|
+
}
|
|
274
|
+
// Update components.json
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
+
componentsJson.theme = newTheme;
|
|
277
|
+
const componentsJsonPath = path.join(rootDir, "components.json");
|
|
278
|
+
fs.writeFileSync(componentsJsonPath, JSON.stringify(componentsJson, null, 2) + "\n");
|
|
279
|
+
spinner.succeed(`Theme switched to "${newTheme}"`);
|
|
280
|
+
console.log(chalk.green("\nUpdated files:"));
|
|
281
|
+
console.log(chalk.dim(" - components.json"));
|
|
282
|
+
console.log(chalk.dim(" - src/index.css"));
|
|
283
|
+
if (componentsJson.registrySource) {
|
|
284
|
+
console.log(chalk.dim(` - src/styles/tokens/themes/${newTheme}.css`));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
spinner.fail("Failed to switch theme.");
|
|
289
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290
|
+
console.error(chalk.red(`\nError: ${message}`));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
193
293
|
async function interactiveAdd() {
|
|
194
294
|
const rootDir = process.cwd();
|
|
195
295
|
const componentsJson = readComponentsJson(rootDir);
|
|
@@ -204,6 +304,26 @@ async function interactiveAdd() {
|
|
|
204
304
|
console.log(chalk.red("Registry not found. Ensure your project is initialized correctly."));
|
|
205
305
|
process.exit(1);
|
|
206
306
|
}
|
|
307
|
+
// First: ask what the user wants to do
|
|
308
|
+
console.log(chalk.bold("\nInAI UI - Interactive Menu\n"));
|
|
309
|
+
const actionResponse = await prompts({
|
|
310
|
+
type: "select",
|
|
311
|
+
name: "action",
|
|
312
|
+
message: "What would you like to do?",
|
|
313
|
+
choices: [
|
|
314
|
+
{ title: "Add components", value: "components", description: "Browse and install components, blocks, or templates" },
|
|
315
|
+
{ title: "Change theme", value: "theme", description: `Current: ${componentsJson.theme ?? "monday"}` },
|
|
316
|
+
],
|
|
317
|
+
});
|
|
318
|
+
if (!actionResponse.action) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
// Theme change flow
|
|
322
|
+
if (actionResponse.action === "theme") {
|
|
323
|
+
await changeTheme(rootDir, registryDir);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
// Component picker flow
|
|
207
327
|
const allItems = [
|
|
208
328
|
...registry.components,
|
|
209
329
|
...registry.blocks,
|
|
@@ -227,8 +347,7 @@ async function interactiveAdd() {
|
|
|
227
347
|
selected: false,
|
|
228
348
|
};
|
|
229
349
|
});
|
|
230
|
-
console.log(chalk.
|
|
231
|
-
console.log(chalk.dim("Select components to add or update. Already installed components will be updated.\n"));
|
|
350
|
+
console.log(chalk.dim("\nSelect components to add or update. Already installed components will be updated.\n"));
|
|
232
351
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
352
|
const response = await prompts({
|
|
234
353
|
type: "multiselect",
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -259,6 +259,13 @@ export declare function buildComponentsJson(config: InitConfig, repoUrl?: string
|
|
|
259
259
|
export declare function getCnTemplate(): string;
|
|
260
260
|
export declare function getLocalTailwindCssTemplate(theme: Theme, fontBody: FontPreset, fontHeading: FontPreset, radius: number): string;
|
|
261
261
|
export declare function getLegacyTailwindCssTemplate(theme: Theme, fontBody: FontPreset, fontHeading: FontPreset, radius: number): string;
|
|
262
|
+
/**
|
|
263
|
+
* Strip the `[data-theme="<name>"]` selector from theme CSS so it applies
|
|
264
|
+
* directly on `:root` / `.dark`. This is used when copying a single theme
|
|
265
|
+
* for a project — the theme becomes the default without needing a
|
|
266
|
+
* `data-theme` attribute on the HTML element.
|
|
267
|
+
*/
|
|
268
|
+
export declare function normalizeThemeCss(css: string, theme: string): string;
|
|
262
269
|
export declare function runInit(config: InitConfig, targetDir: string, repoUrl?: string): Promise<{
|
|
263
270
|
success: boolean;
|
|
264
271
|
filesCreated: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,gBAAgB,yMAeZ,CAAC;AACX,KAAK,KAAK,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,EAAE,MAAM,GAAG,MAAM,CAahI;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBpE;AA6ED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA4CvD;AAED,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DjE"}
|
package/dist/commands/init.js
CHANGED
|
@@ -264,6 +264,24 @@ export function getLegacyTailwindCssTemplate(theme, fontBody, fontHeading, radiu
|
|
|
264
264
|
}
|
|
265
265
|
`;
|
|
266
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Strip the `[data-theme="<name>"]` selector from theme CSS so it applies
|
|
269
|
+
* directly on `:root` / `.dark`. This is used when copying a single theme
|
|
270
|
+
* for a project — the theme becomes the default without needing a
|
|
271
|
+
* `data-theme` attribute on the HTML element.
|
|
272
|
+
*/
|
|
273
|
+
export function normalizeThemeCss(css, theme) {
|
|
274
|
+
// Replace `:root[data-theme="<name>"],\n[data-theme="<name>"]` → `:root`
|
|
275
|
+
const rootSelector = new RegExp(`:root\\[data-theme="${theme}"\\],?\\s*\\n?\\[data-theme="${theme}"\\]`, "g");
|
|
276
|
+
let normalized = css.replace(rootSelector, ":root");
|
|
277
|
+
// Replace `.dark[data-theme="<name>"],\n[data-theme="<name>"].dark` → `.dark`
|
|
278
|
+
const darkSelector = new RegExp(`\\.dark\\[data-theme="${theme}"\\],?\\s*\\n?\\[data-theme="${theme}"\\]\\.dark`, "g");
|
|
279
|
+
normalized = normalized.replace(darkSelector, ".dark");
|
|
280
|
+
// Catch any remaining standalone `[data-theme="<name>"]` selectors
|
|
281
|
+
const standaloneSelector = new RegExp(`\\[data-theme="${theme}"\\]`, "g");
|
|
282
|
+
normalized = normalized.replace(standaloneSelector, "");
|
|
283
|
+
return normalized;
|
|
284
|
+
}
|
|
267
285
|
function copyDirRecursive(src, dest) {
|
|
268
286
|
const copied = [];
|
|
269
287
|
if (!fs.existsSync(src))
|
|
@@ -297,7 +315,7 @@ function copyTokensToProject(registryDir, targetDir, theme) {
|
|
|
297
315
|
copied.push(`src/styles/tokens/${file}`);
|
|
298
316
|
}
|
|
299
317
|
}
|
|
300
|
-
// Copy selected theme
|
|
318
|
+
// Copy selected theme (normalized so it applies without data-theme attribute)
|
|
301
319
|
const themesSrc = path.join(tokensSrc, "themes");
|
|
302
320
|
const themesDest = path.join(tokensDest, "themes");
|
|
303
321
|
if (fs.existsSync(themesSrc)) {
|
|
@@ -305,7 +323,9 @@ function copyTokensToProject(registryDir, targetDir, theme) {
|
|
|
305
323
|
const themeFile = `${theme}.css`;
|
|
306
324
|
const themeSrc = path.join(themesSrc, themeFile);
|
|
307
325
|
if (fs.existsSync(themeSrc)) {
|
|
308
|
-
fs.
|
|
326
|
+
const rawCss = fs.readFileSync(themeSrc, "utf-8");
|
|
327
|
+
const normalizedCss = normalizeThemeCss(rawCss, theme);
|
|
328
|
+
fs.writeFileSync(path.join(themesDest, themeFile), normalizedCss);
|
|
309
329
|
copied.push(`src/styles/tokens/themes/${themeFile}`);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,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