UNPKG

@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
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 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 { plusIcon as w, pencilIcon as S, trashIcon as u, tableBodyIcon as R, tableRowGroupsIcon as f, gridIcon as v, tableUnmergeIcon as E, pageHeaderSectionIcon as A, fileTxtIcon as y, clipboardIcon as D, caretAltExpandIcon as b, caretAltUpIcon as T, caretAltDownIcon as H, caretAltToTopIcon as h, caretAltToBottomIcon as M, filePdfIcon as P, fileExcelIcon as N, sortAscSmallIcon as B, sortDescSmallIcon 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: w, data: { action: "AddCommand" } }, [e.edit]: { name: "edit", text: "Edit", icon: "pencil", svgIcon: S, data: { action: "EditCommand" } }, [e.delete]: { name: "delete", text: "Delete", icon: "trash", svgIcon: u, data: { action: "DeleteCommand" } }, [e.select]: { name: "select", text: "Select", icon: "table-body", svgIcon: R, items: [ { name: "selectRow", text: "Row", icon: "table-row-groups", svgIcon: f, data: { action: "SelectRowCommand" } }, { name: "selectAllRows", text: "All rows", icon: "grid", svgIcon: v, data: { action: "SelectAllRowsCommand" } }, { name: "clearSelection", text: "Clear selection", icon: "table-unmerge", svgIcon: E, data: { action: "ClearSelectionCommand" } } ] }, [e.copySelection]: { name: "copySelection", text: "Copy selection", icon: "page-header-section", svgIcon: A, data: { action: "CopySelectionCommand" }, options: "withHeaders" }, [e.copySelectionNoHeaders]: { name: "copySelectionNoHeaders", text: "Copy selection (No Headers)", icon: "file-txt", svgIcon: y, 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: b, items: [ { name: "reorderRowUp", text: "Up", icon: "caret-alt-up", svgIcon: T, data: { action: "ReorderRowCommand" } }, { name: "reorderRowDown", text: "Down", icon: "caret-alt-down", svgIcon: H, data: { action: "ReorderRowCommand" } }, { name: "reorderRowTop", text: "Top", icon: "caret-alt-to-top", svgIcon: h, data: { action: "ReorderRowCommand" } }, { name: "reorderRowBottom", text: "Bottom", icon: "caret-alt-to-bottom", svgIcon: M, data: { action: "ReorderRowCommand" } } ] }, [e.exportPDF]: { name: "exportPDF", text: "Export to PDF", icon: "file-pdf", svgIcon: P, data: { action: "ExportPDFCommand" } }, [e.exportExcel]: { name: "exportExcel", text: "Export to Excel", icon: "file-excel", svgIcon: N, 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: B, data: { action: "SortCommand" } }, [e.sortDesc]: { name: "sortDesc", text: "Sort Descending", icon: "sort-desc-small", svgIcon: F, 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 };