@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
192 lines (191 loc) • 5.36 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as a from "react";
import { sortDescSmallIcon as w, sortAscSmallIcon as S, fileExcelIcon as u, filePdfIcon as R, caretAltUpIcon as f, caretAltDownIcon as v, caretAltToTopIcon as E, caretAltToBottomIcon as A, caretAltExpandIcon as y, clipboardIcon as D, fileTxtIcon as b, pageHeaderSectionIcon as T, tableRowGroupsIcon as H, gridIcon as h, tableUnmergeIcon as M, tableBodyIcon as P, trashIcon as N, pencilIcon as B, plusIcon as F } from "@progress/kendo-svg-icons";
import { useLocalization as U } from "@progress/kendo-react-intl";
import { ContextMenu as z } from "@progress/kendo-react-layout";
import { GridContextMenuItemNames as e } from "./enums.mjs";
const G = {
[e.create]: {
name: "create",
text: "Add",
icon: "plus",
svgIcon: F,
data: { action: "AddCommand" }
},
[e.edit]: {
name: "edit",
text: "Edit",
icon: "pencil",
svgIcon: B,
data: { action: "EditCommand" }
},
[e.delete]: {
name: "delete",
text: "Delete",
icon: "trash",
svgIcon: N,
data: { action: "DeleteCommand" }
},
[e.select]: {
name: "select",
text: "Select",
icon: "table-body",
svgIcon: P,
items: [
{
name: "selectRow",
text: "Row",
icon: "table-row-groups",
svgIcon: H,
data: { action: "SelectRowCommand" }
},
{
name: "selectAllRows",
text: "All rows",
icon: "grid",
svgIcon: h,
data: { action: "SelectAllRowsCommand" }
},
{
name: "clearSelection",
text: "Clear selection",
icon: "table-unmerge",
svgIcon: M,
data: { action: "ClearSelectionCommand" }
}
]
},
[e.copySelection]: {
name: "copySelection",
text: "Copy selection",
icon: "page-header-section",
svgIcon: T,
data: { action: "CopySelectionCommand" },
options: "withHeaders"
},
[e.copySelectionNoHeaders]: {
name: "copySelectionNoHeaders",
text: "Copy selection (No Headers)",
icon: "file-txt",
svgIcon: b,
data: { action: "CopySelectionCommand" }
},
[e.paste]: {
name: "paste",
text: "Paste (use CTRL/⌘ + V)",
icon: "clipboard",
svgIcon: D,
data: { action: "PasteCommand" }
},
[e.reorderRow]: {
name: "reorderRow",
text: "Reorder row",
icon: "caret-alt-expand",
svgIcon: y,
items: [
{
name: "reorderRowUp",
text: "Up",
icon: "caret-alt-up",
svgIcon: f,
data: { action: "ReorderRowCommand" }
},
{
name: "reorderRowDown",
text: "Down",
icon: "caret-alt-down",
svgIcon: v,
data: { action: "ReorderRowCommand" }
},
{
name: "reorderRowTop",
text: "Top",
icon: "caret-alt-to-top",
svgIcon: E,
data: { action: "ReorderRowCommand" }
},
{
name: "reorderRowBottom",
text: "Bottom",
icon: "caret-alt-to-bottom",
svgIcon: A,
data: { action: "ReorderRowCommand" }
}
]
},
[e.exportPDF]: {
name: "exportPDF",
text: "Export to PDF",
icon: "file-pdf",
svgIcon: R,
data: { action: "ExportPDFCommand" }
},
[e.exportExcel]: {
name: "exportExcel",
text: "Export to Excel",
icon: "file-excel",
svgIcon: u,
items: [
{ name: "exportToExcelAll", text: "All", data: { action: "ExportExcelCommand" } },
{
name: "exportToExcelSelection",
text: "Selection",
data: { action: "ExportExcelCommand" },
options: "selection,withHeaders"
},
{
name: "exportToExcelSelectionNoHeaders",
text: "Selection (No Headers)",
data: { action: "ExportExcelCommand" },
options: "selection"
}
]
},
[e.separator]: { name: "separator", separator: !0 },
[e.sortAsc]: {
name: "sortAsc",
text: "Sort Ascending",
icon: "sort-asc-small",
svgIcon: S,
data: { action: "SortCommand" }
},
[e.sortDesc]: {
name: "sortDesc",
text: "Sort Descending",
icon: "sort-desc-small",
svgIcon: w,
data: { action: "SortCommand" }
}
}, j = (m) => {
const { show: d, offset: p, dataItem: r, field: i, items: n, onClose: x, onSelect: s } = m, l = U(), I = a.useCallback(
(o) => {
s.call(void 0, {
event: o,
dataItem: r,
field: i
});
},
[s, r, i]
), c = a.useCallback(
(o) => {
const t = o;
return t.text && t.name && (t.text = l.toLanguageString(`contextMenu.${t.name}`, t.text || "")), t.items && Array.isArray(t.items) && (t.items = t.items.map((C) => c(C))), t;
},
[l]
), g = a.useMemo(() => n && n.map((o) => {
const t = typeof o == "string" ? G[o] : o;
return c(t);
}), [n, c]);
return /* @__PURE__ */ a.createElement(z, { show: d, offset: p, items: g, onClose: x, onSelect: I });
};
export {
j as GridContextMenu,
G as contextMenuItemsMap
};