UNPKG

@progress/kendo-vue-data-tools

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