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: ae219c8ef90320ee6ce128ce82ebbc4188eea624 (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,Q=function(e,t,a){var c=Array.prototype.slice.apply(e.querySelectorAll(x));return t&&S.call(e,x)&&c.unshift(e),c=c.filter(a),c},X=function(e){return e.contentEditable==="true"},j=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?X(e)||(e.nodeName==="AUDIO"||e.nodeName==="VIDEO"||e.nodeName==="DETAILS")&&e.getAttribute("tabindex")===null?0:e.tabIndex:t},J=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},D=function(e){return e.tagName==="INPUT"},Z=function(e){return D(e)&&e.type==="hidden"},$=function(e){var t=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(a){return a.tagName==="SUMMARY"});return t},_=function(e,t){for(var a=0;a<e.length;a++)if(e[a].checked&&e[a].form===t)return e[a]},ee=function(e){if(!e.name)return!0;var t=e.form||e.ownerDocument,a=function(l){return t.querySelectorAll('input[type="radio"][name="'+l+'"]')},c;if(typeof window!="undefined"&&typeof window.CSS!="undefined"&&typeof window.CSS.escape=="function")c=a(window.CSS.escape(e.name));else try{c=a(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 n=_(c,e.form);return!n||n===e},te=function(e){return D(e)&&e.type==="radio"},re=function(e){return te(e)&&!ee(e)},ae=function(e,t){if(getComputedStyle(e).visibility==="hidden")return!0;var a=S.call(e,"details>summary:first-of-type"),c=a?e.parentElement:e;if(S.call(c,"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 n=e.getBoundingClientRect(),s=n.width,l=n.height;return s===0&&l===0}return!1},ne=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 c=t.children.item(a);if(c.tagName==="LEGEND")return!c.contains(e)}return!0}t=t.parentElement}return!1},G=function(e,t){return!(t.disabled||Z(t)||ae(t,e.displayCheck)||$(t)||ne(t))},ie=function(e,t){return!(!G(e,t)||re(t)||j(t)<0)},M=function(e,t){t=t||{};var a=[],c=[],n=Q(e,t.includeContainer,ie.bind(null,t));n.forEach(function(l,v){var d=j(l);d===0?a.push(l):c.push({documentOrder:v,tabIndex:d,node:l})});var s=c.sort(J).map(function(l){return l.node}).concat(a);return s};var ue=P.concat("iframe").join(","),q=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return S.call(e,ue)===!1?!1:G(t,e)};function B(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(i);e&&(a=a.filter(function(c){return Object.getOwnPropertyDescriptor(i,c).enumerable})),t.push.apply(t,a)}return t}function oe(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?B(Object(t),!0).forEach(function(a){ce(i,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):B(Object(t)).forEach(function(a){Object.defineProperty(i,a,Object.getOwnPropertyDescriptor(t,a))})}return i}function ce(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 a=i[i.length-1];a!==t&&a.pause()}var c=i.indexOf(t);c===-1||i.splice(c,1),i.push(t)},deactivateTrap:function(t){var a=i.indexOf(t);a!==-1&&i.splice(a,1),i.length>0&&i[i.length-1].unpause()}}}(),se=function(e){return e.tagName&&e.tagName.toLowerCase()==="input"&&typeof e.select=="function"},le=function(e){return e.key==="Escape"||e.key==="Esc"||e.keyCode===27},fe=function(e){return e.key==="Tab"||e.keyCode===9},K=function(e){return setTimeout(e,0)},k=function(e,t){var a=-1;return e.every(function(c,n){return t(c)?(a=n,!1):!0}),a},F=function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),c=1;c<t;c++)a[c-1]=arguments[c];return typeof e=="function"?e.apply(void 0,a):e},U=function(e,t){var a=document,c=oe({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),n={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},s,l=function(r,u,o){return r&&r[u]!==void 0?r[u]:c[o||u]},v=function(r){return n.containers.some(function(u){return u.contains(r)})},d=function(r){var u=c[r];if(!u)return null;var o=u;if(typeof u=="string"&&(o=a.querySelector(u),!o))throw new Error("`".concat(r,"` refers to no known node"));if(typeof u=="function"&&(o=u(),!o))throw new Error("`".concat(r,"` did not return a node"));return o},w=function(){var r;if(l({},"initialFocus")===!1)return!1;if(d("initialFocus")!==null)r=d("initialFocus");else if(v(a.activeElement))r=a.activeElement;else{var u=n.tabbableGroups[0],o=u&&u.firstTabbableNode;r=o||d("fallbackFocus")}if(!r)throw new Error("Your focus-trap needs to have at least one focusable element");return r},g=function(){if(n.tabbableGroups=n.containers.map(function(r){var u=M(r);if(u.length>0)return{container:r,firstTabbableNode:u[0],lastTabbableNode:u[u.length-1]}}).filter(function(r){return!!r}),n.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")},y=function f(r){if(r!==!1&&r!==a.activeElement){if(!r||!r.focus){f(w());return}r.focus({preventScroll:!!c.preventScroll}),n.mostRecentlyFocusedNode=r,se(r)&&r.select()}},C=function(r){var u=d("setReturnFocus");return u||r},N=function(r){if(!v(r.target)){if(F(c.clickOutsideDeactivates,r)){s.deactivate({returnFocus:c.returnFocusOnDeactivate&&!q(r.target)});return}F(c.allowOutsideClick,r)||r.preventDefault()}},A=function(r){var u=v(r.target);u||r.target instanceof Document?u&&(n.mostRecentlyFocusedNode=r.target):(r.stopImmediatePropagation(),y(n.mostRecentlyFocusedNode||w()))},Y=function(r){g();var u=null;if(n.tabbableGroups.length>0){var o=k(n.tabbableGroups,function(T){var E=T.container;return E.contains(r.target)});if(o<0)r.shiftKey?u=n.tabbableGroups[n.tabbableGroups.length-1].lastTabbableNode:u=n.tabbableGroups[0].firstTabbableNode;else if(r.shiftKey){var b=k(n.tabbableGroups,function(T){var E=T.firstTabbableNode;return r.target===E});if(b<0&&n.tabbableGroups[o].container===r.target&&(b=o),b>=0){var p=b===0?n.tabbableGroups.length-1:b-1,m=n.tabbableGroups[p];u=m.lastTabbableNode}}else{var h=k(n.tabbableGroups,function(T){var E=T.lastTabbableNode;return r.target===E});if(h<0&&n.tabbableGroups[o].container===r.target&&(h=o),h>=0){var W=h===n.tabbableGroups.length-1?0:h+1,z=n.tabbableGroups[W];u=z.firstTabbableNode}}}else u=d("fallbackFocus");u&&(r.preventDefault(),y(u))},O=function(r){if(le(r)&&F(c.escapeDeactivates)!==!1){r.preventDefault(),s.deactivate();return}if(fe(r)){Y(r);return}},I=function(r){F(c.clickOutsideDeactivates,r)||v(r.target)||F(c.allowOutsideClick,r)||(r.preventDefault(),r.stopImmediatePropagation())},L=function(){if(!!n.active)return H.activateTrap(s),n.delayInitialFocusTimer=c.delayInitialFocus?K(function(){y(w())}):y(w()),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",O,{capture:!0,passive:!1}),s},R=function(){if(!!n.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",O,!0),s};return s={activate:function(r){if(n.active)return this;var u=l(r,"onActivate"),o=l(r,"onPostActivate"),b=l(r,"checkCanFocusTrap");b||g(),n.active=!0,n.paused=!1,n.nodeFocusedBeforeActivation=a.activeElement,u&&u();var p=function(){b&&g(),L(),o&&o()};return b?(b(n.containers.concat()).then(p,p),this):(p(),this)},deactivate:function(r){if(!n.active)return this;clearTimeout(n.delayInitialFocusTimer),n.delayInitialFocusTimer=void 0,R(),n.active=!1,n.paused=!1,H.deactivateTrap(s);var u=l(r,"onDeactivate"),o=l(r,"onPostDeactivate"),b=l(r,"checkCanReturnFocus");u&&u();var p=l(r,"returnFocus","returnFocusOnDeactivate"),m=function(){K(function(){p&&y(C(n.nodeFocusedBeforeActivation)),o&&o()})};return p&&b?(b(C(n.nodeFocusedBeforeActivation)).then(m,m),this):(m(),this)},pause:function(){return n.paused||!n.active?this:(n.paused=!0,R(),this)},unpause:function(){return!n.paused||!n.active?this:(n.paused=!1,g(),L(),this)},updateContainerElements:function(r){var u=[].concat(r).filter(Boolean);return n.containers=u.map(function(o){return typeof o=="string"?a.querySelector(o):o}),n.active&&g(),this}},s.updateContainerElements(e),s};function V(i){i.directive("trap",(e,{expression:t},{effect:a,evaluateLater:c})=>{let n=c(t),s=!1,l=U(e,{escapeDeactivates:!1,allowOutsideClick:!0});a(()=>n(v=>{s!==v&&(v&&!s&&setTimeout(()=>{l.activate()}),!v&&s&&l.deactivate(),s=!!v)}))})}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
*/