mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
amend requested changes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { atomWithReset } from "jotai/utils";
|
||||
import { useAtom } from "jotai";
|
||||
import { atomWithReset, useResetAtom } from "jotai/utils";
|
||||
|
||||
export type SelectedCell = {
|
||||
rowIndex: number;
|
||||
@@ -15,4 +16,15 @@ const INIT_VALUE = {
|
||||
anchorEl: null,
|
||||
};
|
||||
|
||||
export default function useContextMenuAtom() {
|
||||
const [contextMenu, setContextMenu] = useAtom(contextMenuAtom);
|
||||
const resetContextMenu = useResetAtom(contextMenuAtom);
|
||||
|
||||
return {
|
||||
contextMenu,
|
||||
setContextMenu,
|
||||
resetContextMenu,
|
||||
};
|
||||
}
|
||||
|
||||
export const contextMenuAtom = atomWithReset<IContextMenuAtom>(INIT_VALUE);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Menu, MenuList } from "@mui/material";
|
||||
import { Menu } from "@mui/material";
|
||||
import { default as MenuItem } from "./MenuItem";
|
||||
import { IContextMenuItem } from "./MenuItem";
|
||||
|
||||
@@ -39,14 +39,11 @@ export function MenuContents({
|
||||
maxWidth: "100%",
|
||||
},
|
||||
}}
|
||||
MenuListProps={{ disablePadding: true }}
|
||||
onContextMenu={handleContext}
|
||||
>
|
||||
<MenuList dense>
|
||||
{items.map((item, indx: number) => (
|
||||
<MenuItem key={indx} {...item} />
|
||||
))}
|
||||
</MenuList>
|
||||
{items.map((item, indx: number) => (
|
||||
<MenuItem key={indx} {...item} />
|
||||
))}
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import _find from "lodash/find";
|
||||
import { getFieldProp } from "@src/components/fields";
|
||||
import { useProjectContext } from "@src/contexts/ProjectContext";
|
||||
import useContextMenuAtom from "@src/hooks/useContextMenuAtom";
|
||||
import { MenuContents } from "./MenuContent";
|
||||
import useContextMenuAtom from "@src/atoms/ContextMenu";
|
||||
|
||||
export default function ContextMenu() {
|
||||
const { tableState }: any = useProjectContext();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import useContextMenuAtom from "@src/hooks/useContextMenuAtom";
|
||||
import useContextMenuAtom from "@src/atoms/ContextMenu";
|
||||
import { Fragment } from "react";
|
||||
import { Row, RowRendererProps } from "react-data-grid";
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import { formatSubTableName } from "@src/utils/fns";
|
||||
|
||||
import { useAppContext } from "@src/contexts/AppContext";
|
||||
import { useProjectContext } from "@src/contexts/ProjectContext";
|
||||
import useContextMenuAtom from "@src/atoms/ContextMenu";
|
||||
import useWindowSize from "@src/hooks/useWindowSize";
|
||||
import useContextMenuAtom from "@src/hooks/useContextMenuAtom";
|
||||
|
||||
export type TableColumn = Column<any> & {
|
||||
isNew?: boolean;
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function BasicContextMenuActions(
|
||||
};
|
||||
|
||||
const handleCut = () => {
|
||||
const notUndefined = Boolean(typeof cell !== "undefined");
|
||||
const notUndefined = typeof cell !== "undefined";
|
||||
if (deleteCell && notUndefined)
|
||||
deleteCell(selectedRow?.ref, selectedCol?.key);
|
||||
handleClose();
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { useResetAtom } from "jotai/utils";
|
||||
import { contextMenuAtom } from "@src/atoms/ContextMenu";
|
||||
|
||||
export default function useContextMenuAtom() {
|
||||
const [contextMenu, setContextMenu] = useAtom(contextMenuAtom);
|
||||
const resetContextMenu = useResetAtom(contextMenuAtom);
|
||||
|
||||
return {
|
||||
contextMenu,
|
||||
setContextMenu,
|
||||
resetContextMenu,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user