@progress/kendo-vue-grid
Version:
149 lines (148 loc) • 4.1 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 o, inject as s, createVNode as n, h as a } from "vue";
import { getNestedValue as d, parsers as l } from "../utils/main.mjs";
import { provideIntlService as p } from "@progress/kendo-vue-intl";
import { noop as c, getTemplate as g } from "@progress/kendo-vue-common";
import { KEYBOARD_NAV_DATA_LEVEL as m, KEYBOARD_NAV_DATA_ID as h } from "@progress/kendo-vue-data-tools";
const y = /* @__PURE__ */ o({
name: "GridCell",
inheritAttrs: !1,
emits: {
cellclick: null,
cellkeydown: null
},
props: {
id: String,
field: String,
dataItem: Object,
format: String,
readFormat: String,
className: String,
colSpan: Number,
columnIndex: Number,
columnsCount: Number,
dataIndex: Number,
rowType: String,
level: Number,
expanded: Boolean,
type: String,
editor: String,
isSelected: Boolean,
ariaColumnIndex: Number,
render: [String, Function, Object],
isRtl: Boolean,
onEdit: Function,
onSave: Function,
onRemove: Function,
onCancel: Function,
onChange: Function,
onSelectionchange: Function
},
inject: {
kendoIntlService: {
default: null
},
getKeyboardNavigationAttributes: {
default: c
}
},
methods: {
triggerClick() {
this.$emit("cellclick", {
dataItem: this.$props.dataItem,
field: this.$props.field
});
},
triggerKeydown(t) {
this.$emit("cellkeydown", {
event: t,
dataItem: this.$props.dataItem,
field: this.$props.field
});
},
triggerEdit(t) {
this.$emit("edit", t);
},
triggerAdd(t) {
this.$emit("add", t);
},
triggerCancel(t) {
this.$emit("cancel", t);
},
triggerSave(t) {
this.$emit("save", t);
},
triggerRemove(t) {
this.$emit("remove", t);
}
},
created() {
this._intl = p(this);
},
computed: {
tdClass() {
const {
className: t
} = this.$props;
return {
"k-table-td": !0,
[t]: t
};
}
},
setup() {
return {
kendoIntlService: s("kendoIntlService", {})
};
},
render() {
let t = null;
const i = this.getKeyboardNavigationAttributes(this.$props.id);
if (this.$props.rowType === "groupFooter")
t = n("td", {
class: this.tdClass
}, null);
else if (this.$props.field !== void 0 && this.$props.rowType !== "groupHeader") {
const e = d(this.$props.field, this.$props.dataItem);
let r = "";
e != null && (r = this.$props.format ? this.$props.type ? this._intl.format(this.$props.format, l[this.$props.type](e, this._intl, this.$props.readFormat)) : this._intl.format(this.$props.format, e) : e.toString()), t = n("td", {
style: this.$attrs.style,
colspan: this.$props.colSpan,
class: this.tdClass,
onKeydown: this.triggerKeydown,
onClick: this.triggerClick,
role: "gridcell",
"aria-colindex": this.$props.ariaColumnIndex,
"aria-selected": this.$props.isSelected,
"data-grid-col-index": this.$props.columnIndex,
tabindex: i.tabIndex,
"data-keyboardnavlevel": i[m],
"data-keyboardnavid": i[h]
}, [r]);
}
return g.call(this, {
h: a,
template: this.$props.render,
defaultRendering: t,
additionalProps: this.$props,
additionalListeners: {
click: this.triggerClick,
keydown: this.triggerKeydown,
edit: this.triggerEdit,
add: this.triggerAdd,
cancel: this.triggerCancel,
save: this.triggerSave,
remove: this.triggerRemove
}
});
}
});
export {
y as GridCell
};