UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

5 lines (4 loc) • 8.91 kB
/*! All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://github.com/Esri/calcite-design-system/blob/dev/LICENSE.md for details. v3.2.1 */ import{a as T}from"./NNVH7JUI.js";import{K as h}from"./BJZTU5BQ.js";var O=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],b=O.join(","),N=typeof Element>"u",d=N?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,g=!N&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},v=function e(t,r){var n;r===void 0&&(r=!0);var a=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"inert"),o=a===""||a==="true",i=o||r&&t&&e(t.parentNode);return i},k=function(t){var r,n=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"contenteditable");return n===""||n==="true"},M=function(t,r,n){if(v(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(b));return r&&d.call(t,b)&&a.unshift(t),a=a.filter(n),a},B=function e(t,r,n){for(var a=[],o=Array.from(t);o.length;){var i=o.shift();if(!v(i,!1))if(i.tagName==="SLOT"){var s=i.assignedElements(),u=s.length?s:i.children,l=e(u,!0,n);n.flatten?a.push.apply(a,l):a.push({scopeParent:i,candidates:l})}else{var f=d.call(i,b);f&&n.filter(i)&&(r||!t.includes(i))&&a.push(i);var c=i.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(i),D=!v(c,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(i));if(c&&D){var S=e(c===!0?i.children:c.children,!0,n);n.flatten?a.push.apply(a,S):a.push({scopeParent:i,candidates:S})}else o.unshift.apply(o,i.children)}}return a},I=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},A=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||k(t))&&!I(t)?0:t.tabIndex},L=function(t,r){var n=A(t);return n<0&&r&&!I(t)?0:n},P=function(t,r){return t.tabIndex===r.tabIndex?t.documentOrder-r.documentOrder:t.tabIndex-r.tabIndex},x=function(t){return t.tagName==="INPUT"},q=function(t){return x(t)&&t.type==="hidden"},W=function(t){var r=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(n){return n.tagName==="SUMMARY"});return r},$=function(t,r){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===r)return t[n]},G=function(t){if(!t.name)return!0;var r=t.form||g(t),n=function(s){return r.querySelectorAll('input[type="radio"][name="'+s+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=n(window.CSS.escape(t.name));else try{a=n(t.name)}catch(i){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",i.message),!1}var o=$(a,t.form);return!o||o===t},U=function(t){return x(t)&&t.type==="radio"},j=function(t){return U(t)&&!G(t)},z=function(t){var r,n=t&&g(t),a=(r=n)===null||r===void 0?void 0:r.host,o=!1;if(n&&n!==t){var i,s,u;for(o=!!((i=a)!==null&&i!==void 0&&(s=i.ownerDocument)!==null&&s!==void 0&&s.contains(a)||t!=null&&(u=t.ownerDocument)!==null&&u!==void 0&&u.contains(t));!o&&a;){var l,f,c;n=g(a),a=(l=n)===null||l===void 0?void 0:l.host,o=!!((f=a)!==null&&f!==void 0&&(c=f.ownerDocument)!==null&&c!==void 0&&c.contains(a))}}return o},w=function(t){var r=t.getBoundingClientRect(),n=r.width,a=r.height;return n===0&&a===0},X=function(t,r){var n=r.displayCheck,a=r.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var o=d.call(t,"details>summary:first-of-type"),i=o?t.parentElement:t;if(d.call(i,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="legacy-full"){if(typeof a=="function"){for(var s=t;t;){var u=t.parentElement,l=g(t);if(u&&!u.shadowRoot&&a(u)===!0)return w(t);t.assignedSlot?t=t.assignedSlot:!u&&l!==t.ownerDocument?t=l.host:t=u}t=s}if(z(t))return!t.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return w(t);return!1},H=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var r=t.parentElement;r;){if(r.tagName==="FIELDSET"&&r.disabled){for(var n=0;n<r.children.length;n++){var a=r.children.item(n);if(a.tagName==="LEGEND")return d.call(r,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}r=r.parentElement}return!1},V=function(t,r){return!(r.disabled||v(r)||q(r)||X(r,t)||W(r)||H(r))},E=function(t,r){return!(j(r)||A(r)<0||!V(t,r))},Y=function(t){var r=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(r)||r>=0)},Z=function e(t){var r=[],n=[];return t.forEach(function(a,o){var i=!!a.scopeParent,s=i?a.scopeParent:a,u=L(s,i),l=i?e(a.candidates):s;u===0?i?r.push.apply(r,l):r.push(s):n.push({documentOrder:o,tabIndex:u,item:a,isScope:i,content:l})}),n.sort(P).reduce(function(a,o){return o.isScope?a.push.apply(a,o.content):a.push(o.content),a},[]).concat(r)},K=function(t,r){r=r||{};var n;return r.getShadowRoot?n=B([t],r.includeContainer,{filter:E.bind(null,r),flatten:!1,getShadowRoot:r.getShadowRoot,shadowRootFilter:Y}):n=M(t,r.includeContainer,E.bind(null,r)),Z(n)},J={getShadowRoot:!0};function dt(e){return e?e.id=e.id||`${e.tagName.toLowerCase()}-${T()}`:""}function ht(e){return Array.isArray(e)?e:Array.from(e)}function gt(e){let t=m(e,`.${h.darkMode}, .${h.lightMode}, .${h.autoMode}`);return t?.classList.contains("calcite-mode-dark")||t?.classList.contains("calcite-mode-auto")&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function vt(e){let t="dir",r=`[${t}]`,n=m(e,r);return n?n.getAttribute(t):"ltr"}function bt(e){return e?parseFloat(getComputedStyle(e).inlineSize):0}function p(e){return e.getRootNode()}function yt(e){let t=p(e);return"host"in t?t:null}function pt(e,t){if(!e)return 0;let n=document.createElement("canvas").getContext("2d");return n.font=t,n.measureText(e).width}function R(e){return e.host||null}function Q(e,{selector:t,id:r}){if(!e)return null;e.assignedSlot&&(e=e.assignedSlot);let n=p(e);return(r?"getElementById"in n?n.getElementById(r):null:t?n.querySelector(t):null)||Q(R(n),{selector:t,id:r})}function m(e,t){return e?e.closest(t)||m(R(p(e)),t):null}function _(e){return typeof e?.setFocus=="function"}async function tt(e){if(e)return _(e)?e.setFocus():e.focus()}function et(e){if(e)return K(e,J)[0]??e}function mt(e){et(e)?.focus()}function St(e,t){return Array.from(e.children).filter(r=>r.matches(t))}function rt(e,t){return e.filter(r=>r.matches(t))}function Tt(e,t,r){if(typeof t=="string"&&t!=="")return t;if(t===""||t===!0)return e[r]}function wt(e,t){return!(t.left>e.right||t.right<e.left||t.top>e.bottom||t.bottom<e.top)}function Et(e){return(!!e).toString()}function Ct(e){return ot(e)||at(e)}function nt(e){return it(e).filter(t=>t.nodeType===Node.TEXT_NODE).map(t=>t.textContent).join("").trim()}function Nt(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()!==""||t.nodeType===Node.ELEMENT_NODE)return!0;return!1}function at(e){return!!nt(e)}function it(e){return e.currentTarget.assignedNodes({flatten:!0})}function ot(e){return!!st(e).length}function st(e,t){return ut(e.target,t)}function ut(e,t){let r=e.assignedElements({flatten:!0});return t?rt(r,t):r}function It(e){return!!(e.isPrimary&&e.button===0)}function At(e){return e.detail===0}var xt=(e,t,r,n=!0)=>{let a=e.indexOf(t),o=a===0,i=a===e.length-1;n&&(r=r==="previous"&&o?"last":r==="next"&&i?"first":r);let s;return r==="previous"?s=e[a-1]||e[n?e.length-1:a]:r==="next"?s=e[a+1]||e[n?0:a]:r==="last"?s=e[e.length-1]:s=e[0],tt(s),s};function Rt(e,t){if(e.parentNode!==t.parentNode)return!1;let r=Array.from(e.parentNode.children);return r.indexOf(e)<r.indexOf(t)}async function Ft(e,t,r,n){return F(e,t,"animation",r,n)}async function Dt(e,t,r,n){return F(e,t,"transition",r,n)}async function lt(e,t){await y(),e?.(),await y(),t?.()}function C(e,t,r){let n=t==="transition"?"transitionProperty":"animationName";return e.getAnimations().find(a=>a[n]===r)}async function F(e,t,r,n,a){let o=C(e,r,t);if(o||(await y(),o=C(e,r,t)),!o)return lt(n,a);n?.();try{await o.finished}catch{}finally{a?.()}}function y(){return new Promise(e=>requestAnimationFrame(()=>e()))}function Ot(e){switch(!0){case e.endsWith("px"):return parseFloat(e);case e.endsWith("vw"):return window.innerWidth/100*parseFloat(e);case e.endsWith("vh"):return window.innerHeight/100*parseFloat(e);default:return 0}}export{J as a,dt as b,ht as c,gt as d,vt as e,bt as f,p as g,yt as h,pt as i,Q as j,m as k,tt as l,et as m,mt as n,St as o,Tt as p,wt as q,Et as r,Ct as s,Nt as t,ot as u,st as v,ut as w,It as x,At as y,xt as z,Rt as A,Ft as B,Dt as C,Ot as D};