UNPKG

@progress/kendo-react-grid

Version:

React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package

59 lines (58 loc) 2.67 kB
/** * @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 o from "react"; import { IconWrap as E } from "@progress/kendo-react-common"; import { Popup as O } from "@progress/kendo-react-popup"; import { useLocalization as C } from "@progress/kendo-react-intl"; import { unpinOutlineIcon as P, pinOutlineTopIcon as L, pinOutlineBottomIcon as M, pinOutlineIcon as z } from "@progress/kendo-svg-icons"; import { gridPinToTop as T, messages as u, gridPinToBottom as I, gridUnpin as w } from "../../messages/index.mjs"; import { GridContext as D } from "../../utils/GridContext.mjs"; import { Menu as A } from "@progress/kendo-react-layout"; const q = (b) => { const { dataItem: a } = b, n = o.useContext(D), s = C(), k = "#", i = n != null && n.getRowPinPosition ? n.getRowPinPosition(a) : "none", e = i !== "none", [S, c] = o.useState(!1), m = o.useRef(null), v = o.useCallback((t) => { t.preventDefault(), c((l) => !l); }, []), R = o.useCallback((t) => { !t.isAnchorClicked && c(!1); }, []), r = s.toLanguageString(T, u[T]), f = s.toLanguageString(I, u[I]), p = s.toLanguageString(w, u[w]), x = o.useMemo(() => { const t = []; return e && t.push({ text: p, svgIcon: P, data: { action: "unpin" } }), i !== "top" && t.push({ text: r, svgIcon: L, data: { action: "pinTop" } }), i !== "bottom" && t.push({ text: f, svgIcon: M, data: { action: "pinBottom" } }), t; }, [e, p, i, r, f]), B = o.useCallback( (t) => { var g, h, d; const l = (h = (g = t.item) == null ? void 0 : g.data) == null ? void 0 : h.action; (d = n == null ? void 0 : n.onRowPin) == null || d.call(n, l, a), c(!1); }, [n, a] ); return /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement( "a", { className: "k-pin-cell", ref: m, href: k, tabIndex: -1, onClick: v, "aria-label": e ? p : r }, /* @__PURE__ */ o.createElement(E, { name: e ? "unpin" : "pin", icon: e ? P : z }) ), /* @__PURE__ */ o.createElement( O, { anchor: m.current, show: S, anchorAlign: { vertical: "bottom", horizontal: "right" }, popupClass: "k-menu-popup", onMouseDownOutside: R }, /* @__PURE__ */ o.createElement(A, { vertical: !0, items: x, onSelect: B }) )); }; export { q as GridPinDropdownButton };