@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,248 @@
|
|
|
1
|
+
import { chart } from "./vegalite_view.module.js";
|
|
2
|
+
import { loadVega } from "../vegalite/vegalite_loader.js";
|
|
3
|
+
import { CHART_ROWS, arrowTableToRows } from "../vegalite/vegalite_rows.js";
|
|
4
|
+
import { createEmbedOptions, createVegaLiteConfig, resolveChartColors } from "../vegalite/vegalite_theme.js";
|
|
5
|
+
import { useColorScheme } from "../theme/color_scheme.js";
|
|
6
|
+
import { useBrand } from "../brand/brand.js";
|
|
7
|
+
import { useComputationTables } from "./data_table/computation_tables.js";
|
|
8
|
+
import { CardPlaceholder } from "./card_placeholder.js";
|
|
9
|
+
import { ResultRowsPlaceholder, useResultRows } from "./visualization/result_rows.js";
|
|
10
|
+
import { CappedRows } from "./visualization/capped_rows.js";
|
|
11
|
+
import { VegaCrossFilterUpdater, filterTableToVegaCrossFilterRows, injectVegaLiteCrossFilter, injectVegaStableScaleDomains } from "../vegalite/vegalite_crossfilter.js";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { perfMarks } from "@akohn/dashql";
|
|
15
|
+
import { withViewEncodings } from "@akohn/dashql/platform/workbook/chart_config";
|
|
16
|
+
var VIEWPORT_MARGIN = "50% 0px";
|
|
17
|
+
function useNearViewport(ref, mounted) {
|
|
18
|
+
const [near, setNear] = React.useState(() => typeof IntersectionObserver === "undefined");
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
const element = ref.current;
|
|
21
|
+
if (near || !mounted || element == null) return;
|
|
22
|
+
const observer = new IntersectionObserver((entries) => {
|
|
23
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
24
|
+
observer.disconnect();
|
|
25
|
+
setNear(true);
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
rootMargin: VIEWPORT_MARGIN,
|
|
29
|
+
scrollMargin: VIEWPORT_MARGIN
|
|
30
|
+
});
|
|
31
|
+
observer.observe(element);
|
|
32
|
+
return () => observer.disconnect();
|
|
33
|
+
}, [
|
|
34
|
+
ref,
|
|
35
|
+
near,
|
|
36
|
+
mounted
|
|
37
|
+
]);
|
|
38
|
+
return near;
|
|
39
|
+
}
|
|
40
|
+
var DEFAULT_DEPENDENCIES = {
|
|
41
|
+
loadVega,
|
|
42
|
+
useNearViewport
|
|
43
|
+
};
|
|
44
|
+
var LEGEND_CHANNELS = [
|
|
45
|
+
"color",
|
|
46
|
+
"fill",
|
|
47
|
+
"stroke",
|
|
48
|
+
"size",
|
|
49
|
+
"shape",
|
|
50
|
+
"opacity",
|
|
51
|
+
"strokeWidth",
|
|
52
|
+
"strokeDash",
|
|
53
|
+
"angle"
|
|
54
|
+
];
|
|
55
|
+
function stripLegends(spec) {
|
|
56
|
+
if (Array.isArray(spec)) return spec.map(stripLegends);
|
|
57
|
+
if (spec == null || typeof spec !== "object") return spec;
|
|
58
|
+
const out = { ...spec };
|
|
59
|
+
if (out.encoding != null && typeof out.encoding === "object") {
|
|
60
|
+
const encoding = { ...out.encoding };
|
|
61
|
+
for (const channel of LEGEND_CHANNELS) {
|
|
62
|
+
const def = encoding[channel];
|
|
63
|
+
if (def != null && typeof def === "object" && !Array.isArray(def)) encoding[channel] = {
|
|
64
|
+
...def,
|
|
65
|
+
legend: null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
out.encoding = encoding;
|
|
69
|
+
}
|
|
70
|
+
for (const key of [
|
|
71
|
+
"layer",
|
|
72
|
+
"hconcat",
|
|
73
|
+
"vconcat",
|
|
74
|
+
"concat",
|
|
75
|
+
"spec"
|
|
76
|
+
]) if (out[key] != null && typeof out[key] === "object") out[key] = stripLegends(out[key]);
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
var specSignatures = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
function getSpecSignature(spec) {
|
|
81
|
+
let signature = specSignatures.get(spec);
|
|
82
|
+
if (signature === void 0) {
|
|
83
|
+
signature = JSON.stringify(spec);
|
|
84
|
+
specSignatures.set(spec, signature);
|
|
85
|
+
}
|
|
86
|
+
return signature;
|
|
87
|
+
}
|
|
88
|
+
function VegaLiteView(props) {
|
|
89
|
+
const containerRef = React.useRef(null);
|
|
90
|
+
const crossFilterUpdaterRef = React.useRef(null);
|
|
91
|
+
const [error$1, setError] = React.useState(null);
|
|
92
|
+
const dependencies = props.dependencies ?? DEFAULT_DEPENDENCIES;
|
|
93
|
+
const colorScheme = useColorScheme();
|
|
94
|
+
const flavorId = useBrand().id;
|
|
95
|
+
const specSignature = props.vegaLiteSpec == null ? null : getSpecSignature(props.vegaLiteSpec);
|
|
96
|
+
const spec = React.useMemo(() => specSignature == null ? null : JSON.parse(specSignature), [specSignature]);
|
|
97
|
+
const computation = props.model?.computation ?? null;
|
|
98
|
+
const chartRows = useResultRows(props.model, "first", CHART_ROWS, true);
|
|
99
|
+
const dataTable = chartRows.table;
|
|
100
|
+
const cappedRows = dataTable != null && chartRows.rows > dataTable.numRows ? chartRows.rows : null;
|
|
101
|
+
const rowNumberColumnName = computation?.computation.rowNumberColumnName ?? null;
|
|
102
|
+
const filterTable = useComputationTables(computation?.computation ?? null, computation?.tables ?? null).filterTable;
|
|
103
|
+
const nearViewport = dependencies.useNearViewport(containerRef, spec != null && dataTable != null);
|
|
104
|
+
const rows = React.useMemo(() => {
|
|
105
|
+
if (!dataTable || !nearViewport) return null;
|
|
106
|
+
return perfMarks.measure("render:visRows", () => arrowTableToRows(dataTable), () => `${dataTable.numRows} rows`);
|
|
107
|
+
}, [dataTable, nearViewport]);
|
|
108
|
+
const crossFilterBinding = React.useMemo(() => {
|
|
109
|
+
if (spec == null || dataTable == null) return null;
|
|
110
|
+
const baseSpec = props.hideLegend ? stripLegends(spec) : spec;
|
|
111
|
+
return injectVegaLiteCrossFilter(baseSpec, rowNumberColumnName, dataTable.schema.fields.map((field) => field.name));
|
|
112
|
+
}, [
|
|
113
|
+
spec,
|
|
114
|
+
rowNumberColumnName,
|
|
115
|
+
dataTable,
|
|
116
|
+
props.hideLegend
|
|
117
|
+
]);
|
|
118
|
+
const maskSelectedFieldName = crossFilterBinding?.maskSelectedFieldName ?? null;
|
|
119
|
+
const crossFilterMask = React.useMemo(() => ({
|
|
120
|
+
active: filterTable != null,
|
|
121
|
+
rows: filterTable != null && maskSelectedFieldName != null ? filterTableToVegaCrossFilterRows(filterTable, maskSelectedFieldName) : []
|
|
122
|
+
}), [filterTable, maskSelectedFieldName]);
|
|
123
|
+
const crossFilterMaskRef = React.useRef(crossFilterMask);
|
|
124
|
+
crossFilterMaskRef.current = crossFilterMask;
|
|
125
|
+
React.useEffect(() => {
|
|
126
|
+
crossFilterUpdaterRef.current?.update(crossFilterMask);
|
|
127
|
+
}, [crossFilterMask]);
|
|
128
|
+
const scale = props.scale != null && props.scale > 0 ? props.scale : 1;
|
|
129
|
+
const width = props.width != null ? Math.round(props.width / scale) : null;
|
|
130
|
+
const height = props.height != null ? Math.round(props.height / scale) : null;
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
const el = containerRef.current;
|
|
133
|
+
if (!el || !spec || !rows) return;
|
|
134
|
+
let disposed = false;
|
|
135
|
+
let finalizeView = null;
|
|
136
|
+
let stableScaleDomains = [];
|
|
137
|
+
const baseSpec = crossFilterBinding?.spec ?? (props.hideLegend ? stripLegends(spec) : spec);
|
|
138
|
+
const runtimeSpec = { ...withViewEncodings(baseSpec) };
|
|
139
|
+
runtimeSpec.width = width != null ? width : "container";
|
|
140
|
+
runtimeSpec.height = height != null ? height : "container";
|
|
141
|
+
runtimeSpec.autosize = {
|
|
142
|
+
type: "fit",
|
|
143
|
+
contains: "padding",
|
|
144
|
+
resize: false
|
|
145
|
+
};
|
|
146
|
+
const embedStarted = perfMarks.start();
|
|
147
|
+
const embedDetail = () => `${rows.length} rows`;
|
|
148
|
+
dependencies.loadVega().then(({ embed, expressionInterpreter }) => {
|
|
149
|
+
if (disposed) return;
|
|
150
|
+
const colors = resolveChartColors();
|
|
151
|
+
const options = createEmbedOptions(colors, expressionInterpreter);
|
|
152
|
+
const config = (props.config ?? createVegaLiteConfig)(colors);
|
|
153
|
+
return embed(el, runtimeSpec, {
|
|
154
|
+
...options,
|
|
155
|
+
patch: (compiledSpec) => {
|
|
156
|
+
const stableScales = injectVegaStableScaleDomains(compiledSpec);
|
|
157
|
+
stableScaleDomains = stableScales.domains;
|
|
158
|
+
return stableScales.spec;
|
|
159
|
+
},
|
|
160
|
+
config: {
|
|
161
|
+
...config,
|
|
162
|
+
mark: {
|
|
163
|
+
...config.mark,
|
|
164
|
+
tooltip: true
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}).then((result) => {
|
|
169
|
+
if (!result) return;
|
|
170
|
+
perfMarks.end("render:visEmbed", embedStarted, embedDetail);
|
|
171
|
+
if (disposed) {
|
|
172
|
+
result.view.finalize();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
finalizeView = () => result.view.finalize();
|
|
176
|
+
if (crossFilterBinding != null) {
|
|
177
|
+
const updater = new VegaCrossFilterUpdater(result.view, crossFilterBinding.sourceDatasetName, rows, crossFilterBinding.maskDatasetName, crossFilterBinding.maskActiveSignalName, (e) => setError(e instanceof Error ? e.message : String(e)), stableScaleDomains);
|
|
178
|
+
crossFilterUpdaterRef.current = updater;
|
|
179
|
+
updater.update(crossFilterMaskRef.current);
|
|
180
|
+
}
|
|
181
|
+
setError(null);
|
|
182
|
+
}).catch((e) => {
|
|
183
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
184
|
+
});
|
|
185
|
+
return () => {
|
|
186
|
+
disposed = true;
|
|
187
|
+
crossFilterUpdaterRef.current?.dispose();
|
|
188
|
+
crossFilterUpdaterRef.current = null;
|
|
189
|
+
finalizeView?.();
|
|
190
|
+
if (el) el.replaceChildren();
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
spec,
|
|
194
|
+
rows,
|
|
195
|
+
crossFilterBinding,
|
|
196
|
+
width,
|
|
197
|
+
height,
|
|
198
|
+
scale,
|
|
199
|
+
props.hideLegend,
|
|
200
|
+
props.config,
|
|
201
|
+
dependencies,
|
|
202
|
+
colorScheme,
|
|
203
|
+
flavorId
|
|
204
|
+
]);
|
|
205
|
+
if (!spec) return /* @__PURE__ */ jsx(CardPlaceholder, { message: "No visualization available" });
|
|
206
|
+
if (chartRows.status === "reading") return /* @__PURE__ */ jsx("div", {
|
|
207
|
+
className: props.className ?? "dashql_root_vG43rg",
|
|
208
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
209
|
+
className: chart,
|
|
210
|
+
style: {
|
|
211
|
+
width: props.width,
|
|
212
|
+
height: props.height
|
|
213
|
+
},
|
|
214
|
+
children: /* @__PURE__ */ jsx(CardPlaceholder, {})
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
if (dataTable == null) return /* @__PURE__ */ jsx(ResultRowsPlaceholder, {
|
|
218
|
+
query: props.model?.query ?? null,
|
|
219
|
+
rows: chartRows
|
|
220
|
+
});
|
|
221
|
+
const chartStyle = width != null || height != null || scale !== 1 ? {
|
|
222
|
+
width: width ?? void 0,
|
|
223
|
+
height: height ?? void 0,
|
|
224
|
+
transform: scale !== 1 ? `scale(${scale})` : void 0,
|
|
225
|
+
transformOrigin: scale !== 1 ? "top left" : void 0
|
|
226
|
+
} : void 0;
|
|
227
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: props.className ?? "dashql_root_vG43rg",
|
|
229
|
+
children: [
|
|
230
|
+
error$1 && /* @__PURE__ */ jsx("div", {
|
|
231
|
+
className: "dashql_error_honEsZ",
|
|
232
|
+
children: error$1
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx("div", {
|
|
235
|
+
ref: containerRef,
|
|
236
|
+
className: chart,
|
|
237
|
+
style: chartStyle
|
|
238
|
+
}),
|
|
239
|
+
cappedRows != null && /* @__PURE__ */ jsx(CappedRows, {
|
|
240
|
+
className: "dashql_capped_EpDyha",
|
|
241
|
+
part: "first",
|
|
242
|
+
shown: dataTable.numRows,
|
|
243
|
+
rows: cappedRows
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
export { VegaLiteView, useNearViewport };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface VerticalScrollOverflow {
|
|
3
|
+
top: boolean;
|
|
4
|
+
bottom: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function getVerticalScrollOverflow(element: Pick<HTMLElement, 'clientHeight' | 'scrollHeight' | 'scrollTop'>): VerticalScrollOverflow;
|
|
7
|
+
interface VerticalScrollShadowsProps {
|
|
8
|
+
getScrollElement: () => HTMLElement | null;
|
|
9
|
+
prominent?: boolean;
|
|
10
|
+
refreshKey?: unknown;
|
|
11
|
+
rightInset?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const VerticalScrollShadows: React.FC<VerticalScrollShadowsProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { classNames } from "../dom/classnames.js";
|
|
2
|
+
import { bottom, shadow, top } from "./vertical_scroll_shadows.module.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var SCROLL_EDGE_TOLERANCE = 1;
|
|
6
|
+
function getVerticalScrollOverflow(element) {
|
|
7
|
+
const maxScrollTop = Math.max(0, element.scrollHeight - element.clientHeight);
|
|
8
|
+
return {
|
|
9
|
+
top: element.scrollTop > SCROLL_EDGE_TOLERANCE,
|
|
10
|
+
bottom: maxScrollTop - element.scrollTop > SCROLL_EDGE_TOLERANCE
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var NO_OVERFLOW = {
|
|
14
|
+
top: false,
|
|
15
|
+
bottom: false
|
|
16
|
+
};
|
|
17
|
+
var VerticalScrollShadows = ({ getScrollElement, prominent: prominent$1 = false, refreshKey, rightInset = 0 }) => {
|
|
18
|
+
const [overflow, setOverflow] = React.useState(NO_OVERFLOW);
|
|
19
|
+
const updateOverflow = React.useCallback(() => {
|
|
20
|
+
const element = getScrollElement();
|
|
21
|
+
const next = element == null ? NO_OVERFLOW : getVerticalScrollOverflow(element);
|
|
22
|
+
setOverflow((current) => current.top === next.top && current.bottom === next.bottom ? current : next);
|
|
23
|
+
}, [getScrollElement]);
|
|
24
|
+
React.useLayoutEffect(() => {
|
|
25
|
+
const element = getScrollElement();
|
|
26
|
+
updateOverflow();
|
|
27
|
+
if (element == null) return;
|
|
28
|
+
element.addEventListener("scroll", updateOverflow, { passive: true });
|
|
29
|
+
const resizeObserver = new ResizeObserver(updateOverflow);
|
|
30
|
+
resizeObserver.observe(element);
|
|
31
|
+
return () => {
|
|
32
|
+
element.removeEventListener("scroll", updateOverflow);
|
|
33
|
+
resizeObserver.disconnect();
|
|
34
|
+
};
|
|
35
|
+
}, [
|
|
36
|
+
getScrollElement,
|
|
37
|
+
refreshKey,
|
|
38
|
+
updateOverflow
|
|
39
|
+
]);
|
|
40
|
+
const insetStyle = rightInset === 0 ? void 0 : { right: rightInset };
|
|
41
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: classNames(shadow, top, prominent$1 && "dashql_prominent_j7bM48"),
|
|
43
|
+
style: insetStyle,
|
|
44
|
+
"data-scroll-shadow": "top",
|
|
45
|
+
"data-visible": overflow.top,
|
|
46
|
+
"aria-hidden": "true"
|
|
47
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
48
|
+
className: classNames(shadow, bottom, prominent$1 && "dashql_prominent_j7bM48"),
|
|
49
|
+
style: insetStyle,
|
|
50
|
+
"data-scroll-shadow": "bottom",
|
|
51
|
+
"data-visible": overflow.bottom,
|
|
52
|
+
"aria-hidden": "true"
|
|
53
|
+
})] });
|
|
54
|
+
};
|
|
55
|
+
export { VerticalScrollShadows, getVerticalScrollOverflow };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface VerticalSplitProps {
|
|
3
|
+
first: React.ReactNode;
|
|
4
|
+
second: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
defaultRatio?: number;
|
|
7
|
+
minFirstSize?: number;
|
|
8
|
+
minSecondSize?: number;
|
|
9
|
+
separatorLabel?: string;
|
|
10
|
+
secondCollapsed?: boolean;
|
|
11
|
+
collapsedSecondSize?: number;
|
|
12
|
+
separatorSize?: number;
|
|
13
|
+
separatorClassName?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const VerticalSplit: React.FC<VerticalSplitProps>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { classNames } from "../dom/classnames.js";
|
|
2
|
+
import { SEPARATOR_CLASSES, useSeparatorDrag } from "./separator.js";
|
|
3
|
+
import { collapsed_separator, container, first, second } from "./vertical_split.module.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var DEFAULT_SEPARATOR_SIZE = 12;
|
|
7
|
+
var KEYBOARD_STEP = .05;
|
|
8
|
+
function clamp(value, minimum, maximum) {
|
|
9
|
+
return Math.min(maximum, Math.max(minimum, value));
|
|
10
|
+
}
|
|
11
|
+
var VerticalSplit = (props) => {
|
|
12
|
+
const defaultRatio = clamp(props.defaultRatio ?? .4, 0, 1);
|
|
13
|
+
const minFirstSize = props.minFirstSize ?? 120;
|
|
14
|
+
const minSecondSize = props.minSecondSize ?? 120;
|
|
15
|
+
const collapsedSecondSize = props.collapsedSecondSize ?? 40;
|
|
16
|
+
const separatorSize = props.separatorSize ?? DEFAULT_SEPARATOR_SIZE;
|
|
17
|
+
const [ratio, setRatio] = React.useState(defaultRatio);
|
|
18
|
+
const [ratioBounds, setRatioBounds] = React.useState([defaultRatio, defaultRatio]);
|
|
19
|
+
const containerRef = React.useRef(null);
|
|
20
|
+
const getRatioBounds = React.useCallback(() => {
|
|
21
|
+
const height = containerRef.current?.getBoundingClientRect().height ?? 0;
|
|
22
|
+
const availableHeight = Math.max(0, height - separatorSize);
|
|
23
|
+
if (availableHeight === 0 || availableHeight < minFirstSize + minSecondSize) return [defaultRatio, defaultRatio];
|
|
24
|
+
return [minFirstSize / availableHeight, 1 - minSecondSize / availableHeight];
|
|
25
|
+
}, [
|
|
26
|
+
defaultRatio,
|
|
27
|
+
minFirstSize,
|
|
28
|
+
minSecondSize,
|
|
29
|
+
separatorSize
|
|
30
|
+
]);
|
|
31
|
+
const resizeToPointer = React.useCallback((clientY) => {
|
|
32
|
+
const container = containerRef.current;
|
|
33
|
+
if (container == null) return;
|
|
34
|
+
const rect = container.getBoundingClientRect();
|
|
35
|
+
const availableHeight = rect.height - separatorSize;
|
|
36
|
+
if (availableHeight <= 0) return;
|
|
37
|
+
const [minimum, maximum] = getRatioBounds();
|
|
38
|
+
const nextRatio = (clientY - rect.top - separatorSize / 2) / availableHeight;
|
|
39
|
+
setRatio(clamp(nextRatio, minimum, maximum));
|
|
40
|
+
}, [getRatioBounds, separatorSize]);
|
|
41
|
+
React.useLayoutEffect(() => {
|
|
42
|
+
const container = containerRef.current;
|
|
43
|
+
if (container == null) return;
|
|
44
|
+
const updateBounds = () => {
|
|
45
|
+
if (container.getClientRects().length === 0) return;
|
|
46
|
+
const bounds = getRatioBounds();
|
|
47
|
+
setRatioBounds((current) => current[0] === bounds[0] && current[1] === bounds[1] ? current : bounds);
|
|
48
|
+
setRatio((current) => clamp(current, bounds[0], bounds[1]));
|
|
49
|
+
};
|
|
50
|
+
updateBounds();
|
|
51
|
+
const observer = new ResizeObserver(updateBounds);
|
|
52
|
+
observer.observe(container);
|
|
53
|
+
return () => observer.disconnect();
|
|
54
|
+
}, [getRatioBounds]);
|
|
55
|
+
const drag = useSeparatorDrag("y", {
|
|
56
|
+
onMove: resizeToPointer,
|
|
57
|
+
onCancel: () => setRatio(ratio),
|
|
58
|
+
onClick: () => {
|
|
59
|
+
const [minimum, maximum] = getRatioBounds();
|
|
60
|
+
setRatio(clamp(1 - ratio, minimum, maximum));
|
|
61
|
+
},
|
|
62
|
+
onKey: (key) => {
|
|
63
|
+
const [minimum, maximum] = getRatioBounds();
|
|
64
|
+
const next = key === "decrease" ? ratio - KEYBOARD_STEP : key === "increase" ? ratio + KEYBOARD_STEP : key === "min" ? minimum : maximum;
|
|
65
|
+
setRatio(clamp(next, minimum, maximum));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const stopDragging = drag.stop;
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
if (props.secondCollapsed) stopDragging();
|
|
71
|
+
}, [props.secondCollapsed, stopDragging]);
|
|
72
|
+
const ratioPercent = Math.round(ratio * 100);
|
|
73
|
+
const gridTemplateRows = props.secondCollapsed ? `minmax(0, 1fr) ${separatorSize}px ${collapsedSecondSize}px` : `minmax(${minFirstSize}px, ${ratio}fr) ${separatorSize}px minmax(${minSecondSize}px, ${1 - ratio}fr)`;
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
75
|
+
ref: containerRef,
|
|
76
|
+
className: classNames(container, props.className),
|
|
77
|
+
style: { gridTemplateRows },
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("div", {
|
|
80
|
+
className: first,
|
|
81
|
+
children: props.first
|
|
82
|
+
}),
|
|
83
|
+
props.secondCollapsed ? /* @__PURE__ */ jsx("div", {
|
|
84
|
+
className: collapsed_separator,
|
|
85
|
+
"aria-hidden": "true"
|
|
86
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
87
|
+
className: classNames(SEPARATOR_CLASSES.y, props.separatorClassName, { [SEPARATOR_CLASSES.dragging]: drag.dragging }),
|
|
88
|
+
role: "separator",
|
|
89
|
+
"data-electron-drag-region": "false",
|
|
90
|
+
tabIndex: 0,
|
|
91
|
+
"aria-label": props.separatorLabel ?? "Resize panels",
|
|
92
|
+
"aria-orientation": "horizontal",
|
|
93
|
+
"aria-valuemin": Math.round(ratioBounds[0] * 100),
|
|
94
|
+
"aria-valuemax": Math.round(ratioBounds[1] * 100),
|
|
95
|
+
"aria-valuenow": ratioPercent,
|
|
96
|
+
"aria-valuetext": `${ratioPercent}% for the top panel`,
|
|
97
|
+
title: "Drag to resize; click to swap panel sizes",
|
|
98
|
+
onPointerDown: drag.onPointerDown,
|
|
99
|
+
onKeyDown: drag.onKeyDown,
|
|
100
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: SEPARATOR_CLASSES.handle,
|
|
102
|
+
"aria-hidden": "true"
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ jsx("div", {
|
|
106
|
+
className: second,
|
|
107
|
+
children: props.second
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
export { VerticalSplit };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type Key = number;
|
|
3
|
+
export interface VerticalTabRenderers<TabProps extends VerticalTabProps> {
|
|
4
|
+
[key: Key]: (props: TabProps) => React.ReactElement;
|
|
5
|
+
}
|
|
6
|
+
export interface VerticalTabProps {
|
|
7
|
+
tabId: number;
|
|
8
|
+
icon: string;
|
|
9
|
+
iconActive?: string;
|
|
10
|
+
labelShort: string;
|
|
11
|
+
labelLong?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
group?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare enum VerticalTabVariant {
|
|
18
|
+
Stacked = 0
|
|
19
|
+
}
|
|
20
|
+
interface Props<TabProps extends VerticalTabProps> {
|
|
21
|
+
className?: string;
|
|
22
|
+
variant: VerticalTabVariant;
|
|
23
|
+
tabKeys: Key[];
|
|
24
|
+
tabProps: Record<Key, TabProps>;
|
|
25
|
+
tabRenderers: VerticalTabRenderers<TabProps>;
|
|
26
|
+
selectedTab: Key;
|
|
27
|
+
selectTab: (tab: Key) => void;
|
|
28
|
+
splitModeEnabled?: boolean;
|
|
29
|
+
splitTab?: Key | null;
|
|
30
|
+
primaryTabKey?: Key;
|
|
31
|
+
onToggleSplitMode?: () => void;
|
|
32
|
+
onSelectSplitTab?: (tab: Key) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function groupVerticalTabs<TabProps extends VerticalTabProps>(tabKeys: Key[], tabProps: Record<Key, TabProps>): TabProps[][];
|
|
35
|
+
export declare function VerticalTabs<TabProps extends VerticalTabProps>(props: Props<TabProps>): React.ReactElement;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { classNames } from "../dom/classnames.js";
|
|
2
|
+
import { ButtonVariant, IconButton } from "./button.js";
|
|
3
|
+
import { container, container_split, primary_body, 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_group, tabs_list } from "./vertical_tabs.module.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import symbols from "../svg_symbols.js";
|
|
7
|
+
var VSPLIT_DEFAULT_RATIO = .4;
|
|
8
|
+
var VerticalTabVariant = /* @__PURE__ */ function(VerticalTabVariant) {
|
|
9
|
+
VerticalTabVariant[VerticalTabVariant["Stacked"] = 0] = "Stacked";
|
|
10
|
+
return VerticalTabVariant;
|
|
11
|
+
}({});
|
|
12
|
+
function groupVerticalTabs(tabKeys, tabProps) {
|
|
13
|
+
const groups = [];
|
|
14
|
+
for (const key of tabKeys) {
|
|
15
|
+
const tab = tabProps[key];
|
|
16
|
+
const last = groups[groups.length - 1];
|
|
17
|
+
if (last != null && last[0].group === tab.group) last.push(tab);
|
|
18
|
+
else groups.push([tab]);
|
|
19
|
+
}
|
|
20
|
+
return groups;
|
|
21
|
+
}
|
|
22
|
+
function VerticalTabs(props) {
|
|
23
|
+
const [splitRatio, setSplitRatio] = React.useState(VSPLIT_DEFAULT_RATIO);
|
|
24
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
25
|
+
const containerRef = React.useRef(null);
|
|
26
|
+
const { splitModeEnabled, primaryTabKey: splitPrimaryTabKey, onSelectSplitTab, selectTab: selectMainTab } = props;
|
|
27
|
+
const selectTab = React.useCallback((tabId) => {
|
|
28
|
+
if (splitModeEnabled) {
|
|
29
|
+
if (tabId === splitPrimaryTabKey) return;
|
|
30
|
+
if (onSelectSplitTab) onSelectSplitTab(tabId);
|
|
31
|
+
} else selectMainTab(tabId);
|
|
32
|
+
}, [
|
|
33
|
+
splitModeEnabled,
|
|
34
|
+
splitPrimaryTabKey,
|
|
35
|
+
onSelectSplitTab,
|
|
36
|
+
selectMainTab
|
|
37
|
+
]);
|
|
38
|
+
const handleResizeStart = React.useCallback((e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
setIsDragging(true);
|
|
41
|
+
}, []);
|
|
42
|
+
const handleResizeMove = React.useCallback((e) => {
|
|
43
|
+
if (!isDragging || !containerRef.current) return;
|
|
44
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
45
|
+
const y = e.clientY - rect.top;
|
|
46
|
+
const newRatio = Math.max(.2, Math.min(.8, y / rect.height));
|
|
47
|
+
setSplitRatio(newRatio);
|
|
48
|
+
}, [isDragging]);
|
|
49
|
+
const handleResizeEnd = React.useCallback(() => {
|
|
50
|
+
setIsDragging(false);
|
|
51
|
+
}, []);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (isDragging) {
|
|
54
|
+
document.addEventListener("mousemove", handleResizeMove);
|
|
55
|
+
document.addEventListener("mouseup", handleResizeEnd);
|
|
56
|
+
return () => {
|
|
57
|
+
document.removeEventListener("mousemove", handleResizeMove);
|
|
58
|
+
document.removeEventListener("mouseup", handleResizeEnd);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
isDragging,
|
|
63
|
+
handleResizeMove,
|
|
64
|
+
handleResizeEnd
|
|
65
|
+
]);
|
|
66
|
+
const primaryTabKey = props.splitModeEnabled ? props.primaryTabKey ?? props.selectedTab : props.selectedTab;
|
|
67
|
+
const primaryTabRenderer = props.tabRenderers[primaryTabKey];
|
|
68
|
+
const primaryTabBodyProps = props.tabProps[primaryTabKey];
|
|
69
|
+
const primaryTabBody = React.useMemo(() => primaryTabRenderer ? primaryTabRenderer(primaryTabBodyProps) : void 0, [primaryTabRenderer, primaryTabBodyProps]);
|
|
70
|
+
const splitTabRenderer = props.splitModeEnabled && props.splitTab != null ? props.tabRenderers[props.splitTab] : null;
|
|
71
|
+
const splitTabBodyProps = props.splitTab != null ? props.tabProps[props.splitTab] : void 0;
|
|
72
|
+
const splitTabBody = React.useMemo(() => splitTabRenderer ? splitTabRenderer(splitTabBodyProps) : void 0, [splitTabRenderer, splitTabBodyProps]);
|
|
73
|
+
const renderStackedTab = (tabProps) => {
|
|
74
|
+
const isPrimaryTab = props.splitModeEnabled && tabProps.tabId === props.primaryTabKey;
|
|
75
|
+
const isActive = isPrimaryTab || tabProps.tabId == props.selectedTab || props.splitModeEnabled && tabProps.tabId === props.splitTab;
|
|
76
|
+
const isSplitTab = props.splitModeEnabled && tabProps.tabId === props.splitTab;
|
|
77
|
+
const showSplitIndicator = isPrimaryTab || isSplitTab;
|
|
78
|
+
const splitNumber = isPrimaryTab ? "1" : "2";
|
|
79
|
+
const tooltipText = tabProps.description || tabProps.ariaLabel || tabProps.labelShort;
|
|
80
|
+
const ariaLabel = tabProps.ariaLabel || tabProps.labelShort;
|
|
81
|
+
return /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: classNames(stacked_tab, { [stacked_tab_active]: isActive }),
|
|
83
|
+
"data-tab": tabProps.tabId,
|
|
84
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
85
|
+
className: classNames(stacked_tab_icon, { [stacked_tab_icon_split]: showSplitIndicator }),
|
|
86
|
+
variant: ButtonVariant.Invisible,
|
|
87
|
+
"aria-label": ariaLabel,
|
|
88
|
+
"aria-current": isActive ? "page" : void 0,
|
|
89
|
+
description: tooltipText,
|
|
90
|
+
disabled: tabProps.disabled,
|
|
91
|
+
onClick: () => selectTab(tabProps.tabId),
|
|
92
|
+
children: showSplitIndicator ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: stacked_tab_icon_half_first,
|
|
94
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
95
|
+
className: stacked_tab_split_number,
|
|
96
|
+
children: splitNumber
|
|
97
|
+
})
|
|
98
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
99
|
+
className: stacked_tab_icon_half,
|
|
100
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
101
|
+
width: "12px",
|
|
102
|
+
height: "12px",
|
|
103
|
+
children: /* @__PURE__ */ jsx("use", { xlinkHref: isActive && tabProps.iconActive ? tabProps.iconActive : tabProps.icon })
|
|
104
|
+
})
|
|
105
|
+
})] }) : /* @__PURE__ */ jsx("svg", {
|
|
106
|
+
width: "18px",
|
|
107
|
+
height: "16px",
|
|
108
|
+
children: /* @__PURE__ */ jsx("use", { xlinkHref: isActive && tabProps.iconActive ? tabProps.iconActive : tabProps.icon })
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}, tabProps.tabId);
|
|
112
|
+
};
|
|
113
|
+
const canEnableSplit = props.tabKeys.filter((key) => !props.tabProps[key]?.disabled).length >= 2;
|
|
114
|
+
const gridStyle = props.splitModeEnabled ? { gridTemplateRows: `${splitRatio * 100}% max-content 1fr` } : void 0;
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
ref: containerRef,
|
|
117
|
+
className: classNames(props.className, container, { [container_split]: props.splitModeEnabled }),
|
|
118
|
+
style: gridStyle,
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ jsxs("div", {
|
|
121
|
+
className: tabs,
|
|
122
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
123
|
+
className: tabs_list,
|
|
124
|
+
children: groupVerticalTabs(props.tabKeys, props.tabProps).map((group, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("div", {
|
|
125
|
+
className: "dashql_tabs_separator_2LKLxC",
|
|
126
|
+
role: "separator",
|
|
127
|
+
"aria-orientation": "horizontal"
|
|
128
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
129
|
+
className: tabs_group,
|
|
130
|
+
role: "group",
|
|
131
|
+
"aria-label": group[0].group,
|
|
132
|
+
children: group.map(renderStackedTab)
|
|
133
|
+
})] }, group[0].tabId))
|
|
134
|
+
}), props.onToggleSplitMode && /* @__PURE__ */ jsx("div", {
|
|
135
|
+
className: "dashql_tabs_footer_VXxwoA",
|
|
136
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: classNames("dashql_split_toggle_HtEPXl", { ["dashql_split_toggle_active_1afIdW"]: props.splitModeEnabled }),
|
|
138
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
139
|
+
className: "dashql_split_toggle_icon_MfXFK5",
|
|
140
|
+
variant: ButtonVariant.Invisible,
|
|
141
|
+
"aria-label": "Toggle split",
|
|
142
|
+
description: "Toggle split",
|
|
143
|
+
disabled: !canEnableSplit,
|
|
144
|
+
onClick: props.onToggleSplitMode,
|
|
145
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
146
|
+
width: "18px",
|
|
147
|
+
height: "16px",
|
|
148
|
+
children: /* @__PURE__ */ jsx("use", { xlinkHref: `${symbols}#vsplit_24` })
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
})]
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: primary_body,
|
|
156
|
+
children: primaryTabBody
|
|
157
|
+
}),
|
|
158
|
+
props.splitModeEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
159
|
+
className: classNames("dashql_resize_handle_qIadRB", { ["dashql_resize_handle_dragging_sJpPsX"]: isDragging }),
|
|
160
|
+
onMouseDown: handleResizeStart,
|
|
161
|
+
children: /* @__PURE__ */ jsx("div", { className: "dashql_resize_handle_bar_1UWWkB" })
|
|
162
|
+
}), splitTabBody && /* @__PURE__ */ jsx("div", {
|
|
163
|
+
className: "dashql_split_body_C26NTL",
|
|
164
|
+
children: splitTabBody
|
|
165
|
+
})] })
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export { VerticalTabVariant, VerticalTabs, groupVerticalTabs };
|