nue-ui-resolver 0.1.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/README.md +120 -0
- package/index.ts +90 -0
- package/package.json +28 -0
- package/tsconfig.json +3 -0
- package/types.ts +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @nue-ui/resolver
|
|
2
|
+
|
|
3
|
+
Resolver for `unplugin-vue-components` to auto-import NueUI Vue 3 components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# npm
|
|
9
|
+
npm install @nue-ui/resolver -D
|
|
10
|
+
|
|
11
|
+
# pnpm
|
|
12
|
+
pnpm add @nue-ui/resolver -D
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Vite Configuration
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// vite.config.ts
|
|
21
|
+
import Components from 'unplugin-vue-components/vite';
|
|
22
|
+
import { NueUiResolver } from '@nue-ui/resolver';
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
plugins: [
|
|
26
|
+
Components({
|
|
27
|
+
resolvers: [NueUiResolver()]
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### With Additional Options
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// vite.config.ts
|
|
37
|
+
import Components from 'unplugin-vue-components/vite';
|
|
38
|
+
import { NueUiResolver } from '@nue-ui/resolver';
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [
|
|
42
|
+
Components({
|
|
43
|
+
resolvers: [
|
|
44
|
+
NueUiResolver({
|
|
45
|
+
// Custom import path (default: '@nue-ui/components')
|
|
46
|
+
importPath: '@nue-ui/components'
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Important: Manual CSS Import
|
|
55
|
+
|
|
56
|
+
This resolver only handles **component auto-import**. You must manually import the component CSS:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// main.ts
|
|
60
|
+
import 'nue-ui/dist/index.css';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or import individual component CSS:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// main.ts
|
|
67
|
+
import 'nue-ui/dist/theme/button.css';
|
|
68
|
+
import 'nue-ui/dist/theme/dialog.css';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Supported Components
|
|
72
|
+
|
|
73
|
+
- NueAside
|
|
74
|
+
- NueAvatar
|
|
75
|
+
- NueBadge
|
|
76
|
+
- NueBreadcrumb
|
|
77
|
+
- NueBreadcrumbItem
|
|
78
|
+
- NueButton
|
|
79
|
+
- NueButtonGroup
|
|
80
|
+
- NueCheckbox
|
|
81
|
+
- NueCheckboxGroup
|
|
82
|
+
- NueCollapse
|
|
83
|
+
- NueCollapseItem
|
|
84
|
+
- NueContainer
|
|
85
|
+
- NueContent
|
|
86
|
+
- NueDialog
|
|
87
|
+
- NueDiv
|
|
88
|
+
- NueDivider
|
|
89
|
+
- NueDrawer
|
|
90
|
+
- NueDropdown
|
|
91
|
+
- NueDropdownItem
|
|
92
|
+
- NueEmpty
|
|
93
|
+
- NueFooter
|
|
94
|
+
- NueHeader
|
|
95
|
+
- NueIcon
|
|
96
|
+
- NueInfiniteScroll
|
|
97
|
+
- NueInput
|
|
98
|
+
- NueLink
|
|
99
|
+
- NueMain
|
|
100
|
+
- NueMarquee
|
|
101
|
+
- NueMessageWrapper
|
|
102
|
+
- NuePopupPool
|
|
103
|
+
- NueProgress
|
|
104
|
+
- NueSwitch
|
|
105
|
+
- NueSelect
|
|
106
|
+
- NueSelectOption
|
|
107
|
+
- NueSeparator
|
|
108
|
+
- NueText
|
|
109
|
+
- NueTextarea
|
|
110
|
+
- NueTooltip
|
|
111
|
+
|
|
112
|
+
## Options
|
|
113
|
+
|
|
114
|
+
| Option | Type | Default | Description |
|
|
115
|
+
| ------------ | -------- | -------------------- | -------------------------- |
|
|
116
|
+
| `importPath` | `string` | `@nue-ui/components` | Import path for components |
|
|
117
|
+
|
|
118
|
+
## TypeScript
|
|
119
|
+
|
|
120
|
+
This package includes TypeScript declarations.
|
package/index.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NueUI Resolver
|
|
3
|
+
* Resolver for unplugin-vue-components to auto-import NueUI components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ComponentResolver } from 'unplugin-vue-components';
|
|
7
|
+
|
|
8
|
+
const COMPONENTS = [
|
|
9
|
+
'NueAvatar',
|
|
10
|
+
'NueBadge',
|
|
11
|
+
'NueBreadcrumb',
|
|
12
|
+
'NueButton',
|
|
13
|
+
'NueButtonGroup',
|
|
14
|
+
'NueCheckbox',
|
|
15
|
+
'NueCheckboxGroup',
|
|
16
|
+
'NueCollapse',
|
|
17
|
+
'NueConfirm',
|
|
18
|
+
'NueContainer',
|
|
19
|
+
'NueDialog',
|
|
20
|
+
'NueDiv',
|
|
21
|
+
'NueDivider',
|
|
22
|
+
'NueDrawer',
|
|
23
|
+
'NueDropdown',
|
|
24
|
+
'NueEmpty',
|
|
25
|
+
'NueIcon',
|
|
26
|
+
'NueInfiniteScroll',
|
|
27
|
+
'NueInput',
|
|
28
|
+
'NueLink',
|
|
29
|
+
'NuePopupPool',
|
|
30
|
+
'NueProgress',
|
|
31
|
+
'NuePrompt',
|
|
32
|
+
'NueSelect',
|
|
33
|
+
'NueSwitch',
|
|
34
|
+
'NueText',
|
|
35
|
+
'NueTooltip',
|
|
36
|
+
'NueMarquee',
|
|
37
|
+
'NueMessage'
|
|
38
|
+
] as const;
|
|
39
|
+
|
|
40
|
+
const COMPONENT_SET = new Set<string>(COMPONENTS);
|
|
41
|
+
|
|
42
|
+
function pascalToKebab(str: string): string {
|
|
43
|
+
// Strip 'Nue' prefix if present (NueButton -> button)
|
|
44
|
+
const nameWithoutPrefix = str.replace(/^Nue/, '');
|
|
45
|
+
return nameWithoutPrefix.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function normalizeToPascal(name: string): string {
|
|
49
|
+
// If already PascalCase (starts with uppercase and has no dashes), return as-is
|
|
50
|
+
if (!name.includes('-') && /^[A-Z]/.test(name)) {
|
|
51
|
+
return name;
|
|
52
|
+
}
|
|
53
|
+
// Convert kebab-case to PascalCase
|
|
54
|
+
return name
|
|
55
|
+
.split('-')
|
|
56
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
57
|
+
.join('');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface NueUiResolverOptions {
|
|
61
|
+
/** @default '@nue-ui/components' */
|
|
62
|
+
importPath?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function resolve(options: NueUiResolverOptions = {}): ComponentResolver {
|
|
66
|
+
const importPath = options.importPath || '@nue-ui/components';
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
type: 'component',
|
|
70
|
+
resolve: (name: string) => {
|
|
71
|
+
const pascalName = normalizeToPascal(name);
|
|
72
|
+
|
|
73
|
+
if (!COMPONENT_SET.has(pascalName)) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const kebabName = pascalToKebab(pascalName);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
from: `${importPath}/${kebabName}`,
|
|
81
|
+
name: pascalName
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Alias for easier import: NueUiResolver
|
|
88
|
+
export const NueUiResolver = resolve;
|
|
89
|
+
|
|
90
|
+
export default resolve;
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nue-ui-resolver",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NueUI resolver for unplugin-vue-components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"types": "index.ts",
|
|
8
|
+
"author": "Nathan Lee",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.ts",
|
|
13
|
+
"import": "./index.ts",
|
|
14
|
+
"require": "./index.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"unplugin-vue-components": "^0.27.0",
|
|
19
|
+
"vue": "^3.5.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"unplugin-vue-components": "^0.27.0",
|
|
23
|
+
"vue": "^3.5.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@nue-ui/utils": "workspace:*"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/tsconfig.json
ADDED
package/types.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NueUI Resolver Types
|
|
3
|
+
* Type definitions for unplugin-vue-components resolver
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ComponentResolver } from 'unplugin-vue-components';
|
|
7
|
+
|
|
8
|
+
export interface NueUiResolverOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Import path for NueUI components
|
|
11
|
+
* @default '@nue-ui/components'
|
|
12
|
+
*/
|
|
13
|
+
importPath?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type { ComponentResolver };
|