Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cdn.min.js « dist « focus « packages « alpinejs - github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 781dfb81384ab4091f1ebfe4b723e2e9a9976bf0 (plain)
1
2
3
4
5
6
7
8
9
(()=>{var j=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],_=j.join(","),A=typeof Element=="undefined"?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,G=function(e,t,n){var u=Array.prototype.slice.apply(e.querySelectorAll(_));return t&&A.call(e,_)&&u.unshift(e),u=u.filter(n),u},Z=function(e){return e.contentEditable==="true"},M=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?Z(e)||(e.nodeName==="AUDIO"||e.nodeName==="VIDEO"||e.nodeName==="DETAILS")&&e.getAttribute("tabindex")===null?0:e.tabIndex:t},$=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},C=function(e){return e.tagName==="INPUT"},ee=function(e){return C(e)&&e.type==="hidden"},te=function(e){var t=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return t},re=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]},ae=function(e){if(!e.name)return!0;var t=e.form||e.ownerDocument,n=function(l){return t.querySelectorAll('input[type="radio"][name="'+l+'"]')},u;if(typeof window!="undefined"&&typeof window.CSS!="undefined"&&typeof window.CSS.escape=="function")u=n(window.CSS.escape(e.name));else try{u=n(e.name)}catch(s){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",s.message),!1}var r=re(u,e.form);return!r||r===e},ne=function(e){return C(e)&&e.type==="radio"},ie=function(e){return ne(e)&&!ae(e)},ue=function(e,t){if(getComputedStyle(e).visibility==="hidden")return!0;var n=A.call(e,"details>summary:first-of-type"),u=n?e.parentElement:e;if(A.call(u,"details:not([open]) *"))return!0;if(!t||t==="full")for(;e;){if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}else if(t==="non-zero-area"){var r=e.getBoundingClientRect(),s=r.width,l=r.height;return s===0&&l===0}return!1},oe=function(e){if(C(e)||e.tagName==="SELECT"||e.tagName==="TEXTAREA"||e.tagName==="BUTTON")for(var t=e.parentElement;t;){if(t.tagName==="FIELDSET"&&t.disabled){for(var n=0;n<t.children.length;n++){var u=t.children.item(n);if(u.tagName==="LEGEND")return!u.contains(e)}return!0}t=t.parentElement}return!1},O=function(e,t){return!(t.disabled||ee(t)||ue(t,e.displayCheck)||te(t)||oe(t))},se=function(e,t){return!(!O(e,t)||ie(t)||M(t)<0)},W=function(e,t){t=t||{};var n=[],u=[],r=G(e,t.includeContainer,se.bind(null,t));r.forEach(function(l,h){var b=M(l);b===0?n.push(l):u.push({documentOrder:h,tabIndex:b,node:l})});var s=u.sort($).map(function(l){return l.node}).concat(n);return s},q=function(e,t){t=t||{};var n=G(e,t.includeContainer,O.bind(null,t));return n};var ce=j.concat("iframe").join(","),k=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return A.call(e,ce)===!1?!1:O(t,e)};function B(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(u){return Object.getOwnPropertyDescriptor(i,u).enumerable})),t.push.apply(t,n)}return t}function fe(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?B(Object(t),!0).forEach(function(n){le(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):B(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function le(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}var H=function(){var i=[];return{activateTrap:function(t){if(i.length>0){var n=i[i.length-1];n!==t&&n.pause()}var u=i.indexOf(t);u===-1||i.splice(u,1),i.push(t)},deactivateTrap:function(t){var n=i.indexOf(t);n!==-1&&i.splice(n,1),i.length>0&&i[i.length-1].unpause()}}}(),de=function(e){return e.tagName&&e.tagName.toLowerCase()==="input"&&typeof e.select=="function"},be=function(e){return e.key==="Escape"||e.key==="Esc"||e.keyCode===27},ve=function(e){return e.key==="Tab"||e.keyCode===9},U=function(e){return setTimeout(e,0)},L=function(e,t){var n=-1;return e.every(function(u,r){return t(u)?(n=r,!1):!0}),n},D=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),u=1;u<t;u++)n[u-1]=arguments[u];return typeof e=="function"?e.apply(void 0,n):e},K=function(e,t){var n=document,u=fe({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),r={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},s,l=function(a,o,c){return a&&a[o]!==void 0?a[o]:u[c||o]},h=function(a){return r.containers.some(function(o){return o.contains(a)})},b=function(a){var o=u[a];if(!o)return null;var c=o;if(typeof o=="string"&&(c=n.querySelector(o),!c))throw new Error("`".concat(a,"` refers to no known node"));if(typeof o=="function"&&(c=o(),!c))throw new Error("`".concat(a,"` did not return a node"));return c},v=function(){var a;if(l({},"initialFocus")===!1)return!1;if(b("initialFocus")!==null)a=b("initialFocus");else if(h(n.activeElement))a=n.activeElement;else{var o=r.tabbableGroups[0],c=o&&o.firstTabbableNode;a=c||b("fallbackFocus")}if(!a)throw new Error("Your focus-trap needs to have at least one focusable element");return a},m=function(){if(r.tabbableGroups=r.containers.map(function(a){var o=W(a);if(o.length>0)return{container:a,firstTabbableNode:o[0],lastTabbableNode:o[o.length-1]}}).filter(function(a){return!!a}),r.tabbableGroups.length<=0&&!b("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},p=function f(a){if(a!==!1&&a!==n.activeElement){if(!a||!a.focus){f(v());return}a.focus({preventScroll:!!u.preventScroll}),r.mostRecentlyFocusedNode=a,de(a)&&a.select()}},E=function(a){var o=b("setReturnFocus");return o||a},y=function(a){if(!h(a.target)){if(D(u.clickOutsideDeactivates,a)){s.deactivate({returnFocus:u.returnFocusOnDeactivate&&!k(a.target)});return}D(u.allowOutsideClick,a)||a.preventDefault()}},w=function(a){var o=h(a.target);o||a.target instanceof Document?o&&(r.mostRecentlyFocusedNode=a.target):(a.stopImmediatePropagation(),p(r.mostRecentlyFocusedNode||v()))},Q=function(a){m();var o=null;if(r.tabbableGroups.length>0){var c=L(r.tabbableGroups,function(N){var S=N.container;return S.contains(a.target)});if(c<0)a.shiftKey?o=r.tabbableGroups[r.tabbableGroups.length-1].lastTabbableNode:o=r.tabbableGroups[0].firstTabbableNode;else if(a.shiftKey){var d=L(r.tabbableGroups,function(N){var S=N.firstTabbableNode;return a.target===S});if(d<0&&r.tabbableGroups[c].container===a.target&&(d=c),d>=0){var g=d===0?r.tabbableGroups.length-1:d-1,F=r.tabbableGroups[g];o=F.lastTabbableNode}}else{var T=L(r.tabbableGroups,function(N){var S=N.lastTabbableNode;return a.target===S});if(T<0&&r.tabbableGroups[c].container===a.target&&(T=c),T>=0){var X=T===r.tabbableGroups.length-1?0:T+1,J=r.tabbableGroups[X];o=J.firstTabbableNode}}}else o=b("fallbackFocus");o&&(a.preventDefault(),p(o))},R=function(a){if(be(a)&&D(u.escapeDeactivates)!==!1){a.preventDefault(),s.deactivate();return}if(ve(a)){Q(a);return}},x=function(a){D(u.clickOutsideDeactivates,a)||h(a.target)||D(u.allowOutsideClick,a)||(a.preventDefault(),a.stopImmediatePropagation())},I=function(){if(!!r.active)return H.activateTrap(s),r.delayInitialFocusTimer=u.delayInitialFocus?U(function(){p(v())}):p(v()),n.addEventListener("focusin",w,!0),n.addEventListener("mousedown",y,{capture:!0,passive:!1}),n.addEventListener("touchstart",y,{capture:!0,passive:!1}),n.addEventListener("click",x,{capture:!0,passive:!1}),n.addEventListener("keydown",R,{capture:!0,passive:!1}),s},P=function(){if(!!r.active)return n.removeEventListener("focusin",w,!0),n.removeEventListener("mousedown",y,!0),n.removeEventListener("touchstart",y,!0),n.removeEventListener("click",x,!0),n.removeEventListener("keydown",R,!0),s};return s={activate:function(a){if(r.active)return this;var o=l(a,"onActivate"),c=l(a,"onPostActivate"),d=l(a,"checkCanFocusTrap");d||m(),r.active=!0,r.paused=!1,r.nodeFocusedBeforeActivation=n.activeElement,o&&o();var g=function(){d&&m(),I(),c&&c()};return d?(d(r.containers.concat()).then(g,g),this):(g(),this)},deactivate:function(a){if(!r.active)return this;clearTimeout(r.delayInitialFocusTimer),r.delayInitialFocusTimer=void 0,P(),r.active=!1,r.paused=!1,H.deactivateTrap(s);var o=l(a,"onDeactivate"),c=l(a,"onPostDeactivate"),d=l(a,"checkCanReturnFocus");o&&o();var g=l(a,"returnFocus","returnFocusOnDeactivate"),F=function(){U(function(){g&&p(E(r.nodeFocusedBeforeActivation)),c&&c()})};return g&&d?(d(E(r.nodeFocusedBeforeActivation)).then(F,F),this):(F(),this)},pause:function(){return r.paused||!r.active?this:(r.paused=!0,P(),this)},unpause:function(){return!r.paused||!r.active?this:(r.paused=!1,m(),I(),this)},updateContainerElements:function(a){var o=[].concat(a).filter(Boolean);return r.containers=o.map(function(c){return typeof c=="string"?n.querySelector(c):c}),r.active&&m(),this}},s.updateContainerElements(e),s};function Y(i){let e,t;window.addEventListener("focusin",()=>{e=t,t=document.activeElement}),i.magic("focus",n=>{let u=n;return{__noscroll:!1,__wrapAround:!1,within(r){return u=r,this},withoutScrolling(){return this.__noscroll=!0,this},noscroll(){return this.__noscroll=!0,this},withWrapAround(){return this.__wrapAround=!0,this},wrap(){return this.withWrapAround()},focusable(r){return k(r)},previouslyFocused(){return e},lastFocused(){return e},focused(){return t},focusables(){return Array.isArray(u)?u:q(u,{displayCheck:"none"})},all(){return this.focusables()},isFirst(r){let s=this.all();return s[0]&&s[0].isSameNode(r)},isLast(r){let s=this.all();return s.length&&s.slice(-1)[0].isSameNode(r)},getFirst(){return this.all()[0]},getLast(){return this.all().slice(-1)[0]},getNext(){let r=this.all(),s=document.activeElement;if(r.indexOf(s)!==-1)return this.__wrapAround&&r.indexOf(s)===r.length-1?r[0]:r[r.indexOf(s)+1]},getPrevious(){let r=this.all(),s=document.activeElement;if(r.indexOf(s)!==-1)return this.__wrapAround&&r.indexOf(s)===0?r.slice(-1)[0]:r[r.indexOf(s)-1]},first(){this.focus(this.getFirst())},last(){this.focus(this.getLast())},next(){this.focus(this.getNext())},previous(){this.focus(this.getPrevious())},prev(){return this.previous()},focus(r){!r||setTimeout(()=>{r.hasAttribute("tabindex")||r.setAttribute("tabindex","0"),r.focus({preventScroll:this._noscroll})})}}}),i.directive("trap",i.skipDuringClone((n,{expression:u,modifiers:r},{effect:s,evaluateLater:l,cleanup:h})=>{let b=l(u),v=!1,m=K(n,{escapeDeactivates:!1,allowOutsideClick:!0,fallbackFocus:()=>n}),p=()=>{},E=()=>{},y=()=>{p(),p=()=>{},E(),E=()=>{},m.deactivate({returnFocus:!r.includes("noreturn")})};s(()=>b(w=>{v!==w&&(w&&!v&&setTimeout(()=>{r.includes("inert")&&(p=V(n)),r.includes("noscroll")&&(E=pe()),m.activate()}),!w&&v&&y(),v=!!w)})),h(y)},(n,{expression:u,modifiers:r},{evaluate:s})=>{r.includes("inert")&&s(u)&&V(n)}))}function V(i){let e=[];return z(i,t=>{let n=t.hasAttribute("aria-hidden");t.setAttribute("aria-hidden","true"),e.push(()=>n||t.removeAttribute("aria-hidden"))}),()=>{for(;e.length;)e.pop()()}}function z(i,e){i.isSameNode(document.body)||!i.parentNode||Array.from(i.parentNode.children).forEach(t=>{t.isSameNode(i)||e(t),z(i.parentNode,e)})}function pe(){let i=document.documentElement.style.overflow,e=document.documentElement.style.paddingRight,t=window.innerWidth-document.documentElement.clientWidth;return document.documentElement.style.overflow="hidden",document.documentElement.style.paddingRight=`${t}px`,()=>{document.documentElement.style.overflow=i,document.documentElement.style.paddingRight=e}}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(Y)});})();
/*!
* focus-trap 6.6.1
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
/*!
* tabbable 5.2.1
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/