@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
40 lines (36 loc) • 1.65 kB
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
*/
import { o as nodeListToArray } from './dom.js';
import { Build } from '@stencil/core/internal/client';
const ComboboxItem = "CALCITE-COMBOBOX-ITEM";
const ComboboxItemGroup = "CALCITE-COMBOBOX-ITEM-GROUP";
const ComboboxChildSelector = `${ComboboxItem}, ${ComboboxItemGroup}`;
const CSS = {
listContainer: "list-container"
};
function getAncestors(element) {
const parent = element.parentElement?.closest(ComboboxChildSelector);
const grandparent = parent?.parentElement?.closest(ComboboxChildSelector);
return [parent, grandparent].filter((el) => el);
}
function getItemAncestors(item) {
return (item.ancestors?.filter((el) => el.nodeName === "CALCITE-COMBOBOX-ITEM") || []);
}
function getItemChildren(item) {
return nodeListToArray(item.querySelectorAll("calcite-combobox-item"));
}
function hasActiveChildren(node) {
const items = nodeListToArray(node.querySelectorAll("calcite-combobox-item"));
return items.filter((item) => item.selected).length > 0;
}
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;
}
export { ComboboxChildSelector as C, getItemChildren as a, ComboboxItem as b, ComboboxItemGroup as c, CSS as d, getAncestors as e, getDepth as f, getItemAncestors as g, hasActiveChildren as h };