UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1 lines 4.84 kB
var __awaiter=this&&this.__awaiter||function(e,t,r,n){function o(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,u){function i(e){try{l(n.next(e))}catch(t){u(t)}}function a(e){try{l(n["throw"](e))}catch(t){u(t)}}function l(e){e.done?r(e.value):o(e.value).then(i,a)}l((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,o,u,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return l([e,t])}}function l(i){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,o&&(u=i[0]&2?o["return"]:i[0]?o["throw"]||((u=o["return"])&&u.call(o),0):o.next)&&!(u=u.call(o,i[1])).done)return u;if(o=0,u)i=[i[0]&2,u.value];switch(i[0]){case 0:case 1:u=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;o=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!u||i[1]>u[0]&&i[1]<u[3])){r.label=i[1];break}if(i[0]===6&&r.label<u[1]){r.label=u[1];u=i;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(i);break}if(u[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(a){i=[6,a];o=0}finally{n=u=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e};import{g as guid}from"./guid-09142681.js";var CSS_UTILITY={autoTheme:"calcite-theme-auto",darkTheme:"calcite-theme-dark",lightTheme:"calcite-theme-light",rtl:"calcite--rtl"};function ensureId(e){if(!e){return""}return e.id=e.id||e.tagName.toLowerCase()+"-"+guid()}function nodeListToArray(e){return Array.isArray(e)?e:Array.from(e)}function getAttributes(e,t){return Array.from(e.attributes).filter((function(e){return e&&!t.includes(e.name)})).reduce((function(e,t){var r;var n=t.name,o=t.value;return Object.assign(Object.assign({},e),(r={},r[n]=o,r))}),{})}function getThemeName(e){return closestElementCrossShadowBoundary("."+CSS_UTILITY.darkTheme,e)?"dark":"light"}function getElementDir(e){return getElementProp(e,"dir","ltr",true)}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 getRootNode(e){return e.getRootNode()}function getHost(e){return e.host||null}function queryElementsRoots(e,t){function r(e,n){if(!e){return n}if(e.assignedSlot){e=e.assignedSlot}var o=getRootNode(e);var u=Array.from(o.querySelectorAll(t));var i=u.filter((function(e){return!n.includes(e)}));n=__spreadArray(__spreadArray([],n),i);var a=getHost(o);return a?r(a,n):n}return r(e,[])}function queryElementRoots(e,t){function r(e){if(!e){return null}if(e.assignedSlot){e=e.assignedSlot}var n=getRootNode(e);var o=n.querySelector(t);var u=getHost(n);return o?o:u?r(u):null}return r(e)}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 isCalciteFocusable(e){return typeof(e===null||e===void 0?void 0:e.setFocus)==="function"}function focusElement(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!e){return[2]}return[2,isCalciteFocusable(e)?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 __spreadArray(__spreadArray([],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 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{CSS_UTILITY as C,getThemeName as a,getSlotted as b,getElementProp as c,getAttributes as d,ensureId as e,focusElement as f,getElementDir as g,hasLabel as h,isCalciteFocusable as i,queryElementsRoots as j,filterDirectChildren as k,nodeListToArray as n,queryElementRoots as q,setRequestedIcon as s};