serverside_pivot 0.0.91 → 0.0.96

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 (172) hide show
  1. package/README.md +182 -182
  2. package/dist/react/chunks/ContextMenu-DJuS4qTZ.mjs +198 -0
  3. package/dist/react/chunks/{DetailDrawer-Eb4EpVHG.mjs → DetailDrawer-DgKSC5Vu.mjs} +1 -1
  4. package/dist/react/chunks/{DetailSidePanel-BTcHOiKr.mjs → DetailSidePanel-CC5Dugyl.mjs} +1 -1
  5. package/dist/react/chunks/{DetailSurfaceContent-B3ZNKh7q.mjs → DetailSurfaceContent-CrQVHlcU.mjs} +85 -77
  6. package/dist/react/chunks/{ECharts2dRenderer-C3Qv0uAa.mjs → ECharts2dRenderer-46gLrUdf.mjs} +412 -410
  7. package/dist/react/chunks/{ECharts3dRenderer-BB_7-fOt.mjs → ECharts3dRenderer-Dg4ta5Bl.mjs} +2211 -3197
  8. package/dist/react/chunks/{EditSidePanel-C2cAvxlK.mjs → EditSidePanel-CkShaByb.mjs} +77 -65
  9. package/dist/react/chunks/{InlineDetailPanel-BXLAw1o3.mjs → InlineDetailPanel-mnwjoD0I.mjs} +1 -1
  10. package/dist/react/chunks/PivotCharts-MX-Z7DlR.mjs +5076 -0
  11. package/dist/react/chunks/{ReportEditor-D4V0ry2B.mjs → ReportEditor-U0E42xKL.mjs} +952 -631
  12. package/dist/react/chunks/SidebarPanel-BzRW1Kgq.mjs +3944 -0
  13. package/dist/react/chunks/{SparklineDetailGraph-Bu85X7OJ.mjs → SparklineDetailGraph-35Tim_8B.mjs} +88 -58
  14. package/dist/react/chunks/installCanvasRenderer-DRq0xpXO.mjs +21174 -0
  15. package/dist/react/chunks/react-CL4GbEOd.mjs +33206 -0
  16. package/dist/react/chunks/{xlsx.mini.min-vfxHk3Ry.mjs → xlsx.mini.min-kfIgXMVB.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 +40 -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/ShimmerFallback.d.ts +11 -0
  41. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +2 -13
  42. package/dist/react/components/Sidebar/ReportEditor.d.ts +7 -20
  43. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +2 -13
  44. package/dist/react/components/Sidebar/SidebarPanel.d.ts +1 -2
  45. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +2 -13
  46. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +31 -62
  47. package/dist/react/components/Sidebar/formulaUtils.d.ts +16 -18
  48. package/dist/react/components/SkeletonRow.d.ts +2 -5
  49. package/dist/react/components/Table/ContextMenu.d.ts +2 -8
  50. package/dist/react/components/Table/DetailDrawer.d.ts +2 -11
  51. package/dist/react/components/Table/DetailSidePanel.d.ts +2 -11
  52. package/dist/react/components/Table/DetailSurfaceContent.d.ts +2 -11
  53. package/dist/react/components/Table/EditSidePanel.d.ts +2 -20
  54. package/dist/react/components/Table/EditableCell.d.ts +2 -28
  55. package/dist/react/components/Table/InlineDetailPanel.d.ts +2 -13
  56. package/dist/react/components/Table/PivotTableBody.d.ts +3 -3
  57. package/dist/react/components/Table/SparklineCell.d.ts +2 -17
  58. package/dist/react/components/Table/SparklineDetailGraph.d.ts +2 -5
  59. package/dist/react/components/Table/StatusBar.d.ts +2 -7
  60. package/dist/react/components/ThemedSelect.d.ts +8 -0
  61. package/dist/react/contexts/PivotConfigContext.d.ts +5 -33
  62. package/dist/react/contexts/PivotThemeContext.d.ts +8 -4
  63. package/dist/react/contexts/PivotValueDisplayContext.d.ts +5 -9
  64. package/dist/react/hooks/useChartState.d.ts +2 -71
  65. package/dist/react/hooks/useColumnDefs.d.ts +3 -68
  66. package/dist/react/hooks/useColumnVirtualizer.d.ts +1 -30
  67. package/dist/react/hooks/useDetailDrillThrough.d.ts +2 -36
  68. package/dist/react/hooks/useFilteredData.d.ts +4 -2
  69. package/dist/react/hooks/useFormatState.d.ts +2 -39
  70. package/dist/react/hooks/usePersistence.d.ts +4 -5
  71. package/dist/react/hooks/usePivotFieldInteractions.d.ts +2 -23
  72. package/dist/react/hooks/usePivotNormalization.d.ts +127 -461
  73. package/dist/react/hooks/usePivotRenderCounter.d.ts +2 -1
  74. package/dist/react/hooks/usePivotTransactions.d.ts +2 -23
  75. package/dist/react/hooks/useRenderHelpers.d.ts +3 -71
  76. package/dist/react/hooks/useReportMode.d.ts +2 -28
  77. package/dist/react/hooks/useRowCache.d.ts +16 -15
  78. package/dist/react/hooks/useRuntimeDataCommit.d.ts +2 -22
  79. package/dist/react/hooks/useRuntimeProfiling.d.ts +2 -13
  80. package/dist/react/hooks/useRuntimeTransport.d.ts +2 -18
  81. package/dist/react/hooks/useServerSideRowModel.d.ts +1 -50
  82. package/dist/react/hooks/useServerSideViewportController.d.ts +1 -64
  83. package/dist/react/hooks/useSidebarUI.d.ts +2 -32
  84. package/dist/react/hooks/useStickyStyles.d.ts +2 -23
  85. package/dist/react/index.mjs +15 -9
  86. package/dist/react/presentation/headerFormatting.d.ts +28 -11
  87. package/dist/react/presentation/safeCellContent.d.ts +22 -5
  88. package/dist/react/react.d.ts +4 -1
  89. package/dist/react/runtime/PivotRuntimeRoot.d.ts +1 -1
  90. package/dist/react/runtime/client/clientPivotTransport.d.ts +6 -1
  91. package/dist/react/runtime/client/clientResponsePostProcessor.d.ts +50 -0
  92. package/dist/react/runtime/client/duckdbWasmExecutor.d.ts +3 -0
  93. package/dist/react/runtime/client/types.d.ts +17 -0
  94. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +2 -7
  95. package/dist/react/runtime/createRuntimeExportCommands.d.ts +2 -71
  96. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +2 -9
  97. package/dist/react/runtime/displayColumnOrder.d.ts +4 -4
  98. package/dist/react/runtime/httpTransport.d.ts +1 -0
  99. package/dist/react/runtime/runtime-contract.generated.d.ts +3 -0
  100. package/dist/react/runtime/runtimeContract.d.ts +3 -0
  101. package/dist/react/runtime/runtimeDomains.d.ts +110 -0
  102. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +2 -45
  103. package/dist/react/runtime/useCoreRuntime.d.ts +4 -1
  104. package/dist/react/runtime/useCoreRuntimeStage.d.ts +1 -1
  105. package/dist/react/runtime/useRuntimeCellSelection.d.ts +2 -40
  106. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +7 -31
  107. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +2 -13
  108. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +2 -9
  109. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +2 -14
  110. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +2 -28
  111. package/dist/react/runtime/useRuntimeChartModels.d.ts +2 -62
  112. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +2 -12
  113. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +2 -4
  114. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +2 -152
  115. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +2 -7
  116. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +2 -55
  117. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +2 -26
  118. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +2 -22
  119. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +2 -11
  120. package/dist/react/runtime/useRuntimeDataRetry.d.ts +2 -12
  121. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +2 -11
  122. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +2 -18
  123. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +2 -28
  124. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +2 -35
  125. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +2 -43
  126. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +2 -28
  127. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +2 -32
  128. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +2 -24
  129. package/dist/react/runtime/useRuntimeExportState.d.ts +5 -5
  130. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +2 -19
  131. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +2 -40
  132. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +2 -27
  133. package/dist/react/runtime/useRuntimeRequestSession.d.ts +2 -76
  134. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +2 -43
  135. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +2 -15
  136. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +2 -28
  137. package/dist/react/runtime/useRuntimeRowEditing.d.ts +2 -18
  138. package/dist/react/runtime/useRuntimeRowSelection.d.ts +2 -14
  139. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +2 -30
  140. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +2 -61
  141. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +2 -5
  142. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +2 -196
  143. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +2 -23
  144. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +2 -109
  145. package/dist/react/utils/Icons.d.ts +2 -45
  146. package/dist/react/utils/chartModelBuilders.d.ts +76 -230
  147. package/dist/react/utils/columnOrder.d.ts +8 -12
  148. package/dist/react/utils/dataBars.d.ts +4 -7
  149. package/dist/react/utils/domEvents.d.ts +2 -1
  150. package/dist/react/utils/editing.d.ts +12 -47
  151. package/dist/react/utils/exportUtils.d.ts +30 -101
  152. package/dist/react/utils/fieldPanelLayout.d.ts +12 -61
  153. package/dist/react/utils/filterOptions.d.ts +4 -4
  154. package/dist/react/utils/helpers.d.ts +21 -18
  155. package/dist/react/utils/horizontalViewport.d.ts +1 -12
  156. package/dist/react/utils/layoutRows.d.ts +3 -3
  157. package/dist/react/utils/measureAxis.d.ts +6 -22
  158. package/dist/react/utils/pivotLayoutUtils.d.ts +7 -2
  159. package/dist/react/utils/pivotProfiler.d.ts +3 -3
  160. package/dist/react/utils/reportEditorSelection.d.ts +1 -23
  161. package/dist/react/utils/rowSpanning.d.ts +3 -6
  162. package/dist/react/utils/savedReports.d.ts +4 -7
  163. package/dist/react/utils/sorting.d.ts +8 -14
  164. package/dist/react/utils/sparklineDetail.d.ts +5 -8
  165. package/dist/react/utils/sparklines.d.ts +10 -78
  166. package/dist/react/utils/styles.d.ts +19 -308
  167. package/package.json +114 -114
  168. package/dist/react/chunks/ContextMenu-Bt5_3bmD.mjs +0 -192
  169. package/dist/react/chunks/PivotCharts-Bw6Swoa3.mjs +0 -4252
  170. package/dist/react/chunks/SidebarPanel-xO59p_2o.mjs +0 -3339
  171. package/dist/react/chunks/installCanvasRenderer-B7sfDGoL.mjs +0 -21281
  172. 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**.
@@ -0,0 +1,198 @@
1
+ import c, { useState as C, useRef as M, useCallback as b, useEffect as W, useLayoutEffect as K } from "react";
2
+ import { I as z } from "./react-CL4GbEOd.mjs";
3
+ const G = 80, J = 220, _ = ({ actions: n, theme: r, onClose: v, itemRefs: f, onItemMouseEnter: g, onKeyDown: D }) => /* @__PURE__ */ c.createElement(c.Fragment, null, n.map(
4
+ /** @param {any} [action] @param {any} [i] @returns {any} */
5
+ (i, l) => {
6
+ if (i === "separator")
7
+ return /* @__PURE__ */ c.createElement(
8
+ "div",
9
+ {
10
+ key: l,
11
+ role: "presentation",
12
+ style: { height: "1px", background: (r == null ? void 0 : r.border) || "#e0e0e0", margin: "4px 0" }
13
+ }
14
+ );
15
+ const p = !!i.disabled, d = Array.isArray(i.children) && i.children.length > 0;
16
+ return /* @__PURE__ */ c.createElement(
17
+ "div",
18
+ {
19
+ key: l,
20
+ ref: (u) => {
21
+ f && (f.current[l] = u);
22
+ },
23
+ className: "sp-menu-item",
24
+ role: "menuitem",
25
+ "aria-haspopup": d ? "menu" : void 0,
26
+ "aria-disabled": p || void 0,
27
+ tabIndex: p ? -1 : 0,
28
+ title: i.title || (typeof i.label == "string" ? i.label : void 0),
29
+ onMouseEnter: () => {
30
+ g && g(l, d, p);
31
+ },
32
+ onClick: (u) => {
33
+ if (p || d) {
34
+ u.stopPropagation();
35
+ return;
36
+ }
37
+ typeof i.onClick == "function" && i.onClick(), v();
38
+ },
39
+ onKeyDown: (u) => {
40
+ p || (u.key === "Enter" || u.key === " " ? (u.preventDefault(), u.stopPropagation(), !d && typeof i.onClick == "function" && i.onClick(), d ? g && g(l, !0, !1) : v()) : D && D(u, l));
41
+ },
42
+ style: {
43
+ padding: "7px 10px",
44
+ cursor: p ? "not-allowed" : "pointer",
45
+ display: "flex",
46
+ alignItems: "center",
47
+ gap: "8px",
48
+ color: p ? (r == null ? void 0 : r.textSec) || "#757575" : (r == null ? void 0 : r.text) || "#111",
49
+ opacity: p ? 0.48 : 1,
50
+ userSelect: "none"
51
+ }
52
+ },
53
+ i.icon && /* @__PURE__ */ c.createElement("span", { style: { color: (r == null ? void 0 : r.textSec) || "#757575", display: "flex", flexShrink: 0 } }, i.icon),
54
+ /* @__PURE__ */ c.createElement("span", { style: { flex: 1 } }, i.label),
55
+ d && /* @__PURE__ */ c.createElement("span", { "aria-hidden": "true", style: { color: (r == null ? void 0 : r.textSec) || "#9ca3af", display: "inline-flex", alignItems: "center", marginLeft: "4px" } }, z && z.ChevronRight ? /* @__PURE__ */ c.createElement(z.ChevronRight, null) : ">")
56
+ );
57
+ }
58
+ )), O = (n) => ({
59
+ background: `var(--sp-glass-bg, ${(n == null ? void 0 : n.surfaceBg) || (n == null ? void 0 : n.background) || "#fff"})`,
60
+ backdropFilter: "blur(18px) saturate(180%)",
61
+ WebkitBackdropFilter: "blur(18px) saturate(180%)",
62
+ border: `1px solid ${(n == null ? void 0 : n.border) || "#ccc"}`,
63
+ boxShadow: (n == null ? void 0 : n.shadow) || (n == null ? void 0 : n.shadowMd) || "0 14px 36px rgba(0,0,0,0.18)",
64
+ padding: "5px",
65
+ borderRadius: "10px",
66
+ fontSize: "13px",
67
+ minWidth: "190px",
68
+ maxWidth: "300px",
69
+ color: (n == null ? void 0 : n.text) || "#111"
70
+ }), X = ({ x: n, y: r, onClose: v, actions: f, theme: g }) => {
71
+ const [D, i] = C({ x: n, y: r }), [l, p] = C(null), [d, u] = C(null), B = M(null), F = M(null), k = M([]), A = M(null), E = b((e, t = 1) => {
72
+ const o = f.length;
73
+ for (let s = 0; s < o; s++) {
74
+ const y = (e + s * t + o * 2) % o, a = f[y];
75
+ if (a && a !== "separator" && !a.disabled && k.current[y]) {
76
+ k.current[y].focus();
77
+ return;
78
+ }
79
+ }
80
+ }, [f]);
81
+ W(() => {
82
+ E(0, 1);
83
+ }, [E]), W(() => () => clearTimeout(A.current), []);
84
+ const N = b(() => {
85
+ clearTimeout(A.current), A.current = setTimeout(() => {
86
+ p(null), u(null);
87
+ }, J);
88
+ }, []), L = b(() => {
89
+ clearTimeout(A.current);
90
+ }, []), m = b((e) => {
91
+ clearTimeout(A.current), A.current = setTimeout(() => {
92
+ p(e);
93
+ const t = k.current[e];
94
+ t && u(t.getBoundingClientRect());
95
+ }, l !== null ? 0 : G);
96
+ }, [l]), U = b((e, t, o) => {
97
+ o || (t ? m(e) : (L(), p(null), u(null)));
98
+ }, [m, L]), Y = b((e, t) => {
99
+ if (e.key === "Escape")
100
+ e.preventDefault(), v();
101
+ else if (e.key === "ArrowDown")
102
+ e.preventDefault(), E(t + 1, 1);
103
+ else if (e.key === "ArrowUp")
104
+ e.preventDefault(), E(t - 1, -1);
105
+ else if (e.key === "Home")
106
+ e.preventDefault(), E(0, 1);
107
+ else if (e.key === "End")
108
+ e.preventDefault(), E(f.length - 1, -1);
109
+ else if (e.key === "ArrowRight" && l === null && Number.isFinite(t) && t >= 0) {
110
+ const o = f[t];
111
+ o && o !== "separator" && Array.isArray(o.children) && (e.preventDefault(), m(t));
112
+ }
113
+ }, [v, E, f, l, m]);
114
+ K(() => {
115
+ const e = () => {
116
+ var I;
117
+ const t = window.innerWidth, o = window.innerHeight, s = (I = B.current) == null ? void 0 : I.getBoundingClientRect(), y = (s == null ? void 0 : s.width) || 200, a = (s == null ? void 0 : s.height) || f.length * 32 + 20, x = 8;
118
+ let S = Math.max(x, Math.min(n, t - y - x)), q = Math.max(x, Math.min(r, o - a - x));
119
+ i({ x: S, y: q });
120
+ };
121
+ return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
122
+ window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
123
+ };
124
+ }, [n, r, f.length]);
125
+ const [H, $] = C({ left: 0, top: 0 });
126
+ K(() => {
127
+ if (!d || l === null) return;
128
+ const e = F.current;
129
+ if (!e) return;
130
+ const t = window.innerWidth, o = window.innerHeight, s = e.offsetWidth || 200, y = e.offsetHeight || 200, a = 6;
131
+ let x = d.right + 2;
132
+ x + s > t - a && (x = d.left - s - 2);
133
+ let S = d.top - 6;
134
+ S + y > o - a && (S = o - y - a), $({ left: Math.max(a, x), top: Math.max(a, S) });
135
+ }, [d, l]);
136
+ const P = l !== null ? f[l] : null, w = P && Array.isArray(P.children) ? P.children : null, R = M([]), T = b((e, t = 1) => {
137
+ if (!w) return;
138
+ const o = w.length;
139
+ for (let s = 0; s < o; s++) {
140
+ const y = (e + s * t + o * 2) % o, a = w[y];
141
+ if (a && a !== "separator" && !a.disabled && R.current[y]) {
142
+ R.current[y].focus();
143
+ return;
144
+ }
145
+ }
146
+ }, [w]);
147
+ W(() => {
148
+ w && (R.current = R.current.slice(0, w.length));
149
+ }, [w]);
150
+ const j = b((e, t) => {
151
+ e.key === "Escape" || e.key === "ArrowLeft" ? (e.preventDefault(), e.stopPropagation(), p(null), u(null), l !== null && k.current[l] && k.current[l].focus()) : e.key === "ArrowDown" ? (e.preventDefault(), T(t + 1, 1)) : e.key === "ArrowUp" && (e.preventDefault(), T(t - 1, -1));
152
+ }, [T, l]);
153
+ return /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement(
154
+ "div",
155
+ {
156
+ ref: B,
157
+ className: "sp-menu-surface",
158
+ role: "menu",
159
+ style: { position: "fixed", top: D.y, left: D.x, zIndex: 10001, ...O(g) },
160
+ onMouseLeave: N,
161
+ onMouseEnter: L
162
+ },
163
+ /* @__PURE__ */ c.createElement(
164
+ _,
165
+ {
166
+ actions: f,
167
+ theme: g,
168
+ onClose: v,
169
+ itemRefs: k,
170
+ onItemMouseEnter: U,
171
+ onKeyDown: Y
172
+ }
173
+ )
174
+ ), w && /* @__PURE__ */ c.createElement(
175
+ "div",
176
+ {
177
+ ref: F,
178
+ className: "sp-menu-surface",
179
+ role: "menu",
180
+ style: { position: "fixed", top: H.top, left: H.left, zIndex: 10002, ...O(g) },
181
+ onMouseEnter: L,
182
+ onMouseLeave: N
183
+ },
184
+ /* @__PURE__ */ c.createElement(
185
+ _,
186
+ {
187
+ actions: w,
188
+ theme: g,
189
+ onClose: v,
190
+ itemRefs: R,
191
+ onKeyDown: j
192
+ }
193
+ )
194
+ ));
195
+ };
196
+ export {
197
+ X as default
198
+ };
@@ -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-CrQVHlcU.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-CrQVHlcU.mjs";
3
3
  function m({
4
4
  detailState: r,
5
5
  onClose: i,