@srcroot/ui 1.0.2 → 1.0.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/README.md +43 -130
- package/dist/index.js +7 -9
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,143 +1,39 @@
|
|
|
1
1
|
# @srcroot/ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
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
|
-
- **Accessible**: Built on standard HTML elements and WAI-ARIA patterns
|
|
10
|
-
- **Copy/Paste**: Components are copied directly into your project — you own the code
|
|
11
|
-
- **Styled**: Beautiful defaults using Tailwind CSS and `class-variance-authority`
|
|
12
|
-
- **Zero Runtime Dependencies**: No library bundle — just copy what you need
|
|
3
|
+
UI components for Next.js and Vite. Copy-paste into your project.
|
|
13
4
|
|
|
14
5
|
## Install
|
|
15
6
|
|
|
16
7
|
```bash
|
|
8
|
+
# npm
|
|
17
9
|
npx @srcroot/ui init
|
|
10
|
+
|
|
11
|
+
# yarn
|
|
12
|
+
yarn dlx @srcroot/ui init
|
|
13
|
+
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm dlx @srcroot/ui init
|
|
16
|
+
|
|
17
|
+
# bun
|
|
18
|
+
bunx @srcroot/ui init
|
|
19
|
+
|
|
20
|
+
# deno
|
|
21
|
+
deno run -A npm:@srcroot/ui init
|
|
18
22
|
```
|
|
19
23
|
|
|
20
24
|
## Add Components
|
|
21
25
|
|
|
22
26
|
```bash
|
|
23
|
-
# Interactive
|
|
27
|
+
# Interactive
|
|
24
28
|
npx @srcroot/ui add
|
|
25
29
|
|
|
26
30
|
# Specific components
|
|
27
31
|
npx @srcroot/ui add button card input
|
|
28
32
|
|
|
29
|
-
#
|
|
33
|
+
# All components
|
|
30
34
|
npx @srcroot/ui add --all
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
## Supported Package Managers
|
|
34
|
-
|
|
35
|
-
The CLI automatically detects and uses your package manager:
|
|
36
|
-
|
|
37
|
-
| Manager | Command |
|
|
38
|
-
|---------|---------|
|
|
39
|
-
| npm | `npm install` |
|
|
40
|
-
| Yarn | `yarn add` |
|
|
41
|
-
| pnpm | `pnpm add` |
|
|
42
|
-
| Bun | `bun add` |
|
|
43
|
-
| Deno | `deno add -A` |
|
|
44
|
-
|
|
45
|
-
## Framework Detection
|
|
46
|
-
|
|
47
|
-
| Framework | Detection | Notes |
|
|
48
|
-
|-----------|-----------|-------|
|
|
49
|
-
| Next.js | `next.config.ts/js/mjs` or `src/app` | Uses `next/script` for analytics |
|
|
50
|
-
| Vite | `vite.config.ts/js/mjs` | Uses `useEffect` for analytics, localStorage for themes |
|
|
51
|
-
|
|
52
|
-
## Components
|
|
53
|
-
|
|
54
|
-
### Analytics
|
|
55
|
-
- `google-analytics` - Google Analytics 4 integration
|
|
56
|
-
- `google-tag-manager` - Google Tag Manager container
|
|
57
|
-
- `meta-pixel` - Meta/Facebook Pixel tracking
|
|
58
|
-
- `microsoft-clarity` - Microsoft Clarity analytics
|
|
59
|
-
- `tiktok-pixel` - TikTok Pixel tracking
|
|
60
|
-
|
|
61
|
-
### Core
|
|
62
|
-
- `button` - Polymorphic button with variants
|
|
63
|
-
- `badge` - Status indicators
|
|
64
|
-
- `avatar` - User profile images with fallbacks
|
|
65
|
-
- `separator` - Visual divider
|
|
66
|
-
- `button-group` - Attached or spaced button sets
|
|
67
|
-
- `slot` - Polymorphic slot for component composition
|
|
68
|
-
|
|
69
|
-
### Forms
|
|
70
|
-
- `input` - Basic text input
|
|
71
|
-
- `textarea` - Multi-line text input
|
|
72
|
-
- `checkbox` - Toggle selection
|
|
73
|
-
- `radio` - Single selection from list
|
|
74
|
-
- `switch` - Toggle switch
|
|
75
|
-
- `select` - Dropdown selection
|
|
76
|
-
- `slider` - Range input
|
|
77
|
-
- `otp-input` - One-time password verification
|
|
78
|
-
- `search` - Search input with debounce
|
|
79
|
-
- `calendar` - Date and range picker
|
|
80
|
-
- `date-picker` - Date selection component
|
|
81
|
-
- `form-field` - Form field wrapper with label and validation
|
|
82
|
-
- `input-group` - Input with attached elements
|
|
83
|
-
|
|
84
|
-
### Layout
|
|
85
|
-
- `card` - Content container with header/content/footer
|
|
86
|
-
- `container` - Centered layout wrapper
|
|
87
|
-
- `aspect-ratio` - Maintain element proportions
|
|
88
|
-
- `resizable` - Resizable panel groups
|
|
89
|
-
|
|
90
|
-
### Data Display
|
|
91
|
-
- `text` - Polymorphic typography
|
|
92
|
-
- `label` - Accessible form label
|
|
93
|
-
- `table` - Responsive data table
|
|
94
|
-
- `table-of-contents` - Auto-generated TOC
|
|
95
|
-
- `accordion` - Collapsible content sections
|
|
96
|
-
- `collapsible` - Expandable panel
|
|
97
|
-
- `tabs` - Tabbed content switcher
|
|
98
|
-
- `progress` - Progress bar
|
|
99
|
-
- `skeleton` - Loading placeholder
|
|
100
|
-
- `image` - Enhanced image with fallback
|
|
101
|
-
- `carousel` - Content slider with autoplay
|
|
102
|
-
- `marquee` - Scrolling marquee animation
|
|
103
|
-
|
|
104
|
-
### Feedback
|
|
105
|
-
- `loading-spinner` - SVG spinner with variants
|
|
106
|
-
- `star-rating` - Interactive rating component
|
|
107
|
-
- `toast` - Transient notifications
|
|
108
|
-
- `alert` - Critical information banner
|
|
109
|
-
- `scroll-to-top` - Scroll to top button
|
|
110
|
-
- `scroll-animation` - Scroll-triggered animations
|
|
111
|
-
|
|
112
|
-
### Overlays
|
|
113
|
-
- `dialog` - Modal dialog
|
|
114
|
-
- `alert-dialog` - Modal for confirming actions
|
|
115
|
-
- `sheet` - Side-panel overlay
|
|
116
|
-
- `popover` - Content appearing over trigger
|
|
117
|
-
- `tooltip` - Hover information
|
|
118
|
-
- `dropdown-menu` - Menu for actions/navigation
|
|
119
|
-
- `context-menu` - Right-click context menu
|
|
120
|
-
|
|
121
|
-
### Navigation
|
|
122
|
-
- `breadcrumb` - Navigation trail
|
|
123
|
-
- `pagination` - Page navigation controls
|
|
124
|
-
- `sidebar` - Collapsible sidebar with navigation
|
|
125
|
-
- `menubar` - Menu bar component
|
|
126
|
-
|
|
127
|
-
### Specialized
|
|
128
|
-
- `chatbot` - Chat interface widget
|
|
129
|
-
- `chart` - Recharts-based chart component
|
|
130
|
-
- `map` - Google Maps embed
|
|
131
|
-
- `combobox` - Searchable dropdown (Command menu pattern)
|
|
132
|
-
- `command` - Command menu (Cmd+k style)
|
|
133
|
-
- `file-upload` - Drag-and-drop file upload
|
|
134
|
-
- `hover-card` - Hover-triggered card
|
|
135
|
-
- `native-select` - Native select wrapper
|
|
136
|
-
- `patterns` - Decorative background patterns
|
|
137
|
-
- `theme-switcher` - Light/dark/system theme toggle
|
|
138
|
-
- `whatsapp` - WhatsApp floating button
|
|
139
|
-
- `floating-dock` - macOS-style floating dock
|
|
140
|
-
|
|
141
37
|
## Usage
|
|
142
38
|
|
|
143
39
|
```tsx
|
|
@@ -158,23 +54,40 @@ export default function Home() {
|
|
|
158
54
|
}
|
|
159
55
|
```
|
|
160
56
|
|
|
161
|
-
##
|
|
57
|
+
## Components
|
|
162
58
|
|
|
163
|
-
|
|
59
|
+
**Analytics:** google-analytics, google-tag-manager, meta-pixel, microsoft-clarity, tiktok-pixel
|
|
164
60
|
|
|
165
|
-
|
|
166
|
-
<Button as="a" href="/login">Login</Button>
|
|
61
|
+
**Core:** button, badge, avatar, separator, button-group, slot
|
|
167
62
|
|
|
168
|
-
|
|
169
|
-
|
|
63
|
+
**Forms:** input, textarea, checkbox, radio, switch, select, slider, otp-input, search, calendar, date-picker, form-field, input-group
|
|
64
|
+
|
|
65
|
+
**Layout:** card, container, aspect-ratio, resizable
|
|
66
|
+
|
|
67
|
+
**Data Display:** text, label, table, table-of-contents, accordion, collapsible, tabs, progress, skeleton, image, carousel, marquee
|
|
68
|
+
|
|
69
|
+
**Feedback:** loading-spinner, star-rating, toast, alert, scroll-to-top, scroll-animation
|
|
70
|
+
|
|
71
|
+
**Overlays:** dialog, alert-dialog, sheet, popover, tooltip, dropdown-menu, context-menu
|
|
72
|
+
|
|
73
|
+
**Navigation:** breadcrumb, pagination, sidebar, menubar
|
|
74
|
+
|
|
75
|
+
**Specialized:** chatbot, chart, map, combobox, command, file-upload, hover-card, native-select, patterns, theme-switcher, whatsapp, floating-dock
|
|
76
|
+
|
|
77
|
+
## Features
|
|
78
|
+
|
|
79
|
+
- **Framework-aware** — auto-detects Next.js (uses `next/script`) or Vite (uses `useEffect`)
|
|
80
|
+
- **Polymorphic** — use `as` prop to change the HTML element: `<Button as="a" href="/">`
|
|
81
|
+
- **Accessible** — built on WAI-ARIA patterns
|
|
82
|
+
- **No bundle** — components live in your project
|
|
170
83
|
|
|
171
|
-
## CLI
|
|
84
|
+
## CLI
|
|
172
85
|
|
|
173
86
|
```bash
|
|
174
|
-
npx @srcroot/ui init
|
|
175
|
-
npx @srcroot/ui add [comps] Add
|
|
87
|
+
npx @srcroot/ui init Setup project
|
|
88
|
+
npx @srcroot/ui add [comps] Add components
|
|
176
89
|
npx @srcroot/ui add --all Add all components
|
|
177
|
-
npx @srcroot/ui list List
|
|
90
|
+
npx @srcroot/ui list List all components
|
|
178
91
|
```
|
|
179
92
|
|
|
180
93
|
## License
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srcroot/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A UI library with polymorphic, accessible React components",
|
|
5
5
|
"author": "Shifaul Islam",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"src/registry"
|
|
17
|
+
"src/registry",
|
|
18
|
+
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"keywords": [
|
|
20
21
|
"react",
|