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.64 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 C } from "@progress/kendo-react-popup"; import { useLocalization as L } from "@progress/kendo-react-intl"; import { unpinIcon as P, pinTopIcon as M, pinBottomIcon as z, pinIcon as D } from "@progress/kendo-svg-icons"; import { gridPinToTop as T, messages as m, gridPinToBottom as I, gridUnpin as w } from "../../messages/index.mjs"; import { GridContext as A } from "../../utils/GridContext.mjs"; import { Menu as G } from "@progress/kendo-react-layout"; const q = (b) => { const { dataItem: a } = b, n = o.useContext(A), s = L(), k = "#", i = n != null && n.getRowPinPosition ? n.getRowPinPosition(a) : "none", e = i !== "none", [S, c] = o.useState(!1), u = o.useRef(null), v = o.useCallback((t) => { t.preventDefault(), c((l) => !l); }, []), R = o.useCallback((t) => { !t.isAnchorClicked && c(!1); }, []), r = s.toLanguageString(T, m[T]), f = s.toLanguageString(I, m[I]), p = s.toLanguageString(w, m[w]), x = o.useMemo(() => { const t = []; return e && t.push({ text: p, svgIcon: P, data: { action: "unpin" } }), i !== "top" && t.push({ text: r, svgIcon: M, data: { action: "pinTop" } }), i !== "bottom" && t.push({ text: f, svgIcon: z, 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: u, href: k, tabIndex: -1, onClick: v, "aria-label": e ? p : r }, /* @__PURE__ */ o.createElement(E, { name: e ? "unpin" : "pin", icon: e ? P : D }) ), /* @__PURE__ */ o.createElement( C, { anchor: u.current, show: S, anchorAlign: { vertical: "bottom", horizontal: "right" }, popupClass: "k-menu-popup", onMouseDownOutside: R }, /* @__PURE__ */ o.createElement(G, { vertical: !0, items: x, onSelect: B }) )); }; export { q as GridPinDropdownButton };