@schandlergarcia/sf-web-components 1.9.26 → 1.9.28

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.
Files changed (3) hide show
  1. package/INSTALL.md +200 -0
  2. package/README.md +160 -48
  3. package/package.json +2 -1
package/INSTALL.md ADDED
@@ -0,0 +1,200 @@
1
+ # Installation Guide
2
+
3
+ Quick start guide for installing `@schandlergarcia/sf-web-components` in your Salesforce web application.
4
+
5
+ ## Prerequisites
6
+
7
+ - Salesforce web application created with `sf webapp generate --template react-ts`
8
+ - Node.js 18+ and npm installed
9
+ - Tailwind CSS v4 configured in your project
10
+
11
+ ## Installation Steps
12
+
13
+ ### 1. Navigate to Your Web App
14
+
15
+ ```bash
16
+ cd force-app/main/default/webapplications/YOUR_APP_NAME
17
+ ```
18
+
19
+ ### 2. Install the Package
20
+
21
+ ```bash
22
+ npm install @schandlergarcia/sf-web-components@latest
23
+ ```
24
+
25
+ The postinstall script runs automatically and:
26
+ - ✅ Copies 102+ component files to `src/components/library/`
27
+ - ✅ Installs page templates to `src/pages/`
28
+ - ✅ Installs workspace files to `src/components/workspace/`
29
+ - ✅ Copies AI assistant rules to project root `.a4drules/`
30
+ - ✅ Adds `reset:command-center` and `validate:dashboard` scripts
31
+ - ✅ Updates imports in existing files
32
+
33
+ ### 3. Install Type Definitions
34
+
35
+ ```bash
36
+ npm install --save-dev @types/d3 @types/topojson-client
37
+ ```
38
+
39
+ ### 4. Verify Installation
40
+
41
+ ```bash
42
+ npm run build
43
+ npm run dev
44
+ ```
45
+
46
+ Visit `http://localhost:5173` - you should see the CommandCenter with BlankDashboard.
47
+
48
+ ## What You Get
49
+
50
+ After installation:
51
+
52
+ ```
53
+ src/
54
+ ├── components/
55
+ │ ├── library/ # 102+ UI components
56
+ │ │ ├── ui/ # Buttons, inputs, cards, alerts
57
+ │ │ ├── cards/ # MetricCard, ChartCard, TableCard, etc.
58
+ │ │ ├── charts/ # D3Chart, GeoMap
59
+ │ │ ├── forms/ # FormRenderer, FormField
60
+ │ │ ├── filters/ # SearchFilter, SelectFilter
61
+ │ │ └── ...
62
+ │ └── workspace/
63
+ │ └── CommandCenter.tsx # Dashboard wrapper
64
+ ├── pages/
65
+ │ ├── Home.tsx # Renders CommandCenter
66
+ │ ├── BlankDashboard.tsx # Empty template
67
+ │ ├── Search.tsx # Search interface
68
+ │ └── NotFound.tsx # 404 page
69
+ ├── lib/
70
+ │ └── utils.ts # Utility functions
71
+ └── types/
72
+ └── conversation.ts # AgentforceConversationClient types
73
+
74
+ package.json # Added scripts:
75
+ # - reset:command-center
76
+ # - validate:dashboard
77
+
78
+ .a4drules/ # AI assistant rules (at project root)
79
+ ├── skills/
80
+ │ └── command-center-builder/
81
+ │ └── SKILL.md
82
+ └── features/
83
+ └── command-center-dashboard-rule.md
84
+ ```
85
+
86
+ ## Next Steps
87
+
88
+ ### Option 1: Build a Dashboard with AI
89
+
90
+ Have an AI assistant (Agentforce, Claude, etc.) build your dashboard:
91
+
92
+ ```
93
+ Build me a Sales Dashboard with KPI metrics, revenue chart, and top accounts table
94
+ ```
95
+
96
+ The AI will:
97
+ 1. Load the command-center-builder skill
98
+ 2. Create your dashboard file in `src/pages/`
99
+ 3. Wire it to CommandCenter
100
+ 4. Update Home.tsx
101
+ 5. Validate with `npm run validate:dashboard`
102
+
103
+ ### Option 2: Build Manually
104
+
105
+ ```bash
106
+ # 1. Create dashboard file
107
+ cat > src/pages/MyDashboard.tsx << 'EOF'
108
+ import { MetricCard, ChartCard } from '@/components/library';
109
+
110
+ export default function MyDashboard() {
111
+ return (
112
+ <div className="space-y-6 p-6">
113
+ <div className="grid grid-cols-3 gap-6">
114
+ <MetricCard title="Revenue" value="$1.2M" change="+12%" changeType="positive" />
115
+ <MetricCard title="Users" value={1284} change="+8%" changeType="positive" />
116
+ <MetricCard title="Conversion" value="3.2%" change="-0.5%" changeType="negative" />
117
+ </div>
118
+ </div>
119
+ );
120
+ }
121
+ EOF
122
+
123
+ # 2. Wire to CommandCenter
124
+ # Edit src/components/workspace/CommandCenter.tsx
125
+ # Change: import BlankDashboard from "../../pages/BlankDashboard";
126
+ # To: import MyDashboard from "../../pages/MyDashboard";
127
+ # Change: <BlankDashboard />
128
+ # To: <MyDashboard />
129
+
130
+ # 3. Update Home
131
+ # Home.tsx should already render CommandCenter
132
+
133
+ # 4. Validate
134
+ npm run validate:dashboard
135
+ ```
136
+
137
+ ## Useful Commands
138
+
139
+ ```bash
140
+ # Development
141
+ npm run dev # Start dev server
142
+ npm run build # Build for production
143
+
144
+ # Dashboard Management
145
+ npm run reset:command-center # Reset to blank state
146
+ npm run validate:dashboard # Check dashboard rules
147
+
148
+ # GraphQL (if using Salesforce data)
149
+ npm run graphql:schema # Fetch schema
150
+ npm run graphql:codegen # Generate types
151
+ ```
152
+
153
+ ## Troubleshooting
154
+
155
+ ### Postinstall didn't run
156
+
157
+ ```bash
158
+ node node_modules/@schandlergarcia/sf-web-components/scripts/postinstall.mjs
159
+ ```
160
+
161
+ ### Build errors about missing D3 types
162
+
163
+ ```bash
164
+ npm install --save-dev @types/d3 @types/topojson-client
165
+ ```
166
+
167
+ ### Home page shows blank/wrong content
168
+
169
+ ```bash
170
+ # Re-run postinstall to restore templates
171
+ node node_modules/@schandlergarcia/sf-web-components/scripts/postinstall.mjs
172
+ ```
173
+
174
+ ### AI assistant not following rules
175
+
176
+ Check that `.a4drules/` exists at your **project root** (not in the webapp directory):
177
+
178
+ ```bash
179
+ # From webapp directory
180
+ ls ../../../../../.a4drules/skills/command-center-builder/SKILL.md
181
+ ```
182
+
183
+ If missing, re-run postinstall:
184
+
185
+ ```bash
186
+ node node_modules/@schandlergarcia/sf-web-components/scripts/postinstall.mjs
187
+ ```
188
+
189
+ ## Support
190
+
191
+ - **Documentation:** [README.md](./README.md)
192
+ - **Issues:** [GitHub Issues](https://github.com/schandlergarcia/sf-web-components/issues)
193
+ - **Package:** [npm](https://www.npmjs.com/package/@schandlergarcia/sf-web-components)
194
+
195
+ ## Next Steps
196
+
197
+ - Read the [Component Documentation](./README.md#using-the-dashboard-framework)
198
+ - Check [AI Assistant Rules](./.a4drules/skills/command-center-builder/SKILL.md) (after install)
199
+ - Browse example pages in `src/pages/`
200
+ - Explore component library in `src/components/library/`
package/README.md CHANGED
@@ -57,13 +57,13 @@ The postinstall script automatically:
57
57
  - Chat components (message UI, typing indicators, suggestions)
58
58
 
59
59
  ✅ **Installs complete routes configuration** at `src/routes.tsx`
60
- - Home page with account search
60
+ - `/` (Home) - Renders CommandCenter (dashboard wrapper)
61
61
  - `/accounts` - Account search with filters and sorting
62
62
  - `/accounts/:recordId` - Account detail page
63
- - NotFound page
63
+ - `*` (NotFound) - 404 error page
64
64
 
65
65
  ✅ **Installs 4 page templates** to `src/pages/`
66
- - `Home.tsx` - Search interface with UIButton and UIInput
66
+ - `Home.tsx` - Renders CommandCenter (dashboard wrapper)
67
67
  - `NotFound.tsx` - 404 error page
68
68
  - `Search.tsx` - Generic search page
69
69
  - `BlankDashboard.tsx` - Empty dashboard template
@@ -77,6 +77,63 @@ The postinstall script automatically:
77
77
  ✅ **Installs workspace components** to `src/components/workspace/`
78
78
  - `CommandCenter.tsx` - Dashboard wrapper with theme and data providers
79
79
 
80
+ ✅ **Adds npm scripts** to your `package.json`
81
+ - `reset:command-center` - Reset to blank dashboard state
82
+ - `validate:dashboard` - Validate dashboard files against rules
83
+
84
+ ✅ **Copies AI assistant rules** to project root `.a4drules/`
85
+ - `skills/` - Step-by-step guides for AI assistants (Agentforce, Claude, etc.)
86
+ - `features/` - Feature-specific implementation rules
87
+ - Enables AI assistants to build dashboards correctly
88
+
89
+ ---
90
+
91
+ ## Building Dashboards
92
+
93
+ ### With AI Assistants (Agentforce, Claude, etc.)
94
+
95
+ After installation, AI assistants can build complete dashboards for you:
96
+
97
+ **Example prompt:**
98
+ ```
99
+ Build me a Fleet Management Command Center dashboard with:
100
+ - KPI metrics for total vehicles, active trips, maintenance alerts
101
+ - World map showing vehicle locations
102
+ - List of recent trips
103
+ - Status panel for vehicle health
104
+ ```
105
+
106
+ The AI assistant will:
107
+ 1. ✅ Load the command-center-builder skill
108
+ 2. ✅ Create `src/pages/FleetDashboard.tsx` (complete, valid TypeScript)
109
+ 3. ✅ Update `CommandCenter.tsx` to import it
110
+ 4. ✅ Update `Home.tsx` to render CommandCenter
111
+ 5. ✅ Run `npm run validate:dashboard` and fix all errors
112
+ 6. ✅ Report when complete
113
+
114
+ **Result:** Working dashboard at `/` using only library components.
115
+
116
+ ### Manual Dashboard Development
117
+
118
+ If you prefer to build dashboards manually:
119
+
120
+ ```bash
121
+ # 1. Create your dashboard file
122
+ touch src/pages/MyDashboard.tsx
123
+
124
+ # 2. Import and use library components
125
+ # (see examples below)
126
+
127
+ # 3. Wire it to CommandCenter
128
+ # Edit src/components/workspace/CommandCenter.tsx
129
+
130
+ # 4. Update Home to render CommandCenter
131
+ # Edit src/pages/Home.tsx
132
+
133
+ # 5. Validate your work
134
+ npm run validate:dashboard
135
+ ```
136
+
80
137
  ---
81
138
 
82
139
  ## Using the Dashboard Framework
@@ -289,12 +346,12 @@ npm install
289
346
  npm run build
290
347
  ```
291
348
 
292
- ### Reset Command Center (All Apps)
349
+ ### Reset Command Center
293
350
 
294
351
  This script resets any app back to the blank dashboard baseline state:
295
352
 
296
353
  ```bash
297
- # This script resets the command center to the blank dashboard template
354
+ # Reset the command center to the blank dashboard template
298
355
  npm run reset:command-center
299
356
 
300
357
  # Or run directly:
@@ -302,15 +359,40 @@ bash node_modules/@schandlergarcia/sf-web-components/scripts/reset-command-cente
302
359
  ```
303
360
 
304
361
  **What it does:**
305
- - Removes custom dashboard pages (including those created at SFDX project root)
306
- - Reinstalls BlankDashboard.tsx with EmptyState
307
- - Resets CommandCenter.tsx (preserves theme mode)
308
- - Updates Home.tsx to render search interface
309
- - Creates Search.tsx for search interface at `/search` route
310
- - Resets routes to baseline configuration
311
- - Preserves: component library, authentication, all dependencies
362
+ - Removes custom dashboard pages from `src/pages/` (EngineDashboard.tsx, FleetDashboard.tsx, etc.)
363
+ - Reinstalls BlankDashboard.tsx with EmptyState ("Bespoke App Template" message)
364
+ - Resets CommandCenter.tsx to import BlankDashboard (preserves theme mode)
365
+ - Updates Home.tsx to render search interface (not CommandCenter)
366
+ - Creates Search.tsx for search interface
367
+ - Resets routes.tsx to baseline configuration
368
+ - Preserves: component library, workspace files, authentication, all dependencies
369
+
370
+ **Result:** Home route (`/`) displays the search interface. CommandCenter exists but is not wired to any route until you create a dashboard.
371
+
372
+ ### Validate Dashboard
373
+
374
+ After building a dashboard, validate it meets all requirements:
375
+
376
+ ```bash
377
+ # Run the dashboard validator
378
+ npm run validate:dashboard
379
+
380
+ # Or run directly:
381
+ bash node_modules/@schandlergarcia/sf-web-components/scripts/validate-dashboard.sh
382
+ ```
383
+
384
+ **What it checks:**
385
+ - Files use `.tsx` extension (not `.jsx`)
386
+ - CommandCenter.tsx imports a real dashboard (not BlankDashboard)
387
+ - No hand-rolled HTML cards (must use library components)
388
+ - No forbidden colors (`text-white`, `text-black`, `bg-black`)
389
+ - No inline `style={{}}` or `<style>` tags
390
+ - Dashboard uses `useDataSource` for sample/live data
391
+ - No navigation elements (`<nav>`) inside dashboard
392
+ - Max 4 metrics per row
393
+ - All JSX tags properly closed
312
394
 
313
- **Result:** Home route (`/`) displays the search interface (baseline state)
395
+ **Exit codes:** 0 = pass, 1 = errors found (must fix before dashboard is complete)
314
396
 
315
397
  ---
316
398
 
@@ -378,16 +460,20 @@ Available npm scripts in the consuming application:
378
460
 
379
461
  ```bash
380
462
  # Development
381
- npm run dev # Start Vite dev server
382
- npm run build # TypeScript check + Vite build
383
- npm run lint # Run ESLint
463
+ npm run dev # Start Vite dev server
464
+ npm run build # TypeScript check + Vite build
465
+ npm run lint # Run ESLint
466
+
467
+ # Dashboard Development
468
+ npm run reset:command-center # Reset to blank dashboard state
469
+ npm run validate:dashboard # Validate dashboard files against rules
384
470
 
385
471
  # GraphQL (if using)
386
- npm run graphql:schema # Fetch GraphQL schema from Salesforce org
387
- npm run graphql:codegen # Generate TypeScript types from schema
472
+ npm run graphql:schema # Fetch GraphQL schema from Salesforce org
473
+ npm run graphql:codegen # Generate TypeScript types from schema
388
474
 
389
475
  # Testing
390
- npm run test # Run Vitest tests
476
+ npm run test # Run Vitest tests
391
477
  ```
392
478
 
393
479
  ---
@@ -402,50 +488,76 @@ For detailed component API documentation, see:
402
488
 
403
489
  ## Version History
404
490
 
405
- ### Latest: v1.9.9 (2026-03-29)
406
- - Fixed routes template importing wrong Home page
407
- - Now uses installed Home.tsx with component library UI
491
+ ### Latest: v1.9.26 (2026-03-29)
492
+ - **Fixed:** AI assistant file truncation (explicit "write complete files" rule)
493
+ - Dashboard validator now requires `.tsx` files (not `.jsx`)
494
+ - Postinstall adds `validate:dashboard` script to package.json
495
+
496
+ ### v1.9.25 (2026-03-29)
497
+ - **Fixed:** Dashboard validator paths (`src/pages/` not `src/components/pages/`)
498
+ - **Fixed:** Validator file extension check (`.tsx` required, `.jsx` is error)
499
+ - Postinstall adds both `reset:command-center` and `validate:dashboard` scripts
408
500
 
409
- ### v1.9.8 (2026-03-29)
410
- - Added complete routes.tsx template with account search & detail
411
- - Zero-config installation
501
+ ### v1.9.24 (2026-03-29)
502
+ - **Fixed:** Home.tsx to render CommandCenter (not search interface)
503
+ - AI rules updated with explicit Step 2.5 for updating Home.tsx
504
+ - Strengthened rule #15 in dashboard feature rules
412
505
 
413
- ### v1.9.7 (2026-03-29)
414
- - Fixed UIButton using non-existent brand colors
415
- - Changed to standard blue colors
506
+ ### v1.9.23 (2026-03-29)
507
+ - **Fixed:** Postinstall now copies `.md` files (skills were being skipped)
508
+ - AI assistant rules now properly installed to project root `.a4drules/`
416
509
 
417
- ### v1.9.6 (2026-03-29)
418
- - Fixed AgentforceConversationClient type definitions
419
- - Postinstall now skips hidden directories
510
+ ### v1.9.22 (2026-03-29)
511
+ - Added automatic `.a4drules` copying to project root for AI assistant discovery
512
+ - Copies `skills/` and `features/` directories during postinstall
420
513
 
421
- ### v1.9.5 (2026-03-29)
422
- - Updated glob dependency to v13.0.6
423
- - Fixed security vulnerabilities
514
+ ### v1.9.21 (2026-03-29)
515
+ - Added automatic dashboard file migration from old location to new location
516
+ - Migrates `src/components/pages/*.jsx` → `src/pages/*.tsx`
517
+
518
+ ### v1.9.20 (2026-03-29)
519
+ - **Fixed:** SKILL.md paths corrected to `src/pages/` (not `src/components/pages/`)
520
+ - All examples updated with correct file locations and imports
521
+
522
+ ### v1.9.19 (2026-03-29)
523
+ - **Fixed:** File extension rule strengthened to MUST be `.tsx` (not "should")
524
+ - Dashboard feature rules updated with no exceptions for `.jsx`
424
525
 
425
526
  See [CHANGELOG.md](./CHANGELOG.md) for full version history.
426
527
 
427
528
  ---
428
529
 
429
- ## 🤖 AI Agent Skills
530
+ ## 🤖 AI Assistant Rules
531
+
532
+ This package includes comprehensive rules for AI assistants (Agentforce, Claude, etc.) to build dashboards correctly.
533
+
534
+ During postinstall, rules are copied to your **project root** at `.a4drules/`:
535
+ - **skills/** - Step-by-step implementation guides
536
+ - `command-center-builder/` - Dashboard building rules
537
+ - `component-library/` - Component API reference
538
+ - And more...
539
+ - **features/** - Automatic rules that apply to specific files
540
+ - `command-center-dashboard-rule.md` - Applies to `src/pages/*.tsx` and `CommandCenter.tsx`
430
541
 
431
- This package includes Claude Code agent skills that teach AI how to work with these components.
542
+ ### How AI Assistants Use These Rules
432
543
 
433
- The `.a4drules/` directory contains:
434
- - **Skills**: Step-by-step guides for building with this library
435
- - **Features**: Feature-specific implementation rules
436
- - **Docs**: Data access patterns and UI conventions
544
+ When building dashboards, AI assistants:
545
+ 1. **Auto-load feature rules** when editing matching file paths
546
+ 2. **Follow explicit steps** from skill guides (create file → wire CommandCenter → update Home)
547
+ 3. **Validate** against requirements (`.tsx` only, no hand-rolled HTML, complete files)
548
+ 4. **Self-check** with `npm run validate:dashboard` before reporting done
437
549
 
438
- ### Using with Claude Code
550
+ ### Key Rules AI Assistants Follow
439
551
 
440
- When you install this package, Claude Code automatically discovers the skills and uses them to:
441
- - Build components correctly
442
- - Follow your architectural patterns
443
- - Use the right data access methods
444
- - Apply consistent styling
552
+ - **File location:** `src/pages/MyDashboard.tsx` (TypeScript required)
553
+ - **File completeness:** Write entire file from imports to closing brace (no truncation)
554
+ - **Components:** Use library components only (no hand-rolled `<div>` cards)
555
+ - **Wiring:** Update CommandCenter.tsx Home.tsx → routes.tsx
556
+ - **Validation:** Run `npm run validate:dashboard` and fix all errors before done
445
557
 
446
- ### Available Skills
558
+ ### For Human Developers
447
559
 
448
- Check `.a4drules/skills/` for the full list of included agent skills.
560
+ You can read these same rules at `.a4drules/skills/command-center-builder/SKILL.md` for the complete dashboard building guide.
449
561
 
450
562
  ---
451
563
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "1.9.26",
3
+ "version": "1.9.28",
4
4
  "description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,6 +32,7 @@
32
32
  "src/lib",
33
33
  "src/types",
34
34
  "README.md",
35
+ "INSTALL.md",
35
36
  ".a4drules"
36
37
  ],
37
38
  "scripts": {