* Cut copy paste first cut * removed different parent groups logic * mouseup on the outer canvas removes selections. * bug fix * remove unwanted dead code. * Adding tests * build fix * min height fixes * fixing specs. * fixing specs.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { useDispatch } from "react-redux";
|
|
import { focusWidget } from "actions/widgetActions";
|
|
import {
|
|
selectMultipleWidgetsAction,
|
|
selectWidgetInitAction,
|
|
shiftSelectWidgetsEntityExplorerInitAction,
|
|
} from "actions/widgetSelectionActions";
|
|
|
|
import { useCallback } from "react";
|
|
|
|
export const useWidgetSelection = () => {
|
|
const dispatch = useDispatch();
|
|
return {
|
|
selectWidget: useCallback(
|
|
(widgetId?: string, isMultiSelect?: boolean) => {
|
|
dispatch(selectWidgetInitAction(widgetId, isMultiSelect));
|
|
},
|
|
[dispatch],
|
|
),
|
|
shiftSelectWidgetEntityExplorer: useCallback(
|
|
(widgetId: string, siblingWidgets: string[]) => {
|
|
dispatch(
|
|
shiftSelectWidgetsEntityExplorerInitAction(widgetId, siblingWidgets),
|
|
);
|
|
},
|
|
[dispatch],
|
|
),
|
|
focusWidget: useCallback(
|
|
(widgetId?: string) => dispatch(focusWidget(widgetId)),
|
|
[dispatch],
|
|
),
|
|
deselectAll: useCallback(() => dispatch(selectMultipleWidgetsAction([])), [
|
|
dispatch,
|
|
]),
|
|
};
|
|
};
|