@smallwebco/tinypivot-react 1.0.53 → 1.0.54

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 CHANGED
@@ -1,9 +1,16 @@
1
1
  # @smallwebco/tinypivot-react
2
2
 
3
- A powerful Excel-like data grid and pivot table component for React.
3
+ A lightweight, AI-ready data grid with pivot tables and charts for React. **Under 40KB gzipped** — 10x smaller than AG Grid.
4
4
 
5
5
  **[Live Demo](https://tiny-pivot.com)** · **[Buy License](https://tiny-pivot.com/#pricing)**
6
6
 
7
+ ## Why TinyPivot?
8
+
9
+ - **Lightweight**: Under 40KB gzipped vs 500KB+ for AG Grid
10
+ - **AI-Ready**: Natural language data exploration with your own API key (BYOK)
11
+ - **Batteries Included**: Pivot tables, charts, and Excel-like features out of the box
12
+ - **One-Time License**: No subscriptions — pay once, use forever
13
+
7
14
  ## Installation
8
15
 
9
16
  ```bash
@@ -49,6 +56,8 @@ export default function App() {
49
56
  | Column resizing | ✅ | ✅ |
50
57
  | Clipboard (Ctrl+C) | ✅ | ✅ |
51
58
  | Dark mode | ✅ | ✅ |
59
+ | **AI Data Analyst** (natural language, BYOK) | ❌ | ✅ |
60
+ | **Chart Builder** (6 chart types) | ❌ | ✅ |
52
61
  | Pivot table | ❌ | ✅ |
53
62
  | Aggregations (Sum, Avg, etc.) | ❌ | ✅ |
54
63
  | Row/column totals | ❌ | ✅ |
@@ -79,6 +88,87 @@ export default function App() {
79
88
  | `onExport` | `(payload) => void` | CSV exported |
80
89
  | `onCopy` | `(payload) => void` | Cells copied |
81
90
 
91
+ ## AI Data Analyst (Pro)
92
+
93
+ Enable natural language data exploration with your own AI API key (BYOK).
94
+
95
+ ```tsx
96
+ import { DataGrid } from '@smallwebco/tinypivot-react'
97
+ import '@smallwebco/tinypivot-react/style.css'
98
+
99
+ const data = [/* your data */]
100
+
101
+ const aiConfig = {
102
+ enabled: true,
103
+ aiEndpoint: '/api/ai-proxy', // Your AI proxy endpoint
104
+ databaseEndpoint: '/api/tp-database', // Optional: auto-discover tables
105
+ aiModelName: 'Claude Sonnet 4', // Optional: display in UI
106
+ persistToLocalStorage: true, // Preserve conversation on tab switch
107
+ }
108
+
109
+ export default function App() {
110
+ return (
111
+ <DataGrid
112
+ data={data}
113
+ aiAnalyst={aiConfig}
114
+ />
115
+ )
116
+ }
117
+ ```
118
+
119
+ ### AI Analyst Config Options
120
+
121
+ | Option | Type | Description |
122
+ |--------|------|-------------|
123
+ | `enabled` | `boolean` | Enable the AI Analyst tab |
124
+ | `aiEndpoint` | `string` | Your AI proxy endpoint (keeps API keys secure) |
125
+ | `databaseEndpoint` | `string` | Unified endpoint for table discovery and queries |
126
+ | `dataSources` | `AIDataSource[]` | Manual list of available tables |
127
+ | `queryExecutor` | `function` | Custom query executor (e.g., client-side DuckDB) |
128
+ | `aiModelName` | `string` | Display name for the AI model in UI |
129
+ | `persistToLocalStorage` | `boolean` | Persist conversation across tab switches |
130
+ | `sessionId` | `string` | Unique session ID for conversation isolation |
131
+ | `maxRows` | `number` | Max rows to return (default: 10000) |
132
+ | `demoMode` | `boolean` | Use canned responses (no real AI calls) |
133
+
134
+ ### AI Analyst Callbacks
135
+
136
+ | Prop | Type | Description |
137
+ |------|------|-------------|
138
+ | `onAIDataLoaded` | `(payload) => void` | Query results loaded |
139
+ | `onAIConversationUpdate` | `(payload) => void` | Conversation state changed |
140
+ | `onAIQueryExecuted` | `(payload) => void` | SQL query executed |
141
+ | `onAIError` | `(payload) => void` | Error occurred |
142
+
143
+ ### State Preservation
144
+
145
+ The AI Analyst preserves state when switching between tabs (Grid, Pivot, Chart, AI):
146
+
147
+ - **Conversation history** is maintained in memory
148
+ - **Query results** are preserved
149
+ - **SQL queries** remain accessible via the SQL panel
150
+
151
+ To persist across page refreshes, enable `persistToLocalStorage: true`. The conversation will be saved to localStorage using the `sessionId` as the key.
152
+
153
+ For production apps, use `onAIConversationUpdate` to implement your own persistence:
154
+
155
+ ```tsx
156
+ function App() {
157
+ const saveConversation = ({ conversation }) => {
158
+ // Save to your backend
159
+ api.saveConversation(userId, conversation)
160
+ }
161
+
162
+ return (
163
+ <DataGrid
164
+ data={data}
165
+ aiAnalyst={aiConfig}
166
+ onAIConversationUpdate={saveConversation}
167
+ />
168
+ )
169
+ }
170
+ ```
171
+
82
172
  ## Documentation
83
173
 
84
174
  See the [full documentation](https://github.com/Small-Web-Co/tinypivot) for complete API reference, styling, and Pro license activation.