@akohn/dashql-react 0.0.0-stage → 0.0.20-dev.661.gda3ac9a7e
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,141 @@
|
|
|
1
|
+
import { Button, ButtonSize, ButtonVariant } from "../button.js";
|
|
2
|
+
import { SearchIcon, XIcon } from "../symbol_icon.js";
|
|
3
|
+
import { TextInput } from "../text_input.js";
|
|
4
|
+
import { TextInputAction } from "../text_input_action.js";
|
|
5
|
+
import { button, button_label, control, input, status } from "./query_result_search_controls.module.js";
|
|
6
|
+
import { useQueryResultSearch } from "./use_query_result_search.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var DATA_SEARCH_DEBOUNCE_MS = 200;
|
|
10
|
+
function SearchControl(props) {
|
|
11
|
+
const testId = `search-${props.kind.toLowerCase()}`;
|
|
12
|
+
const inputRef = React.useRef(null);
|
|
13
|
+
const buttonRef = React.useRef(null);
|
|
14
|
+
const inputId = React.useId();
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (props.expanded) inputRef.current?.focus();
|
|
17
|
+
}, [props.expanded]);
|
|
18
|
+
const requestedPattern = props.state.requestedPattern;
|
|
19
|
+
const [pattern, setPattern] = React.useState(requestedPattern);
|
|
20
|
+
const pendingChange = React.useRef(null);
|
|
21
|
+
const onChangeRef = React.useRef(props.onChange);
|
|
22
|
+
onChangeRef.current = props.onChange;
|
|
23
|
+
const flushChange = React.useCallback(() => {
|
|
24
|
+
const pending = pendingChange.current;
|
|
25
|
+
if (pending == null) return;
|
|
26
|
+
clearTimeout(pending.timer);
|
|
27
|
+
pendingChange.current = null;
|
|
28
|
+
onChangeRef.current(pending.value);
|
|
29
|
+
}, []);
|
|
30
|
+
const changePattern = React.useCallback((value, immediate) => {
|
|
31
|
+
setPattern(value);
|
|
32
|
+
const pending = pendingChange.current;
|
|
33
|
+
if (pending != null) {
|
|
34
|
+
clearTimeout(pending.timer);
|
|
35
|
+
pendingChange.current = null;
|
|
36
|
+
}
|
|
37
|
+
const debounceMs = props.debounceMs ?? 0;
|
|
38
|
+
if (immediate || debounceMs <= 0) {
|
|
39
|
+
onChangeRef.current(value);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
pendingChange.current = {
|
|
43
|
+
timer: setTimeout(flushChange, debounceMs),
|
|
44
|
+
value
|
|
45
|
+
};
|
|
46
|
+
}, [props.debounceMs, flushChange]);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (pendingChange.current == null) setPattern(requestedPattern);
|
|
49
|
+
}, [requestedPattern]);
|
|
50
|
+
React.useEffect(() => () => flushChange(), [flushChange]);
|
|
51
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: control,
|
|
53
|
+
"aria-busy": props.state.pending || void 0,
|
|
54
|
+
children: [
|
|
55
|
+
props.expanded ? /* @__PURE__ */ jsx(TextInput, {
|
|
56
|
+
ref: inputRef,
|
|
57
|
+
id: inputId,
|
|
58
|
+
className: input,
|
|
59
|
+
"aria-label": `Search ${props.kind.toLowerCase()}`,
|
|
60
|
+
"data-testid": `${testId}-input`,
|
|
61
|
+
placeholder: `Search ${props.kind.toLowerCase()}`,
|
|
62
|
+
leadingVisual: SearchIcon,
|
|
63
|
+
value: pattern,
|
|
64
|
+
onChange: (event) => changePattern(event.target.value, false),
|
|
65
|
+
onBlur: () => {
|
|
66
|
+
if (pattern.length === 0) props.onCollapse();
|
|
67
|
+
},
|
|
68
|
+
onKeyDown: (event) => {
|
|
69
|
+
if (event.key === "Escape") {
|
|
70
|
+
if (pattern.length === 0) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
props.onCollapse();
|
|
73
|
+
requestAnimationFrame(() => buttonRef.current?.focus());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
trailingAction: /* @__PURE__ */ jsx(TextInputAction, {
|
|
78
|
+
"aria-label": `Close ${props.kind.toLowerCase()} search`,
|
|
79
|
+
"aria-labelledby": "",
|
|
80
|
+
"data-testid": `${testId}-close`,
|
|
81
|
+
onClick: () => {
|
|
82
|
+
changePattern("", true);
|
|
83
|
+
props.onCollapse();
|
|
84
|
+
requestAnimationFrame(() => buttonRef.current?.focus());
|
|
85
|
+
},
|
|
86
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
87
|
+
})
|
|
88
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
89
|
+
ref: buttonRef,
|
|
90
|
+
className: button,
|
|
91
|
+
variant: ButtonVariant.Invisible,
|
|
92
|
+
size: ButtonSize.Small,
|
|
93
|
+
leadingVisual: SearchIcon,
|
|
94
|
+
"aria-expanded": false,
|
|
95
|
+
"aria-controls": inputId,
|
|
96
|
+
onClick: props.onExpand,
|
|
97
|
+
"data-testid": `${testId}-button`,
|
|
98
|
+
title: `${props.kind} search`,
|
|
99
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: button_label,
|
|
101
|
+
children: props.kind
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
props.state.error != null && /* @__PURE__ */ jsx("span", {
|
|
105
|
+
className: "dashql_error_uKHhqe",
|
|
106
|
+
title: props.state.error,
|
|
107
|
+
"aria-label": `${props.kind} search failed`,
|
|
108
|
+
children: "!"
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: status,
|
|
112
|
+
role: "status",
|
|
113
|
+
"data-testid": `${testId}-status`,
|
|
114
|
+
children: props.state.error ?? (props.state.pending ? `Searching ${props.kind.toLowerCase()}` : props.state.requestedPattern.length > 0 && props.matchCount != null ? `${props.kind} search complete, ${props.matchCount} matching ${props.kind.toLowerCase()}` : "")
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function QueryResultSearchControls(props) {
|
|
120
|
+
const [columnsExpanded, setColumnsExpanded] = React.useState(() => props.columnSearch.requestedPattern.length > 0);
|
|
121
|
+
const [dataExpanded, setDataExpanded] = React.useState(() => props.dataSearch.requestedPattern.length > 0);
|
|
122
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SearchControl, {
|
|
123
|
+
kind: "Columns",
|
|
124
|
+
state: props.columnSearch,
|
|
125
|
+
expanded: columnsExpanded,
|
|
126
|
+
onExpand: () => setColumnsExpanded((expanded) => !expanded),
|
|
127
|
+
onCollapse: () => setColumnsExpanded(false),
|
|
128
|
+
onChange: props.onColumnPatternChange,
|
|
129
|
+
matchCount: props.columnMatchCount
|
|
130
|
+
}), /* @__PURE__ */ jsx(SearchControl, {
|
|
131
|
+
kind: "Data",
|
|
132
|
+
state: props.dataSearch,
|
|
133
|
+
expanded: dataExpanded,
|
|
134
|
+
onExpand: () => setDataExpanded((expanded) => !expanded),
|
|
135
|
+
onCollapse: () => setDataExpanded(false),
|
|
136
|
+
onChange: props.onDataPatternChange,
|
|
137
|
+
matchCount: props.dataMatchCount,
|
|
138
|
+
debounceMs: DATA_SEARCH_DEBOUNCE_MS
|
|
139
|
+
})] });
|
|
140
|
+
}
|
|
141
|
+
export { QueryResultSearchControls, useQueryResultSearch };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var control = "dashql_control_sRLxM1";
|
|
2
|
+
var button = "dashql_button_pRAzdX";
|
|
3
|
+
var input = "dashql_input_01TbFK";
|
|
4
|
+
var status = "dashql_status_9Kz-xo";
|
|
5
|
+
var error = "dashql_error_uKHhqe";
|
|
6
|
+
var button_label = "dashql_button_label_hlMdGM";
|
|
7
|
+
export { button, button_label, control, error, input, status };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComputationModel } from '../../models/computation_model.js';
|
|
3
|
+
import type { QueryModel } from '../../models/query_model.js';
|
|
4
|
+
import { type ComputationTables } from '../data_table/data_table.js';
|
|
5
|
+
interface TableSearchToolbarProps {
|
|
6
|
+
computation: ComputationModel | null;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function TableSearchToolbar(props: TableSearchToolbarProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
10
|
+
export interface ResultRowCounts {
|
|
11
|
+
totalRows: number | null;
|
|
12
|
+
currentRows: number | null;
|
|
13
|
+
matchingRows: number | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function useResultRowCounts(computation: ComputationModel | null): ResultRowCounts;
|
|
16
|
+
export declare function resultRowCount(model: QueryModel | null): {
|
|
17
|
+
hasResult: boolean;
|
|
18
|
+
totalRows: number | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function getMatchingRowCount(tables: ComputationTables): number | null;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useComputationTables } from "../data_table/computation_tables.js";
|
|
2
|
+
import { QueryResultSearchControls } from "./query_result_search_controls.js";
|
|
3
|
+
import { useQueryResultSearch } from "./use_query_result_search.js";
|
|
4
|
+
import "../data_table/data_table.js";
|
|
5
|
+
import { forEachIntegerValue } from "../data_table/data_table_window.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
9
|
+
var NO_DISPATCH = () => ({
|
|
10
|
+
ok: false,
|
|
11
|
+
changed: false,
|
|
12
|
+
error: "no computation",
|
|
13
|
+
id: null
|
|
14
|
+
});
|
|
15
|
+
function TableSearchToolbar(props) {
|
|
16
|
+
const computation = props.computation;
|
|
17
|
+
const search = useQueryResultSearch(computation?.computation ?? null, computation?.dispatch ?? NO_DISPATCH);
|
|
18
|
+
const tables = useComputationTables(computation?.computation ?? null, computation?.tables ?? null);
|
|
19
|
+
if (computation == null || search.columnSearch == null || search.dataSearch == null) return props.children;
|
|
20
|
+
const dataMatchCount = getMatchingRowCount(tables);
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(QueryResultSearchControls, {
|
|
22
|
+
columnSearch: search.columnSearch,
|
|
23
|
+
dataSearch: search.dataSearch,
|
|
24
|
+
onColumnPatternChange: search.setColumnPattern,
|
|
25
|
+
onDataPatternChange: search.setDataPattern,
|
|
26
|
+
columnMatchCount: search.columnSearch.matchingColumnGroups?.length ?? null,
|
|
27
|
+
dataMatchCount
|
|
28
|
+
}), props.children] });
|
|
29
|
+
}
|
|
30
|
+
function useResultRowCounts(computation) {
|
|
31
|
+
const table = computation?.computation ?? null;
|
|
32
|
+
const tables = useComputationTables(table, computation?.tables ?? null);
|
|
33
|
+
const totalRows = table?.dataTableRows ?? null;
|
|
34
|
+
const matchingRows = getMatchingRowCount(tables);
|
|
35
|
+
return {
|
|
36
|
+
totalRows,
|
|
37
|
+
currentRows: matchingRows ?? table?.filterTable?.rows ?? totalRows,
|
|
38
|
+
matchingRows
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function resultRowCount(model) {
|
|
42
|
+
const computation = model?.computation?.computation ?? null;
|
|
43
|
+
if (model == null || computation == null || model.query.status !== QueryExecutionStatus.SUCCEEDED) return {
|
|
44
|
+
hasResult: false,
|
|
45
|
+
totalRows: null
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
hasResult: true,
|
|
49
|
+
totalRows: computation.dataTableRows ?? null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var matchingRowCounts = /* @__PURE__ */ new WeakMap();
|
|
53
|
+
function getMatchingRowCount(tables) {
|
|
54
|
+
const dataMatches = tables.matchingRows;
|
|
55
|
+
if (dataMatches == null) return null;
|
|
56
|
+
if (tables.filterTable == null) return dataMatches.size;
|
|
57
|
+
const filterDataTable = tables.filterTable;
|
|
58
|
+
let countsByMatches = matchingRowCounts.get(filterDataTable);
|
|
59
|
+
const cached = countsByMatches?.get(dataMatches);
|
|
60
|
+
if (cached !== void 0) return cached;
|
|
61
|
+
const rowIds = filterDataTable.getChildAt(0);
|
|
62
|
+
if (rowIds == null) return 0;
|
|
63
|
+
let count = 0;
|
|
64
|
+
forEachIntegerValue(rowIds, (rowId) => {
|
|
65
|
+
if (dataMatches.has(rowId)) ++count;
|
|
66
|
+
});
|
|
67
|
+
if (countsByMatches == null) {
|
|
68
|
+
countsByMatches = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
matchingRowCounts.set(filterDataTable, countsByMatches);
|
|
70
|
+
}
|
|
71
|
+
countsByMatches.set(dataMatches, count);
|
|
72
|
+
return count;
|
|
73
|
+
}
|
|
74
|
+
export { TableSearchToolbar, getMatchingRowCount, resultRowCount, useResultRowCounts };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { QueryResultDetailsLayout } from './query_result_details.js';
|
|
3
|
+
export interface ResultTableOverlayProps {
|
|
4
|
+
scriptName: string;
|
|
5
|
+
subject?: string;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
children: (layout: QueryResultDetailsLayout) => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function ResultTableOverlay(props: ResultTableOverlayProps): React.ReactElement;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { body, dialog, header, spacer, title } from "./result_table_overlay.module.js";
|
|
2
|
+
import { ButtonSize, ButtonVariant, IconButton } from "../button.js";
|
|
3
|
+
import { useFocusTrap } from "../../dom/focus.js";
|
|
4
|
+
import { Overlay, OverlaySize } from "../overlay.js";
|
|
5
|
+
import { ScreenFullIcon, ScreenNormalIcon, SymbolIcon } from "../symbol_icon.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var IGNORE_OUTSIDE_CLICK = () => {};
|
|
9
|
+
var CloseIcon = SymbolIcon("x_16");
|
|
10
|
+
function ResultTableOverlay(props) {
|
|
11
|
+
const dialogRef = React.useRef(null);
|
|
12
|
+
const [expanded, setExpanded] = React.useState(true);
|
|
13
|
+
const subject = props.subject ?? "Query results";
|
|
14
|
+
useFocusTrap({
|
|
15
|
+
containerRef: dialogRef,
|
|
16
|
+
initialFocusRef: dialogRef,
|
|
17
|
+
restoreFocusOnCleanUp: true
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsx(Overlay, {
|
|
20
|
+
centered: true,
|
|
21
|
+
width: OverlaySize.XXL,
|
|
22
|
+
height: OverlaySize.AUTO,
|
|
23
|
+
maxHeight: OverlaySize.XL,
|
|
24
|
+
preventFocusOnOpen: true,
|
|
25
|
+
expanded,
|
|
26
|
+
onEscape: props.onClose,
|
|
27
|
+
onClickOutside: IGNORE_OUTSIDE_CLICK,
|
|
28
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
29
|
+
ref: dialogRef,
|
|
30
|
+
className: dialog,
|
|
31
|
+
role: "dialog",
|
|
32
|
+
"aria-modal": "true",
|
|
33
|
+
tabIndex: -1,
|
|
34
|
+
"aria-label": `${subject} of ${props.scriptName}`,
|
|
35
|
+
"data-expanded": expanded || void 0,
|
|
36
|
+
"data-testid": "result-table-overlay",
|
|
37
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
38
|
+
className: header,
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx("h2", {
|
|
41
|
+
className: title,
|
|
42
|
+
children: props.scriptName
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsx("div", { className: spacer }),
|
|
45
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
46
|
+
variant: ButtonVariant.Invisible,
|
|
47
|
+
size: ButtonSize.Small,
|
|
48
|
+
"aria-label": expanded ? "Restore size" : "Enlarge",
|
|
49
|
+
"aria-pressed": expanded,
|
|
50
|
+
"data-testid": "result-table-overlay-resize",
|
|
51
|
+
onClick: () => setExpanded((e) => !e),
|
|
52
|
+
children: expanded ? /* @__PURE__ */ jsx(ScreenNormalIcon, { size: 16 }) : /* @__PURE__ */ jsx(ScreenFullIcon, { size: 16 })
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
55
|
+
variant: ButtonVariant.Invisible,
|
|
56
|
+
size: ButtonSize.Small,
|
|
57
|
+
"aria-label": `Close ${subject.toLowerCase()}`,
|
|
58
|
+
"data-testid": "result-table-overlay-close",
|
|
59
|
+
onClick: props.onClose,
|
|
60
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { size: 16 })
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
64
|
+
className: body,
|
|
65
|
+
children: props.children({
|
|
66
|
+
fitHeight: !expanded,
|
|
67
|
+
maxHeight: expanded ? void 0 : 556
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export { ResultTableOverlay };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComputationView } from '@akohn/dashql';
|
|
2
|
+
import type { ComputationDispatch } from '../data_table/data_table.js';
|
|
3
|
+
export declare function useQueryResultSearch(table: ComputationView | null, dispatch: ComputationDispatch): {
|
|
4
|
+
columnSearch: import("@akohn/dashql").ComputationSearch | null;
|
|
5
|
+
dataSearch: import("@akohn/dashql").ComputationSearch | null;
|
|
6
|
+
setColumnPattern: (pattern: string) => void;
|
|
7
|
+
setDataPattern: (pattern: string) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function useQueryResultSearch(table, dispatch) {
|
|
3
|
+
const setColumnPattern = React.useCallback((pattern) => {
|
|
4
|
+
dispatch({
|
|
5
|
+
kind: "setResultSearchPattern",
|
|
6
|
+
value: {
|
|
7
|
+
search: "columns",
|
|
8
|
+
pattern
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}, [dispatch]);
|
|
12
|
+
const setDataPattern = React.useCallback((pattern) => {
|
|
13
|
+
dispatch({
|
|
14
|
+
kind: "setResultSearchPattern",
|
|
15
|
+
value: {
|
|
16
|
+
search: "data",
|
|
17
|
+
pattern
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}, [dispatch]);
|
|
21
|
+
return {
|
|
22
|
+
columnSearch: table?.columnSearch ?? null,
|
|
23
|
+
dataSearch: table?.dataSearch ?? null,
|
|
24
|
+
setColumnPattern,
|
|
25
|
+
setDataPattern
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export { useQueryResultSearch };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare enum SegmentedControlSize {
|
|
3
|
+
Tiny = 0,
|
|
4
|
+
Small = 1,
|
|
5
|
+
Medium = 2,
|
|
6
|
+
XSmall = 3,
|
|
7
|
+
XXSmall = 4
|
|
8
|
+
}
|
|
9
|
+
export declare enum SegmentedControlVariant {
|
|
10
|
+
/** The default variant with an outer border and dividers between segments */
|
|
11
|
+
Default = 0,
|
|
12
|
+
/** A borderless variant (no outer border, no dividers) — like the Button's invisible variant */
|
|
13
|
+
Invisible = 1
|
|
14
|
+
}
|
|
15
|
+
export interface SegmentedControlProps {
|
|
16
|
+
'aria-label'?: string;
|
|
17
|
+
'aria-labelledby'?: string;
|
|
18
|
+
'aria-describedby'?: string;
|
|
19
|
+
/** A stable hook for tests */
|
|
20
|
+
'data-testid'?: string;
|
|
21
|
+
/** Whether the control fills the width of its parent */
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
/** The handler that gets called when a segment is selected */
|
|
24
|
+
onChange?: (selectedIndex: number) => void;
|
|
25
|
+
/** The size of the buttons */
|
|
26
|
+
size?: SegmentedControlSize;
|
|
27
|
+
/** The visual variant of the control */
|
|
28
|
+
variant?: SegmentedControlVariant;
|
|
29
|
+
className?: string;
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
export interface SegmentedControlButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
33
|
+
/** The visible label rendered in the button */
|
|
34
|
+
children: string;
|
|
35
|
+
/** Whether the segment is selected (for controlled components) */
|
|
36
|
+
selected?: boolean;
|
|
37
|
+
/** Whether the segment is selected initially (for uncontrolled components) */
|
|
38
|
+
defaultSelected?: boolean;
|
|
39
|
+
/** The leading visual icon */
|
|
40
|
+
leadingVisual?: React.ElementType;
|
|
41
|
+
/** Optional counter to display */
|
|
42
|
+
count?: number | string;
|
|
43
|
+
}
|
|
44
|
+
export interface SegmentedControlIconButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'> {
|
|
45
|
+
'aria-label': string;
|
|
46
|
+
/** The icon element */
|
|
47
|
+
icon: React.ElementType | React.ReactElement;
|
|
48
|
+
/** Whether the segment is selected (for controlled components) */
|
|
49
|
+
selected?: boolean;
|
|
50
|
+
/** Whether the segment is selected initially (for uncontrolled components) */
|
|
51
|
+
defaultSelected?: boolean;
|
|
52
|
+
/** Supplementary description for tooltip */
|
|
53
|
+
description?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const SegmentedControl: React.FC<SegmentedControlProps> & {
|
|
56
|
+
Button: React.FC<SegmentedControlButtonProps>;
|
|
57
|
+
IconButton: React.FC<SegmentedControlIconButtonProps>;
|
|
58
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { button, content, full_width, icon_button, icon_item, item, segmented_control, selected, size_small, size_tiny, size_xsmall, size_xxsmall, text, variant_invisible } from "./segmented_control.module.js";
|
|
2
|
+
import { classNames } from "../dom/classnames.js";
|
|
3
|
+
import { Tooltip } from "./tooltip.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var SegmentedControlSize = /* @__PURE__ */ function(SegmentedControlSize) {
|
|
7
|
+
SegmentedControlSize[SegmentedControlSize["Tiny"] = 0] = "Tiny";
|
|
8
|
+
SegmentedControlSize[SegmentedControlSize["Small"] = 1] = "Small";
|
|
9
|
+
SegmentedControlSize[SegmentedControlSize["Medium"] = 2] = "Medium";
|
|
10
|
+
SegmentedControlSize[SegmentedControlSize["XSmall"] = 3] = "XSmall";
|
|
11
|
+
SegmentedControlSize[SegmentedControlSize["XXSmall"] = 4] = "XXSmall";
|
|
12
|
+
return SegmentedControlSize;
|
|
13
|
+
}({});
|
|
14
|
+
var SegmentedControlVariant = /* @__PURE__ */ function(SegmentedControlVariant) {
|
|
15
|
+
/** The default variant with an outer border and dividers between segments */
|
|
16
|
+
SegmentedControlVariant[SegmentedControlVariant["Default"] = 0] = "Default";
|
|
17
|
+
/** A borderless variant (no outer border, no dividers) — like the Button's invisible variant */
|
|
18
|
+
SegmentedControlVariant[SegmentedControlVariant["Invisible"] = 1] = "Invisible";
|
|
19
|
+
return SegmentedControlVariant;
|
|
20
|
+
}({});
|
|
21
|
+
var SegmentedControlButton = ({ children, leadingVisual: LeadingVisual, selected: selected$1, defaultSelected: _defaultSelected, count, className, disabled, ...props }) => {
|
|
22
|
+
return /* @__PURE__ */ jsx("li", {
|
|
23
|
+
className: classNames(item, { [selected]: selected$1 }),
|
|
24
|
+
"data-selected": selected$1 ? "" : void 0,
|
|
25
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
26
|
+
className: classNames(button, className),
|
|
27
|
+
type: "button",
|
|
28
|
+
"aria-current": selected$1,
|
|
29
|
+
"aria-disabled": disabled || void 0,
|
|
30
|
+
disabled,
|
|
31
|
+
...props,
|
|
32
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
33
|
+
className: content,
|
|
34
|
+
children: [
|
|
35
|
+
LeadingVisual && /* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "dashql_leading_visual_D94tIE",
|
|
37
|
+
children: /* @__PURE__ */ jsx(LeadingVisual, {})
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: text,
|
|
41
|
+
"data-text": children,
|
|
42
|
+
children
|
|
43
|
+
}),
|
|
44
|
+
count !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: "dashql_counter_vNRNoa",
|
|
46
|
+
children: count
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var SegmentedControlIconButton = ({ "aria-label": ariaLabel, icon: Icon, selected: selected$2, defaultSelected: _defaultSelected, description, className, disabled, ...props }) => {
|
|
54
|
+
return /* @__PURE__ */ jsx("li", {
|
|
55
|
+
className: classNames(item, icon_item, { [selected]: selected$2 }),
|
|
56
|
+
"data-selected": selected$2 ? "" : void 0,
|
|
57
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
58
|
+
text: description ?? ariaLabel,
|
|
59
|
+
type: description ? void 0 : "label",
|
|
60
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
61
|
+
className: classNames(button, icon_button, className),
|
|
62
|
+
type: "button",
|
|
63
|
+
"aria-current": selected$2,
|
|
64
|
+
"aria-label": description ? ariaLabel : void 0,
|
|
65
|
+
"aria-disabled": disabled || void 0,
|
|
66
|
+
disabled,
|
|
67
|
+
...props,
|
|
68
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
69
|
+
className: content,
|
|
70
|
+
children: React.isValidElement(Icon) ? Icon : /* @__PURE__ */ jsx(Icon, {})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var Root = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "data-testid": testId, children, fullWidth, onChange, size, variant, className }) => {
|
|
77
|
+
const isUncontrolled = onChange === void 0 || React.Children.toArray(children).some((child) => React.isValidElement(child) && child.props.defaultSelected !== void 0);
|
|
78
|
+
const selectedSegments = React.Children.toArray(children).map((child) => React.isValidElement(child) && (child.props.defaultSelected || child.props.selected));
|
|
79
|
+
const selectedIndexExternal = selectedSegments.some((isSelected) => isSelected) ? selectedSegments.indexOf(true) : 0;
|
|
80
|
+
const [selectedIndexInternalState, setSelectedIndexInternalState] = React.useState(selectedIndexExternal);
|
|
81
|
+
const selectedIndex = isUncontrolled ? selectedIndexInternalState : selectedIndexExternal;
|
|
82
|
+
if (!ariaLabel && !ariaLabelledby) console.warn("Use the `aria-label` or `aria-labelledby` prop to provide an accessible label for assistive technologies");
|
|
83
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
84
|
+
"aria-label": ariaLabel,
|
|
85
|
+
"aria-labelledby": ariaLabelledby,
|
|
86
|
+
"aria-describedby": ariaDescribedby,
|
|
87
|
+
"data-testid": testId,
|
|
88
|
+
className: classNames(segmented_control, {
|
|
89
|
+
[full_width]: fullWidth,
|
|
90
|
+
[size_tiny]: size === SegmentedControlSize.Tiny,
|
|
91
|
+
[size_small]: size === SegmentedControlSize.Small,
|
|
92
|
+
[size_xsmall]: size === SegmentedControlSize.XSmall,
|
|
93
|
+
[size_xxsmall]: size === SegmentedControlSize.XXSmall,
|
|
94
|
+
[variant_invisible]: variant === SegmentedControlVariant.Invisible
|
|
95
|
+
}, className),
|
|
96
|
+
children: React.Children.map(children, (child, index) => {
|
|
97
|
+
if (!React.isValidElement(child)) return null;
|
|
98
|
+
const sharedChildProps = {
|
|
99
|
+
onClick: (event) => {
|
|
100
|
+
if (!(child.props.disabled === true || child.props["aria-disabled"] === "true" || child.props["aria-disabled"] === true)) {
|
|
101
|
+
onChange?.(index);
|
|
102
|
+
if (isUncontrolled) setSelectedIndexInternalState(index);
|
|
103
|
+
child.props.onClick?.(event);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
selected: index === selectedIndex
|
|
107
|
+
};
|
|
108
|
+
return React.cloneElement(child, sharedChildProps);
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var SegmentedControl = Object.assign(Root, {
|
|
113
|
+
Button: SegmentedControlButton,
|
|
114
|
+
IconButton: SegmentedControlIconButton
|
|
115
|
+
});
|
|
116
|
+
export { SegmentedControl, SegmentedControlSize, SegmentedControlVariant };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var segmented_control = "dashql_segmented_control_20dSw-";
|
|
2
|
+
var full_width = "dashql_full_width_q97SOM";
|
|
3
|
+
var size_small = "dashql_size_small_o8l3FD";
|
|
4
|
+
var size_tiny = "dashql_size_tiny_NARB8k";
|
|
5
|
+
var size_xsmall = "dashql_size_xsmall_wNi__4";
|
|
6
|
+
var size_xxsmall = "dashql_size_xxsmall_pW6pSC";
|
|
7
|
+
var variant_invisible = "dashql_variant_invisible_injjHM";
|
|
8
|
+
var item = "dashql_item_FJhPPa";
|
|
9
|
+
var button = "dashql_button_YhxgUO";
|
|
10
|
+
var content = "dashql_content_yFgLVv";
|
|
11
|
+
var selected = "dashql_selected_leSSqx";
|
|
12
|
+
var icon_item = "dashql_icon_item_YZFSCD";
|
|
13
|
+
var leading_visual = "dashql_leading_visual_D94tIE";
|
|
14
|
+
var icon_button = "dashql_icon_button_h1bfpp";
|
|
15
|
+
var text = "dashql_text_pk23C0";
|
|
16
|
+
var counter = "dashql_counter_vNRNoa";
|
|
17
|
+
export { button, content, counter, full_width, icon_button, icon_item, item, leading_visual, segmented_control, selected, size_small, size_tiny, size_xsmall, size_xxsmall, text, variant_invisible };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type SeparatorAxis = 'x' | 'y';
|
|
3
|
+
export interface SeparatorDragHandlers {
|
|
4
|
+
onMove: (position: number, start: number) => void;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
onDragStart?: () => () => void;
|
|
8
|
+
onKey: (key: 'decrease' | 'increase' | 'min' | 'max') => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const SEPARATOR_CLASSES: {
|
|
11
|
+
x: any;
|
|
12
|
+
y: any;
|
|
13
|
+
dragging: any;
|
|
14
|
+
handle: any;
|
|
15
|
+
};
|
|
16
|
+
export declare function useSeparatorDrag(axis: SeparatorAxis, handlers: SeparatorDragHandlers): {
|
|
17
|
+
dragging: boolean;
|
|
18
|
+
onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
|
|
19
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
20
|
+
stop: () => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { dragging, handle, resizing_x, resizing_y, separator_x, separator_y } from "./separator.module.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var DRAG_THRESHOLD = 3;
|
|
4
|
+
var SEPARATOR_CLASSES = {
|
|
5
|
+
x: separator_x,
|
|
6
|
+
y: separator_y,
|
|
7
|
+
dragging,
|
|
8
|
+
handle
|
|
9
|
+
};
|
|
10
|
+
var KEYS = {
|
|
11
|
+
x: {
|
|
12
|
+
ArrowLeft: "decrease",
|
|
13
|
+
ArrowRight: "increase"
|
|
14
|
+
},
|
|
15
|
+
y: {
|
|
16
|
+
ArrowUp: "decrease",
|
|
17
|
+
ArrowDown: "increase"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function useSeparatorDrag(axis, handlers) {
|
|
21
|
+
const [dragging, setDragging] = React.useState(false);
|
|
22
|
+
const stopDraggingRef = React.useRef(null);
|
|
23
|
+
const stop = React.useCallback(() => stopDraggingRef.current?.(), []);
|
|
24
|
+
React.useEffect(() => stop, [stop]);
|
|
25
|
+
const onPointerDown = (event) => {
|
|
26
|
+
if (event.button !== 0) return;
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
stopDraggingRef.current?.();
|
|
29
|
+
setDragging(true);
|
|
30
|
+
const position = (e) => axis === "x" ? e.clientX : e.clientY;
|
|
31
|
+
const pointerId = event.pointerId;
|
|
32
|
+
const start = position(event);
|
|
33
|
+
let pointerMoved = false;
|
|
34
|
+
let endDrag;
|
|
35
|
+
const handlePointerMove = (moveEvent) => {
|
|
36
|
+
if (moveEvent.pointerId !== pointerId) return;
|
|
37
|
+
moveEvent.preventDefault();
|
|
38
|
+
if (!pointerMoved && Math.abs(position(moveEvent) - start) >= DRAG_THRESHOLD) {
|
|
39
|
+
pointerMoved = true;
|
|
40
|
+
endDrag = handlers.onDragStart?.();
|
|
41
|
+
}
|
|
42
|
+
if (pointerMoved) handlers.onMove(position(moveEvent), start);
|
|
43
|
+
};
|
|
44
|
+
const stopDragging = () => {
|
|
45
|
+
endDrag?.();
|
|
46
|
+
endDrag = void 0;
|
|
47
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
48
|
+
window.removeEventListener("pointerup", handlePointerEnd);
|
|
49
|
+
window.removeEventListener("pointercancel", handlePointerEnd);
|
|
50
|
+
document.documentElement.classList.remove(resizing_x, resizing_y);
|
|
51
|
+
if (stopDraggingRef.current === stopDragging) stopDraggingRef.current = null;
|
|
52
|
+
setDragging(false);
|
|
53
|
+
};
|
|
54
|
+
const handlePointerEnd = (endEvent) => {
|
|
55
|
+
if (endEvent.pointerId !== pointerId) return;
|
|
56
|
+
if (endEvent.type === "pointercancel") handlers.onCancel();
|
|
57
|
+
else if (!pointerMoved) handlers.onClick?.();
|
|
58
|
+
stopDragging();
|
|
59
|
+
};
|
|
60
|
+
window.addEventListener("pointermove", handlePointerMove);
|
|
61
|
+
window.addEventListener("pointerup", handlePointerEnd);
|
|
62
|
+
window.addEventListener("pointercancel", handlePointerEnd);
|
|
63
|
+
document.documentElement.classList.add(axis === "x" ? resizing_x : resizing_y);
|
|
64
|
+
stopDraggingRef.current = stopDragging;
|
|
65
|
+
};
|
|
66
|
+
const onKeyDown = (event) => {
|
|
67
|
+
const key = event.key === "Home" ? "min" : event.key === "End" ? "max" : KEYS[axis][event.key];
|
|
68
|
+
if (key == null) return;
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
handlers.onKey(key);
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
dragging,
|
|
74
|
+
onPointerDown,
|
|
75
|
+
onKeyDown,
|
|
76
|
+
stop
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export { SEPARATOR_CLASSES, useSeparatorDrag };
|