@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
22 lines (21 loc) • 651 B
JavaScript
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
* v1.5.0-next.4
*/
function isTreeItem(element) {
return element?.matches("calcite-tree-item");
}
export function getEnabledSiblingItem(el, direction) {
const directionProp = direction === "down" ? "nextElementSibling" : "previousElementSibling";
let currentEl = el;
let enabledEl = null;
while (isTreeItem(currentEl)) {
if (!currentEl.disabled) {
enabledEl = currentEl;
break;
}
currentEl = currentEl[directionProp];
}
return enabledEl;
}