@schandlergarcia/sf-web-components 1.9.61 → 1.9.62

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/CHANGELOG.md +18 -0
  2. package/CLAUDE.md +258 -0
  3. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.9.62] - 2026-04-01
9
+
10
+ ### Added
11
+ - **CLAUDE.md** - Comprehensive guidance for working with the package in Claude Code
12
+ - Package overview and purpose
13
+ - Critical explanation of two UI contexts (outer app vs command center)
14
+ - Architecture and directory structure
15
+ - Key conventions (component naming, theme hook, data hook)
16
+ - Development workflow and pre-publish checks
17
+ - Postinstall and reset script behavior
18
+ - Important files guide
19
+ - Common issues and solutions
20
+ - Testing checklist
21
+ - Version history summary
22
+ - Now included in published package (added to files array)
23
+
24
+ This file provides essential context when opening sf-web-components as a standalone Claude Code project, explaining the architecture, conventions, and common pitfalls (like UIButton vs Button confusion).
25
+
8
26
  ## [1.9.61] - 2026-04-01
9
27
 
10
28
  ### Updated
package/CLAUDE.md ADDED
@@ -0,0 +1,258 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code when working with the sf-web-components package.
4
+
5
+ ## Package Overview
6
+
7
+ **@schandlergarcia/sf-web-components** is an npm package that provides:
8
+
9
+ 1. **React component library** - Pre-built UI components for Salesforce Web Applications
10
+ 2. **Templates** - Page templates (Home, Search, NotFound, BlankDashboard) and config templates (routes.tsx, vite.config.ts, dataStrategy.ts)
11
+ 3. **Automation** - Postinstall script that sets up consuming projects automatically
12
+ 4. **Documentation** - `.a4drules` skills and features for AI-assisted development
13
+ 5. **Sample data** - Engine Travel sample data and pre-built GraphQL schema
14
+ 6. **Scripts** - Reset scripts, validation scripts, schema generation
15
+
16
+ **Primary use case:** Building Salesforce Web Applications with React, specifically for:
17
+ - Outer app pages (search, navigation) using shadcn/ui + Tailwind
18
+ - Command Center dashboards using custom library components + HeroUI
19
+
20
+ ## Architecture
21
+
22
+ ### Two UI Contexts (CRITICAL)
23
+
24
+ The package supports **two distinct UI contexts** that must NOT be mixed:
25
+
26
+ #### 1. Outer App Context
27
+ - **Files:** `src/pages/Home.tsx`, `src/pages/Search.tsx`, `src/pages/NotFound.tsx` (installed from templates)
28
+ - **Rendered in:** AppLayout wrapper (standard React Router routes)
29
+ - **Components:** shadcn/ui from `@/components/ui/`
30
+ - `Button` from `@/components/ui/button`
31
+ - `Input` from `@/components/ui/input`
32
+ - etc.
33
+ - **Icons:** Lucide React (`lucide-react`)
34
+ - **Styling:** Neutral shadcn theme (slate colors, no Engine branding)
35
+ - **File type:** `.tsx`
36
+
37
+ #### 2. Command Center Context
38
+ - **Files:** Dashboard pages in `src/pages/` (e.g., BlankDashboard, EngineDashboard)
39
+ - **Rendered in:** CommandCenter wrapper with `.heroui-scope` class
40
+ - **Components:** Library components from `@/components/library`
41
+ - `UIButton` from `@/components/library/ui/UIButton`
42
+ - `UIInput` from `@/components/library/ui/UIInput`
43
+ - `MetricCard`, `ChartCard`, `ListCard`, `TableCard`, etc.
44
+ - **Icons:** Heroicons (`@heroicons/react`)
45
+ - **Styling:** Engine brand colors (teal #5BC8C8, coral, orange) inside `.heroui-scope`
46
+ - **File type:** `.jsx` or `.tsx`
47
+
48
+ **Common mistake:** Using UIButton/UIInput in outer app pages or shadcn Button/Input in command center dashboards. Check `.a4drules/features/pre-code-checklist.md` for validation rules.
49
+
50
+ ### Package Structure
51
+
52
+ ```
53
+ sf-web-components/
54
+ ├── src/
55
+ │ ├── components/
56
+ │ │ ├── library/ # Command center components (MetricCard, ChartCard, etc.)
57
+ │ │ │ ├── cards/
58
+ │ │ │ ├── charts/
59
+ │ │ │ ├── ui/ # UIButton, UIInput, etc.
60
+ │ │ │ ├── theme/ # AppThemeProvider, useThemeMode
61
+ │ │ │ ├── data/ # useDataSource, DataModeProvider
62
+ │ │ │ └── index.jsx # Barrel export
63
+ │ │ └── workspace/ # CommandRegistry, ComponentRegistry
64
+ │ ├── templates/
65
+ │ │ ├── pages/ # Home.tsx.template, Search.tsx.template, etc.
66
+ │ │ ├── config/ # routes.tsx.template, vite.config.ts.template
67
+ │ │ ├── lib/ # dataStrategy.ts.template
68
+ │ │ └── workspace/ # CommandCenter.tsx.template
69
+ │ ├── lib/ # Utilities (utils.ts)
70
+ │ └── styles/ # global.css with Engine brand tokens
71
+ ├── scripts/
72
+ │ ├── postinstall.mjs # Runs after npm install in consuming projects
73
+ │ ├── reset-command-center.sh
74
+ │ ├── validate-dashboard.sh
75
+ │ └── verify-consistency.sh
76
+ ├── data/
77
+ │ ├── engine-sample-data.js
78
+ │ ├── schema.graphql
79
+ │ └── engine-command-center-prd.md
80
+ └── .a4drules/
81
+ ├── features/ # Dashboard rules, engine-dashboard-rule, etc.
82
+ ├── skills/ # component-library, command-center-builder, etc.
83
+ ├── troubleshooting/ # Common issues and solutions
84
+ ├── validation-requirements.md
85
+ ├── webapp-data.md
86
+ └── webapp-ui.md
87
+ ```
88
+
89
+ ## Key Conventions
90
+
91
+ ### Component Naming
92
+ - **Library components** (command center): `UIButton`, `UIInput`, `MetricCard`, `ChartCard`
93
+ - **shadcn components** (outer app): `Button`, `Input`, `Card` from `@/components/ui/`
94
+
95
+ ### Theme Hook
96
+ - **Correct:** `import { useThemeMode } from "@/components/library/theme/AppThemeProvider"`
97
+ - **Wrong:** `import useAppTheme from ...` (does not exist)
98
+ - **Usage:** `const { mode, toggle } = useThemeMode();`
99
+
100
+ ### Data Hook
101
+ - **Pattern:** Use `useDataSource` for instant loading with sample data cache
102
+ - **Example:**
103
+ ```javascript
104
+ import useDataSource from "@/components/library/data/useDataSource";
105
+
106
+ const travelers = useDataSource({
107
+ sample: SAMPLE_TRAVELERS,
108
+ live: liveTravelers ?? []
109
+ });
110
+ ```
111
+ - **Configuration:** `src/lib/dataStrategy.ts` controls `ENABLE_SAMPLE_DATA_CACHE`
112
+
113
+ ### File Extensions
114
+ - **Outer app pages:** `.tsx`
115
+ - **Command center dashboards:** `.jsx` or `.tsx` (`.jsx` preferred per dashboard rules)
116
+
117
+ ## Working with the Package
118
+
119
+ ### Development Workflow
120
+
121
+ 1. **Make changes** to components, templates, or documentation
122
+ 2. **Update version:** `npm version patch` (or minor/major)
123
+ 3. **Update CHANGELOG.md** with:
124
+ - Version number
125
+ - Date
126
+ - What changed and why
127
+ - Context for the change
128
+ 4. **Build:** `npm run build`
129
+ 5. **Verify:** `npm run verify` (checks consistency)
130
+ 6. **Publish:** `npm publish` (runs pre-publish checks automatically)
131
+
132
+ ### Pre-Publish Checks
133
+
134
+ The `scripts/pre-publish-check.sh` runs automatically before publishing and verifies:
135
+ 1. Consistency between code, docs, and templates
136
+ 2. CHANGELOG.md has entry for current version
137
+ 3. Component naming conventions (UIButton.tsx exists, Button.tsx doesn't in library/ui/)
138
+ 4. Build succeeds
139
+ 5. Documentation files exist
140
+ 6. package.json files array includes necessary directories
141
+
142
+ ### Postinstall Behavior
143
+
144
+ When a project installs this package, `scripts/postinstall.mjs` automatically:
145
+
146
+ 1. **Copies component library** to `src/components/library/`
147
+ 2. **Copies lib utilities** to `src/lib/`
148
+ 3. **Copies types** to `src/types/`
149
+ 4. **Copies workspace files** to `src/components/workspace/`
150
+ 5. **Installs page templates** to `src/pages/` (Home.tsx, Search.tsx, NotFound.tsx, BlankDashboard.tsx)
151
+ 6. **Updates imports** in existing files (changes package imports to local `@/components/library` imports)
152
+ 7. **Copies sample data** to `src/data/engine-sample-data.js`
153
+ 8. **Copies schema** to root `schema.graphql`
154
+ 9. **Copies PRD** to root `engine-command-center-prd.md`
155
+ 10. **Installs config files** (routes.tsx, vite.config.ts, dataStrategy.ts) if they don't exist
156
+ 11. **Adds npm scripts** to package.json (reset:command-center, validate:dashboard, graphql:schema:sample)
157
+ 12. **Copies .a4drules** to project root for AI assistant discoverability
158
+
159
+ **Important:** Templates are **always overwritten** to ensure latest versions, except for config files (vite.config.ts, dataStrategy.ts) which only install if missing.
160
+
161
+ ### Reset Script
162
+
163
+ The `scripts/reset-command-center.sh` provides a clean baseline for projects:
164
+
165
+ - Removes custom dashboard pages
166
+ - Restores BlankDashboard.tsx
167
+ - Updates CommandCenter.tsx to render BlankDashboard
168
+ - Restores Home.tsx with Account Search page
169
+ - Restores Search.tsx placeholder
170
+ - Updates routes.tsx to include Home, /accounts, and /accounts/:recordId
171
+ - Updates appLayout.tsx with nav bar
172
+ - Clears Vite cache
173
+ - Restores Engine-branded global.css
174
+ - Restores sample data and schema
175
+
176
+ ## Important Files
177
+
178
+ ### CHANGELOG.md
179
+ Complete history of all changes. ALWAYS update when making changes. Include:
180
+ - What changed
181
+ - Why it changed
182
+ - Context for the change
183
+ - Impact on consuming projects
184
+
185
+ ### .a4drules/
186
+ AI assistant documentation. Key files:
187
+ - `features/engine-dashboard-rule.md` - How to build Engine Travel Command Center
188
+ - `features/command-center-dashboard-rule.md` - Dashboard development rules
189
+ - `features/pre-code-checklist.md` - Pre-implementation validation
190
+ - `skills/component-library/` - Component API reference
191
+ - `validation-requirements.md` - Validation rules
192
+ - `webapp-data.md` - Data access patterns (GraphQL, REST, SDK usage)
193
+ - `webapp-ui.md` - UI platform rules
194
+
195
+ ### data/engine-command-center-prd.md
196
+ Product Requirements Document for Engine Travel Command Center. Defines:
197
+ - Product overview and users
198
+ - Brand tokens (Engine teal #5BC8C8, etc.)
199
+ - Layout structure (visualization-hero pattern)
200
+ - Component sections and data model
201
+ - Phase-by-phase build instructions
202
+
203
+ ### src/components/library/theme/AppThemeProvider.jsx
204
+ Theme provider with dark mode toggle. Exports:
205
+ - **Default:** `AppThemeProvider` component
206
+ - **Named:** `useThemeMode` hook
207
+
208
+ ### src/components/library/data/useDataSource.js
209
+ Hook for sample/live data switching via `ENABLE_SAMPLE_DATA_CACHE` flag.
210
+
211
+ ## Common Issues
212
+
213
+ ### TypeScript Errors
214
+ If you see TypeScript errors about missing exports:
215
+ 1. Check the actual file to see what's exported
216
+ 2. Don't trust TypeScript's suggestions blindly (it may suggest wrong import patterns)
217
+ 3. Refer to `.a4drules/skills/component-library/SKILL.md` for correct import patterns
218
+
219
+ ### Component Confusion
220
+ If agents mix up UIButton (library) vs Button (shadcn):
221
+ 1. Check `.a4drules/features/pre-code-checklist.md` for validation rules
222
+ 2. Outer app pages should NEVER import from `@/components/library`
223
+ 3. Command center dashboards should NEVER import from `@/components/ui/`
224
+
225
+ ### Routes Not Working
226
+ If routes show 404:
227
+ 1. Check routes.tsx imports match installed file locations
228
+ 2. Home should point to `./pages/Home` (not `__examples__`)
229
+ 3. Accounts should point to `./features/object-search/__examples__/pages/AccountSearch`
230
+ 4. Make sure `handle.showNavBar: true` is set for pages that need nav
231
+
232
+ ### Missing Nav Bar
233
+ Routes need `handle: { showInNavigation: true, showNavBar: true }` for nav bar to appear.
234
+
235
+ ## Testing
236
+
237
+ Before publishing:
238
+ 1. Test in a real project (reactapp4, vibes3, etc.)
239
+ 2. Run `npm install @schandlergarcia/sf-web-components@latest`
240
+ 3. Verify postinstall behavior
241
+ 4. Check templates are correct
242
+ 5. Verify .a4drules are accessible
243
+ 6. Test reset script: `npm run reset:command-center`
244
+ 7. Test validation: `npm run validate:dashboard`
245
+
246
+ ## Version History
247
+
248
+ See CHANGELOG.md for complete history. Recent major changes:
249
+ - v1.9.55 - Fixed UIButton/Button confusion in templates
250
+ - v1.9.56 - Fixed reset script 404 errors
251
+ - v1.9.57 - Restored "Browse All Accounts" button
252
+ - v1.9.58 - Fixed reset routes pointing to wrong Home file
253
+ - v1.9.59 - Restored navigation bar (showNavBar flag)
254
+ - v1.9.60-61 - Synced .a4drules and PRD from reactapp4
255
+
256
+ ## Current Version
257
+
258
+ Run `node -p "require('./package.json').version"` to get current version.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "1.9.61",
3
+ "version": "1.9.62",
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",
@@ -38,6 +38,7 @@
38
38
  "CONTRIBUTING.md",
39
39
  "ARCHITECTURE.md",
40
40
  "QUICK-REFERENCE.md",
41
+ "CLAUDE.md",
41
42
  ".a4drules"
42
43
  ],
43
44
  "scripts": {