UNPKG

@progress/kendo-react-data-tools

Version:

Includes React Pager & React Filter component, an intuitive interface to create complex filter descriptions. KendoReact Data Tools package

74 lines (73 loc) 3.07 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 { getStackedCellContainer as c, focusStackedCellElement as p } from "./utils.mjs"; const w = (t) => t === "ArrowLeft" || t === "ArrowRight" || t === "ArrowUp" || t === "ArrowDown" || t === "PageUp" || t === "PageDown" || t === "Home" || t === "End", D = (t, r, e, n, i, a) => { if (n && i === "inline") return !1; if (n && i === "incell") { t.preventDefault(), t.stopPropagation(); const s = c(r); if (!s) return !0; const g = Array.from(s.querySelectorAll(".k-grid-stack-cell")), d = g.indexOf(r); if (d === -1) return !0; const k = t.shiftKey ? -1 : 1, C = d + k; return C < 0 || C >= g.length || a && a(k), !0; } const f = c(r); if (!f) return !1; const o = Array.from(f.querySelectorAll(".k-grid-stack-cell")), l = o.indexOf(r); if (l === -1) return !1; if (t.shiftKey) { if (l === 0) return t.stopPropagation(), t.preventDefault(), !0; t.preventDefault(); const s = o[l - 1]; return s && p(s, 0), !0; } if (l === o.length - 1) return t.stopPropagation(), t.preventDefault(), !0; t.preventDefault(); const u = o[l + 1]; return u && p(u, 0), !0; }, y = (t, r, e, n, i) => n && i === "incell" || n && i === "inline" ? !1 : e === r ? (t.preventDefault(), p(r, 0), !0) : !1, h = (t, r, e, n, i, a) => { if (t.preventDefault(), t.stopPropagation(), i && a === "incell") { const o = document.activeElement; return o && r.contains(o) && o.blur(), r.focus(), n && n(), e && e(), !0; } if (i && a === "inline") return e && e(), !1; const f = c(r); return e && e(), f && f.focus(), !0; }, A = (t, r, e) => { if (!r) return !1; const n = t.key, a = t.target.closest(".k-animation-container, .k-popup, .k-list-container"); return e === "incell" && w(n) && !a || e === "inline" && (n === "ArrowUp" || n === "ArrowDown") && !a ? (t.preventDefault(), t.stopPropagation(), !0) : !1; }, S = (t) => { const { event: r, cellElement: e, onKeyDown: n, onEscape: i, onExitEdit: a, onTabToNextCell: f, isInEdit: o, editMode: l } = t, u = r.target; A(r, o, l) || (r.key === "Tab" && D(r, e, u, o, l, f), (r.key === "Enter" || r.key === "F2") && y(r, e, u, o, l), r.key === "Escape" && h(r, e, i, a, o, l), n && n(r)); }, P = { handleStackedKeyboardNavigation: S, handleStackedCellTabNavigation: D, handleStackedCellEnterKey: y, handleStackedCellEscapeKey: h, handleNavigationKeysInEditMode: A, isNavigationKey: w }; export { A as handleNavigationKeysInEditMode, y as handleStackedCellEnterKey, h as handleStackedCellEscapeKey, D as handleStackedCellTabNavigation, S as handleStackedKeyboardNavigation, P as stackedKeyboardNavigationTools };