@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
1 lines • 2.18 kB
JavaScript
var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),o=0,t=0;t<r;t++)for(var u=arguments[t],l=0,i=u.length;l<i;l++,o++)n[o]=u[l];return n};function nodeListToArray(e){return Array.isArray(e)?e:Array.from(e)}function getElementDir(e){return getElementProp(e,"dir","ltr")}function getElementTheme(e){return getElementProp(e,"theme","light")}function getElementProp(e,t,r,n){if(n===void 0){n=false}var o="["+t+"]";var u=n?closestElementCrossShadowBoundary(o,e):e.closest(o);return u?u.getAttribute(t):r}function closestElementCrossShadowBoundary(e,t){if(t===void 0){t=this}function r(t){if(!t||t===document||t===window)return null;var n=t.closest(e);return n?n:r(t.getRootNode().host)}return r(t)}function focusElement(e){if(!e){return}typeof e.setFocus==="function"?e.setFocus():e.focus()}function getSlotted(e,t,r){var n='[slot="'+t+'"]';if(r===null||r===void 0?void 0:r.all){return queryMultiple(e,n,r)}return querySingle(e,n,r)}function queryMultiple(e,t,r){var n=Array.from(e.querySelectorAll(t));n=r&&r.direct===false?n:n.filter((function(t){return t.parentElement===e}));var o=r===null||r===void 0?void 0:r.selector;return o?n.map((function(e){return Array.from(e.querySelectorAll(o))})).reduce((function(e,t){return __spreadArrays(e,t)}),[]).filter((function(e){return!!e})):n}function querySingle(e,t,r){var n=e.querySelector(t);n=r&&r.direct===false?n:(n===null||n===void 0?void 0:n.parentElement)===e?n:null;var o=r===null||r===void 0?void 0:r.selector;return o?n.querySelector(o):n}function filterDirectChildren(e,t){return Array.from(e.children).filter((function(e){return e.matches(t)}))}function getElementByAttributeId(e,t){var r=e===null||e===void 0?void 0:e.getAttribute(t);return r&&document.getElementById(r)||null}function hasLabel(e,t){return e.contains(t)}function setRequestedIcon(e,t,r){if(typeof t==="string"&&t!==""){return t}else if(t===""){return e[r]}}export{getElementTheme as a,getElementProp as b,getSlotted as c,getElementByAttributeId as d,filterDirectChildren as e,focusElement as f,getElementDir as g,hasLabel as h,nodeListToArray as n,setRequestedIcon as s};