react-principles 0.0.1

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 ADDED
@@ -0,0 +1,219 @@
1
+ # react-principles
2
+
3
+ A CLI to add react-principles UI components to your project — copy-paste based, no dependency lock-in.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 18+
8
+ - React 18+
9
+ - Tailwind CSS v4
10
+
11
+ ## Usage
12
+
13
+ No installation needed. Run directly with `npx`:
14
+
15
+ ```bash
16
+ npx react-principles init
17
+ npx react-principles add <component>
18
+ npx react-principles list
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Commands
24
+
25
+ ### `init`
26
+
27
+ Initialize react-principles in your project. Run this once before adding components.
28
+
29
+ ```bash
30
+ npx react-principles init
31
+ npx react-principles init --template next
32
+ ```
33
+
34
+ **Options**
35
+
36
+ | Flag | Description |
37
+ |------|-------------|
38
+ | `-t, --template <framework>` | Skip prompt and set framework directly: `next` \| `vite` \| `remix` \| `other` |
39
+
40
+ **What it does**
41
+
42
+ 1. Auto-detects your framework from `package.json`
43
+ 2. Prompts for install directories (components, hooks, utilities)
44
+ 3. Creates `components.json` in your project root
45
+ 4. Installs `cn()` utility to your lib directory
46
+ 5. Installs `clsx`, `tailwind-merge`, and `tailwind-animate`
47
+ 6. Appends `@import "tailwindcss"` to your `globals.css` (skipped for Vite)
48
+
49
+ **Interactive prompts**
50
+
51
+ ```
52
+ ? Which framework are you using? › Next.js (detected: Next.js)
53
+ ? Where should components be installed? › src/components/ui
54
+ ? Where should hooks be installed? › src/hooks
55
+ ? Where should utilities be installed? › src/lib
56
+ ```
57
+
58
+ **Generated `components.json`**
59
+
60
+ ```json
61
+ {
62
+ "framework": "next",
63
+ "rsc": true,
64
+ "tsx": true,
65
+ "componentsDir": "src/components/ui",
66
+ "hooksDir": "src/hooks",
67
+ "libDir": "src/lib",
68
+ "aliases": {
69
+ "components": "@/components/ui",
70
+ "hooks": "@/hooks",
71
+ "lib": "@/lib"
72
+ }
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ ### `add`
79
+
80
+ Add one or more components to your project.
81
+
82
+ ```bash
83
+ npx react-principles add button
84
+ npx react-principles add button input card
85
+ npx react-principles add --all
86
+ ```
87
+
88
+ **Arguments**
89
+
90
+ | Argument | Description |
91
+ |----------|-------------|
92
+ | `<components...>` | One or more component names (space-separated) |
93
+ | `--all` | Install all available components at once |
94
+
95
+ **What it does**
96
+
97
+ 1. Reads `components.json` to determine install paths
98
+ 2. Resolves transitive dependencies automatically (e.g. adding `dialog` also installs `utils` and `use-animated-mount`)
99
+ 3. Writes component files to the configured directory
100
+ 4. Skips files that already exist — your customizations are safe
101
+ 5. Installs any required npm packages using your detected package manager (pnpm / yarn / npm)
102
+
103
+ **Example output**
104
+
105
+ ```
106
+ ✓ Created src/lib/utils.ts
107
+ ✓ Created src/hooks/use-animated-mount.ts
108
+ ✓ Created src/components/ui/Dialog.tsx
109
+ – Skipped src/lib/utils.ts (already exists)
110
+
111
+ Done!
112
+ ```
113
+
114
+ ---
115
+
116
+ ### `list`
117
+
118
+ Display all available components.
119
+
120
+ ```bash
121
+ npx react-principles list
122
+ ```
123
+
124
+ **Example output**
125
+
126
+ ```
127
+ Available components:
128
+
129
+ accordion Collapsible content sections
130
+ alert Inline status messages
131
+ alert-dialog Confirmation dialog with destructive actions
132
+ ...
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Configuration
138
+
139
+ `components.json` is created by `init` and read by `add`. You can edit it manually if you change your project structure.
140
+
141
+ | Field | Type | Description |
142
+ |-------|------|-------------|
143
+ | `framework` | `next` \| `vite` \| `remix` \| `other` | Your framework |
144
+ | `rsc` | `boolean` | React Server Components (auto-set to `true` for Next.js) |
145
+ | `tsx` | `boolean` | TypeScript (always `true`) |
146
+ | `componentsDir` | `string` | Where UI components are written |
147
+ | `hooksDir` | `string` | Where hooks are written |
148
+ | `libDir` | `string` | Where utilities are written |
149
+ | `aliases.components` | `string` | Import alias for components |
150
+ | `aliases.hooks` | `string` | Import alias for hooks |
151
+ | `aliases.lib` | `string` | Import alias for utilities |
152
+
153
+ ---
154
+
155
+ ## Available Components
156
+
157
+ Run `npx react-principles list` to see all components. Below is the full reference:
158
+
159
+ ### Utilities
160
+
161
+ These are installed automatically as dependencies but can also be added directly.
162
+
163
+ | Name | Output | Description |
164
+ |------|--------|-------------|
165
+ | `utils` | `lib/utils.ts` | `cn()` utility for merging Tailwind classes |
166
+ | `use-animated-mount` | `hooks/use-animated-mount.ts` | Hook for managing animated mount/unmount timing |
167
+
168
+ ### Components
169
+
170
+ | Name | Output | Description | Extra deps |
171
+ |------|--------|-------------|------------|
172
+ | `accordion` | `Accordion.tsx` | Collapsible content sections | — |
173
+ | `alert` | `Alert.tsx` | Inline status messages | — |
174
+ | `alert-dialog` | `AlertDialog.tsx` | Confirmation dialog with destructive actions | `use-animated-mount` |
175
+ | `avatar` | `Avatar.tsx` | User avatar with size variants | — |
176
+ | `badge` | `Badge.tsx` | Status and label tags | — |
177
+ | `breadcrumb` | `Breadcrumb.tsx` | Navigation breadcrumb trail | — |
178
+ | `button` | `Button.tsx` | Primary, secondary, ghost, outline, destructive variants | — |
179
+ | `card` | `Card.tsx` | Content container with variants | — |
180
+ | `checkbox` | `Checkbox.tsx` | Controlled checkbox with label | — |
181
+ | `combobox` | `Combobox.tsx` | Searchable dropdown select | — |
182
+ | `command` | `Command.tsx` | Command palette container | — |
183
+ | `date-picker` | `DatePicker.tsx` | Date input | — |
184
+ | `dialog` | `Dialog.tsx` | Modal dialog with compound sub-components | `use-animated-mount` |
185
+ | `drawer` | `Drawer.tsx` | Slide-in panel (left/right) | `use-animated-mount` |
186
+ | `dropdown-menu` | `DropdownMenu.tsx` | Contextual dropdown | — |
187
+ | `floating-lines` | `FloatingLines.tsx` | Decorative animated background | — |
188
+ | `input` | `Input.tsx` | Text input with variants | — |
189
+ | `pagination` | `Pagination.tsx` | Page navigation | — |
190
+ | `popover` | `Popover.tsx` | Floating content anchored to a trigger | — |
191
+ | `progress` | `Progress.tsx` | Linear progress bar | — |
192
+ | `progress-bar` | `ProgressBar.tsx` | Animated top progress bar tied to navigation | `use-animated-mount` |
193
+ | `radio-group` | `RadioGroup.tsx` | Radio button group | — |
194
+ | `search-dialog` | `SearchDialog.tsx` | Full-screen search dialog | `use-animated-mount` |
195
+ | `select` | `Select.tsx` | Native select with styling | — |
196
+ | `separator` | `Separator.tsx` | Horizontal/vertical divider | — |
197
+ | `skeleton` | `Skeleton.tsx` | Loading placeholder shapes | — |
198
+ | `slider` | `Slider.tsx` | Range input | — |
199
+ | `switch` | `Switch.tsx` | Toggle switch | — |
200
+ | `tabs` | `Tabs.tsx` | Tabbed content panels | — |
201
+ | `textarea` | `Textarea.tsx` | Multi-line text input | — |
202
+ | `toast` | `Toast.tsx` | Transient notification | `use-animated-mount` |
203
+ | `tooltip` | `Tooltip.tsx` | Hover tooltip with positioning | — |
204
+
205
+ > **Note:** All components depend on `utils` (`cn()` utility). It is always installed automatically.
206
+
207
+ ---
208
+
209
+ ## How It Works
210
+
211
+ react-principles uses a **copy-paste model** — component source code is copied directly into your project. You own the code and can customize it freely without maintaining a fork or ejecting from a library.
212
+
213
+ There are no runtime dependencies on react-principles. Once a component is added to your project, it has no connection to this package.
214
+
215
+ ---
216
+
217
+ ## License
218
+
219
+ MIT
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node