@progress/kendo-vue-grid
Version:
135 lines (134 loc) • 3.95 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { defineComponent as c, createVNode as r, h as m } from "vue";
import { getNestedValue as u } from "../utils/main.mjs";
import { noop as h, Keys as g, Icon as f, getTemplate as y } from "@progress/kendo-vue-common";
import { KEYBOARD_NAV_DATA_LEVEL as b, KEYBOARD_NAV_DATA_ID as I } from "@progress/kendo-vue-data-tools";
import { provideLocalizationService as $ } from "@progress/kendo-vue-intl";
import { collapseDetailAriaLabel as s, messages as d, expandDetailAriaLabel as p } from "../messages/main.mjs";
import { minusIcon as v, plusIcon as x } from "@progress/kendo-svg-icons";
const D = /* @__PURE__ */ c({
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
},
emits: {
change: null,
cellkeydown: null
},
inject: {
kendoIntlService: {
default: null
},
kendoLocalizationService: {
default: null
},
getKeyboardNavigationAttributes: {
default: h
}
},
methods: {
triggerKeydown(e, t) {
this.$emit("cellkeydown", {
event: e,
dataItem: this.$props.dataItem,
field: this.$props.field,
expanded: t
}), !e.defaultPrevented && e.keyCode === g.enter && (e.preventDefault(), this.$emit("change", {
dataItem: this.$props.dataItem,
dataIndex: this.$props.dataIndex,
event: e,
field: this.$props.field,
value: !t
}));
},
clickHandler(e, t, i) {
e.preventDefault(), this.$emit("change", {
dataItem: t,
event: e,
field: void 0,
value: !i
});
}
},
computed: {
wrapperClass() {
return {
"k-table-td": !0,
"k-hierarchy-cell": !0,
[this.className || ""]: this.className
};
}
},
render() {
let e = null;
const t = this.getKeyboardNavigationAttributes(this.$props.id), i = $(this), l = i.toLanguageString(s, d[s]), o = i.toLanguageString(p, d[p]);
if (this.$props.rowType === "groupFooter")
e = r("td", {
class: this.wrapperClass
}, null);
else if (this.$props.rowType !== "groupHeader") {
const a = u(this.$props.field, this.$props.dataItem);
e = r("td", {
style: this.$attrs.style,
onKeydown: (n) => {
this.triggerKeydown(n, a);
},
class: this.wrapperClass,
"aria-expanded": a ? "true" : "false",
role: "gridcell",
"aria-colindex": this.$props.ariaColumnIndex,
tabindex: t.tabIndex,
"data-keyboardnavlevel": t[b],
"data-keyboardnavid": t[I]
}, [r("a", {
onClick: (n) => {
this.clickHandler(n, this.$props.dataItem, a);
},
href: "#",
tabindex: -1,
title: a ? l : o,
"aria-label": a ? l : o
}, [r(f, {
name: a ? "minus" : "plus",
icon: a ? v : x
}, null)])]);
}
return y.call(this, {
h: m,
template: this.$props.render,
defaultRendering: e,
additionalProps: this.$props,
additionalListeners: {
keydown: this.triggerKeydown,
click: this.clickHandler
}
});
}
});
export {
D as GridHierarchyCell
};