PromucFlow_constructor/app/client/src/utils/hooks/useWidgetSelection.ts
Ashok Kumar M cf19b8e44d
[Feature] Widget Grouping Phase - 3 (Cut Copy Paste) (#5083)
* 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.
2021-06-28 12:41:47 +05:30

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,
]),
};
};