@progress/kendo-vue-grid
Version:
138 lines (137 loc) • 3.9 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 d, createVNode as o, Fragment as p, mergeProps as c, h, inject as u } from "vue";
import { getNestedValue as m } from "../utils/main.mjs";
import { noop as g, getTemplate as b, Keys as s, guid as C } from "@progress/kendo-vue-common";
import { KEYBOARD_NAV_DATA_ID as y, KEYBOARD_NAV_DATA_LEVEL as f } from "@progress/kendo-vue-data-tools";
const x = (e) => {
var t, n;
return (n = (t = e.cells) == null ? void 0 : t.select) == null ? void 0 : n[e.rowType || "data"];
}, N = /* @__PURE__ */ d({
name: "KendoGridSelectionCell",
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,
render: [String, Function, Object],
isSelected: Boolean,
ariaColumnIndex: Number,
editor: String,
isRtl: Boolean,
cells: Object
},
emits: {
selectionchange: null,
cellkeydown: null
},
inject: {
kendoIntlService: {
default: null
},
getKeyboardNavigationAttributes: {
default: g
}
},
data() {
return {
inputId: C()
};
},
computed: {
tdClass() {
const {
className: e
} = this.$props;
return {
"k-table-td": !0,
[e]: e
};
}
},
methods: {
handleKeyDown(e) {
this.$emit("cellkeydown", {
event: e,
dataItem: this.$props.dataItem,
field: this.$props.field
}), (e.keyCode === s.enter || e.keyCode === s.space) && this.$emit("selectionchange", {
event: e,
dataItem: this.$props.dataItem
});
},
handleOnChange(e) {
this.$emit("selectionchange", {
event: e,
dataItem: this.$props.dataItem
});
},
triggerContextMenu(e) {
var t, n;
(n = (t = this.gridContext) == null ? void 0 : t.onContextMenu) == null || n.call(t, e, this.$props.dataItem, this.$props.field);
}
},
setup() {
return {
gridContext: u("gridContext", null)
};
},
render() {
let e, t = null;
const n = this.$props.isSelected || m(this.$props.field, this.$props.dataItem), i = typeof n == "boolean" && n, r = this.$props.render, l = this.getKeyboardNavigationAttributes(this.$props.id), a = this.$props.rowType !== "groupHeader" ? (e = {
style: this.$attrs.style,
colspan: this.$props.colSpan,
class: this.tdClass,
"aria-colindex": this.$props.ariaColumnIndex,
role: "gridcell",
tabindex: l.tabIndex,
"data-keyboardnavlevel": l[f],
"data-keyboardnavid": l[y]
}, t = o(p, null, [o("span", {
class: "k-checkbox-wrap"
}, [o("input", {
checked: i,
id: this.inputId,
type: "checkbox",
class: "k-checkbox k-checkbox-md k-rounded-md",
onChange: this.handleOnChange
}, null)]), o("label", {
class: "k-checkbox-label",
for: this.inputId
}, null)]), o("td", c(e, {
onKeydown: this.handleKeyDown
}), [t])) : null;
return b.call(this, {
h,
template: r || x(this.$props),
defaultRendering: a,
additionalProps: {
...this.$props,
tdProps: e
},
additionalListeners: {
keydown: this.handleKeyDown,
change: this.handleOnChange,
contextmenu: this.triggerContextMenu
},
defaultSlots: t
});
}
});
export {
N as GridSelectionCell
};