@srcroot/ui 1.0.1 → 1.0.4
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 +76 -37
- package/dist/index.js +7 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,63 +1,88 @@
|
|
|
1
1
|
# @srcroot/ui
|
|
2
2
|
|
|
3
|
-
A UI library with polymorphic, accessible React components for Next.js, Vite, and other React frameworks.
|
|
3
|
+
A lightweight UI library with polymorphic, accessible React components for Next.js, Vite, and other React frameworks.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Framework-Aware**: Automatically detects
|
|
8
|
-
- **Polymorphic**: Most components support an `as` prop
|
|
7
|
+
- **Framework-Aware**: Automatically detects Next.js or Vite and uses optimized component variants
|
|
8
|
+
- **Polymorphic**: Most components support an `as` prop to change the underlying HTML element
|
|
9
9
|
- **Accessible**: Built on standard HTML elements and WAI-ARIA patterns
|
|
10
10
|
- **Copy/Paste**: Components are copied directly into your project — you own the code
|
|
11
11
|
- **Styled**: Beautiful defaults using Tailwind CSS and `class-variance-authority`
|
|
12
|
-
- **
|
|
12
|
+
- **Zero Runtime Dependencies**: No library bundle — just copy what you need
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Install
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Initialize your project with `@srcroot/ui`:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
+
# npm
|
|
19
20
|
npx @srcroot/ui init
|
|
21
|
+
|
|
22
|
+
# yarn
|
|
23
|
+
yarn dlx @srcroot/ui init
|
|
24
|
+
|
|
25
|
+
# pnpm
|
|
26
|
+
pnpm dlx @srcroot/ui init
|
|
27
|
+
|
|
28
|
+
# bun
|
|
29
|
+
bunx @srcroot/ui init
|
|
30
|
+
|
|
31
|
+
# deno
|
|
32
|
+
deno run -A npm:@srcroot/ui init
|
|
20
33
|
```
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
## Add Components
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
Add components to your project:
|
|
25
38
|
|
|
26
39
|
```bash
|
|
27
|
-
#
|
|
40
|
+
# npm
|
|
28
41
|
npx @srcroot/ui add
|
|
29
|
-
|
|
30
|
-
# Specific components
|
|
31
42
|
npx @srcroot/ui add button card input
|
|
32
|
-
|
|
33
|
-
# Add all components
|
|
34
43
|
npx @srcroot/ui add --all
|
|
35
|
-
```
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
# yarn
|
|
46
|
+
yarn dlx @srcroot/ui add
|
|
47
|
+
yarn dlx @srcroot/ui add button card input
|
|
48
|
+
yarn dlx @srcroot/ui add --all
|
|
49
|
+
|
|
50
|
+
# pnpm
|
|
51
|
+
pnpm dlx @srcroot/ui add
|
|
52
|
+
pnpm dlx @srcroot/ui add button card input
|
|
53
|
+
pnpm dlx @srcroot/ui add --all
|
|
54
|
+
|
|
55
|
+
# bun
|
|
56
|
+
bunx @srcroot/ui add
|
|
57
|
+
bunx @srcroot/ui add button card input
|
|
58
|
+
bunx @srcroot/ui add --all
|
|
59
|
+
|
|
60
|
+
# deno
|
|
61
|
+
deno run -A npm:@srcroot/ui add
|
|
62
|
+
deno run -A npm:@srcroot/ui add button card input
|
|
63
|
+
deno run -A npm:@srcroot/ui add --all
|
|
64
|
+
```
|
|
38
65
|
|
|
39
66
|
## Supported Package Managers
|
|
40
67
|
|
|
41
68
|
The CLI automatically detects and uses your package manager:
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
| Manager | Command |
|
|
71
|
+
|---------|---------|
|
|
72
|
+
| npm | `npm install` |
|
|
73
|
+
| Yarn | `yarn add` |
|
|
74
|
+
| pnpm | `pnpm add` |
|
|
75
|
+
| Bun | `bun add` |
|
|
76
|
+
| Deno | `deno add -A` |
|
|
48
77
|
|
|
49
78
|
## Framework Detection
|
|
50
79
|
|
|
51
|
-
The CLI automatically detects your framework:
|
|
52
|
-
|
|
53
80
|
| Framework | Detection | Notes |
|
|
54
81
|
|-----------|-----------|-------|
|
|
55
|
-
| Next.js | `next.config.ts/js/mjs` or `src/app`
|
|
82
|
+
| Next.js | `next.config.ts/js/mjs` or `src/app` | Uses `next/script` for analytics |
|
|
56
83
|
| Vite | `vite.config.ts/js/mjs` | Uses `useEffect` for analytics, localStorage for themes |
|
|
57
84
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
Run `npx @srcroot/ui list` to see all available components.
|
|
85
|
+
## Components
|
|
61
86
|
|
|
62
87
|
### Analytics
|
|
63
88
|
- `google-analytics` - Google Analytics 4 integration
|
|
@@ -137,7 +162,7 @@ Run `npx @srcroot/ui list` to see all available components.
|
|
|
137
162
|
- `chart` - Recharts-based chart component
|
|
138
163
|
- `map` - Google Maps embed
|
|
139
164
|
- `combobox` - Searchable dropdown (Command menu pattern)
|
|
140
|
-
- `command` - Command menu (
|
|
165
|
+
- `command` - Command menu (Cmd+k style)
|
|
141
166
|
- `file-upload` - Drag-and-drop file upload
|
|
142
167
|
- `hover-card` - Hover-triggered card
|
|
143
168
|
- `native-select` - Native select wrapper
|
|
@@ -146,6 +171,26 @@ Run `npx @srcroot/ui list` to see all available components.
|
|
|
146
171
|
- `whatsapp` - WhatsApp floating button
|
|
147
172
|
- `floating-dock` - macOS-style floating dock
|
|
148
173
|
|
|
174
|
+
## Usage
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { Button } from "@/components/ui/button"
|
|
178
|
+
import { Card, CardHeader, CardContent } from "@/components/ui/card"
|
|
179
|
+
|
|
180
|
+
export default function Home() {
|
|
181
|
+
return (
|
|
182
|
+
<Card>
|
|
183
|
+
<CardHeader>Welcome</CardHeader>
|
|
184
|
+
<CardContent>
|
|
185
|
+
<Button variant="destructive" onClick={() => alert("Clicked!")}>
|
|
186
|
+
Get Started
|
|
187
|
+
</Button>
|
|
188
|
+
</CardContent>
|
|
189
|
+
</Card>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
149
194
|
## Polymorphism
|
|
150
195
|
|
|
151
196
|
Components accept an `as` prop to change the underlying HTML element:
|
|
@@ -156,21 +201,15 @@ Components accept an `as` prop to change the underlying HTML element:
|
|
|
156
201
|
<Text as="h1" variant="h1">Page Title</Text>
|
|
157
202
|
```
|
|
158
203
|
|
|
159
|
-
## CLI
|
|
204
|
+
## CLI Reference
|
|
160
205
|
|
|
161
|
-
```
|
|
206
|
+
```bash
|
|
162
207
|
npx @srcroot/ui init Initialize project structure
|
|
163
208
|
npx @srcroot/ui add [comps] Add component(s)
|
|
164
209
|
npx @srcroot/ui add --all Add all components
|
|
165
210
|
npx @srcroot/ui list List available components
|
|
166
211
|
```
|
|
167
212
|
|
|
168
|
-
##
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
cd examples/playground
|
|
172
|
-
npm install
|
|
173
|
-
npm run dev
|
|
174
|
-
```
|
|
213
|
+
## License
|
|
175
214
|
|
|
176
|
-
|
|
215
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -971,12 +971,11 @@ var ComponentAdder = class {
|
|
|
971
971
|
return "unknown";
|
|
972
972
|
}
|
|
973
973
|
transformForVite(name, content) {
|
|
974
|
-
content = content.replace(/^"use client"
|
|
975
|
-
content = content.replace(/import\s
|
|
976
|
-
content = content.replace(/import\s
|
|
977
|
-
content = content.replace(/import\s
|
|
978
|
-
|
|
979
|
-
const otherUiImports = [
|
|
974
|
+
content = content.replace(/^["']use client["'];?\r?\n?/m, "");
|
|
975
|
+
content = content.replace(/import\s*\{[^}]*\}\s*from\s*["']next-themes["'];?\r?\n?/g, "");
|
|
976
|
+
content = content.replace(/import\s*\{[^}]*\}\s*from\s*["']@\/lib\/utils["'];?\r?\n?/g, 'import { cn } from "../../lib/utils"\n');
|
|
977
|
+
content = content.replace(/import\s*\{[^}]*\}\s*from\s*["']@\/components\/ui\/slot["'];?\r?\n?/g, 'import { Slot } from "./slot"\n');
|
|
978
|
+
const allComponents = [
|
|
980
979
|
"accordion",
|
|
981
980
|
"alert-dialog",
|
|
982
981
|
"alert",
|
|
@@ -1046,9 +1045,8 @@ var ComponentAdder = class {
|
|
|
1046
1045
|
"tooltip",
|
|
1047
1046
|
"whatsapp"
|
|
1048
1047
|
];
|
|
1049
|
-
for (const comp of
|
|
1050
|
-
|
|
1051
|
-
content = content.replace(regex, `from "./${comp}"`);
|
|
1048
|
+
for (const comp of allComponents) {
|
|
1049
|
+
content = content.replace(new RegExp(`from\\s+["']@/components/ui/${comp}["']`, "g"), `from "./${comp}"`);
|
|
1052
1050
|
}
|
|
1053
1051
|
return content.trimStart();
|
|
1054
1052
|
}
|