UNPKG

@progress/kendo-vue-grid

Version:
112 lines (111 loc) 3.59 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { defineComponent as M, createVNode as u, inject as P, ref as C, computed as e } from "vue"; import { Icon as j, guid as D } from "@progress/kendo-vue-common"; import { Popup as R } from "@progress/kendo-vue-popup"; import { unpinIcon as I, pinIcon as V, pinTopIcon as A, pinBottomIcon as G } from "@progress/kendo-svg-icons"; import { messages as s, gridPinToTop as p, gridPinToBottom as l, gridUnpin as r } from "../../messages/main.mjs"; import { Menu as N } from "@progress/kendo-vue-layout"; const Q = /* @__PURE__ */ M({ name: "GridPinDropdownButton", props: { dataItem: Object }, inject: { kendoLocalizationService: { default: null }, gridContext: { default: null } }, setup(h) { const t = P("kendoLocalizationService", {}), o = P("gridContext", {}), i = C(!1), w = "#", v = D(), a = e(() => o != null && o.getRowPinPosition ? o.getRowPinPosition(h.dataItem) : "none"), c = e(() => a.value !== "none"), m = e(() => { var n; return ((n = t == null ? void 0 : t.toLanguageString) == null ? void 0 : n.call(t, p, s[p])) || s[p]; }), x = e(() => { var n; return ((n = t == null ? void 0 : t.toLanguageString) == null ? void 0 : n.call(t, l, s[l])) || s[l]; }), d = e(() => { var n; return ((n = t == null ? void 0 : t.toLanguageString) == null ? void 0 : n.call(t, r, s[r])) || s[r]; }), B = e(() => { const n = []; return c.value && n.push({ text: d.value, svgIcon: I, data: { action: "unpin" } }), a.value !== "top" && n.push({ text: m.value, svgIcon: A, data: { action: "pinTop" } }), a.value !== "bottom" && n.push({ text: x.value, svgIcon: G, data: { action: "pinBottom" } }), n; }); return { anchor: v, showPopup: i, hrefValue: w, isPinned: c, pinToTopText: m, unpinText: d, menuItems: B, handleToggle: (n) => { n.preventDefault(), i.value = !i.value; }, handleClose: (n) => { n.isAnchorClicked || (i.value = !1); }, handleMenuSelect: (n) => { var g, f, T; const b = (f = (g = n.item) == null ? void 0 : g.data) == null ? void 0 : f.action; (T = o == null ? void 0 : o.onRowPin) == null || T.call(o, b, h.dataItem), i.value = !1; } }; }, render() { return [u("a", { class: "k-pin-cell", ref: this.anchor, href: this.hrefValue, tabindex: -1, onClick: this.handleToggle, "aria-label": this.isPinned ? this.unpinText : this.pinToTopText }, [u(j, { name: this.isPinned ? "unpin" : "pin", icon: this.isPinned ? I : V }, null)]), u(R, { anchor: this.anchor, show: this.showPopup, anchorAlign: { vertical: "bottom", horizontal: "right" }, popupClass: "k-menu-popup", onMousedownoutside: this.handleClose }, { default: () => [u(N, { vertical: !0, items: this.menuItems, onSelect: this.handleMenuSelect }, null)] })]; } }); export { Q as GridPinDropdownButton };