UNPKG

@volverjs/ui-vue

Version:

@volverjs/ui-vue is a lightweight Vue 3 component library to accompany @volverjs/style.

2 lines (1 loc) 3.28 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@iconify/vue"),require("vue")):"function"==typeof define&&define.amd?define(["exports","@iconify/vue","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).volver={},e.vue$1,e.vue)}(this,function(e,t,n){"use strict";const r=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),i=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),o=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),s=/[^\p{L}\d]+/giu,c="$1\0$2";function l(e){let t=e.trim();t=t.replace(r,c).replace(i,c),t=t.replace(s,"\0");let n=0,o=t.length;for(;"\0"===t.charAt(n);)n++;if(n===o)return[];for(;"\0"===t.charAt(o-1);)o--;return t.slice(n,o).split(/\0/g)}function a(e){const t=l(e);for(let n=0;n<t.length;n++){const e=t[n],r=o.exec(e);if(r){const i=r.index+(r[1]??r[2]).length;t.splice(n,1,e.slice(0,i),e.slice(i))}}return t}function u(e,t){const[n,r,i]=function(e,t={}){const n=t.split??(t.separateNumbers?a:l),r=t.prefixCharacters??"",i=t.suffixCharacters??"";let o=0,s=e.length;for(;o<e.length;){const t=e.charAt(o);if(!r.includes(t))break;o++}for(;s>o;){const t=s-1,n=e.charAt(t);if(!i.includes(n))break;s=t}return[e.slice(0,o),n(e.slice(o,s)),e.slice(s)]}(e,t);return n+r.map((o=t?.locale,!1===o?e=>e.toLowerCase():e=>e.toLocaleLowerCase(o))).join(t?.delimiter??" ")+i;var o}const f=Symbol.for("volver");function d(e,t,n){const r=n||e.name;if(!r)return e;const i=t?.[r],o=e.props;return i&&o?{...e,name:r,props:Object.keys(o).reduce((e,t)=>{if(!(t in i))return e[t]=o[t],e;const n=i[t];return"function"==typeof o[t]||Array.isArray(o[t])?(e[t]={type:o[t],default:n},e):(e[t]={...o[t],default:n},e)},{})}:{...e,name:r}}class p{_fetchOptions={};_iconsCollections=[];_iconsProvider="vv";_nuxt=!1;_experimentalFeatures={};defaults=n.ref({});constructor({fetchWithCredentials:e,fetchOptions:t,iconsProvider:n,nuxt:r,iconsCollections:i,defaults:o,experimentalFeatures:s}={}){t&&(this._fetchOptions=t),e&&(this._fetchOptions={...this._fetchOptions,credentials:"include"}),n&&(this._iconsProvider=n),r&&(this._nuxt=r),i&&Array.isArray(i)&&i.forEach(e=>{this.addCollection(e,this._iconsProvider)}),o&&(this.defaults.value=o),s&&(this._experimentalFeatures=s)}get nuxt(){return this._nuxt}get iconsProvider(){return this._iconsProvider}get iconsCollections(){return this._iconsCollections}get experimentalFeatures(){return this._experimentalFeatures}addCollection(e,n=this._iconsProvider){return this._iconsCollections.push(e),t.addCollection(e,n)}addIcon(e,n){return t.addIcon(e,n)}addIconsAPIProvider(e,n){return t.addAPIProvider(e,n)}fetchIcon(e,t={cache:"force-cache"}){return new Promise((n,r)=>{fetch(e,{...this._fetchOptions,...t}).catch(e=>r(e)).then(e=>e?.text()).then(e=>n(e))})}}const h={install(e,t={}){const n=new p(t);e.config.globalProperties.$vv=n,t.components&&Object.entries(t.components).forEach(([n,r])=>{e.component(n,d(r,t.defaults))}),t.aliases&&Object.entries(t.aliases).forEach(([n,r])=>{e.component(n,d(r,t.defaults,n))}),t.directives&&Object.entries(t.directives).forEach(([t,n])=>{const r=function(e,t){return u(e,{delimiter:"-",...t})}(t);r.startsWith("v-")&&(t=r.substring(2).toLocaleLowerCase()),e.directive(t,n)}),e.provide(f,n)}};e.VolverPlugin=h,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});