serverside_pivot 0.0.91 → 0.0.95

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 (166) hide show
  1. package/README.md +182 -182
  2. package/dist/react/chunks/{ContextMenu-Bt5_3bmD.mjs → ContextMenu-1G-o1ms9.mjs} +52 -49
  3. package/dist/react/chunks/{DetailDrawer-Eb4EpVHG.mjs → DetailDrawer-DCKIxSpW.mjs} +1 -1
  4. package/dist/react/chunks/{DetailSidePanel-BTcHOiKr.mjs → DetailSidePanel-DgUWPBQk.mjs} +1 -1
  5. package/dist/react/chunks/{DetailSurfaceContent-B3ZNKh7q.mjs → DetailSurfaceContent-BEL6xuaZ.mjs} +46 -37
  6. package/dist/react/chunks/{ECharts2dRenderer-C3Qv0uAa.mjs → ECharts2dRenderer-Dgkp9_1P.mjs} +412 -410
  7. package/dist/react/chunks/{ECharts3dRenderer-BB_7-fOt.mjs → ECharts3dRenderer-70VOp8V0.mjs} +2211 -3197
  8. package/dist/react/chunks/{EditSidePanel-C2cAvxlK.mjs → EditSidePanel-CygqVXLX.mjs} +77 -65
  9. package/dist/react/chunks/{InlineDetailPanel-BXLAw1o3.mjs → InlineDetailPanel-BUBRWdFW.mjs} +1 -1
  10. package/dist/react/chunks/{PivotCharts-Bw6Swoa3.mjs → PivotCharts-VX5-mEEp.mjs} +2206 -1396
  11. package/dist/react/chunks/{ReportEditor-D4V0ry2B.mjs → ReportEditor-B5j-CU9-.mjs} +614 -319
  12. package/dist/react/chunks/{SidebarPanel-xO59p_2o.mjs → SidebarPanel-LXUE6nPd.mjs} +1793 -1390
  13. package/dist/react/chunks/{SparklineDetailGraph-Bu85X7OJ.mjs → SparklineDetailGraph-Cfe2KcOp.mjs} +88 -58
  14. package/dist/react/chunks/installCanvasRenderer-C4h5pc1p.mjs +21174 -0
  15. package/dist/react/chunks/react-CDa-ADnG.mjs +31199 -0
  16. package/dist/react/chunks/{xlsx.mini.min-vfxHk3Ry.mjs → xlsx.mini.min-CzdkdH3N.mjs} +5 -5
  17. package/dist/react/components/Charts/ChartRenderers.d.ts +5 -73
  18. package/dist/react/components/Charts/ChartWorkspace.d.ts +3 -34
  19. package/dist/react/components/Charts/ECharts2dRenderer.d.ts +2 -5
  20. package/dist/react/components/Charts/ECharts3dRenderer.d.ts +2 -6
  21. package/dist/react/components/Charts/PivotCharts.d.ts +2 -9
  22. package/dist/react/components/Charts/chartEnhancements.d.ts +17 -66
  23. package/dist/react/components/Charts/chartExportPresentation.d.ts +5 -19
  24. package/dist/react/components/Charts/chartMath.d.ts +4 -4
  25. package/dist/react/components/Charts/useChartExportMenu.d.ts +4 -12
  26. package/dist/react/components/DashTanstackPivot.react.d.ts +36 -0
  27. package/dist/react/components/Filters/ColumnFilter.d.ts +2 -12
  28. package/dist/react/components/Filters/DateRangeFilter.d.ts +2 -7
  29. package/dist/react/components/Filters/FilterPopover.d.ts +2 -13
  30. package/dist/react/components/Filters/MultiSelectFilter.d.ts +2 -11
  31. package/dist/react/components/Filters/NumericRangeFilter.d.ts +2 -7
  32. package/dist/react/components/Notification.d.ts +2 -6
  33. package/dist/react/components/PivotAppBar.d.ts +2 -2
  34. package/dist/react/components/PivotErrorBoundary.d.ts +11 -7
  35. package/dist/react/components/PivotSmallComponents.d.ts +2 -3
  36. package/dist/react/components/PivotWorkspaceCanvas.d.ts +2 -5
  37. package/dist/react/components/PivotWorkspaceControls.d.ts +4 -8
  38. package/dist/react/components/PivotWorkspaceShell.d.ts +4 -12
  39. package/dist/react/components/RuntimeDataError.d.ts +2 -7
  40. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +2 -13
  41. package/dist/react/components/Sidebar/ReportEditor.d.ts +7 -20
  42. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +2 -13
  43. package/dist/react/components/Sidebar/SidebarPanel.d.ts +1 -2
  44. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +2 -13
  45. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +31 -62
  46. package/dist/react/components/Sidebar/formulaUtils.d.ts +16 -18
  47. package/dist/react/components/SkeletonRow.d.ts +2 -5
  48. package/dist/react/components/Table/ContextMenu.d.ts +2 -8
  49. package/dist/react/components/Table/DetailDrawer.d.ts +2 -11
  50. package/dist/react/components/Table/DetailSidePanel.d.ts +2 -11
  51. package/dist/react/components/Table/DetailSurfaceContent.d.ts +2 -11
  52. package/dist/react/components/Table/EditSidePanel.d.ts +2 -20
  53. package/dist/react/components/Table/EditableCell.d.ts +2 -28
  54. package/dist/react/components/Table/InlineDetailPanel.d.ts +2 -13
  55. package/dist/react/components/Table/PivotTableBody.d.ts +3 -3
  56. package/dist/react/components/Table/SparklineCell.d.ts +2 -17
  57. package/dist/react/components/Table/SparklineDetailGraph.d.ts +2 -5
  58. package/dist/react/components/Table/StatusBar.d.ts +2 -7
  59. package/dist/react/contexts/PivotConfigContext.d.ts +5 -33
  60. package/dist/react/contexts/PivotThemeContext.d.ts +7 -4
  61. package/dist/react/contexts/PivotValueDisplayContext.d.ts +5 -9
  62. package/dist/react/hooks/useChartState.d.ts +2 -71
  63. package/dist/react/hooks/useColumnDefs.d.ts +3 -68
  64. package/dist/react/hooks/useColumnVirtualizer.d.ts +1 -30
  65. package/dist/react/hooks/useDetailDrillThrough.d.ts +2 -36
  66. package/dist/react/hooks/useFilteredData.d.ts +4 -2
  67. package/dist/react/hooks/useFormatState.d.ts +2 -39
  68. package/dist/react/hooks/usePersistence.d.ts +4 -5
  69. package/dist/react/hooks/usePivotFieldInteractions.d.ts +2 -23
  70. package/dist/react/hooks/usePivotNormalization.d.ts +127 -461
  71. package/dist/react/hooks/usePivotRenderCounter.d.ts +2 -1
  72. package/dist/react/hooks/usePivotTransactions.d.ts +2 -23
  73. package/dist/react/hooks/useRenderHelpers.d.ts +3 -71
  74. package/dist/react/hooks/useReportMode.d.ts +2 -28
  75. package/dist/react/hooks/useRowCache.d.ts +16 -15
  76. package/dist/react/hooks/useRuntimeDataCommit.d.ts +2 -22
  77. package/dist/react/hooks/useRuntimeProfiling.d.ts +2 -13
  78. package/dist/react/hooks/useRuntimeTransport.d.ts +2 -18
  79. package/dist/react/hooks/useServerSideRowModel.d.ts +1 -50
  80. package/dist/react/hooks/useServerSideViewportController.d.ts +1 -64
  81. package/dist/react/hooks/useSidebarUI.d.ts +2 -32
  82. package/dist/react/hooks/useStickyStyles.d.ts +2 -23
  83. package/dist/react/index.mjs +15 -9
  84. package/dist/react/presentation/headerFormatting.d.ts +28 -11
  85. package/dist/react/presentation/safeCellContent.d.ts +22 -5
  86. package/dist/react/react.d.ts +3 -0
  87. package/dist/react/runtime/PivotRuntimeRoot.d.ts +1 -1
  88. package/dist/react/runtime/client/clientPivotTransport.d.ts +5 -1
  89. package/dist/react/runtime/client/clientResponsePostProcessor.d.ts +50 -0
  90. package/dist/react/runtime/client/types.d.ts +5 -0
  91. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +2 -7
  92. package/dist/react/runtime/createRuntimeExportCommands.d.ts +2 -71
  93. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +2 -9
  94. package/dist/react/runtime/displayColumnOrder.d.ts +4 -4
  95. package/dist/react/runtime/httpTransport.d.ts +1 -0
  96. package/dist/react/runtime/runtime-contract.generated.d.ts +3 -0
  97. package/dist/react/runtime/runtimeContract.d.ts +3 -0
  98. package/dist/react/runtime/runtimeDomains.d.ts +18 -0
  99. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +2 -45
  100. package/dist/react/runtime/useCoreRuntime.d.ts +4 -1
  101. package/dist/react/runtime/useCoreRuntimeStage.d.ts +1 -1
  102. package/dist/react/runtime/useRuntimeCellSelection.d.ts +2 -40
  103. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +7 -31
  104. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +2 -13
  105. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +2 -9
  106. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +2 -14
  107. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +2 -28
  108. package/dist/react/runtime/useRuntimeChartModels.d.ts +2 -62
  109. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +2 -12
  110. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +2 -4
  111. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +2 -152
  112. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +2 -7
  113. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +2 -55
  114. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +2 -26
  115. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +2 -22
  116. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +2 -11
  117. package/dist/react/runtime/useRuntimeDataRetry.d.ts +2 -12
  118. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +2 -11
  119. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +2 -18
  120. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +2 -28
  121. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +2 -35
  122. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +2 -43
  123. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +2 -28
  124. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +2 -32
  125. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +2 -24
  126. package/dist/react/runtime/useRuntimeExportState.d.ts +5 -5
  127. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +2 -19
  128. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +2 -40
  129. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +2 -27
  130. package/dist/react/runtime/useRuntimeRequestSession.d.ts +2 -76
  131. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +2 -43
  132. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +2 -15
  133. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +2 -28
  134. package/dist/react/runtime/useRuntimeRowEditing.d.ts +2 -18
  135. package/dist/react/runtime/useRuntimeRowSelection.d.ts +2 -14
  136. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +2 -30
  137. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +2 -61
  138. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +2 -5
  139. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +2 -196
  140. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +2 -23
  141. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +2 -109
  142. package/dist/react/utils/Icons.d.ts +2 -45
  143. package/dist/react/utils/chartModelBuilders.d.ts +76 -230
  144. package/dist/react/utils/columnOrder.d.ts +8 -12
  145. package/dist/react/utils/dataBars.d.ts +3 -7
  146. package/dist/react/utils/domEvents.d.ts +1 -1
  147. package/dist/react/utils/editing.d.ts +12 -47
  148. package/dist/react/utils/exportUtils.d.ts +30 -101
  149. package/dist/react/utils/fieldPanelLayout.d.ts +12 -61
  150. package/dist/react/utils/filterOptions.d.ts +4 -4
  151. package/dist/react/utils/helpers.d.ts +16 -18
  152. package/dist/react/utils/horizontalViewport.d.ts +1 -12
  153. package/dist/react/utils/layoutRows.d.ts +3 -3
  154. package/dist/react/utils/measureAxis.d.ts +6 -22
  155. package/dist/react/utils/pivotLayoutUtils.d.ts +3 -2
  156. package/dist/react/utils/pivotProfiler.d.ts +3 -3
  157. package/dist/react/utils/reportEditorSelection.d.ts +1 -23
  158. package/dist/react/utils/rowSpanning.d.ts +3 -6
  159. package/dist/react/utils/savedReports.d.ts +4 -7
  160. package/dist/react/utils/sorting.d.ts +8 -14
  161. package/dist/react/utils/sparklineDetail.d.ts +5 -8
  162. package/dist/react/utils/sparklines.d.ts +10 -78
  163. package/dist/react/utils/styles.d.ts +19 -308
  164. package/package.json +114 -114
  165. package/dist/react/chunks/installCanvasRenderer-B7sfDGoL.mjs +0 -21281
  166. package/dist/react/chunks/react-CPZZxtSo.mjs +0 -26999
package/README.md CHANGED
@@ -1,182 +1,182 @@
1
- # ⚡ serverside_pivot
2
-
3
- ### **Turnkey Analytical Pivot Table & Virtualized Data Grid for React**
4
- #### *Dual-Engine Architecture: Zero-Network In-Browser Analytics (DuckDB-WASM & In-Memory) + Scalable Server-Side Pushdown.*
5
-
6
- [![npm version](https://img.shields.io/npm/v/serverside_pivot.svg?color=cb3837)](https://www.npmjs.com/package/serverside_pivot)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue)](https://www.typescriptlang.org/)
9
- [![React](https://img.shields.io/badge/React-18%20%7C%2019-61dafb)](https://react.dev/)
10
- [![DuckDB-WASM](https://img.shields.io/badge/Engine-DuckDB--WASM%20%7C%20In--Memory-yellow)](https://duckdb.org/docs/api/wasm/overview)
11
- [![ECharts](https://img.shields.io/badge/Charts-ECharts%206%20%2B%20GL%203D-red)](https://echarts.apache.org/)
12
-
13
- `serverside_pivot` is an enterprise-grade, low-code analytical pivot table and 2D virtualized grid for **React**. Built on **TanStack Table v8**, **DuckDB-WASM**, and **Apache ECharts 6**, it bridges the gap between lightweight client tables and heavy server-side BI tools.
14
-
15
- ---
16
-
17
- ## 🚀 Why `serverside_pivot`?
18
-
19
- Unlike traditional grid components that either crash browser memory with large datasets or force you to spend months building custom SQL backends:
20
-
21
- 1. **Dual Execution Engine (Hybrid)**:
22
- - **Client-Side Mode (`DuckDB-WASM` & In-Memory)**: Run complete multi-dimensional pivots, $\mathcal{O}(D)$ level-based hierarchy expansions, multi-column sorting, Excel formulas, window functions, and ECharts visualizations **100% inside the browser with ZERO server roundtrips and zero latency**.
23
- - **Server-Side Pushdown Mode**: Connect seamlessly to Python backend services (`serverside-pivot`) backed by **Snowflake, BigQuery, PostgreSQL, ClickHouse, MotherDuck, or DuckDB** to query hundreds of millions of rows with bounded 50-row virtual slices.
24
- 2. **2D Virtualization (Row + Column)**: Smoothly virtualizes both vertical rows (millions of records) and horizontal pivoted columns (1,000+ columns) with a **constant < 80 MB client RAM footprint**.
25
- 3. **Turnkey BI Analytics**: Built-in 23+ chart families (ECharts 2D/3D), inline cell sparklines, heatmaps, Excel-like calculated formulas (`[revenue] - [cost]`), window functions (`percent_of_grand_total`), 11 enterprise themes, and client-side SheetJS XLSX/CSV export.
26
-
27
- ---
28
-
29
- ## 📦 Installation
30
-
31
- ```bash
32
- npm install serverside_pivot
33
- # or
34
- yarn add serverside_pivot
35
- # or
36
- pnpm add serverside_pivot
37
- ```
38
-
39
- ### Peer Dependencies
40
- ```bash
41
- npm install react react-dom styled-components
42
- ```
43
-
44
- ---
45
-
46
- ## ⚡ Quickstart
47
-
48
- ### 1. Zero-Backend Client-Side Pivot (DuckDB-WASM / In-Memory)
49
-
50
- Feed your JSON records or CSV/Parquet data directly into `PivotWorkspace`. The internal `ClientPivotTransport` executes all groupings, multi-column aggregations, and expansions in browser WebAssembly:
51
-
52
- ```tsx
53
- import React from 'react';
54
- import { PivotWorkspace, ClientPivotTransport } from 'serverside_pivot/react';
55
-
56
- const salesData = [
57
- { region: 'North America', country: 'USA', rep: 'Alice', year: '2024', revenue: 150000, cost: 95000 },
58
- { region: 'North America', country: 'USA', rep: 'Bob', year: '2025', revenue: 180000, cost: 110000 },
59
- { region: 'North America', country: 'Canada', rep: 'Charlie', year: '2024', revenue: 90000, cost: 60000 },
60
- { region: 'Europe', country: 'Germany', rep: 'David', year: '2024', revenue: 130000, cost: 85000 },
61
- { region: 'Europe', country: 'France', rep: 'Emma', year: '2025', revenue: 140000, cost: 90000 },
62
- // ... up to 50,000+ rows
63
- ];
64
-
65
- // Initialize client transport (runs 100% in-browser)
66
- const clientTransport = new ClientPivotTransport({
67
- tableName: 'sales',
68
- data: salesData,
69
- clientEngine: 'auto', // 'auto' (>= 1000 rows activates DuckDB-Wasm), 'duckdb-wasm', or 'memory'
70
- });
71
-
72
- export function App() {
73
- return (
74
- <div style={{ height: '800px', width: '100%' }}>
75
- <PivotWorkspace
76
- table="sales"
77
- transport={clientTransport}
78
- rowFields={['region', 'country', 'rep']}
79
- colFields={['year']}
80
- valConfigs={[
81
- { field: 'revenue', agg: 'sum', format: 'currency', label: 'Revenue ($)' },
82
- { field: 'cost', agg: 'sum', format: 'currency', label: 'Cost ($)' },
83
- {
84
- field: 'profit',
85
- label: 'Gross Profit',
86
- formula: '[revenue] - [cost]',
87
- format: 'currency',
88
- },
89
- {
90
- field: 'rev_pct',
91
- label: '% Total Revenue',
92
- agg: 'sum',
93
- windowFn: 'percent_of_grand_total',
94
- format: 'percent',
95
- },
96
- ]}
97
- showRowTotals={true}
98
- showColTotals={true}
99
- defaultTheme="flash" // 'dark' | 'light' | 'bloomberg_black' | 'flash' | 'material' | ...
100
- />
101
- </div>
102
- );
103
- }
104
- ```
105
-
106
- ---
107
-
108
- ### 2. Scalable Server-Side Pushdown Mode
109
-
110
- For datasets with millions or billions of rows, connect to any backend implementing the standard V1 runtime protocol:
111
-
112
- ```tsx
113
- import React from 'react';
114
- import {
115
- PivotWorkspace,
116
- HttpPivotTransport,
117
- LatestViewportScheduler,
118
- } from 'serverside_pivot/react';
119
-
120
- // Wraps HTTP requests with auto-cancellation (latest-viewport-wins)
121
- const transport = new LatestViewportScheduler(
122
- new HttpPivotTransport({
123
- endpoint: '/v1/runtime',
124
- })
125
- );
126
-
127
- export function EnterpriseAnalytics() {
128
- return (
129
- <div style={{ height: '100vh', width: '100%' }}>
130
- <PivotWorkspace
131
- table="warehouse_orders"
132
- transport={transport}
133
- rowFields={['department', 'category', 'product']}
134
- colFields={['quarter']}
135
- valConfigs={[
136
- { field: 'sales_amount', agg: 'sum', format: 'currency' },
137
- { field: 'order_count', agg: 'count' },
138
- ]}
139
- showRowTotals={true}
140
- showColTotals={true}
141
- defaultTheme="dark"
142
- />
143
- </div>
144
- );
145
- }
146
- ```
147
-
148
- ---
149
-
150
- ## ✨ Key Enterprise Capabilities
151
-
152
- | Feature | Description |
153
- | :--- | :--- |
154
- | **Dual Execution Engine** | Seamlessly toggle between 100% in-browser WebAssembly execution (`ClientPivotTransport`) and server-side warehouse pushdown (`HttpPivotTransport`). |
155
- | **2D Virtualization** | Constant < 80 MB browser memory whether scrolling through 10,000 rows or 1,000,000,000+ rows with 1,000+ dynamic pivoted columns. |
156
- | **$\mathcal{O}(D)$ Level-Based Hierarchy** | Multi-level tree group expansions execute one single batched query per hierarchy depth level ($D$) rather than sequential $N$-query waterfalls. |
157
- | **Visual Analytics & Charting** | Integrated **ECharts 6** & **ECharts-GL 3D**: 23+ chart types across 11 families (Bar, Line, Area, Pie, Radar, Scatter, Waterfall, 3D Bar/Surface) linked to live pivot state. |
158
- | **In-Cell Sparklines & Data Bars** | High-performance inline SVG sparklines (Line, Area, Bar) and proportional cell data bars rendered directly inside grid cells with zero DOM bloat. |
159
- | **Excel AST Formulas & Window Functions** | Excel-like calculated measures using `[Field]` syntax and built-in pivot window functions (`percent_of_row`, `percent_of_col`, `percent_of_grand_total`). |
160
- | **4 Layout Modes** | Multidimensional Pivot (`pivot`), Parent-Child Tree (`tree`), Flat Record Grid (`table`), and Financial P&L Report Mode (`report`). |
161
- | **Client SheetJS & Clipboard** | Instant client-side Excel XLSX and CSV streaming export with merged headers and formatting preserved. RFC-compliant HTML/TSV clipboard copy. |
162
- | **11 Enterprise Themes** | Complete theme system: `light`, `dark`, `flash`, `material`, `balham`, `bloomberg`, `bloomberg_black`, `strata`, `crystal`, `alabaster`, `satin` with full `--sp-*` CSS variables. |
163
-
164
- ---
165
-
166
- ## 🌐 Multi-Framework Ecosystem
167
-
168
- `serverside_pivot` is part of the `serverside-pivot` ecosystem:
169
- - **Standalone React**: `serverside_pivot` (this package)
170
- - **Python Plotly Dash**: `pip install serverside-pivot`
171
- - **Streamlit**: `pip install "serverside-pivot[streamlit]"`
172
- - **Backend Pushdown**: Powered by **DuckDB**, **PyArrow**, and **Ibis** (Snowflake, BigQuery, Postgres, ClickHouse, MotherDuck, Databricks, Trino)
173
-
174
- For comprehensive documentation, live Python/Dash showcases, and interactive examples, visit the **[GitHub Repository](https://github.com/Ramzy22/serverside_pivot)**.
175
-
176
- > Cell editing and edit transactions are not a supported public capability in this release. Legacy edit-related Dash inputs are accepted as no-ops only for layout compatibility.
177
-
178
- ---
179
-
180
- ## 📄 License
181
-
182
- Distributed under the **MIT License**.
1
+ # ⚡ serverside_pivot
2
+
3
+ ### **Turnkey Analytical Pivot Table & Virtualized Data Grid for React**
4
+ #### *Dual-Engine Architecture: Zero-Network In-Browser Analytics (DuckDB-WASM & In-Memory) + Scalable Server-Side Pushdown.*
5
+
6
+ [![npm version](https://img.shields.io/npm/v/serverside_pivot.svg?color=cb3837)](https://www.npmjs.com/package/serverside_pivot)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue)](https://www.typescriptlang.org/)
9
+ [![React](https://img.shields.io/badge/React-18%20%7C%2019-61dafb)](https://react.dev/)
10
+ [![DuckDB-WASM](https://img.shields.io/badge/Engine-DuckDB--WASM%20%7C%20In--Memory-yellow)](https://duckdb.org/docs/api/wasm/overview)
11
+ [![ECharts](https://img.shields.io/badge/Charts-ECharts%206%20%2B%20GL%203D-red)](https://echarts.apache.org/)
12
+
13
+ `serverside_pivot` is an enterprise-grade, low-code analytical pivot table and 2D virtualized grid for **React**. Built on **TanStack Table v8**, **DuckDB-WASM**, and **Apache ECharts 6**, it bridges the gap between lightweight client tables and heavy server-side BI tools.
14
+
15
+ ---
16
+
17
+ ## 🚀 Why `serverside_pivot`?
18
+
19
+ Unlike traditional grid components that either crash browser memory with large datasets or force you to spend months building custom SQL backends:
20
+
21
+ 1. **Dual Execution Engine (Hybrid)**:
22
+ - **Client-Side Mode (`DuckDB-WASM` & In-Memory)**: Run complete multi-dimensional pivots, $\mathcal{O}(D)$ level-based hierarchy expansions, multi-column sorting, Excel formulas, window functions, and ECharts visualizations **100% inside the browser with ZERO server roundtrips and zero latency**.
23
+ - **Server-Side Pushdown Mode**: Connect seamlessly to Python backend services (`serverside-pivot`) backed by **Snowflake, BigQuery, PostgreSQL, ClickHouse, MotherDuck, or DuckDB** to query hundreds of millions of rows with bounded 50-row virtual slices.
24
+ 2. **2D Virtualization (Row + Column)**: Smoothly virtualizes both vertical rows (millions of records) and horizontal pivoted columns (1,000+ columns) with a **constant < 80 MB client RAM footprint**.
25
+ 3. **Turnkey BI Analytics**: Built-in 23+ chart families (ECharts 2D/3D), inline cell sparklines, heatmaps, Excel-like calculated formulas (`[revenue] - [cost]`), window functions (`percent_of_grand_total`), 11 enterprise themes, and client-side SheetJS XLSX/CSV export.
26
+
27
+ ---
28
+
29
+ ## 📦 Installation
30
+
31
+ ```bash
32
+ npm install serverside_pivot
33
+ # or
34
+ yarn add serverside_pivot
35
+ # or
36
+ pnpm add serverside_pivot
37
+ ```
38
+
39
+ ### Peer Dependencies
40
+ ```bash
41
+ npm install react react-dom styled-components
42
+ ```
43
+
44
+ ---
45
+
46
+ ## ⚡ Quickstart
47
+
48
+ ### 1. Zero-Backend Client-Side Pivot (DuckDB-WASM / In-Memory)
49
+
50
+ Feed your JSON records or CSV/Parquet data directly into `PivotWorkspace`. The internal `ClientPivotTransport` executes all groupings, multi-column aggregations, and expansions in browser WebAssembly:
51
+
52
+ ```tsx
53
+ import React from 'react';
54
+ import { PivotWorkspace, ClientPivotTransport } from 'serverside_pivot/react';
55
+
56
+ const salesData = [
57
+ { region: 'North America', country: 'USA', rep: 'Alice', year: '2024', revenue: 150000, cost: 95000 },
58
+ { region: 'North America', country: 'USA', rep: 'Bob', year: '2025', revenue: 180000, cost: 110000 },
59
+ { region: 'North America', country: 'Canada', rep: 'Charlie', year: '2024', revenue: 90000, cost: 60000 },
60
+ { region: 'Europe', country: 'Germany', rep: 'David', year: '2024', revenue: 130000, cost: 85000 },
61
+ { region: 'Europe', country: 'France', rep: 'Emma', year: '2025', revenue: 140000, cost: 90000 },
62
+ // ... up to 50,000+ rows
63
+ ];
64
+
65
+ // Initialize client transport (runs 100% in-browser)
66
+ const clientTransport = new ClientPivotTransport({
67
+ tableName: 'sales',
68
+ data: salesData,
69
+ clientEngine: 'auto', // 'auto' (>= 1000 rows activates DuckDB-Wasm), 'duckdb-wasm', or 'memory'
70
+ });
71
+
72
+ export function App() {
73
+ return (
74
+ <div style={{ height: '800px', width: '100%' }}>
75
+ <PivotWorkspace
76
+ table="sales"
77
+ transport={clientTransport}
78
+ rowFields={['region', 'country', 'rep']}
79
+ colFields={['year']}
80
+ valConfigs={[
81
+ { field: 'revenue', agg: 'sum', format: 'currency', label: 'Revenue ($)' },
82
+ { field: 'cost', agg: 'sum', format: 'currency', label: 'Cost ($)' },
83
+ {
84
+ field: 'profit',
85
+ label: 'Gross Profit',
86
+ formula: '[revenue] - [cost]',
87
+ format: 'currency',
88
+ },
89
+ {
90
+ field: 'rev_pct',
91
+ label: '% Total Revenue',
92
+ agg: 'sum',
93
+ windowFn: 'percent_of_grand_total',
94
+ format: 'percent',
95
+ },
96
+ ]}
97
+ showRowTotals={true}
98
+ showColTotals={true}
99
+ defaultTheme="flash" // 'dark' | 'light' | 'bloomberg_black' | 'flash' | 'material' | ...
100
+ />
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ---
107
+
108
+ ### 2. Scalable Server-Side Pushdown Mode
109
+
110
+ For datasets with millions or billions of rows, connect to any backend implementing the standard V1 runtime protocol:
111
+
112
+ ```tsx
113
+ import React from 'react';
114
+ import {
115
+ PivotWorkspace,
116
+ HttpPivotTransport,
117
+ LatestViewportScheduler,
118
+ } from 'serverside_pivot/react';
119
+
120
+ // Wraps HTTP requests with auto-cancellation (latest-viewport-wins)
121
+ const transport = new LatestViewportScheduler(
122
+ new HttpPivotTransport({
123
+ endpoint: '/v1/runtime',
124
+ })
125
+ );
126
+
127
+ export function EnterpriseAnalytics() {
128
+ return (
129
+ <div style={{ height: '100vh', width: '100%' }}>
130
+ <PivotWorkspace
131
+ table="warehouse_orders"
132
+ transport={transport}
133
+ rowFields={['department', 'category', 'product']}
134
+ colFields={['quarter']}
135
+ valConfigs={[
136
+ { field: 'sales_amount', agg: 'sum', format: 'currency' },
137
+ { field: 'order_count', agg: 'count' },
138
+ ]}
139
+ showRowTotals={true}
140
+ showColTotals={true}
141
+ defaultTheme="dark"
142
+ />
143
+ </div>
144
+ );
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## ✨ Key Enterprise Capabilities
151
+
152
+ | Feature | Description |
153
+ | :--- | :--- |
154
+ | **Dual Execution Engine** | Seamlessly toggle between 100% in-browser WebAssembly execution (`ClientPivotTransport`) and server-side warehouse pushdown (`HttpPivotTransport`). |
155
+ | **2D Virtualization** | Constant < 80 MB browser memory whether scrolling through 10,000 rows or 1,000,000,000+ rows with 1,000+ dynamic pivoted columns. |
156
+ | **$\mathcal{O}(D)$ Level-Based Hierarchy** | Multi-level tree group expansions execute one single batched query per hierarchy depth level ($D$) rather than sequential $N$-query waterfalls. |
157
+ | **Visual Analytics & Charting** | Integrated **ECharts 6** & **ECharts-GL 3D**: 23+ chart types across 11 families (Bar, Line, Area, Pie, Radar, Scatter, Waterfall, 3D Bar/Surface) linked to live pivot state. |
158
+ | **In-Cell Sparklines & Data Bars** | High-performance inline SVG sparklines (Line, Area, Bar) and proportional cell data bars rendered directly inside grid cells with zero DOM bloat. |
159
+ | **Excel AST Formulas & Window Functions** | Excel-like calculated measures using `[Field]` syntax and built-in pivot window functions (`percent_of_row`, `percent_of_col`, `percent_of_grand_total`). |
160
+ | **4 Layout Modes** | Multidimensional Pivot (`pivot`), Parent-Child Tree (`tree`), Flat Record Grid (`table`), and Financial P&L Report Mode (`report`). |
161
+ | **Client SheetJS & Clipboard** | Instant client-side Excel XLSX and CSV streaming export with merged headers and formatting preserved. RFC-compliant HTML/TSV clipboard copy. |
162
+ | **11 Enterprise Themes** | Complete theme system: `light`, `dark`, `flash`, `material`, `balham`, `bloomberg`, `bloomberg_black`, `strata`, `crystal`, `alabaster`, `satin` with full `--sp-*` CSS variables. |
163
+
164
+ ---
165
+
166
+ ## 🌐 Multi-Framework Ecosystem
167
+
168
+ `serverside_pivot` is part of the `serverside-pivot` ecosystem:
169
+ - **Standalone React**: `serverside_pivot` (this package)
170
+ - **Python Plotly Dash**: `pip install serverside-pivot`
171
+ - **Streamlit**: `pip install "serverside-pivot[streamlit]"`
172
+ - **Backend Pushdown**: Powered by **DuckDB**, **PyArrow**, and **Ibis** (Snowflake, BigQuery, Postgres, ClickHouse, MotherDuck, Databricks, Trino)
173
+
174
+ For comprehensive documentation, live Python/Dash showcases, and interactive examples, visit the **[GitHub Repository](https://github.com/Ramzy22/serverside_pivot)**.
175
+
176
+ > Cell editing and edit transactions are not a supported public capability in this release. Legacy edit-related Dash inputs are accepted as no-ops only for layout compatibility.
177
+
178
+ ---
179
+
180
+ ## 📄 License
181
+
182
+ Distributed under the **MIT License**.
@@ -1,59 +1,62 @@
1
1
  import p, { useState as T, useRef as R, useCallback as v, useEffect as B, useLayoutEffect as O } from "react";
2
- const G = 80, J = 220, N = ({ actions: e, theme: t, onClose: b, itemRefs: f, onItemMouseEnter: g, onKeyDown: D }) => /* @__PURE__ */ p.createElement(p.Fragment, null, e.map((u, o) => {
3
- if (u === "separator")
2
+ const G = 80, J = 220, N = ({ actions: e, theme: t, onClose: b, itemRefs: f, onItemMouseEnter: g, onKeyDown: D }) => /* @__PURE__ */ p.createElement(p.Fragment, null, e.map(
3
+ /** @param {any} [action] @param {any} [i] @returns {any} */
4
+ (u, o) => {
5
+ if (u === "separator")
6
+ return /* @__PURE__ */ p.createElement(
7
+ "div",
8
+ {
9
+ key: o,
10
+ role: "presentation",
11
+ style: { height: "1px", background: (t == null ? void 0 : t.border) || "#e0e0e0", margin: "4px 0" }
12
+ }
13
+ );
14
+ const a = !!u.disabled, d = Array.isArray(u.children) && u.children.length > 0;
4
15
  return /* @__PURE__ */ p.createElement(
5
16
  "div",
6
17
  {
7
18
  key: o,
8
- role: "presentation",
9
- style: { height: "1px", background: (t == null ? void 0 : t.border) || "#e0e0e0", margin: "4px 0" }
10
- }
11
- );
12
- const a = !!u.disabled, d = Array.isArray(u.children) && u.children.length > 0;
13
- return /* @__PURE__ */ p.createElement(
14
- "div",
15
- {
16
- key: o,
17
- ref: (l) => {
18
- f && (f.current[o] = l);
19
- },
20
- role: "menuitem",
21
- "aria-haspopup": d ? "menu" : void 0,
22
- "aria-disabled": a || void 0,
23
- tabIndex: a ? -1 : 0,
24
- title: u.title || (typeof u.label == "string" ? u.label : void 0),
25
- onMouseEnter: (l) => {
26
- l.currentTarget.style.backgroundColor = a ? "" : (t == null ? void 0 : t.hover) || "#f5f5f5", g && g(o, d, a);
27
- },
28
- onMouseLeave: (l) => {
29
- l.currentTarget.style.backgroundColor = "";
30
- },
31
- onClick: (l) => {
32
- if (a || d) {
33
- l.stopPropagation();
34
- return;
19
+ ref: (l) => {
20
+ f && (f.current[o] = l);
21
+ },
22
+ role: "menuitem",
23
+ "aria-haspopup": d ? "menu" : void 0,
24
+ "aria-disabled": a || void 0,
25
+ tabIndex: a ? -1 : 0,
26
+ title: u.title || (typeof u.label == "string" ? u.label : void 0),
27
+ onMouseEnter: (l) => {
28
+ l.currentTarget.style.backgroundColor = a ? "" : (t == null ? void 0 : t.hover) || "#f5f5f5", g && g(o, d, a);
29
+ },
30
+ onMouseLeave: (l) => {
31
+ l.currentTarget.style.backgroundColor = "";
32
+ },
33
+ onClick: (l) => {
34
+ if (a || d) {
35
+ l.stopPropagation();
36
+ return;
37
+ }
38
+ typeof u.onClick == "function" && u.onClick(), b();
39
+ },
40
+ onKeyDown: (l) => {
41
+ a || (l.key === "Enter" || l.key === " " ? (l.preventDefault(), l.stopPropagation(), !d && typeof u.onClick == "function" && u.onClick(), d ? g && g(o, !0, !1) : b()) : D && D(l, o));
42
+ },
43
+ style: {
44
+ padding: "7px 12px 7px 14px",
45
+ cursor: a ? "not-allowed" : "pointer",
46
+ display: "flex",
47
+ alignItems: "center",
48
+ gap: "8px",
49
+ color: a ? (t == null ? void 0 : t.textSec) || "#757575" : (t == null ? void 0 : t.text) || "#111",
50
+ opacity: a ? 0.48 : 1,
51
+ userSelect: "none"
35
52
  }
36
- typeof u.onClick == "function" && u.onClick(), b();
37
- },
38
- onKeyDown: (l) => {
39
- a || (l.key === "Enter" || l.key === " " ? (l.preventDefault(), l.stopPropagation(), !d && typeof u.onClick == "function" && u.onClick(), d ? g && g(o, !0, !1) : b()) : D && D(l, o));
40
53
  },
41
- style: {
42
- padding: "7px 12px 7px 14px",
43
- cursor: a ? "not-allowed" : "pointer",
44
- display: "flex",
45
- alignItems: "center",
46
- gap: "8px",
47
- color: a ? (t == null ? void 0 : t.textSec) || "#757575" : (t == null ? void 0 : t.text) || "#111",
48
- opacity: a ? 0.48 : 1,
49
- userSelect: "none"
50
- }
51
- },
52
- u.icon && /* @__PURE__ */ p.createElement("span", { style: { color: (t == null ? void 0 : t.textSec) || "#757575", display: "flex", flexShrink: 0 } }, u.icon),
53
- /* @__PURE__ */ p.createElement("span", { style: { flex: 1 } }, u.label),
54
- d && /* @__PURE__ */ p.createElement("span", { style: { color: (t == null ? void 0 : t.textSec) || "#9ca3af", fontSize: "10px", marginLeft: "4px" } }, "▶")
55
- );
56
- })), U = (e) => ({
54
+ u.icon && /* @__PURE__ */ p.createElement("span", { style: { color: (t == null ? void 0 : t.textSec) || "#757575", display: "flex", flexShrink: 0 } }, u.icon),
55
+ /* @__PURE__ */ p.createElement("span", { style: { flex: 1 } }, u.label),
56
+ d && /* @__PURE__ */ p.createElement("span", { style: { color: (t == null ? void 0 : t.textSec) || "#9ca3af", fontSize: "10px", marginLeft: "4px" } }, "▶")
57
+ );
58
+ }
59
+ )), U = (e) => ({
57
60
  background: (e == null ? void 0 : e.surfaceBg) || (e == null ? void 0 : e.background) || "#fff",
58
61
  border: `1px solid ${(e == null ? void 0 : e.border) || "#ccc"}`,
59
62
  boxShadow: (e == null ? void 0 : e.shadowMd) || "0 4px 20px rgba(0,0,0,0.15)",
@@ -1,5 +1,5 @@
1
1
  import o from "react";
2
- import { D as u } from "./DetailSurfaceContent-B3ZNKh7q.mjs";
2
+ import { D as u } from "./DetailSurfaceContent-BEL6xuaZ.mjs";
3
3
  function b({
4
4
  detailState: e,
5
5
  onClose: t,
@@ -1,5 +1,5 @@
1
1
  import a from "react";
2
- import { D as d } from "./DetailSurfaceContent-B3ZNKh7q.mjs";
2
+ import { D as d } from "./DetailSurfaceContent-BEL6xuaZ.mjs";
3
3
  function m({
4
4
  detailState: r,
5
5
  onClose: i,
@@ -1,5 +1,5 @@
1
1
  import t, { useState as m, useEffect as D } from "react";
2
- import { y as B } from "./react-CPZZxtSo.mjs";
2
+ import { z as B } from "./react-CDa-ADnG.mjs";
3
3
  function M({
4
4
  detailState: o,
5
5
  onClose: C,
@@ -103,27 +103,30 @@ function M({
103
103
  height: "100%",
104
104
  color: e.textSec,
105
105
  fontSize: "13px"
106
- } }, "Loading detail...") : /* @__PURE__ */ t.createElement("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: "12px" } }, /* @__PURE__ */ t.createElement("thead", null, /* @__PURE__ */ t.createElement("tr", null, g.map((r) => /* @__PURE__ */ t.createElement(
107
- "th",
108
- {
109
- key: r,
110
- onClick: () => z(r),
111
- style: {
112
- position: "sticky",
113
- top: 0,
114
- zIndex: 1,
115
- textAlign: "left",
116
- padding: n ? "8px 10px" : "10px 12px",
117
- background: e.headerBg,
118
- color: e.text,
119
- borderBottom: `1px solid ${e.border}`,
120
- cursor: i ? "pointer" : "default",
121
- whiteSpace: "nowrap"
122
- }
123
- },
124
- r,
125
- w === r ? v === "asc" ? " ▲" : " ▼" : ""
126
- )))), /* @__PURE__ */ t.createElement("tbody", null, p.length === 0 ? /* @__PURE__ */ t.createElement("tr", null, /* @__PURE__ */ t.createElement(
106
+ } }, "Loading detail...") : /* @__PURE__ */ t.createElement("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: "12px" } }, /* @__PURE__ */ t.createElement("thead", null, /* @__PURE__ */ t.createElement("tr", null, g.map(
107
+ /** @param {any} [columnId] @returns {any} */
108
+ (r) => /* @__PURE__ */ t.createElement(
109
+ "th",
110
+ {
111
+ key: r,
112
+ onClick: () => z(r),
113
+ style: {
114
+ position: "sticky",
115
+ top: 0,
116
+ zIndex: 1,
117
+ textAlign: "left",
118
+ padding: n ? "8px 10px" : "10px 12px",
119
+ background: e.headerBg,
120
+ color: e.text,
121
+ borderBottom: `1px solid ${e.border}`,
122
+ cursor: i ? "pointer" : "default",
123
+ whiteSpace: "nowrap"
124
+ }
125
+ },
126
+ r,
127
+ w === r ? v === "asc" ? " ▲" : " ▼" : ""
128
+ )
129
+ ))), /* @__PURE__ */ t.createElement("tbody", null, p.length === 0 ? /* @__PURE__ */ t.createElement("tr", null, /* @__PURE__ */ t.createElement(
127
130
  "td",
128
131
  {
129
132
  colSpan: Math.max(g.length, 1),
@@ -135,21 +138,27 @@ function M({
135
138
  }
136
139
  },
137
140
  "No detail rows"
138
- )) : p.map((r, f) => /* @__PURE__ */ t.createElement("tr", { key: `${o.rowKey || u || "detail"}:${f}`, style: {
139
- background: f % 2 === 0 ? e.surfaceBg || e.background : e.headerSubtleBg
140
- } }, g.map((d) => /* @__PURE__ */ t.createElement(
141
- "td",
142
- {
143
- key: `${d}:${f}`,
144
- style: {
145
- padding: n ? "7px 10px" : "9px 12px",
146
- borderBottom: `1px solid ${e.border}`,
147
- color: e.text,
148
- whiteSpace: "nowrap"
149
- }
150
- },
151
- r[d] !== void 0 && r[d] !== null ? String(r[d]) : ""
152
- ))))))), /* @__PURE__ */ t.createElement("div", { style: {
141
+ )) : p.map(
142
+ /** @param {any} [row] @param {any} [index] @returns {any} */
143
+ (r, f) => /* @__PURE__ */ t.createElement("tr", { key: `${o.rowKey || u || "detail"}:${f}`, style: {
144
+ background: f % 2 === 0 ? e.surfaceBg || e.background : e.headerSubtleBg
145
+ } }, g.map(
146
+ /** @param {any} [columnId] @returns {any} */
147
+ (d) => /* @__PURE__ */ t.createElement(
148
+ "td",
149
+ {
150
+ key: `${d}:${f}`,
151
+ style: {
152
+ padding: n ? "7px 10px" : "9px 12px",
153
+ borderBottom: `1px solid ${e.border}`,
154
+ color: e.text,
155
+ whiteSpace: "nowrap"
156
+ }
157
+ },
158
+ r[d] !== void 0 && r[d] !== null ? String(r[d]) : ""
159
+ )
160
+ ))
161
+ )))), /* @__PURE__ */ t.createElement("div", { style: {
153
162
  display: "flex",
154
163
  alignItems: "center",
155
164
  justifyContent: "space-between",