From 0ebf0ca5e3313393d4b9723ff3367afc8d1b18e1 Mon Sep 17 00:00:00 2001 From: Collin Henderson Date: Mon, 24 Jan 2022 09:49:51 -0500 Subject: [PATCH] Commits build files --- .gitignore | 1 - dist/favicon.ico | Bin 0 -> 4286 bytes dist/vue-tribute.es.js | 79 ++++++++++++++++++++++++++++++++++++++++ dist/vue-tribute.umd.js | 1 + package.json | 2 +- tsconfig.json | 3 +- 6 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 dist/favicon.ico create mode 100644 dist/vue-tribute.es.js create mode 100644 dist/vue-tribute.umd.js diff --git a/.gitignore b/.gitignore index e12f9cc..66d2135 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ node_modules .DS_Store -dist dist-demo dist-ssr *.local diff --git a/dist/favicon.ico b/dist/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/dist/vue-tribute.es.js b/dist/vue-tribute.es.js new file mode 100644 index 0000000..f2e41c6 --- /dev/null +++ b/dist/vue-tribute.es.js @@ -0,0 +1,79 @@ +var __defProp = Object.defineProperty; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +import { defineComponent, ref, onMounted, onBeforeUnmount, watch, nextTick, h, unref } from "vue"; +import Tribute from "tributejs"; +const VueTribute = defineComponent({ + name: "vue-tribute", + props: { + options: { + type: Object, + required: true + } + }, + setup(props, context) { + if (typeof Tribute === "undefined") { + throw new Error("[vue-tribute] cannot locate tributejs."); + } + const root = ref(); + const el = ref(); + const attachTribute = (el2, options = props.options) => { + if (!el2.value) + return; + let tribute = new Tribute(unref(options)); + tribute.attach(el2.value); + el2.value.tributeInstance = tribute; + }; + onMounted(() => { + var _a; + el.value = (_a = root.value) == null ? void 0 : _a.childNodes[0]; + if (!el) { + throw new Error("[vue-tribute] cannot find a suitable element to attach to."); + } + attachTribute(el); + el.value.addEventListener("tribute-replaced", (e) => { + var _a2; + (_a2 = e.target) == null ? void 0 : _a2.dispatchEvent(new Event("input", { bubbles: true })); + }); + }); + const detachTribute = (el2) => { + var _a; + if (!((_a = el2.value) == null ? void 0 : _a.tributeInstance)) + return; + el2.value.tributeInstance.detach(el2.value); + el2.value.tributeInstance = void 0; + delete el2.value.dataset.tribute; + }; + onBeforeUnmount(() => { + detachTribute(el); + }); + watch(() => props.options, async (newOptions) => { + var _a; + if ((_a = el.value) == null ? void 0 : _a.tributeInstance) { + await nextTick(); + detachTribute(el); + await nextTick(); + attachTribute(el, __spreadValues({}, newOptions)); + } + }, { deep: true }); + return () => h("div", { class: "v-tribute", ref: root }, [context.slots.default ? context.slots.default()[0] : null].filter(Boolean)); + } +}); +const install = (app) => { + app.component(VueTribute.name, VueTribute); +}; +VueTribute.install = install; +export { VueTribute, VueTribute as default }; diff --git a/dist/vue-tribute.umd.js b/dist/vue-tribute.umd.js new file mode 100644 index 0000000..b3e8462 --- /dev/null +++ b/dist/vue-tribute.umd.js @@ -0,0 +1 @@ +var w=Object.defineProperty;var p=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var v=(t,e,u)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,h=(t,e)=>{for(var u in e||(e={}))y.call(e,u)&&v(t,u,e[u]);if(p)for(var u of p(e))j.call(e,u)&&v(t,u,e[u]);return t};(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("tributejs")):typeof define=="function"&&define.amd?define(["exports","vue","tributejs"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t["vue-tribute"]={},t.Vue,t.Tribute))})(this,function(t,e,u){"use strict";function T(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var d=T(u);const o=e.defineComponent({name:"vue-tribute",props:{options:{type:Object,required:!0}},setup(i,f){if(typeof d.default=="undefined")throw new Error("[vue-tribute] cannot locate tributejs.");const l=e.ref(),a=e.ref(),c=(n,r=i.options)=>{if(!n.value)return;let s=new d.default(e.unref(r));s.attach(n.value),n.value.tributeInstance=s};e.onMounted(()=>{var n;if(a.value=(n=l.value)==null?void 0:n.childNodes[0],!a)throw new Error("[vue-tribute] cannot find a suitable element to attach to.");c(a),a.value.addEventListener("tribute-replaced",r=>{var s;(s=r.target)==null||s.dispatchEvent(new Event("input",{bubbles:!0}))})});const b=n=>{var r;!((r=n.value)==null?void 0:r.tributeInstance)||(n.value.tributeInstance.detach(n.value),n.value.tributeInstance=void 0,delete n.value.dataset.tribute)};return e.onBeforeUnmount(()=>{b(a)}),e.watch(()=>i.options,async n=>{var r;((r=a.value)==null?void 0:r.tributeInstance)&&(await e.nextTick(),b(a),await e.nextTick(),c(a,h({},n)))},{deep:!0}),()=>e.h("div",{class:"v-tribute",ref:l},[f.slots.default?f.slots.default()[0]:null].filter(Boolean))}}),m=i=>{i.component(o.name,o)};o.install=m,t.VueTribute=o,t.default=o,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"}); diff --git a/package.json b/package.json index 7d94321..4a5e8ac 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "dev": "vite", "start": "vite", - "build": "vue-tsc --noEmit && vite build", + "build": "vue-tsc --noEmit --skipLibCheck && vite build", "build:demo": "vite build --mode demo", "preview": "vite preview", "serve": "vite preview", diff --git a/tsconfig.json b/tsconfig.json index 336c32e..028d6f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "lib": ["esnext", "dom"], "types": ["node", "vitest/globals"] }, - "include": ["vite.config.ts", "env.d.ts", "lib/**/*.ts", "demo/**/*.ts", "demo/**/*.vue"] + "include": ["vite.config.ts", "env.d.ts", "lib/**/*.ts", "demo/**/*.ts", "demo/**/*.vue"], + "exclude": ["node_modules"] }