UNPKG

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) 1.73 kB
"use strict";const e=require("vue"),t=require("./keys-W3DrYQSP.js");function n(t,n){const o=e.getCurrentInstance();if(!o)throw new Error(`[Bvn] ${t} must be called from inside a setup function`);return o}const o=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);function r(e={},t={},n){const u={};for(const o in e)u[o]=e[o];for(const l in t){const n=e[l],s=t[l];o(n)&&o(s)?u[l]=r(n,s):u[l]=s}return u}function u(o={},u){const l=e.inject(t.defaultsKey,e.ref({})),s=n("useDefaults");if(!(u=u??s.type.name??s.type.__name))throw new Error("[Bvn] Could not determine component name");const i=e.computed((()=>{var e;return null==(e=l.value)?void 0:e[o._as??u]})),a=new Proxy(o,{get(e,t){var n,o,r,u;const a=Reflect.get(e,t);return"class"===t||"style"===t?[null==(n=i.value)?void 0:n[t],a].filter((e=>null!=e)):"string"!=typeof t||((e,t)=>{var n,o;return void 0!==(null==(n=e.props)?void 0:n[t])||void 0!==(null==(o=e.props)?void 0:o[((e="")=>e.replace(/[^a-z]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase())(t)])})(s.vnode,t)?a:(null==(o=i.value)?void 0:o[t])??(null==(u=null==(r=l.value)?void 0:r.global)?void 0:u[t])??a}}),c=e.shallowRef();return e.watchEffect((()=>{if(i.value){const e=Object.entries(i.value).filter((([e])=>e.startsWith(e[0].toUpperCase())));c.value=e.length?Object.fromEntries(e):void 0}else c.value=void 0})),{props:a,provideSubDefaults:function(){const o=function(e,t=n("injectSelf")){const{provides:o}=t;if(o&&e in o)return o[e]}(t.defaultsKey,s);e.provide(t.defaultsKey,e.computed((()=>c.value?r((null==o?void 0:o.value)??{},c.value):null==o?void 0:o.value)))}}}exports.useDefaults=function(e,t){const{props:n,provideSubDefaults:o}=u(e,t);return o(),n}; //# sourceMappingURL=useDefaults-q0yyNSBk.js.map