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

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