1234567891011121314151617181920212223242526272829303132 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { nodeListToArray } from "../../utils/dom";
- import { ComboboxChildSelector } from "./resources";
- import { Build } from "@stencil/core";
- export function getAncestors(element) {
- var _a, _b;
- const parent = (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.closest(ComboboxChildSelector);
- const grandparent = (_b = parent === null || parent === void 0 ? void 0 : parent.parentElement) === null || _b === void 0 ? void 0 : _b.closest(ComboboxChildSelector);
- return [parent, grandparent].filter((el) => el);
- }
- export function getItemAncestors(item) {
- var _a;
- return (((_a = item.ancestors) === null || _a === void 0 ? void 0 : _a.filter((el) => el.nodeName === "CALCITE-COMBOBOX-ITEM")) || []);
- }
- export function getItemChildren(item) {
- return nodeListToArray(item.querySelectorAll("calcite-combobox-item"));
- }
- export function hasActiveChildren(node) {
- const items = nodeListToArray(node.querySelectorAll("calcite-combobox-item"));
- return items.filter((item) => item.selected).length > 0;
- }
- export function getDepth(element) {
- if (!Build.isBrowser) {
- return 0;
- }
- const result = document.evaluate("ancestor::calcite-combobox-item | ancestor::calcite-combobox-item-group", element, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
- return result.snapshotLength;
- }
|