UNPKG

@progress/kendo-vue-grid

Version:
163 lines (162 loc) 4.78 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 b, createVNode as n, h as x } from "vue"; import { noop as y, Icon as $, getTemplate as k, Keys as A } from "@progress/kendo-vue-common"; import { KEYBOARD_NAV_DATA_ID as v, KEYBOARD_NAV_DATA_LEVEL as S, GROUP_EXPAND_ACTION as C } from "@progress/kendo-vue-data-tools"; import { groupCaretAriaLabelCollapse as u, messages as g, groupCaretAriaLabelExpand as h } from "../messages/main.mjs"; import { provideLocalizationService as m } from "@progress/kendo-vue-intl"; import { caretAltDownIcon as N, caretAltRightIcon as L, caretAltLeftIcon as w } from "@progress/kendo-svg-icons"; const _ = /* @__PURE__ */ b({ name: "KendoGridGroupCell", inheritAttrs: !1, props: { id: String, field: String, dataItem: Object, format: String, type: String, colSpan: Number, className: String, columnIndex: Number, columnsCount: Number, rowType: String, level: Number, expanded: Boolean, editor: String, dataIndex: Number, isSelected: Boolean, isRtl: Boolean, ariaColumnIndex: Number, group: Object, render: [String, Function, Object] }, emits: { change: null, cellkeydown: null }, inject: { kendo: { default: null }, kendoIntlService: { default: null }, kendoLocalizationService: { default: null }, getKeyboardNavigationAttributes: { default: y } }, computed: { tdClass() { const { className: e } = this.$props; return { "k-table-td": !0, [e]: e }; } }, methods: { triggerStateChange() { var t; const e = this.kendo; (t = e == null ? void 0 : e.dispatchGroupExpand) == null || t.call(e, { type: C.TOGGLE, group: this.$props.group }); }, triggerKeydown(e, t) { this.$emit("cellkeydown", { event: e, dataItem: this.$props.dataItem, dataIndex: this.$props.dataIndex, field: this.$props.field, expanded: this.$props.expanded }), !e.defaultPrevented && e.keyCode === A.enter && (e.preventDefault(), this.$emit("change", { dataItem: this.$props.dataItem, dataIndex: this.$props.dataIndex, event: e, level: this.$props.level, field: void 0, value: !t }), this.triggerStateChange()); }, clickHandler(e, t, r) { e.preventDefault(), this.$emit("change", { dataItem: t, dataIndex: this.$props.dataIndex, event: e, level: this.$props.level, field: void 0, value: !r }), this.triggerStateChange(); } }, render() { let e = null; const { columnIndex: t, level: r, columnsCount: s, rowType: f, dataItem: i, field: l, expanded: a, render: I } = this.$props, d = this.getKeyboardNavigationAttributes(this.$props.id), p = m(this).toLanguageString(u, g[u]), c = m(this).toLanguageString(h, g[h]); return t === void 0 || r === void 0 || t < r || s === void 0 || f !== "groupHeader" || i[l] === void 0 ? e = n("td", { style: this.$attrs.style, key: "g" + t, class: "k-table-td k-group-cell" }, null) : t <= r && (e = n("td", { style: this.$attrs.style, onKeydown: (o) => { this.triggerKeydown(o, a); }, key: "g-colspan", class: this.tdClass, colspan: s - t, role: "gridcell", "aria-colindex": this.$props.ariaColumnIndex, "aria-selected": this.$props.isSelected, "aria-expanded": a, "data-grid-col-index": this.$props.columnIndex, tabindex: d.tabIndex, "data-keyboardnavlevel": d[S], "data-keyboardnavid": d[v] }, [n("p", { class: "k-reset" }, [n("a", { onClick: (o) => { this.clickHandler(o, i, a); }, href: "#", tabindex: -1, title: a ? p : c, "aria-label": a ? p : c }, [n($, { name: a ? "caret-alt-down" : this.isRtl ? "caret-alt-left" : "caret-alt-right", icon: a ? N : this.isRtl ? w : L }, null)]), i[l] ? i[l].toString() : ""])])), k.call(this, { h: x, template: I, defaultRendering: e, additionalProps: this.$props, additionalListeners: { keydown: this.triggerKeydown, click: this.clickHandler } }); } }); export { _ as GridGroupCell };