UNPKG

@progress/kendo-vue-grid

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