@akohn/dashql-react 0.0.20-latest.668.g590a68535 → 0.0.20-latest.916.g2c2e9e4f8

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 (65) hide show
  1. package/NOTICE +53 -1
  2. package/README.md +88 -1
  3. package/dist/components/data_table/data_table.d.ts +4 -3
  4. package/dist/components/data_table/data_table.js +56 -19
  5. package/dist/components/data_table/data_table_cell_data.d.ts +1 -0
  6. package/dist/components/data_table/data_table_cell_data.js +4 -0
  7. package/dist/components/data_table/data_table_cell_header_plots.d.ts +1 -3
  8. package/dist/components/data_table/data_table_cell_header_plots.js +4 -6
  9. package/dist/components/data_table/data_table_row_detail.d.ts +22 -0
  10. package/dist/components/data_table/data_table_row_detail.js +68 -0
  11. package/dist/components/data_table/data_table_row_detail.module.js +7 -0
  12. package/dist/components/data_table/data_table_sticky_views.d.ts +1 -0
  13. package/dist/components/data_table/data_table_sticky_views.js +3 -3
  14. package/dist/components/data_table/histogram_brush.d.ts +0 -1
  15. package/dist/components/data_table/histogram_brush.js +3 -5
  16. package/dist/components/data_table/histogram_cell.d.ts +0 -2
  17. package/dist/components/data_table/histogram_cell.js +1 -2
  18. package/dist/components/name_input.d.ts +1 -0
  19. package/dist/components/name_input.js +13 -1
  20. package/dist/components/query_history_viewer.d.ts +1 -3
  21. package/dist/components/query_history_viewer.js +7 -4
  22. package/dist/components/query_profile/profile_execution_controller.d.ts +0 -2
  23. package/dist/components/query_profile/profile_execution_controller.js +0 -12
  24. package/dist/components/query_profile/query_profile_view.d.ts +1 -9
  25. package/dist/components/query_profile/query_profile_view.js +19 -27
  26. package/dist/components/query_result/query_result_header.js +3 -2
  27. package/dist/components/sheet.d.ts +11 -0
  28. package/dist/components/sheet.js +65 -0
  29. package/dist/components/sheet.module.js +7 -0
  30. package/dist/components/vegalite_chart.d.ts +0 -2
  31. package/dist/components/vegalite_chart.js +1 -3
  32. package/dist/components/vegalite_view.d.ts +0 -1
  33. package/dist/components/vegalite_view.js +11 -20
  34. package/dist/components/visualization/vegalite_preview.d.ts +1 -1
  35. package/dist/components/visualization/visualization_dispatch.d.ts +0 -1
  36. package/dist/components/visualization/visualization_dispatch.js +0 -1
  37. package/dist/components/visualization/visualization_panel.d.ts +1 -1
  38. package/dist/components/visualization/visualization_panel.js +0 -1
  39. package/dist/dom/app_host.d.ts +2 -1
  40. package/dist/dom/app_host.js +6 -3
  41. package/dist/dom/calm_frames.d.ts +5 -0
  42. package/dist/dom/calm_frames.js +25 -1
  43. package/dist/dom/media_query.d.ts +4 -1
  44. package/dist/dom/media_query.js +5 -2
  45. package/dist/hooks.d.ts +2 -1
  46. package/dist/hooks.js +4 -1
  47. package/dist/logger.d.ts +2 -2
  48. package/dist/logger.js +8 -1
  49. package/dist/models/script_model.js +4 -14
  50. package/dist/platform/content_length.d.ts +1 -0
  51. package/dist/platform/content_length.js +7 -0
  52. package/dist/platform/core_provider.d.ts +18 -0
  53. package/dist/platform/core_provider.js +106 -0
  54. package/dist/platform/embedded_database_provider.d.ts +19 -0
  55. package/dist/platform/embedded_database_provider.js +53 -0
  56. package/dist/platform/page_runtime.d.ts +3 -0
  57. package/dist/platform/page_runtime.js +29 -0
  58. package/dist/style.css +160 -2
  59. package/dist/vegalite/vegalite_image.d.ts +0 -2
  60. package/dist/vegalite/vegalite_image.js +1 -1
  61. package/dist/vegalite/vegalite_rows.d.ts +1 -1
  62. package/dist/vegalite/vegalite_rows.js +7 -1
  63. package/dist/vegalite/vegalite_theme.d.ts +2 -0
  64. package/dist/vegalite/vegalite_theme.js +18 -2
  65. package/package.json +376 -16
package/NOTICE CHANGED
@@ -9,7 +9,7 @@ their own licenses.
9
9
  1. GitHub Octicons
10
10
  --------------------------------------------------------------------------------
11
11
 
12
- Icon geometry under `packages/dashql-app/static/svg/icons/` includes icons from
12
+ Icon geometry under `packages/dashql-react/svg/icons/` includes icons from
13
13
  GitHub Octicons (https://github.com/primer/octicons).
14
14
 
15
15
  MIT License
@@ -64,3 +64,55 @@ and used here under the MIT license.
64
64
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65
65
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
66
66
  SOFTWARE.
67
+
68
+ --------------------------------------------------------------------------------
69
+ 3. Instrument Sans and JetBrains Mono
70
+ --------------------------------------------------------------------------------
71
+
72
+ The fonts under `packages/dashql-react/fonts/` are Instrument Sans
73
+ (https://github.com/Instrument/instrument-sans, Copyright 2022 The Instrument
74
+ Sans Project Authors) and JetBrains Mono
75
+ (https://github.com/JetBrains/JetBrainsMono, Copyright 2020 The JetBrains Mono
76
+ Project Authors), both under the SIL Open Font License, Version 1.1. The full
77
+ license text ships next to the fonts in `InstrumentSans-OFL.txt` and
78
+ `JetBrainsMono-OFL.txt`.
79
+
80
+ --------------------------------------------------------------------------------
81
+ 4. Google protocol buffers
82
+ --------------------------------------------------------------------------------
83
+
84
+ `proto/pb/google/rpc/status.proto` is a copy of google/rpc/status.proto
85
+ (https://github.com/googleapis/googleapis), Copyright 2020 Google LLC, licensed
86
+ under the Apache License, Version 2.0
87
+ (http://www.apache.org/licenses/LICENSE-2.0).
88
+
89
+ `proto/pb/google/protobuf/{any,empty,timestamp}.proto` are copies of the
90
+ well-known types of Protocol Buffers (https://github.com/protocolbuffers/protobuf).
91
+
92
+ Copyright 2008 Google Inc. All rights reserved.
93
+
94
+ Redistribution and use in source and binary forms, with or without
95
+ modification, are permitted provided that the following conditions are
96
+ met:
97
+
98
+ * Redistributions of source code must retain the above copyright
99
+ notice, this list of conditions and the following disclaimer.
100
+ * Redistributions in binary form must reproduce the above
101
+ copyright notice, this list of conditions and the following disclaimer
102
+ in the documentation and/or other materials provided with the
103
+ distribution.
104
+ * Neither the name of Google Inc. nor the names of its
105
+ contributors may be used to endorse or promote products derived from
106
+ this software without specific prior written permission.
107
+
108
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
109
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
110
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
111
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
112
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
113
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
114
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
115
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
116
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
118
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -13,7 +13,8 @@ come from the same build. The Vega libraries are optional peers, for the charts.
13
13
 
14
14
  ## Using it
15
15
 
16
- The modules keep the paths of the sources, every one is a subpath of its own:
16
+ Every public module is a subpath of its own, at the path of its source. The `exports` of the package list them, the
17
+ other modules stay inside it:
17
18
 
18
19
  ```tsx
19
20
  import '@akohn/dashql-react/style.css';
@@ -34,6 +35,92 @@ import { useScriptModel } from '@akohn/dashql-react/models/script_model';
34
35
  next to the modules (`new URL('./symbols.svg', import.meta.url)`), which the bundler of the host emits as an asset.
35
36
  The atlas is served by the host: browsers resolve the `<use>` of a symbol only from the origin of the page.
36
37
 
38
+ ## A page with a runtime
39
+
40
+ `platform/` holds what a page needs for a runtime: the core, the embedded Hyper and the runtime of the page. The
41
+ files of the core and of the engine are assets of the host, it passes their URLs. The embedded Hyper needs a
42
+ cross-origin isolated page (`Cross-Origin-Opener-Policy: same-origin`, `Cross-Origin-Embedder-Policy: require-corp`)
43
+ and a script of the page's origin that loads the worker of the engine:
44
+
45
+ ```js
46
+ // hyperdb_worker_bridge.js, served by the host
47
+ const workerUrl = new URL(self.location.href).searchParams.get('workerUrl');
48
+ if (workerUrl == null) throw new Error('Missing HyperDB worker URL');
49
+ self.importScripts(workerUrl);
50
+ ```
51
+
52
+ ```tsx
53
+ import coreWasm from '@akohn/dashql/wasm?url';
54
+ import { BufferLogger } from '@akohn/dashql/platform/logger/logger';
55
+ import { setupWebHyperDB } from '@akohn/dashql/platform/hyperdb/hyperdb_web';
56
+ import { migrateStorage } from '@akohn/dashql/platform/storage/storage_migration';
57
+ import { openPageStorage } from '@akohn/dashql/platform/storage/page_storage';
58
+ import { createWorkbookResultFiles } from '@akohn/dashql/platform/workbook/workbook_result_files';
59
+ import { WebHttpClient } from '@akohn/dashql/platform/web_http_client';
60
+ import { createEmbeddedChannelConnector } from '@akohn/dashql/runtime/embedded_channels';
61
+ import { createRuntime } from '@akohn/dashql/runtime';
62
+ import { FRAME_UPDATE_SCHEDULER } from '@akohn/dashql/runtime/store/update_scheduler';
63
+ import { createRuntimeArchives } from '@akohn/dashql/runtime/workbook_archives';
64
+ import { RuntimeContextProvider } from '@akohn/dashql-react/hooks';
65
+ import { LoggerContext } from '@akohn/dashql-react/logger';
66
+ import { DashQLCoreProvider, useDashQLCore, useDashQLCoreSetup } from '@akohn/dashql-react/platform/core_provider';
67
+ import { EmbeddedDatabaseProvider, useEmbeddedDatabaseSetup } from '@akohn/dashql-react/platform/embedded_database_provider';
68
+ import { usePageRuntime } from '@akohn/dashql-react/platform/page_runtime';
69
+
70
+ const HYPERDB = {
71
+ engine: hyperdbEngineUrl, // hyperdb-wasm/dist/hyperdb-wasm.js
72
+ wasm: hyperdbWasmUrl, // hyperdb-wasm/dist/hyperdb-wasm.wasm
73
+ worker: hyperdbWorkerUrl, // hyperdb-wasm/dist/browser_worker.js
74
+ workerBridge: '/hyperdb_worker_bridge.js',
75
+ };
76
+ const logger = new BufferLogger();
77
+
78
+ export const Page = () => (
79
+ <LoggerContext.Provider value={logger}>
80
+ <DashQLCoreProvider wasmUrl={coreWasm}>
81
+ <EmbeddedDatabaseProvider setupDatabase={(context, logger, progress, options) => setupWebHyperDB(context, logger, HYPERDB, progress, options)}>
82
+ <Console />
83
+ </EmbeddedDatabaseProvider>
84
+ </DashQLCoreProvider>
85
+ </LoggerContext.Provider>
86
+ );
87
+
88
+ function Console() {
89
+ const setupCore = useDashQLCoreSetup();
90
+ const core = useDashQLCore();
91
+ // Migrate the storage before anything reads it, a fresh one too, then open it
92
+ const [storage, setStorage] = React.useState<Awaited<ReturnType<typeof openPageStorage>> | null>(null);
93
+ React.useEffect(() => {
94
+ void migrateStorage(logger, setupCore).then(async () => setStorage(await openPageStorage(await setupCore('storage'), logger)));
95
+ }, [setupCore]);
96
+ if (core == null || storage == null) return <Loading />;
97
+ return <ConsoleRuntime core={core} storage={storage} />;
98
+ }
99
+
100
+ function ConsoleRuntime(props: { core: DashQL; storage: StorageBackend }) {
101
+ // Null only outside of an EmbeddedDatabaseProvider
102
+ const database = useEmbeddedDatabaseSetup()!;
103
+ const runtime = usePageRuntime(() => createRuntime({
104
+ logger,
105
+ scheduler: FRAME_UPDATE_SCHEDULER,
106
+ core: props.core,
107
+ storage: props.storage,
108
+ http: new WebHttpClient(),
109
+ channels: createEmbeddedChannelConnector(database),
110
+ computeDatabase: () => database('compute'),
111
+ results: createWorkbookResultFiles(),
112
+ archives: handles => createRuntimeArchives(handles, database),
113
+ settings: { capabilities: [] },
114
+ }));
115
+ return <RuntimeContextProvider value={runtime}>{/* the hooks and models of the console */}</RuntimeContextProvider>;
116
+ }
117
+ ```
118
+
119
+ Only one tab of an origin may write its storage: `AppOwnership` of `@akohn/dashql/platform/app_ownership` holds a Web
120
+ Lock for the tab and hands over to another one. `settings.capabilities` turns off the extensions of SQL that the
121
+ host doesn't offer ([capabilities.md](../../docs/design/capabilities.md)). The OAuth flow of a Salesforce connection is
122
+ not in the packages yet.
123
+
37
124
  How the layers fit, the runtime, the models and the components, is described in
38
125
  [dashql_runtime.md](../../docs/design/dashql_runtime.md) and
39
126
  [writing_components.md](../../docs/agents/writing_components.md).
@@ -20,7 +20,6 @@ export interface DataTableProps {
20
20
  model: ComputationModel;
21
21
  maxRows?: number;
22
22
  columnHeader?: TableColumnHeader;
23
- cellBackground?: string;
24
23
  onShowTable?: () => void;
25
24
  onShowMoreRows?: () => void;
26
25
  onShowFewerRows?: () => void;
@@ -33,6 +32,8 @@ export interface DataTableProps {
33
32
  type Props = DataTableProps;
34
33
  export declare const COLUMN_HEADER_HEIGHT = 32;
35
34
  export declare const ROW_HEIGHT = 26;
36
- export declare function computeGridHeight(baseRowCount: number, visibleRowCount: number, headerHeight: number, scrollbarHeight: number, fitHeight: boolean, maxHeight?: number, measuredHeight?: number, maxRows?: number): number;
37
- export declare function fittingRowCount(height: number): number;
35
+ export declare const TOUCH_ROW_HEIGHT = 36;
36
+ export declare function useDataTableRowHeight(): number;
37
+ export declare function computeGridHeight(baseRowCount: number, visibleRowCount: number, headerHeight: number, scrollbarHeight: number, fitHeight: boolean, maxHeight?: number, measuredHeight?: number, maxRows?: number, rowHeight?: number): number;
38
+ export declare function fittingRowCount(height: number, rowHeight?: number): number;
38
39
  export declare const DataTable: React.MemoExoticComponent<(props: Props) => React.JSX.Element | null>;
@@ -8,12 +8,14 @@ import { useObservedSize } from "../size_observer.js";
8
8
  import { useLogger } from "../../logger.js";
9
9
  import { DataCell } from "./data_table_cell_data.js";
10
10
  import { useScrollbarHeight, useScrollbarsOverlay } from "../../dom/scrollbar.js";
11
+ import { useMediaQuery } from "../../dom/media_query.js";
11
12
  import { useDataTableOrdering } from "./data_table_ordering.js";
12
13
  import { useDataTablePortalContainers } from "./data_table_portals.js";
13
14
  import { useDataTableColumnResize } from "./data_table_column_resize.js";
14
15
  import { DataTableStickyColumn, DataTableStickyHeaders } from "./data_table_sticky_views.js";
15
16
  import { DataTableFocusStore } from "./data_table_focus.js";
16
17
  import { useDataTableWindow } from "./data_table_window.js";
18
+ import { DataTableRowDetail, rowDetailOf } from "./data_table_row_detail.js";
17
19
  import { peekFormat } from "./format_peek.js";
18
20
  import * as React from "react";
19
21
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -28,23 +30,27 @@ var COLUMN_HEADER_HEIGHT = 32;
28
30
  var COLUMN_HEADER_PLOTS_HEIGHT = 76;
29
31
  var COLUMN_HEADER_PLOTS_COLLAPSED_HEIGHT = 18;
30
32
  var ROW_HEIGHT = 26;
33
+ var TOUCH_ROW_HEIGHT = 36;
34
+ function useDataTableRowHeight() {
35
+ return useMediaQuery("(pointer: coarse)") ? 36 : 26;
36
+ }
31
37
  var MORE_ROWS_HEIGHT = 24;
32
38
  var GRID_OVERSCAN_COUNT = 10;
33
- var NOOP_BRUSHING = () => {};
34
- function computeGridHeight(baseRowCount, visibleRowCount, headerHeight, scrollbarHeight, fitHeight, maxHeight, measuredHeight = 0, maxRows) {
35
- const contentHeight = headerHeight + visibleRowCount * 26 + scrollbarHeight;
36
- if (fitHeight) return Math.min(headerHeight + (maxRows == null ? baseRowCount : Math.min(baseRowCount, maxRows)) * 26 + scrollbarHeight, maxHeight ?? Number.POSITIVE_INFINITY);
39
+ function computeGridHeight(baseRowCount, visibleRowCount, headerHeight, scrollbarHeight, fitHeight, maxHeight, measuredHeight = 0, maxRows, rowHeight = 26) {
40
+ const contentHeight = headerHeight + visibleRowCount * rowHeight + scrollbarHeight;
41
+ if (fitHeight) return Math.min(headerHeight + (maxRows == null ? baseRowCount : Math.min(baseRowCount, maxRows)) * rowHeight + scrollbarHeight, maxHeight ?? Number.POSITIVE_INFINITY);
37
42
  return maxRows != null ? contentHeight : Math.max(measuredHeight, MIN_GRID_HEIGHT);
38
43
  }
39
- function fittingRowCount(height) {
40
- return Math.max(1, Math.ceil((height - 32) / 26));
44
+ function fittingRowCount(height, rowHeight = 26) {
45
+ return Math.max(1, Math.ceil((height - 32) / rowHeight));
41
46
  }
42
47
  var DataTable = React.memo((props) => {
43
48
  const tables = useComputationTables(props.model.computation, props.model.tables);
44
49
  if (tables.dataTable == null) return null;
45
50
  return /* @__PURE__ */ jsx(DataTableGrid, {
46
51
  ...props,
47
- dataTable: tables.dataTable
52
+ dataTable: tables.dataTable,
53
+ matchingRows: tables.matchingRows
48
54
  });
49
55
  });
50
56
  function DataTableGrid(props) {
@@ -53,7 +59,7 @@ function DataTableGrid(props) {
53
59
  const summaryTables = props.model.tables;
54
60
  const dispatchComputation = props.model.dispatch;
55
61
  const dataTable = props.dataTable;
56
- const matchingRows = useComputationTables(computationState, summaryTables).matchingRows;
62
+ const matchingRows = props.matchingRows;
57
63
  const { tableAggregation, columnAggregates, filteredColumnAggregates, columnGroups } = computationState;
58
64
  const dataTableHandle = computationState.dataTable;
59
65
  const summaries = React.useMemo(() => resolveSummaries({
@@ -87,6 +93,7 @@ function DataTableGrid(props) {
87
93
  });
88
94
  const { window: rowWindow, rows: totalRowCount, error: rowsError, retry: retryRows } = useDataTableWindow(props.model, renderedCells.rowStart, renderedCells.rowStop);
89
95
  const readRows = props.model.readRows;
96
+ const rowHeight = useDataTableRowHeight();
90
97
  const dataRowCount = props.maxRows != null ? Math.min(totalRowCount, props.maxRows) : totalRowCount;
91
98
  const hiddenRowCount = totalRowCount - dataRowCount;
92
99
  const showFewerRows = hiddenRowCount === 0 ? props.onShowFewerRows : void 0;
@@ -153,6 +160,32 @@ function DataTableGrid(props) {
153
160
  dataRowCount,
154
161
  logger
155
162
  ]);
163
+ const [rowDetail, setRowDetail] = React.useState(null);
164
+ const showRow = React.useCallback((visibleRow) => {
165
+ if (visibleRow < 0 || visibleRow >= dataRowCount) return;
166
+ const detail = rowWindow == null ? null : rowDetailOf(rowWindow.table, rowWindow.formatter, gridLayout, visibleRow - rowWindow.offset, visibleRow);
167
+ if (detail != null) {
168
+ setRowDetail(detail);
169
+ return;
170
+ }
171
+ readRows(visibleRow, 1).then((result) => {
172
+ const formatter = new ArrowTableFormatter(result.table.schema, result.table.batches, logger);
173
+ const read = rowDetailOf(result.table, formatter, gridLayout, visibleRow - result.offset, visibleRow);
174
+ if (read != null) setRowDetail(read);
175
+ }, (error) => logger.warn("Failed to read a row", { error: stringifyError(error) }, "data_table"));
176
+ }, [
177
+ rowWindow,
178
+ gridLayout,
179
+ readRows,
180
+ dataRowCount,
181
+ logger
182
+ ]);
183
+ const onClickRowHeader = React.useCallback((event) => {
184
+ showRow(Number.parseInt(event.currentTarget.dataset["visibleRow"]));
185
+ }, [showRow]);
186
+ const navigateRow = React.useCallback((delta) => {
187
+ if (rowDetail != null) showRow(rowDetail.visibleRow + delta);
188
+ }, [rowDetail, showRow]);
156
189
  const gridData = React.useMemo(() => ({
157
190
  window: rowWindow,
158
191
  gridLayout,
@@ -161,6 +194,7 @@ function DataTableGrid(props) {
161
194
  onMouseEnter: onMouseEnterCell,
162
195
  onMouseLeave: onMouseLeaveCell,
163
196
  onClick: onClickCell,
197
+ onClickRowHeader,
164
198
  focus: focusStore,
165
199
  rightmostVisibleColumn: gridLayout.columnCount - 1,
166
200
  matchingRows,
@@ -176,7 +210,8 @@ function DataTableGrid(props) {
176
210
  focusStore,
177
211
  onMouseEnterCell,
178
212
  onMouseLeaveCell,
179
- onClickCell
213
+ onClickCell,
214
+ onClickRowHeader
180
215
  ]);
181
216
  const onCellsRendered = React.useCallback((_visibleCells, allCells) => {
182
217
  setRenderedCells((prev) => {
@@ -195,7 +230,7 @@ function DataTableGrid(props) {
195
230
  const scrollbarHeight = useScrollbarHeight();
196
231
  const scrollbarsOverlay = useScrollbarsOverlay();
197
232
  const horizontalScrollbarHeight = totalColumnsWidth > gridContainerWidth && !(scrollbarsOverlay && hasFooterRow) ? scrollbarHeight : 0;
198
- const gridContainerHeight = props.fillHeight ? gridContainerSize?.height ?? 0 : computeGridHeight(totalRowCount, dataRowCount, headerHeight, horizontalScrollbarHeight, props.fitHeight ?? false, props.maxHeight, gridContainerSize?.height ?? 0, props.maxRows);
233
+ const gridContainerHeight = props.fillHeight ? gridContainerSize?.height ?? 0 : computeGridHeight(totalRowCount, dataRowCount, headerHeight, horizontalScrollbarHeight, props.fitHeight ?? false, props.maxHeight, gridContainerSize?.height ?? 0, props.maxRows, rowHeight);
199
234
  const firstRenderedColumn = gridLayout.columnCount > 1 ? Math.max(1, Math.min(renderedCells.columnStart, gridLayout.columnCount - 1)) : 1;
200
235
  const lastRenderedColumn = gridLayout.columnCount > 1 ? Math.max(firstRenderedColumn, Math.min(renderedCells.columnStop, gridLayout.columnCount - 1)) : 0;
201
236
  const renderedColumnCount = Math.max(0, lastRenderedColumn - firstRenderedColumn + 1);
@@ -231,11 +266,9 @@ function DataTableGrid(props) {
231
266
  selectionEpoch,
232
267
  dataSearchRequestId,
233
268
  crossFilters,
234
- isVisible: true,
235
269
  rightmostVisibleColumn: gridLayout.columnCount - 1,
236
270
  onRequestFilteredColumnAggregation: requestFilteredColumnAggregation,
237
271
  onHistogramFilter: histogramFilter,
238
- onBrushingChange: NOOP_BRUSHING,
239
272
  onMostFrequentValueFilter: mostFrequentValueFilter
240
273
  }), [
241
274
  gridLayout,
@@ -253,17 +286,14 @@ function DataTableGrid(props) {
253
286
  ]);
254
287
  const portalContainers = useDataTablePortalContainers(gridApi);
255
288
  const columnResize = useDataTableColumnResize(gridApi, gridLayout, dataTable, setResizedColumnWidths);
256
- const totalDataHeight = dataRowCount * 26;
289
+ const totalDataHeight = dataRowCount * rowHeight;
257
290
  return /* @__PURE__ */ jsxs("div", {
258
291
  className: classNames(root, props.className, {
259
292
  [root_compact]: props.compact,
260
293
  [root_more_rows]: hasFooterRow
261
294
  }),
262
295
  "data-electron-drag-region": "false",
263
- style: {
264
- ...props.cellBackground ? { "--data_table_bg": props.cellBackground } : {},
265
- ...props.fitHeight ? { height: gridContainerHeight + footerRowCount * 23 } : {}
266
- },
296
+ style: { ...props.fitHeight ? { height: gridContainerHeight + footerRowCount * 23 } : {} },
267
297
  children: [
268
298
  /* @__PURE__ */ jsxs("div", {
269
299
  className: grid_container,
@@ -280,7 +310,7 @@ function DataTableGrid(props) {
280
310
  columnCount: gridLayout.columnCount,
281
311
  columnWidth: getColumnWidth,
282
312
  rowCount: dataRowCount,
283
- rowHeight: 26,
313
+ rowHeight,
284
314
  onCellsRendered,
285
315
  overscanCount: GRID_OVERSCAN_COUNT,
286
316
  cellComponent: DataCell,
@@ -306,6 +336,7 @@ function DataTableGrid(props) {
306
336
  }),
307
337
  /* @__PURE__ */ jsx(DataTableStickyColumn, {
308
338
  container: portalContainers?.data ?? null,
339
+ rowHeight,
309
340
  firstColumnWidth,
310
341
  totalDataHeight,
311
342
  startRow: Math.max(0, renderedCells.rowStart),
@@ -338,6 +369,12 @@ function DataTableGrid(props) {
338
369
  dataRow: cellDetail?.visibleRow ?? 0,
339
370
  maxRow: dataRowCount - 1,
340
371
  onNavigate: onNavigateCell
372
+ }),
373
+ rowDetail != null && /* @__PURE__ */ jsx(DataTableRowDetail, {
374
+ detail: rowDetail,
375
+ rowCount: dataRowCount,
376
+ onNavigate: navigateRow,
377
+ onClose: () => setRowDetail(null)
341
378
  })
342
379
  ]
343
380
  });
@@ -375,4 +412,4 @@ function TableFooterRow(props) {
375
412
  children: props.label
376
413
  });
377
414
  }
378
- export { COLUMN_HEADER_HEIGHT, DataTable, ROW_HEIGHT, TableColumnHeader, computeGridHeight, fittingRowCount, peekFormat, resolveComputationTables, useComputationTables };
415
+ export { COLUMN_HEADER_HEIGHT, DataTable, ROW_HEIGHT, TOUCH_ROW_HEIGHT, TableColumnHeader, computeGridHeight, fittingRowCount, peekFormat, resolveComputationTables, useComputationTables, useDataTableRowHeight };
@@ -17,5 +17,6 @@ export interface DataCellData {
17
17
  onMouseEnter: (event: React.PointerEvent<HTMLDivElement>) => void;
18
18
  onMouseLeave: (event: React.PointerEvent<HTMLDivElement>) => void;
19
19
  onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
20
+ onClickRowHeader: (event: React.MouseEvent<HTMLDivElement>) => void;
20
21
  }
21
22
  export declare function DataCell(props: CellComponentProps<DataCellData>): React.ReactElement | null;
@@ -51,6 +51,10 @@ function DataCell(props) {
51
51
  return /* @__PURE__ */ jsx("div", {
52
52
  className,
53
53
  style: props.style,
54
+ "data-visible-row": props.rowIndex,
55
+ "data-testid": "data-table-row-number",
56
+ title: "Show the fields of the row",
57
+ onClick: props.onClickRowHeader,
54
58
  children: formatted ?? ""
55
59
  });
56
60
  } else {
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type * as core from '@akohn/dashql';
3
3
  import type { ComputationColumnGroup, ComputationTrackedTask, ComputationVersionValue } from '@akohn/dashql';
4
4
  import { ColumnAggregationVariant, TableAggregation, WithFilterEpoch } from '@akohn/dashql/platform/compute/computation_types';
5
- import { BrushingStateCallback, HistogramFilterCallback } from './histogram_cell.js';
5
+ import { HistogramFilterCallback } from './histogram_cell.js';
6
6
  import { MostFrequentValueFilterCallback } from './mostfrequent_cell.js';
7
7
  import { DataTableLayout } from './data_table_layout.js';
8
8
  export interface HeaderPlotsCellProps {
@@ -19,11 +19,9 @@ export interface HeaderPlotsCellProps {
19
19
  selectionEpoch: ComputationVersionValue;
20
20
  dataSearchRequestId: number | null;
21
21
  crossFilters: core.ComputationCrossFilter[];
22
- isVisible: boolean;
23
22
  rightmostVisibleColumn: number;
24
23
  onRequestFilteredColumnAggregation: (columnId: number) => void;
25
24
  onHistogramFilter: HistogramFilterCallback;
26
- onBrushingChange: BrushingStateCallback;
27
25
  onMostFrequentValueFilter: MostFrequentValueFilterCallback;
28
26
  }
29
27
  declare function HeaderPlotsCellImpl(props: HeaderPlotsCellProps): React.ReactElement;
@@ -23,9 +23,9 @@ function HeaderPlotsCellImpl(props) {
23
23
  filteredColumnAggregationTask = props.filteredColumnAggregationTasks[columnAggregateId] ?? null;
24
24
  filteredColumnAggregationOutdated = props.filteredColumnAggregationOutdated[columnAggregateId] ?? false;
25
25
  }
26
- const { isVisible, onRequestFilteredColumnAggregation } = props;
26
+ const { onRequestFilteredColumnAggregation } = props;
27
27
  React.useEffect(() => {
28
- if (columnAggregateId == -1 || !isVisible || !filteredColumnAggregationOutdated) return;
28
+ if (columnAggregateId == -1 || !filteredColumnAggregationOutdated) return;
29
29
  onRequestFilteredColumnAggregation(columnAggregateId);
30
30
  }, [
31
31
  columnAggregateId,
@@ -33,11 +33,10 @@ function HeaderPlotsCellImpl(props) {
33
33
  filteredColumnAggregationTask,
34
34
  props.selectionEpoch,
35
35
  props.dataSearchRequestId,
36
- isVisible,
37
36
  onRequestFilteredColumnAggregation
38
37
  ]);
39
38
  const isRightmost = props.columnIndex === props.rightmostVisibleColumn;
40
- if (pastFields || !props.isVisible) return /* @__PURE__ */ jsx("div", { style: props.style });
39
+ if (pastFields) return /* @__PURE__ */ jsx("div", { style: props.style });
41
40
  const columnGroupId = props.gridLayout.columnGroupByColumnIndex[props.columnIndex];
42
41
  const columnGroup = props.columnGroups[columnGroupId];
43
42
  const crossFilter = crossFilterOf(props.crossFilters, columnGroupId);
@@ -96,8 +95,7 @@ function HeaderPlotsCellImpl(props) {
96
95
  columnIndex: props.columnIndex,
97
96
  columnAggregate: columnAggregate.value,
98
97
  selection: histogramSelection,
99
- onFilter: props.onHistogramFilter,
100
- onBrushingChange: props.onBrushingChange
98
+ onFilter: props.onHistogramFilter
101
99
  });
102
100
  case STRING_COLUMN: return /* @__PURE__ */ jsx(MostFrequentCell, {
103
101
  className: classNames(plots_cell, { [plots_cell_rightmost]: isRightmost }),
@@ -0,0 +1,22 @@
1
+ import * as arrow from 'apache-arrow';
2
+ import * as React from 'react';
3
+ import { type ArrowTableFormatter } from '@akohn/dashql/platform/compute/arrow_formatter';
4
+ import type { DataTableLayout } from './data_table_layout.js';
5
+ export interface RowDetailField {
6
+ name: string;
7
+ type: string;
8
+ value: string | null;
9
+ }
10
+ export interface RowDetail {
11
+ visibleRow: number;
12
+ fields: RowDetailField[];
13
+ }
14
+ export declare function rowDetailOf(table: arrow.Table, formatter: ArrowTableFormatter, layout: DataTableLayout, row: number, visibleRow: number): RowDetail | null;
15
+ interface Props {
16
+ detail: RowDetail;
17
+ rowCount: number;
18
+ onNavigate: (delta: number) => void;
19
+ onClose: () => void;
20
+ }
21
+ export declare function DataTableRowDetail(props: Props): React.ReactElement;
22
+ export {};
@@ -0,0 +1,68 @@
1
+ import { field, fields, name, type, value, value_null } from "./data_table_row_detail.module.js";
2
+ import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
3
+ import { Sheet } from "../sheet.js";
4
+ import { ChevronDownIcon, ChevronUpIcon } from "../symbol_icon.js";
5
+ import "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { dataTypeToString } from "@akohn/dashql/platform/compute/arrow_formatter";
8
+ function rowDetailOf(table, formatter, layout, row, visibleRow) {
9
+ if (row < 0 || row >= table.numRows) return null;
10
+ const fields = [];
11
+ for (let column = 1; column < layout.arrowFieldByColumnIndex.length; ++column) {
12
+ const fieldId = layout.arrowFieldByColumnIndex[column];
13
+ const field = table.schema.fields[fieldId];
14
+ if (field == null) continue;
15
+ fields.push({
16
+ name: field.name,
17
+ type: dataTypeToString(field.type),
18
+ value: formatter.getValue(row, fieldId)
19
+ });
20
+ }
21
+ return {
22
+ visibleRow,
23
+ fields
24
+ };
25
+ }
26
+ function DataTableRowDetail(props) {
27
+ const { detail, rowCount, onNavigate } = props;
28
+ return /* @__PURE__ */ jsx(Sheet, {
29
+ title: `Row ${detail.visibleRow + 1} of ${rowCount}`,
30
+ onClose: props.onClose,
31
+ "data-testid": "data-table-row-detail",
32
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconButton, {
33
+ size: ButtonSize.Small,
34
+ variant: ButtonVariant.Invisible,
35
+ "aria-label": "Previous row",
36
+ "data-testid": "data-table-row-previous",
37
+ disabled: detail.visibleRow <= 0,
38
+ onClick: () => onNavigate(-1),
39
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, { size: 16 })
40
+ }), /* @__PURE__ */ jsx(IconButton, {
41
+ size: ButtonSize.Small,
42
+ variant: ButtonVariant.Invisible,
43
+ "aria-label": "Next row",
44
+ "data-testid": "data-table-row-next",
45
+ disabled: detail.visibleRow >= rowCount - 1,
46
+ onClick: () => onNavigate(1),
47
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
48
+ })] }),
49
+ children: /* @__PURE__ */ jsx("dl", {
50
+ className: fields,
51
+ children: detail.fields.map((field$1, index) => /* @__PURE__ */ jsxs("div", {
52
+ className: field,
53
+ "data-testid": "data-table-row-field",
54
+ children: [/* @__PURE__ */ jsxs("dt", {
55
+ className: name,
56
+ children: [field$1.name, /* @__PURE__ */ jsx("span", {
57
+ className: type,
58
+ children: field$1.type
59
+ })]
60
+ }), /* @__PURE__ */ jsx("dd", {
61
+ className: field$1.value == null ? `${value} ${value_null}` : value,
62
+ children: field$1.value ?? "null"
63
+ })]
64
+ }, index))
65
+ })
66
+ });
67
+ }
68
+ export { DataTableRowDetail, rowDetailOf };
@@ -0,0 +1,7 @@
1
+ var fields = "dashql_fields_jOg5bq";
2
+ var field = "dashql_field_D9hR7-";
3
+ var name = "dashql_name_GCEkkk";
4
+ var type = "dashql_type_9zm-Uu";
5
+ var value = "dashql_value_ZkMNpe";
6
+ var value_null = "dashql_value_null_Ypwy0D";
7
+ export { field, fields, name, type, value, value_null };
@@ -25,6 +25,7 @@ export declare const DataTableStickyHeaders: React.MemoExoticComponent<(props: S
25
25
  interface StickyColumnProps {
26
26
  container: DataTablePortalContainers['data'] | null;
27
27
  firstColumnWidth: number;
28
+ rowHeight: number;
28
29
  totalDataHeight: number;
29
30
  startRow: number;
30
31
  stopRow: number;
@@ -137,10 +137,10 @@ var DataTableStickyColumn = React.memo((props) => {
137
137
  return /* @__PURE__ */ jsx("div", {
138
138
  style: {
139
139
  position: "absolute",
140
- top: rowIndex * 26,
140
+ top: rowIndex * props.rowHeight,
141
141
  left: 0,
142
142
  width: props.firstColumnWidth,
143
- height: 26,
143
+ height: props.rowHeight,
144
144
  pointerEvents: "auto"
145
145
  },
146
146
  children: /* @__PURE__ */ jsx(StickyRowHeaderCell, {
@@ -149,7 +149,7 @@ var DataTableStickyColumn = React.memo((props) => {
149
149
  columnIndex: 0,
150
150
  style: {
151
151
  width: props.firstColumnWidth,
152
- height: 26
152
+ height: props.rowHeight
153
153
  },
154
154
  ...props.gridData,
155
155
  hideRowHeader: false
@@ -14,7 +14,6 @@ interface HistogramBrushOptions {
14
14
  selection: [number, number] | null;
15
15
  onBrushUpdate: (event: d3.D3BrushEvent<unknown>) => void;
16
16
  onClear: () => void;
17
- onBrushingChange?: (isBrushing: boolean) => void;
18
17
  }
19
18
  export declare function useHistogramBrush(options: HistogramBrushOptions): {
20
19
  brushContainer: React.RefObject<SVGGElement | null>;
@@ -34,7 +34,7 @@ function useHistogramBrush(options) {
34
34
  const brushBehavior = React.useRef(null);
35
35
  const syncingSelection = React.useRef(false);
36
36
  const settledBrushUpdates = React.useRef(new SettledBrushUpdates());
37
- const { xScale, height, selection, onBrushUpdate, onClear, onBrushingChange } = options;
37
+ const { xScale, height, selection, onBrushUpdate, onClear } = options;
38
38
  const onBrushUpdateRef = React.useRef(onBrushUpdate);
39
39
  onBrushUpdateRef.current = onBrushUpdate;
40
40
  const selectionRef = React.useRef(selection);
@@ -42,8 +42,7 @@ function useHistogramBrush(options) {
42
42
  const onBrushStart = React.useCallback(() => {
43
43
  if (syncingSelection.current) return;
44
44
  settledBrushUpdates.current.cancel();
45
- onBrushingChange?.(true);
46
- }, [onBrushingChange]);
45
+ }, []);
47
46
  const onBrushMove = React.useCallback((event) => {
48
47
  if (syncingSelection.current) return;
49
48
  settledBrushUpdates.current.schedule(event, (pending) => onBrushUpdateRef.current(pending));
@@ -51,8 +50,7 @@ function useHistogramBrush(options) {
51
50
  const onBrushEnd = React.useCallback((event) => {
52
51
  if (syncingSelection.current) return;
53
52
  settledBrushUpdates.current.flush(event, onBrushUpdate);
54
- onBrushingChange?.(false);
55
- }, [onBrushUpdate, onBrushingChange]);
53
+ }, [onBrushUpdate]);
56
54
  const onBrushStartRef = React.useRef(onBrushStart);
57
55
  const onBrushMoveRef = React.useRef(onBrushMove);
58
56
  const onBrushEndRef = React.useRef(onBrushEnd);
@@ -3,7 +3,6 @@ import { ColumnAggregationVariant, OrdinalColumnAggregation, TableAggregation, W
3
3
  export { NULL_SYMBOL } from './histogram_bars.js';
4
4
  export { SettledBrushUpdates } from './histogram_brush.js';
5
5
  export type HistogramFilterCallback = (table: TableAggregation, columnId: number, column: OrdinalColumnAggregation, filter: [number, number] | null) => void;
6
- export type BrushingStateCallback = (isBrushing: boolean) => void;
7
6
  interface HistogramCellProps {
8
7
  className?: string;
9
8
  style?: React.CSSProperties;
@@ -13,7 +12,6 @@ interface HistogramCellProps {
13
12
  filteredColumnAggregation: WithFilterEpoch<ColumnAggregationVariant> | null;
14
13
  selection: [number, number] | null;
15
14
  onFilter: HistogramFilterCallback;
16
- onBrushingChange?: BrushingStateCallback;
17
15
  }
18
16
  declare function HistogramCellImpl(props: HistogramCellProps): React.ReactElement;
19
17
  export declare const HistogramCell: React.MemoExoticComponent<typeof HistogramCellImpl>;
@@ -93,8 +93,7 @@ function HistogramCellImpl(props) {
93
93
  height,
94
94
  selection: brushSelection,
95
95
  onBrushUpdate,
96
- onClear: clearFilter,
97
- onBrushingChange: props.onBrushingChange
96
+ onClear: clearFilter
98
97
  });
99
98
  const nullsPadding = (nullsWidth - nullsXScale.bandwidth()) / 2;
100
99
  const hasFilteredAggregate = props.filteredColumnAggregation != null && props.filteredColumnAggregation.type === ORDINAL_COLUMN;