@schandlergarcia/sf-web-components 1.9.61 → 1.9.63

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.
@@ -26,7 +26,7 @@ The Engine dashboard uses a **strict 4-phase build process.** You MUST complete
26
26
  - **Map data:** Add markers, arcs, overlays to GeoMap to show where travelers are (see PRD Section 7)
27
27
  - **Panel titles:** "Disruptions", "Active Travelers", "Escalations", "Travel Spend"
28
28
  - **Escalations panel:** ActivityCard must be wrapped in BaseCard for visible card styling
29
- - **Chart:** Line chart showing monthly spend trend (see PRD Section 8d code block for exact options)
29
+ - **Chart:** Bar chart showing monthly spend trend (see PRD Section 8d code block for exact options and data transformation)
30
30
  - **DO NOT run validation or dev server** — phase is complete after wiring files
31
31
  3. **Phase 3: Real Data** — Connect to Salesforce, keep UI identical to Phase 2
32
32
  4. **Phase 4: Agent** — Add Eva ChatBar integration
package/CHANGELOG.md CHANGED
@@ -5,6 +5,34 @@ 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.63] - 2026-04-01
9
+
10
+ ### Updated
11
+ - **Synced latest .a4drules and PRD from reactapp4** - Final sync of all documentation
12
+ - All `.a4drules/features/` updated
13
+ - All `.a4drules/skills/` updated
14
+ - All `.a4drules/troubleshooting/` updated
15
+ - Root `.a4drules/*.md` files updated
16
+ - `data/engine-command-center-prd.md` updated to latest
17
+
18
+ ## [1.9.62] - 2026-04-01
19
+
20
+ ### Added
21
+ - **CLAUDE.md** - Comprehensive guidance for working with the package in Claude Code
22
+ - Package overview and purpose
23
+ - Critical explanation of two UI contexts (outer app vs command center)
24
+ - Architecture and directory structure
25
+ - Key conventions (component naming, theme hook, data hook)
26
+ - Development workflow and pre-publish checks
27
+ - Postinstall and reset script behavior
28
+ - Important files guide
29
+ - Common issues and solutions
30
+ - Testing checklist
31
+ - Version history summary
32
+ - Now included in published package (added to files array)
33
+
34
+ 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).
35
+
8
36
  ## [1.9.61] - 2026-04-01
9
37
 
10
38
  ### 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.
@@ -305,30 +305,31 @@ Examples from sample data:
305
305
 
306
306
  ### 8d. Monthly Spend Trend (1/2 width)
307
307
 
308
- `ChartCard` wrapping a `D3Chart` with `D3ChartTemplates.lineChart`.
308
+ `ChartCard` wrapping a `D3Chart` with `D3ChartTemplates.groupedBarChart` (lineChart doesn't support categorical x-axis).
309
309
 
310
310
  **CRITICAL: Use this exact code structure:**
311
311
 
312
312
  ```tsx
313
+ // Transform data to chart format
314
+ const spendChartData = useDataSource({
315
+ sample: MONTHLY_SPEND.map(m => ({ x: m.month, spend: m.amount })),
316
+ live: []
317
+ });
318
+
313
319
  <ChartCard
314
320
  title="Travel Spend"
315
321
  subtitle="Monthly trend (6 months)"
316
322
  chart={
317
323
  <D3Chart
318
- data={useDataSource({ sample: MONTHLY_SPEND, live: [] })}
319
- renderChart={D3ChartTemplates.lineChart}
324
+ data={spendChartData}
325
+ renderChart={D3ChartTemplates.groupedBarChart}
320
326
  options={{
321
- xKey: "month",
322
- yKey: "amount",
323
- color: "#5BC8C8",
324
- lineWidth: 3,
325
- showDots: true,
326
- dotRadius: 4,
327
- showArea: true,
328
- areaOpacity: 0.1,
327
+ xKey: "x",
328
+ groups: ["spend"],
329
+ colors: ["#5BC8C8"],
330
+ barRadius: 6,
329
331
  margin: { top: 20, right: 20, bottom: 40, left: 60 },
330
332
  showGrid: true,
331
- formatY: (d) => `$${(d / 1000).toFixed(0)}K`,
332
333
  }}
333
334
  responsive
334
335
  height={320}
@@ -337,19 +338,18 @@ Examples from sample data:
337
338
  />
338
339
  ```
339
340
 
340
- **Data source:** Import `MONTHLY_SPEND` from sample data
341
+ **Data source:** Import `MONTHLY_SPEND` from sample data, transform to chart format
341
342
 
342
343
  **Requirements:**
343
- - X-axis: month names (Oct through Mar)
344
- - Y-axis: spend amount formatted as $XXK
344
+ - X-axis: month names (Oct through Mar) - categorical
345
+ - Y-axis: spend amount in dollars (will show as thousands: 98000, 128000, etc.)
345
346
  - Height: 320px
346
- - Line color: Engine teal (#5BC8C8)
347
- - Line width: 3px
348
- - Show dots at data points (radius: 4)
349
- - Show filled area under line (opacity: 0.1)
347
+ - Bar color: Engine teal (#5BC8C8)
348
+ - Bar radius: 6 for rounded corners
349
+ - **Data transformation:** map `{ month, amount }` to `{ x, spend }` format inline
350
350
  - responsive={true}
351
351
 
352
- **Why this chart:** Shows spend trends over time so travel managers can spot anomalies, budget overruns, or seasonal patterns. Actionable data for financial planning.
352
+ **Why this chart:** Shows spend trends over time so travel managers can spot anomalies, budget overruns, or seasonal patterns. Using bars instead of line because D3 lineChart requires numeric x-axis.
353
353
 
354
354
  **That's it!** Only 4 panels total: Disruptions, Active Travelers, Escalations, and Monthly Spend Trend.
355
355
 
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.63",
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": {