@progress/kendo-vue-layout
Version:
124 lines (123 loc) • 2.95 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 { Keys as r } from "@progress/kendo-vue-common";
import { isIdZeroLevel as i, getFirstChildId as N, getRootParentId as b, getDirectParentId as f, getShortId as O, isIdFirstLevel as q, getItemById as D, getDirectSiblingIdForLevelZero as P, createId as J } from "./itemsIdsUtils.mjs";
const Q = /\S/;
function V(a, n, G, S, g, s) {
const H = l();
switch (G) {
case r.left:
return x();
case r.right:
return B();
case r.up:
return A();
case r.down:
return z();
case r.enter:
case r.space:
return R();
case r.home:
return W();
case r.end:
return Z();
case r.esc:
return _();
default:
return X() ? M() : n;
}
function x() {
return g ? s ? F() : U() : s ? C() : K();
}
function B() {
return g ? s ? U() : F() : s ? K() : C();
}
function z() {
return g ? u() : i(n) ? c() : u();
}
function A() {
return g ? h() : i(n) ? E() : h();
}
function R() {
return H.disabled ? n : d() ? N(n) : b(n);
}
function W() {
return y()[0].id;
}
function Z() {
const e = y();
return e[e.length - 1].id;
}
function _() {
return i(n) ? n : f(n);
}
function M() {
const e = S.toLowerCase(), t = y(), o = Number(O(n)), p = t.slice(o + 1).concat(t.slice(0, o + 1)).find((j) => (j.text || "").toLowerCase().startsWith(e));
return p ? p.id : n;
}
function K() {
return i(n) ? h() : q(n) ? c(h(b(n))) : f(n);
}
function U() {
return i(n) ? E() : f(n);
}
function C() {
return i(n) ? u() : c(
d() ? n : u(b(n))
);
}
function F() {
return c(
i(n) || d() ? n : u(b(n))
);
}
function c(e) {
return v(!0, e);
}
function E(e) {
return v(!1, e);
}
function X() {
return S.length === 1 && Q.test(S);
}
function l(e, t) {
return e === void 0 && (e = n), t === void 0 && (t = a), D(e, t);
}
function d(e) {
return l(e).items.length > 0;
}
function h(e) {
return L(!1, e);
}
function u(e) {
return L(!0, e);
}
function $(e) {
const t = l(e).items;
return t[t.length - 1].id;
}
function y() {
return i(n) ? a : l(f(n), a).items;
}
function v(e, t) {
t === void 0 && (t = n);
const o = l(t);
return d(t) && !o.disabled ? e ? N(t) : $(t) : t;
}
function L(e, t) {
if (t === void 0 && (t = n), i(t))
return P(e, t, a.length);
{
const o = f(t), w = O(t), p = l(o).items.length;
return J(P(e, w, p), o);
}
}
}
export {
V as getNewItemIdUponKeyboardNavigation
};