@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,277 @@
|
|
|
1
|
+
import { body, body_padded, codemirror_container, header, header_spacer, header_title, header_title_equal, header_title_field, header_title_index, header_title_label, main, modal, sidebar, sidebar_bottom, sidebar_top, structured_view } from "./cell_detail_overlay.module.js";
|
|
2
|
+
import "../data_table/data_table.js";
|
|
3
|
+
import { ChevronDownIcon, ChevronUpIcon, ScreenFullIcon, ScreenNormalIcon, SymbolIcon, XIcon } from "../symbol_icon.js";
|
|
4
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
5
|
+
import { SegmentedControl, SegmentedControlSize } from "../segmented_control.js";
|
|
6
|
+
import { JsonView } from "../json/json_view.js";
|
|
7
|
+
import { peekFormat } from "../data_table/format_peek.js";
|
|
8
|
+
import { Overlay, OverlaySize } from "../overlay.js";
|
|
9
|
+
import { CopyToClipboardButton } from "../clipboard.js";
|
|
10
|
+
import { useKeyEvents } from "../../dom/key_events.js";
|
|
11
|
+
import { detectPlanEngine } from "../../utils/plan_engine.js";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import * as dashql from "@akohn/dashql";
|
|
15
|
+
var LOG_CTX = "cell_detail_overlay";
|
|
16
|
+
var FormatMode = /* @__PURE__ */ function(FormatMode) {
|
|
17
|
+
FormatMode[FormatMode["Raw"] = 0] = "Raw";
|
|
18
|
+
FormatMode[FormatMode["Structured"] = 1] = "Structured";
|
|
19
|
+
FormatMode[FormatMode["SQL"] = 2] = "SQL";
|
|
20
|
+
FormatMode[FormatMode["Plan"] = 3] = "Plan";
|
|
21
|
+
return FormatMode;
|
|
22
|
+
}(FormatMode || {});
|
|
23
|
+
var FORMAT_LABELS = {
|
|
24
|
+
[FormatMode.Raw]: "Raw",
|
|
25
|
+
[FormatMode.Structured]: "Structured",
|
|
26
|
+
[FormatMode.SQL]: "SQL",
|
|
27
|
+
[FormatMode.Plan]: "Plan"
|
|
28
|
+
};
|
|
29
|
+
function detectFormats(value, detectSql) {
|
|
30
|
+
const result = {
|
|
31
|
+
json: null,
|
|
32
|
+
sql: null,
|
|
33
|
+
plan: null
|
|
34
|
+
};
|
|
35
|
+
if (value == null) return result;
|
|
36
|
+
const peeked = peekFormat(value);
|
|
37
|
+
if (peeked === "plan") result.plan = value;
|
|
38
|
+
if (peeked === "plan" || peeked === "json") try {
|
|
39
|
+
const parsed = JSON.parse(value);
|
|
40
|
+
if (typeof parsed === "object" && parsed !== null) result.json = parsed;
|
|
41
|
+
} catch {}
|
|
42
|
+
if (detectSql != null && result.json == null) {
|
|
43
|
+
const sql = detectSql(value);
|
|
44
|
+
if (sql != null) result.sql = {
|
|
45
|
+
...sql,
|
|
46
|
+
originalText: value
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
function detectStructuredFormats(value) {
|
|
52
|
+
return {
|
|
53
|
+
json: value,
|
|
54
|
+
sql: null,
|
|
55
|
+
plan: null
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var STRUCTURED_ARRAY_PAGE_SIZE = 100;
|
|
59
|
+
function structuredValueToText(value) {
|
|
60
|
+
return JSON.stringify(value, (_key, item) => typeof item === "bigint" ? `${item}n` : item, 2);
|
|
61
|
+
}
|
|
62
|
+
function pickDefaultMode(formats) {
|
|
63
|
+
if (formats.plan != null) return FormatMode.Plan;
|
|
64
|
+
if (formats.sql != null && !formats.sql.hasErrors) return FormatMode.SQL;
|
|
65
|
+
if (formats.json != null) return FormatMode.Structured;
|
|
66
|
+
return FormatMode.Raw;
|
|
67
|
+
}
|
|
68
|
+
function getAvailableModes(formats) {
|
|
69
|
+
const modes = [FormatMode.Raw];
|
|
70
|
+
if (formats.json != null) modes.push(FormatMode.Structured);
|
|
71
|
+
if (formats.sql != null) modes.push(FormatMode.SQL);
|
|
72
|
+
if (formats.plan != null) modes.push(FormatMode.Plan);
|
|
73
|
+
return modes;
|
|
74
|
+
}
|
|
75
|
+
var PencilAIIcon = SymbolIcon("pencil_ai_16");
|
|
76
|
+
function SqlTextView(props) {
|
|
77
|
+
const [pretty, setPretty] = React.useState(false);
|
|
78
|
+
const activeText = pretty && props.formattedText != null ? props.formattedText : props.originalText;
|
|
79
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
80
|
+
className: codemirror_container,
|
|
81
|
+
children: [props.sqlView(activeText), props.formattedText != null && /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: "dashql_pretty_toggle_m-OdDP",
|
|
83
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
84
|
+
className: "dashql_pretty_toggle_button_luaCAy",
|
|
85
|
+
variant: ButtonVariant.Default,
|
|
86
|
+
"aria-label": "Pretty format",
|
|
87
|
+
"aria-pressed": pretty,
|
|
88
|
+
onClick: () => setPretty((p) => !p),
|
|
89
|
+
children: /* @__PURE__ */ jsx(PencilAIIcon, {})
|
|
90
|
+
})
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function StructuredValueView(props) {
|
|
95
|
+
return /* @__PURE__ */ jsx(JsonView, {
|
|
96
|
+
className: structured_view,
|
|
97
|
+
value: props.value,
|
|
98
|
+
collapsed: 2,
|
|
99
|
+
shortenTextAfterLength: 100,
|
|
100
|
+
arrayPageSize: 100
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function CellDetailOverlay(props) {
|
|
104
|
+
if (!props.isOpen) return null;
|
|
105
|
+
return /* @__PURE__ */ jsx(CellDetailOverlayInner, { ...props });
|
|
106
|
+
}
|
|
107
|
+
var EMPTY_FORMATS = {
|
|
108
|
+
json: null,
|
|
109
|
+
sql: null,
|
|
110
|
+
plan: null
|
|
111
|
+
};
|
|
112
|
+
function CellDetailOverlayInner(props) {
|
|
113
|
+
const [formats, setFormats] = React.useState(EMPTY_FORMATS);
|
|
114
|
+
const [selectedFormat, setSelectedFormat] = React.useState(FormatMode.Raw);
|
|
115
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
116
|
+
const value = props.structuredValue ?? props.formattedValue;
|
|
117
|
+
const pickedValue = React.useRef(void 0);
|
|
118
|
+
const { structuredValue, formattedValue, detectSql } = props;
|
|
119
|
+
React.useEffect(() => {
|
|
120
|
+
const f = structuredValue == null ? detectFormats(formattedValue, detectSql) : detectStructuredFormats(structuredValue);
|
|
121
|
+
setFormats(f);
|
|
122
|
+
setSelectedFormat((selected) => pickedValue.current === value && getAvailableModes(f).includes(selected) ? selected : pickDefaultMode(f));
|
|
123
|
+
}, [
|
|
124
|
+
formattedValue,
|
|
125
|
+
structuredValue,
|
|
126
|
+
detectSql,
|
|
127
|
+
value
|
|
128
|
+
]);
|
|
129
|
+
const availableModes = React.useMemo(() => getAvailableModes(formats), [formats]);
|
|
130
|
+
const onSegmentChange = React.useCallback((index) => {
|
|
131
|
+
pickedValue.current = value;
|
|
132
|
+
setSelectedFormat(availableModes[index]);
|
|
133
|
+
}, [availableModes, value]);
|
|
134
|
+
const { dataRow, maxRow, onNavigate } = props;
|
|
135
|
+
useKeyEvents(React.useMemo(() => [{
|
|
136
|
+
key: "ArrowUp",
|
|
137
|
+
callback: (e) => {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
if (dataRow > 0) onNavigate(-1);
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "ArrowDown",
|
|
143
|
+
callback: (e) => {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
if (dataRow < maxRow) onNavigate(1);
|
|
146
|
+
}
|
|
147
|
+
}], [
|
|
148
|
+
dataRow,
|
|
149
|
+
maxRow,
|
|
150
|
+
onNavigate
|
|
151
|
+
]));
|
|
152
|
+
const rawText = React.useMemo(() => props.structuredValue == null ? props.formattedValue ?? "NULL" : structuredValueToText(props.structuredValue), [props.structuredValue, props.formattedValue]);
|
|
153
|
+
return /* @__PURE__ */ jsx(Overlay, {
|
|
154
|
+
centered: true,
|
|
155
|
+
onEscape: props.onClose,
|
|
156
|
+
onClickOutside: props.onClose,
|
|
157
|
+
preventFocusOnOpen: true,
|
|
158
|
+
width: OverlaySize.XL,
|
|
159
|
+
maxHeight: OverlaySize.XL,
|
|
160
|
+
expanded,
|
|
161
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
162
|
+
className: modal,
|
|
163
|
+
"data-expanded": expanded || void 0,
|
|
164
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
165
|
+
className: main,
|
|
166
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
167
|
+
className: header,
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsxs("span", {
|
|
170
|
+
className: header_title,
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsx("span", {
|
|
173
|
+
className: header_title_label,
|
|
174
|
+
children: "row"
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx("span", {
|
|
177
|
+
className: header_title_equal,
|
|
178
|
+
children: "="
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ jsx("span", {
|
|
181
|
+
className: header_title_index,
|
|
182
|
+
children: props.dataRow
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ jsx("span", {
|
|
185
|
+
className: header_title_label,
|
|
186
|
+
children: "field"
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsx("span", {
|
|
189
|
+
className: header_title_equal,
|
|
190
|
+
children: "="
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("span", {
|
|
193
|
+
className: header_title_field,
|
|
194
|
+
children: props.columnName ?? "value"
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsx("div", { className: header_spacer }),
|
|
199
|
+
/* @__PURE__ */ jsx(CopyToClipboardButton, {
|
|
200
|
+
variant: ButtonVariant.Invisible,
|
|
201
|
+
size: ButtonSize.Small,
|
|
202
|
+
value: rawText,
|
|
203
|
+
logContext: LOG_CTX,
|
|
204
|
+
"aria-label": "Copy raw output",
|
|
205
|
+
"aria-labelledby": ""
|
|
206
|
+
}),
|
|
207
|
+
availableModes.length > 1 && /* @__PURE__ */ jsx(SegmentedControl, {
|
|
208
|
+
"aria-label": "Format mode",
|
|
209
|
+
size: SegmentedControlSize.Small,
|
|
210
|
+
onChange: onSegmentChange,
|
|
211
|
+
children: availableModes.map((mode) => /* @__PURE__ */ jsx(SegmentedControl.Button, {
|
|
212
|
+
selected: mode === selectedFormat,
|
|
213
|
+
children: FORMAT_LABELS[mode]
|
|
214
|
+
}, mode))
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
218
|
+
className: `${body} ${selectedFormat === FormatMode.Structured ? body_padded : ""}`,
|
|
219
|
+
children: [
|
|
220
|
+
selectedFormat === FormatMode.Raw && /* @__PURE__ */ jsx("div", {
|
|
221
|
+
className: "dashql_codemirror_container_gO7gQP",
|
|
222
|
+
children: props.rawView(rawText)
|
|
223
|
+
}),
|
|
224
|
+
selectedFormat === FormatMode.Structured && formats.json != null && /* @__PURE__ */ jsx(StructuredValueView, { value: formats.json }),
|
|
225
|
+
selectedFormat === FormatMode.SQL && formats.sql != null && /* @__PURE__ */ jsx(SqlTextView, {
|
|
226
|
+
originalText: formats.sql.originalText,
|
|
227
|
+
formattedText: formats.sql.formattedText,
|
|
228
|
+
sqlView: props.sqlView
|
|
229
|
+
}),
|
|
230
|
+
selectedFormat === FormatMode.Plan && formats.plan != null && props.planView({
|
|
231
|
+
engine: detectPlanEngine(formats.plan) ?? dashql.buffers.profile.ProfileEngine.HYPER,
|
|
232
|
+
planText: formats.plan,
|
|
233
|
+
className: "dashql_plan_container_TGXx4S",
|
|
234
|
+
fallback: /* @__PURE__ */ jsx("div", {
|
|
235
|
+
className: "dashql_plan_error_DGKes6",
|
|
236
|
+
children: "Could not render plan"
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
]
|
|
240
|
+
})]
|
|
241
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
242
|
+
className: sidebar,
|
|
243
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
244
|
+
className: sidebar_top,
|
|
245
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
246
|
+
variant: ButtonVariant.Invisible,
|
|
247
|
+
"aria-label": "Close",
|
|
248
|
+
onClick: props.onClose,
|
|
249
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
250
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
251
|
+
variant: ButtonVariant.Invisible,
|
|
252
|
+
"aria-label": expanded ? "Restore size" : "Expand",
|
|
253
|
+
"aria-pressed": expanded,
|
|
254
|
+
onClick: () => setExpanded((e) => !e),
|
|
255
|
+
children: expanded ? /* @__PURE__ */ jsx(ScreenNormalIcon, {}) : /* @__PURE__ */ jsx(ScreenFullIcon, {})
|
|
256
|
+
})]
|
|
257
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
258
|
+
className: sidebar_bottom,
|
|
259
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
260
|
+
variant: ButtonVariant.Invisible,
|
|
261
|
+
"aria-label": "Previous row",
|
|
262
|
+
onClick: () => props.onNavigate(-1),
|
|
263
|
+
disabled: props.dataRow <= 0,
|
|
264
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, {})
|
|
265
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
266
|
+
variant: ButtonVariant.Invisible,
|
|
267
|
+
"aria-label": "Next row",
|
|
268
|
+
onClick: () => props.onNavigate(1),
|
|
269
|
+
disabled: props.dataRow >= props.maxRow,
|
|
270
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
271
|
+
})]
|
|
272
|
+
})]
|
|
273
|
+
})]
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
export { CellDetailOverlay, STRUCTURED_ARRAY_PAGE_SIZE, detectFormats, detectStructuredFormats, structuredValueToText };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var modal = "dashql_modal_tAM1M9";
|
|
2
|
+
var main = "dashql_main_2tUSSR";
|
|
3
|
+
var plan_container = "dashql_plan_container_TGXx4S";
|
|
4
|
+
var sidebar = "dashql_sidebar_u4eC_u";
|
|
5
|
+
var sidebar_top = "dashql_sidebar_top_MAV5oV";
|
|
6
|
+
var sidebar_bottom = "dashql_sidebar_bottom_kKpc3l";
|
|
7
|
+
var header = "dashql_header_If9lMh";
|
|
8
|
+
var header_title = "dashql_header_title_N9rPt3";
|
|
9
|
+
var header_title_label = "dashql_header_title_label_OQ3A-h";
|
|
10
|
+
var header_title_equal = "dashql_header_title_equal_h8e6qh";
|
|
11
|
+
var header_title_index = "dashql_header_title_index_ZToGtP";
|
|
12
|
+
var header_title_field = "dashql_header_title_field_5-kU34";
|
|
13
|
+
var header_spacer = "dashql_header_spacer_2gcZ1k";
|
|
14
|
+
var body = "dashql_body_94i4V_";
|
|
15
|
+
var body_padded = "dashql_body_padded_mFNlrY";
|
|
16
|
+
var structured_view = "dashql_structured_view_DH60JU";
|
|
17
|
+
var plan_error = "dashql_plan_error_DGKes6";
|
|
18
|
+
var codemirror_container = "dashql_codemirror_container_gO7gQP";
|
|
19
|
+
var pretty_toggle = "dashql_pretty_toggle_m-OdDP";
|
|
20
|
+
var pretty_toggle_button = "dashql_pretty_toggle_button_luaCAy";
|
|
21
|
+
export { body, body_padded, codemirror_container, header, header_spacer, header_title, header_title_equal, header_title_field, header_title_index, header_title_label, main, modal, plan_container, plan_error, pretty_toggle, pretty_toggle_button, sidebar, sidebar_bottom, sidebar_top, structured_view };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ResultProjection = {
|
|
3
|
+
text: string;
|
|
4
|
+
} | {
|
|
5
|
+
error: string;
|
|
6
|
+
};
|
|
7
|
+
export interface QueryResultActionMenuProps {
|
|
8
|
+
hasResult: boolean;
|
|
9
|
+
projectColumns: () => ResultProjection | null;
|
|
10
|
+
applyProjection: (text: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function QueryResultActionMenu(props: QueryResultActionMenuProps): React.ReactElement;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { menu } from "./query_result_action_menu.module.js";
|
|
2
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
3
|
+
import { ItemText, ItemTextDescription, ItemTextTitle, Leading, List, ListItem } from "../action_list.js";
|
|
4
|
+
import { AnchorAlignment, AnchorSide } from "../../dom/anchored_position.js";
|
|
5
|
+
import { AnchoredOverlay } from "../anchored_overlay.js";
|
|
6
|
+
import { SymbolIcon } from "../symbol_icon.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var MoreIcon = SymbolIcon("kebab_horizontal");
|
|
10
|
+
var ProjectionIcon = SymbolIcon("columns_16");
|
|
11
|
+
function QueryResultActionMenu(props) {
|
|
12
|
+
const [open, setOpen] = React.useState(false);
|
|
13
|
+
const [projection, setProjection] = React.useState(null);
|
|
14
|
+
const triggerRef = React.useRef(null);
|
|
15
|
+
const openMenu = () => {
|
|
16
|
+
setProjection(null);
|
|
17
|
+
setOpen(true);
|
|
18
|
+
setProjection(props.projectColumns());
|
|
19
|
+
};
|
|
20
|
+
const applyProjection = () => {
|
|
21
|
+
setOpen(false);
|
|
22
|
+
if (projection == null || !("text" in projection)) return;
|
|
23
|
+
props.applyProjection(projection.text);
|
|
24
|
+
};
|
|
25
|
+
const projectionText = projection != null && "text" in projection ? projection.text : null;
|
|
26
|
+
const projectionError = projection != null && "error" in projection ? projection.error : null;
|
|
27
|
+
return /* @__PURE__ */ jsx(AnchoredOverlay, {
|
|
28
|
+
open,
|
|
29
|
+
onOpen: openMenu,
|
|
30
|
+
onClose: () => setOpen(false),
|
|
31
|
+
side: AnchorSide.OutsideBottom,
|
|
32
|
+
align: AnchorAlignment.End,
|
|
33
|
+
anchorOffset: 4,
|
|
34
|
+
anchorRef: triggerRef,
|
|
35
|
+
returnFocusRef: triggerRef,
|
|
36
|
+
renderAnchor: (anchorProps) => /* @__PURE__ */ jsx(IconButton, {
|
|
37
|
+
...anchorProps,
|
|
38
|
+
ref: triggerRef,
|
|
39
|
+
variant: ButtonVariant.Invisible,
|
|
40
|
+
size: ButtonSize.Small,
|
|
41
|
+
"aria-label": "More actions for the query result",
|
|
42
|
+
"data-testid": "query-result-more-actions",
|
|
43
|
+
disabled: !props.hasResult,
|
|
44
|
+
children: /* @__PURE__ */ jsx(MoreIcon, { size: 16 })
|
|
45
|
+
}),
|
|
46
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: menu,
|
|
48
|
+
role: "dialog",
|
|
49
|
+
"aria-label": "Query result actions",
|
|
50
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
51
|
+
"aria-label": "Query result actions",
|
|
52
|
+
children: /* @__PURE__ */ jsxs(ListItem, {
|
|
53
|
+
"data-testid": "query-result-project-columns",
|
|
54
|
+
disabled: projectionText == null,
|
|
55
|
+
onClick: applyProjection,
|
|
56
|
+
children: [/* @__PURE__ */ jsx(Leading, { children: /* @__PURE__ */ jsx(ProjectionIcon, { size: 16 }) }), /* @__PURE__ */ jsxs(ItemText, { children: [/* @__PURE__ */ jsx(ItemTextTitle, { children: "Project Columns" }), projectionError != null ? /* @__PURE__ */ jsx(ItemTextDescription, { children: projectionError }) : void 0] })]
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export { QueryResultActionMenu };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as arrow from 'apache-arrow';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { ComputationModel } from '../../models/computation_model.js';
|
|
4
|
+
export interface QueryResultDetailsLayout {
|
|
5
|
+
fitHeight?: boolean;
|
|
6
|
+
maxHeight?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TableDetailsProps {
|
|
9
|
+
title: string;
|
|
10
|
+
computation: ComputationModel | null;
|
|
11
|
+
resultTable?: arrow.Table | null;
|
|
12
|
+
actions?: React.ReactNode;
|
|
13
|
+
fitHeight?: boolean;
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
table: (layout: QueryResultDetailsLayout) => React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export declare function TableDetails(props: TableDetailsProps): React.ReactElement;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { body, body_fit_height, root, root_fit_height } from "./query_result_details.module.js";
|
|
2
|
+
import { TabHeader, formatRowCountDetail } from "../tab_header.js";
|
|
3
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
4
|
+
import { SymbolIcon } from "../symbol_icon.js";
|
|
5
|
+
import { classNames } from "../../dom/classnames.js";
|
|
6
|
+
import { formatResultDetail } from "./query_result_header.js";
|
|
7
|
+
import { TableSearchToolbar, useResultRowCounts } from "./query_result_toolbar.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var HEADER_HEIGHT = 32;
|
|
11
|
+
var ClearFiltersIcon = SymbolIcon("filter_remove_24");
|
|
12
|
+
function TableDetails(props) {
|
|
13
|
+
const computation = props.computation;
|
|
14
|
+
const counts = useResultRowCounts(computation);
|
|
15
|
+
const hasCrossFilters = (computation?.computation.crossFilters.length ?? 0) > 0;
|
|
16
|
+
const clearCrossFilters = React.useCallback(() => {
|
|
17
|
+
computation?.dispatch({ kind: "clearCrossFilters" });
|
|
18
|
+
}, [computation]);
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: classNames(root, { [root_fit_height]: props.fitHeight }),
|
|
21
|
+
children: [/* @__PURE__ */ jsx(TabHeader, {
|
|
22
|
+
title: props.title,
|
|
23
|
+
detail: formatResultDetail(counts.matchingRows == null ? formatRowCountDetail(counts.totalRows) : `${counts.matchingRows} of ${counts.currentRows ?? counts.totalRows ?? 0} rows`, props.resultTable ?? null),
|
|
24
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx(TableSearchToolbar, { computation }),
|
|
26
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
27
|
+
variant: ButtonVariant.Invisible,
|
|
28
|
+
size: ButtonSize.Small,
|
|
29
|
+
"aria-label": "Clear all cross-filters",
|
|
30
|
+
"data-testid": "clear-cross-filters",
|
|
31
|
+
onClick: clearCrossFilters,
|
|
32
|
+
disabled: !hasCrossFilters,
|
|
33
|
+
children: /* @__PURE__ */ jsx(ClearFiltersIcon, { size: 16 })
|
|
34
|
+
}),
|
|
35
|
+
props.actions
|
|
36
|
+
] })
|
|
37
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
38
|
+
className: classNames(body, { [body_fit_height]: props.fitHeight }),
|
|
39
|
+
children: props.table({
|
|
40
|
+
fitHeight: props.fitHeight,
|
|
41
|
+
maxHeight: props.maxHeight == null ? void 0 : Math.max(0, props.maxHeight - HEADER_HEIGHT)
|
|
42
|
+
})
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export { TableDetails };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
3
|
+
export type ExportParquet = (tableId: number) => Promise<Uint8Array>;
|
|
4
|
+
export interface QueryResultDownloadButtonProps {
|
|
5
|
+
model: QueryModel;
|
|
6
|
+
exportParquet: ExportParquet | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function QueryResultDownloadButton({ model, exportParquet }: QueryResultDownloadButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
2
|
+
import { DownloadIcon } from "../symbol_icon.js";
|
|
3
|
+
import { useLogger } from "../../logger.js";
|
|
4
|
+
import { useHost } from "../../host.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
8
|
+
import { stringifyError } from "@akohn/dashql/platform/logger/logger";
|
|
9
|
+
function QueryResultDownloadButton({ model, exportParquet }) {
|
|
10
|
+
const { query } = model;
|
|
11
|
+
const { downloadFile } = useHost();
|
|
12
|
+
const logger = useLogger();
|
|
13
|
+
const [downloading, setDownloading] = React.useState(false);
|
|
14
|
+
const computation = model.computation?.computation ?? null;
|
|
15
|
+
const tableId = exportParquet != null && query.status === QueryExecutionStatus.SUCCEEDED && computation?.dataFrame != null ? computation.tableId : null;
|
|
16
|
+
const download = async () => {
|
|
17
|
+
if (exportParquet == null || tableId == null || downloading) return;
|
|
18
|
+
setDownloading(true);
|
|
19
|
+
try {
|
|
20
|
+
const bytes = await exportParquet(tableId);
|
|
21
|
+
await downloadFile(bytes, `query-result-${query.queryId}.parquet`);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
logger.error("Failed to download query result", { error: stringifyError(error) }, "query_result_download");
|
|
24
|
+
} finally {
|
|
25
|
+
setDownloading(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
29
|
+
variant: ButtonVariant.Invisible,
|
|
30
|
+
size: ButtonSize.Small,
|
|
31
|
+
"aria-label": "Download query result as Parquet",
|
|
32
|
+
"data-testid": "download-query-result",
|
|
33
|
+
disabled: tableId == null || downloading,
|
|
34
|
+
onClick: download,
|
|
35
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, { size: 16 })
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { QueryResultDownloadButton };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { type QueryExecutionState } from '@akohn/dashql/platform/query/query_execution_state';
|
|
4
|
+
import { type ResultRowCounts } from './query_result_toolbar.js';
|
|
5
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
6
|
+
export declare function formatResultRowCount(counts: ResultRowCounts, maxRows?: number): string | null;
|
|
7
|
+
export declare function getResultTableBytes(table: arrow.Table): number;
|
|
8
|
+
export declare function formatResultDetail(rowCount: string | null, resultTable: arrow.Table | null): string | null;
|
|
9
|
+
export interface QueryResultHeaderProps {
|
|
10
|
+
model: QueryModel;
|
|
11
|
+
maxRows?: number;
|
|
12
|
+
onShowTable?: () => void;
|
|
13
|
+
actions?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function QueryResultHeader(props: QueryResultHeaderProps): React.ReactElement;
|
|
16
|
+
export interface QueryResultPanelProps {
|
|
17
|
+
query: QueryExecutionState | null;
|
|
18
|
+
header: (maxRows: number) => React.ReactNode;
|
|
19
|
+
table: (maxRows: number) => React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare function QueryResultPanel(props: QueryResultPanelProps): React.ReactElement;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { panel, panel_body } from "./query_result_header.module.js";
|
|
2
|
+
import { TabHeader } from "../tab_header.js";
|
|
3
|
+
import { QueryStatusPlaceholder } from "../card_placeholder.js";
|
|
4
|
+
import { fittingRowCount } from "../data_table/data_table.js";
|
|
5
|
+
import { formatBytes } from "../../format/format.js";
|
|
6
|
+
import { useResultRowCounts } from "./query_result_toolbar.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
10
|
+
function formatResultRowCount(counts, maxRows = Infinity) {
|
|
11
|
+
const { totalRows, currentRows, matchingRows } = counts;
|
|
12
|
+
if (totalRows == null) return null;
|
|
13
|
+
if (matchingRows != null) return matchingRows > maxRows ? `${maxRows} of ${matchingRows} matching rows` : `${matchingRows} of ${currentRows ?? totalRows} rows`;
|
|
14
|
+
return totalRows > maxRows ? `${maxRows} of ${totalRows} rows` : `${totalRows} ${totalRows === 1 ? "row" : "rows"}`;
|
|
15
|
+
}
|
|
16
|
+
var resultTableBytes = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
function getResultTableBytes(table) {
|
|
18
|
+
const cached = resultTableBytes.get(table);
|
|
19
|
+
if (cached !== void 0) return cached;
|
|
20
|
+
const dictionaries = /* @__PURE__ */ new Set();
|
|
21
|
+
const collectDictionaries = (data) => {
|
|
22
|
+
if (data.dictionary != null) dictionaries.add(data.dictionary);
|
|
23
|
+
for (const child of data.children) collectDictionaries(child);
|
|
24
|
+
};
|
|
25
|
+
let bytes = 0;
|
|
26
|
+
for (const batch of table.batches) {
|
|
27
|
+
bytes += batch.data.byteLength;
|
|
28
|
+
collectDictionaries(batch.data);
|
|
29
|
+
}
|
|
30
|
+
for (const dictionary of dictionaries) for (const data of dictionary.data) bytes += data.byteLength;
|
|
31
|
+
resultTableBytes.set(table, bytes);
|
|
32
|
+
return bytes;
|
|
33
|
+
}
|
|
34
|
+
function formatResultDetail(rowCount, resultTable) {
|
|
35
|
+
if (rowCount == null || resultTable == null) return rowCount;
|
|
36
|
+
return `${rowCount}, ${formatBytes(getResultTableBytes(resultTable))}`;
|
|
37
|
+
}
|
|
38
|
+
function QueryResultHeader(props) {
|
|
39
|
+
const maxRows = props.maxRows ?? Infinity;
|
|
40
|
+
const counts = useResultRowCounts(props.model.computation);
|
|
41
|
+
const displayedRows = counts.matchingRows ?? counts.totalRows;
|
|
42
|
+
return /* @__PURE__ */ jsx(TabHeader, {
|
|
43
|
+
title: "Query Results",
|
|
44
|
+
detail: formatResultDetail(formatResultRowCount(counts, maxRows), props.model.result),
|
|
45
|
+
onClick: props.onShowTable,
|
|
46
|
+
detailIsLink: displayedRows != null && displayedRows > maxRows,
|
|
47
|
+
actions: props.actions
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function QueryResultPanel(props) {
|
|
51
|
+
const bodyRef = React.useRef(null);
|
|
52
|
+
const [bodyHeight, setBodyHeight] = React.useState(null);
|
|
53
|
+
React.useLayoutEffect(() => {
|
|
54
|
+
const body = bodyRef.current;
|
|
55
|
+
if (body == null) return;
|
|
56
|
+
setBodyHeight(body.clientHeight);
|
|
57
|
+
const observer = new ResizeObserver((entries) => setBodyHeight(entries[0]?.contentRect.height ?? body.clientHeight));
|
|
58
|
+
observer.observe(body);
|
|
59
|
+
return () => observer.disconnect();
|
|
60
|
+
}, []);
|
|
61
|
+
const maxRows = bodyHeight == null ? 0 : fittingRowCount(bodyHeight);
|
|
62
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
63
|
+
className: panel,
|
|
64
|
+
children: [props.query != null && props.header(maxRows), /* @__PURE__ */ jsx("div", {
|
|
65
|
+
ref: bodyRef,
|
|
66
|
+
className: panel_body,
|
|
67
|
+
children: props.query == null || props.query.resultTable == null && props.query.status !== QueryExecutionStatus.SUCCEEDED ? /* @__PURE__ */ jsx(QueryStatusPlaceholder, { query: props.query }) : props.table(maxRows)
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export { QueryResultHeader, QueryResultPanel, formatResultDetail, formatResultRowCount, getResultTableBytes };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComputationSearch } from '@akohn/dashql';
|
|
3
|
+
export { useQueryResultSearch } from './use_query_result_search.js';
|
|
4
|
+
interface Props {
|
|
5
|
+
columnSearch: ComputationSearch;
|
|
6
|
+
dataSearch: ComputationSearch;
|
|
7
|
+
onColumnPatternChange: (value: string) => void;
|
|
8
|
+
onDataPatternChange: (value: string) => void;
|
|
9
|
+
columnMatchCount: number | null;
|
|
10
|
+
dataMatchCount: number | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function QueryResultSearchControls(props: Props): React.JSX.Element;
|