sigma-ui 1.1.2 → 1.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 (34) hide show
  1. package/README.md +1 -1
  2. package/__generated/registry-schemes/colors/blue.json +1 -1
  3. package/__generated/registry-schemes/colors/frosted-glass.json +1 -1
  4. package/__generated/registry-schemes/colors/grayscale.json +1 -1
  5. package/__generated/registry-schemes/colors/green.json +1 -1
  6. package/__generated/registry-schemes/colors/orange.json +1 -1
  7. package/__generated/registry-schemes/colors/red.json +1 -1
  8. package/__generated/registry-schemes/colors/rose.json +1 -1
  9. package/__generated/registry-schemes/colors/yellow.json +1 -1
  10. package/__generated/registry-schemes/style-system/css/accordion.json +1 -1
  11. package/__generated/registry-schemes/style-system/css/alert-dialog.json +1 -1
  12. package/__generated/registry-schemes/style-system/css/button.json +1 -1
  13. package/__generated/registry-schemes/style-system/css/collapsible.json +1 -1
  14. package/__generated/registry-schemes/style-system/css/combobox.json +1 -1
  15. package/__generated/registry-schemes/style-system/css/context-menu.json +2 -2
  16. package/__generated/registry-schemes/style-system/css/dialog.json +2 -2
  17. package/__generated/registry-schemes/style-system/css/dropdown-menu.json +2 -2
  18. package/__generated/registry-schemes/style-system/css/hover-card.json +1 -1
  19. package/__generated/registry-schemes/style-system/css/image.json +1 -1
  20. package/__generated/registry-schemes/style-system/css/menubar.json +2 -2
  21. package/__generated/registry-schemes/style-system/css/navigation-menu.json +3 -3
  22. package/__generated/registry-schemes/style-system/css/popover.json +1 -1
  23. package/__generated/registry-schemes/style-system/css/radio-group.json +1 -1
  24. package/__generated/registry-schemes/style-system/css/select.json +1 -1
  25. package/__generated/registry-schemes/style-system/css/sheet.json +1 -1
  26. package/__generated/registry-schemes/style-system/css/skeleton.json +1 -1
  27. package/__generated/registry-schemes/style-system/css/switch.json +1 -1
  28. package/__generated/registry-schemes/style-system/css/tooltip.json +1 -1
  29. package/__generated/registry-schemes/style-system/tailwind/button.json +1 -1
  30. package/__generated/registry-schemes/style-system/tailwind/navigation-menu.json +1 -1
  31. package/dist/index.js +417 -183
  32. package/dist/index.js.map +1 -1
  33. package/package.json +19 -19
  34. package/LICENSE +0 -21
package/dist/index.js CHANGED
@@ -139,6 +139,43 @@ async function transform(opts) {
139
139
  return sourceFile?.getFullText();
140
140
  }
141
141
 
142
+ // src/utils/transformers/transform-component-naming.ts
143
+ function pascalToKebab(pascalCase) {
144
+ return pascalCase.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
145
+ }
146
+ function kebabToPascal(kebabCase) {
147
+ return kebabCase.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
148
+ }
149
+ function transformDirectoryName(dirName, naming) {
150
+ if (naming === "kebab-case") {
151
+ return dirName;
152
+ }
153
+ return kebabToPascal(dirName);
154
+ }
155
+ function transformFileName(fileName, naming) {
156
+ if (naming === "pascal-case") {
157
+ return fileName;
158
+ }
159
+ if (fileName === "index.ts") {
160
+ return fileName;
161
+ }
162
+ const extension = fileName.includes(".") ? fileName.slice(fileName.lastIndexOf(".")) : "";
163
+ const baseName = fileName.includes(".") ? fileName.slice(0, fileName.lastIndexOf(".")) : fileName;
164
+ return pascalToKebab(baseName) + extension;
165
+ }
166
+ function transformLocalVueImports(content, naming) {
167
+ if (naming === "pascal-case") {
168
+ return content;
169
+ }
170
+ return content.replace(
171
+ /from\s+['"]\.\/([\w-]+)\.vue['"]/g,
172
+ (match, componentName) => {
173
+ const kebabName = pascalToKebab(componentName);
174
+ return `from './${kebabName}.vue'`;
175
+ }
176
+ );
177
+ }
178
+
142
179
  // src/utils/get-config.ts
143
180
  import { existsSync as existsSync2 } from "node:fs";
144
181
  import process2 from "node:process";
@@ -217,6 +254,7 @@ var registryBaseColorSchema = z.object({
217
254
  })
218
255
  })
219
256
  });
257
+ var componentNamingSchema = z.enum(["pascal-case", "kebab-case"]).default("pascal-case");
220
258
  var rawConfigSchema = z.object({
221
259
  $schema: z.string().optional(),
222
260
  styleSystem: commonFields.styleSystem,
@@ -233,7 +271,8 @@ var rawConfigSchema = z.object({
233
271
  utils: z.string().default(""),
234
272
  components: z.string()
235
273
  }),
236
- generatePreflight: z.boolean().optional().default(true)
274
+ generatePreflight: z.boolean().optional().default(true),
275
+ componentNaming: componentNamingSchema
237
276
  });
238
277
  var configSchema = rawConfigSchema.extend({
239
278
  resolvedPaths: z.object({
@@ -245,7 +284,8 @@ var configSchema = rawConfigSchema.extend({
245
284
  });
246
285
  var initOptionsSchema = z.object({
247
286
  cwd: commonFields.cwd,
248
- yes: commonFields.yes
287
+ yes: commonFields.yes,
288
+ defaults: z.boolean().default(false)
249
289
  });
250
290
  var addOptionsSchema = z.object({
251
291
  components: commonFields.components,
@@ -952,7 +992,9 @@ async function processItem(item, targetDir, options8, config, baseColor, cwd, se
952
992
  if (!existsSync3(targetDir)) {
953
993
  await fs3.mkdir(targetDir, { recursive: true });
954
994
  }
955
- const componentPath = path5.resolve(targetDir, item.name);
995
+ const componentNaming = config.componentNaming ?? "pascal-case";
996
+ const transformedDirName = transformDirectoryName(item.name, componentNaming);
997
+ const componentPath = path5.resolve(targetDir, transformedDirName);
956
998
  const existingComponent = item.files.filter(
957
999
  (file) => existsSync3(path5.resolve(componentPath, file.name))
958
1000
  );
@@ -1010,19 +1052,22 @@ async function writeComponentFiles(item, componentDir, config, baseColor) {
1010
1052
  if (!existsSync3(componentDir)) {
1011
1053
  await fs3.mkdir(componentDir, { recursive: true });
1012
1054
  }
1055
+ const componentNaming = config.componentNaming ?? "pascal-case";
1013
1056
  const files = item.files.map((file) => ({
1014
1057
  ...file,
1015
- path: path5.resolve(componentDir, file.name)
1058
+ originalName: file.name,
1059
+ name: transformFileName(file.name, componentNaming),
1060
+ path: path5.resolve(componentDir, transformFileName(file.name, componentNaming))
1016
1061
  }));
1017
1062
  for (const file of files) {
1063
+ const fileContent = transformLocalVueImports(file.content, componentNaming);
1018
1064
  const content = await transform({
1019
1065
  filename: file.path,
1020
- raw: file.content,
1066
+ raw: fileContent,
1021
1067
  config,
1022
1068
  baseColor
1023
1069
  });
1024
- const filePath = file.path;
1025
- await fs3.writeFile(filePath, content);
1070
+ await fs3.writeFile(file.path, content);
1026
1071
  }
1027
1072
  }
1028
1073
 
@@ -24108,55 +24153,82 @@ import { existsSync as existsSync5 } from "node:fs";
24108
24153
  import path13 from "pathe";
24109
24154
  import fs7 from "fs-extra";
24110
24155
  import { readPackageJSON } from "pkg-types";
24111
- async function getProjectInfo() {
24112
- const info = {
24113
- tsconfig: null,
24114
- isNuxt: false,
24115
- sigmaUiNuxtModuleInfo: void 0,
24116
- isVueVite: false,
24117
- srcDir: false,
24118
- componentsUiDir: false,
24119
- srcComponentsUiDir: false
24156
+ async function getProjectInfo(cwd = process.cwd()) {
24157
+ const framework = detectFramework(cwd);
24158
+ const tsConfigPath = detectTsConfigPath(cwd, framework);
24159
+ const hasTailwind = await detectTailwind(cwd);
24160
+ const { configType: tailwindConfigType, configPath: tailwindConfigPath } = detectTailwindConfigType(cwd);
24161
+ const sigmaUiNuxtModuleInfo = framework === "nuxt" ? await getSigmaUiNuxtInfo() : void 0;
24162
+ return {
24163
+ framework,
24164
+ tsConfigPath,
24165
+ srcDir: existsSync5(path13.resolve(cwd, "src")),
24166
+ srcComponentsUiDir: existsSync5(path13.resolve(cwd, "src/components/ui")),
24167
+ componentsUiDir: existsSync5(path13.resolve(cwd, "components/ui")),
24168
+ hasTailwind,
24169
+ tailwindConfigType,
24170
+ tailwindConfigPath,
24171
+ sigmaUiNuxtModuleInfo
24120
24172
  };
24121
- try {
24122
- const tsconfig = await getTsConfig();
24123
- const isNuxt = existsSync5(path13.resolve("./nuxt.config.js")) || existsSync5(path13.resolve("./nuxt.config.ts"));
24124
- const sigmaUiNuxtModuleInfo = isNuxt ? await getSigmaUiNuxtInfo() : void 0;
24125
- return {
24126
- tsconfig,
24127
- isNuxt,
24128
- sigmaUiNuxtModuleInfo,
24129
- isVueVite: existsSync5(path13.resolve("./vite.config.js")) || existsSync5(path13.resolve("./vite.config.ts")),
24130
- srcDir: existsSync5(path13.resolve("./src")),
24131
- srcComponentsUiDir: existsSync5(path13.resolve("./src/components/ui")),
24132
- componentsUiDir: existsSync5(path13.resolve("./components/ui"))
24133
- };
24134
- } catch (error) {
24135
- console.log(error);
24136
- return info;
24173
+ }
24174
+ function detectTailwindConfigType(cwd) {
24175
+ const jsConfigPaths = [
24176
+ "tailwind.config.js",
24177
+ "tailwind.config.ts",
24178
+ "tailwind.config.mjs",
24179
+ "tailwind.config.cjs"
24180
+ ];
24181
+ for (const configPath of jsConfigPaths) {
24182
+ if (existsSync5(path13.resolve(cwd, configPath))) {
24183
+ return { configType: "js", configPath };
24184
+ }
24137
24185
  }
24186
+ return { configType: "css", configPath: null };
24138
24187
  }
24139
- async function getSigmaUiNuxtInfo() {
24140
- let nuxtModule;
24188
+ function detectFramework(cwd) {
24189
+ if (existsSync5(path13.resolve(cwd, "nuxt.config.js")) || existsSync5(path13.resolve(cwd, "nuxt.config.ts"))) {
24190
+ return "nuxt";
24191
+ }
24192
+ if (existsSync5(path13.resolve(cwd, "astro.config.mjs")) || existsSync5(path13.resolve(cwd, "astro.config.ts"))) {
24193
+ return "astro";
24194
+ }
24195
+ if (existsSync5(path13.resolve(cwd, "artisan"))) {
24196
+ return "laravel";
24197
+ }
24198
+ return "vite";
24199
+ }
24200
+ function detectTsConfigPath(cwd, framework) {
24201
+ if (framework === "nuxt") {
24202
+ return ".nuxt/tsconfig.json";
24203
+ }
24204
+ const possiblePaths = [
24205
+ "tsconfig.json",
24206
+ "tsconfig.app.json"
24207
+ ];
24208
+ for (const tsPath of possiblePaths) {
24209
+ if (existsSync5(path13.resolve(cwd, tsPath))) {
24210
+ return tsPath;
24211
+ }
24212
+ }
24213
+ return "tsconfig.json";
24214
+ }
24215
+ async function detectTailwind(cwd) {
24141
24216
  try {
24142
- nuxtModule = await readPackageJSON("sigma-ui-nuxt");
24143
- } catch (error) {
24144
- console.log(error);
24145
- nuxtModule = void 0;
24217
+ const packageJson = await readPackageJSON(cwd);
24218
+ const allDeps = {
24219
+ ...packageJson.dependencies,
24220
+ ...packageJson.devDependencies
24221
+ };
24222
+ return "tailwindcss" in allDeps;
24223
+ } catch {
24224
+ return false;
24146
24225
  }
24147
- return nuxtModule;
24148
24226
  }
24149
- async function getTsConfig() {
24227
+ async function getSigmaUiNuxtInfo() {
24150
24228
  try {
24151
- const tsconfigPath = path13.join("tsconfig.json");
24152
- const tsconfig = await fs7.readJSON(tsconfigPath);
24153
- if (!tsconfig) {
24154
- throw new Error("tsconfig.json is missing");
24155
- }
24156
- return tsconfig;
24157
- } catch (error) {
24158
- console.log(error);
24159
- return null;
24229
+ return await readPackageJSON("sigma-ui-nuxt");
24230
+ } catch {
24231
+ return void 0;
24160
24232
  }
24161
24233
  }
24162
24234
 
@@ -24216,43 +24288,162 @@ function applyPrefixesCss(css, prefix) {
24216
24288
  }
24217
24289
 
24218
24290
  // ../shared/templates/tailwind-config.ts
24219
- var TAILWIND_KEYFRAMES = `
24220
- "fade-in": {
24291
+ var UTILS_TEMPLATE = `import { type ClassValue, clsx } from 'clsx'
24292
+ import { twMerge } from 'tailwind-merge'
24293
+
24294
+ export function cn(...inputs: ClassValue[]) {
24295
+ return twMerge(clsx(inputs))
24296
+ }
24297
+ `;
24298
+ var TAILWIND_V4_CSS_TEMPLATE = `@import "tailwindcss";
24299
+
24300
+ @plugin "tailwindcss-animate";
24301
+
24302
+ @custom-variant dark (&:is(.dark *));
24303
+
24304
+ @theme inline {
24305
+ --color-background: hsl(var(--background));
24306
+ --color-foreground: hsl(var(--foreground));
24307
+ --color-muted: hsl(var(--muted));
24308
+ --color-muted-foreground: hsl(var(--muted-foreground));
24309
+ --color-popover: hsl(var(--popover));
24310
+ --color-popover-foreground: hsl(var(--popover-foreground));
24311
+ --color-card: hsl(var(--card));
24312
+ --color-card-foreground: hsl(var(--card-foreground));
24313
+ --color-border: hsl(var(--border));
24314
+ --color-input: hsl(var(--input));
24315
+ --color-primary: hsl(var(--primary));
24316
+ --color-primary-foreground: hsl(var(--primary-foreground));
24317
+ --color-secondary: hsl(var(--secondary));
24318
+ --color-secondary-foreground: hsl(var(--secondary-foreground));
24319
+ --color-destructive: hsl(var(--destructive));
24320
+ --color-destructive-foreground: hsl(var(--destructive-foreground));
24321
+ --color-ring: hsl(var(--ring));
24322
+
24323
+ --radius-xl: calc(var(--radius) + 4px);
24324
+ --radius-lg: var(--radius);
24325
+ --radius-md: calc(var(--radius) - 2px);
24326
+ --radius-sm: calc(var(--radius) - 4px);
24327
+ --radius-xs: min(calc(var(--radius) / 2.5), 6px);
24328
+
24329
+ --animate-accordion-down: accordion-down 0.2s ease-out;
24330
+ --animate-accordion-up: accordion-up 0.2s ease-out;
24331
+ --animate-collapsible-down: collapsible-down 0.2s ease-in-out;
24332
+ --animate-collapsible-up: collapsible-up 0.2s ease-in-out;
24333
+
24334
+ @keyframes accordion-down {
24335
+ from {
24336
+ height: 0;
24337
+ }
24338
+ to {
24339
+ height: var(--reka-accordion-content-height);
24340
+ }
24341
+ }
24342
+
24343
+ @keyframes accordion-up {
24344
+ from {
24345
+ height: var(--reka-accordion-content-height);
24346
+ }
24347
+ to {
24348
+ height: 0;
24349
+ }
24350
+ }
24351
+
24352
+ @keyframes collapsible-down {
24353
+ from {
24354
+ height: 0;
24355
+ }
24356
+ to {
24357
+ height: var(--reka-collapsible-content-height);
24358
+ }
24359
+ }
24360
+
24361
+ @keyframes collapsible-up {
24362
+ from {
24363
+ height: var(--reka-collapsible-content-height);
24364
+ }
24365
+ to {
24366
+ height: 0;
24367
+ }
24368
+ }
24369
+ }
24370
+
24371
+ @layer base {
24372
+ :root {
24373
+ --backdrop-filter-blur: 32px;
24374
+ --radius: 0.5rem;
24375
+
24376
+ <%- cssVarsLight %>
24377
+ }
24378
+
24379
+ .dark {
24380
+ <%- cssVarsDark %>
24381
+ }
24382
+
24383
+ * {
24384
+ @apply border-border;
24385
+ }
24386
+
24387
+ body {
24388
+ @apply bg-background text-foreground;
24389
+ }
24390
+ }
24391
+ `;
24392
+ var TAILWIND_KEYFRAMES_JS = `
24393
+ "sigma-ui-fade-in": {
24221
24394
  from: { opacity: 0 },
24222
24395
  to: { opacity: 1 },
24223
24396
  },
24224
- "accordion-down": {
24397
+ "sigma-ui-accordion-down": {
24225
24398
  from: { height: 0 },
24226
24399
  to: { height: "var(--reka-accordion-content-height)" },
24227
24400
  },
24228
- "accordion-up": {
24401
+ "sigma-ui-accordion-up": {
24229
24402
  from: { height: "var(--reka-accordion-content-height)" },
24230
24403
  to: { height: 0 },
24231
24404
  },
24232
- "collapsible-down": {
24405
+ "sigma-ui-collapsible-down": {
24233
24406
  from: { height: 0 },
24234
- to: { height: 'var(--reka-collapsible-content-height)' },
24407
+ to: { height: "var(--reka-collapsible-content-height)" },
24235
24408
  },
24236
- "collapsible-up": {
24237
- from: { height: 'var(--reka-collapsible-content-height)' },
24409
+ "sigma-ui-collapsible-up": {
24410
+ from: { height: "var(--reka-collapsible-content-height)" },
24238
24411
  to: { height: 0 },
24239
24412
  },
24413
+ "sigma-ui-popover-slide-blur-from-top": {
24414
+ from: { opacity: 0, transform: "translateY(-1rem) scaleY(0.98)", filter: "blur(4px)" },
24415
+ to: { opacity: 1, transform: "translateY(0) scaleY(1)", filter: "blur(0px)" },
24416
+ },
24417
+ "sigma-ui-popover-slide-blur-from-bottom": {
24418
+ from: { opacity: 0, transform: "translateY(1rem) scaleY(0.98)", filter: "blur(4px)" },
24419
+ to: { opacity: 1, transform: "translateY(0) scaleY(1)", filter: "blur(0px)" },
24420
+ },
24421
+ "sigma-ui-popover-slide-blur-from-left": {
24422
+ from: { opacity: 0, transform: "translateX(-1rem) scaleY(0.98)", filter: "blur(4px)" },
24423
+ to: { opacity: 1, transform: "translateX(0) scaleY(1)", filter: "blur(0px)" },
24424
+ },
24425
+ "sigma-ui-popover-slide-blur-from-right": {
24426
+ from: { opacity: 0, transform: "translateX(1rem) scaleY(0.98)", filter: "blur(4px)" },
24427
+ to: { opacity: 1, transform: "translateX(0) scaleY(1)", filter: "blur(0px)" },
24428
+ },
24429
+ "sigma-ui-popover-fade-scale-blur-out": {
24430
+ from: { opacity: 1, transform: "scaleY(1)", filter: "blur(0px)" },
24431
+ to: { opacity: 0, transform: "scaleY(0.98)", filter: "blur(4px)" },
24432
+ },
24240
24433
  `;
24241
- var TAILWIND_ANIMATION = `
24242
- "fade-in": "fade-in 0.5s ease-in-out",
24243
- "accordion-down": "accordion-down 0.2s ease-out",
24244
- "accordion-up": "accordion-up 0.2s ease-out",
24245
- "collapsible-down": "collapsible-down 0.2s ease-in-out",
24246
- "collapsible-up": "collapsible-up 0.2s ease-in-out",
24247
- `;
24248
- var UTILS_TEMPLATE = `import { type ClassValue, clsx } from 'clsx'
24249
- import { twMerge } from 'tailwind-merge'
24250
-
24251
- export function cn(...inputs: ClassValue[]) {
24252
- return twMerge(clsx(inputs))
24253
- }
24434
+ var TAILWIND_ANIMATION_JS = `
24435
+ "fade-in": "sigma-ui-fade-in 0.5s ease-in-out",
24436
+ "accordion-down": "sigma-ui-accordion-down 0.2s ease-out",
24437
+ "accordion-up": "sigma-ui-accordion-up 0.2s ease-out",
24438
+ "collapsible-down": "sigma-ui-collapsible-down 0.2s ease-in-out",
24439
+ "collapsible-up": "sigma-ui-collapsible-up 0.2s ease-in-out",
24440
+ "popover-slide-blur-from-top": "sigma-ui-popover-slide-blur-from-top 150ms ease-out",
24441
+ "popover-slide-blur-from-bottom": "sigma-ui-popover-slide-blur-from-bottom 150ms ease-out",
24442
+ "popover-slide-blur-from-left": "sigma-ui-popover-slide-blur-from-left 150ms ease-out",
24443
+ "popover-slide-blur-from-right": "sigma-ui-popover-slide-blur-from-right 150ms ease-out",
24444
+ "popover-fade-scale-blur-out": "sigma-ui-popover-fade-scale-blur-out 150ms ease-in",
24254
24445
  `;
24255
- var TAILWIND_CONFIG_TEMPLATE = `const animate = require("tailwindcss-animate")
24446
+ var TAILWIND_CONFIG_JS_TEMPLATE = `const animate = require("tailwindcss-animate")
24256
24447
 
24257
24448
  /** @type {import('tailwindcss').Config} */
24258
24449
  module.exports = {
@@ -24326,15 +24517,39 @@ module.exports = {
24326
24517
  xs: 'min(calc(var(--radius) / 2.5), 6px)',
24327
24518
  },
24328
24519
  keyframes: {
24329
- ${TAILWIND_KEYFRAMES}
24520
+ ${TAILWIND_KEYFRAMES_JS}
24330
24521
  },
24331
24522
  animation: {
24332
- ${TAILWIND_ANIMATION}
24523
+ ${TAILWIND_ANIMATION_JS}
24333
24524
  },
24334
24525
  },
24335
24526
  },
24336
24527
  plugins: [animate],
24337
24528
  }`;
24529
+ var TAILWIND_CSS_WITH_JS_CONFIG_TEMPLATE = `@import "tailwindcss";
24530
+ @config "<%- configPath %>";
24531
+
24532
+ @layer base {
24533
+ :root {
24534
+ --backdrop-filter-blur: 32px;
24535
+ --radius: 0.5rem;
24536
+
24537
+ <%- cssVarsLight %>
24538
+ }
24539
+
24540
+ .dark {
24541
+ <%- cssVarsDark %>
24542
+ }
24543
+
24544
+ * {
24545
+ @apply border-border;
24546
+ }
24547
+
24548
+ body {
24549
+ @apply bg-background text-foreground;
24550
+ }
24551
+ }
24552
+ `;
24338
24553
 
24339
24554
  // ../shared/templates/preflight.ts
24340
24555
  var PREFLIGHT_CSS_TEMPLATE = `
@@ -24753,22 +24968,19 @@ var PROJECT_DEV_DEPENDENCIES = {
24753
24968
  ]
24754
24969
  }
24755
24970
  };
24756
- var init = new Command3().name("init").description("initialize your project and install dependencies").option("-y, --yes", "skip confirmation prompt.", false).option(
24971
+ var init = new Command3().name("init").description("initialize your project and install dependencies").option("-y, --yes", "skip confirmation prompt.", false).option("-d, --defaults", "use default configuration without prompts.", false).option(
24757
24972
  "-c, --cwd <cwd>",
24758
24973
  "the working directory. defaults to the current directory.",
24759
24974
  process5.cwd()
24760
24975
  ).action(async (opts) => {
24761
24976
  try {
24762
- const spinner = ora2("Fetching data...").start();
24763
24977
  const options8 = initOptionsSchema.parse(opts);
24764
24978
  const cwd = path14.resolve(options8.cwd);
24765
24979
  if (!existsSync6(cwd)) {
24766
24980
  consola5.error(`The path ${cwd} does not exist. Please try again.`);
24767
24981
  process5.exit(1);
24768
24982
  }
24769
- const existingConfig = await getConfig(cwd);
24770
- spinner.stop();
24771
- const config = await promptForConfig(cwd, existingConfig, options8.yes);
24983
+ const config = await promptForConfig(cwd, options8.yes, options8.defaults);
24772
24984
  await runInit(cwd, config);
24773
24985
  consola5.log("");
24774
24986
  consola5.info(
@@ -24779,115 +24991,111 @@ var init = new Command3().name("init").description("initialize your project and
24779
24991
  handleError(error);
24780
24992
  }
24781
24993
  });
24782
- async function promptForConfig(cwd, defaultConfig = null, skip2 = false) {
24994
+ function getDetectedConfig(projectInfo) {
24995
+ const { framework, tsConfigPath, hasTailwind, tailwindConfigType, tailwindConfigPath } = projectInfo;
24996
+ return {
24997
+ framework,
24998
+ tsConfigPath,
24999
+ cssPath: TAILWIND_CSS_PATH[framework],
25000
+ tailwindConfigPath: tailwindConfigPath ?? (framework === "astro" ? "tailwind.config.mjs" : DEFAULT_TAILWIND_CONFIG),
25001
+ tailwindConfigType,
25002
+ setupTailwind: !hasTailwind
25003
+ };
25004
+ }
25005
+ async function promptForConfig(cwd, skipConfirmation = false, useDefaults = false) {
24783
25006
  const highlight = (text) => colors4.cyan(text);
25007
+ const spinner = ora2("Detecting project settings...").start();
25008
+ const projectInfo = await getProjectInfo(cwd);
25009
+ const detectedConfig = getDetectedConfig(projectInfo);
24784
25010
  const styles3 = await getRegistryStyles();
24785
25011
  const baseColors2 = await getRegistryBaseColors();
25012
+ spinner.stop();
25013
+ consola5.info(`Detected ${highlight(detectedConfig.framework)} project`);
25014
+ if (useDefaults) {
25015
+ const config2 = createConfig({
25016
+ framework: detectedConfig.framework,
25017
+ styleSystem: "tailwind",
25018
+ tailwindBaseColor: "grayscale",
25019
+ componentNaming: "pascal-case",
25020
+ tsConfigPath: detectedConfig.tsConfigPath,
25021
+ cssPath: detectedConfig.cssPath,
25022
+ tailwindConfigPath: detectedConfig.tailwindConfigPath,
25023
+ tailwindConfigType: detectedConfig.tailwindConfigType,
25024
+ setupTailwind: detectedConfig.setupTailwind,
25025
+ components: DEFAULT_COMPONENTS,
25026
+ utils: DEFAULT_UTILS,
25027
+ generatePreflight: true
25028
+ });
25029
+ await writeConfigFile(cwd, config2);
25030
+ return await resolveConfigPaths(cwd, config2);
25031
+ }
24786
25032
  const options8 = await prompts2([
24787
- {
24788
- type: "select",
24789
- name: "framework",
24790
- message: `Which ${highlight("framework")} are you using?`,
24791
- choices: [
24792
- { title: "Vite", value: "vite" },
24793
- { title: "Nuxt", value: "nuxt" },
24794
- { title: "Laravel", value: "laravel" },
24795
- { title: "Astro", value: "astro" }
24796
- ]
24797
- },
24798
25033
  {
24799
25034
  type: "select",
24800
25035
  name: "styleSystem",
24801
- message: `Which ${highlight("style system")} are you using?`,
25036
+ message: `Which ${highlight("style system")} would you like to use?`,
24802
25037
  choices: styles3.map((style) => ({
24803
25038
  title: style.label,
24804
25039
  value: style.name
24805
25040
  }))
24806
25041
  },
24807
- {
24808
- type: (_, answers) => answers.styleSystem === "tailwind" ? "toggle" : null,
24809
- name: "setupTailwind",
24810
- message: `Setup ${highlight("Tailwind")} in this project for you?`,
24811
- initial: !defaultConfig?.tailwind.config,
24812
- active: "yes",
24813
- inactive: "no"
24814
- },
24815
25042
  {
24816
25043
  type: "select",
24817
25044
  name: "tailwindBaseColor",
24818
- message: `Choose primary ${highlight("base color")}:`,
25045
+ message: `Choose a ${highlight("base color")} for your theme:`,
24819
25046
  choices: baseColors2.map((color) => ({
24820
25047
  title: color.label,
24821
25048
  value: color.name
24822
25049
  }))
24823
25050
  },
24824
25051
  {
24825
- type: (_, answers) => answers.styleSystem === "tailwind" ? "text" : null,
24826
- name: "tailwindConfig",
24827
- message: `Specify the path to ${highlight("tailwind")} config file ${colors4.gray("(it will be overwritten / created)")}`,
24828
- initial: (_, answers) => {
24829
- if (defaultConfig?.tailwind.config) {
24830
- return defaultConfig?.tailwind.config;
24831
- }
24832
- if (answers.framework === "astro") {
24833
- return "tailwind.config.mjs";
24834
- } else {
24835
- return DEFAULT_TAILWIND_CONFIG;
24836
- }
24837
- }
24838
- },
24839
- {
24840
- type: "text",
24841
- name: "tsConfigPath",
24842
- message: `Specify the path to ${highlight("tsconfig")} file`,
24843
- initial: (_, values) => {
24844
- const prefix = values.framework === "nuxt" ? ".nuxt/" : "./";
24845
- return `${prefix}tsconfig.json`;
24846
- }
24847
- },
24848
- {
24849
- type: "text",
24850
- name: "cssPath",
24851
- message: `Specify the path to ${highlight("global CSS")} file ${colors4.gray("(it will be overwritten / created)")}`,
24852
- initial: (_, values) => defaultConfig?.cssPath ?? TAILWIND_CSS_PATH[values.framework]
24853
- },
24854
- {
24855
- type: "text",
24856
- name: "components",
24857
- message: `Configure the import alias for ${highlight("components")}:`,
24858
- initial: defaultConfig?.aliases.components ?? DEFAULT_COMPONENTS
24859
- },
24860
- {
24861
- type: (_, answers) => answers.styleSystem === "tailwind" ? "text" : null,
24862
- name: "utils",
24863
- message: `Configure the import alias for ${highlight("utils")}:`,
24864
- initial: defaultConfig?.aliases.utils ?? DEFAULT_UTILS
24865
- },
24866
- {
24867
- type: (_, answers) => answers.styleSystem === "css" ? "toggle" : null,
24868
- name: "generatePreflight",
24869
- message: `Generate ${highlight("preflight.css")} with modern CSS reset? ${colors4.gray("(recommended)")}`,
24870
- initial: true,
24871
- active: "yes",
24872
- inactive: "no"
25052
+ type: "select",
25053
+ name: "componentNaming",
25054
+ message: `Choose ${highlight("component naming")} convention:`,
25055
+ choices: [
25056
+ { title: "PascalCase (Button.vue)", value: "pascal-case" },
25057
+ { title: "kebab-case (button.vue)", value: "kebab-case" }
25058
+ ],
25059
+ initial: 0
24873
25060
  }
24874
25061
  ]);
24875
- if (!skip2) {
25062
+ if (!skipConfirmation) {
25063
+ consola5.log("");
25064
+ consola5.box(
25065
+ `Framework: ${highlight(detectedConfig.framework)}
25066
+ Style: ${highlight(options8.styleSystem)}
25067
+ Theme: ${highlight(options8.tailwindBaseColor)}
25068
+ Naming: ${highlight(options8.componentNaming)}
25069
+ CSS: ${highlight(detectedConfig.cssPath)}
25070
+ Components: ${highlight(DEFAULT_COMPONENTS)}`
25071
+ );
24876
25072
  const { proceed } = await prompts2({
24877
25073
  type: "confirm",
24878
25074
  name: "proceed",
24879
- message: `Configuration is done. The config file will be created (${highlight(CONFIG_FILE_PATH)}) and the required dependencies will be installed. Make sure to handle any unstaged Git changes before proceeding. Finish setup?`,
25075
+ message: "Proceed with installation?",
24880
25076
  initial: true
24881
25077
  });
24882
25078
  if (!proceed) {
24883
25079
  process5.exit(0);
24884
25080
  }
24885
25081
  }
24886
- const config = createConfig(options8);
25082
+ const config = createConfig({
25083
+ ...options8,
25084
+ framework: detectedConfig.framework,
25085
+ tsConfigPath: detectedConfig.tsConfigPath,
25086
+ cssPath: detectedConfig.cssPath,
25087
+ tailwindConfigPath: options8.styleSystem === "tailwind" ? detectedConfig.tailwindConfigPath : "",
25088
+ tailwindConfigType: detectedConfig.tailwindConfigType,
25089
+ setupTailwind: options8.styleSystem === "tailwind" ? detectedConfig.setupTailwind : false,
25090
+ components: DEFAULT_COMPONENTS,
25091
+ utils: DEFAULT_UTILS,
25092
+ generatePreflight: options8.styleSystem === "css"
25093
+ });
24887
25094
  await writeConfigFile(cwd, config);
24888
25095
  return await resolveConfigPaths(cwd, config);
24889
25096
  }
24890
25097
  function createConfig(options8) {
25098
+ const usesJsConfig = options8.tailwindConfigType === "js";
24891
25099
  const config = rawConfigSchema.parse({
24892
25100
  $schema: "https://sigma-ui.dev/schema.json",
24893
25101
  styleSystem: options8.styleSystem,
@@ -24897,13 +25105,14 @@ function createConfig(options8) {
24897
25105
  cssPath: options8.cssPath,
24898
25106
  baseColor: options8.tailwindBaseColor,
24899
25107
  tailwind: {
24900
- config: options8.tailwindConfig || ""
25108
+ config: usesJsConfig ? options8.tailwindConfigPath : ""
24901
25109
  },
24902
25110
  aliases: {
24903
25111
  utils: options8.utils || "",
24904
25112
  components: options8.components
24905
25113
  },
24906
- generatePreflight: options8.generatePreflight
25114
+ generatePreflight: options8.generatePreflight,
25115
+ componentNaming: options8.componentNaming || "pascal-case"
24907
25116
  });
24908
25117
  return config;
24909
25118
  }
@@ -24914,38 +25123,39 @@ async function writeConfigFile(cwd, config) {
24914
25123
  await fs8.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
24915
25124
  spinner.succeed();
24916
25125
  }
24917
- async function handleNuxtProject() {
24918
- const { isNuxt, sigmaUiNuxtModuleInfo } = await getProjectInfo();
24919
- if (isNuxt) {
25126
+ async function handleNuxtProject(cwd) {
25127
+ const projectInfo = await getProjectInfo(cwd);
25128
+ if (projectInfo.framework === "nuxt") {
24920
25129
  consola5.log("");
24921
- if (sigmaUiNuxtModuleInfo) {
24922
- consola5.info(`Detected a Nuxt project with 'sigma-ui-nuxt' v${sigmaUiNuxtModuleInfo.version}`);
25130
+ if (projectInfo.sigmaUiNuxtModuleInfo) {
25131
+ consola5.info(`Detected a Nuxt project with 'sigma-ui-nuxt' v${projectInfo.sigmaUiNuxtModuleInfo.version}`);
24923
25132
  } else {
24924
25133
  consola5.warn(`Detected a Nuxt project without 'sigma-ui-nuxt' module. It's recommended to install it.`);
24925
25134
  }
24926
25135
  }
24927
25136
  }
24928
25137
  async function runInit(cwd, config) {
24929
- await writeFiles(config);
25138
+ await writeFiles(config, cwd);
24930
25139
  await installDependencies2(config, cwd);
24931
25140
  }
24932
- async function writeFiles(config) {
25141
+ async function writeFiles(config, cwd) {
24933
25142
  const writeFilesSpinner = ora2("Initializing project")?.start();
24934
- await handleNuxtProject();
25143
+ await handleNuxtProject(cwd);
24935
25144
  await ensureDirectoriesExist(config);
24936
- if (config.tailwind.config) {
24937
- writeTailwindConfig(config);
24938
- if (config.framework === "vite" && config.setupTailwind) {
24939
- await updateViteConfig();
24940
- }
25145
+ const hasJsConfig = Boolean(config.tailwind.config && config.tailwind.config.length > 0);
25146
+ if (hasJsConfig) {
25147
+ await writeTailwindJsConfig(config);
24941
25148
  }
24942
- writeCssFile(config);
25149
+ if (config.framework === "vite" && config.setupTailwind) {
25150
+ await updateViteConfig();
25151
+ }
25152
+ await writeCssFile(config, hasJsConfig);
24943
25153
  writeCnFile(config);
24944
25154
  await writePreflightCss(config);
24945
25155
  writeFilesSpinner?.succeed();
24946
25156
  }
24947
- async function writeTailwindConfig(config) {
24948
- const unformattedConfig = template(TAILWIND_CONFIG_TEMPLATE)({
25157
+ async function writeTailwindJsConfig(config) {
25158
+ const unformattedConfig = template(TAILWIND_CONFIG_JS_TEMPLATE)({
24949
25159
  framework: config.framework,
24950
25160
  prefix: config.tailwind.prefix,
24951
25161
  extension: "ts"
@@ -24966,23 +25176,47 @@ async function writeTailwindConfig(config) {
24966
25176
  "utf8"
24967
25177
  );
24968
25178
  }
24969
- async function writeCssFile(config) {
25179
+ async function writeCssFile(config, hasJsConfig) {
24970
25180
  const baseColorData = await getRegistryBaseColor(config.baseColor);
24971
- if (baseColorData) {
24972
- const file = config.resolvedPaths.tailwindCss;
24973
- let data = "";
24974
- if (config.styleSystem === "tailwind") {
24975
- data = config.tailwind.prefix ? applyPrefixesCss(baseColorData.templates.tailwind.withVariables, config.tailwind.prefix) : baseColorData.templates.tailwind.withVariables;
24976
- } else if (config.styleSystem === "css") {
24977
- data = baseColorData.templates.css.withVariables;
24978
- if (config.generatePreflight) {
24979
- data = `@import "./preflight.css";
25181
+ if (!baseColorData) {
25182
+ return;
25183
+ }
25184
+ const file = config.resolvedPaths.tailwindCss;
25185
+ let data = "";
25186
+ if (config.styleSystem === "tailwind") {
25187
+ const cssVarsLight = generateCssVars(baseColorData.cssVars.light);
25188
+ const cssVarsDark = generateCssVars(baseColorData.cssVars.dark);
25189
+ if (hasJsConfig) {
25190
+ data = template(TAILWIND_CSS_WITH_JS_CONFIG_TEMPLATE)({
25191
+ configPath: config.tailwind.config,
25192
+ cssVarsLight,
25193
+ cssVarsDark
25194
+ });
25195
+ } else {
25196
+ data = template(TAILWIND_V4_CSS_TEMPLATE)({
25197
+ cssVarsLight,
25198
+ cssVarsDark
25199
+ });
25200
+ }
25201
+ if (config.tailwind.prefix) {
25202
+ data = applyPrefixesCss(data, config.tailwind.prefix);
25203
+ }
25204
+ } else if (config.styleSystem === "css") {
25205
+ data = baseColorData.templates.css.withVariables;
25206
+ if (config.generatePreflight) {
25207
+ data = `@import "./preflight.css";
24980
25208
 
24981
25209
  ${data}`;
24982
- }
24983
25210
  }
24984
- await fs8.writeFile(file, data, "utf8");
24985
25211
  }
25212
+ const formattedCss = await src_default.format(data, {
25213
+ parser: "css",
25214
+ singleQuote: true
25215
+ });
25216
+ await fs8.writeFile(file, formattedCss, "utf8");
25217
+ }
25218
+ function generateCssVars(vars) {
25219
+ return Object.entries(vars).map(([key2, value]) => `--${key2}: ${value};`).join("\n ");
24986
25220
  }
24987
25221
  async function writeCnFile(config) {
24988
25222
  if (config.resolvedPaths.utils) {
@@ -25004,11 +25238,11 @@ async function writePreflightCss(config) {
25004
25238
  }
25005
25239
  }
25006
25240
  async function installDependencies2(config, cwd) {
25007
- const { sigmaUiNuxtModuleInfo } = await getProjectInfo();
25241
+ const projectInfo = await getProjectInfo(cwd);
25008
25242
  const dependenciesSpinner = ora2("Installing dependencies")?.start();
25009
25243
  let baseDeps = [];
25010
25244
  let baseDevDeps = [];
25011
- if (sigmaUiNuxtModuleInfo?.version) {
25245
+ if (projectInfo.sigmaUiNuxtModuleInfo?.version) {
25012
25246
  baseDeps = [];
25013
25247
  } else {
25014
25248
  if (config.styleSystem === "css") {