centoui-nuxt 1.0.0-alpha.3 → 1.0.0-alpha.30

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/README.md CHANGED
@@ -1,30 +1,67 @@
1
- # centoui-nuxt
1
+ <div align="center">
2
+ <h1>🚀 centoui-nuxt</h1>
3
+ <p><strong>CentoUI, seamlessly integrated with Nuxt.</strong></p>
4
+ <p>
5
+ <a href="https://npmx.dev/package/centoui-nuxt"><img src="https://img.shields.io/npm/v/centoui-nuxt.svg?style=plastic&label=NPM Version&color=blue" alt="npm version"></a>
6
+ <a href="https://npmx.dev/package/centoui-nuxt"><img src="https://img.shields.io/npm/dw/centoui-nuxt.svg?style=plastic&label=NPM Downloads&color=blue" alt="npm downloads"></a>
7
+ <a href="https://npmx.dev/package/centoui-nuxt"><img src="https://img.shields.io/npm/unpacked-size/centoui-nuxt?style=plastic" alt="NPM Unpacked Size"></a>
8
+ </p>
9
+ </div>
2
10
 
3
- [![npm version](https://img.shields.io/npm/v/centoui-nuxt.svg?style=flat-square)](https://www.npmjs.com/package/centoui-nuxt)
4
- [![npm downloads](https://img.shields.io/npm/dm/centoui-nuxt.svg?style=flat-square)](https://www.npmjs.com/package/centoui-nuxt)
5
- [![license](https://img.shields.io/github/license/favorodera/centoui.svg?style=flat-square)](https://github.com/favorodera/centoui/blob/main/LICENSE)
6
- [![Nuxt](https://img.shields.io/badge/Nuxt-020420?logo=nuxt)](https://nuxt.com)
11
+ <br>
7
12
 
8
- **Precise vue components. Seamlessly integrated with Nuxt.**
13
+ `centoui-nuxt` is the official Nuxt module for [CentoUI](../core). It auto-registers every CentoUI component in your project so you can use them in templates without manual imports.
9
14
 
10
- `centoui-nuxt` is the official Nuxt module for [CentoUI](https://github.com/favorodera/centoui).
11
-
12
- ## Quick Setup
13
-
14
- Install the module to your Nuxt application:
15
+ ## Installation
15
16
 
16
17
  ```bash
17
- pnpm add centoui-nuxt centoui
18
+ pnpm add centoui
19
+ pnpm add -D centoui-nuxt
18
20
  ```
19
21
 
20
- Add `centoui-nuxt` to the `modules` section of `nuxt.config.ts`:
22
+ ## Setup
23
+
24
+ Add `centoui-nuxt` to the `modules` section of your `nuxt.config.ts`:
21
25
 
22
26
  ```ts
23
27
  export default defineNuxtConfig({
24
28
  modules: [
25
29
  'centoui-nuxt'
26
- ]
30
+ ],
31
+ centoui: {
32
+ // Optional: prefix all component names
33
+ prefix: "Cento",
34
+ }
27
35
  })
28
36
  ```
29
37
 
30
- That's it! You can now use CentoUI components in your Nuxt app
38
+ That's it all components from your `centoui.config.ts` component directory are now globally available.
39
+
40
+ ## What the Module Does
41
+
42
+ 1. **Reads your `centoui.config.ts`** — Picks up `componentsDir` to know where your CentoUI components live.
43
+ 2. **Auto-registers every `.vue` file** — Scans component group folders (e.g., `button/`, `select/`) and registers each `.vue` file as a global Nuxt component.
44
+ 3. **Converts names to PascalCase** — A file named `alert-root.vue` becomes `AlertRoot` (or `CentoAlertRoot` with `prefix: "Cento"`).
45
+ 4. **Exposes config at `#centoui/config`** — Your resolved `centoui.config.ts` is available as a Nuxt template import for runtime access.
46
+ 5. **Pre-bundles dependencies** — Adds `@vueuse/core`, `reka-ui`, `tailwind-variants`, and `@iconify/vue` to Vite's `optimizeDeps` for faster dev startup.
47
+
48
+ ## Options
49
+
50
+ | Option | Type | Default | Description |
51
+ |--------|------|---------|-------------|
52
+ | `prefix` | `string` | `""` | Prepended to every registered component name in PascalCase. `"Cento"` turns `Button` into `CentoButton`. |
53
+
54
+ ## Prerequisites
55
+
56
+ Before using this module, you need a CentoUI project initialized with the CLI:
57
+
58
+ ```bash
59
+ pnpm dlx centoui init
60
+ pnpm dlx centoui add button accordion
61
+ ```
62
+
63
+ The module reads from the component directory created by `centoui init`. Without it, there are no components to register.
64
+
65
+ ## License
66
+
67
+ [MIT](../../LICENSE) &copy; [Favour Emeka](https://github.com/favorodera)
package/dist/module.d.mts CHANGED
@@ -1,5 +1,13 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
- declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
3
+ interface ModuleOptions {
4
+ /**
5
+ * Prefix for all registered components (normalized to PascalCase internally).
6
+ * @default ""
7
+ */
8
+ prefix?: string;
9
+ }
10
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
4
11
 
5
12
  export { _default as default };
13
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "centoui-nuxt",
3
3
  "configKey": "centoui",
4
- "version": "1.0.0-alpha.3",
4
+ "version": "1.0.0-alpha.30",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,12 +1,80 @@
1
- import { defineNuxtModule } from '@nuxt/kit';
1
+ import { existsSync, readdirSync } from 'node:fs';
2
+ import { defineNuxtModule, addComponentsDir, addTemplate, extendViteConfig, addComponent } from '@nuxt/kit';
3
+ import { loadConfig } from 'c12';
4
+ import { join, basename } from 'pathe';
2
5
 
6
+ function kebabToPascalCase(kebabString) {
7
+ return kebabString.toLowerCase().split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
8
+ }
9
+ function buildComponentName(prefix, base) {
10
+ const pascalBase = kebabToPascalCase(base);
11
+ if (!prefix) {
12
+ return pascalBase;
13
+ }
14
+ const pascalPrefix = kebabToPascalCase(prefix);
15
+ return `${pascalPrefix}${pascalBase}`;
16
+ }
3
17
  const module$1 = defineNuxtModule({
4
18
  meta: {
5
19
  name: "centoui-nuxt",
6
20
  configKey: "centoui"
7
21
  },
8
- defaults: {},
9
- setup() {
22
+ defaults: {
23
+ prefix: ""
24
+ },
25
+ async setup(options, nuxt) {
26
+ const rootDir = nuxt.options.rootDir;
27
+ const { config } = await loadConfig({
28
+ name: "centoui",
29
+ cwd: rootDir
30
+ });
31
+ const componentsDir = join(rootDir, config.componentsDir);
32
+ if (!existsSync(componentsDir)) {
33
+ console.warn(`[centoui-nuxt] Component directory not found: ${componentsDir}`);
34
+ return;
35
+ }
36
+ addComponentsDir(
37
+ {
38
+ path: componentsDir,
39
+ extensions: [],
40
+ ignore: ["**/*"]
41
+ },
42
+ { prepend: true }
43
+ );
44
+ function registerComponents(componentsDir2) {
45
+ for (const group of readdirSync(componentsDir2, { withFileTypes: true })) {
46
+ if (!group.isDirectory()) continue;
47
+ const groupPath = join(componentsDir2, group.name);
48
+ for (const file of readdirSync(groupPath, { withFileTypes: true })) {
49
+ if (file.isFile() && file.name.endsWith(".vue")) {
50
+ addComponent({
51
+ name: buildComponentName(options.prefix, basename(file.name, ".vue")),
52
+ filePath: join(groupPath, file.name),
53
+ priority: 1
54
+ // Override default user components
55
+ });
56
+ }
57
+ }
58
+ }
59
+ }
60
+ registerComponents(componentsDir);
61
+ addTemplate({
62
+ filename: "centoui/config.ts",
63
+ write: true,
64
+ getContents: () => `export default ${JSON.stringify(config, null, 2)} as const
65
+ `
66
+ });
67
+ nuxt.options.alias["#centoui/config"] = join(nuxt.options.buildDir, "centoui/config.ts");
68
+ extendViteConfig((config2) => {
69
+ config2.optimizeDeps ||= {};
70
+ config2.optimizeDeps.include ||= [];
71
+ config2.optimizeDeps.include.push(
72
+ "@vueuse/core",
73
+ "reka-ui",
74
+ "tailwind-variants",
75
+ "@iconify/vue"
76
+ );
77
+ });
10
78
  }
11
79
  });
12
80
 
package/dist/types.d.mts CHANGED
@@ -1,7 +1,3 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module.mjs'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
1
  export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "centoui-nuxt",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "Official Nuxt module for CentoUI",
5
+ "keywords": [
6
+ "nuxt",
7
+ "nuxt-module",
8
+ "vue",
9
+ "ui",
10
+ "components",
11
+ "tailwindcss"
12
+ ],
5
13
  "author": "Favour Emeka <favorodera@gmail.com>",
6
14
  "license": "MIT",
7
15
  "homepage": "https://centoui.vercel.app",
@@ -33,16 +41,23 @@
33
41
  "access": "public"
34
42
  },
35
43
  "dependencies": {
36
- "@nuxt/kit": "^4.4.2"
44
+ "@nuxt/kit": "^4.4.6",
45
+ "c12": "4.0.0-beta.5",
46
+ "pathe": "^2.0.3"
47
+ },
48
+ "peerDependencies": {
49
+ "centoui": "1.0.0-alpha.30"
37
50
  },
38
51
  "devDependencies": {
39
52
  "@nuxt/module-builder": "^1.0.2",
40
- "@nuxt/schema": "^4.4.2",
41
- "nuxt": "^4.4.2",
42
- "vue-tsc": "^3.2.6"
53
+ "@nuxt/schema": "^4.4.6",
54
+ "nuxt": "^4.4.6",
55
+ "vue-tsc": "^3.2.6",
56
+ "centoui": "1.0.0-alpha.30"
43
57
  },
44
58
  "engines": {
45
- "node": ">=24.13.0"
59
+ "node": ">=22.0.0",
60
+ "pnpm": ">=11.0.0"
46
61
  },
47
62
  "scripts": {
48
63
  "dev": "nuxt prepare && nuxt-module-build build --stub",