UNPKG

@progress/kendo-vue-grid

Version:
141 lines (140 loc) 5.13 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 z, createVNode as c, inject as L, isVNode as j } from "vue"; import { getFilterType as O, getAriaLabel as V, operatorMap as $, booleanFilterValues as w } from "../filterCommon.mjs"; import { GridFilterCell as N } from "../cells/GridFilterCell.mjs"; import { provideLocalizationService as A } from "@progress/kendo-vue-intl"; import { filterAriaLabel as v, messages as B } from "../messages/main.mjs"; import { HeaderTdElement as k, tableKeyboardNavigationTools as y } from "@progress/kendo-vue-data-tools"; import { getVirtualHeaderCellsToRender as E } from "../utils/virtualColumns.mjs"; function H(t) { return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !j(t); } const Q = /* @__PURE__ */ z({ name: "kendoFilterRow", props: { grid: Object, columns: Array, filter: Object, filterOperators: Object, sort: [Object, Array], cellRender: [String, Function, Object], isRtl: Boolean, ariaRowIndex: Number, size: String, cellsToRender: Array, columnVirtualization: Boolean, onFilterchange: Function }, inject: { kendoLocalizationService: { default: null } }, methods: { headerCellClassName(t, r) { let i = r ? " k-grid-header-sticky" : ""; return this.$props.sort && this.$props.sort.filter((s) => s.field === t).length > 0 && (i += " k-sorted"), i; }, setFilter(t, r, i, s) { const o = []; (t !== "" && t !== null || r !== "") && o.push({ field: i, operator: r, value: t }), this.$props.filter && this.$props.filter.filters && (this.$props.filter.filters || []).forEach((d) => { const f = d; f && f.field !== i && o.push(f); }); const h = o.length > 0 ? { logic: "and", filters: o } : null; this.$emit("filterchange", h, s); } }, setup() { return { kendoLocalizationService: L("kendoLocalizationService", {}) }; }, render() { const t = A(this), r = this.$props.filter && this.$props.filter.filters || [], i = (e, l = null) => { const n = r.filter((a) => a.field === e)[0]; return n ? n.value : l; }, s = (e) => { const l = r.filter((n) => n.field === e)[0]; return l ? l.operator : null; }; let o = 0, h = -1; const p = E({ cellsToRender: this.$props.cellsToRender || [], columns: this.$props.columns, rowIndex: 0, // FilterRow is always a single row enableVirtualization: this.$props.columnVirtualization }), d = p.columnsToRender.length > 0, f = this.$props.columns.filter((e) => e.children.length === 0), I = d ? p.columnsToRender.map((e) => this.$props.columns[e]).filter((e) => e.children.length === 0) : f, C = d ? p.colSpans : [], S = I.map(function(e, l) { const n = (b) => { this.setFilter(b.value, b.operator, e.field, b); }, a = O(e.filter), u = (e.title || e.field) + " " + V(a, t), g = c(N, { grid: this.$props.grid, field: e.field, title: e.filterTitle, value: i(e.field, a === "text" ? "" : null), operator: s(e.field), operators: $(this.$props.filterOperators[a] || [], t), booleanValues: $(w, t), filterType: a, onChange: n, render: e.filterCell || this.$props.cellRender, "aria-label": u, size: this.$props.size }, null), m = e.declarationIndex >= 0 ? ++h : --o, F = { ariaLabel: e.filterable ? t.toLanguageString(v, B[v]) : void 0, ariaColumnIndex: e.ariaColumnIndex }, x = e.locked && e.left !== void 0 ? this.$props.isRtl ? { left: e.right + "px", right: e.left + "px" } : { left: e.left + "px", right: e.right + "px" } : void 0, R = d && C[l] !== void 0 ? C[l] : void 0, T = c(k, { key: m, role: "gridcell", columnId: y.getFilterColumnId(e.id), navigatable: e.navigatable, style: x, class: this.headerCellClassName(e.field, e.locked) || void 0, ariaColumnIndex: F.ariaColumnIndex, "aria-label": u, colSpan: R }, H(g) ? g : { default: () => [g] }); return e.filterable && T || c(k, { key: m, role: "gridcell", columnId: y.getFilterColumnId(e.id), navigatable: e.navigatable, style: x, class: this.headerCellClassName(e.field, e.locked) || void 0, ariaColumnIndex: F.ariaColumnIndex, "aria-label": u, colSpan: R }, null); }, this); return c("tr", { class: "k-table-row k-filter-row", "aria-rowindex": this.ariaRowIndex, role: "row" }, [S]); } }); export { Q as FilterRow };