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