UNPKG

@progress/kendo-react-grid

Version:

React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package

54 lines (53 loc) 2.29 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use client"; import * as l from "react"; import { GridColumnMenuItem as f } from "./GridColumnMenuItem.mjs"; import { GridColumnMenuItemGroup as x } from "./GridColumnMenuItemGroup.mjs"; import { normalizeSortable as z, sortSeqMap as L } from "../sortCommon.mjs"; import { useLocalization as R } from "@progress/kendo-react-intl"; import { sortAscending as C, messages as S, sortDescending as g } from "../messages/index.mjs"; import { sortAscSmallIcon as b, sortDescSmallIcon as w } from "@progress/kendo-svg-icons"; const D = "asc", I = "desc", M = (e, n) => n ? n.findIndex((o) => o.field === e) : -1, k = (e, n) => !!(n && e > -1 && n[e].dir === D), A = (e, n) => !!(n && e > -1 && n[e].dir === I), F = (e, n) => { const o = M(e, n); return A(o, n) || k(o, n); }, H = (e) => { const n = (t) => { i(t, D), e.onCloseMenu && e.onCloseMenu(); }, o = (t) => { i(t, I), e.onCloseMenu && e.onCloseMenu(); }, i = (t, G) => { if (t.preventDefault(), !e.onSortChange) return; const { allowUnsort: h, mode: v } = z(e.sortable || !1, !1), u = (e.sort || []).filter((r) => r.field === e.column.field)[0], a = L[h][u && u.dir || ""][G], d = v === "single" ? [] : (e.sort || []).filter((r) => r.field !== e.column.field); a !== "" && e.column.field && d.push({ field: e.column.field, dir: a }), e.onSortChange(d, t); }, { sort: c, column: E } = e, s = M(E.field, c), m = R(); return /* @__PURE__ */ l.createElement(x, null, /* @__PURE__ */ l.createElement( f, { title: m.toLanguageString(C, S[C]), iconClass: "k-i-sort-asc-sm", svgIcon: b, selected: k(s, c), onClick: n } ), /* @__PURE__ */ l.createElement( f, { title: m.toLanguageString(g, S[g]), iconClass: "k-i-sort-desc-sm", svgIcon: w, selected: A(s, c), onClick: o } )); }; export { H as GridColumnMenuSort, F as isColumnMenuSortActive };