create-bluecopa-react-app 1.0.13 → 1.0.14
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/package.json
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This guide helps AI assistants and developers understand the project structure, patterns, and best practices for working with this BlueCopa React application template.
|
|
4
4
|
|
|
5
|
+
---
|
|
6
|
+
|
|
5
7
|
## 🏗️ Project Architecture Overview
|
|
6
8
|
|
|
7
9
|
### Core Stack
|
|
@@ -12,11 +14,48 @@ This guide helps AI assistants and developers understand the project structure,
|
|
|
12
14
|
- **Vite 6** for build tooling
|
|
13
15
|
- **TanStack Query** (via @bluecopa/react)
|
|
14
16
|
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 💡 UI Components & @bluecopa-ui Registry
|
|
20
|
+
|
|
21
|
+
This project uses [shadcn/ui](https://ui.shadcn.com/) to scaffold and manage UI component libraries, configured with an explicit support for the **@bluecopa-ui** component registry.
|
|
22
|
+
|
|
23
|
+
### About the `@bluecopa-ui` Registry
|
|
24
|
+
|
|
25
|
+
The registry location is defined in your `components.json` file, mapping the registry name to a hosted registry endpoint:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
...
|
|
30
|
+
"registries": {
|
|
31
|
+
"@bluecopa-ui": "https://shadcn-ui-henna.vercel.app/r/{name}.json"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- **@bluecopa-ui** registry extends the standard shadcn/ui workflow and provides a curated set of BlueCopa-centric UI components, patterns, and design tokens.
|
|
37
|
+
- When running any `npx shadcn@latest` CLI commands and passing `add` or `add registry`, you can use `@bluecopa-ui` as the registry source, e.g.:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx shadcn@latest add @bluecopa-ui/<component>
|
|
41
|
+
```
|
|
42
|
+
- This enables streamlined upgrades, easy addition of company-specific components, and consistency with the BlueCopa Design System.
|
|
43
|
+
|
|
44
|
+
#### Benefits
|
|
45
|
+
|
|
46
|
+
- **Consistency:** Centralizes custom BlueCopa UI patterns and updates.
|
|
47
|
+
- **Discoverability:** Quickly add business-specific primitives, layouts, dashboards, and utilities.
|
|
48
|
+
- **Maintenance:** Receive improvements, fixes, and new patterns from BlueCopa UX engineering.
|
|
49
|
+
|
|
50
|
+
**Tip:** `@bluecopa-ui` can be used alongside the default shadcn registry. Specify which to use with `--registry` CLI flag.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
15
54
|
### Key Directories
|
|
16
55
|
```
|
|
17
56
|
app/
|
|
18
57
|
├── components/ # Reusable UI components
|
|
19
|
-
│ ├── ui/ # shadcn/ui components
|
|
58
|
+
│ ├── ui/ # shadcn/ui & @bluecopa-ui components
|
|
20
59
|
│ ├── app-sidebar.tsx # Main navigation
|
|
21
60
|
│ ├── data-table.tsx # TanStack Table wrapper
|
|
22
61
|
│ └── chart-*.tsx # Recharts components
|
|
@@ -26,23 +65,25 @@ app/
|
|
|
26
65
|
└── dashboard/ # Sample data and components
|
|
27
66
|
```
|
|
28
67
|
|
|
68
|
+
---
|
|
69
|
+
|
|
29
70
|
## 🎨 Component Patterns
|
|
30
71
|
|
|
31
|
-
### shadcn/ui Components
|
|
32
|
-
All UI components
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- Use `cn()` utility for
|
|
37
|
-
-
|
|
72
|
+
### shadcn/ui & @bluecopa-ui Components
|
|
73
|
+
- All base UI components reside in `app/components/ui/`
|
|
74
|
+
- Most are built atop [Radix UI](https://www.radix-ui.com/) primitives
|
|
75
|
+
- Styled using Tailwind CSS and support theme variables
|
|
76
|
+
- All component imports use the `@bluecopa-ui` registry if you fetch using `npx shadcn@latest add @bluecopa-ui/tooltip`
|
|
77
|
+
- Use the `cn()` utility for conditional styling
|
|
78
|
+
- Fully support dark mode and global CSS variables for design tokens
|
|
38
79
|
|
|
39
80
|
### Custom Components
|
|
40
81
|
- Use TypeScript interfaces for props
|
|
41
|
-
- Follow React best practices
|
|
42
|
-
- Implement
|
|
43
|
-
- Use semantic HTML
|
|
82
|
+
- Follow React best practices: hooks, `React.memo` as appropriate
|
|
83
|
+
- Implement full accessibility (aria attributes, keyboard nav)
|
|
84
|
+
- Use semantic HTML
|
|
44
85
|
|
|
45
|
-
|
|
86
|
+
#### Example Component Structure
|
|
46
87
|
```tsx
|
|
47
88
|
import { cn } from "~/lib/utils"
|
|
48
89
|
|
|
@@ -60,41 +101,49 @@ export function Component({ className, children }: ComponentProps) {
|
|
|
60
101
|
}
|
|
61
102
|
```
|
|
62
103
|
|
|
104
|
+
---
|
|
105
|
+
|
|
63
106
|
## 🔧 Development Patterns
|
|
64
107
|
|
|
65
108
|
### State Management
|
|
66
|
-
-
|
|
67
|
-
- TanStack Query for server state
|
|
68
|
-
-
|
|
69
|
-
- Avoid prop drilling with context
|
|
109
|
+
- Prefer React hooks (`useState`, `useReducer`, `useContext`)
|
|
110
|
+
- Use TanStack Query for server state
|
|
111
|
+
- Avoid prop drilling by using React Context
|
|
70
112
|
|
|
71
113
|
### Data Fetching
|
|
72
|
-
- Use `@bluecopa/react` hooks for API
|
|
73
|
-
- Implement loading and error states
|
|
74
|
-
-
|
|
75
|
-
-
|
|
114
|
+
- Use `@bluecopa/react` hooks for all API access
|
|
115
|
+
- Implement loading and error states at the component level
|
|
116
|
+
- Leverage TanStack Query caching and invalidation
|
|
117
|
+
- Support optimistic UI for updating server state where possible
|
|
118
|
+
|
|
119
|
+
---
|
|
76
120
|
|
|
77
121
|
# @bluecopa/react [](https://www.npmjs.com/package/@bluecopa/react) [](https://github.com/bluecopa/blui/blob/main/packages/react/LICENSE)
|
|
78
122
|
|
|
79
|
-
## A Comprehensive React Query Integration for
|
|
123
|
+
## A Comprehensive React Query Integration for BlueCopa
|
|
80
124
|
|
|
81
|
-
A React library providing opinionated custom hooks for TanStack React Query integration with
|
|
125
|
+
A React library providing opinionated custom hooks for TanStack React Query integration with BlueCopa core API. This package enables efficient data fetching, caching, and synchronization with the BlueCopa platform while maintaining type safety and developer experience.
|
|
126
|
+
|
|
127
|
+
---
|
|
82
128
|
|
|
83
129
|
## Table of Contents
|
|
84
130
|
|
|
85
131
|
- [AI Agent Guide for BlueCopa React shadcn/ui Template](#ai-agent-guide-for-bluecopa-react-shadcnui-template)
|
|
86
132
|
- [🏗️ Project Architecture Overview](#️-project-architecture-overview)
|
|
87
133
|
- [Core Stack](#core-stack)
|
|
134
|
+
- [💡 UI Components \& @bluecopa-ui Registry](#-ui-components--bluecopa-ui-registry)
|
|
135
|
+
- [About the `@bluecopa-ui` Registry](#about-the-bluecopa-ui-registry)
|
|
136
|
+
- [Benefits](#benefits)
|
|
88
137
|
- [Key Directories](#key-directories)
|
|
89
138
|
- [🎨 Component Patterns](#-component-patterns)
|
|
90
|
-
- [shadcn/ui Components](#shadcnui-components)
|
|
139
|
+
- [shadcn/ui \& @bluecopa-ui Components](#shadcnui--bluecopa-ui-components)
|
|
91
140
|
- [Custom Components](#custom-components)
|
|
92
|
-
|
|
141
|
+
- [Example Component Structure](#example-component-structure)
|
|
93
142
|
- [🔧 Development Patterns](#-development-patterns)
|
|
94
143
|
- [State Management](#state-management)
|
|
95
144
|
- [Data Fetching](#data-fetching)
|
|
96
145
|
- [@bluecopa/react ](#bluecopareact--)
|
|
97
|
-
- [A Comprehensive React Query Integration for
|
|
146
|
+
- [A Comprehensive React Query Integration for BlueCopa](#a-comprehensive-react-query-integration-for-bluecopa)
|
|
98
147
|
- [Table of Contents](#table-of-contents)
|
|
99
148
|
- [Features](#features)
|
|
100
149
|
- [Installation](#installation)
|
|
@@ -102,11 +151,11 @@ A React library providing opinionated custom hooks for TanStack React Query inte
|
|
|
102
151
|
- [Usage](#usage)
|
|
103
152
|
- [Query Provider Setup](#query-provider-setup)
|
|
104
153
|
- [Boilerplate Integration](#boilerplate-integration)
|
|
154
|
+
- [Adding a BlueCopa UI Component](#adding-a-bluecopa-ui-component)
|
|
105
155
|
- [Hook Examples](#hook-examples)
|
|
106
156
|
- [`useUser` - Fetch authenticated user](#useuser---fetch-authenticated-user)
|
|
107
157
|
- [`useDataset` - Fetch dataset with query controls](#usedataset---fetch-dataset-with-query-controls)
|
|
108
|
-
- [
|
|
109
|
-
- [`useUser(options?)`](#useuseroptions)
|
|
158
|
+
- [... *(rest of guide unchanged)*](#-rest-of-guide-unchanged)
|
|
110
159
|
- [`useDataset(datasetId, options?)`](#usedatasetdatasetid-options)
|
|
111
160
|
- [`useDatasetSample(datasetId, options?)`](#usedatasetsampledatasetid-options)
|
|
112
161
|
- [`useMetric(metricId, options?)`](#usemetricmetricid-options)
|
|
@@ -177,6 +226,9 @@ A React library providing opinionated custom hooks for TanStack React Query inte
|
|
|
177
226
|
- 📦 Re-exports of core TanStack React Query utilities
|
|
178
227
|
- 📊 Sample data preview capabilities
|
|
179
228
|
- 🧩 Customizable query parameters (limit, caching, retries)
|
|
229
|
+
- 🪄 Quickly use shadcn/ui and BlueCopa-specific components via `@bluecopa-ui` registry
|
|
230
|
+
|
|
231
|
+
---
|
|
180
232
|
|
|
181
233
|
## Installation
|
|
182
234
|
|
|
@@ -186,14 +238,24 @@ npm install @bluecopa/react
|
|
|
186
238
|
pnpm add @bluecopa/react
|
|
187
239
|
```
|
|
188
240
|
|
|
241
|
+
**To enable shadcn/ui with BlueCopa custom components (from @bluecopa-ui registry):**
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npx shadcn@latest add @bluecopa-ui/<component>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This will fetch the component from the "@bluecopa-ui" registry endpoint declared in your `components.json`. This means you automatically get the most up-to-date BlueCopa patterns and design system building blocks.
|
|
248
|
+
|
|
189
249
|
### Peer Dependencies
|
|
190
250
|
|
|
191
|
-
|
|
251
|
+
Install required peer dependencies:
|
|
192
252
|
|
|
193
253
|
```bash
|
|
194
254
|
npm install react@^18.0.0 react-dom@^18.0.0
|
|
195
255
|
```
|
|
196
256
|
|
|
257
|
+
---
|
|
258
|
+
|
|
197
259
|
## Usage
|
|
198
260
|
|
|
199
261
|
### Query Provider Setup
|
|
@@ -224,7 +286,7 @@ function App() {
|
|
|
224
286
|
|
|
225
287
|
### Boilerplate Integration
|
|
226
288
|
|
|
227
|
-
For projects using the
|
|
289
|
+
For projects using the BlueCopa React boilerplate, use the pre-configured `QueryProvider` component that handles API configuration automatically and integrates all BlueCopa registry UI imports:
|
|
228
290
|
|
|
229
291
|
```tsx
|
|
230
292
|
// src/providers/query-provider.tsx
|
|
@@ -275,7 +337,7 @@ export default function QueryProvider({ children }: { children: React.ReactNode
|
|
|
275
337
|
|
|
276
338
|
| Variable | Description | Example |
|
|
277
339
|
|----------|-------------|---------|
|
|
278
|
-
| `VITE_BLUECOPA_API_URL` | Base URL for
|
|
340
|
+
| `VITE_BLUECOPA_API_URL` | Base URL for BlueCopa API | `https://develop.bluecopa.com` |
|
|
279
341
|
| `VITE_BLUECOPA_WORKSPACE_ID` | Your workspace identifier | `my-workspace-123` |
|
|
280
342
|
| `VITE_BLUECOPA_API_TOKEN` | Base64-encoded JSON string containing `accessToken` | `eyJhY2Nlc3NUb2tlbiI6IjEyMzQ1In0=` |
|
|
281
343
|
|
|
@@ -300,7 +362,21 @@ function App() {
|
|
|
300
362
|
}
|
|
301
363
|
```
|
|
302
364
|
|
|
303
|
-
This setup automatically configures the API client
|
|
365
|
+
This setup automatically configures both the BlueCopa API client and enables seamless usage of BlueCopa UI primitives pulled from the custom registry.
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
### Adding a BlueCopa UI Component
|
|
370
|
+
|
|
371
|
+
To add a BlueCopa custom UI primitive (e.g., "copa-card") to your project, use:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
npx shadcn@latest add @bluecopa-ui/pagination-block
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
The CLI pulls the latest [copa-card](https://shadcn-ui-henna.vercel.app/r/copa-card.json) definition from the registry as specified in `components.json`, and installs it to `app/components/ui/`.
|
|
378
|
+
|
|
379
|
+
---
|
|
304
380
|
|
|
305
381
|
### Hook Examples
|
|
306
382
|
|
|
@@ -338,14 +414,12 @@ function DatasetViewer({ datasetId }) {
|
|
|
338
414
|
}
|
|
339
415
|
```
|
|
340
416
|
|
|
341
|
-
|
|
417
|
+
---
|
|
342
418
|
|
|
343
|
-
|
|
419
|
+
## ... *(rest of guide unchanged)*
|
|
344
420
|
|
|
345
|
-
|
|
421
|
+
The rest of this guide covers all @bluecopa/react data hooks, configuration, testing, and best practices as before. For adding or updating UI primitives, always prefer `@bluecopa-ui` registry where available to match BlueCopa's latest design system and component standards.
|
|
346
422
|
|
|
347
|
-
**Parameters:**
|
|
348
|
-
- `options` (optional): Query options extending TanStack React Query's `UseQueryOptions`
|
|
349
423
|
|
|
350
424
|
**Returns:**
|
|
351
425
|
- `data`: User object or `undefined`
|