@progress/kendo-vue-grid
Version:
158 lines (157 loc) • 4.8 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
*-------------------------------------------------------------------------------------------
*/
import { defineComponent as h, createVNode as r, mergeProps as m, h as g } from "vue";
import { noop as f, Icon as y, getTemplate as I, Keys as b } from "@progress/kendo-vue-common";
import { KEYBOARD_NAV_DATA_ID as x, KEYBOARD_NAV_DATA_LEVEL as $, DETAIL_EXPAND_ACTION as C } from "@progress/kendo-vue-data-tools";
import { provideLocalizationService as S } from "@progress/kendo-vue-intl";
import { collapseDetailAriaLabel as p, messages as c, expandDetailAriaLabel as u } from "../messages/main.mjs";
import { minusIcon as A, plusIcon as v } from "@progress/kendo-svg-icons";
const N = (e) => {
var t, a;
return (a = (t = e.cells) == null ? void 0 : t.hierarchy) == null ? void 0 : a[e.rowType || "data"];
}, E = /* @__PURE__ */ h({
name: "KendoGridHierarchyCell",
inheritAttrs: !1,
props: {
id: String,
field: String,
dataItem: Object,
format: String,
type: String,
className: String,
colSpan: Number,
columnIndex: Number,
columnsCount: Number,
rowType: String,
level: Number,
expanded: Boolean,
editor: String,
isSelected: Boolean,
dataIndex: Number,
ariaColumnIndex: Number,
render: [String, Function, Object],
isRtl: Boolean,
cells: Object
},
emits: {
change: null,
cellkeydown: null
},
inject: {
gridContext: {
default: null
},
kendoIntlService: {
default: null
},
kendoLocalizationService: {
default: null
},
getKeyboardNavigationAttributes: {
default: f
}
},
methods: {
triggerStateChange() {
const e = this.gridContext;
e != null && e.dataItemKey && this.$props.dataItem[e.dataItemKey] !== void 0 && (e == null || e.dispatchDetailExpand({
type: C.TOGGLE,
id: this.$props.dataItem[e.dataItemKey]
}));
},
triggerKeydown(e, t) {
this.$emit("cellkeydown", {
event: e,
dataItem: this.$props.dataItem,
field: this.$props.field,
expanded: t
}), !e.defaultPrevented && e.keyCode === b.enter && (e.preventDefault(), this.$emit("change", {
dataItem: this.$props.dataItem,
dataIndex: this.$props.dataIndex,
event: e,
field: this.$props.field,
value: !t
}), this.triggerStateChange());
},
clickHandler(e, t, a) {
e.preventDefault(), this.$emit("change", {
dataItem: t,
event: e,
field: void 0,
value: !a
}), this.triggerStateChange();
},
triggerContextMenu(e) {
var t, a;
(a = (t = this.gridContext) == null ? void 0 : t.onContextMenu) == null || a.call(t, e, this.$props.dataItem, this.$props.field);
}
},
computed: {
wrapperClass() {
return {
"k-table-td": !0,
"k-hierarchy-cell": !0,
[this.className || ""]: this.className
};
}
},
render() {
let e = null, t, a = null;
const n = this.getKeyboardNavigationAttributes(this.$props.id), s = S(this), o = s.toLanguageString(p, c[p]), d = s.toLanguageString(u, c[u]);
if (this.$props.rowType === "groupFooter")
t = {
class: this.wrapperClass
}, e = r("td", t, null);
else if (this.$props.rowType !== "groupHeader") {
const i = this.$props.expanded;
t = {
style: this.$attrs.style,
class: this.wrapperClass,
"aria-expanded": i ? "true" : "false",
role: "gridcell",
"aria-colindex": this.$props.ariaColumnIndex,
tabindex: n.tabIndex,
"data-keyboardnavlevel": n[$],
"data-keyboardnavid": n[x]
}, a = r("a", {
onClick: (l) => {
this.clickHandler(l, this.$props.dataItem, i);
},
href: "#",
tabindex: -1,
title: i ? o : d,
"aria-label": i ? o : d
}, [r(y, {
name: i ? "minus" : "plus",
icon: i ? A : v
}, null)]), e = r("td", m(t, {
onKeydown: (l) => {
this.triggerKeydown(l, i);
}
}), [a]);
}
return I.call(this, {
h: g,
template: this.$props.render || N(this.$props),
defaultRendering: e,
additionalProps: {
...this.$props,
tdProps: t
},
additionalListeners: {
keydown: this.triggerKeydown,
click: this.clickHandler,
contextmenu: this.triggerContextMenu
},
defaultSlots: a
});
}
});
export {
E as GridHierarchyCell
};