@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,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { iterateFocusableElements } from "@primer/behaviors/utils";
|
|
3
|
+
import { focusTrap, focusZone } from "@primer/behaviors";
|
|
4
|
+
function useOpenAndCloseFocus(args) {
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
if (args.preventFocusOnOpen) return;
|
|
7
|
+
const returnRef = args.returnFocusRef?.current;
|
|
8
|
+
if (args.initialFocusRef && args.initialFocusRef.current) args.initialFocusRef.current.focus();
|
|
9
|
+
else if (args.containerRef.current) iterateFocusableElements(args.containerRef.current).next().value?.focus();
|
|
10
|
+
return function() {
|
|
11
|
+
returnRef?.focus();
|
|
12
|
+
};
|
|
13
|
+
}, [
|
|
14
|
+
args.initialFocusRef,
|
|
15
|
+
args.returnFocusRef,
|
|
16
|
+
args.containerRef,
|
|
17
|
+
args.preventFocusOnOpen
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
function useFocusTrap(args) {
|
|
21
|
+
const altContainerRef = React.useRef(null);
|
|
22
|
+
const altInitialFocusRef = React.useRef(null);
|
|
23
|
+
const containerRef = args?.containerRef ?? altContainerRef;
|
|
24
|
+
const initialFocusRef = args?.initialFocusRef ?? altInitialFocusRef;
|
|
25
|
+
const disabled = args?.disabled;
|
|
26
|
+
const abortController = React.useRef(null);
|
|
27
|
+
const previousFocusedElement = React.useRef(null);
|
|
28
|
+
if (!previousFocusedElement.current && !args?.disabled) previousFocusedElement.current = document.activeElement;
|
|
29
|
+
const disableTrap = React.useEffectEvent(() => {
|
|
30
|
+
abortController.current?.abort();
|
|
31
|
+
if (args?.returnFocusRef && args.returnFocusRef.current instanceof HTMLElement) args.returnFocusRef.current.focus();
|
|
32
|
+
else if (args?.restoreFocusOnCleanUp && previousFocusedElement.current instanceof HTMLElement) {
|
|
33
|
+
previousFocusedElement.current.focus();
|
|
34
|
+
previousFocusedElement.current = null;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (containerRef.current instanceof HTMLElement) {
|
|
39
|
+
if (!disabled) {
|
|
40
|
+
abortController.current = focusTrap(containerRef.current, initialFocusRef.current ?? void 0) ?? null;
|
|
41
|
+
return () => {
|
|
42
|
+
disableTrap();
|
|
43
|
+
};
|
|
44
|
+
} else disableTrap();
|
|
45
|
+
}
|
|
46
|
+
}, [
|
|
47
|
+
containerRef,
|
|
48
|
+
initialFocusRef,
|
|
49
|
+
disabled
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
containerRef,
|
|
53
|
+
initialFocusRef
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function useFocusZone(settings = {}) {
|
|
57
|
+
const altContainerRef = React.useRef(null);
|
|
58
|
+
const altActiveDescFocusRef = React.useRef(null);
|
|
59
|
+
const containerRef = settings.containerRef ?? altContainerRef;
|
|
60
|
+
const useActiveDescendant = !!settings.activeDescendantFocus;
|
|
61
|
+
const activeDescendantControlRef = (typeof settings.activeDescendantFocus === "boolean" || !settings.activeDescendantFocus ? void 0 : settings.activeDescendantFocus) ?? altActiveDescFocusRef;
|
|
62
|
+
const disabled = settings.disabled;
|
|
63
|
+
const abortController = React.useRef(null);
|
|
64
|
+
const updateZone = React.useEffectEvent(() => {
|
|
65
|
+
if (containerRef.current instanceof HTMLElement && (!useActiveDescendant || activeDescendantControlRef.current instanceof HTMLElement)) {
|
|
66
|
+
if (!disabled) {
|
|
67
|
+
const vanillaSettings = {
|
|
68
|
+
...settings,
|
|
69
|
+
activeDescendantControl: activeDescendantControlRef.current ?? void 0
|
|
70
|
+
};
|
|
71
|
+
abortController.current = focusZone(containerRef.current, vanillaSettings);
|
|
72
|
+
return () => {
|
|
73
|
+
abortController.current?.abort();
|
|
74
|
+
};
|
|
75
|
+
} else abortController.current?.abort();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
React.useEffect(() => updateZone(), [disabled]);
|
|
79
|
+
return {
|
|
80
|
+
containerRef,
|
|
81
|
+
activeDescendantControlRef
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export { useFocusTrap, useFocusZone, useOpenAndCloseFocus };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare enum EdgeType {
|
|
2
|
+
West = 0,
|
|
3
|
+
South = 1,
|
|
4
|
+
East = 2,
|
|
5
|
+
North = 3,
|
|
6
|
+
SouthWest = 4,
|
|
7
|
+
SouthEast = 5,
|
|
8
|
+
NorthEast = 6,
|
|
9
|
+
NorthWest = 7,
|
|
10
|
+
WestSouth = 8,
|
|
11
|
+
EastSouth = 9,
|
|
12
|
+
EastNorth = 10,
|
|
13
|
+
WestNorth = 11,
|
|
14
|
+
SouthWestSouth = 12,
|
|
15
|
+
SouthEastSouth = 13,
|
|
16
|
+
NorthEastNorth = 14,
|
|
17
|
+
NorthWestNorth = 15,
|
|
18
|
+
WestSouthWest = 16,
|
|
19
|
+
EastSouthEast = 17,
|
|
20
|
+
EastNorthEast = 18,
|
|
21
|
+
WestNorthWest = 19
|
|
22
|
+
}
|
|
23
|
+
export declare enum NodePort {
|
|
24
|
+
North = 1,
|
|
25
|
+
East = 2,
|
|
26
|
+
South = 4,
|
|
27
|
+
West = 8
|
|
28
|
+
}
|
|
29
|
+
export declare const PORTS_FROM: Uint8Array<ArrayBuffer>;
|
|
30
|
+
export declare const PORTS_TO: Uint8Array<ArrayBuffer>;
|
|
31
|
+
export declare function selectEdgeTypeFromAngle(angle: number): EdgeType;
|
|
32
|
+
export declare function selectEdgeType(fromX: number, fromY: number, toX: number, toY: number, width: number, height: number): EdgeType;
|
|
33
|
+
export declare function selectHorizontalEdgeType(fromX: number, fromY: number, toX: number, toY: number): EdgeType;
|
|
34
|
+
export declare function selectVerticalEdgeType(fromX: number, fromY: number, toX: number, toY: number): EdgeType;
|
|
35
|
+
export declare enum PathType {
|
|
36
|
+
NONE = 0,
|
|
37
|
+
DIRECT = 1,
|
|
38
|
+
SINGLE_TURN = 2,
|
|
39
|
+
TWO_TURNS = 3
|
|
40
|
+
}
|
|
41
|
+
export declare class PathBuilder {
|
|
42
|
+
pathType: PathType;
|
|
43
|
+
path: Float64Array;
|
|
44
|
+
i: number;
|
|
45
|
+
constructor();
|
|
46
|
+
clear(): void;
|
|
47
|
+
last(): [number, number];
|
|
48
|
+
begin(x: number, y: number): void;
|
|
49
|
+
push(x: number, y: number): void;
|
|
50
|
+
finish(pathType: PathType): PathBuilder;
|
|
51
|
+
render(standalone?: boolean): string;
|
|
52
|
+
}
|
|
53
|
+
export declare function buildEdgePathBetweenRectangles(builder: PathBuilder, type: EdgeType, fromCenterX: number, fromCenterY: number, toCenterX: number, toCenterY: number, fromWidth: number, fromHeight: number, toWidth: number, toHeight: number, cornerRadius: number, offset?: number): PathBuilder;
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
var EdgeType = /* @__PURE__ */ function(EdgeType) {
|
|
2
|
+
EdgeType[EdgeType["West"] = 0] = "West";
|
|
3
|
+
EdgeType[EdgeType["South"] = 1] = "South";
|
|
4
|
+
EdgeType[EdgeType["East"] = 2] = "East";
|
|
5
|
+
EdgeType[EdgeType["North"] = 3] = "North";
|
|
6
|
+
EdgeType[EdgeType["SouthWest"] = 4] = "SouthWest";
|
|
7
|
+
EdgeType[EdgeType["SouthEast"] = 5] = "SouthEast";
|
|
8
|
+
EdgeType[EdgeType["NorthEast"] = 6] = "NorthEast";
|
|
9
|
+
EdgeType[EdgeType["NorthWest"] = 7] = "NorthWest";
|
|
10
|
+
EdgeType[EdgeType["WestSouth"] = 8] = "WestSouth";
|
|
11
|
+
EdgeType[EdgeType["EastSouth"] = 9] = "EastSouth";
|
|
12
|
+
EdgeType[EdgeType["EastNorth"] = 10] = "EastNorth";
|
|
13
|
+
EdgeType[EdgeType["WestNorth"] = 11] = "WestNorth";
|
|
14
|
+
EdgeType[EdgeType["SouthWestSouth"] = 12] = "SouthWestSouth";
|
|
15
|
+
EdgeType[EdgeType["SouthEastSouth"] = 13] = "SouthEastSouth";
|
|
16
|
+
EdgeType[EdgeType["NorthEastNorth"] = 14] = "NorthEastNorth";
|
|
17
|
+
EdgeType[EdgeType["NorthWestNorth"] = 15] = "NorthWestNorth";
|
|
18
|
+
EdgeType[EdgeType["WestSouthWest"] = 16] = "WestSouthWest";
|
|
19
|
+
EdgeType[EdgeType["EastSouthEast"] = 17] = "EastSouthEast";
|
|
20
|
+
EdgeType[EdgeType["EastNorthEast"] = 18] = "EastNorthEast";
|
|
21
|
+
EdgeType[EdgeType["WestNorthWest"] = 19] = "WestNorthWest";
|
|
22
|
+
return EdgeType;
|
|
23
|
+
}({});
|
|
24
|
+
var NodePort = /* @__PURE__ */ function(NodePort) {
|
|
25
|
+
NodePort[NodePort["North"] = 1] = "North";
|
|
26
|
+
NodePort[NodePort["East"] = 2] = "East";
|
|
27
|
+
NodePort[NodePort["South"] = 4] = "South";
|
|
28
|
+
NodePort[NodePort["West"] = 8] = "West";
|
|
29
|
+
return NodePort;
|
|
30
|
+
}({});
|
|
31
|
+
var PORTS_FROM = new Uint8Array([
|
|
32
|
+
NodePort.West,
|
|
33
|
+
NodePort.South,
|
|
34
|
+
NodePort.East,
|
|
35
|
+
NodePort.North,
|
|
36
|
+
NodePort.South,
|
|
37
|
+
NodePort.South,
|
|
38
|
+
NodePort.North,
|
|
39
|
+
NodePort.North,
|
|
40
|
+
NodePort.West,
|
|
41
|
+
NodePort.East,
|
|
42
|
+
NodePort.East,
|
|
43
|
+
NodePort.West,
|
|
44
|
+
NodePort.South,
|
|
45
|
+
NodePort.South,
|
|
46
|
+
NodePort.North,
|
|
47
|
+
NodePort.North,
|
|
48
|
+
NodePort.West,
|
|
49
|
+
NodePort.East,
|
|
50
|
+
NodePort.East,
|
|
51
|
+
NodePort.West
|
|
52
|
+
]);
|
|
53
|
+
var PORTS_TO = new Uint8Array([
|
|
54
|
+
NodePort.East,
|
|
55
|
+
NodePort.North,
|
|
56
|
+
NodePort.West,
|
|
57
|
+
NodePort.South,
|
|
58
|
+
NodePort.East,
|
|
59
|
+
NodePort.West,
|
|
60
|
+
NodePort.West,
|
|
61
|
+
NodePort.East,
|
|
62
|
+
NodePort.North,
|
|
63
|
+
NodePort.North,
|
|
64
|
+
NodePort.South,
|
|
65
|
+
NodePort.South,
|
|
66
|
+
NodePort.North,
|
|
67
|
+
NodePort.North,
|
|
68
|
+
NodePort.South,
|
|
69
|
+
NodePort.South,
|
|
70
|
+
NodePort.East,
|
|
71
|
+
NodePort.West,
|
|
72
|
+
NodePort.West,
|
|
73
|
+
NodePort.East
|
|
74
|
+
]);
|
|
75
|
+
function selectEdgeTypeFromAngle(angle) {
|
|
76
|
+
const sector = angle === 180 ? -2 : angle / 90;
|
|
77
|
+
if (sector == Math.floor(sector)) return sector + 2;
|
|
78
|
+
else return Math.floor(sector) + 2 + 4;
|
|
79
|
+
}
|
|
80
|
+
function selectEdgeType(fromX, fromY, toX, toY, width, height) {
|
|
81
|
+
const dx = toX - fromX;
|
|
82
|
+
const dy = toY - fromY;
|
|
83
|
+
let orientation = selectEdgeTypeFromAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
84
|
+
const boxDx = Math.max(Math.abs(dx), width) - width;
|
|
85
|
+
const boxDy = Math.max(Math.abs(dy), height) - height;
|
|
86
|
+
if (orientation >= 4) {
|
|
87
|
+
if (boxDx > boxDy) {
|
|
88
|
+
orientation += 4;
|
|
89
|
+
if (Math.abs(dy) < height) orientation += 8;
|
|
90
|
+
} else if (Math.abs(dx) < width) orientation += 8;
|
|
91
|
+
}
|
|
92
|
+
return orientation;
|
|
93
|
+
}
|
|
94
|
+
function selectHorizontalEdgeType(fromX, fromY, toX, toY) {
|
|
95
|
+
const dx = toX - fromX;
|
|
96
|
+
const dy = toY - fromY;
|
|
97
|
+
const orientation = selectEdgeTypeFromAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
98
|
+
if (orientation >= 4) return orientation + 12;
|
|
99
|
+
else return orientation;
|
|
100
|
+
}
|
|
101
|
+
function selectVerticalEdgeType(fromX, fromY, toX, toY) {
|
|
102
|
+
const dx = toX - fromX;
|
|
103
|
+
const dy = toY - fromY;
|
|
104
|
+
const orientation = selectEdgeTypeFromAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
105
|
+
if (orientation >= 4) return orientation + 8;
|
|
106
|
+
else return orientation;
|
|
107
|
+
}
|
|
108
|
+
var PathType = /* @__PURE__ */ function(PathType) {
|
|
109
|
+
PathType[PathType["NONE"] = 0] = "NONE";
|
|
110
|
+
PathType[PathType["DIRECT"] = 1] = "DIRECT";
|
|
111
|
+
PathType[PathType["SINGLE_TURN"] = 2] = "SINGLE_TURN";
|
|
112
|
+
PathType[PathType["TWO_TURNS"] = 3] = "TWO_TURNS";
|
|
113
|
+
return PathType;
|
|
114
|
+
}({});
|
|
115
|
+
var PathBuilder = class {
|
|
116
|
+
pathType;
|
|
117
|
+
path;
|
|
118
|
+
i;
|
|
119
|
+
constructor() {
|
|
120
|
+
this.pathType = PathType.NONE;
|
|
121
|
+
this.path = /* @__PURE__ */ new Float64Array(16);
|
|
122
|
+
this.i = 0;
|
|
123
|
+
}
|
|
124
|
+
clear() {
|
|
125
|
+
for (let i = 0; i < 16; ++i) this.path[i] = 0;
|
|
126
|
+
this.i = 0;
|
|
127
|
+
}
|
|
128
|
+
last() {
|
|
129
|
+
return this.i < 2 ? [0, 0] : [this.path[this.i - 2], this.path[this.i - 1]];
|
|
130
|
+
}
|
|
131
|
+
begin(x, y) {
|
|
132
|
+
this.clear();
|
|
133
|
+
this.path[0] = x;
|
|
134
|
+
this.path[1] = y;
|
|
135
|
+
}
|
|
136
|
+
push(x, y) {
|
|
137
|
+
this.i += 2;
|
|
138
|
+
this.path[this.i] = x;
|
|
139
|
+
this.path[this.i + 1] = y;
|
|
140
|
+
}
|
|
141
|
+
finish(pathType) {
|
|
142
|
+
this.pathType = pathType;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
render(standalone = true) {
|
|
146
|
+
const p = this.path;
|
|
147
|
+
const prefix = standalone ? "M" : "L";
|
|
148
|
+
switch (this.pathType) {
|
|
149
|
+
case PathType.NONE: return "";
|
|
150
|
+
case PathType.DIRECT: return `${prefix} ${p[0]} ${p[1]} L ${p[2]} ${p[3]}`;
|
|
151
|
+
case PathType.SINGLE_TURN: return `${prefix} ${p[0]} ${p[1]} L ${p[2]} ${p[3]} Q ${p[4]} ${p[5]}, ${p[6]} ${p[7]} L ${p[8]} ${p[9]}`;
|
|
152
|
+
case PathType.TWO_TURNS: return `${prefix} ${p[0]} ${p[1]} L ${p[2]} ${p[3]} Q ${p[4]} ${p[5]}, ${p[6]} ${p[7]} L ${p[8]} ${p[9]} Q ${p[10]} ${p[11]}, ${p[12]} ${p[13]} L ${p[14]} ${p[15]}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
function buildEdgePathBetweenRectangles(builder, type, fromCenterX, fromCenterY, toCenterX, toCenterY, fromWidth, fromHeight, toWidth, toHeight, cornerRadius, offset = 0) {
|
|
157
|
+
if (toCenterX - fromCenterX == 0 && toCenterY - fromCenterY == 0) return builder;
|
|
158
|
+
const r = cornerRadius;
|
|
159
|
+
switch (type) {
|
|
160
|
+
case EdgeType.North:
|
|
161
|
+
fromCenterX += offset;
|
|
162
|
+
toCenterX += offset;
|
|
163
|
+
builder.begin(fromCenterX, fromCenterY + fromHeight / 2);
|
|
164
|
+
builder.push(toCenterX, toCenterY - toHeight / 2);
|
|
165
|
+
return builder.finish(PathType.DIRECT);
|
|
166
|
+
case EdgeType.South:
|
|
167
|
+
fromCenterX -= offset;
|
|
168
|
+
toCenterX -= offset;
|
|
169
|
+
builder.begin(fromCenterX, fromCenterY - fromHeight / 2);
|
|
170
|
+
builder.push(toCenterX, toCenterY + toHeight / 2);
|
|
171
|
+
return builder.finish(PathType.DIRECT);
|
|
172
|
+
case EdgeType.East:
|
|
173
|
+
fromCenterY -= offset;
|
|
174
|
+
toCenterY -= offset;
|
|
175
|
+
builder.begin(fromCenterX + fromWidth / 2, fromCenterY);
|
|
176
|
+
builder.push(toCenterX - toWidth / 2, toCenterY);
|
|
177
|
+
return builder.finish(PathType.DIRECT);
|
|
178
|
+
case EdgeType.West:
|
|
179
|
+
fromCenterY += offset;
|
|
180
|
+
toCenterY += offset;
|
|
181
|
+
builder.begin(fromCenterX - fromWidth / 2, fromCenterY);
|
|
182
|
+
builder.push(toCenterX + toWidth / 2, toCenterY);
|
|
183
|
+
return builder.finish(PathType.DIRECT);
|
|
184
|
+
case EdgeType.NorthEast: {
|
|
185
|
+
fromCenterY += fromHeight / 2;
|
|
186
|
+
toCenterX -= toWidth / 2;
|
|
187
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
188
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
189
|
+
fromCenterX += offset;
|
|
190
|
+
toCenterY -= offset;
|
|
191
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
192
|
+
builder.push(fromCenterX, toCenterY - Math.min(diffY / 2, r) - r);
|
|
193
|
+
builder.push(fromCenterX, toCenterY);
|
|
194
|
+
builder.push(fromCenterX + Math.min(diffX / 2, r), toCenterY);
|
|
195
|
+
builder.push(toCenterX, toCenterY);
|
|
196
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
197
|
+
}
|
|
198
|
+
case EdgeType.NorthWest: {
|
|
199
|
+
fromCenterY += fromHeight / 2;
|
|
200
|
+
toCenterX += toWidth / 2;
|
|
201
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
202
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
203
|
+
fromCenterX += offset;
|
|
204
|
+
toCenterY += offset;
|
|
205
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
206
|
+
builder.push(fromCenterX, toCenterY - Math.min(diffY / 2, r));
|
|
207
|
+
builder.push(fromCenterX, toCenterY);
|
|
208
|
+
builder.push(fromCenterX - Math.min(diffX / 2, r), toCenterY);
|
|
209
|
+
builder.push(toCenterX, toCenterY);
|
|
210
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
211
|
+
}
|
|
212
|
+
case EdgeType.SouthEast: {
|
|
213
|
+
fromCenterY -= fromHeight / 2;
|
|
214
|
+
toCenterX -= toWidth / 2;
|
|
215
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
216
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
217
|
+
fromCenterX -= offset;
|
|
218
|
+
toCenterY -= offset;
|
|
219
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
220
|
+
builder.push(fromCenterX, toCenterY + Math.min(diffY / 2, r));
|
|
221
|
+
builder.push(fromCenterX, toCenterY);
|
|
222
|
+
builder.push(fromCenterX + Math.min(diffX / 2, r), toCenterY);
|
|
223
|
+
builder.push(toCenterX, toCenterY);
|
|
224
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
225
|
+
}
|
|
226
|
+
case EdgeType.SouthWest: {
|
|
227
|
+
fromCenterY -= fromHeight / 2;
|
|
228
|
+
toCenterX += toWidth / 2;
|
|
229
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
230
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
231
|
+
fromCenterX -= offset;
|
|
232
|
+
toCenterY += offset;
|
|
233
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
234
|
+
builder.push(fromCenterX, toCenterY + Math.min(diffY / 2, r));
|
|
235
|
+
builder.push(fromCenterX, toCenterY);
|
|
236
|
+
builder.push(fromCenterX - Math.min(diffX / 2, r), toCenterY);
|
|
237
|
+
builder.push(toCenterX, toCenterY);
|
|
238
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
239
|
+
}
|
|
240
|
+
case EdgeType.EastNorth: {
|
|
241
|
+
fromCenterX += fromWidth / 2;
|
|
242
|
+
toCenterY -= toHeight / 2;
|
|
243
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
244
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
245
|
+
fromCenterY -= offset;
|
|
246
|
+
toCenterX += offset;
|
|
247
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
248
|
+
builder.push(toCenterX - Math.min(diffX / 2, r), fromCenterY);
|
|
249
|
+
builder.push(toCenterX, fromCenterY);
|
|
250
|
+
builder.push(toCenterX, fromCenterY + Math.min(diffY / 2, r));
|
|
251
|
+
builder.push(toCenterX, toCenterY);
|
|
252
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
253
|
+
}
|
|
254
|
+
case EdgeType.EastSouth: {
|
|
255
|
+
fromCenterX += fromWidth / 2;
|
|
256
|
+
toCenterY += toHeight / 2;
|
|
257
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
258
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
259
|
+
fromCenterY -= offset;
|
|
260
|
+
toCenterX -= offset;
|
|
261
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
262
|
+
builder.push(toCenterX - Math.min(diffX / 2, r), fromCenterY);
|
|
263
|
+
builder.push(toCenterX, fromCenterY);
|
|
264
|
+
builder.push(toCenterX, fromCenterY - Math.min(diffY / 2, r));
|
|
265
|
+
builder.push(toCenterX, toCenterY);
|
|
266
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
267
|
+
}
|
|
268
|
+
case EdgeType.WestNorth: {
|
|
269
|
+
fromCenterX -= fromWidth / 2;
|
|
270
|
+
toCenterY -= toHeight / 2;
|
|
271
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
272
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
273
|
+
fromCenterY += offset;
|
|
274
|
+
toCenterX += offset;
|
|
275
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
276
|
+
builder.push(toCenterX + Math.min(diffX / 2, r), fromCenterY);
|
|
277
|
+
builder.push(toCenterX, fromCenterY);
|
|
278
|
+
builder.push(toCenterX, fromCenterY + Math.min(diffY / 2, r));
|
|
279
|
+
builder.push(toCenterX, toCenterY);
|
|
280
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
281
|
+
}
|
|
282
|
+
case EdgeType.WestSouth: {
|
|
283
|
+
fromCenterX -= fromWidth / 2;
|
|
284
|
+
toCenterY += toHeight / 2;
|
|
285
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
286
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
287
|
+
fromCenterY -= offset;
|
|
288
|
+
toCenterX += offset;
|
|
289
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
290
|
+
builder.push(toCenterX + Math.min(diffX / 2, r), fromCenterY);
|
|
291
|
+
builder.push(toCenterX, fromCenterY);
|
|
292
|
+
builder.push(toCenterX, fromCenterY - Math.min(diffY / 2, r));
|
|
293
|
+
builder.push(toCenterX, toCenterY);
|
|
294
|
+
return builder.finish(PathType.SINGLE_TURN);
|
|
295
|
+
}
|
|
296
|
+
case EdgeType.EastNorthEast: {
|
|
297
|
+
fromCenterX += fromWidth / 2;
|
|
298
|
+
toCenterX -= toWidth / 2;
|
|
299
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
300
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
301
|
+
let midX = fromCenterX + diffX / 2;
|
|
302
|
+
fromCenterY -= offset;
|
|
303
|
+
toCenterY -= offset;
|
|
304
|
+
midX += offset;
|
|
305
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
306
|
+
builder.push(midX - Math.min(diffX / 2, r), fromCenterY);
|
|
307
|
+
builder.push(midX, fromCenterY);
|
|
308
|
+
builder.push(midX, fromCenterY + Math.min(diffY / 2, r));
|
|
309
|
+
builder.push(midX, toCenterY - Math.min(diffY / 2, r));
|
|
310
|
+
builder.push(midX, toCenterY);
|
|
311
|
+
builder.push(midX + Math.min(diffX / 2, r), toCenterY);
|
|
312
|
+
builder.push(toCenterX, toCenterY);
|
|
313
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
314
|
+
}
|
|
315
|
+
case EdgeType.EastSouthEast: {
|
|
316
|
+
fromCenterX += fromWidth / 2;
|
|
317
|
+
toCenterX -= toWidth / 2;
|
|
318
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
319
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
320
|
+
let midX = fromCenterX + diffX / 2;
|
|
321
|
+
fromCenterY -= offset;
|
|
322
|
+
toCenterY -= offset;
|
|
323
|
+
midX -= offset;
|
|
324
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
325
|
+
builder.push(midX - Math.min(diffX / 2, r), fromCenterY);
|
|
326
|
+
builder.push(midX, fromCenterY);
|
|
327
|
+
builder.push(midX, fromCenterY - Math.min(diffY / 2, r));
|
|
328
|
+
builder.push(midX, toCenterY + Math.min(diffY / 2, r));
|
|
329
|
+
builder.push(midX, toCenterY);
|
|
330
|
+
builder.push(midX + Math.min(diffX / 2, r), toCenterY);
|
|
331
|
+
builder.push(toCenterX, toCenterY);
|
|
332
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
333
|
+
}
|
|
334
|
+
case EdgeType.SouthEastSouth: {
|
|
335
|
+
fromCenterY -= fromHeight / 2;
|
|
336
|
+
toCenterY += toHeight / 2;
|
|
337
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
338
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
339
|
+
let midY = fromCenterY - diffY / 2;
|
|
340
|
+
fromCenterX -= offset;
|
|
341
|
+
toCenterX -= offset;
|
|
342
|
+
midY -= offset;
|
|
343
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
344
|
+
builder.push(fromCenterX, midY + Math.min(diffY / 2, r));
|
|
345
|
+
builder.push(fromCenterX, midY);
|
|
346
|
+
builder.push(fromCenterX + Math.min(diffX / 2, r), midY);
|
|
347
|
+
builder.push(toCenterX - Math.min(diffX / 2, r), midY);
|
|
348
|
+
builder.push(toCenterX, midY);
|
|
349
|
+
builder.push(toCenterX, midY - Math.min(diffY / 2, r));
|
|
350
|
+
builder.push(toCenterX, toCenterY);
|
|
351
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
352
|
+
}
|
|
353
|
+
case EdgeType.SouthWestSouth: {
|
|
354
|
+
fromCenterY -= fromHeight / 2;
|
|
355
|
+
toCenterY += toHeight / 2;
|
|
356
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
357
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
358
|
+
let midY = fromCenterY - diffY / 2;
|
|
359
|
+
fromCenterX -= offset;
|
|
360
|
+
toCenterX -= offset;
|
|
361
|
+
midY += offset;
|
|
362
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
363
|
+
builder.push(fromCenterX, midY + Math.min(diffY / 2, r));
|
|
364
|
+
builder.push(fromCenterX, midY);
|
|
365
|
+
builder.push(fromCenterX - Math.min(diffX / 2, r), midY);
|
|
366
|
+
builder.push(toCenterX + Math.min(diffX / 2, r), midY);
|
|
367
|
+
builder.push(toCenterX, midY);
|
|
368
|
+
builder.push(toCenterX, midY - Math.min(diffY / 2, r));
|
|
369
|
+
builder.push(toCenterX, toCenterY);
|
|
370
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
371
|
+
}
|
|
372
|
+
case EdgeType.WestNorthWest: {
|
|
373
|
+
fromCenterX -= fromWidth / 2;
|
|
374
|
+
toCenterX += toWidth / 2;
|
|
375
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
376
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
377
|
+
let midX = fromCenterX - diffX / 2;
|
|
378
|
+
fromCenterY += offset;
|
|
379
|
+
toCenterY += offset;
|
|
380
|
+
midX += offset;
|
|
381
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
382
|
+
builder.push(midX + Math.min(diffX / 2, r), fromCenterY);
|
|
383
|
+
builder.push(midX, fromCenterY);
|
|
384
|
+
builder.push(midX, fromCenterY + Math.min(diffY / 2, r));
|
|
385
|
+
builder.push(midX, toCenterY - Math.min(diffY / 2, r));
|
|
386
|
+
builder.push(midX, toCenterY);
|
|
387
|
+
builder.push(midX - Math.min(diffX / 2, r), toCenterY);
|
|
388
|
+
builder.push(toCenterX, toCenterY);
|
|
389
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
390
|
+
}
|
|
391
|
+
case EdgeType.WestSouthWest: {
|
|
392
|
+
fromCenterX -= fromWidth / 2;
|
|
393
|
+
toCenterX += toWidth / 2;
|
|
394
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
395
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
396
|
+
let midX = fromCenterX - diffX / 2;
|
|
397
|
+
fromCenterY += offset;
|
|
398
|
+
toCenterY += offset;
|
|
399
|
+
midX -= offset;
|
|
400
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
401
|
+
builder.push(midX + Math.min(diffX / 2, r), fromCenterY);
|
|
402
|
+
builder.push(midX, fromCenterY);
|
|
403
|
+
builder.push(midX, fromCenterY - Math.min(diffY / 2, r));
|
|
404
|
+
builder.push(midX, toCenterY + Math.min(diffY / 2, r));
|
|
405
|
+
builder.push(midX, toCenterY);
|
|
406
|
+
builder.push(midX - Math.min(diffX / 2, r), toCenterY);
|
|
407
|
+
builder.push(toCenterX, toCenterY);
|
|
408
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
409
|
+
}
|
|
410
|
+
case EdgeType.NorthEastNorth: {
|
|
411
|
+
fromCenterY += fromHeight / 2;
|
|
412
|
+
toCenterY -= toHeight / 2;
|
|
413
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
414
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
415
|
+
let midY = fromCenterY + diffY / 2;
|
|
416
|
+
fromCenterX += offset;
|
|
417
|
+
toCenterX += offset;
|
|
418
|
+
midY -= offset;
|
|
419
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
420
|
+
builder.push(fromCenterX, midY - Math.min(diffY / 2, r));
|
|
421
|
+
builder.push(fromCenterX, midY);
|
|
422
|
+
builder.push(fromCenterX + Math.min(diffX / 2, r), midY);
|
|
423
|
+
builder.push(toCenterX - Math.min(diffX / 2, r), midY);
|
|
424
|
+
builder.push(toCenterX, midY);
|
|
425
|
+
builder.push(toCenterX, midY + Math.min(diffY / 2, r));
|
|
426
|
+
builder.push(toCenterX, toCenterY);
|
|
427
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
428
|
+
}
|
|
429
|
+
case EdgeType.NorthWestNorth: {
|
|
430
|
+
fromCenterY += fromHeight / 2;
|
|
431
|
+
toCenterY -= toHeight / 2;
|
|
432
|
+
const diffX = Math.abs(toCenterX - fromCenterX);
|
|
433
|
+
const diffY = Math.abs(toCenterY - fromCenterY);
|
|
434
|
+
let midY = fromCenterY + diffY / 2;
|
|
435
|
+
fromCenterX += offset;
|
|
436
|
+
toCenterX += offset;
|
|
437
|
+
midY += offset;
|
|
438
|
+
builder.begin(fromCenterX, fromCenterY);
|
|
439
|
+
builder.push(fromCenterX, midY - Math.min(diffY / 2, r));
|
|
440
|
+
builder.push(fromCenterX, midY);
|
|
441
|
+
builder.push(fromCenterX - Math.min(diffX / 2, r), midY);
|
|
442
|
+
builder.push(toCenterX + Math.min(diffX / 2, r), midY);
|
|
443
|
+
builder.push(toCenterX, midY);
|
|
444
|
+
builder.push(toCenterX, midY + Math.min(diffY / 2, r));
|
|
445
|
+
builder.push(toCenterX, toCenterY);
|
|
446
|
+
return builder.finish(PathType.TWO_TURNS);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
export { EdgeType, NodePort, PORTS_FROM, PORTS_TO, PathBuilder, PathType, buildEdgePathBetweenRectangles, selectEdgeType, selectEdgeTypeFromAngle, selectHorizontalEdgeType, selectVerticalEdgeType };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type KeyEventCallback = (event: KeyboardEvent) => void;
|
|
2
|
+
export interface KeyEventHandler {
|
|
3
|
+
key: string;
|
|
4
|
+
ctrlKey?: boolean;
|
|
5
|
+
capture?: boolean;
|
|
6
|
+
callback: KeyEventCallback;
|
|
7
|
+
}
|
|
8
|
+
export declare function useKeyEvents(subscribers: KeyEventHandler[]): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function useKeyEvents(subscribers) {
|
|
3
|
+
const subscribersRef = React.useRef([]);
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
subscribersRef.current = subscribers;
|
|
6
|
+
}, [subscribers]);
|
|
7
|
+
const handleKeyPress = React.useCallback((event, capture) => {
|
|
8
|
+
for (const subscriber of subscribersRef.current) {
|
|
9
|
+
const ctrlKeyMatches = subscriber.ctrlKey === void 0 || subscriber.ctrlKey === event.ctrlKey;
|
|
10
|
+
if ((subscriber.capture ?? false) === capture && ctrlKeyMatches && subscriber.key == event.key) subscriber.callback(event);
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
const handleKeyPressCapture = React.useCallback((event) => {
|
|
14
|
+
if (event.defaultPrevented) return;
|
|
15
|
+
handleKeyPress(event, true);
|
|
16
|
+
}, [handleKeyPress]);
|
|
17
|
+
const handleKeyPressBubble = React.useCallback((event) => {
|
|
18
|
+
if (event.defaultPrevented) return;
|
|
19
|
+
handleKeyPress(event, false);
|
|
20
|
+
}, [handleKeyPress]);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
const target = document;
|
|
23
|
+
if (target) {
|
|
24
|
+
target.addEventListener("keydown", handleKeyPressCapture, true);
|
|
25
|
+
target.addEventListener("keydown", handleKeyPressBubble);
|
|
26
|
+
return () => {
|
|
27
|
+
target.removeEventListener("keydown", handleKeyPressCapture, true);
|
|
28
|
+
target.removeEventListener("keydown", handleKeyPressBubble);
|
|
29
|
+
};
|
|
30
|
+
} else return () => {};
|
|
31
|
+
}, [handleKeyPressBubble, handleKeyPressCapture]);
|
|
32
|
+
}
|
|
33
|
+
export { useKeyEvents };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function useMediaQuery(query) {
|
|
3
|
+
const [matches, setMatches] = React.useState(() => window.matchMedia?.(query).matches ?? false);
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const media = window.matchMedia?.(query);
|
|
6
|
+
if (media == null) return;
|
|
7
|
+
const update = () => setMatches(media.matches);
|
|
8
|
+
update();
|
|
9
|
+
media.addEventListener("change", update);
|
|
10
|
+
return () => media.removeEventListener("change", update);
|
|
11
|
+
}, [query]);
|
|
12
|
+
return matches;
|
|
13
|
+
}
|
|
14
|
+
var PHONE_WIDTH_QUERY = "(max-width: 600px)";
|
|
15
|
+
export { PHONE_WIDTH_QUERY, useMediaQuery };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface UseOnOutsideClickArgs {
|
|
3
|
+
containerRef: React.RefObject<HTMLDivElement | null> | React.RefObject<HTMLUListElement | null>;
|
|
4
|
+
ignoreClickRefs?: React.RefObject<Element | null>[];
|
|
5
|
+
onClickOutside: (e: MouseEvent | TouchEvent) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function useOnOutsideClick(args: UseOnOutsideClickArgs): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
var STOP_PROPAGATION = true;
|
|
3
|
+
var REGISTRY = {};
|
|
4
|
+
var NEXT_HANDLER_ID = 1;
|
|
5
|
+
function handleClick(event) {
|
|
6
|
+
if (!event.defaultPrevented) {
|
|
7
|
+
for (const handler of Object.values(REGISTRY).reverse()) if (handler(event) === STOP_PROPAGATION || event.defaultPrevented) break;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function useOnOutsideClick(args) {
|
|
11
|
+
const id = React.useMemo(() => NEXT_HANDLER_ID++, []);
|
|
12
|
+
const { containerRef, ignoreClickRefs, onClickOutside } = args;
|
|
13
|
+
const handler = React.useCallback((event) => {
|
|
14
|
+
if (event instanceof MouseEvent && event.button !== 0 && event.button !== 2) return STOP_PROPAGATION;
|
|
15
|
+
if (containerRef.current?.contains(event.target)) return STOP_PROPAGATION;
|
|
16
|
+
if (ignoreClickRefs && ignoreClickRefs.some(({ current }) => current?.contains(event.target))) return STOP_PROPAGATION;
|
|
17
|
+
onClickOutside(event);
|
|
18
|
+
}, [
|
|
19
|
+
containerRef,
|
|
20
|
+
ignoreClickRefs,
|
|
21
|
+
onClickOutside
|
|
22
|
+
]);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (Object.keys(REGISTRY).length === 0) document.addEventListener("mousedown", handleClick, { capture: true });
|
|
25
|
+
REGISTRY[id] = handler;
|
|
26
|
+
return () => {
|
|
27
|
+
delete REGISTRY[id];
|
|
28
|
+
if (Object.keys(REGISTRY).length === 0) document.removeEventListener("mousedown", handleClick, { capture: true });
|
|
29
|
+
};
|
|
30
|
+
}, [id, handler]);
|
|
31
|
+
}
|
|
32
|
+
export { useOnOutsideClick };
|