UNPKG

bootstrap-vue-next

Version:

BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.

13 lines (12 loc) 17.8 kB
"use strict";const e=require("vue"),t=require("./index-CnY1um_J.js"),n=require("./index-BInTFWT4.js"); /*! * tabbable 6.2.0 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */ var o=["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])"],r=o.join(","),a="undefined"==typeof Element,i=a?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,u=!a&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},c=function e(t,n){var o;void 0===n&&(n=!0);var r=null==t||null===(o=t.getAttribute)||void 0===o?void 0:o.call(t,"inert");return""===r||"true"===r||n&&t&&e(t.parentNode)},l=function(e,t,n){if(c(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(r));return t&&i.call(e,r)&&o.unshift(e),o=o.filter(n)},s=function e(t,n,o){for(var a=[],u=Array.from(t);u.length;){var l=u.shift();if(!c(l,!1))if("SLOT"===l.tagName){var s=l.assignedElements(),d=e(s.length?s:l.children,!0,o);o.flatten?a.push.apply(a,d):a.push({scopeParent:l,candidates:d})}else{i.call(l,r)&&o.filter(l)&&(n||!t.includes(l))&&a.push(l);var f=l.shadowRoot||"function"==typeof o.getShadowRoot&&o.getShadowRoot(l),v=!c(f,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(l));if(f&&v){var p=e(!0===f?l.children:f.children,!0,o);o.flatten?a.push.apply(a,p):a.push({scopeParent:l,candidates:p})}else u.unshift.apply(u,l.children)}}return a},d=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},f=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!d(e)?0:e.tabIndex},v=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},p=function(e){return"INPUT"===e.tagName},b=function(e){return function(e){return p(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||u(e),o=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=o(window.CSS.escape(e.name));else try{t=o(e.name)}catch(a){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",a.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},h=function(e){var t=e.getBoundingClientRect(),n=t.width,o=t.height;return 0===n&&0===o},m=function(e,t){var n=t.displayCheck,o=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var r=i.call(e,"details>summary:first-of-type")?e.parentElement:e;if(i.call(r,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(e)}else{if("function"==typeof o){for(var a=e;e;){var c=e.parentElement,l=u(e);if(c&&!c.shadowRoot&&!0===o(c))return h(e);e=e.assignedSlot?e.assignedSlot:c||l===e.ownerDocument?c:l.host}e=a}if(function(e){var t,n,o,r,a=e&&u(e),i=null===(t=a)||void 0===t?void 0:t.host,c=!1;if(a&&a!==e)for(c=!!(null!==(n=i)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(i)||null!=e&&null!==(r=e.ownerDocument)&&void 0!==r&&r.contains(e));!c&&i;){var l,s,d;c=!(null===(s=i=null===(l=a=u(i))||void 0===l?void 0:l.host)||void 0===s||null===(d=s.ownerDocument)||void 0===d||!d.contains(i))}return c}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},y=function(e,t){return!(t.disabled||c(t)||function(e){return p(e)&&"hidden"===e.type}(t)||m(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!i.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},w=function(e,t){return!(b(t)||f(t)<0||!y(e,t))},g=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},N=function e(t){var n=[],o=[];return t.forEach((function(t,r){var a=!!t.scopeParent,i=a?t.scopeParent:t,u=function(e,t){var n=f(e);return n<0&&t&&!d(e)?0:n}(i,a),c=a?e(t.candidates):i;0===u?a?n.push.apply(n,c):n.push(i):o.push({documentOrder:r,tabIndex:u,item:t,isScope:a,content:c})})),o.sort(v).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},E=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==i.call(e,r)&&w(t,e)},S=o.concat("iframe").join(","),O=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==i.call(e,S)&&y(t,e)}; /*! * focus-trap 7.5.4 * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE */ function F(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?F(Object(n),!0).forEach((function(t){T(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function T(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var k=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},D=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},x=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},A=function(e){return x(e)&&!e.shiftKey},P=function(e){return x(e)&&e.shiftKey},I=function(e){return setTimeout(e,0)},C=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},G=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},L=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},j=[],B=function(e,t){var n,o=(null==t?void 0:t.document)||document,r=(null==t?void 0:t.trapStack)||j,a=R({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:A,isKeyBackward:P},t),i={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},u=function(e,t,n){return e&&void 0!==e[t]?e[t]:a[n||t]},c=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return i.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},d=function(e){var t=a[e];if("function"==typeof t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];t=t.apply(void 0,r)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var u=t;if("string"==typeof t&&!(u=o.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return u},v=function(){var e=d("initialFocus");if(!1===e)return!1;if(void 0===e||!O(e,a.tabbableOptions))if(c(o.activeElement)>=0)e=o.activeElement;else{var t=i.tabbableGroups[0];e=t&&t.firstTabbableNode||d("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},p=function(){if(i.containerGroups=i.containers.map((function(e){var t=function(e,t){var n;return n=(t=t||{}).getShadowRoot?s([e],t.includeContainer,{filter:w.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:g}):l(e,t.includeContainer,w.bind(null,t)),N(n)}(e,a.tabbableOptions),n=function(e,t){return(t=t||{}).getShadowRoot?s([e],t.includeContainer,{filter:y.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):l(e,t.includeContainer,y.bind(null,t))}(e,a.tabbableOptions),o=t.length>0?t[0]:void 0,r=t.length>0?t[t.length-1]:void 0,i=n.find((function(e){return E(e)})),u=n.slice().reverse().find((function(e){return E(e)})),c=!!t.find((function(e){return f(e)>0}));return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:c,firstTabbableNode:o,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var o=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t.indexOf(e);return r<0?o?n.slice(n.indexOf(e)+1).find((function(e){return E(e)})):n.slice(0,n.indexOf(e)).reverse().find((function(e){return E(e)})):t[r+(o?1:-1)]}}})),i.tabbableGroups=i.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),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");if(i.containerGroups.find((function(e){return e.posTabIndexesFound}))&&i.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},b=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},h=function e(t){!1!==t&&t!==b(document)&&(t&&t.focus?(t.focus({preventScroll:!!a.preventScroll}),i.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(v()))},m=function(e){var t=d("setReturnFocus",e);return t||!1!==t&&e},S=function(e){var t=e.target,n=e.event,o=e.isBackward,r=void 0!==o&&o;t=t||L(n),p();var u=null;if(i.tabbableGroups.length>0){var l=c(t,n),s=l>=0?i.containerGroups[l]:void 0;if(l<0)u=r?i.tabbableGroups[i.tabbableGroups.length-1].lastTabbableNode:i.tabbableGroups[0].firstTabbableNode;else if(r){var v=C(i.tabbableGroups,(function(e){var n=e.firstTabbableNode;return t===n}));if(v<0&&(s.container===t||O(t,a.tabbableOptions)&&!E(t,a.tabbableOptions)&&!s.nextTabbableNode(t,!1))&&(v=l),v>=0){var b=0===v?i.tabbableGroups.length-1:v-1,h=i.tabbableGroups[b];u=f(t)>=0?h.lastTabbableNode:h.lastDomTabbableNode}else x(n)||(u=s.nextTabbableNode(t,!1))}else{var m=C(i.tabbableGroups,(function(e){var n=e.lastTabbableNode;return t===n}));if(m<0&&(s.container===t||O(t,a.tabbableOptions)&&!E(t,a.tabbableOptions)&&!s.nextTabbableNode(t))&&(m=l),m>=0){var y=m===i.tabbableGroups.length-1?0:m+1,w=i.tabbableGroups[y];u=f(t)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else x(n)||(u=s.nextTabbableNode(t))}}else u=d("fallbackFocus");return u},F=function(e){var t=L(e);c(t,e)>=0||(G(a.clickOutsideDeactivates,e)?n.deactivate({returnFocus:a.returnFocusOnDeactivate}):G(a.allowOutsideClick,e)||e.preventDefault())},T=function(e){var t=L(e),n=c(t,e)>=0;if(n||t instanceof Document)n&&(i.mostRecentlyFocusedNode=t);else{var o;e.stopImmediatePropagation();var r=!0;if(i.mostRecentlyFocusedNode)if(f(i.mostRecentlyFocusedNode)>0){var u=c(i.mostRecentlyFocusedNode),l=i.containerGroups[u].tabbableNodes;if(l.length>0){var s=l.findIndex((function(e){return e===i.mostRecentlyFocusedNode}));s>=0&&(a.isKeyForward(i.recentNavEvent)?s+1<l.length&&(o=l[s+1],r=!1):s-1>=0&&(o=l[s-1],r=!1))}}else i.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return f(e)>0}))}))||(r=!1);else r=!1;r&&(o=S({target:i.mostRecentlyFocusedNode,isBackward:a.isKeyBackward(i.recentNavEvent)})),h(o||(i.mostRecentlyFocusedNode||v()))}i.recentNavEvent=void 0},B=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===G(a.escapeDeactivates,e)))return e.preventDefault(),void n.deactivate();var t;(a.isKeyForward(e)||a.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i.recentNavEvent=e;var n=S({event:e,isBackward:t});n&&(x(e)&&e.preventDefault(),h(n))}(e,a.isKeyBackward(e))},M=function(e){var t=L(e);c(t,e)>=0||G(a.clickOutsideDeactivates,e)||G(a.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},K=function(){if(i.active)return k(r,n),i.delayInitialFocusTimer=a.delayInitialFocus?I((function(){h(v())})):h(v()),o.addEventListener("focusin",T,!0),o.addEventListener("mousedown",F,{capture:!0,passive:!1}),o.addEventListener("touchstart",F,{capture:!0,passive:!1}),o.addEventListener("click",M,{capture:!0,passive:!1}),o.addEventListener("keydown",B,{capture:!0,passive:!1}),n},q=function(){if(i.active)return o.removeEventListener("focusin",T,!0),o.removeEventListener("mousedown",F,!0),o.removeEventListener("touchstart",F,!0),o.removeEventListener("click",M,!0),o.removeEventListener("keydown",B,!0),n},U="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===i.mostRecentlyFocusedNode}))}))&&h(v())})):void 0,V=function(){U&&(U.disconnect(),i.active&&!i.paused&&i.containers.map((function(e){U.observe(e,{subtree:!0,childList:!0})})))};return(n={get active(){return i.active},get paused(){return i.paused},activate:function(e){if(i.active)return this;var t=u(e,"onActivate"),n=u(e,"onPostActivate"),r=u(e,"checkCanFocusTrap");r||p(),i.active=!0,i.paused=!1,i.nodeFocusedBeforeActivation=o.activeElement,null==t||t();var a=function(){r&&p(),K(),V(),null==n||n()};return r?(r(i.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!i.active)return this;var t=R({onDeactivate:a.onDeactivate,onPostDeactivate:a.onPostDeactivate,checkCanReturnFocus:a.checkCanReturnFocus},e);clearTimeout(i.delayInitialFocusTimer),i.delayInitialFocusTimer=void 0,q(),i.active=!1,i.paused=!1,V(),D(r,n);var o=u(t,"onDeactivate"),c=u(t,"onPostDeactivate"),l=u(t,"checkCanReturnFocus"),s=u(t,"returnFocus","returnFocusOnDeactivate");null==o||o();var d=function(){I((function(){s&&h(m(i.nodeFocusedBeforeActivation)),null==c||c()}))};return s&&l?(l(m(i.nodeFocusedBeforeActivation)).then(d,d),this):(d(),this)},pause:function(e){if(i.paused||!i.active)return this;var t=u(e,"onPause"),n=u(e,"onPostPause");return i.paused=!0,null==t||t(),q(),V(),null==n||n(),this},unpause:function(e){if(!i.paused||!i.active)return this;var t=u(e,"onUnpause"),n=u(e,"onPostUnpause");return i.paused=!1,null==t||t(),p(),K(),V(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return i.containers=t.map((function(e){return"string"==typeof e?o.querySelector(e):e})),i.active&&p(),V(),this}}).updateContainerElements(e),n};let M="";const K=new Map;exports.useActivatedFocusTrap=({element:o,isActive:r,noTrap:a,fallbackFocus:i},u={allowOutsideClick:!0,fallbackFocus:i.ref.value??void 0,escapeDeactivates:!1})=>{const c=e.readonly(e.toRef(r)),l=e.readonly(e.toRef(a)),s=()=>{var e;const t=null==(e=o.value)?void 0:e.querySelectorAll(`a, button, input, select, textarea, [tabindex]:not([tabindex="-1"]):not(.${i.classSelector})`);return!t||0===t.length},d=e.ref(s());e.onMounted((()=>{t.useMutationObserver(o,(()=>{d.value=s()}),{childList:!0,subtree:!0})}));const f=function(o,r={}){let a;const{immediate:i,...u}=r,c=e.ref(!1),l=e.ref(!1),s=e=>a&&a.activate(e),d=e=>a&&a.deactivate(e),f=e.computed((()=>{const e=n.toValue(o);return(Array.isArray(e)?e:[e]).map((e=>{const o=n.toValue(e);return"string"==typeof o?o:t.unrefElement(o)})).filter(n.notNullish)}));return e.watch(f,(e=>{e.length&&(a=B(e,{...u,onActivate(){c.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){c.value=!1,r.onDeactivate&&r.onDeactivate()}}),i&&s())}),{flush:"post"}),n.tryOnScopeDispose((()=>d())),{hasFocus:c,isPaused:l,activate:s,deactivate:d,pause:()=>{a&&(a.pause(),l.value=!0)},unpause:()=>{a&&(a.unpause(),l.value=!1)}}}(o,u);return e.watch(c,(async t=>{await e.nextTick(),t&&!1===l.value?f.activate():f.deactivate()})),e.watch(l,(e=>{!0===e&&f.deactivate()})),{needsFallback:e.readonly(d)}},exports.useSafeScrollLock=(n,o)=>{const r=e.readonly(e.toRef(n)),a=e.useId(),i=e.computed((()=>!e.toValue(o)));e.onMounted((()=>{K.set(a,!1);const n=t.useScrollLock(document.body,r.value&&i.value);e.watch([r,i],(([e,t])=>{const o=window.innerWidth-document.documentElement.clientWidth,r=Array.from(K.values()).some((e=>!0===e)),i=e&&t;K.set(a,i),!i||r||n.value||(n.value=!0,o>0&&(M=document.body.style.paddingRight,document.body.style.paddingRight=`${o+M}px`));const u=Array.from(K.values()).some((e=>!0===e));r&&!u&&(K.set(a,!1),n.value=!1,document.body.style.paddingRight=M)}),{immediate:!0})})),e.onUnmounted((()=>{K.delete(a)}))}; //# sourceMappingURL=useSafeScrollLock-DoX-OOqc.js.map