serverside_pivot 0.0.0-stage → 0.0.90

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 (178) hide show
  1. package/README.md +165 -3
  2. package/dist/react/chunks/ContextMenu-Bt5_3bmD.mjs +192 -0
  3. package/dist/react/chunks/DetailDrawer-DtsvdhO4.mjs +37 -0
  4. package/dist/react/chunks/DetailSidePanel-v_7iU73g.mjs +36 -0
  5. package/dist/react/chunks/DetailSurfaceContent-BOXVc58A.mjs +200 -0
  6. package/dist/react/chunks/ECharts2dRenderer-BGL_NVGU.mjs +3299 -0
  7. package/dist/react/chunks/ECharts3dRenderer-BF2YWlsP.mjs +21573 -0
  8. package/dist/react/chunks/EditSidePanel-CuvtsKTK.mjs +298 -0
  9. package/dist/react/chunks/InlineDetailPanel-Bmtlu3lc.mjs +41 -0
  10. package/dist/react/chunks/PivotCharts-CA3_0bB8.mjs +4252 -0
  11. package/dist/react/chunks/ReportEditor-DYBr0HDz.mjs +1726 -0
  12. package/dist/react/chunks/SidebarPanel-B64bhrUW.mjs +3339 -0
  13. package/dist/react/chunks/SparklineDetailGraph-90WjWkhg.mjs +200 -0
  14. package/dist/react/chunks/installCanvasRenderer-C8gE9ttC.mjs +21281 -0
  15. package/dist/react/chunks/react-52jgz-em.mjs +25301 -0
  16. package/dist/react/chunks/xlsx.mini.min-BwwnBtoK.mjs +7996 -0
  17. package/dist/react/components/Charts/ChartRenderers.d.ts +73 -0
  18. package/dist/react/components/Charts/ChartWorkspace.d.ts +38 -0
  19. package/dist/react/components/Charts/ECharts2dRenderer.d.ts +5 -0
  20. package/dist/react/components/Charts/ECharts3dRenderer.d.ts +6 -0
  21. package/dist/react/components/Charts/PivotCharts.d.ts +9 -0
  22. package/dist/react/components/Charts/chartEnhancements.d.ts +66 -0
  23. package/dist/react/components/Charts/chartExportPresentation.d.ts +19 -0
  24. package/dist/react/components/Charts/chartMath.d.ts +4 -0
  25. package/dist/react/components/Charts/useChartExportMenu.d.ts +12 -0
  26. package/dist/react/components/DashTanstackPivot.react.d.ts +365 -0
  27. package/dist/react/components/Filters/ColumnFilter.d.ts +13 -0
  28. package/dist/react/components/Filters/DateRangeFilter.d.ts +8 -0
  29. package/dist/react/components/Filters/FilterPopover.d.ts +14 -0
  30. package/dist/react/components/Filters/MultiSelectFilter.d.ts +12 -0
  31. package/dist/react/components/Filters/NumericRangeFilter.d.ts +8 -0
  32. package/dist/react/components/Notification.d.ts +7 -0
  33. package/dist/react/components/PivotAppBar.d.ts +2 -0
  34. package/dist/react/components/PivotErrorBoundary.d.ts +15 -0
  35. package/dist/react/components/PivotSmallComponents.d.ts +6 -0
  36. package/dist/react/components/PivotWorkspace.d.ts +19 -0
  37. package/dist/react/components/PivotWorkspaceCanvas.d.ts +5 -0
  38. package/dist/react/components/PivotWorkspaceControls.d.ts +12 -0
  39. package/dist/react/components/PivotWorkspaceShell.d.ts +12 -0
  40. package/dist/react/components/RuntimeDataError.d.ts +7 -0
  41. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +14 -0
  42. package/dist/react/components/Sidebar/ReportEditor.d.ts +21 -0
  43. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +14 -0
  44. package/dist/react/components/Sidebar/SidebarPanel.d.ts +2 -0
  45. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +14 -0
  46. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +62 -0
  47. package/dist/react/components/Sidebar/formulaUtils.d.ts +22 -0
  48. package/dist/react/components/SkeletonRow.d.ts +6 -0
  49. package/dist/react/components/Table/ContextMenu.d.ts +9 -0
  50. package/dist/react/components/Table/DetailDrawer.d.ts +12 -0
  51. package/dist/react/components/Table/DetailSidePanel.d.ts +12 -0
  52. package/dist/react/components/Table/DetailSurfaceContent.d.ts +12 -0
  53. package/dist/react/components/Table/EditSidePanel.d.ts +21 -0
  54. package/dist/react/components/Table/EditableCell.d.ts +29 -0
  55. package/dist/react/components/Table/InlineDetailPanel.d.ts +14 -0
  56. package/dist/react/components/Table/PivotTableBody.d.ts +9 -0
  57. package/dist/react/components/Table/SparklineCell.d.ts +17 -0
  58. package/dist/react/components/Table/SparklineDetailGraph.d.ts +5 -0
  59. package/dist/react/components/Table/StatusBar.d.ts +8 -0
  60. package/dist/react/contexts/PivotConfigContext.d.ts +34 -0
  61. package/dist/react/contexts/PivotThemeContext.d.ts +7 -0
  62. package/dist/react/contexts/PivotValueDisplayContext.d.ts +10 -0
  63. package/dist/react/hooks/useCellInteraction.d.ts +31 -0
  64. package/dist/react/hooks/useChartState.d.ts +76 -0
  65. package/dist/react/hooks/useColumnDefs.d.ts +82 -0
  66. package/dist/react/hooks/useColumnVirtualizer.d.ts +30 -0
  67. package/dist/react/hooks/useDetailDrillThrough.d.ts +38 -0
  68. package/dist/react/hooks/useFilteredData.d.ts +2 -0
  69. package/dist/react/hooks/useFormatState.d.ts +44 -0
  70. package/dist/react/hooks/usePersistence.d.ts +5 -0
  71. package/dist/react/hooks/usePivotFieldInteractions.d.ts +28 -0
  72. package/dist/react/hooks/usePivotNormalization.d.ts +473 -0
  73. package/dist/react/hooks/usePivotRenderCounter.d.ts +1 -0
  74. package/dist/react/hooks/usePivotTransactions.d.ts +29 -0
  75. package/dist/react/hooks/useRenderHelpers.d.ts +85 -0
  76. package/dist/react/hooks/useReportMode.d.ts +32 -0
  77. package/dist/react/hooks/useRowCache.d.ts +19 -0
  78. package/dist/react/hooks/useRuntimeDataCommit.d.ts +26 -0
  79. package/dist/react/hooks/useRuntimeProfiling.d.ts +19 -0
  80. package/dist/react/hooks/useRuntimeTransport.d.ts +24 -0
  81. package/dist/react/hooks/useServerSideRowModel.d.ts +50 -0
  82. package/dist/react/hooks/useServerSideViewportController.d.ts +64 -0
  83. package/dist/react/hooks/useSidebarUI.d.ts +37 -0
  84. package/dist/react/hooks/useStickyStyles.d.ts +24 -0
  85. package/dist/react/index.mjs +8 -0
  86. package/dist/react/presentation/headerFormatting.d.ts +13 -0
  87. package/dist/react/presentation/safeCellContent.d.ts +16 -0
  88. package/dist/react/react.d.ts +7 -0
  89. package/dist/react/runtime/PivotRuntimeRoot.d.ts +7 -0
  90. package/dist/react/runtime/cellSelectionAnchor.d.ts +45 -0
  91. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +7 -0
  92. package/dist/react/runtime/createRuntimeExportCommands.d.ts +77 -0
  93. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +9 -0
  94. package/dist/react/runtime/createWorkspacePresentation.d.ts +7 -0
  95. package/dist/react/runtime/displayColumnOrder.d.ts +4 -0
  96. package/dist/react/runtime/httpTransport.d.ts +65 -0
  97. package/dist/react/runtime/runtime-contract.generated.d.ts +48 -0
  98. package/dist/react/runtime/runtime-response-contract.generated.d.ts +34 -0
  99. package/dist/react/runtime/runtimeContract.d.ts +115 -0
  100. package/dist/react/runtime/runtimeDomains.d.ts +642 -0
  101. package/dist/react/runtime/runtimeDomains.type-test.d.ts +1 -0
  102. package/dist/react/runtime/runtimeResponseDedup.d.ts +36 -0
  103. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +50 -0
  104. package/dist/react/runtime/useCommandRuntime.d.ts +3 -0
  105. package/dist/react/runtime/useCommandRuntimeStage.d.ts +1 -0
  106. package/dist/react/runtime/useCoreRuntime.d.ts +3 -0
  107. package/dist/react/runtime/useCoreRuntimeStage.d.ts +3 -0
  108. package/dist/react/runtime/useRuntimeCellSelection.d.ts +44 -0
  109. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +36 -0
  110. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +13 -0
  111. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +9 -0
  112. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +14 -0
  113. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +28 -0
  114. package/dist/react/runtime/useRuntimeChartModels.d.ts +69 -0
  115. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +12 -0
  116. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +7 -0
  117. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +159 -0
  118. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +7 -0
  119. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +55 -0
  120. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +26 -0
  121. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +22 -0
  122. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +16 -0
  123. package/dist/react/runtime/useRuntimeDataRetry.d.ts +12 -0
  124. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +17 -0
  125. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +22 -0
  126. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +28 -0
  127. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +35 -0
  128. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +47 -0
  129. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +32 -0
  130. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +32 -0
  131. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +28 -0
  132. package/dist/react/runtime/useRuntimeExportState.d.ts +20 -0
  133. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +23 -0
  134. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +44 -0
  135. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +27 -0
  136. package/dist/react/runtime/useRuntimeRequestSession.d.ts +79 -0
  137. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +47 -0
  138. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +15 -0
  139. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +28 -0
  140. package/dist/react/runtime/useRuntimeRowEditing.d.ts +18 -0
  141. package/dist/react/runtime/useRuntimeRowSelection.d.ts +14 -0
  142. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +36 -0
  143. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +62 -0
  144. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +9 -0
  145. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +203 -0
  146. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +23 -0
  147. package/dist/react/runtime/useTransportRuntime.d.ts +12 -0
  148. package/dist/react/runtime/useViewportRuntime.d.ts +3 -0
  149. package/dist/react/runtime/useViewportRuntimeStage.d.ts +1 -0
  150. package/dist/react/runtime/useWorkspaceRuntime.d.ts +3 -0
  151. package/dist/react/runtime/useWorkspaceRuntimeStage.d.ts +1 -0
  152. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +115 -0
  153. package/dist/react/runtime/workspaceViewModel.d.ts +7 -0
  154. package/dist/react/utils/Icons.d.ts +46 -0
  155. package/dist/react/utils/chartModelBuilders.d.ts +236 -0
  156. package/dist/react/utils/columnOrder.d.ts +12 -0
  157. package/dist/react/utils/dataBars.d.ts +7 -0
  158. package/dist/react/utils/domEvents.d.ts +1 -0
  159. package/dist/react/utils/editing.d.ts +47 -0
  160. package/dist/react/utils/exportUtils.d.ts +121 -0
  161. package/dist/react/utils/fieldPanelLayout.d.ts +61 -0
  162. package/dist/react/utils/filterOptions.d.ts +4 -0
  163. package/dist/react/utils/formatting.d.ts +1 -0
  164. package/dist/react/utils/helpers.d.ts +20 -0
  165. package/dist/react/utils/horizontalViewport.d.ts +12 -0
  166. package/dist/react/utils/layoutRows.d.ts +3 -0
  167. package/dist/react/utils/measureAxis.d.ts +22 -0
  168. package/dist/react/utils/pivotLayoutUtils.d.ts +2 -0
  169. package/dist/react/utils/pivotProfiler.d.ts +4 -0
  170. package/dist/react/utils/rawTableTsv.d.ts +21 -0
  171. package/dist/react/utils/reportEditorSelection.d.ts +23 -0
  172. package/dist/react/utils/rowSpanning.d.ts +6 -0
  173. package/dist/react/utils/savedReports.d.ts +7 -0
  174. package/dist/react/utils/sorting.d.ts +14 -0
  175. package/dist/react/utils/sparklineDetail.d.ts +8 -0
  176. package/dist/react/utils/sparklines.d.ts +78 -0
  177. package/dist/react/utils/styles.d.ts +957 -0
  178. package/package.json +89 -6
package/README.md CHANGED
@@ -1,3 +1,165 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # serverside-pivot
2
+
3
+ `serverside-pivot` is a Dash component library for server-side pivot tables
4
+ built on TanStack Table. It supports large analytical datasets, virtual
5
+ scrolling, grouping, totals, filters, formulas, charts, and controlled exports.
6
+
7
+ Install the component with:
8
+
9
+ ```bash
10
+ pip install serverside-pivot
11
+ ```
12
+
13
+ Install optional FastAPI and authentication support with:
14
+
15
+ ```bash
16
+ pip install "serverside-pivot[api]"
17
+ ```
18
+
19
+ The complete quick-start guide, security guidance, and examples live in the
20
+ [project repository](https://github.com/Ramzy22/serverside_pivot).
21
+
22
+ For a publishing-ready comparison of the Dash, React, and Streamlit hosts,
23
+ see the [flagship host demos](https://github.com/Ramzy22/serverside_pivot/blob/main/examples/FLAGSHIP_DEMOS.md).
24
+
25
+ Cell editing and edit transactions are not a supported public capability in
26
+ this release. Legacy edit-related Dash inputs are accepted as no-ops only for
27
+ layout compatibility.
28
+
29
+ ## Host-neutral runtime transport
30
+
31
+ All hosts use one wire format: Pivot Runtime Protocol V1 (`schemaVersion: 1`).
32
+ There is no V2 or host-specific variant. A `CompletePivotAPI` instance exposes
33
+ the authenticated endpoint at `POST /v1/runtime`; it validates the V1 request,
34
+ derives the session and row-level-security context from the authenticated user,
35
+ and returns the matching V1 response.
36
+
37
+ Large viewport payloads are returned as short-lived, user-scoped `payloadRef`
38
+ objects. Fetch `payloadRef.url` instead of putting rows into component state.
39
+ The endpoint emits transport profiling under `profile.transport` and supports
40
+ ETags for payload retrieval.
41
+
42
+ ### Mutation security
43
+
44
+ The HTTP runtime is read-only by default, including when the authenticated
45
+ principal has an `editor` role. To enable a dataset explicitly, install a
46
+ server-owned policy when registering the route. It checks roles, dataset,
47
+ operation, and physical columns; authenticated `attributes` are applied to
48
+ every update/delete/upsert/aggregate predicate. Added and upserted rows must
49
+ include matching attribute values. Undo, redo, revert, and replacement actions
50
+ are scoped again when they replay history.
51
+
52
+ ```python
53
+ from pivot_engine.runtime import RuntimeMutationAuthorizer, register_runtime_http_transport
54
+
55
+ mutation_policy = RuntimeMutationAuthorizer({
56
+ "sales": {
57
+ "roles": {"admin", "editor"},
58
+ "columns": {"tenant", "region", "sales"},
59
+ "operations": {"add", "remove", "update", "upsert", "aggregate", "history"},
60
+ }
61
+ })
62
+
63
+ register_runtime_http_transport(
64
+ app,
65
+ get_runtime_service,
66
+ current_user_dependency=get_current_user,
67
+ mutation_authorizer=mutation_policy,
68
+ )
69
+ ```
70
+
71
+ Do not treat hidden editing controls as authorization. The principal and this
72
+ policy must be supplied by the server; browser payloads cannot grant access.
73
+
74
+ For a standalone React host, use `PivotWorkspace` with `HttpPivotTransport`
75
+ (wrap it in `LatestViewportScheduler` for latest-wins virtual scrolling):
76
+
77
+ ```tsx
78
+ import {
79
+ HttpPivotTransport,
80
+ LatestViewportScheduler,
81
+ PivotWorkspace,
82
+ themes,
83
+ injectThemeCssVars,
84
+ type PivotRuntimeProps,
85
+ type ValConfig,
86
+ type FilterConfig,
87
+ type SortConfig,
88
+ type ChartDefinition,
89
+ } from "dash_tanstack_pivot/react";
90
+
91
+ const transport = new LatestViewportScheduler(new HttpPivotTransport({
92
+ endpoint: '/v1/runtime',
93
+ }));
94
+
95
+ <PivotWorkspace table="sales" serverSide transport={transport} />
96
+ ```
97
+
98
+ `react`, `react-dom`, and `styled-components` are peer dependencies, so the
99
+ React application owns those singleton instances. The Streamlit adapter builds
100
+ from this exact React entry source; it adds only a V2 mounting/state wrapper.
101
+
102
+ Dash remains supported through its existing prop callback bridge; it adapts to
103
+ the same V1 service without changing the Dash Python API.
104
+
105
+ ## Streamlit host
106
+
107
+ The optional Streamlit V2 host uses the same browser-to-`/v1/runtime` V1
108
+ transport. Virtual scrolling therefore does not rerun the Streamlit script or
109
+ place row blocks in Streamlit state:
110
+
111
+ ```bash
112
+ pip install "serverside-pivot[streamlit]"
113
+ ```
114
+
115
+ ```python
116
+ from streamlit_pivot import pivot_workspace
117
+
118
+ pivot_workspace("sales", runtime_endpoint="/v1/runtime", key="sales-pivot")
119
+ ```
120
+
121
+ The browser endpoint must be reachable from the Streamlit page and authenticate
122
+ the browser user (same-origin cookies are preferred). `view_state` is emitted
123
+ only for durable user-controlled changes; it is not a viewport data channel.
124
+
125
+ ## Performance benchmarks
126
+
127
+ The runtime benchmark measures in-process Arrow load, cold/warm pivot, cache,
128
+ and viewport costs:
129
+
130
+ ```bash
131
+ python scripts/benchmark_pivot_runtime.py --rows 100000 --repeat-runs 7
132
+ ```
133
+
134
+ For the publishing-ready Dash, React, and Streamlit pages, see the
135
+ [flagship host performance report](../docs/flagship-performance.md). It keeps
136
+ shared-engine, direct-transport, and browser-to-paint measurements separate.
137
+
138
+ The browser benchmark launches the actual Dash component in headless Chrome,
139
+ scrolls through server-side viewport blocks, and reports end-to-end,
140
+ network/server, Dash callback, pivot service, and React-commit p50/p95
141
+ latency. It also prints the initial hydration sample separately, so a
142
+ warm-scroll result cannot hide a first-render regression. It needs Chrome and
143
+ a compatible ChromeDriver:
144
+
145
+ ```bash
146
+ python scripts/benchmark_browser_runtime.py --rows 100000 --requests 30
147
+ # Two independently positioned Chrome clients issue overlapping viewport
148
+ # requests against the same local Dash server.
149
+ python scripts/benchmark_browser_runtime.py --rows 1000000 --requests 20 --clients 2
150
+ ```
151
+
152
+ From `dash_tanstack_pivot/`, npm 11 requires an extra option separator when
153
+ forwarding flags:
154
+
155
+ ```bash
156
+ npm run benchmark:browser -- -- --rows 100000 --requests 30 --json
157
+ ```
158
+
159
+ Collapsed root hierarchies with at most 10,000 root members are materialized
160
+ once and sliced for later viewport requests when their Arrow result is at most
161
+ 32 MiB. This eliminates repeated `IN (...)` aggregate queries while retaining
162
+ bounded memory. Tune or disable that optimization with
163
+ `PIVOT_COLLAPSED_ROOT_MATERIALIZATION_MAX_ROWS` and
164
+ `PIVOT_COLLAPSED_ROOT_MATERIALIZATION_MAX_BYTES` (set either to `0` to disable
165
+ it); larger results continue to use the paged-query path.
@@ -0,0 +1,192 @@
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")
4
+ return /* @__PURE__ */ p.createElement(
5
+ "div",
6
+ {
7
+ 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;
35
+ }
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
+ },
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) => ({
57
+ background: (e == null ? void 0 : e.surfaceBg) || (e == null ? void 0 : e.background) || "#fff",
58
+ border: `1px solid ${(e == null ? void 0 : e.border) || "#ccc"}`,
59
+ boxShadow: (e == null ? void 0 : e.shadowMd) || "0 4px 20px rgba(0,0,0,0.15)",
60
+ padding: "6px 0",
61
+ borderRadius: (e == null ? void 0 : e.radiusSm) || "8px",
62
+ fontSize: "13px",
63
+ minWidth: "190px",
64
+ maxWidth: "300px",
65
+ color: (e == null ? void 0 : e.text) || "#111"
66
+ }), V = ({ x: e, y: t, onClose: b, actions: f, theme: g }) => {
67
+ const [D, u] = T({ x: e, y: t }), [o, a] = T(null), [d, l] = T(null), W = R(null), H = R(null), k = R([]), A = R(null), E = v((n, r = 1) => {
68
+ const s = f.length;
69
+ for (let i = 0; i < s; i++) {
70
+ const y = (n + i * r + s * 2) % s, c = f[y];
71
+ if (c && c !== "separator" && !c.disabled && k.current[y]) {
72
+ k.current[y].focus();
73
+ return;
74
+ }
75
+ }
76
+ }, [f]);
77
+ B(() => {
78
+ E(0, 1);
79
+ }, [E]), B(() => () => clearTimeout(A.current), []);
80
+ const K = v(() => {
81
+ clearTimeout(A.current), A.current = setTimeout(() => {
82
+ a(null), l(null);
83
+ }, J);
84
+ }, []), L = v(() => {
85
+ clearTimeout(A.current);
86
+ }, []), C = v((n) => {
87
+ clearTimeout(A.current), A.current = setTimeout(() => {
88
+ a(n);
89
+ const r = k.current[n];
90
+ r && l(r.getBoundingClientRect());
91
+ }, o !== null ? 0 : G);
92
+ }, [o]), Y = v((n, r, s) => {
93
+ s || (r ? C(n) : (L(), a(null), l(null)));
94
+ }, [C, L]), I = v((n, r) => {
95
+ if (n.key === "Escape")
96
+ n.preventDefault(), b();
97
+ else if (n.key === "ArrowDown")
98
+ n.preventDefault(), E(r + 1, 1);
99
+ else if (n.key === "ArrowUp")
100
+ n.preventDefault(), E(r - 1, -1);
101
+ else if (n.key === "Home")
102
+ n.preventDefault(), E(0, 1);
103
+ else if (n.key === "End")
104
+ n.preventDefault(), E(f.length - 1, -1);
105
+ else if (n.key === "ArrowRight" && o === null && Number.isFinite(r) && r >= 0) {
106
+ const s = f[r];
107
+ s && s !== "separator" && Array.isArray(s.children) && (n.preventDefault(), C(r));
108
+ }
109
+ }, [b, E, f, o, C]);
110
+ O(() => {
111
+ const n = () => {
112
+ var F;
113
+ const r = window.innerWidth, s = window.innerHeight, i = (F = W.current) == null ? void 0 : F.getBoundingClientRect(), y = (i == null ? void 0 : i.width) || 200, c = (i == null ? void 0 : i.height) || f.length * 32 + 20, x = 8;
114
+ let M = Math.max(x, Math.min(e, r - y - x)), q = Math.max(x, Math.min(t, s - c - x));
115
+ u({ x: M, y: q });
116
+ };
117
+ return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
118
+ window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
119
+ };
120
+ }, [e, t, f.length]);
121
+ const [_, $] = T({ left: 0, top: 0 });
122
+ O(() => {
123
+ if (!d || o === null) return;
124
+ const n = H.current;
125
+ if (!n) return;
126
+ const r = window.innerWidth, s = window.innerHeight, i = n.offsetWidth || 200, y = n.offsetHeight || 200, c = 6;
127
+ let x = d.right + 2;
128
+ x + i > r - c && (x = d.left - i - 2);
129
+ let M = d.top - 6;
130
+ M + y > s - c && (M = s - y - c), $({ left: Math.max(c, x), top: Math.max(c, M) });
131
+ }, [d, o]);
132
+ const P = o !== null ? f[o] : null, w = P && Array.isArray(P.children) ? P.children : null, S = R([]), z = v((n, r = 1) => {
133
+ if (!w) return;
134
+ const s = w.length;
135
+ for (let i = 0; i < s; i++) {
136
+ const y = (n + i * r + s * 2) % s, c = w[y];
137
+ if (c && c !== "separator" && !c.disabled && S.current[y]) {
138
+ S.current[y].focus();
139
+ return;
140
+ }
141
+ }
142
+ }, [w]);
143
+ B(() => {
144
+ w && (S.current = S.current.slice(0, w.length));
145
+ }, [w]);
146
+ const j = v((n, r) => {
147
+ n.key === "Escape" || n.key === "ArrowLeft" ? (n.preventDefault(), n.stopPropagation(), a(null), l(null), o !== null && k.current[o] && k.current[o].focus()) : n.key === "ArrowDown" ? (n.preventDefault(), z(r + 1, 1)) : n.key === "ArrowUp" && (n.preventDefault(), z(r - 1, -1));
148
+ }, [z, o]);
149
+ return /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement(
150
+ "div",
151
+ {
152
+ ref: W,
153
+ role: "menu",
154
+ style: { position: "fixed", top: D.y, left: D.x, zIndex: 10001, ...U(g) },
155
+ onMouseLeave: K,
156
+ onMouseEnter: L
157
+ },
158
+ /* @__PURE__ */ p.createElement(
159
+ N,
160
+ {
161
+ actions: f,
162
+ theme: g,
163
+ onClose: b,
164
+ itemRefs: k,
165
+ onItemMouseEnter: Y,
166
+ onKeyDown: I
167
+ }
168
+ )
169
+ ), w && /* @__PURE__ */ p.createElement(
170
+ "div",
171
+ {
172
+ ref: H,
173
+ role: "menu",
174
+ style: { position: "fixed", top: _.top, left: _.left, zIndex: 10002, ...U(g) },
175
+ onMouseEnter: L,
176
+ onMouseLeave: K
177
+ },
178
+ /* @__PURE__ */ p.createElement(
179
+ N,
180
+ {
181
+ actions: w,
182
+ theme: g,
183
+ onClose: b,
184
+ itemRefs: S,
185
+ onKeyDown: j
186
+ }
187
+ )
188
+ ));
189
+ };
190
+ export {
191
+ V as default
192
+ };
@@ -0,0 +1,37 @@
1
+ import o from "react";
2
+ import { D as u } from "./DetailSurfaceContent-BOXVc58A.mjs";
3
+ function b({
4
+ detailState: e,
5
+ onClose: t,
6
+ onPageChange: a,
7
+ onSort: n,
8
+ onFilter: i,
9
+ theme: r,
10
+ height: l = 320
11
+ }) {
12
+ return e ? /* @__PURE__ */ o.createElement("div", { style: {
13
+ position: "absolute",
14
+ left: 0,
15
+ right: 0,
16
+ bottom: 0,
17
+ height: `${Math.max(220, Number(l) || 320)}px`,
18
+ borderTop: `1px solid ${r.border}`,
19
+ background: r.surfaceBg || r.background,
20
+ zIndex: 85,
21
+ boxShadow: "0 -10px 24px rgba(15,23,42,0.12)",
22
+ overflow: "hidden"
23
+ } }, /* @__PURE__ */ o.createElement(
24
+ u,
25
+ {
26
+ detailState: e,
27
+ onClose: t,
28
+ onPageChange: a,
29
+ onSort: n,
30
+ onFilter: i,
31
+ theme: r
32
+ }
33
+ )) : null;
34
+ }
35
+ export {
36
+ b as default
37
+ };
@@ -0,0 +1,36 @@
1
+ import a from "react";
2
+ import { D as d } from "./DetailSurfaceContent-BOXVc58A.mjs";
3
+ function m({
4
+ detailState: r,
5
+ onClose: i,
6
+ onPageChange: n,
7
+ onSort: o,
8
+ onFilter: l,
9
+ theme: e,
10
+ width: t = 480
11
+ }) {
12
+ return r ? /* @__PURE__ */ a.createElement("div", { style: {
13
+ width: `${Math.max(320, Number(t) || 480)}px`,
14
+ minWidth: `${Math.max(320, Number(t) || 480)}px`,
15
+ maxWidth: "52vw",
16
+ borderLeft: `1px solid ${e.border}`,
17
+ background: e.surfaceBg || e.background,
18
+ display: "flex",
19
+ flexDirection: "column",
20
+ minHeight: 0,
21
+ overflow: "hidden"
22
+ } }, /* @__PURE__ */ a.createElement(
23
+ d,
24
+ {
25
+ detailState: r,
26
+ onClose: i,
27
+ onPageChange: n,
28
+ onSort: o,
29
+ onFilter: l,
30
+ theme: e
31
+ }
32
+ )) : null;
33
+ }
34
+ export {
35
+ m as default
36
+ };
@@ -0,0 +1,200 @@
1
+ import t, { useState as m, useEffect as D } from "react";
2
+ import { y as B } from "./react-52jgz-em.mjs";
3
+ function M({
4
+ detailState: o,
5
+ onClose: C,
6
+ onPageChange: a,
7
+ onSort: i,
8
+ onFilter: b,
9
+ theme: e,
10
+ compact: n = !1
11
+ }) {
12
+ const [y, E] = m("");
13
+ if (D(() => {
14
+ E(o && typeof o.filterText == "string" ? o.filterText : "");
15
+ }, [o && o.filterText]), !o) return null;
16
+ const {
17
+ loading: c,
18
+ rows: p = [],
19
+ columns: x = [],
20
+ page: l = 0,
21
+ pageSize: S = 100,
22
+ totalRows: k = 0,
23
+ sortCol: w = null,
24
+ sortDir: v = "asc",
25
+ title: $ = "Detail",
26
+ rowPath: u = ""
27
+ } = o, g = Array.isArray(x) && x.length > 0 ? x.map((r) => typeof r == "string" ? r : r.id).filter(Boolean) : p[0] ? Object.keys(p[0]).filter((r) => !r.startsWith("_")) : [], s = Math.max(1, Math.ceil((k || 0) / Math.max(1, S || 100))), z = (r) => {
28
+ if (i) {
29
+ if (w === r) {
30
+ i(r, v === "asc" ? "desc" : "asc");
31
+ return;
32
+ }
33
+ i(r, "asc");
34
+ }
35
+ };
36
+ return /* @__PURE__ */ t.createElement("div", { style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 } }, /* @__PURE__ */ t.createElement("div", { style: {
37
+ display: "flex",
38
+ alignItems: "center",
39
+ justifyContent: "space-between",
40
+ gap: "12px",
41
+ padding: n ? "10px 12px" : "14px 16px",
42
+ borderBottom: `1px solid ${e.border}`,
43
+ background: e.headerBg
44
+ } }, /* @__PURE__ */ t.createElement("div", { style: { minWidth: 0 } }, /* @__PURE__ */ t.createElement("div", { style: { fontSize: n ? "12px" : "13px", fontWeight: 700, color: e.text } }, $), u && /* @__PURE__ */ t.createElement("div", { style: {
45
+ fontSize: "11px",
46
+ color: e.textSec,
47
+ whiteSpace: "nowrap",
48
+ overflow: "hidden",
49
+ textOverflow: "ellipsis",
50
+ maxWidth: n ? "320px" : "460px"
51
+ } }, u)), /* @__PURE__ */ t.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexShrink: 0 } }, /* @__PURE__ */ t.createElement("div", { style: {
52
+ display: "flex",
53
+ alignItems: "center",
54
+ gap: "6px",
55
+ padding: "0 10px",
56
+ border: `1px solid ${e.border}`,
57
+ borderRadius: "999px",
58
+ background: e.surfaceBg || e.background
59
+ } }, /* @__PURE__ */ t.createElement(B.Search, null), /* @__PURE__ */ t.createElement(
60
+ "input",
61
+ {
62
+ type: "text",
63
+ value: y,
64
+ placeholder: "Filter rows...",
65
+ onChange: (r) => E(r.target.value),
66
+ onKeyDown: (r) => {
67
+ r.key === "Enter" && b && b(y);
68
+ },
69
+ style: {
70
+ border: "none",
71
+ outline: "none",
72
+ background: "transparent",
73
+ color: e.text,
74
+ fontSize: "12px",
75
+ width: n ? "140px" : "180px",
76
+ padding: "8px 0"
77
+ }
78
+ }
79
+ )), /* @__PURE__ */ t.createElement(
80
+ "button",
81
+ {
82
+ type: "button",
83
+ onClick: C,
84
+ style: {
85
+ width: "28px",
86
+ height: "28px",
87
+ borderRadius: "999px",
88
+ border: `1px solid ${e.border}`,
89
+ background: e.surfaceBg || e.background,
90
+ color: e.textSec,
91
+ cursor: "pointer",
92
+ display: "inline-flex",
93
+ alignItems: "center",
94
+ justifyContent: "center"
95
+ },
96
+ title: "Close detail"
97
+ },
98
+ /* @__PURE__ */ t.createElement(B.Close, null)
99
+ ))), /* @__PURE__ */ t.createElement("div", { style: { flex: 1, minHeight: 0, overflow: "auto", background: e.surfaceBg || e.background } }, c ? /* @__PURE__ */ t.createElement("div", { style: {
100
+ display: "flex",
101
+ alignItems: "center",
102
+ justifyContent: "center",
103
+ height: "100%",
104
+ color: e.textSec,
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(
127
+ "td",
128
+ {
129
+ colSpan: Math.max(g.length, 1),
130
+ style: {
131
+ padding: "18px 12px",
132
+ textAlign: "center",
133
+ color: e.textSec,
134
+ borderBottom: `1px solid ${e.border}`
135
+ }
136
+ },
137
+ "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: {
153
+ display: "flex",
154
+ alignItems: "center",
155
+ justifyContent: "space-between",
156
+ gap: "12px",
157
+ padding: n ? "10px 12px" : "12px 16px",
158
+ borderTop: `1px solid ${e.border}`,
159
+ background: e.headerBg,
160
+ fontSize: "12px",
161
+ color: e.textSec
162
+ } }, /* @__PURE__ */ t.createElement("span", null, "Page ", l + 1, " of ", s, " ", "(", k || 0, " rows)"), /* @__PURE__ */ t.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px" } }, /* @__PURE__ */ t.createElement(
163
+ "button",
164
+ {
165
+ type: "button",
166
+ onClick: () => a && a(Math.max(l - 1, 0)),
167
+ disabled: c || l <= 0,
168
+ style: {
169
+ padding: "6px 10px",
170
+ borderRadius: "8px",
171
+ border: `1px solid ${e.border}`,
172
+ background: e.surfaceBg || e.background,
173
+ color: e.text,
174
+ cursor: l <= 0 ? "default" : "pointer",
175
+ opacity: l <= 0 ? 0.45 : 1
176
+ }
177
+ },
178
+ "Previous"
179
+ ), /* @__PURE__ */ t.createElement(
180
+ "button",
181
+ {
182
+ type: "button",
183
+ onClick: () => a && a(l + 1),
184
+ disabled: c || l >= s - 1,
185
+ style: {
186
+ padding: "6px 10px",
187
+ borderRadius: "8px",
188
+ border: `1px solid ${e.border}`,
189
+ background: e.surfaceBg || e.background,
190
+ color: e.text,
191
+ cursor: l >= s - 1 ? "default" : "pointer",
192
+ opacity: l >= s - 1 ? 0.45 : 1
193
+ }
194
+ },
195
+ "Next"
196
+ ))));
197
+ }
198
+ export {
199
+ M as D
200
+ };