@akohn/dashql-react 0.0.0-stage → 0.0.20-dev.664.g9e89b805d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/NOTICE +66 -0
- package/README.md +46 -2
- package/dist/_virtual/_vite/preload-helper.js +100 -0
- package/dist/brand/brand.d.ts +13 -0
- package/dist/brand/brand.js +14 -0
- package/dist/brand/landing_backdrop.d.ts +56 -0
- package/dist/brand/landing_backdrop.js +1019 -0
- package/dist/brand/wobble_morph.d.ts +54 -0
- package/dist/brand/wobble_morph.js +439 -0
- package/dist/components/action_list.d.ts +31 -0
- package/dist/components/action_list.js +63 -0
- package/dist/components/action_list.module.js +11 -0
- package/dist/components/anchored_overlay.d.ts +28 -0
- package/dist/components/anchored_overlay.js +93 -0
- package/dist/components/button.d.ts +42 -0
- package/dist/components/button.js +97 -0
- package/dist/components/button.module.js +20 -0
- package/dist/components/button_group.d.ts +7 -0
- package/dist/components/button_group.js +18 -0
- package/dist/components/button_group.module.js +3 -0
- package/dist/components/card_placeholder.d.ts +9 -0
- package/dist/components/card_placeholder.js +39 -0
- package/dist/components/card_placeholder.module.js +6 -0
- package/dist/components/clipboard.d.ts +19 -0
- package/dist/components/clipboard.js +54 -0
- package/dist/components/data_table/computation_tables.d.ts +12 -0
- package/dist/components/data_table/computation_tables.js +42 -0
- package/dist/components/data_table/data_table.d.ts +38 -0
- package/dist/components/data_table/data_table.js +378 -0
- package/dist/components/data_table/data_table.module.js +41 -0
- package/dist/components/data_table/data_table_cell.d.ts +7 -0
- package/dist/components/data_table/data_table_cell.js +9 -0
- package/dist/components/data_table/data_table_cell_data.d.ts +21 -0
- package/dist/components/data_table/data_table_cell_data.js +99 -0
- package/dist/components/data_table/data_table_cell_header_name.d.ts +17 -0
- package/dist/components/data_table/data_table_cell_header_name.js +73 -0
- package/dist/components/data_table/data_table_cell_header_plots.d.ts +31 -0
- package/dist/components/data_table/data_table_cell_header_plots.js +122 -0
- package/dist/components/data_table/data_table_colors.d.ts +19 -0
- package/dist/components/data_table/data_table_colors.js +27 -0
- package/dist/components/data_table/data_table_column_resize.d.ts +21 -0
- package/dist/components/data_table/data_table_column_resize.js +121 -0
- package/dist/components/data_table/data_table_focus.d.ts +15 -0
- package/dist/components/data_table/data_table_focus.js +53 -0
- package/dist/components/data_table/data_table_layout.d.ts +18 -0
- package/dist/components/data_table/data_table_layout.js +103 -0
- package/dist/components/data_table/data_table_ordering.d.ts +9 -0
- package/dist/components/data_table/data_table_ordering.js +39 -0
- package/dist/components/data_table/data_table_portals.d.ts +9 -0
- package/dist/components/data_table/data_table_portals.js +29 -0
- package/dist/components/data_table/data_table_sticky_views.d.ts +34 -0
- package/dist/components/data_table/data_table_sticky_views.js +161 -0
- package/dist/components/data_table/data_table_window.d.ts +18 -0
- package/dist/components/data_table/data_table_window.js +118 -0
- package/dist/components/data_table/format_peek.d.ts +2 -0
- package/dist/components/data_table/format_peek.js +17 -0
- package/dist/components/data_table/histogram_bars.d.ts +36 -0
- package/dist/components/data_table/histogram_bars.js +100 -0
- package/dist/components/data_table/histogram_brush.d.ts +23 -0
- package/dist/components/data_table/histogram_brush.js +107 -0
- package/dist/components/data_table/histogram_cell.d.ts +19 -0
- package/dist/components/data_table/histogram_cell.js +325 -0
- package/dist/components/data_table/histogram_cell.module.js +9 -0
- package/dist/components/data_table/histogram_label.d.ts +1 -0
- package/dist/components/data_table/histogram_label.js +7 -0
- package/dist/components/data_table/memo_props.d.ts +1 -0
- package/dist/components/data_table/memo_props.js +17 -0
- package/dist/components/data_table/mostfrequent_cell.d.ts +17 -0
- package/dist/components/data_table/mostfrequent_cell.js +316 -0
- package/dist/components/data_table/mostfrequent_cell.module.js +10 -0
- package/dist/components/data_table/use_cross_filters.d.ts +14 -0
- package/dist/components/data_table/use_cross_filters.js +47 -0
- package/dist/components/deferred.d.ts +11 -0
- package/dist/components/deferred.js +41 -0
- package/dist/components/deferred.module.js +5 -0
- package/dist/components/error_boundary.d.ts +18 -0
- package/dist/components/error_boundary.js +15 -0
- package/dist/components/graph.module.js +15 -0
- package/dist/components/graph_port.d.ts +10 -0
- package/dist/components/graph_port.js +34 -0
- package/dist/components/inspector_overlay.d.ts +32 -0
- package/dist/components/inspector_overlay.js +72 -0
- package/dist/components/inspector_overlay.module.js +18 -0
- package/dist/components/json/json_arrow_symbol.d.ts +4 -0
- package/dist/components/json/json_arrow_symbol.js +25 -0
- package/dist/components/json/json_copy_button.d.ts +11 -0
- package/dist/components/json/json_copy_button.js +61 -0
- package/dist/components/json/json_ellipsis_symbol.d.ts +7 -0
- package/dist/components/json/json_ellipsis_symbol.js +11 -0
- package/dist/components/json/json_item_count.d.ts +5 -0
- package/dist/components/json/json_item_count.js +12 -0
- package/dist/components/json/json_key_name.d.ts +6 -0
- package/dist/components/json/json_key_name.js +40 -0
- package/dist/components/json/json_key_values.d.ts +12 -0
- package/dist/components/json/json_key_values.js +99 -0
- package/dist/components/json/json_literal.d.ts +8 -0
- package/dist/components/json/json_literal.js +140 -0
- package/dist/components/json/json_nested_close.d.ts +11 -0
- package/dist/components/json/json_nested_close.js +31 -0
- package/dist/components/json/json_nested_open.d.ts +18 -0
- package/dist/components/json/json_nested_open.js +150 -0
- package/dist/components/json/json_nested_state.d.ts +14 -0
- package/dist/components/json/json_nested_state.js +28 -0
- package/dist/components/json/json_tool_state.d.ts +18 -0
- package/dist/components/json/json_tool_state.js +46 -0
- package/dist/components/json/json_value.d.ts +10 -0
- package/dist/components/json/json_value.js +46 -0
- package/dist/components/json/json_view.d.ts +14 -0
- package/dist/components/json/json_view.js +37 -0
- package/dist/components/json/json_view.module.js +41 -0
- package/dist/components/json/json_view_state.d.ts +14 -0
- package/dist/components/json/json_view_state.js +32 -0
- package/dist/components/json/unique_key.d.ts +1 -0
- package/dist/components/json/unique_key.js +8 -0
- package/dist/components/keyvalue_list.d.ts +25 -0
- package/dist/components/keyvalue_list.js +106 -0
- package/dist/components/keyvalue_list.module.js +15 -0
- package/dist/components/name_input.d.ts +11 -0
- package/dist/components/name_input.js +51 -0
- package/dist/components/overlay.d.ts +53 -0
- package/dist/components/overlay.js +183 -0
- package/dist/components/overlay.module.js +32 -0
- package/dist/components/panel_resize_handle.d.ts +12 -0
- package/dist/components/panel_resize_handle.js +39 -0
- package/dist/components/portal.d.ts +8 -0
- package/dist/components/portal.js +53 -0
- package/dist/components/progress_bar.d.ts +7 -0
- package/dist/components/progress_bar.js +21 -0
- package/dist/components/progress_bar.module.js +3 -0
- package/dist/components/query_history_viewer.d.ts +33 -0
- package/dist/components/query_history_viewer.js +268 -0
- package/dist/components/query_history_viewer.module.js +7 -0
- package/dist/components/query_profile/engine_profile_view.d.ts +19 -0
- package/dist/components/query_profile/engine_profile_view.js +94 -0
- package/dist/components/query_profile/numeric_limits.d.ts +1 -0
- package/dist/components/query_profile/numeric_limits.js +2 -0
- package/dist/components/query_profile/profile_execution_controller.d.ts +14 -0
- package/dist/components/query_profile/profile_execution_controller.js +56 -0
- package/dist/components/query_profile/profile_fit.d.ts +24 -0
- package/dist/components/query_profile/profile_fit.js +22 -0
- package/dist/components/query_profile/profile_navigation.d.ts +3 -0
- package/dist/components/query_profile/profile_navigation.js +34 -0
- package/dist/components/query_profile/profile_scene.d.ts +64 -0
- package/dist/components/query_profile/profile_scene.js +422 -0
- package/dist/components/query_profile/query_profile_view.d.ts +44 -0
- package/dist/components/query_profile/query_profile_view.js +961 -0
- package/dist/components/query_profile/query_profile_view.module.js +23 -0
- package/dist/components/query_progress/query_profile_overlay.d.ts +7 -0
- package/dist/components/query_progress/query_profile_overlay.js +67 -0
- package/dist/components/query_progress/query_profile_overlay.module.js +6 -0
- package/dist/components/query_progress/query_progress_panel.d.ts +14 -0
- package/dist/components/query_progress/query_progress_panel.js +255 -0
- package/dist/components/query_progress/query_progress_panel.module.js +10 -0
- package/dist/components/query_result/cell_detail_overlay.d.ts +34 -0
- package/dist/components/query_result/cell_detail_overlay.js +277 -0
- package/dist/components/query_result/cell_detail_overlay.module.js +21 -0
- package/dist/components/query_result/query_result_action_menu.d.ts +12 -0
- package/dist/components/query_result/query_result_action_menu.js +62 -0
- package/dist/components/query_result/query_result_action_menu.module.js +2 -0
- package/dist/components/query_result/query_result_details.d.ts +17 -0
- package/dist/components/query_result/query_result_details.js +46 -0
- package/dist/components/query_result/query_result_details.module.js +5 -0
- package/dist/components/query_result/query_result_download_button.d.ts +8 -0
- package/dist/components/query_result/query_result_download_button.js +38 -0
- package/dist/components/query_result/query_result_header.d.ts +21 -0
- package/dist/components/query_result/query_result_header.js +71 -0
- package/dist/components/query_result/query_result_header.module.js +3 -0
- package/dist/components/query_result/query_result_search_controls.d.ts +12 -0
- package/dist/components/query_result/query_result_search_controls.js +141 -0
- package/dist/components/query_result/query_result_search_controls.module.js +7 -0
- package/dist/components/query_result/query_result_toolbar.d.ts +21 -0
- package/dist/components/query_result/query_result_toolbar.js +74 -0
- package/dist/components/query_result/result_table_overlay.d.ts +9 -0
- package/dist/components/query_result/result_table_overlay.js +73 -0
- package/dist/components/query_result/result_table_overlay.module.js +6 -0
- package/dist/components/query_result/use_query_result_search.d.ts +8 -0
- package/dist/components/query_result/use_query_result_search.js +28 -0
- package/dist/components/segmented_control.d.ts +58 -0
- package/dist/components/segmented_control.js +116 -0
- package/dist/components/segmented_control.module.js +17 -0
- package/dist/components/separator.d.ts +21 -0
- package/dist/components/separator.js +79 -0
- package/dist/components/separator.module.js +7 -0
- package/dist/components/size_observer.d.ts +7 -0
- package/dist/components/size_observer.js +57 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +14 -0
- package/dist/components/skeleton.module.js +2 -0
- package/dist/components/spinners.d.ts +8 -0
- package/dist/components/spinners.js +33 -0
- package/dist/components/spinners.module.js +8 -0
- package/dist/components/status_indicator.d.ts +36 -0
- package/dist/components/status_indicator.js +182 -0
- package/dist/components/status_indicator.module.js +3 -0
- package/dist/components/symbol_icon.d.ts +65 -0
- package/dist/components/symbol_icon.js +213 -0
- package/dist/components/tab_header.d.ts +11 -0
- package/dist/components/tab_header.js +55 -0
- package/dist/components/tab_header.module.js +7 -0
- package/dist/components/tag.d.ts +10 -0
- package/dist/components/tag.js +17 -0
- package/dist/components/tag.module.js +4 -0
- package/dist/components/text_field.d.ts +44 -0
- package/dist/components/text_field.js +159 -0
- package/dist/components/text_field.module.js +15 -0
- package/dist/components/text_input.d.ts +25 -0
- package/dist/components/text_input.js +90 -0
- package/dist/components/text_input.module.js +13 -0
- package/dist/components/text_input_action.d.ts +19 -0
- package/dist/components/text_input_action.js +33 -0
- package/dist/components/text_input_action.module.js +2 -0
- package/dist/components/toggle_switch.d.ts +7 -0
- package/dist/components/toggle_switch.js +22 -0
- package/dist/components/toggle_switch.module.js +6 -0
- package/dist/components/tooltip.d.ts +22 -0
- package/dist/components/tooltip.js +139 -0
- package/dist/components/tooltip.module.js +2 -0
- package/dist/components/tree_entry.d.ts +17 -0
- package/dist/components/tree_entry.js +48 -0
- package/dist/components/tree_entry.module.js +9 -0
- package/dist/components/value_list.d.ts +17 -0
- package/dist/components/value_list.js +70 -0
- package/dist/components/value_list.module.js +8 -0
- package/dist/components/vegalite_chart.d.ts +18 -0
- package/dist/components/vegalite_chart.js +151 -0
- package/dist/components/vegalite_chart.module.js +3 -0
- package/dist/components/vegalite_view.d.ts +27 -0
- package/dist/components/vegalite_view.js +248 -0
- package/dist/components/vegalite_view.module.js +5 -0
- package/dist/components/vertical_scroll_shadows.d.ts +14 -0
- package/dist/components/vertical_scroll_shadows.js +55 -0
- package/dist/components/vertical_scroll_shadows.module.js +5 -0
- package/dist/components/vertical_split.d.ts +15 -0
- package/dist/components/vertical_split.js +112 -0
- package/dist/components/vertical_split.module.js +5 -0
- package/dist/components/vertical_tabs.d.ts +36 -0
- package/dist/components/vertical_tabs.js +169 -0
- package/dist/components/vertical_tabs.module.js +23 -0
- package/dist/components/visualization/capped_rows.d.ts +9 -0
- package/dist/components/visualization/capped_rows.js +23 -0
- package/dist/components/visualization/capped_rows.module.js +3 -0
- package/dist/components/visualization/chart_download_button.d.ts +12 -0
- package/dist/components/visualization/chart_download_button.js +41 -0
- package/dist/components/visualization/kpi_view.d.ts +10 -0
- package/dist/components/visualization/kpi_view.js +215 -0
- package/dist/components/visualization/kpi_view.module.js +17 -0
- package/dist/components/visualization/markdown_view.d.ts +17 -0
- package/dist/components/visualization/markdown_view.js +154 -0
- package/dist/components/visualization/markdown_view.module.js +4 -0
- package/dist/components/visualization/result_rows.d.ts +17 -0
- package/dist/components/visualization/result_rows.js +82 -0
- package/dist/components/visualization/vegalite_preview.d.ts +8 -0
- package/dist/components/visualization/vegalite_preview.js +17 -0
- package/dist/components/visualization/vegalite_preview.module.js +2 -0
- package/dist/components/visualization/visualization_dispatch.d.ts +14 -0
- package/dist/components/visualization/visualization_dispatch.js +41 -0
- package/dist/components/visualization/visualization_panel.d.ts +10 -0
- package/dist/components/visualization/visualization_panel.js +37 -0
- package/dist/components/visualization/visualization_panel.module.js +3 -0
- package/dist/dom/anchored_position.d.ts +42 -0
- package/dist/dom/anchored_position.js +255 -0
- package/dist/dom/app_host.d.ts +6 -0
- package/dist/dom/app_host.js +13 -0
- package/dist/dom/calm_frames.d.ts +24 -0
- package/dist/dom/calm_frames.js +96 -0
- package/dist/dom/classnames.d.ts +8 -0
- package/dist/dom/classnames.js +20 -0
- package/dist/dom/download_file.d.ts +1 -0
- package/dist/dom/download_file.js +12 -0
- package/dist/dom/focus.d.ts +29 -0
- package/dist/dom/focus.js +84 -0
- package/dist/dom/graph_edges.d.ts +53 -0
- package/dist/dom/graph_edges.js +450 -0
- package/dist/dom/key_events.d.ts +9 -0
- package/dist/dom/key_events.js +33 -0
- package/dist/dom/media_query.d.ts +2 -0
- package/dist/dom/media_query.js +15 -0
- package/dist/dom/outside_click.d.ts +8 -0
- package/dist/dom/outside_click.js +32 -0
- package/dist/dom/rerender_ref.d.ts +2 -0
- package/dist/dom/rerender_ref.js +11 -0
- package/dist/dom/row_context_menu.d.ts +7 -0
- package/dist/dom/row_context_menu.js +32 -0
- package/dist/dom/scrollbar.d.ts +3 -0
- package/dist/dom/scrollbar.js +23 -0
- package/dist/format/format.d.ts +11 -0
- package/dist/format/format.js +72 -0
- package/dist/format/query_progress_format.d.ts +17 -0
- package/dist/format/query_progress_format.js +69 -0
- package/dist/format/time_format.d.ts +5 -0
- package/dist/format/time_format.js +45 -0
- package/dist/hooks.d.ts +71 -0
- package/dist/hooks.js +302 -0
- package/dist/host.d.ts +10 -0
- package/dist/host.js +12 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +6 -0
- package/dist/models/computation_model.d.ts +14 -0
- package/dist/models/computation_model.js +27 -0
- package/dist/models/query_model.d.ts +12 -0
- package/dist/models/query_model.js +27 -0
- package/dist/models/script_model.d.ts +17 -0
- package/dist/models/script_model.js +69 -0
- package/dist/style.css +4226 -0
- package/dist/svg_symbols.d.ts +2 -0
- package/dist/svg_symbols.js +2 -0
- package/dist/symbols.svg +1197 -0
- package/dist/theme/color_scheme.d.ts +4 -0
- package/dist/theme/color_scheme.js +28 -0
- package/dist/theme/xcode_palette.d.ts +22 -0
- package/dist/theme/xcode_palette.js +4 -0
- package/dist/theme/xcode_palettes.js +41 -0
- package/dist/utils/plan_engine.d.ts +2 -0
- package/dist/utils/plan_engine.js +13 -0
- package/dist/vegalite/vegalite_check.d.ts +1 -0
- package/dist/vegalite/vegalite_check.js +7 -0
- package/dist/vegalite/vegalite_crossfilter.d.ts +54 -0
- package/dist/vegalite/vegalite_crossfilter.js +187 -0
- package/dist/vegalite/vegalite_image.d.ts +16 -0
- package/dist/vegalite/vegalite_image.js +28 -0
- package/dist/vegalite/vegalite_loader.d.ts +7 -0
- package/dist/vegalite/vegalite_loader.js +15 -0
- package/dist/vegalite/vegalite_rows.d.ts +3 -0
- package/dist/vegalite/vegalite_rows.js +17 -0
- package/dist/vegalite/vegalite_theme.d.ts +11 -0
- package/dist/vegalite/vegalite_theme.js +125 -0
- package/fonts/InstrumentSans-Bold.ttf +0 -0
- package/fonts/InstrumentSans-Medium.ttf +0 -0
- package/fonts/InstrumentSans-OFL.txt +93 -0
- package/fonts/InstrumentSans-Regular.ttf +0 -0
- package/fonts/InstrumentSans-SemiBold.ttf +0 -0
- package/fonts/JetBrainsMono-Bold.ttf +0 -0
- package/fonts/JetBrainsMono-Medium.ttf +0 -0
- package/fonts/JetBrainsMono-OFL.txt +93 -0
- package/fonts/JetBrainsMono-Regular.ttf +0 -0
- package/fonts/JetBrainsMono-SemiBold.ttf +0 -0
- package/fonts/fonts.css +61 -0
- package/package.json +43 -4
- package/styles/colors.css +110 -0
- package/styles/flavors/dbcom.css +48 -0
- package/styles/tokens.css +192 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { sticky_column_container, sticky_header_container, sticky_header_row } from "./data_table.module.js";
|
|
2
|
+
import { TableColumnHeader } from "./data_table_cell.js";
|
|
3
|
+
import { ChevronDownIcon, ChevronUpIcon } from "../symbol_icon.js";
|
|
4
|
+
import { HeaderNameCell } from "./data_table_cell_header_name.js";
|
|
5
|
+
import { HeaderPlotsCell } from "./data_table_cell_header_plots.js";
|
|
6
|
+
import { DataCell } from "./data_table_cell_data.js";
|
|
7
|
+
import { arePropsEqualWithStyle } from "./memo_props.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import * as ReactDOM from "react-dom";
|
|
11
|
+
var StickyRowHeaderCell = React.memo(DataCell, arePropsEqualWithStyle);
|
|
12
|
+
var STICKY_ROW_HEADER_ARIA = {
|
|
13
|
+
"aria-colindex": 1,
|
|
14
|
+
role: "gridcell"
|
|
15
|
+
};
|
|
16
|
+
var DataTableStickyHeaders = React.memo((props) => {
|
|
17
|
+
if (props.container == null) return null;
|
|
18
|
+
const renderNameCell = (columnIndex, sticky) => /* @__PURE__ */ jsx(HeaderNameCell, {
|
|
19
|
+
columnIndex,
|
|
20
|
+
style: {
|
|
21
|
+
width: props.getColumnWidth(columnIndex),
|
|
22
|
+
height: 32,
|
|
23
|
+
...!sticky ? { flexShrink: 0 } : {}
|
|
24
|
+
},
|
|
25
|
+
table: props.nameCellProps.table,
|
|
26
|
+
gridLayout: props.nameCellProps.gridLayout,
|
|
27
|
+
dataFrame: props.nameCellProps.dataFrame,
|
|
28
|
+
rightmostVisibleColumn: props.nameCellProps.rightmostVisibleColumn,
|
|
29
|
+
sortAscending: props.nameCellProps.getSortDirection(props.nameCellProps.gridLayout.arrowFieldByColumnIndex[columnIndex]),
|
|
30
|
+
onOrderByColumn: props.nameCellProps.onOrderByColumn,
|
|
31
|
+
onShowTable: props.nameCellProps.onShowTable
|
|
32
|
+
}, `header-0-${columnIndex}`);
|
|
33
|
+
const renderPlotCell = (columnIndex, sticky) => /* @__PURE__ */ jsx(HeaderPlotsCell, {
|
|
34
|
+
...props.plotCellProps,
|
|
35
|
+
columnIndex,
|
|
36
|
+
style: {
|
|
37
|
+
width: props.getColumnWidth(columnIndex),
|
|
38
|
+
height: props.plotsHeight,
|
|
39
|
+
...!sticky ? { flexShrink: 0 } : {}
|
|
40
|
+
}
|
|
41
|
+
}, `header-1-${columnIndex}`);
|
|
42
|
+
const PlotsChevron = props.plotsCollapsed ? ChevronDownIcon : ChevronUpIcon;
|
|
43
|
+
return ReactDOM.createPortal(/* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: sticky_header_container,
|
|
45
|
+
style: {
|
|
46
|
+
position: "sticky",
|
|
47
|
+
top: 0,
|
|
48
|
+
zIndex: 10,
|
|
49
|
+
width: props.totalWidth,
|
|
50
|
+
height: props.headerHeight
|
|
51
|
+
},
|
|
52
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: sticky_header_row,
|
|
54
|
+
style: {
|
|
55
|
+
display: "flex",
|
|
56
|
+
height: 32
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", {
|
|
60
|
+
style: {
|
|
61
|
+
position: "sticky",
|
|
62
|
+
left: 0,
|
|
63
|
+
zIndex: 11,
|
|
64
|
+
flexShrink: 0
|
|
65
|
+
},
|
|
66
|
+
children: renderNameCell(0, true)
|
|
67
|
+
}),
|
|
68
|
+
props.leftSpacerWidth > 0 && /* @__PURE__ */ jsx("div", { style: {
|
|
69
|
+
width: props.leftSpacerWidth,
|
|
70
|
+
flexShrink: 0
|
|
71
|
+
} }),
|
|
72
|
+
Array.from({ length: props.renderedColumnCount }, (_, index) => renderNameCell(props.firstRenderedColumn + index, false)),
|
|
73
|
+
props.rightSpacerWidth > 0 && /* @__PURE__ */ jsx("div", { style: {
|
|
74
|
+
width: props.rightSpacerWidth,
|
|
75
|
+
flexShrink: 0
|
|
76
|
+
} })
|
|
77
|
+
]
|
|
78
|
+
}), props.columnHeader === TableColumnHeader.WithColumnPlots && /* @__PURE__ */ jsxs("div", {
|
|
79
|
+
className: "dashql_sticky_header_row_k4jXSK",
|
|
80
|
+
style: {
|
|
81
|
+
display: "flex",
|
|
82
|
+
height: props.plotsHeight
|
|
83
|
+
},
|
|
84
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
85
|
+
style: {
|
|
86
|
+
position: "sticky",
|
|
87
|
+
left: 0,
|
|
88
|
+
zIndex: 11,
|
|
89
|
+
flexShrink: 0
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
92
|
+
type: "button",
|
|
93
|
+
className: "dashql_plots_toggle_3vXAdD",
|
|
94
|
+
style: {
|
|
95
|
+
width: props.firstColumnWidth,
|
|
96
|
+
height: props.plotsHeight
|
|
97
|
+
},
|
|
98
|
+
"aria-label": props.plotsCollapsed ? "Show column plots" : "Hide column plots",
|
|
99
|
+
"aria-expanded": !props.plotsCollapsed,
|
|
100
|
+
title: props.plotsCollapsed ? "Show column plots" : "Hide column plots",
|
|
101
|
+
onClick: props.onTogglePlots,
|
|
102
|
+
children: /* @__PURE__ */ jsx(PlotsChevron, { size: props.plotsCollapsed ? 12 : 16 })
|
|
103
|
+
})
|
|
104
|
+
}), props.plotsCollapsed ? /* @__PURE__ */ jsx("div", {
|
|
105
|
+
className: "dashql_plots_collapsed_cell_Zb3ndp",
|
|
106
|
+
style: { width: props.totalWidth - props.firstColumnWidth }
|
|
107
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
props.leftSpacerWidth > 0 && /* @__PURE__ */ jsx("div", { style: {
|
|
109
|
+
width: props.leftSpacerWidth,
|
|
110
|
+
flexShrink: 0
|
|
111
|
+
} }),
|
|
112
|
+
Array.from({ length: props.renderedColumnCount }, (_, index) => renderPlotCell(props.firstRenderedColumn + index, false)),
|
|
113
|
+
props.rightSpacerWidth > 0 && /* @__PURE__ */ jsx("div", { style: {
|
|
114
|
+
width: props.rightSpacerWidth,
|
|
115
|
+
flexShrink: 0
|
|
116
|
+
} })
|
|
117
|
+
] })]
|
|
118
|
+
})]
|
|
119
|
+
}), props.container);
|
|
120
|
+
});
|
|
121
|
+
var DataTableStickyColumn = React.memo((props) => {
|
|
122
|
+
if (props.container == null) return null;
|
|
123
|
+
const visibleCount = Math.max(0, props.stopRow - props.startRow + 1);
|
|
124
|
+
return ReactDOM.createPortal(/* @__PURE__ */ jsx("div", {
|
|
125
|
+
className: sticky_column_container,
|
|
126
|
+
style: {
|
|
127
|
+
position: "sticky",
|
|
128
|
+
left: 0,
|
|
129
|
+
width: props.firstColumnWidth,
|
|
130
|
+
height: props.totalDataHeight,
|
|
131
|
+
marginTop: -props.totalDataHeight,
|
|
132
|
+
zIndex: 5,
|
|
133
|
+
pointerEvents: "none"
|
|
134
|
+
},
|
|
135
|
+
children: Array.from({ length: visibleCount }, (_, index) => {
|
|
136
|
+
const rowIndex = props.startRow + index;
|
|
137
|
+
return /* @__PURE__ */ jsx("div", {
|
|
138
|
+
style: {
|
|
139
|
+
position: "absolute",
|
|
140
|
+
top: rowIndex * 26,
|
|
141
|
+
left: 0,
|
|
142
|
+
width: props.firstColumnWidth,
|
|
143
|
+
height: 26,
|
|
144
|
+
pointerEvents: "auto"
|
|
145
|
+
},
|
|
146
|
+
children: /* @__PURE__ */ jsx(StickyRowHeaderCell, {
|
|
147
|
+
ariaAttributes: STICKY_ROW_HEADER_ARIA,
|
|
148
|
+
rowIndex,
|
|
149
|
+
columnIndex: 0,
|
|
150
|
+
style: {
|
|
151
|
+
width: props.firstColumnWidth,
|
|
152
|
+
height: 26
|
|
153
|
+
},
|
|
154
|
+
...props.gridData,
|
|
155
|
+
hideRowHeader: false
|
|
156
|
+
})
|
|
157
|
+
}, `col0-${rowIndex}`);
|
|
158
|
+
})
|
|
159
|
+
}), props.container);
|
|
160
|
+
});
|
|
161
|
+
export { DataTableStickyColumn, DataTableStickyHeaders };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import { ArrowTableFormatter } from '@akohn/dashql/platform/compute/arrow_formatter';
|
|
3
|
+
import type { ComputationModel } from '../../models/computation_model.js';
|
|
4
|
+
export declare const WINDOW_MARGIN_ROWS = 100;
|
|
5
|
+
export interface DataTableWindow {
|
|
6
|
+
offset: number;
|
|
7
|
+
table: arrow.Table;
|
|
8
|
+
formatter: ArrowTableFormatter;
|
|
9
|
+
dataRows: Int32Array;
|
|
10
|
+
}
|
|
11
|
+
export interface DataTableRows {
|
|
12
|
+
window: DataTableWindow | null;
|
|
13
|
+
rows: number;
|
|
14
|
+
error: string | null;
|
|
15
|
+
retry: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function forEachIntegerValue(column: arrow.Vector, visit: (value: number, index: number) => void): void;
|
|
18
|
+
export declare function useDataTableWindow(model: ComputationModel, start: number, stop: number): DataTableRows;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useLogger } from "../../logger.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { stringifyError } from "@akohn/dashql/platform/logger/logger";
|
|
4
|
+
import * as arrow from "apache-arrow";
|
|
5
|
+
import { ArrowTableFormatter } from "@akohn/dashql/platform/compute/arrow_formatter";
|
|
6
|
+
var WINDOW_MARGIN_ROWS = 100;
|
|
7
|
+
function forEachIntegerValue(column, visit) {
|
|
8
|
+
if (column.type.typeId !== arrow.Type.Int) {
|
|
9
|
+
for (let i = 0; i < column.length; ++i) visit(Number(column.get(i)), i);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let index = 0;
|
|
13
|
+
for (const chunk of column.data) {
|
|
14
|
+
const values = chunk.values;
|
|
15
|
+
if (chunk.nullCount === 0) for (let i = 0; i < chunk.length; ++i) visit(Number(values[i]), index++);
|
|
16
|
+
else for (let i = 0; i < chunk.length; ++i) visit(chunk.getValid(i) ? Number(values[i]) : 0, index++);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function dataRowsOf(table) {
|
|
20
|
+
const out = new Int32Array(table.numRows);
|
|
21
|
+
const column = table.numCols === 0 ? null : table.getChildAt(table.numCols - 1);
|
|
22
|
+
if (column == null) return out;
|
|
23
|
+
forEachIntegerValue(column, (rowNumber, index) => {
|
|
24
|
+
out[index] = rowNumber - 1;
|
|
25
|
+
});
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
function rowsOfView(view) {
|
|
29
|
+
return view.orderingTable?.rows ?? view.filterTable?.rows ?? view.dataSearchTable?.rows ?? view.dataTableRows;
|
|
30
|
+
}
|
|
31
|
+
function tableKey(view) {
|
|
32
|
+
return `${view.tableId}:${view.dataTable}`;
|
|
33
|
+
}
|
|
34
|
+
function selectionKey(view) {
|
|
35
|
+
return [
|
|
36
|
+
tableKey(view),
|
|
37
|
+
view.dataFrame,
|
|
38
|
+
view.filterTable?.dataTable,
|
|
39
|
+
view.orderingTable?.dataTable,
|
|
40
|
+
view.dataSearchTable?.dataTable
|
|
41
|
+
].join(":");
|
|
42
|
+
}
|
|
43
|
+
function holds(offset, length, rows, start, stop) {
|
|
44
|
+
return start >= offset && (stop < offset + length || offset + length >= rows);
|
|
45
|
+
}
|
|
46
|
+
function useDataTableWindow(model, start, stop) {
|
|
47
|
+
const logger = useLogger();
|
|
48
|
+
const view = model.computation;
|
|
49
|
+
const key = selectionKey(view);
|
|
50
|
+
const table = tableKey(view);
|
|
51
|
+
const [state, setState] = React.useState(null);
|
|
52
|
+
const [failed, setFailed] = React.useState(null);
|
|
53
|
+
const readRows = React.useRef(model.readRows);
|
|
54
|
+
readRows.current = model.readRows;
|
|
55
|
+
const pending = React.useRef(null);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
const current = state?.key === key ? state : null;
|
|
58
|
+
if (current != null && holds(current.window.offset, current.window.table.numRows, current.rows, start, stop)) return;
|
|
59
|
+
const running = pending.current;
|
|
60
|
+
if (running != null && running.key === key && holds(running.offset, running.limit, Number.POSITIVE_INFINITY, start, stop)) return;
|
|
61
|
+
if (failed != null && failed.key === key && holds(failed.offset, failed.limit, Number.POSITIVE_INFINITY, start, stop)) return;
|
|
62
|
+
const offset = Math.max(0, start - 100);
|
|
63
|
+
const limit = Math.max(0, stop - start + 1) + 200;
|
|
64
|
+
const read = {
|
|
65
|
+
key,
|
|
66
|
+
offset,
|
|
67
|
+
limit
|
|
68
|
+
};
|
|
69
|
+
pending.current = read;
|
|
70
|
+
readRows.current(offset, limit).then((result) => {
|
|
71
|
+
if (pending.current !== read) return;
|
|
72
|
+
pending.current = null;
|
|
73
|
+
const formatter = new ArrowTableFormatter(result.table.schema, result.table.batches, logger);
|
|
74
|
+
const window = {
|
|
75
|
+
offset: result.offset,
|
|
76
|
+
table: result.table,
|
|
77
|
+
formatter,
|
|
78
|
+
dataRows: dataRowsOf(result.table)
|
|
79
|
+
};
|
|
80
|
+
setFailed(null);
|
|
81
|
+
setState({
|
|
82
|
+
key,
|
|
83
|
+
table,
|
|
84
|
+
rows: result.rows,
|
|
85
|
+
window
|
|
86
|
+
});
|
|
87
|
+
}, (error) => {
|
|
88
|
+
if (pending.current !== read) return;
|
|
89
|
+
pending.current = null;
|
|
90
|
+
const message = stringifyError(error);
|
|
91
|
+
logger.warn("Failed to read the rows of a table", { error: message }, "data_table");
|
|
92
|
+
setFailed({
|
|
93
|
+
key,
|
|
94
|
+
offset,
|
|
95
|
+
limit,
|
|
96
|
+
error: message
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}, [
|
|
100
|
+
key,
|
|
101
|
+
table,
|
|
102
|
+
start,
|
|
103
|
+
stop,
|
|
104
|
+
state,
|
|
105
|
+
failed,
|
|
106
|
+
logger
|
|
107
|
+
]);
|
|
108
|
+
const retry = React.useCallback(() => setFailed(null), []);
|
|
109
|
+
const shown = state?.table === table ? state : null;
|
|
110
|
+
const error = failed != null && failed.key === key && (shown == null || shown.key !== key || !holds(shown.window.offset, shown.window.table.numRows, shown.rows, start, stop)) ? failed.error : null;
|
|
111
|
+
return {
|
|
112
|
+
window: shown?.window ?? null,
|
|
113
|
+
rows: shown?.rows ?? rowsOfView(view),
|
|
114
|
+
error,
|
|
115
|
+
retry
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export { WINDOW_MARGIN_ROWS, forEachIntegerValue, useDataTableWindow };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { detectPlanEngine } from "../../utils/plan_engine.js";
|
|
2
|
+
var PEEK_WINDOW = 4096;
|
|
3
|
+
var SQL_RE = /^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|DROP|WITH|EXPLAIN|COPY|SET|BEGIN|COMMIT|ROLLBACK)\b/i;
|
|
4
|
+
function peekFormat(value) {
|
|
5
|
+
if (value == null || value.length < 2) return null;
|
|
6
|
+
const head = value.slice(0, PEEK_WINDOW).trimStart();
|
|
7
|
+
const tail = value.slice(-4096).trimEnd();
|
|
8
|
+
const first = head.length > 0 ? head[0] : null;
|
|
9
|
+
const last = tail.length > 0 ? tail[tail.length - 1] : null;
|
|
10
|
+
if ((first === "{" || first === "[") && (last === "}" || last === "]")) {
|
|
11
|
+
if (detectPlanEngine(value) != null) return "plan";
|
|
12
|
+
return "json";
|
|
13
|
+
}
|
|
14
|
+
if (SQL_RE.test(head)) return "sql";
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
export { peekFormat };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as d3 from 'd3';
|
|
3
|
+
export declare const NULL_SYMBOL = "\u2205";
|
|
4
|
+
interface HistogramBarsProps {
|
|
5
|
+
binCounts: BigInt64Array;
|
|
6
|
+
filteredBinCounts: BigInt64Array | null;
|
|
7
|
+
focusedBin: number | null;
|
|
8
|
+
xScale: d3.ScaleBand<string>;
|
|
9
|
+
yScale: d3.ScaleLinear<number, number>;
|
|
10
|
+
height: number;
|
|
11
|
+
totalBarColor: string;
|
|
12
|
+
totalBarFocusedColor: string;
|
|
13
|
+
filteredBarColor: string;
|
|
14
|
+
filteredBarFocusedColor: string;
|
|
15
|
+
}
|
|
16
|
+
declare function HistogramBarsImpl(props: HistogramBarsProps): React.ReactElement;
|
|
17
|
+
export declare const HistogramBars: React.MemoExoticComponent<typeof HistogramBarsImpl>;
|
|
18
|
+
interface HistogramNullBarProps {
|
|
19
|
+
countNull: number;
|
|
20
|
+
filteredNullCount: number | null;
|
|
21
|
+
focused: boolean | null;
|
|
22
|
+
xScale: d3.ScaleBand<string>;
|
|
23
|
+
yScale: d3.ScaleLinear<number, number>;
|
|
24
|
+
xWidth: number;
|
|
25
|
+
height: number;
|
|
26
|
+
bottomMargin: number;
|
|
27
|
+
transformX: number;
|
|
28
|
+
totalBarColor: string;
|
|
29
|
+
totalBarFocusedColor: string;
|
|
30
|
+
filteredBarColor: string;
|
|
31
|
+
filteredBarFocusedColor: string;
|
|
32
|
+
onPointerOver: React.MouseEventHandler<SVGGElement>;
|
|
33
|
+
onPointerOut: React.MouseEventHandler<SVGGElement>;
|
|
34
|
+
}
|
|
35
|
+
export declare function HistogramNullBar(props: HistogramNullBarProps): React.ReactElement | null;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { COLUMN_SUMMARY_BASELINE_COLOR } from "./data_table_colors.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var NULL_SYMBOL = "∅";
|
|
5
|
+
function getBarGeometry(bin, count, xScale, yScale, height) {
|
|
6
|
+
const x = xScale(bin.toString());
|
|
7
|
+
const y = yScale(Number(count));
|
|
8
|
+
const width = xScale.bandwidth();
|
|
9
|
+
const barHeight = height - y;
|
|
10
|
+
if (x == null || isNaN(y) || isNaN(width) || isNaN(barHeight)) return null;
|
|
11
|
+
return {
|
|
12
|
+
x,
|
|
13
|
+
y,
|
|
14
|
+
width,
|
|
15
|
+
height: barHeight
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function HistogramBarsImpl(props) {
|
|
19
|
+
const filteredBinCounts = props.filteredBinCounts;
|
|
20
|
+
const totalBars = Array.from({ length: props.binCounts.length }, (_, bin) => {
|
|
21
|
+
const geometry = getBarGeometry(bin, props.binCounts[bin], props.xScale, props.yScale, props.height);
|
|
22
|
+
return geometry == null ? null : /* @__PURE__ */ jsx("rect", {
|
|
23
|
+
...geometry,
|
|
24
|
+
style: { fill: props.totalBarColor }
|
|
25
|
+
}, bin);
|
|
26
|
+
});
|
|
27
|
+
const focusedTotalGeometry = props.focusedBin == null ? null : getBarGeometry(props.focusedBin, props.binCounts[props.focusedBin], props.xScale, props.yScale, props.height);
|
|
28
|
+
const filteredBars = filteredBinCounts == null ? null : Array.from({ length: filteredBinCounts.length }, (_, bin) => {
|
|
29
|
+
const geometry = getBarGeometry(bin, filteredBinCounts[bin], props.xScale, props.yScale, props.height);
|
|
30
|
+
return geometry == null ? null : /* @__PURE__ */ jsx("rect", {
|
|
31
|
+
...geometry,
|
|
32
|
+
style: { fill: props.filteredBarColor }
|
|
33
|
+
}, `filtered-${bin}`);
|
|
34
|
+
});
|
|
35
|
+
const focusedFilteredGeometry = props.focusedBin == null || filteredBinCounts == null ? null : getBarGeometry(props.focusedBin, filteredBinCounts[props.focusedBin], props.xScale, props.yScale, props.height);
|
|
36
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
+
totalBars,
|
|
38
|
+
focusedTotalGeometry != null && /* @__PURE__ */ jsx("rect", {
|
|
39
|
+
"data-part": "focus",
|
|
40
|
+
...focusedTotalGeometry,
|
|
41
|
+
style: { fill: props.totalBarFocusedColor }
|
|
42
|
+
}, `focused-${props.focusedBin}`),
|
|
43
|
+
filteredBars,
|
|
44
|
+
focusedFilteredGeometry != null && /* @__PURE__ */ jsx("rect", {
|
|
45
|
+
...focusedFilteredGeometry,
|
|
46
|
+
style: { fill: props.filteredBarFocusedColor }
|
|
47
|
+
}, `focused-filtered-${props.focusedBin}`)
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
var HistogramBars = React.memo(HistogramBarsImpl);
|
|
51
|
+
function HistogramNullBar(props) {
|
|
52
|
+
const nullX = props.xScale("∅");
|
|
53
|
+
const nullY = props.yScale(props.countNull);
|
|
54
|
+
const nullWidth = props.xScale.bandwidth();
|
|
55
|
+
const nullHeight = props.height - nullY;
|
|
56
|
+
if (nullX == null || isNaN(nullY) || isNaN(nullWidth) || isNaN(nullHeight)) return null;
|
|
57
|
+
const filteredNullY = props.filteredNullCount == null ? null : props.yScale(props.filteredNullCount);
|
|
58
|
+
const filteredNullHeight = filteredNullY == null ? null : props.height - filteredNullY;
|
|
59
|
+
const hasValidFilteredBar = filteredNullY != null && filteredNullHeight != null && !isNaN(filteredNullY) && !isNaN(filteredNullHeight);
|
|
60
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
61
|
+
"data-part": "null",
|
|
62
|
+
transform: `translate(${props.transformX}, 0)`,
|
|
63
|
+
onPointerOver: props.onPointerOver,
|
|
64
|
+
onPointerMove: props.onPointerOver,
|
|
65
|
+
onPointerOut: props.onPointerOut,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx("rect", {
|
|
68
|
+
x: nullX,
|
|
69
|
+
y: nullY,
|
|
70
|
+
width: nullWidth,
|
|
71
|
+
height: nullHeight,
|
|
72
|
+
style: { fill: props.focused ? props.totalBarFocusedColor : props.totalBarColor }
|
|
73
|
+
}),
|
|
74
|
+
hasValidFilteredBar && /* @__PURE__ */ jsx("rect", {
|
|
75
|
+
x: nullX,
|
|
76
|
+
y: filteredNullY,
|
|
77
|
+
width: nullWidth,
|
|
78
|
+
height: filteredNullHeight,
|
|
79
|
+
style: { fill: props.focused ? props.filteredBarFocusedColor : props.filteredBarColor }
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsxs("g", {
|
|
82
|
+
transform: `translate(0, ${props.height})`,
|
|
83
|
+
children: [/* @__PURE__ */ jsx("line", {
|
|
84
|
+
x1: 0,
|
|
85
|
+
y1: 1,
|
|
86
|
+
x2: props.xWidth,
|
|
87
|
+
y2: 1,
|
|
88
|
+
style: { stroke: COLUMN_SUMMARY_BASELINE_COLOR }
|
|
89
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
90
|
+
x: nullX,
|
|
91
|
+
y: 0,
|
|
92
|
+
width: nullWidth,
|
|
93
|
+
height: props.bottomMargin,
|
|
94
|
+
fillOpacity: 0
|
|
95
|
+
})]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export { HistogramBars, HistogramNullBar, NULL_SYMBOL };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as d3 from 'd3';
|
|
3
|
+
export declare const BRUSH_SETTLE_DELAY_MS = 120;
|
|
4
|
+
export declare class SettledBrushUpdates<T> {
|
|
5
|
+
private timeout;
|
|
6
|
+
private pending;
|
|
7
|
+
schedule(event: T, callback: (event: T) => void): void;
|
|
8
|
+
flush(event: T, callback: (event: T) => void): void;
|
|
9
|
+
cancel(): void;
|
|
10
|
+
}
|
|
11
|
+
interface HistogramBrushOptions {
|
|
12
|
+
xScale: d3.ScaleBand<string>;
|
|
13
|
+
height: number;
|
|
14
|
+
selection: [number, number] | null;
|
|
15
|
+
onBrushUpdate: (event: d3.D3BrushEvent<unknown>) => void;
|
|
16
|
+
onClear: () => void;
|
|
17
|
+
onBrushingChange?: (isBrushing: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function useHistogramBrush(options: HistogramBrushOptions): {
|
|
20
|
+
brushContainer: React.RefObject<SVGGElement | null>;
|
|
21
|
+
clearBrush: () => void;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as d3 from "d3";
|
|
3
|
+
var BRUSH_SETTLE_DELAY_MS = 120;
|
|
4
|
+
function hideBrushSelection(container) {
|
|
5
|
+
d3.select(container).selectAll(".selection, .handle").style("display", "none").attr("x", 0).attr("y", 0).attr("width", 0).attr("height", 0);
|
|
6
|
+
}
|
|
7
|
+
var SettledBrushUpdates = class {
|
|
8
|
+
timeout = null;
|
|
9
|
+
pending = null;
|
|
10
|
+
schedule(event, callback) {
|
|
11
|
+
this.pending = event;
|
|
12
|
+
if (this.timeout != null) window.clearTimeout(this.timeout);
|
|
13
|
+
this.timeout = window.setTimeout(() => {
|
|
14
|
+
this.timeout = null;
|
|
15
|
+
const pending = this.pending;
|
|
16
|
+
this.pending = null;
|
|
17
|
+
if (pending != null) callback(pending);
|
|
18
|
+
}, 120);
|
|
19
|
+
}
|
|
20
|
+
flush(event, callback) {
|
|
21
|
+
this.cancel();
|
|
22
|
+
callback(event);
|
|
23
|
+
}
|
|
24
|
+
cancel() {
|
|
25
|
+
if (this.timeout != null) {
|
|
26
|
+
window.clearTimeout(this.timeout);
|
|
27
|
+
this.timeout = null;
|
|
28
|
+
}
|
|
29
|
+
this.pending = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function useHistogramBrush(options) {
|
|
33
|
+
const brushContainer = React.useRef(null);
|
|
34
|
+
const brushBehavior = React.useRef(null);
|
|
35
|
+
const syncingSelection = React.useRef(false);
|
|
36
|
+
const settledBrushUpdates = React.useRef(new SettledBrushUpdates());
|
|
37
|
+
const { xScale, height, selection, onBrushUpdate, onClear, onBrushingChange } = options;
|
|
38
|
+
const onBrushUpdateRef = React.useRef(onBrushUpdate);
|
|
39
|
+
onBrushUpdateRef.current = onBrushUpdate;
|
|
40
|
+
const selectionRef = React.useRef(selection);
|
|
41
|
+
selectionRef.current = selection;
|
|
42
|
+
const onBrushStart = React.useCallback(() => {
|
|
43
|
+
if (syncingSelection.current) return;
|
|
44
|
+
settledBrushUpdates.current.cancel();
|
|
45
|
+
onBrushingChange?.(true);
|
|
46
|
+
}, [onBrushingChange]);
|
|
47
|
+
const onBrushMove = React.useCallback((event) => {
|
|
48
|
+
if (syncingSelection.current) return;
|
|
49
|
+
settledBrushUpdates.current.schedule(event, (pending) => onBrushUpdateRef.current(pending));
|
|
50
|
+
}, []);
|
|
51
|
+
const onBrushEnd = React.useCallback((event) => {
|
|
52
|
+
if (syncingSelection.current) return;
|
|
53
|
+
settledBrushUpdates.current.flush(event, onBrushUpdate);
|
|
54
|
+
onBrushingChange?.(false);
|
|
55
|
+
}, [onBrushUpdate, onBrushingChange]);
|
|
56
|
+
const onBrushStartRef = React.useRef(onBrushStart);
|
|
57
|
+
const onBrushMoveRef = React.useRef(onBrushMove);
|
|
58
|
+
const onBrushEndRef = React.useRef(onBrushEnd);
|
|
59
|
+
onBrushStartRef.current = onBrushStart;
|
|
60
|
+
onBrushMoveRef.current = onBrushMove;
|
|
61
|
+
onBrushEndRef.current = onBrushEnd;
|
|
62
|
+
React.useEffect(() => () => settledBrushUpdates.current.cancel(), []);
|
|
63
|
+
React.useLayoutEffect(() => {
|
|
64
|
+
const brush = d3.brushX().extent([[xScale.range()[0], 0], [xScale.range()[1], height]]).on("start", () => onBrushStartRef.current()).on("brush", (event) => onBrushMoveRef.current(event)).on("end", (event) => onBrushEndRef.current(event));
|
|
65
|
+
brushBehavior.current = brush;
|
|
66
|
+
d3.select(brushContainer.current).selectChildren().remove();
|
|
67
|
+
d3.select(brushContainer.current).call(brush).selectAll("rect").attr("y", 0).attr("height", height);
|
|
68
|
+
if (selectionRef.current == null) hideBrushSelection(brushContainer.current);
|
|
69
|
+
return () => {
|
|
70
|
+
brushBehavior.current = null;
|
|
71
|
+
};
|
|
72
|
+
}, [xScale, height]);
|
|
73
|
+
React.useLayoutEffect(() => {
|
|
74
|
+
const container = brushContainer.current;
|
|
75
|
+
const brush = brushBehavior.current;
|
|
76
|
+
if (container == null || brush == null) return;
|
|
77
|
+
const current = d3.brushSelection(container);
|
|
78
|
+
const next = selection;
|
|
79
|
+
if (current == null ? next == null : next != null && current[0] === next[0] && current[1] === next[1]) return;
|
|
80
|
+
settledBrushUpdates.current.cancel();
|
|
81
|
+
syncingSelection.current = true;
|
|
82
|
+
try {
|
|
83
|
+
d3.select(container).call(brush.move, next);
|
|
84
|
+
if (next == null) hideBrushSelection(container);
|
|
85
|
+
} finally {
|
|
86
|
+
syncingSelection.current = false;
|
|
87
|
+
}
|
|
88
|
+
}, [
|
|
89
|
+
selection,
|
|
90
|
+
xScale,
|
|
91
|
+
height
|
|
92
|
+
]);
|
|
93
|
+
return {
|
|
94
|
+
brushContainer,
|
|
95
|
+
clearBrush: React.useCallback(() => {
|
|
96
|
+
const container = brushContainer.current;
|
|
97
|
+
const brush = brushBehavior.current;
|
|
98
|
+
if (container != null && brush != null) {
|
|
99
|
+
d3.select(container).call(brush.move, null);
|
|
100
|
+
hideBrushSelection(container);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
onClear();
|
|
104
|
+
}, [onClear])
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export { BRUSH_SETTLE_DELAY_MS, SettledBrushUpdates, useHistogramBrush };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ColumnAggregationVariant, OrdinalColumnAggregation, TableAggregation, WithFilterEpoch } from '@akohn/dashql/platform/compute/computation_types';
|
|
3
|
+
export { NULL_SYMBOL } from './histogram_bars.js';
|
|
4
|
+
export { SettledBrushUpdates } from './histogram_brush.js';
|
|
5
|
+
export type HistogramFilterCallback = (table: TableAggregation, columnId: number, column: OrdinalColumnAggregation, filter: [number, number] | null) => void;
|
|
6
|
+
export type BrushingStateCallback = (isBrushing: boolean) => void;
|
|
7
|
+
interface HistogramCellProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
tableAggregation: TableAggregation;
|
|
11
|
+
columnIndex: number;
|
|
12
|
+
columnAggregate: OrdinalColumnAggregation;
|
|
13
|
+
filteredColumnAggregation: WithFilterEpoch<ColumnAggregationVariant> | null;
|
|
14
|
+
selection: [number, number] | null;
|
|
15
|
+
onFilter: HistogramFilterCallback;
|
|
16
|
+
onBrushingChange?: BrushingStateCallback;
|
|
17
|
+
}
|
|
18
|
+
declare function HistogramCellImpl(props: HistogramCellProps): React.ReactElement;
|
|
19
|
+
export declare const HistogramCell: React.MemoExoticComponent<typeof HistogramCellImpl>;
|