@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,23 @@
|
|
|
1
|
+
var container = "dashql_container_ieL1zt";
|
|
2
|
+
var container_split = "dashql_container_split_wcc73e";
|
|
3
|
+
var primary_body = "dashql_primary_body_ibG_PY";
|
|
4
|
+
var split_body = "dashql_split_body_C26NTL";
|
|
5
|
+
var resize_handle = "dashql_resize_handle_qIadRB";
|
|
6
|
+
var resize_handle_dragging = "dashql_resize_handle_dragging_sJpPsX";
|
|
7
|
+
var resize_handle_bar = "dashql_resize_handle_bar_1UWWkB";
|
|
8
|
+
var tabs = "dashql_tabs_jgtb4-";
|
|
9
|
+
var tabs_list = "dashql_tabs_list_eRuVAg";
|
|
10
|
+
var tabs_group = "dashql_tabs_group_4IUXtZ";
|
|
11
|
+
var tabs_separator = "dashql_tabs_separator_2LKLxC";
|
|
12
|
+
var tabs_footer = "dashql_tabs_footer_VXxwoA";
|
|
13
|
+
var stacked_tab = "dashql_stacked_tab_dBUOQg";
|
|
14
|
+
var stacked_tab_icon = "dashql_stacked_tab_icon_Pnqskx";
|
|
15
|
+
var stacked_tab_icon_split = "dashql_stacked_tab_icon_split_8xqHtc";
|
|
16
|
+
var stacked_tab_icon_half_first = "dashql_stacked_tab_icon_half_first_qBYOKW";
|
|
17
|
+
var stacked_tab_icon_half = "dashql_stacked_tab_icon_half_MZXF0o";
|
|
18
|
+
var stacked_tab_split_number = "dashql_stacked_tab_split_number_P3u505";
|
|
19
|
+
var stacked_tab_active = "dashql_stacked_tab_active_AvAQgE";
|
|
20
|
+
var split_toggle = "dashql_split_toggle_HtEPXl";
|
|
21
|
+
var split_toggle_icon = "dashql_split_toggle_icon_MfXFK5";
|
|
22
|
+
var split_toggle_active = "dashql_split_toggle_active_1afIdW";
|
|
23
|
+
export { container, container_split, primary_body, resize_handle, resize_handle_bar, resize_handle_dragging, split_body, split_toggle, split_toggle_active, split_toggle_icon, stacked_tab, stacked_tab_active, stacked_tab_icon, stacked_tab_icon_half, stacked_tab_icon_half_first, stacked_tab_icon_split, stacked_tab_split_number, tabs, tabs_footer, tabs_group, tabs_list, tabs_separator };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function cappedRowsText(part: 'first' | 'last', shown: number, rows: number): string;
|
|
3
|
+
export interface CappedRowsProps {
|
|
4
|
+
part: 'first' | 'last';
|
|
5
|
+
shown: number;
|
|
6
|
+
rows: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function CappedRows(props: CappedRowsProps): React.ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { icon, root } from "./capped_rows.module.js";
|
|
2
|
+
import { AlertIcon } from "../symbol_icon.js";
|
|
3
|
+
import { classNames } from "../../dom/classnames.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var ROW_COUNT_FORMAT = new Intl.NumberFormat("en-US");
|
|
7
|
+
function cappedRowsText(part, shown, rows) {
|
|
8
|
+
return `Showing the ${part} ${ROW_COUNT_FORMAT.format(shown)} of ${ROW_COUNT_FORMAT.format(rows)} rows`;
|
|
9
|
+
}
|
|
10
|
+
function CappedRows(props) {
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
12
|
+
className: classNames(root, props.className),
|
|
13
|
+
role: "status",
|
|
14
|
+
title: "The view caps the rows of the result, aggregate the query to show all of them",
|
|
15
|
+
"data-testid": "capped-rows",
|
|
16
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, {
|
|
17
|
+
size: 16,
|
|
18
|
+
className: icon,
|
|
19
|
+
"aria-hidden": "true"
|
|
20
|
+
}), /* @__PURE__ */ jsx("span", { children: cappedRowsText(props.part, props.shown, props.rows) })]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export { CappedRows, cappedRowsText };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TopLevelSpec } from 'vega-lite';
|
|
3
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
4
|
+
import { renderVegaLitePng } from '../../vegalite/vegalite_image.js';
|
|
5
|
+
export interface ChartDownloadButtonProps {
|
|
6
|
+
model: QueryModel;
|
|
7
|
+
spec: TopLevelSpec;
|
|
8
|
+
dependencies?: {
|
|
9
|
+
renderVegaLitePng: typeof renderVegaLitePng;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function ChartDownloadButton({ model, spec, dependencies }: ChartDownloadButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
2
|
+
import { DownloadIcon } from "../symbol_icon.js";
|
|
3
|
+
import { CHART_ROWS, arrowTableToRows } from "../../vegalite/vegalite_rows.js";
|
|
4
|
+
import { renderVegaLitePng } from "../../vegalite/vegalite_image.js";
|
|
5
|
+
import { useLogger } from "../../logger.js";
|
|
6
|
+
import { useHost } from "../../host.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
10
|
+
import { stringifyError } from "@akohn/dashql/platform/logger/logger";
|
|
11
|
+
var DEFAULT_DEPENDENCIES = { renderVegaLitePng };
|
|
12
|
+
function ChartDownloadButton({ model, spec, dependencies = DEFAULT_DEPENDENCIES }) {
|
|
13
|
+
const { query, computation } = model;
|
|
14
|
+
const { downloadFile } = useHost();
|
|
15
|
+
const logger = useLogger();
|
|
16
|
+
const [downloading, setDownloading] = React.useState(false);
|
|
17
|
+
const hasResult = query.status === QueryExecutionStatus.SUCCEEDED && computation != null;
|
|
18
|
+
const download = async () => {
|
|
19
|
+
if (!hasResult || downloading) return;
|
|
20
|
+
setDownloading(true);
|
|
21
|
+
try {
|
|
22
|
+
const rows = await computation.previewRows(0, CHART_ROWS, false);
|
|
23
|
+
const image = await dependencies.renderVegaLitePng(spec, arrowTableToRows(rows));
|
|
24
|
+
await downloadFile(image.png, `chart-${query.queryId}.png`);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
logger.error("Failed to download chart", { error: stringifyError(error) }, "chart_download");
|
|
27
|
+
} finally {
|
|
28
|
+
setDownloading(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
32
|
+
variant: ButtonVariant.Invisible,
|
|
33
|
+
size: ButtonSize.Small,
|
|
34
|
+
"aria-label": "Download chart as PNG",
|
|
35
|
+
"data-testid": "download-chart-png",
|
|
36
|
+
disabled: !hasResult || downloading,
|
|
37
|
+
onClick: download,
|
|
38
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, { size: 16 })
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { ChartDownloadButton };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { buffers } from '@akohn/dashql';
|
|
3
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
4
|
+
type KpiSpec = buffers.visualization.KpiSpecT;
|
|
5
|
+
export interface KpiViewProps {
|
|
6
|
+
model: QueryModel | null;
|
|
7
|
+
spec: KpiSpec | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function KpiView(props: KpiViewProps): React.ReactElement;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { area_bottom, area_top, bar, bar_last, chart, content, label, root, rule, value } from "./kpi_view.module.js";
|
|
2
|
+
import { CardPlaceholder } from "../card_placeholder.js";
|
|
3
|
+
import { useObservedSize } from "../size_observer.js";
|
|
4
|
+
import { ResultRowsPlaceholder, useResultRows } from "./result_rows.js";
|
|
5
|
+
import { CappedRows } from "./capped_rows.js";
|
|
6
|
+
import { useLogger } from "../../logger.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { KPI_CARD_ROWS, formatKpiChange, kpiBase, readKpi } from "@akohn/dashql/platform/workbook/kpi_reading";
|
|
10
|
+
var CHART_TOP_SHARE = .45;
|
|
11
|
+
var CHART_TOP_MIN = 30;
|
|
12
|
+
var CHART_BOTTOM = 20;
|
|
13
|
+
var LABEL_INSET = 8;
|
|
14
|
+
var LABEL_INSET_RIGHT = 20;
|
|
15
|
+
var BAR_GAP = 1;
|
|
16
|
+
function layoutChart(reading, width, height) {
|
|
17
|
+
const points = reading.points;
|
|
18
|
+
const top = Math.max(CHART_TOP_MIN, Math.round(height * CHART_TOP_SHARE));
|
|
19
|
+
const bottom = height - CHART_BOTTOM;
|
|
20
|
+
if (reading.chart == null || points.length < 2 || width < 40 || bottom - top < 12) return null;
|
|
21
|
+
const yOf = (y) => top + (1 - y) * (bottom - top);
|
|
22
|
+
if (reading.chart === "bar") {
|
|
23
|
+
const band = width / points.length;
|
|
24
|
+
const gap = band > 3 ? BAR_GAP : 0;
|
|
25
|
+
const base = yOf(reading.zero);
|
|
26
|
+
return {
|
|
27
|
+
line: null,
|
|
28
|
+
area: null,
|
|
29
|
+
bars: points.map(([, y], i) => {
|
|
30
|
+
const end = yOf(y);
|
|
31
|
+
return {
|
|
32
|
+
x: i * band,
|
|
33
|
+
y: Math.min(base, end),
|
|
34
|
+
width: Math.max(band - gap, .5),
|
|
35
|
+
height: Math.max(Math.abs(end - base), 1)
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
top,
|
|
39
|
+
bottom
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const line = `M${points.map(([x, y]) => `${(x * width).toFixed(1)},${yOf(y).toFixed(1)}`).join("L")}`;
|
|
43
|
+
return {
|
|
44
|
+
line,
|
|
45
|
+
area: `${line}L${width},${height}L0,${height}Z`,
|
|
46
|
+
bars: [],
|
|
47
|
+
top,
|
|
48
|
+
bottom
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function KpiChart(props) {
|
|
52
|
+
const gradient = React.useId();
|
|
53
|
+
const layout = layoutChart(props.reading, props.width, props.height);
|
|
54
|
+
const axis$1 = props.reading.axis;
|
|
55
|
+
if (layout == null) return null;
|
|
56
|
+
const right = props.width - LABEL_INSET;
|
|
57
|
+
const xLabelY = props.height - 7;
|
|
58
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
59
|
+
className: chart,
|
|
60
|
+
width: props.width,
|
|
61
|
+
height: props.height,
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
"data-testid": "kpi-chart",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
66
|
+
id: gradient,
|
|
67
|
+
x1: "0",
|
|
68
|
+
y1: layout.top,
|
|
69
|
+
x2: "0",
|
|
70
|
+
y2: props.height,
|
|
71
|
+
gradientUnits: "userSpaceOnUse",
|
|
72
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
73
|
+
offset: "0",
|
|
74
|
+
className: area_top
|
|
75
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
76
|
+
offset: "1",
|
|
77
|
+
className: area_bottom
|
|
78
|
+
})]
|
|
79
|
+
}) }),
|
|
80
|
+
/* @__PURE__ */ jsx("line", {
|
|
81
|
+
className: rule,
|
|
82
|
+
x1: 0,
|
|
83
|
+
x2: props.width,
|
|
84
|
+
y1: layout.top,
|
|
85
|
+
y2: layout.top
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx("line", {
|
|
88
|
+
className: rule,
|
|
89
|
+
x1: 0,
|
|
90
|
+
x2: props.width,
|
|
91
|
+
y1: layout.bottom,
|
|
92
|
+
y2: layout.bottom
|
|
93
|
+
}),
|
|
94
|
+
layout.area != null && /* @__PURE__ */ jsx("path", {
|
|
95
|
+
d: layout.area,
|
|
96
|
+
fill: `url(#${gradient})`
|
|
97
|
+
}),
|
|
98
|
+
layout.line != null && /* @__PURE__ */ jsx("path", {
|
|
99
|
+
className: "dashql_line_rQyP8B",
|
|
100
|
+
d: layout.line
|
|
101
|
+
}),
|
|
102
|
+
layout.bars.map((bar$1, i) => /* @__PURE__ */ jsx("rect", {
|
|
103
|
+
className: i === layout.bars.length - 1 ? bar_last : bar,
|
|
104
|
+
x: bar$1.x,
|
|
105
|
+
y: bar$1.y,
|
|
106
|
+
width: bar$1.width,
|
|
107
|
+
height: bar$1.height
|
|
108
|
+
}, i)),
|
|
109
|
+
axis$1 != null && /* @__PURE__ */ jsxs("g", {
|
|
110
|
+
className: "dashql_axis_xz3qbR",
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ jsx("text", {
|
|
113
|
+
x: right,
|
|
114
|
+
y: layout.top - 4,
|
|
115
|
+
textAnchor: "end",
|
|
116
|
+
children: axis$1.yMax
|
|
117
|
+
}),
|
|
118
|
+
axis$1.yMin != null && /* @__PURE__ */ jsx("text", {
|
|
119
|
+
x: right,
|
|
120
|
+
y: layout.bottom - 4,
|
|
121
|
+
textAnchor: "end",
|
|
122
|
+
children: axis$1.yMin
|
|
123
|
+
}),
|
|
124
|
+
axis$1.xFirst != null && /* @__PURE__ */ jsx("text", {
|
|
125
|
+
x: LABEL_INSET,
|
|
126
|
+
y: xLabelY,
|
|
127
|
+
children: axis$1.xFirst
|
|
128
|
+
}),
|
|
129
|
+
axis$1.xLast != null && /* @__PURE__ */ jsx("text", {
|
|
130
|
+
x: props.width - LABEL_INSET_RIGHT,
|
|
131
|
+
y: xLabelY,
|
|
132
|
+
textAnchor: "end",
|
|
133
|
+
children: axis$1.xLast
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function KpiView(props) {
|
|
141
|
+
const logger = useLogger();
|
|
142
|
+
const rootRef = React.useRef(null);
|
|
143
|
+
const size = useObservedSize(rootRef);
|
|
144
|
+
const resultRows = useResultRows(props.model, "last", KPI_CARD_ROWS, false);
|
|
145
|
+
const { table, rows } = resultRows;
|
|
146
|
+
const reading = React.useMemo(() => {
|
|
147
|
+
if (props.spec == null || table == null) return null;
|
|
148
|
+
try {
|
|
149
|
+
return readKpi(table, props.spec);
|
|
150
|
+
} catch (e) {
|
|
151
|
+
logger.error("cannot read the KPI of a result", { error: String(e) }, "kpi_view");
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}, [
|
|
155
|
+
props.spec,
|
|
156
|
+
table,
|
|
157
|
+
logger
|
|
158
|
+
]);
|
|
159
|
+
if (props.spec == null) return /* @__PURE__ */ jsx(CardPlaceholder, { message: "No visualization available" });
|
|
160
|
+
if (table == null) return /* @__PURE__ */ jsx(ResultRowsPlaceholder, {
|
|
161
|
+
query: props.model?.query ?? null,
|
|
162
|
+
rows: resultRows
|
|
163
|
+
});
|
|
164
|
+
if (reading == null) return /* @__PURE__ */ jsx(CardPlaceholder, { message: "No visualization available" });
|
|
165
|
+
if (reading.missing != null) return /* @__PURE__ */ jsx(CardPlaceholder, { message: reading.missing });
|
|
166
|
+
const direction = reading.change == null || reading.change === 0 ? "flat" : reading.change > 0 ? "up" : "down";
|
|
167
|
+
const base = kpiBase(props.spec) ?? "the previous row";
|
|
168
|
+
const versus$1 = reading.axis?.xBase;
|
|
169
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
170
|
+
className: root,
|
|
171
|
+
ref: rootRef,
|
|
172
|
+
"data-testid": "kpi-view",
|
|
173
|
+
children: [
|
|
174
|
+
size != null && /* @__PURE__ */ jsx(KpiChart, {
|
|
175
|
+
reading,
|
|
176
|
+
width: size.width,
|
|
177
|
+
height: size.height
|
|
178
|
+
}),
|
|
179
|
+
rows > table.numRows && /* @__PURE__ */ jsx(CappedRows, {
|
|
180
|
+
className: "dashql_capped_EjqvDB",
|
|
181
|
+
part: "last",
|
|
182
|
+
shown: table.numRows,
|
|
183
|
+
rows
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ jsxs("div", {
|
|
186
|
+
className: content,
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ jsx("div", {
|
|
189
|
+
className: label,
|
|
190
|
+
children: reading.label
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("div", {
|
|
193
|
+
className: value,
|
|
194
|
+
"data-testid": "kpi-value",
|
|
195
|
+
children: reading.value ?? "–"
|
|
196
|
+
}),
|
|
197
|
+
reading.change != null && /* @__PURE__ */ jsxs("div", {
|
|
198
|
+
className: "dashql_change_row_PL2Os0",
|
|
199
|
+
title: `Change against ${base}`,
|
|
200
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
201
|
+
className: "dashql_change_tMT6J4",
|
|
202
|
+
"data-direction": direction,
|
|
203
|
+
"data-testid": "kpi-change",
|
|
204
|
+
children: [direction === "up" ? "▲ " : direction === "down" ? "▼ " : "", formatKpiChange(reading.change)]
|
|
205
|
+
}), versus$1 != null && /* @__PURE__ */ jsxs("span", {
|
|
206
|
+
className: "dashql_versus_MdswnR",
|
|
207
|
+
children: ["vs ", versus$1]
|
|
208
|
+
})]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
export { KpiView };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var root = "dashql_root_XblgMh";
|
|
2
|
+
var chart = "dashql_chart_7Zh06o";
|
|
3
|
+
var line = "dashql_line_rQyP8B";
|
|
4
|
+
var area_top = "dashql_area_top_eYt9CU";
|
|
5
|
+
var area_bottom = "dashql_area_bottom_ircCn2";
|
|
6
|
+
var bar = "dashql_bar_mUaE0N";
|
|
7
|
+
var bar_last = "dashql_bar_last_93GnCi";
|
|
8
|
+
var rule = "dashql_rule_TwUPZD";
|
|
9
|
+
var axis = "dashql_axis_xz3qbR";
|
|
10
|
+
var content = "dashql_content_4X1iNA";
|
|
11
|
+
var label = "dashql_label_zGAc9J";
|
|
12
|
+
var value = "dashql_value_4EzylC";
|
|
13
|
+
var change_row = "dashql_change_row_PL2Os0";
|
|
14
|
+
var change = "dashql_change_tMT6J4";
|
|
15
|
+
var versus = "dashql_versus_MdswnR";
|
|
16
|
+
var capped = "dashql_capped_EjqvDB";
|
|
17
|
+
export { area_bottom, area_top, axis, bar, bar_last, capped, change, change_row, chart, content, label, line, root, rule, value, versus };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { buffers } from '@akohn/dashql';
|
|
3
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
4
|
+
type MarkdownNode = buffers.visualization.MarkdownNodeT;
|
|
5
|
+
type MarkdownSpec = buffers.visualization.MarkdownSpecT;
|
|
6
|
+
export declare const MARKDOWN_CARD_ROWS = 100;
|
|
7
|
+
export interface MarkdownViewProps {
|
|
8
|
+
model: QueryModel | null;
|
|
9
|
+
spec: MarkdownSpec | null;
|
|
10
|
+
}
|
|
11
|
+
export declare function MarkdownText(props: {
|
|
12
|
+
document: MarkdownNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
'data-testid'?: string;
|
|
15
|
+
}): React.ReactElement;
|
|
16
|
+
export declare function MarkdownView(props: MarkdownViewProps): React.ReactElement;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { root, row } from "./markdown_view.module.js";
|
|
2
|
+
import { CardPlaceholder } from "../card_placeholder.js";
|
|
3
|
+
import { ResultRowsPlaceholder, useResultRows } from "./result_rows.js";
|
|
4
|
+
import { CappedRows } from "./capped_rows.js";
|
|
5
|
+
import { useLogger } from "../../logger.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ArrowTableFormatter } from "@akohn/dashql/platform/compute/arrow_formatter";
|
|
9
|
+
import { buffers } from "@akohn/dashql";
|
|
10
|
+
var NodeType = buffers.visualization.MarkdownNodeType;
|
|
11
|
+
var MARKDOWN_CARD_ROWS = 100;
|
|
12
|
+
function renderChildren(node, fields, key) {
|
|
13
|
+
return node.children.map((child, index) => renderNode(child, fields, `${key}.${index}`));
|
|
14
|
+
}
|
|
15
|
+
function renderPlainText(nodes, fields) {
|
|
16
|
+
return nodes.map((node) => {
|
|
17
|
+
switch (node.nodeType) {
|
|
18
|
+
case NodeType.TEXT: return readString(node.value);
|
|
19
|
+
case NodeType.FIELD: {
|
|
20
|
+
const field = readString(node.value);
|
|
21
|
+
return fields.has(field) ? fields.get(field) ?? "" : `{{${field}}}`;
|
|
22
|
+
}
|
|
23
|
+
case NodeType.HARD_BREAK: return "\n";
|
|
24
|
+
case NodeType.THEMATIC_BREAK: return "";
|
|
25
|
+
default: return renderPlainText(node.children, fields);
|
|
26
|
+
}
|
|
27
|
+
}).join("");
|
|
28
|
+
}
|
|
29
|
+
function readString(value) {
|
|
30
|
+
if (typeof value === "string") return value;
|
|
31
|
+
return value == null ? "" : new TextDecoder().decode(value);
|
|
32
|
+
}
|
|
33
|
+
function renderNode(node, fields, key) {
|
|
34
|
+
switch (node.nodeType) {
|
|
35
|
+
case NodeType.DOCUMENT:
|
|
36
|
+
case NodeType.SPAN: return /* @__PURE__ */ jsx(React.Fragment, { children: renderChildren(node, fields, key) }, key);
|
|
37
|
+
case NodeType.PARAGRAPH: return /* @__PURE__ */ jsx("p", { children: renderChildren(node, fields, key) }, key);
|
|
38
|
+
case NodeType.BLOCKQUOTE: return /* @__PURE__ */ jsx("blockquote", { children: renderChildren(node, fields, key) }, key);
|
|
39
|
+
case NodeType.LIST_ITEM: return /* @__PURE__ */ jsx("li", { children: renderChildren(node, fields, key) }, key);
|
|
40
|
+
case NodeType.EMPHASIS: return /* @__PURE__ */ jsx("em", { children: renderChildren(node, fields, key) }, key);
|
|
41
|
+
case NodeType.STRONG: return /* @__PURE__ */ jsx("strong", { children: renderChildren(node, fields, key) }, key);
|
|
42
|
+
case NodeType.HEADING: {
|
|
43
|
+
const Heading = `h${node.level}`;
|
|
44
|
+
return /* @__PURE__ */ jsx(Heading, { children: renderChildren(node, fields, key) }, key);
|
|
45
|
+
}
|
|
46
|
+
case NodeType.LIST: {
|
|
47
|
+
const children = renderChildren(node, fields, key);
|
|
48
|
+
return node.ordered ? /* @__PURE__ */ jsx("ol", {
|
|
49
|
+
start: node.start,
|
|
50
|
+
children
|
|
51
|
+
}, key) : /* @__PURE__ */ jsx("ul", { children }, key);
|
|
52
|
+
}
|
|
53
|
+
case NodeType.TEXT: return readString(node.value);
|
|
54
|
+
case NodeType.FIELD: {
|
|
55
|
+
const field = readString(node.value);
|
|
56
|
+
return fields.has(field) ? fields.get(field) : `{{${field}}}`;
|
|
57
|
+
}
|
|
58
|
+
case NodeType.INLINE_CODE: return /* @__PURE__ */ jsx("code", { children: renderChildren(node, fields, key) }, key);
|
|
59
|
+
case NodeType.CODE_BLOCK: {
|
|
60
|
+
const language = readString(node.language);
|
|
61
|
+
return /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", {
|
|
62
|
+
className: language ? `language-${language}` : void 0,
|
|
63
|
+
children: renderChildren(node, fields, key)
|
|
64
|
+
}) }, key);
|
|
65
|
+
}
|
|
66
|
+
case NodeType.LINK: return /* @__PURE__ */ jsx("a", {
|
|
67
|
+
href: readString(node.url),
|
|
68
|
+
title: readString(node.title) || void 0,
|
|
69
|
+
target: "_blank",
|
|
70
|
+
rel: "noopener noreferrer",
|
|
71
|
+
children: renderChildren(node, fields, key)
|
|
72
|
+
}, key);
|
|
73
|
+
case NodeType.IMAGE: {
|
|
74
|
+
const alt = renderPlainText(node.children, fields);
|
|
75
|
+
return /* @__PURE__ */ jsx("img", {
|
|
76
|
+
src: readString(node.url),
|
|
77
|
+
title: readString(node.title) || void 0,
|
|
78
|
+
alt
|
|
79
|
+
}, key);
|
|
80
|
+
}
|
|
81
|
+
case NodeType.HARD_BREAK: return /* @__PURE__ */ jsx("br", {}, key);
|
|
82
|
+
case NodeType.THEMATIC_BREAK: return /* @__PURE__ */ jsx("hr", {}, key);
|
|
83
|
+
case NodeType.NONE: return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var NO_FIELDS = /* @__PURE__ */ new Map();
|
|
87
|
+
function withoutImages(node) {
|
|
88
|
+
if (node.nodeType === NodeType.IMAGE) {
|
|
89
|
+
const span = new buffers.visualization.MarkdownNodeT();
|
|
90
|
+
span.nodeType = NodeType.SPAN;
|
|
91
|
+
span.children = node.children.map(withoutImages);
|
|
92
|
+
return span;
|
|
93
|
+
}
|
|
94
|
+
if (node.children.length === 0) return node;
|
|
95
|
+
const copy = Object.assign(new buffers.visualization.MarkdownNodeT(), node);
|
|
96
|
+
copy.children = node.children.map(withoutImages);
|
|
97
|
+
return copy;
|
|
98
|
+
}
|
|
99
|
+
function MarkdownText(props) {
|
|
100
|
+
const document = React.useMemo(() => withoutImages(props.document), [props.document]);
|
|
101
|
+
return /* @__PURE__ */ jsx("div", {
|
|
102
|
+
className: props.className,
|
|
103
|
+
"data-testid": props["data-testid"],
|
|
104
|
+
children: renderNode(document, NO_FIELDS, "md")
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function MarkdownView(props) {
|
|
108
|
+
const logger = useLogger();
|
|
109
|
+
const resultRows = useResultRows(props.model, "first", 100, false);
|
|
110
|
+
const { table, rows } = resultRows;
|
|
111
|
+
const renderedRows = React.useMemo(() => {
|
|
112
|
+
if (props.spec == null || table == null) return null;
|
|
113
|
+
const fields = /* @__PURE__ */ new Map();
|
|
114
|
+
table.schema.fields.forEach((field, index) => {
|
|
115
|
+
if (!fields.has(field.name)) fields.set(field.name, index);
|
|
116
|
+
});
|
|
117
|
+
const formatter = new ArrowTableFormatter(table.schema, table.batches, logger);
|
|
118
|
+
const rows = [];
|
|
119
|
+
for (let row = 0; row < table.numRows; ++row) {
|
|
120
|
+
const values = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const field of props.spec.fields) {
|
|
122
|
+
const column = fields.get(field);
|
|
123
|
+
if (column != null) values.set(field, formatter.getValue(row, column));
|
|
124
|
+
}
|
|
125
|
+
rows.push(values);
|
|
126
|
+
}
|
|
127
|
+
return rows;
|
|
128
|
+
}, [
|
|
129
|
+
props.spec,
|
|
130
|
+
table,
|
|
131
|
+
logger
|
|
132
|
+
]);
|
|
133
|
+
const document = props.spec?.document ?? null;
|
|
134
|
+
if (document == null) return /* @__PURE__ */ jsx(CardPlaceholder, { message: "No visualization available" });
|
|
135
|
+
if (renderedRows == null) return /* @__PURE__ */ jsx(ResultRowsPlaceholder, {
|
|
136
|
+
query: props.model?.query ?? null,
|
|
137
|
+
rows: resultRows
|
|
138
|
+
});
|
|
139
|
+
if (renderedRows.length === 0) return /* @__PURE__ */ jsx(CardPlaceholder, { message: "Result is empty" });
|
|
140
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
141
|
+
className: root,
|
|
142
|
+
children: [renderedRows.map((fields, row$1) => /* @__PURE__ */ jsx("article", {
|
|
143
|
+
className: row,
|
|
144
|
+
"data-markdown-row": true,
|
|
145
|
+
children: renderNode(document, fields, String(row$1))
|
|
146
|
+
}, row$1)), rows > renderedRows.length && /* @__PURE__ */ jsx(CappedRows, {
|
|
147
|
+
className: "dashql_capped_qr9-4Y",
|
|
148
|
+
part: "first",
|
|
149
|
+
shown: renderedRows.length,
|
|
150
|
+
rows
|
|
151
|
+
})]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export { MARKDOWN_CARD_ROWS, MarkdownText, MarkdownView };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type * as arrow from 'apache-arrow';
|
|
3
|
+
import { type QueryExecutionState } from '@akohn/dashql/platform/query/query_execution_state';
|
|
4
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
5
|
+
export type ResultPart = 'first' | 'last';
|
|
6
|
+
export type ResultRowsStatus = 'waiting' | 'reading' | 'failed' | 'ready';
|
|
7
|
+
export interface ResultRows {
|
|
8
|
+
status: ResultRowsStatus;
|
|
9
|
+
table: arrow.Table | null;
|
|
10
|
+
rows: number;
|
|
11
|
+
error: string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function useResultRows(model: QueryModel | null, part: ResultPart, limit: number, rowNumbers: boolean): ResultRows;
|
|
14
|
+
export declare function ResultRowsPlaceholder(props: {
|
|
15
|
+
query: QueryExecutionState | null;
|
|
16
|
+
rows: ResultRows;
|
|
17
|
+
}): React.ReactElement;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useLogger } from "../../logger.js";
|
|
2
|
+
import { CardPlaceholder, QueryStatusPlaceholder } from "../card_placeholder.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
6
|
+
import { stringifyError } from "@akohn/dashql/platform/logger/logger";
|
|
7
|
+
var NO_ROWS = {
|
|
8
|
+
status: "waiting",
|
|
9
|
+
table: null,
|
|
10
|
+
rows: 0,
|
|
11
|
+
error: null
|
|
12
|
+
};
|
|
13
|
+
function useResultRows(model, part, limit, rowNumbers) {
|
|
14
|
+
const logger = useLogger();
|
|
15
|
+
const succeeded = model?.query.status === QueryExecutionStatus.SUCCEEDED;
|
|
16
|
+
const computation = succeeded ? model?.computation ?? null : null;
|
|
17
|
+
const rows = model?.query.resultTable?.rows ?? computation?.computation.dataTableRows ?? 0;
|
|
18
|
+
const tableId = computation?.computation.tableId ?? null;
|
|
19
|
+
const dataFrame = computation?.computation.dataFrame ?? null;
|
|
20
|
+
const key = tableId == null || dataFrame == null ? null : `${tableId}:${dataFrame}:${part}:${limit}:${rows}:${rowNumbers}`;
|
|
21
|
+
const [state, setState] = React.useState(null);
|
|
22
|
+
const previewRows = React.useRef(computation?.previewRows);
|
|
23
|
+
previewRows.current = computation?.previewRows;
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
const read = previewRows.current;
|
|
26
|
+
if (key == null || read == null) return;
|
|
27
|
+
let current = true;
|
|
28
|
+
read(part === "last" ? Math.max(0, rows - limit) : 0, limit, rowNumbers).then((table) => {
|
|
29
|
+
if (current) setState({
|
|
30
|
+
key,
|
|
31
|
+
table,
|
|
32
|
+
error: null
|
|
33
|
+
});
|
|
34
|
+
}, (error) => {
|
|
35
|
+
if (!current) return;
|
|
36
|
+
logger.warn("Failed to read the rows of a result", { error: stringifyError(error) }, "result_rows");
|
|
37
|
+
setState({
|
|
38
|
+
key,
|
|
39
|
+
table: null,
|
|
40
|
+
error: stringifyError(error)
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
current = false;
|
|
45
|
+
};
|
|
46
|
+
}, [
|
|
47
|
+
key,
|
|
48
|
+
part,
|
|
49
|
+
limit,
|
|
50
|
+
rows,
|
|
51
|
+
rowNumbers,
|
|
52
|
+
logger
|
|
53
|
+
]);
|
|
54
|
+
if (!succeeded) return NO_ROWS;
|
|
55
|
+
const read = state != null && state.key === key ? state : null;
|
|
56
|
+
if (read == null) return {
|
|
57
|
+
status: "reading",
|
|
58
|
+
table: null,
|
|
59
|
+
rows,
|
|
60
|
+
error: null
|
|
61
|
+
};
|
|
62
|
+
if (read.table == null) return {
|
|
63
|
+
status: "failed",
|
|
64
|
+
table: null,
|
|
65
|
+
rows,
|
|
66
|
+
error: read.error
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
status: "ready",
|
|
70
|
+
table: read.table,
|
|
71
|
+
rows,
|
|
72
|
+
error: null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function ResultRowsPlaceholder(props) {
|
|
76
|
+
switch (props.rows.status) {
|
|
77
|
+
case "waiting": return /* @__PURE__ */ jsx(QueryStatusPlaceholder, { query: props.query });
|
|
78
|
+
case "failed": return /* @__PURE__ */ jsx(CardPlaceholder, { message: `Failed to read the rows: ${props.rows.error}` });
|
|
79
|
+
default: return /* @__PURE__ */ jsx(CardPlaceholder, {});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export { ResultRowsPlaceholder, useResultRows };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VegaLiteViewProps } from '../vegalite_view.js';
|
|
3
|
+
export declare const VEGALITE_PREVIEW_INSET = 8;
|
|
4
|
+
export type VegaLitePreviewProps = Omit<VegaLiteViewProps, 'width' | 'height' | 'scale' | 'hideLegend' | 'config' | 'className'> & {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function VegaLitePreview({ width, height, ...props }: VegaLitePreviewProps): React.ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { preview } from "./vegalite_preview.module.js";
|
|
2
|
+
import { createVegaLitePreviewConfig } from "../../vegalite/vegalite_theme.js";
|
|
3
|
+
import { VegaLiteView } from "../vegalite_view.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var VEGALITE_PREVIEW_INSET = 8;
|
|
7
|
+
function VegaLitePreview({ width, height, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(VegaLiteView, {
|
|
9
|
+
...props,
|
|
10
|
+
width: Math.max(0, width - 16),
|
|
11
|
+
height: Math.max(0, height - 16),
|
|
12
|
+
config: createVegaLitePreviewConfig,
|
|
13
|
+
className: preview,
|
|
14
|
+
hideLegend: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { VEGALITE_PREVIEW_INSET, VegaLitePreview };
|