myoperator-ui 0.0.207 → 0.0.208-beta.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 +394 -394
- package/dist/index.js +3762 -539
- package/package.json +67 -67
package/README.md
CHANGED
|
@@ -1,394 +1,394 @@
|
|
|
1
|
-
# myOperator UI
|
|
2
|
-
|
|
3
|
-
CLI for adding myOperator UI components to your React project. Works with both standalone projects and projects that use Bootstrap or other CSS frameworks.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Initialize your project
|
|
9
|
-
npx myoperator-ui init
|
|
10
|
-
|
|
11
|
-
# Add a component
|
|
12
|
-
npx myoperator-ui add button
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Commands
|
|
16
|
-
|
|
17
|
-
### `init` - Initialize Project
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npx myoperator-ui init
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
This will:
|
|
24
|
-
- Create a `components.json` configuration file
|
|
25
|
-
- Set up the utils file with the `cn` helper
|
|
26
|
-
- Create the components directory
|
|
27
|
-
- Create/update your global CSS (`App.scss`) with Tailwind imports
|
|
28
|
-
- Create/update `postcss.config.js` with the correct Tailwind CSS PostCSS plugin
|
|
29
|
-
- Configure Tailwind with `tw-` prefix by default
|
|
30
|
-
|
|
31
|
-
### `add` - Add Components
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# Add a specific component
|
|
35
|
-
npx myoperator-ui add button
|
|
36
|
-
|
|
37
|
-
# Add multiple components
|
|
38
|
-
npx myoperator-ui add button badge table
|
|
39
|
-
|
|
40
|
-
# Add all available components at once
|
|
41
|
-
npx myoperator-ui add --all
|
|
42
|
-
|
|
43
|
-
# Interactive selection (shows all available components)
|
|
44
|
-
npx myoperator-ui add
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**Options:**
|
|
48
|
-
|
|
49
|
-
| Option | Short | Description |
|
|
50
|
-
|--------|-------|-------------|
|
|
51
|
-
| `--all` | `-a` | Add all available components |
|
|
52
|
-
| `--yes` | `-y` | Skip confirmation prompt |
|
|
53
|
-
| `--overwrite` | `-o` | Overwrite existing files |
|
|
54
|
-
| `--path <path>` | `-p` | Custom path (default: `src/components/ui`) |
|
|
55
|
-
|
|
56
|
-
**Examples:**
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Add all components at once
|
|
60
|
-
npx myoperator-ui add --all
|
|
61
|
-
|
|
62
|
-
# Add all components, skip confirmation
|
|
63
|
-
npx myoperator-ui add --all -y
|
|
64
|
-
|
|
65
|
-
# Skip confirmation
|
|
66
|
-
npx myoperator-ui add button -y
|
|
67
|
-
|
|
68
|
-
# Overwrite existing component
|
|
69
|
-
npx myoperator-ui add button --overwrite
|
|
70
|
-
|
|
71
|
-
# Add to custom directory
|
|
72
|
-
npx myoperator-ui add button -p src/ui
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### `update` - Update Components
|
|
76
|
-
|
|
77
|
-
Safely update installed components to the latest version with diff preview.
|
|
78
|
-
|
|
79
|
-
**Important:** Always use `@latest` to ensure you get the newest component code:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Update a specific component (recommended)
|
|
83
|
-
npx myoperator-ui@latest update button
|
|
84
|
-
|
|
85
|
-
# Update multiple components
|
|
86
|
-
npx myoperator-ui@latest update button badge
|
|
87
|
-
|
|
88
|
-
# Interactive selection (shows installed components)
|
|
89
|
-
npx myoperator-ui@latest update
|
|
90
|
-
|
|
91
|
-
# Update all installed components
|
|
92
|
-
npx myoperator-ui@latest update --all
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
**Options:**
|
|
96
|
-
|
|
97
|
-
| Option | Short | Description |
|
|
98
|
-
|--------|-------|-------------|
|
|
99
|
-
| `--yes` | `-y` | Skip confirmation prompt |
|
|
100
|
-
| `--all` | `-a` | Update all installed components |
|
|
101
|
-
| `--dry-run` | `-d` | Preview changes without modifying files |
|
|
102
|
-
| `--backup` | `-b` | Create backup files before updating |
|
|
103
|
-
| `--path <path>` | `-p` | Custom path (default: `src/components/ui`) |
|
|
104
|
-
|
|
105
|
-
**Examples:**
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# Preview what would change (safe - no modifications)
|
|
109
|
-
npx myoperator-ui@latest update button --dry-run
|
|
110
|
-
|
|
111
|
-
# Preview all component updates
|
|
112
|
-
npx myoperator-ui@latest update --all --dry-run
|
|
113
|
-
|
|
114
|
-
# Update all with backups
|
|
115
|
-
npx myoperator-ui@latest update --all --backup
|
|
116
|
-
|
|
117
|
-
# Force update without confirmation
|
|
118
|
-
npx myoperator-ui@latest update button -y
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
> **Note:** If you see "No changes" but expect updates, make sure you're using `@latest` to get the newest package version. NPX may cache older versions.
|
|
122
|
-
|
|
123
|
-
**Update Safeguards:**
|
|
124
|
-
- Shows diff of changes before applying
|
|
125
|
-
- `--dry-run` lets you preview without making changes
|
|
126
|
-
- `--backup` creates timestamped backups (e.g., `button.tsx.backup.1700000000`)
|
|
127
|
-
- Only updates components that are already installed
|
|
128
|
-
- Skips components with no changes
|
|
129
|
-
|
|
130
|
-
### Other Commands
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
# Check CLI version
|
|
134
|
-
npx myoperator-ui --version
|
|
135
|
-
|
|
136
|
-
# Get help
|
|
137
|
-
npx myoperator-ui --help
|
|
138
|
-
npx myoperator-ui add --help
|
|
139
|
-
npx myoperator-ui update --help
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Available Components
|
|
143
|
-
|
|
144
|
-
| Component | Description |
|
|
145
|
-
|-----------|-------------|
|
|
146
|
-
| `accordion` | Expandable/collapsible accordion component with single or multiple mode support |
|
|
147
|
-
| `badge` | Status badge with active, failed, disabled, outline, secondary, destructive variants and asChild support |
|
|
148
|
-
| `button` | Customizable button with variants, sizes (including icon-lg), icons, and loading state |
|
|
149
|
-
| `checkbox` | Tri-state checkbox built on Radix UI with label support (checked, unchecked, indeterminate) |
|
|
150
|
-
| `dropdown-menu` | Dropdown menu for displaying actions and options |
|
|
151
|
-
| `input` | Basic input component |
|
|
152
|
-
| `multi-select` | Multi-select dropdown with search, tags, and keyboard navigation |
|
|
153
|
-
| `select` | Single select dropdown component |
|
|
154
|
-
| `select-field` | Select field with label, helper text, and validation states |
|
|
155
|
-
| `switch` | Switch component built on Radix UI for boolean inputs with on/off states |
|
|
156
|
-
| `table` | Composable table with size variants, loading/empty states, sticky columns |
|
|
157
|
-
| `tag` | Tag component for event labels with optional bold label prefix |
|
|
158
|
-
| `text-field` | Text input with label, icons, prefix/suffix, validation states, and character count |
|
|
159
|
-
|
|
160
|
-
## Configuration
|
|
161
|
-
|
|
162
|
-
After running `init`, a `components.json` file is created:
|
|
163
|
-
|
|
164
|
-
```json
|
|
165
|
-
{
|
|
166
|
-
"$schema": "https://myoperator.com/schema.json",
|
|
167
|
-
"style": "default",
|
|
168
|
-
"tailwind": {
|
|
169
|
-
"config": "tailwind.config.js",
|
|
170
|
-
"css": "src/App.scss",
|
|
171
|
-
"baseColor": "slate",
|
|
172
|
-
"cssVariables": true,
|
|
173
|
-
"prefix": "tw-"
|
|
174
|
-
},
|
|
175
|
-
"aliases": {
|
|
176
|
-
"components": "@/components",
|
|
177
|
-
"utils": "@/lib/utils",
|
|
178
|
-
"ui": "@/components/ui"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Tailwind CSS Configuration
|
|
184
|
-
|
|
185
|
-
The CLI generates a `tailwind.config.js` with:
|
|
186
|
-
|
|
187
|
-
```javascript
|
|
188
|
-
/** @type {import('tailwindcss').Config} */
|
|
189
|
-
export default {
|
|
190
|
-
darkMode: ["class"],
|
|
191
|
-
prefix: "tw-",
|
|
192
|
-
content: ["./src/components/ui/**/*.{js,ts,jsx,tsx}"],
|
|
193
|
-
theme: {
|
|
194
|
-
// ... theme configuration
|
|
195
|
-
},
|
|
196
|
-
plugins: [require("tailwindcss-animate")],
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
**Key Features:**
|
|
201
|
-
- `prefix: "tw-"` - Avoids conflicts with other CSS frameworks
|
|
202
|
-
- Scoped content path - Only scans UI components directory
|
|
203
|
-
|
|
204
|
-
## Bootstrap Compatibility
|
|
205
|
-
|
|
206
|
-
myOperator UI automatically detects if your project uses Bootstrap and configures Tailwind CSS to avoid conflicts.
|
|
207
|
-
|
|
208
|
-
### How it works
|
|
209
|
-
|
|
210
|
-
When Bootstrap is detected, the CLI uses selective Tailwind imports - importing only theme and utilities, skipping Preflight (Tailwind's CSS reset) which would override Bootstrap's base styles.
|
|
211
|
-
|
|
212
|
-
### Generated CSS for Bootstrap projects
|
|
213
|
-
|
|
214
|
-
```css
|
|
215
|
-
/* Selective imports to avoid Preflight conflicts with Bootstrap */
|
|
216
|
-
@layer theme, base, components, utilities;
|
|
217
|
-
@import "tailwindcss/theme.css" layer(theme);
|
|
218
|
-
@import "tailwindcss/utilities.css" layer(utilities);
|
|
219
|
-
|
|
220
|
-
/* Tell Tailwind to scan component files for utility classes */
|
|
221
|
-
@source "./components/**/*.{js,ts,jsx,tsx}";
|
|
222
|
-
@source "./lib/**/*.{js,ts,jsx,tsx}";
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## Tailwind CSS Version Support
|
|
226
|
-
|
|
227
|
-
### Tailwind CSS v4 (default)
|
|
228
|
-
|
|
229
|
-
For v4 projects, the CLI generates CSS-based configuration:
|
|
230
|
-
|
|
231
|
-
```css
|
|
232
|
-
@import "tailwindcss";
|
|
233
|
-
|
|
234
|
-
@theme {
|
|
235
|
-
--color-primary: hsl(222.2 47.4% 11.2%);
|
|
236
|
-
/* ... */
|
|
237
|
-
}
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### Tailwind CSS v3
|
|
241
|
-
|
|
242
|
-
For v3 projects, the CLI generates the traditional configuration with `tailwind.config.js` and CSS variables.
|
|
243
|
-
|
|
244
|
-
## Requirements
|
|
245
|
-
|
|
246
|
-
- React 18+
|
|
247
|
-
- Tailwind CSS v3 or v4
|
|
248
|
-
- TypeScript (recommended)
|
|
249
|
-
|
|
250
|
-
## Dependencies
|
|
251
|
-
|
|
252
|
-
Components use these packages (installed automatically during `init`):
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
For Tailwind v3, you'll also need:
|
|
259
|
-
- `tailwindcss-animate`
|
|
260
|
-
|
|
261
|
-
## PostCSS Configuration
|
|
262
|
-
|
|
263
|
-
The CLI automatically sets up the correct PostCSS configuration for Tailwind CSS.
|
|
264
|
-
|
|
265
|
-
### For Tailwind v4
|
|
266
|
-
|
|
267
|
-
```javascript
|
|
268
|
-
// postcss.config.js
|
|
269
|
-
export default {
|
|
270
|
-
plugins: {
|
|
271
|
-
'@tailwindcss/postcss': {},
|
|
272
|
-
},
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Common Error
|
|
277
|
-
|
|
278
|
-
If you see this error:
|
|
279
|
-
|
|
280
|
-
```
|
|
281
|
-
[plugin:vite:css] [postcss] It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin.
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Fix it by:**
|
|
285
|
-
|
|
286
|
-
1. Installing the new plugin:
|
|
287
|
-
```bash
|
|
288
|
-
npm install -D @tailwindcss/postcss
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
2. Run `npx myoperator-ui init` to automatically create the correct configuration
|
|
292
|
-
|
|
293
|
-
## Troubleshooting
|
|
294
|
-
|
|
295
|
-
### Component styles not applying
|
|
296
|
-
|
|
297
|
-
Make sure you've installed the required dependencies:
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Styles conflict with Bootstrap
|
|
304
|
-
|
|
305
|
-
If you're seeing Bootstrap styles override your components, make sure:
|
|
306
|
-
|
|
307
|
-
1. You ran `npx myoperator-ui init` after adding Bootstrap
|
|
308
|
-
2. The CSS file has selective imports (not `@import "tailwindcss"`)
|
|
309
|
-
|
|
310
|
-
### Version mismatch
|
|
311
|
-
|
|
312
|
-
To ensure you're using the latest version:
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
npx myoperator-ui@latest init
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Updating components
|
|
319
|
-
|
|
320
|
-
To get the latest component updates:
|
|
321
|
-
|
|
322
|
-
```bash
|
|
323
|
-
# Preview changes first
|
|
324
|
-
npx myoperator-ui update --all --dry-run
|
|
325
|
-
|
|
326
|
-
# Then apply updates
|
|
327
|
-
npx myoperator-ui update --all
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## Development Workflow (For Maintainers)
|
|
331
|
-
|
|
332
|
-
### Safe Component Updates
|
|
333
|
-
|
|
334
|
-
To ensure changes don't accidentally break other components:
|
|
335
|
-
|
|
336
|
-
```bash
|
|
337
|
-
cd packages/cli
|
|
338
|
-
|
|
339
|
-
# 1. Create a snapshot BEFORE making changes
|
|
340
|
-
npm run integrity:snapshot
|
|
341
|
-
|
|
342
|
-
# 2. Make your changes to a component (e.g., button.tsx)
|
|
343
|
-
|
|
344
|
-
# 3. Verify only the intended component changed
|
|
345
|
-
node scripts/check-integrity.js verify button
|
|
346
|
-
|
|
347
|
-
# 4. If check passes, build and publish
|
|
348
|
-
npm run build
|
|
349
|
-
npm publish
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Integrity Check Commands
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
# Create baseline snapshot of all components
|
|
356
|
-
npm run integrity:snapshot
|
|
357
|
-
|
|
358
|
-
# Verify no unexpected changes
|
|
359
|
-
npm run integrity:verify
|
|
360
|
-
|
|
361
|
-
# Verify specific component changed (others unchanged)
|
|
362
|
-
node scripts/check-integrity.js verify button
|
|
363
|
-
|
|
364
|
-
# Verify multiple components changed
|
|
365
|
-
node scripts/check-integrity.js verify button badge
|
|
366
|
-
|
|
367
|
-
# Check status of a specific component
|
|
368
|
-
node scripts/check-integrity.js diff button
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### What the Integrity Check Does
|
|
372
|
-
|
|
373
|
-
1. **Creates MD5 hashes** of each component file
|
|
374
|
-
2. **Compares current state** against the snapshot
|
|
375
|
-
3. **Fails if unexpected changes** are detected
|
|
376
|
-
4. **Passes if only expected components** changed
|
|
377
|
-
|
|
378
|
-
Example output when an unexpected change is detected:
|
|
379
|
-
|
|
380
|
-
```
|
|
381
|
-
Component Status:
|
|
382
|
-
──────────────────────────────────────────────────
|
|
383
|
-
✓ badge - unchanged
|
|
384
|
-
✓ button - changed (expected)
|
|
385
|
-
⚠️ table - CHANGED (unexpected!)
|
|
386
|
-
✓ tag - unchanged
|
|
387
|
-
|
|
388
|
-
❌ INTEGRITY CHECK FAILED
|
|
389
|
-
Unexpected changes detected in: table
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
## License
|
|
393
|
-
|
|
394
|
-
MIT
|
|
1
|
+
# myOperator UI
|
|
2
|
+
|
|
3
|
+
CLI for adding myOperator UI components to your React project. Works with both standalone projects and projects that use Bootstrap or other CSS frameworks.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Initialize your project
|
|
9
|
+
npx myoperator-ui init
|
|
10
|
+
|
|
11
|
+
# Add a component
|
|
12
|
+
npx myoperator-ui add button
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
### `init` - Initialize Project
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx myoperator-ui init
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This will:
|
|
24
|
+
- Create a `components.json` configuration file
|
|
25
|
+
- Set up the utils file with the `cn` helper
|
|
26
|
+
- Create the components directory
|
|
27
|
+
- Create/update your global CSS (`App.scss`) with Tailwind imports
|
|
28
|
+
- Create/update `postcss.config.js` with the correct Tailwind CSS PostCSS plugin
|
|
29
|
+
- Configure Tailwind with `tw-` prefix by default
|
|
30
|
+
|
|
31
|
+
### `add` - Add Components
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Add a specific component
|
|
35
|
+
npx myoperator-ui add button
|
|
36
|
+
|
|
37
|
+
# Add multiple components
|
|
38
|
+
npx myoperator-ui add button badge table
|
|
39
|
+
|
|
40
|
+
# Add all available components at once
|
|
41
|
+
npx myoperator-ui add --all
|
|
42
|
+
|
|
43
|
+
# Interactive selection (shows all available components)
|
|
44
|
+
npx myoperator-ui add
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Options:**
|
|
48
|
+
|
|
49
|
+
| Option | Short | Description |
|
|
50
|
+
|--------|-------|-------------|
|
|
51
|
+
| `--all` | `-a` | Add all available components |
|
|
52
|
+
| `--yes` | `-y` | Skip confirmation prompt |
|
|
53
|
+
| `--overwrite` | `-o` | Overwrite existing files |
|
|
54
|
+
| `--path <path>` | `-p` | Custom path (default: `src/components/ui`) |
|
|
55
|
+
|
|
56
|
+
**Examples:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Add all components at once
|
|
60
|
+
npx myoperator-ui add --all
|
|
61
|
+
|
|
62
|
+
# Add all components, skip confirmation
|
|
63
|
+
npx myoperator-ui add --all -y
|
|
64
|
+
|
|
65
|
+
# Skip confirmation
|
|
66
|
+
npx myoperator-ui add button -y
|
|
67
|
+
|
|
68
|
+
# Overwrite existing component
|
|
69
|
+
npx myoperator-ui add button --overwrite
|
|
70
|
+
|
|
71
|
+
# Add to custom directory
|
|
72
|
+
npx myoperator-ui add button -p src/ui
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `update` - Update Components
|
|
76
|
+
|
|
77
|
+
Safely update installed components to the latest version with diff preview.
|
|
78
|
+
|
|
79
|
+
**Important:** Always use `@latest` to ensure you get the newest component code:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Update a specific component (recommended)
|
|
83
|
+
npx myoperator-ui@latest update button
|
|
84
|
+
|
|
85
|
+
# Update multiple components
|
|
86
|
+
npx myoperator-ui@latest update button badge
|
|
87
|
+
|
|
88
|
+
# Interactive selection (shows installed components)
|
|
89
|
+
npx myoperator-ui@latest update
|
|
90
|
+
|
|
91
|
+
# Update all installed components
|
|
92
|
+
npx myoperator-ui@latest update --all
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Options:**
|
|
96
|
+
|
|
97
|
+
| Option | Short | Description |
|
|
98
|
+
|--------|-------|-------------|
|
|
99
|
+
| `--yes` | `-y` | Skip confirmation prompt |
|
|
100
|
+
| `--all` | `-a` | Update all installed components |
|
|
101
|
+
| `--dry-run` | `-d` | Preview changes without modifying files |
|
|
102
|
+
| `--backup` | `-b` | Create backup files before updating |
|
|
103
|
+
| `--path <path>` | `-p` | Custom path (default: `src/components/ui`) |
|
|
104
|
+
|
|
105
|
+
**Examples:**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Preview what would change (safe - no modifications)
|
|
109
|
+
npx myoperator-ui@latest update button --dry-run
|
|
110
|
+
|
|
111
|
+
# Preview all component updates
|
|
112
|
+
npx myoperator-ui@latest update --all --dry-run
|
|
113
|
+
|
|
114
|
+
# Update all with backups
|
|
115
|
+
npx myoperator-ui@latest update --all --backup
|
|
116
|
+
|
|
117
|
+
# Force update without confirmation
|
|
118
|
+
npx myoperator-ui@latest update button -y
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
> **Note:** If you see "No changes" but expect updates, make sure you're using `@latest` to get the newest package version. NPX may cache older versions.
|
|
122
|
+
|
|
123
|
+
**Update Safeguards:**
|
|
124
|
+
- Shows diff of changes before applying
|
|
125
|
+
- `--dry-run` lets you preview without making changes
|
|
126
|
+
- `--backup` creates timestamped backups (e.g., `button.tsx.backup.1700000000`)
|
|
127
|
+
- Only updates components that are already installed
|
|
128
|
+
- Skips components with no changes
|
|
129
|
+
|
|
130
|
+
### Other Commands
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Check CLI version
|
|
134
|
+
npx myoperator-ui --version
|
|
135
|
+
|
|
136
|
+
# Get help
|
|
137
|
+
npx myoperator-ui --help
|
|
138
|
+
npx myoperator-ui add --help
|
|
139
|
+
npx myoperator-ui update --help
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Available Components
|
|
143
|
+
|
|
144
|
+
| Component | Description |
|
|
145
|
+
|-----------|-------------|
|
|
146
|
+
| `accordion` | Expandable/collapsible accordion component with single or multiple mode support |
|
|
147
|
+
| `badge` | Status badge with active, failed, disabled, outline, secondary, destructive variants and asChild support |
|
|
148
|
+
| `button` | Customizable button with variants, sizes (including icon-lg), icons, and loading state |
|
|
149
|
+
| `checkbox` | Tri-state checkbox built on Radix UI with label support (checked, unchecked, indeterminate) |
|
|
150
|
+
| `dropdown-menu` | Dropdown menu for displaying actions and options |
|
|
151
|
+
| `input` | Basic input component |
|
|
152
|
+
| `multi-select` | Multi-select dropdown with search, tags, and keyboard navigation |
|
|
153
|
+
| `select` | Single select dropdown component |
|
|
154
|
+
| `select-field` | Select field with label, helper text, and validation states |
|
|
155
|
+
| `switch` | Switch component built on Radix UI for boolean inputs with on/off states |
|
|
156
|
+
| `table` | Composable table with size variants, loading/empty states, sticky columns |
|
|
157
|
+
| `tag` | Tag component for event labels with optional bold label prefix |
|
|
158
|
+
| `text-field` | Text input with label, icons, prefix/suffix, validation states, and character count |
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
After running `init`, a `components.json` file is created:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"$schema": "https://myoperator.com/schema.json",
|
|
167
|
+
"style": "default",
|
|
168
|
+
"tailwind": {
|
|
169
|
+
"config": "tailwind.config.js",
|
|
170
|
+
"css": "src/App.scss",
|
|
171
|
+
"baseColor": "slate",
|
|
172
|
+
"cssVariables": true,
|
|
173
|
+
"prefix": "tw-"
|
|
174
|
+
},
|
|
175
|
+
"aliases": {
|
|
176
|
+
"components": "@/components",
|
|
177
|
+
"utils": "@/lib/utils",
|
|
178
|
+
"ui": "@/components/ui"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Tailwind CSS Configuration
|
|
184
|
+
|
|
185
|
+
The CLI generates a `tailwind.config.js` with:
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
/** @type {import('tailwindcss').Config} */
|
|
189
|
+
export default {
|
|
190
|
+
darkMode: ["class"],
|
|
191
|
+
prefix: "tw-",
|
|
192
|
+
content: ["./src/components/ui/**/*.{js,ts,jsx,tsx}"],
|
|
193
|
+
theme: {
|
|
194
|
+
// ... theme configuration
|
|
195
|
+
},
|
|
196
|
+
plugins: [require("tailwindcss-animate")],
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Key Features:**
|
|
201
|
+
- `prefix: "tw-"` - Avoids conflicts with other CSS frameworks
|
|
202
|
+
- Scoped content path - Only scans UI components directory
|
|
203
|
+
|
|
204
|
+
## Bootstrap Compatibility
|
|
205
|
+
|
|
206
|
+
myOperator UI automatically detects if your project uses Bootstrap and configures Tailwind CSS to avoid conflicts.
|
|
207
|
+
|
|
208
|
+
### How it works
|
|
209
|
+
|
|
210
|
+
When Bootstrap is detected, the CLI uses selective Tailwind imports - importing only theme and utilities, skipping Preflight (Tailwind's CSS reset) which would override Bootstrap's base styles.
|
|
211
|
+
|
|
212
|
+
### Generated CSS for Bootstrap projects
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
/* Selective imports to avoid Preflight conflicts with Bootstrap */
|
|
216
|
+
@layer theme, base, components, utilities;
|
|
217
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
218
|
+
@import "tailwindcss/utilities.css" layer(utilities);
|
|
219
|
+
|
|
220
|
+
/* Tell Tailwind to scan component files for utility classes */
|
|
221
|
+
@source "./components/**/*.{js,ts,jsx,tsx}";
|
|
222
|
+
@source "./lib/**/*.{js,ts,jsx,tsx}";
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Tailwind CSS Version Support
|
|
226
|
+
|
|
227
|
+
### Tailwind CSS v4 (default)
|
|
228
|
+
|
|
229
|
+
For v4 projects, the CLI generates CSS-based configuration:
|
|
230
|
+
|
|
231
|
+
```css
|
|
232
|
+
@import "tailwindcss";
|
|
233
|
+
|
|
234
|
+
@theme {
|
|
235
|
+
--color-primary: hsl(222.2 47.4% 11.2%);
|
|
236
|
+
/* ... */
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Tailwind CSS v3
|
|
241
|
+
|
|
242
|
+
For v3 projects, the CLI generates the traditional configuration with `tailwind.config.js` and CSS variables.
|
|
243
|
+
|
|
244
|
+
## Requirements
|
|
245
|
+
|
|
246
|
+
- React 18+
|
|
247
|
+
- Tailwind CSS v3 or v4
|
|
248
|
+
- TypeScript (recommended)
|
|
249
|
+
|
|
250
|
+
## Dependencies
|
|
251
|
+
|
|
252
|
+
Components use these packages (installed automatically during `init`):
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
For Tailwind v3, you'll also need:
|
|
259
|
+
- `tailwindcss-animate`
|
|
260
|
+
|
|
261
|
+
## PostCSS Configuration
|
|
262
|
+
|
|
263
|
+
The CLI automatically sets up the correct PostCSS configuration for Tailwind CSS.
|
|
264
|
+
|
|
265
|
+
### For Tailwind v4
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
// postcss.config.js
|
|
269
|
+
export default {
|
|
270
|
+
plugins: {
|
|
271
|
+
'@tailwindcss/postcss': {},
|
|
272
|
+
},
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Common Error
|
|
277
|
+
|
|
278
|
+
If you see this error:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
[plugin:vite:css] [postcss] It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin.
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Fix it by:**
|
|
285
|
+
|
|
286
|
+
1. Installing the new plugin:
|
|
287
|
+
```bash
|
|
288
|
+
npm install -D @tailwindcss/postcss
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
2. Run `npx myoperator-ui init` to automatically create the correct configuration
|
|
292
|
+
|
|
293
|
+
## Troubleshooting
|
|
294
|
+
|
|
295
|
+
### Component styles not applying
|
|
296
|
+
|
|
297
|
+
Make sure you've installed the required dependencies:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Styles conflict with Bootstrap
|
|
304
|
+
|
|
305
|
+
If you're seeing Bootstrap styles override your components, make sure:
|
|
306
|
+
|
|
307
|
+
1. You ran `npx myoperator-ui init` after adding Bootstrap
|
|
308
|
+
2. The CSS file has selective imports (not `@import "tailwindcss"`)
|
|
309
|
+
|
|
310
|
+
### Version mismatch
|
|
311
|
+
|
|
312
|
+
To ensure you're using the latest version:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npx myoperator-ui@latest init
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Updating components
|
|
319
|
+
|
|
320
|
+
To get the latest component updates:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# Preview changes first
|
|
324
|
+
npx myoperator-ui update --all --dry-run
|
|
325
|
+
|
|
326
|
+
# Then apply updates
|
|
327
|
+
npx myoperator-ui update --all
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Development Workflow (For Maintainers)
|
|
331
|
+
|
|
332
|
+
### Safe Component Updates
|
|
333
|
+
|
|
334
|
+
To ensure changes don't accidentally break other components:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
cd packages/cli
|
|
338
|
+
|
|
339
|
+
# 1. Create a snapshot BEFORE making changes
|
|
340
|
+
npm run integrity:snapshot
|
|
341
|
+
|
|
342
|
+
# 2. Make your changes to a component (e.g., button.tsx)
|
|
343
|
+
|
|
344
|
+
# 3. Verify only the intended component changed
|
|
345
|
+
node scripts/check-integrity.js verify button
|
|
346
|
+
|
|
347
|
+
# 4. If check passes, build and publish
|
|
348
|
+
npm run build
|
|
349
|
+
npm publish
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Integrity Check Commands
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Create baseline snapshot of all components
|
|
356
|
+
npm run integrity:snapshot
|
|
357
|
+
|
|
358
|
+
# Verify no unexpected changes
|
|
359
|
+
npm run integrity:verify
|
|
360
|
+
|
|
361
|
+
# Verify specific component changed (others unchanged)
|
|
362
|
+
node scripts/check-integrity.js verify button
|
|
363
|
+
|
|
364
|
+
# Verify multiple components changed
|
|
365
|
+
node scripts/check-integrity.js verify button badge
|
|
366
|
+
|
|
367
|
+
# Check status of a specific component
|
|
368
|
+
node scripts/check-integrity.js diff button
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### What the Integrity Check Does
|
|
372
|
+
|
|
373
|
+
1. **Creates MD5 hashes** of each component file
|
|
374
|
+
2. **Compares current state** against the snapshot
|
|
375
|
+
3. **Fails if unexpected changes** are detected
|
|
376
|
+
4. **Passes if only expected components** changed
|
|
377
|
+
|
|
378
|
+
Example output when an unexpected change is detected:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
Component Status:
|
|
382
|
+
──────────────────────────────────────────────────
|
|
383
|
+
✓ badge - unchanged
|
|
384
|
+
✓ button - changed (expected)
|
|
385
|
+
⚠️ table - CHANGED (unexpected!)
|
|
386
|
+
✓ tag - unchanged
|
|
387
|
+
|
|
388
|
+
❌ INTEGRITY CHECK FAILED
|
|
389
|
+
Unexpected changes detected in: table
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## License
|
|
393
|
+
|
|
394
|
+
MIT
|