bootstrap-vue-next
Version:
BootstrapVueNext is an early and lovely component library for Vue 3 & Nuxt 3 based on Bootstrap 5 and Typescript.
3 lines (2 loc) • 15.3 kB
JavaScript
;const e=require("./index-BqHkgtNq.js"),t=require("vue");function n(t){const n={};for(const o in t)n[e.camelize(o)]=t[o];return n}const o=e.isClient?window:void 0;function r(t){var n;const o=e.toValue(t);return null!=(n=null==o?void 0:o.$el)?n:o}function a(...n){let a,s,i,u;if("string"==typeof n[0]||Array.isArray(n[0])?([s,i,u]=n,a=o):[a,s,i,u]=n,!a)return e.noop;Array.isArray(s)||(s=[s]),Array.isArray(i)||(i=[i]);const l=[],c=()=>{l.forEach((e=>e())),l.length=0},d=t.watch((()=>[r(a),e.toValue(u)]),(([t,n])=>{if(c(),!t)return;const o=e.isObject(n)?{...n}:n;l.push(...s.flatMap((e=>i.map((n=>((e,t,n,o)=>(e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)))(t,e,n,o))))))}),{immediate:!0,flush:"post"}),f=()=>{d(),c()};return e.tryOnScopeDispose(f),f}let s=!1;function i(e){const n=function(){const e=t.ref(!1),n=t.getCurrentInstance();return n&&t.onMounted((()=>{e.value=!0}),n),e}();return t.computed((()=>(n.value,Boolean(e()))))}function u(n,r={}){const{window:a=o}=r,s=i((()=>a&&"matchMedia"in a&&"function"==typeof a.matchMedia));let u;const l=t.ref(!1),c=e=>{l.value=e.matches},d=()=>{u&&("removeEventListener"in u?u.removeEventListener("change",c):u.removeListener(c))},f=t.watchEffect((()=>{s.value&&(d(),u=a.matchMedia(e.toValue(n)),"addEventListener"in u?u.addEventListener("change",c):u.addListener(c),l.value=u.matches)}));return e.tryOnScopeDispose((()=>{f(),d(),u=void 0})),l}const l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},c="__vueuse_ssr_handlers__",d=f();function f(){return c in l||(l[c]=l[c]||{}),l[c]}function v(e,t){return d[e]||t}const m={boolean:{read:e=>"true"===e,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},p="vueuse-storage";function h(n,r,s,i={}){var u;const{flush:l="pre",deep:c=!0,listenToStorageChanges:d=!0,writeDefaults:f=!0,mergeDefaults:h=!1,shallow:w,window:g=o,eventFilter:y,onError:S=e=>{console.error(e)},initOnMounted:b}=i,x=(w?t.shallowRef:t.ref)("function"==typeof r?r():r);if(!s)try{s=v("getDefaultStorage",(()=>{var e;return null==(e=o)?void 0:e.localStorage}))()}catch(N){S(N)}if(!s)return x;const E=e.toValue(r),O=function(e){return null==e?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":"boolean"==typeof e?"boolean":"string"==typeof e?"string":"object"==typeof e?"object":Number.isNaN(e)?"any":"number"}(E),A=null!=(u=i.serializer)?u:m[O],{pause:k,resume:M}=e.watchPausable(x,(()=>function(e){try{const t=s.getItem(n);if(null==e)V(t,null),s.removeItem(n);else{const o=A.write(e);t!==o&&(s.setItem(n,o),V(t,o))}}catch(N){S(N)}}(x.value)),{flush:l,deep:c,eventFilter:y});function V(e,t){if(g){const o={key:n,oldValue:e,newValue:t,storageArea:s};g.dispatchEvent(s instanceof Storage?new StorageEvent("storage",o):new CustomEvent(p,{detail:o}))}}function D(e){if(!e||e.storageArea===s)if(e&&null==e.key)x.value=E;else if(!e||e.key===n){k();try{(null==e?void 0:e.newValue)!==A.write(x.value)&&(x.value=function(e){const t=e?e.newValue:s.getItem(n);if(null==t)return f&&null!=E&&s.setItem(n,A.write(E)),E;if(!e&&h){const e=A.read(t);return"function"==typeof h?h(e,E):"object"!==O||Array.isArray(e)?e:{...E,...e}}return"string"!=typeof t?t:A.read(t)}(e))}catch(N){S(N)}finally{e?t.nextTick(M):M()}}}function L(e){D(e.detail)}return g&&d&&e.tryOnMounted((()=>{s instanceof Storage?a(g,"storage",D):a(g,p,L),b&&D()})),b||D(),x}function w(e){return"undefined"!=typeof Window&&e instanceof Window?e.document.documentElement:"undefined"!=typeof Document&&e instanceof Document?e.documentElement:e}const g={page:e=>[e.pageX,e.pageY],client:e=>[e.clientX,e.clientY],screen:e=>[e.screenX,e.screenY],movement:e=>e instanceof Touch?null:[e.movementX,e.movementY]};function y(e){const t=window.getComputedStyle(e);if("scroll"===t.overflowX||"scroll"===t.overflowY||"auto"===t.overflowX&&e.clientWidth<e.scrollWidth||"auto"===t.overflowY&&e.clientHeight<e.scrollHeight)return!0;{const t=e.parentNode;return!(!t||"BODY"===t.tagName)&&y(t)}}function S(e){const t=e||window.event;return!y(t.target)&&(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))}const b=new WeakMap;exports.breakpointsBootstrapV5={xs:0,sm:576,md:768,lg:992,xl:1200,xxl:1400},exports.createReusableTemplate=function(o={}){const{inheritAttrs:r=!0}=o,a=t.shallowRef(),s=t.defineComponent({setup:(e,{slots:t})=>()=>{a.value=t.default}}),i=t.defineComponent({inheritAttrs:r,setup:(e,{attrs:t,slots:o})=>()=>{var e;if(!a.value&&"production"!==process.env.NODE_ENV)throw new Error("[VueUse] Failed to find the definition of reusable template");const s=null==(e=a.value)?void 0:e.call(a,{...n(t),$slots:o});return r&&1===(null==s?void 0:s.length)?s[0]:s}});return e.makeDestructurable({define:s,reuse:i},[s,i])},exports.getSSRHandler=v,exports.onClickOutside=function(t,n,i={}){const{window:u=o,ignore:l=[],capture:c=!0,detectIframe:d=!1}=i;if(!u)return e.noop;e.isIOS&&!s&&(s=!0,Array.from(u.document.body.children).forEach((t=>t.addEventListener("click",e.noop))),u.document.documentElement.addEventListener("click",e.noop));let f=!0;const v=t=>e.toValue(l).some((e=>{if("string"==typeof e)return Array.from(u.document.querySelectorAll(e)).some((e=>e===t.target||t.composedPath().includes(e)));{const n=r(e);return n&&(t.target===n||t.composedPath().includes(n))}}));let m=!1;const p=[a(u,"click",(e=>{m||(m=!0,setTimeout((()=>{m=!1}),0),(e=>{const o=r(t);o&&o!==e.target&&!e.composedPath().includes(o)&&(0===e.detail&&(f=!v(e)),f?n(e):f=!0)})(e))}),{passive:!0,capture:c}),a(u,"pointerdown",(e=>{const n=r(t);f=!v(e)&&!(!n||e.composedPath().includes(n))}),{passive:!0}),d&&a(u,"blur",(e=>{setTimeout((()=>{var o;const a=r(t);"IFRAME"!==(null==(o=u.document.activeElement)?void 0:o.tagName)||(null==a?void 0:a.contains(u.document.activeElement))||n(e)}),0)}))].filter(Boolean);return()=>p.forEach((e=>e()))},exports.onKeyStroke=function(...t){let n,r,s={};3===t.length?(n=t[0],r=t[1],s=t[2]):2===t.length?"object"==typeof t[1]?(n=!0,r=t[0],s=t[1]):(n=t[0],r=t[1]):(n=!0,r=t[0]);const{target:i=o,eventName:u="keydown",passive:l=!1,dedupe:c=!1}=s,d="function"==typeof(f=n)?f:"string"==typeof f?e=>e.key===f:Array.isArray(f)?e=>f.includes(e.key):()=>!0;var f;return a(i,u,(t=>{t.repeat&&e.toValue(c)||d(t)&&r(t)}),l)},exports.unrefElement=r,exports.useBreakpoints=function(n,r={}){function a(t,o){let r=e.toValue(n[e.toValue(t)]);return null!=o&&(r=e.increaseWithUnit(r,o)),"number"==typeof r&&(r=`${r}px`),r}const{window:s=o,strategy:i="min-width"}=r;function l(e){return!!s&&s.matchMedia(e).matches}const c=e=>u((()=>`(min-width: ${a(e)})`),r),d=e=>u((()=>`(max-width: ${a(e)})`),r),f=Object.keys(n).reduce(((e,t)=>(Object.defineProperty(e,t,{get:()=>"min-width"===i?c(t):d(t),enumerable:!0,configurable:!0}),e)),{});function v(){const e=Object.keys(n).map((e=>[e,c(e)]));return t.computed((()=>e.filter((([,e])=>e.value)).map((([e])=>e))))}return Object.assign(f,{greaterOrEqual:c,smallerOrEqual:d,greater:e=>u((()=>`(min-width: ${a(e,.1)})`),r),smaller:e=>u((()=>`(max-width: ${a(e,-.1)})`),r),between:(e,t)=>u((()=>`(min-width: ${a(e)}) and (max-width: ${a(t,-.1)})`),r),isGreater:e=>l(`(min-width: ${a(e,.1)})`),isGreaterOrEqual:e=>l(`(min-width: ${a(e)})`),isSmaller:e=>l(`(max-width: ${a(e,-.1)})`),isSmallerOrEqual:e=>l(`(max-width: ${a(e)})`),isInBetween:(e,t)=>l(`(min-width: ${a(e)}) and (max-width: ${a(t,-.1)})`),current:v,active(){const e=v();return t.computed((()=>0===e.value.length?"":e.value.at(-1)))}})},exports.useColorMode=function(n={}){const{selector:a="html",attribute:s="class",initialValue:i="auto",window:l=o,storage:c,storageKey:d="vueuse-color-scheme",listenToStorageChanges:f=!0,storageRef:m,emitAuto:p,disableTransition:w=!0}=n,g={auto:"",light:"light",dark:"dark",...n.modes||{}},y=function(e){return u("(prefers-color-scheme: dark)",e)}({window:l}),S=t.computed((()=>y.value?"dark":"light")),b=m||(null==d?e.toRef(i):h(d,i,c,{window:l,listenToStorageChanges:f})),x=t.computed((()=>"auto"===b.value?S.value:b.value)),E=v("updateHTMLAttrs",((e,t,n)=>{const o="string"==typeof e?null==l?void 0:l.document.querySelector(e):r(e);if(!o)return;const a=new Set,s=new Set;let i,u=null;if("class"===t){const e=n.split(/\s/g);Object.values(g).flatMap((e=>(e||"").split(/\s/g))).filter(Boolean).forEach((t=>{e.includes(t)?a.add(t):s.add(t)}))}else u={key:t,value:n};if(0!==a.size||0!==s.size||null!==u){w&&(i=l.document.createElement("style"),i.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),l.document.head.appendChild(i));for(const e of a)o.classList.add(e);for(const e of s)o.classList.remove(e);u&&o.setAttribute(u.key,u.value),w&&(l.getComputedStyle(i).opacity,document.head.removeChild(i))}}));function O(e){var t;E(a,s,null!=(t=g[e])?t:e)}function A(e){n.onChanged?n.onChanged(e,O):O(e)}t.watch(x,A,{flush:"post",immediate:!0}),e.tryOnMounted((()=>A(x.value)));const k=t.computed({get:()=>p?b.value:x.value,set(e){b.value=e}});try{return Object.assign(k,{store:b,system:S,state:x})}catch(M){return k}},exports.useElementHover=function(e,n={}){const{delayEnter:r=0,delayLeave:s=0,window:i=o}=n,u=t.ref(!1);let l;const c=e=>{const t=e?r:s;l&&(clearTimeout(l),l=void 0),t?l=setTimeout((()=>u.value=e),t):u.value=e};return i?(a(e,"mouseenter",(()=>c(!0)),{passive:!0}),a(e,"mouseleave",(()=>c(!1)),{passive:!0}),u):u},exports.useEventListener=a,exports.useFocus=function(e,n={}){const{initialValue:o=!1,focusVisible:s=!1,preventScroll:i=!1}=n,u=t.ref(!1),l=t.computed((()=>r(e)));a(l,"focus",(e=>{var t,n;s&&!(null==(n=(t=e.target).matches)?void 0:n.call(t,":focus-visible"))||(u.value=!0)})),a(l,"blur",(()=>u.value=!1));const c=t.computed({get:()=>u.value,set(e){var t,n;!e&&u.value?null==(t=l.value)||t.blur():e&&!u.value&&(null==(n=l.value)||n.focus({preventScroll:i}))}});return t.watch(l,(()=>{c.value=o}),{immediate:!0,flush:"post"}),{focused:c}},exports.useIntersectionObserver=function(n,a,s={}){const{root:u,rootMargin:l="0px",threshold:c=0,window:d=o,immediate:f=!0}=s,v=i((()=>d&&"IntersectionObserver"in d)),m=t.computed((()=>{const t=e.toValue(n);return(Array.isArray(t)?t:[t]).map(r).filter(e.notNullish)}));let p=e.noop;const h=t.ref(f),w=v.value?t.watch((()=>[m.value,r(u),h.value]),(([t,n])=>{if(p(),!h.value)return;if(!t.length)return;const o=new IntersectionObserver(a,{root:r(n),rootMargin:l,threshold:c});t.forEach((e=>e&&o.observe(e))),p=()=>{o.disconnect(),p=e.noop}}),{immediate:f,flush:"post"}):e.noop,g=()=>{p(),w(),h.value=!1};return e.tryOnScopeDispose(g),{isSupported:v,isActive:h,pause(){p(),h.value=!1},resume(){h.value=!0},stop:g}},exports.useMouse=function(e={}){const{type:n="page",touch:r=!0,resetOnTouchEnds:s=!1,initialValue:i={x:0,y:0},window:u=o,target:l=u,scroll:c=!0,eventFilter:d}=e;let f=null;const v=t.ref(i.x),m=t.ref(i.y),p=t.ref(null),h="function"==typeof n?n:g[n],w=e=>{const t=h(e);f=e,t&&([v.value,m.value]=t,p.value="mouse")},y=e=>{if(e.touches.length>0){const t=h(e.touches[0]);t&&([v.value,m.value]=t,p.value="touch")}},S=()=>{if(!f||!u)return;const e=h(f);f instanceof MouseEvent&&e&&(v.value=e[0]+u.scrollX,m.value=e[1]+u.scrollY)},b=()=>{v.value=i.x,m.value=i.y},x=d?e=>d((()=>w(e)),{}):e=>w(e),E=d?e=>d((()=>y(e)),{}):e=>y(e),O=d?()=>d((()=>S()),{}):()=>S();if(l){const e={passive:!0};a(l,["mousemove","dragover"],x,e),r&&"movement"!==n&&(a(l,["touchstart","touchmove"],E,e),s&&a(l,"touchend",b,e)),c&&"page"===n&&a(u,"scroll",O,{passive:!0})}return{x:v,y:m,sourceType:p}},exports.useMutationObserver=function(n,a,s={}){const{window:u=o,...l}=s;let c;const d=i((()=>u&&"MutationObserver"in u)),f=()=>{c&&(c.disconnect(),c=void 0)},v=t.computed((()=>{const t=e.toValue(n),o=(Array.isArray(t)?t:[t]).map(r).filter(e.notNullish);return new Set(o)})),m=t.watch((()=>v.value),(e=>{f(),d.value&&e.size&&(c=new MutationObserver(a),e.forEach((e=>c.observe(e,l))))}),{immediate:!0,flush:"post"}),p=()=>{m(),f()};return e.tryOnScopeDispose(p),{isSupported:d,stop:p,takeRecords:()=>null==c?void 0:c.takeRecords()}},exports.useScrollLock=function(n,o=!1){const r=t.ref(o);let s=null,i="";t.watch(e.toRef(n),(t=>{const n=w(e.toValue(t));if(n){const e=n;if(b.get(e)||b.set(e,e.style.overflow),"hidden"!==e.style.overflow&&(i=e.style.overflow),"hidden"===e.style.overflow)return r.value=!0;if(r.value)return e.style.overflow="hidden"}}),{immediate:!0});const u=()=>{const t=w(e.toValue(n));t&&r.value&&(e.isIOS&&(null==s||s()),t.style.overflow=i,b.delete(t),r.value=!1)};return e.tryOnScopeDispose(u),t.computed({get:()=>r.value,set(t){t?(()=>{const t=w(e.toValue(n));t&&!r.value&&(e.isIOS&&(s=a(t,"touchmove",(e=>{S(e)}),{passive:!1})),t.style.overflow="hidden",r.value=!0)})():u()}})},exports.useSwipe=function(n,r={}){const{threshold:s=50,onSwipe:i,onSwipeEnd:u,onSwipeStart:l,passive:c=!0,window:d=o}=r,f=t.reactive({x:0,y:0}),v=t.reactive({x:0,y:0}),m=t.computed((()=>f.x-v.x)),p=t.computed((()=>f.y-v.y)),{max:h,abs:w}=Math,g=t.computed((()=>h(w(m.value),w(p.value))>=s)),y=t.ref(!1),S=t.computed((()=>g.value?w(m.value)>w(p.value)?m.value>0?"left":"right":p.value>0?"up":"down":"none")),b=e=>[e.touches[0].clientX,e.touches[0].clientY],x=(e,t)=>{v.x=e,v.y=t};let E;const O=function(t){if(!t)return!1;let n=!1;const o={get passive(){return n=!0,!1}};return t.addEventListener("x",e.noop,o),t.removeEventListener("x",e.noop),n}(null==d?void 0:d.document);E=c?O?{passive:!0}:{capture:!1}:O?{passive:!1,capture:!0}:{capture:!0};const A=[a(n,"touchstart",(e=>{if(1!==e.touches.length)return;E.capture&&!E.passive&&e.preventDefault();const[t,n]=b(e);((e,t)=>{f.x=e,f.y=t})(t,n),x(t,n),null==l||l(e)}),E),a(n,"touchmove",(e=>{if(1!==e.touches.length)return;const[t,n]=b(e);x(t,n),!y.value&&g.value&&(y.value=!0),y.value&&(null==i||i(e))}),E),a(n,["touchend","touchcancel"],(e=>{y.value&&(null==u||u(e,S.value)),y.value=!1}),E)];return{isPassiveEventSupported:O,isSwiping:y,direction:S,coordsStart:f,coordsEnd:v,lengthX:m,lengthY:p,stop:()=>A.forEach((e=>e()))}},exports.useTimestamp=function(n={}){const{controls:r=!1,offset:a=0,immediate:s=!0,interval:i="requestAnimationFrame",callback:u}=n,l=t.ref(e.timestamp()+a),c=()=>l.value=e.timestamp()+a,d=u?()=>{c(),u(l.value)}:c,f="requestAnimationFrame"===i?function(n,r={}){const{immediate:a=!0,fpsLimit:s,window:i=o}=r,u=t.ref(!1),l=s?1e3/s:null;let c=0,d=null;function f(e){if(!u.value||!i)return;c||(c=e);const t=e-c;l&&t<l||(c=e,n({delta:t,timestamp:e})),d=i.requestAnimationFrame(f)}function v(){!u.value&&i&&(u.value=!0,c=0,d=i.requestAnimationFrame(f))}function m(){u.value=!1,null!=d&&i&&(i.cancelAnimationFrame(d),d=null)}return a&&v(),e.tryOnScopeDispose(m),{isActive:t.readonly(u),pause:m,resume:v}}(d,{immediate:s}):e.useIntervalFn(d,i,{immediate:s});return r?{timestamp:l,...f}:l};
//# sourceMappingURL=index-CSe17yC0.js.map