7 lines
5.8 KiB
JavaScript
7 lines
5.8 KiB
JavaScript
/*!
|
|
* tabbable 6.3.0
|
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
*/
|
|
var t=["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=t.join(","),n="undefined"==typeof Element,r=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},i=function(t,e){var n;void 0===e&&(e=!0);var r=null==t||null===(n=t.getAttribute)||void 0===n?void 0:n.call(t,"inert");return""===r||"true"===r||e&&t&&i(t.parentNode)},a=function(t,n,o){if(i(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&r.call(t,e)&&a.unshift(t),a=a.filter(o)},l=function(t,n,o){for(var a=[],u=Array.from(t);u.length;){var c=u.shift();if(!i(c,!1))if("SLOT"===c.tagName){var d=c.assignedElements(),f=d.length?d:c.children,s=l(f,!0,o);o.flatten?a.push.apply(a,s):a.push({scopeParent:c,candidates:s})}else{r.call(c,e)&&o.filter(c)&&(n||!t.includes(c))&&a.push(c);var p=c.shadowRoot||"function"==typeof o.getShadowRoot&&o.getShadowRoot(c),h=!i(p,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(c));if(p&&h){var v=l(!0===p?c.children:p.children,!0,o);o.flatten?a.push.apply(a,v):a.push({scopeParent:c,candidates:v})}else u.unshift.apply(u,c.children)}}return a},u=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},c=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!u(t)?0:t.tabIndex},d=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},f=function(t){return"INPUT"===t.tagName},s=function(t){return function(t){return f(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||o(t),r=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=r(window.CSS.escape(t.name));else try{e=r(t.name)}catch(t){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",t.message),!1}var i=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!i||i===t}(t)},p=function(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height;return 0===n&&0===r},h=function(t,e){var n=e.displayCheck,i=e.getShadowRoot;if("full-native"===n&&"checkVisibility"in t)return!t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===getComputedStyle(t).visibility)return!0;var a=r.call(t,"details>summary:first-of-type")?t.parentElement:t;if(r.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"full-native"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return p(t)}else{if("function"==typeof i){for(var l=t;t;){var u=t.parentElement,c=o(t);if(u&&!u.shadowRoot&&!0===i(u))return p(t);t=t.assignedSlot?t.assignedSlot:u||c===t.ownerDocument?u:c.host}t=l}if(function(t){var e,n,r,i,a=t&&o(t),l=null===(e=a)||void 0===e?void 0:e.host,u=!1;if(a&&a!==t)for(u=!!(null!==(n=l)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(l)||null!=t&&null!==(i=t.ownerDocument)&&void 0!==i&&i.contains(t));!u&&l;){var c,d,f;u=!(null===(d=l=null===(c=a=o(l))||void 0===c?void 0:c.host)||void 0===d||null===(f=d.ownerDocument)||void 0===f||!f.contains(l))}return u}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},v=function(t,e){return!(e.disabled||i(e)||function(t){return f(t)&&"hidden"===t.type}(e)||h(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!r.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},m=function(t,e){return!(s(e)||c(e)<0||!v(t,e))},y=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},g=function(t){var e=[],n=[];return t.forEach((function(t,r){var o=!!t.scopeParent,i=o?t.scopeParent:t,a=function(t,e){var n=c(t);return n<0&&e&&!u(t)?0:n}(i,o),l=o?g(t.candidates):i;0===a?o?e.push.apply(e,l):e.push(i):n.push({documentOrder:r,tabIndex:a,item:t,isScope:o,content:l})})),n.sort(d).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(e)},w=function(t,e){var n;return n=(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:m.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:y}):a(t,e.includeContainer,m.bind(null,e)),g(n)},S=function(t,e){return(e=e||{}).getShadowRoot?l([t],e.includeContainer,{filter:v.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):a(t,e.includeContainer,v.bind(null,e))},b=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return!1!==r.call(t,e)&&m(n,t)},E=t.concat("iframe").join(","),N=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==r.call(t,E)&&v(e,t)};export{S as focusable,c as getTabIndex,N as isFocusable,b as isTabbable,w as tabbable};
|
|
//# sourceMappingURL=index.esm.min.js.map
|