utils.js 701 B

123456789101112131415161718192021
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. function isTreeItem(element) {
  7. return element === null || element === void 0 ? void 0 : element.matches("calcite-tree-item");
  8. }
  9. export function getEnabledSiblingItem(el, direction) {
  10. const directionProp = direction === "down" ? "nextElementSibling" : "previousElementSibling";
  11. let currentEl = el;
  12. let enabledEl = null;
  13. while (isTreeItem(currentEl)) {
  14. if (!currentEl.disabled) {
  15. enabledEl = currentEl;
  16. break;
  17. }
  18. currentEl = currentEl[directionProp];
  19. }
  20. return enabledEl;
  21. }