UNPKG

@progress/kendo-vue-grid

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