@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
11 lines • 8.56 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{g as n}from"./p-d2aa9245.js";import{C as t}from"./p-9280476e.js";
/*!
* tabbable 6.1.2
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var r=["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])"],e=r.join(","),o="undefined"==typeof Element,u=o?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,i=!o&&Element.prototype.getRootNode?function(n){var t;return null==n||null===(t=n.getRootNode)||void 0===t?void 0:t.call(n)}:function(n){return null==n?void 0:n.ownerDocument},a=function n(t,r){var e;void 0===r&&(r=!0);var o=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"inert");return""===o||"true"===o||r&&t&&n(t.parentNode)},f=function(n,t,r){if(a(n))return[];var o=Array.prototype.slice.apply(n.querySelectorAll(e));return t&&u.call(n,e)&&o.unshift(n),o.filter(r)},l=function n(t,r,o){for(var i=[],f=Array.from(t);f.length;){var l=f.shift();if(!a(l,!1))if("SLOT"===l.tagName){var c=l.assignedElements(),s=n(c.length?c:l.children,!0,o);o.flatten?i.push.apply(i,s):i.push({scopeParent:l,candidates:s})}else{u.call(l,e)&&o.filter(l)&&(r||!t.includes(l))&&i.push(l);var d=l.shadowRoot||"function"==typeof o.getShadowRoot&&o.getShadowRoot(l),v=!a(d,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(l));if(d&&v){var p=n(!0===d?l.children:d.children,!0,o);o.flatten?i.push.apply(i,p):i.push({scopeParent:l,candidates:p})}else f.unshift.apply(f,l.children)}}return i},c=function(n,t){return n.tabIndex<0&&(t||/^(AUDIO|VIDEO|DETAILS)$/.test(n.tagName)||function(n){var t,r=null==n||null===(t=n.getAttribute)||void 0===t?void 0:t.call(n,"contenteditable");return""===r||"true"===r}(n))&&isNaN(parseInt(n.getAttribute("tabindex"),10))?0:n.tabIndex},s=function(n,t){return n.tabIndex===t.tabIndex?n.documentOrder-t.documentOrder:n.tabIndex-t.tabIndex},d=function(n){return"INPUT"===n.tagName},v=function(n){var t=n.getBoundingClientRect();return 0===t.width&&0===t.height},p=function(n,t){return!(t.disabled||a(t)||function(n){return d(n)&&"hidden"===n.type}(t)||function(n,t){var r=t.displayCheck,e=t.getShadowRoot;if("hidden"===getComputedStyle(n).visibility)return!0;var o=u.call(n,"details>summary:first-of-type");if(u.call(o?n.parentElement:n,"details:not([open]) *"))return!0;if(r&&"full"!==r&&"legacy-full"!==r){if("non-zero-area"===r)return v(n)}else{if("function"==typeof e){for(var a=n;n;){var f=n.parentElement,l=i(n);if(f&&!f.shadowRoot&&!0===e(f))return v(n);n=n.assignedSlot?n.assignedSlot:f||l===n.ownerDocument?f:l.host}n=a}if(function(n){var t,r,e,o,u=n&&i(n),a=null===(t=u)||void 0===t?void 0:t.host,f=!1;if(u&&u!==n)for(f=!!(null!==(r=a)&&void 0!==r&&null!==(e=r.ownerDocument)&&void 0!==e&&e.contains(a)||null!=n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(n));!f&&a;){var l,c,s;f=!(null===(c=a=null===(l=u=i(a))||void 0===l?void 0:l.host)||void 0===c||null===(s=c.ownerDocument)||void 0===s||!s.contains(a))}return f}(n))return!n.getClientRects().length;if("legacy-full"!==r)return!0}return!1}(t,n)||function(n){return"DETAILS"===n.tagName&&Array.prototype.slice.apply(n.children).some((function(n){return"SUMMARY"===n.tagName}))}(t)||function(n){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(n.tagName))for(var t=n.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var r=0;r<t.children.length;r++){var e=t.children.item(r);if("LEGEND"===e.tagName)return!!u.call(t,"fieldset[disabled] *")||!e.contains(n)}return!0}t=t.parentElement}return!1}(t))},y=function(n,t){return!(function(n){return function(n){return d(n)&&"radio"===n.type}(n)&&!function(n){if(!n.name)return!0;var t,r=n.form||i(n),e=function(n){return r.querySelectorAll('input[type="radio"][name="'+n+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=e(window.CSS.escape(n.name));else try{t=e(n.name)}catch(n){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",n.message),!1}var o=function(n,t){for(var r=0;r<n.length;r++)if(n[r].checked&&n[r].form===t)return n[r]}(t,n.form);return!o||o===n}(n)}(t)||c(t)<0||!p(n,t))},m=function(n){var t=parseInt(n.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},w=function n(t){var r=[],e=[];return t.forEach((function(t,o){var u=!!t.scopeParent,i=u?t.scopeParent:t,a=c(i,u),f=u?n(t.candidates):i;0===a?u?r.push.apply(r,f):r.push(i):e.push({documentOrder:o,tabIndex:a,item:t,isScope:u,content:f})})),e.sort(s).reduce((function(n,t){return t.isScope?n.push.apply(n,t.content):n.push(t.content),n}),[]).concat(r)},E=function(n,t){var r;return r=(t=t||{}).getShadowRoot?l([n],t.includeContainer,{filter:y.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:m}):f(n,t.includeContainer,y.bind(null,t)),w(r)},h=function(n,t){return(t=t||{}).getShadowRoot?l([n],t.includeContainer,{filter:p.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):f(n,t.includeContainer,p.bind(null,t))},A=function(n,t){if(t=t||{},!n)throw new Error("No node provided");return!1!==u.call(n,e)&&y(t,n)},S=r.concat("iframe").join(","),g=function(n,t){if(t=t||{},!n)throw new Error("No node provided");return!1!==u.call(n,S)&&p(t,n)};const b={getShadowRoot:!0};function I(t){return t?t.id=t.id||`${t.tagName.toLowerCase()}-${n()}`:""}function N(n){return Array.isArray(n)?n:Array.from(n)}function T(n){return C(n,`.${t.darkMode}, .${t.lightMode}`)?.classList.contains("calcite-mode-dark")?"dark":"light"}function x(n){const t=C(n,"[dir]");return t?t.getAttribute("dir"):"ltr"}function $(n,t,r){const e=n.closest(`[${t}]`);return e?e.getAttribute(t):r}function L(n){return n.getRootNode()}function R(n){const t=L(n);return"host"in t?t:null}function D(n){return n.host||null}function k(n,{selector:t,id:r}){return function n(e){if(!e)return null;e.assignedSlot&&(e=e.assignedSlot);const o=L(e),u=r?"getElementById"in o?o.getElementById(r):null:t?o.querySelector(t):null,i=D(o);return u||(i?n(i):null)}(n)}function C(n,t){return function n(r){return r?r.closest(t)||n(D(L(r))):null}(n)}function O(n,t){return U(n,t)}function U(n,t){if(!n)return;const r=t(n);if(void 0!==r)return r;const{parentNode:e}=n;return U(e instanceof ShadowRoot?e.host:e,t)}function P(n,t){return!!O(t,(t=>t===n||void 0))}async function j(n){if(n)return function(n){return"function"==typeof n?.setFocus}(n)?n.setFocus():n.focus()}function B(n){n&&(E(n,b)[0]||n).focus()}const z=":not([slot])";function F(n,t,r){t&&!Array.isArray(t)&&"string"!=typeof t&&(r=t,t=null);const e=t?Array.isArray(t)?t.map((n=>`[slot="${n}"]`)).join(","):`[slot="${t}"]`:z;return r?.all?function(n,t,r){let e=t===z?M(n,z):Array.from(n.querySelectorAll(t));e=r&&!1===r.direct?e:e.filter((t=>t.parentElement===n)),e=r?.matches?e.filter((n=>n?.matches(r.matches))):e;const o=r?.selector;return o?e.map((n=>Array.from(n.querySelectorAll(o)))).reduce(((n,t)=>[...n,...t]),[]).filter((n=>!!n)):e}(n,e,r):function(n,t,r){let e=t===z?M(n,z)[0]||null:n.querySelector(t);e=r&&!1===r.direct||e?.parentElement===n?e:null,e=r?.matches?e?.matches(r.matches)?e:null:e;const o=r?.selector;return o?e?.querySelector(o):e}(n,e,r)}function M(n,t){return n?Array.from(n.children||[]).filter((n=>n?.matches(t))):[]}function q(n,t){return Array.from(n.children).filter((n=>n.matches(t)))}function G(n,t,r){return"string"==typeof t&&""!==t?t:""===t?n[r]:void 0}function V(n,t){return!(t.left>n.right||t.right<n.left||t.top>n.bottom||t.bottom<n.top)}function X(n){return Boolean(n).toString()}function Y(n){return!!H(n).length}function H(n){return n.target.assignedElements({flatten:!0})}function J(n){return!(!n.isPrimary||0!==n.button)}const K=(n,t,r,e=!0)=>{const o=n.indexOf(t);let u;return e&&(r="previous"===r&&0===o?"last":"next"===r&&o===n.length-1?"first":r),u="previous"===r?n[o-1]||n[e?n.length-1:o]:"next"===r?n[o+1]||n[e?0:o]:"last"===r?n[n.length-1]:n[0],j(u),u};export{P as a,x as b,C as c,Y as d,G as e,j as f,F as g,T as h,J as i,K as j,E as k,h as l,A as m,g as n,b as o,B as p,k as q,I as r,H as s,X as t,R as u,$ as v,V as w,N as x,L as y,q as z}