From 6fbdf3a616a85fa23986bdbcbba7b0c3988e96ae Mon Sep 17 00:00:00 2001 From: Mihira Jayasekera Date: Wed, 26 Sep 2018 10:51:51 -0700 Subject: [PATCH] Change default component names to PascalCase (#147) Switch from camelCase default component names to PascalCase, so that both kebab-case (``) and PascalCase (``) component names in templates are supported by default. (Fixes #146.) --- dist/portal-vue.js | 4 ++-- dist/portal-vue.js.map | 2 +- dist/portal-vue.min.js | 2 +- src/index.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/portal-vue.js b/dist/portal-vue.js index 88e29f3..6d7e41c 100644 --- a/dist/portal-vue.js +++ b/dist/portal-vue.js @@ -594,8 +594,8 @@ var Portal = { function install(Vue$$1) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - Vue$$1.component(opts.portalName || 'portal', Portal); - Vue$$1.component(opts.portalTargetName || 'portalTarget', PortalTarget); + Vue$$1.component(opts.portalName || 'Portal', Portal); + Vue$$1.component(opts.portalTargetName || 'PortalTarget', PortalTarget); } if (typeof window !== 'undefined' && window.Vue) { window.Vue.use({ install: install }); diff --git a/dist/portal-vue.js.map b/dist/portal-vue.js.map index 0f6cb07..b35a213 100644 --- a/dist/portal-vue.js.map +++ b/dist/portal-vue.js.map @@ -1 +1 @@ -{"version":3,"file":"portal-vue.js","sources":["../src/utils.js","../src/components/wormhole.js","../node_modules/babel-helper-vue-jsx-merge-props/index.js","../src/components/portal-target.js","../src/components/portal.js","../src/index.js"],"sourcesContent":["export function extractAttributes(el) {\n const map = el.hasAttributes() ? el.attributes : []\n const attrs = {}\n for (let i = 0; i < map.length; i++) {\n const attr = map[i]\n if (attr.value) {\n attrs[attr.name] = attr.value === '' ? true : attr.value\n }\n }\n let klass, style\n if (attrs.class) {\n klass = attrs.class\n delete attrs.class\n }\n if (attrs.style) {\n style = attrs.style\n delete attrs.style\n }\n const data = {\n attrs,\n class: klass,\n style,\n }\n return data\n}\n\nexport function freeze(item) {\n if (Array.isArray(item) || typeof item === 'object') {\n return Object.freeze(item)\n }\n return item\n}\n\nexport function combinePassengers(transports, slotProps = {}) {\n return transports.reduce((passengers, transport) => {\n let newPassengers = transport.passengers[0]\n newPassengers =\n typeof newPassengers === 'function'\n ? newPassengers(slotProps)\n : transport.passengers\n return passengers.concat(newPassengers)\n }, [])\n}\n","import Vue from 'vue'\nimport { combinePassengers, freeze } from '../utils'\nconst transports = {}\n\nexport { transports }\n\nexport const Wormhole = Vue.extend({\n data: () => ({ transports }),\n methods: {\n open(transport) {\n const { to, from, passengers } = transport\n if (!to || !from || !passengers) return\n\n transport.passengers = freeze(passengers)\n const keys = Object.keys(this.transports)\n if (keys.indexOf(to) === -1) {\n Vue.set(this.transports, to, [])\n }\n\n const currentIndex = this.getTransportIndex(transport)\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n if (currentIndex === -1) {\n newTransports.push(transport)\n } else {\n newTransports[currentIndex] = transport\n }\n newTransports.sort(function(a, b) {\n return a.order - b.order\n })\n\n this.transports[to] = newTransports\n },\n\n close(transport, force = false) {\n const { to, from } = transport\n if (!to || !from) return\n if (!this.transports[to]) {\n return\n }\n\n if (force) {\n this.transports[to] = []\n } else {\n const index = this.getTransportIndex(transport)\n if (index >= 0) {\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n newTransports.splice(index, 1)\n this.transports[to] = newTransports\n }\n }\n },\n\n hasTarget(to) {\n return this.transports.hasOwnProperty(to)\n },\n\n hasContentFor(to) {\n if (!this.transports[to]) {\n return false\n }\n return this.getContentFor(to).length > 0\n },\n\n getSourceFor(to) {\n return this.transports[to] && this.transports[to][0].from\n },\n\n getContentFor(to) {\n const transports = this.transports[to]\n if (!transports) {\n return undefined\n }\n return combinePassengers(transports)\n },\n\n getTransportIndex({ to, from }) {\n for (const i in this.transports[to]) {\n if (this.transports[to][i].from === from) {\n return i\n }\n }\n return -1\n },\n },\n})\n\nconst wormhole = new Wormhole(transports)\nexport default wormhole\n","var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/\n\nmodule.exports = function mergeJSXProps (objs) {\n return objs.reduce(function (a, b) {\n var aa, bb, key, nestedKey, temp\n for (key in b) {\n aa = a[key]\n bb = b[key]\n if (aa && nestRE.test(key)) {\n // normalize class\n if (key === 'class') {\n if (typeof aa === 'string') {\n temp = aa\n a[key] = aa = {}\n aa[temp] = true\n }\n if (typeof bb === 'string') {\n temp = bb\n b[key] = bb = {}\n bb[temp] = true\n }\n }\n if (key === 'on' || key === 'nativeOn' || key === 'hook') {\n // merge functions\n for (nestedKey in bb) {\n aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])\n }\n } else if (Array.isArray(aa)) {\n a[key] = aa.concat(bb)\n } else if (Array.isArray(bb)) {\n a[key] = [aa].concat(bb)\n } else {\n for (nestedKey in bb) {\n aa[nestedKey] = bb[nestedKey]\n }\n }\n } else {\n a[key] = b[key]\n }\n }\n return a\n }, {})\n}\n\nfunction mergeFn (a, b) {\n return function () {\n a && a.apply(this, arguments)\n b && b.apply(this, arguments)\n }\n}\n","// import { transports } from './wormhole'\nimport { combinePassengers } from '../utils'\nimport wormhole from './wormhole'\n\nexport default {\n abstract: false,\n name: 'portalTarget',\n props: {\n attributes: { type: Object, default: () => ({}) },\n multiple: { type: Boolean, default: false },\n name: { type: String, required: true },\n slim: { type: Boolean, default: false },\n slotProps: { type: Object, default: () => ({}) },\n tag: { type: String, default: 'div' },\n transition: { type: [Boolean, String, Object], default: false },\n transitionEvents: { type: Object, default: () => ({}) },\n },\n data() {\n return {\n transports: wormhole.transports,\n firstRender: true,\n }\n },\n created() {\n if (!this.transports[this.name]) {\n this.$set(this.transports, this.name, [])\n }\n },\n mounted() {\n this.unwatch = this.$watch('ownTransports', this.emitChange)\n this.$nextTick(() => {\n if (this.transition) {\n // only when we have a transition, because it causes a re-render\n this.firstRender = false\n }\n })\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n updated() {\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n beforeDestroy() {\n this.unwatch()\n },\n\n computed: {\n ownTransports() {\n const transports = this.transports[this.name] || []\n if (this.multiple) {\n return transports\n }\n return transports.length === 0 ? [] : [transports[transports.length - 1]]\n },\n passengers() {\n return combinePassengers(this.ownTransports, this.slotProps)\n },\n hasAttributes() {\n return Object.keys(this.attributes).length > 0\n },\n withTransition() {\n return !!this.transition\n },\n transitionData() {\n const t = this.transition\n const data = {}\n\n // During first render, we render a dumb transition without any classes, events and a fake name\n // We have to do this to emulate the normal behaviour of transitions without `appear`\n // because in Portals, transitions can behave as if appear was defined under certain conditions.\n if (\n this.firstRender &&\n (typeof this.transition === 'object' && !this.transition.appear)\n ) {\n data.props = { name: '__notranstition__portal-vue__' }\n return data\n }\n\n if (typeof t === 'string') {\n data.props = { name: t }\n } else if (typeof t === 'object') {\n data.props = t\n }\n if (this.renderSlim) {\n data.props.tag = this.tag\n }\n data.on = this.transitionEvents\n\n return data\n },\n transportedClasses() {\n return this.ownTransports\n .map(transport => transport.class)\n .reduce((array, subarray) => array.concat(subarray), [])\n //.filter((string, index, array) => array.indexOf(string) === index)\n },\n },\n\n methods: {\n emitChange(newTransports, oldTransports) {\n if (this.multiple) {\n this.$emit('change', [...newTransports], [...oldTransports])\n } else {\n const newTransport =\n newTransports.length === 0 ? undefined : newTransports[0]\n const oldTransport =\n oldTransports.length === 0 ? undefined : oldTransports[0]\n this.$emit('change', { ...newTransport }, { ...oldTransport })\n }\n },\n // can't be a computed prop because it has to \"react\" to $slot changes.\n children() {\n return this.passengers.length !== 0\n ? this.passengers\n : this.$slots.default || []\n },\n noWrapper() {\n const noWrapper = !this.hasAttributes && this.slim\n if (noWrapper && this.children().length > 1) {\n console.warn(\n '[portal-vue]: PortalTarget with `slim` option received more than one child element.'\n )\n }\n return noWrapper\n },\n },\n render(h) {\n this.$options.abstract = true\n const noWrapper = this.noWrapper()\n const children = this.children()\n const TransitionType = noWrapper ? 'transition' : 'transition-group'\n const Tag = this.tag\n\n if (this.withTransition) {\n return (\n \n {children}\n \n )\n }\n\n // Solves a bug where Vue would sometimes duplicate elements upon changing multiple or disabled\n const wrapperKey = this.ownTransports.length\n\n return noWrapper ? (\n children[0]\n ) : (\n \n {children}\n \n )\n },\n}\n","import Vue from 'vue'\nimport wormhole from './wormhole'\nimport Target from './portal-target'\nimport { extractAttributes } from '../utils'\n\nconst inBrowser = typeof window !== 'undefined'\n\nlet pid = 1\n\nexport default {\n abstract: false,\n name: 'portal',\n props: {\n /* global HTMLElement */\n disabled: { type: Boolean, default: false },\n name: { type: String, default: () => String(pid++) },\n order: { type: Number, default: 0 },\n slim: { type: Boolean, default: false },\n slotProps: { type: Object, default: () => ({}) },\n tag: { type: [String], default: 'DIV' },\n targetEl: { type: inBrowser ? [String, HTMLElement] : String },\n targetClass: { type: String },\n to: {\n type: String,\n default: () => String(Math.round(Math.random() * 10000000)),\n },\n },\n\n mounted() {\n if (this.targetEl) {\n this.mountToTarget()\n }\n if (!this.disabled) {\n this.sendUpdate()\n }\n // Reset hack to make child components skip the portal when defining their $parent\n // was set to true during render when we render something locally.\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n\n updated() {\n if (this.disabled) {\n this.clear()\n } else {\n this.sendUpdate()\n }\n // Reset hack to make child components skip the portal when defining their $parent\n // was set to true during render when we render something locally.\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n\n beforeDestroy() {\n this.clear()\n if (this.mountedComp) {\n this.mountedComp.$destroy()\n }\n },\n watch: {\n to(newValue, oldValue) {\n oldValue && oldValue !== newValue && this.clear(oldValue)\n this.sendUpdate()\n },\n targetEl(newValue, oldValue) {\n if (newValue) {\n this.mountToTarget()\n }\n },\n },\n\n methods: {\n normalizedSlots() {\n return this.$scopedSlots.default\n ? [this.$scopedSlots.default]\n : this.$slots.default\n },\n sendUpdate() {\n const slotContent = this.normalizedSlots()\n\n if (slotContent) {\n wormhole.open({\n from: this.name,\n to: this.to,\n passengers: [...slotContent],\n class: this.targetClass && this.targetClass.split(' '),\n order: this.order,\n })\n } else {\n this.clear()\n }\n },\n\n clear(target) {\n wormhole.close({\n from: this.name,\n to: target || this.to,\n })\n },\n\n mountToTarget() {\n let el\n const target = this.targetEl\n\n if (typeof target === 'string') {\n el = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n el = target\n } else {\n console.warn(\n '[vue-portal]: value of targetEl must be of type String or HTMLElement'\n )\n return\n }\n\n if (el) {\n const newTarget = new Vue({\n ...Target,\n parent: this,\n propsData: {\n name: this.to,\n tag: el.tagName,\n attributes: extractAttributes(el),\n },\n })\n newTarget.$mount(el)\n this.mountedComp = newTarget\n } else {\n console.warn(\n '[vue-portal]: The specified targetEl ' + target + ' was not found'\n )\n }\n },\n normalizeChildren(children) {\n return typeof children === 'function'\n ? children(this.slotProps)\n : children\n },\n },\n\n render(h) {\n const children = this.$slots.default || this.$scopedSlots.default || []\n const Tag = this.tag\n if (children.length && this.disabled) {\n // hack to make child components skip the portal when defining their $parent\n this.$options.abstract = true\n return children.length <= 1 && this.slim ? (\n children[0]\n ) : (\n {this.normalizeChildren(children)}\n )\n } else {\n return (\n \n )\n // h(this.tag, { class: { 'v-portal': true }, style: { display: 'none' }, key: 'v-portal-placeholder' })\n }\n },\n}\n","import Portal from './components/portal.js'\nimport PortalTarget from './components/portal-target.js'\nimport Wormhole from './components/wormhole.js'\n\nfunction install(Vue, opts = {}) {\n Vue.component(opts.portalName || 'portal', Portal)\n Vue.component(opts.portalTargetName || 'portalTarget', PortalTarget)\n}\nif (typeof window !== 'undefined' && window.Vue) {\n window.Vue.use({ install: install })\n}\n\nexport default {\n install,\n Portal,\n PortalTarget,\n Wormhole,\n}\n"],"names":["extractAttributes","el","map","hasAttributes","attributes","attrs","i","length","attr","value","name","klass","style","class","data","freeze","item","Array","isArray","Object","combinePassengers","transports","slotProps","reduce","passengers","transport","newPassengers","concat","Wormhole","Vue","extend","to","from","keys","indexOf","set","currentIndex","getTransportIndex","newTransports","slice","push","sort","a","b","order","force","index","splice","hasOwnProperty","getContentFor","undefined","wormhole","type","default","Boolean","String","required","$set","unwatch","$watch","emitChange","$nextTick","transition","firstRender","$options","abstract","multiple","ownTransports","t","babelHelpers.typeof","appear","props","renderSlim","tag","on","transitionEvents","array","subarray","oldTransports","$emit","newTransport","oldTransport","$slots","noWrapper","slim","children","warn","h","TransitionType","Tag","withTransition","transitionData","wrapperKey","transportedClasses","join","inBrowser","window","pid","Number","HTMLElement","Math","round","random","targetEl","mountToTarget","disabled","sendUpdate","clear","mountedComp","$destroy","newValue","oldValue","$scopedSlots","slotContent","normalizedSlots","open","targetClass","split","target","close","document","querySelector","newTarget","Target","tagName","$mount","normalizeChildren","install","opts","component","portalName","Portal","portalTargetName","PortalTarget","use"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,iBAAT,CAA2BC,EAA3B,EAA+B;MAC9BC,MAAMD,GAAGE,aAAH,KAAqBF,GAAGG,UAAxB,GAAqC,EAAjD;MACMC,QAAQ,EAAd;OACK,IAAIC,IAAI,CAAb,EAAgBA,IAAIJ,IAAIK,MAAxB,EAAgCD,GAAhC,EAAqC;QAC7BE,OAAON,IAAII,CAAJ,CAAb;QACIE,KAAKC,KAAT,EAAgB;YACRD,KAAKE,IAAX,IAAmBF,KAAKC,KAAL,KAAe,EAAf,GAAoB,IAApB,GAA2BD,KAAKC,KAAnD;;;MAGAE,cAAJ;MAAWC,cAAX;MACIP,MAAMQ,KAAV,EAAiB;YACPR,MAAMQ,KAAd;WACOR,MAAMQ,KAAb;;MAEER,MAAMO,KAAV,EAAiB;YACPP,MAAMO,KAAd;WACOP,MAAMO,KAAb;;MAEIE,OAAO;gBAAA;WAEJH,KAFI;;GAAb;SAKOG,IAAP;;;AAGF,AAAO,SAASC,MAAT,CAAgBC,IAAh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AAzB;aACOoB,SAAS9E,MAAT,IAAmB,CAAnB,IAAwB,KAAK6E,IAA7B,GACLC,SAAS,CAAT,CADK,GAGL,EAAC,GAAD,GAAM,KAAKyC,iBAAL,CAAuBzC,QAAvB,CAAN,EAHF;KAHF,MAQO;aAEH,EAAC,GAAD;iBACS,UADT;eAES,eAFT;aAGO;QAJT;;;;CAjJN;;ACLA,SAAS0C,OAAT,CAAiBlG,MAAjB,EAAiC;MAAXmG,IAAW,uEAAJ,EAAI;;SAC3BC,SAAJ,CAAcD,KAAKE,UAAL,IAAmB,QAAjC,EAA2CC,MAA3C;SACIF,SAAJ,CAAcD,KAAKI,gBAAL,IAAyB,cAAvC,EAAuDC,YAAvD;;AAEF,IAAI,OAAOrC,MAAP,KAAkB,WAAlB,IAAiCA,OAAOnE,GAA5C,EAAiD;SACxCA,GAAP,CAAWyG,GAAX,CAAe,EAAEP,SAASA,OAAX,EAAf;;;AAGF,YAAe;kBAAA;gBAAA;4BAAA;;CAAf;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"portal-vue.js","sources":["../src/utils.js","../src/components/wormhole.js","../node_modules/babel-helper-vue-jsx-merge-props/index.js","../src/components/portal-target.js","../src/components/portal.js","../src/index.js"],"sourcesContent":["export function extractAttributes(el) {\n const map = el.hasAttributes() ? el.attributes : []\n const attrs = {}\n for (let i = 0; i < map.length; i++) {\n const attr = map[i]\n if (attr.value) {\n attrs[attr.name] = attr.value === '' ? true : attr.value\n }\n }\n let klass, style\n if (attrs.class) {\n klass = attrs.class\n delete attrs.class\n }\n if (attrs.style) {\n style = attrs.style\n delete attrs.style\n }\n const data = {\n attrs,\n class: klass,\n style,\n }\n return data\n}\n\nexport function freeze(item) {\n if (Array.isArray(item) || typeof item === 'object') {\n return Object.freeze(item)\n }\n return item\n}\n\nexport function combinePassengers(transports, slotProps = {}) {\n return transports.reduce((passengers, transport) => {\n let newPassengers = transport.passengers[0]\n newPassengers =\n typeof newPassengers === 'function'\n ? newPassengers(slotProps)\n : transport.passengers\n return passengers.concat(newPassengers)\n }, [])\n}\n","import Vue from 'vue'\nimport { combinePassengers, freeze } from '../utils'\nconst transports = {}\n\nexport { transports }\n\nexport const Wormhole = Vue.extend({\n data: () => ({ transports }),\n methods: {\n open(transport) {\n const { to, from, passengers } = transport\n if (!to || !from || !passengers) return\n\n transport.passengers = freeze(passengers)\n const keys = Object.keys(this.transports)\n if (keys.indexOf(to) === -1) {\n Vue.set(this.transports, to, [])\n }\n\n const currentIndex = this.getTransportIndex(transport)\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n if (currentIndex === -1) {\n newTransports.push(transport)\n } else {\n newTransports[currentIndex] = transport\n }\n newTransports.sort(function(a, b) {\n return a.order - b.order\n })\n\n this.transports[to] = newTransports\n },\n\n close(transport, force = false) {\n const { to, from } = transport\n if (!to || !from) return\n if (!this.transports[to]) {\n return\n }\n\n if (force) {\n this.transports[to] = []\n } else {\n const index = this.getTransportIndex(transport)\n if (index >= 0) {\n // Copying the array here so that the PortalTarget change event will actually contain two distinct arrays\n const newTransports = this.transports[to].slice(0)\n newTransports.splice(index, 1)\n this.transports[to] = newTransports\n }\n }\n },\n\n hasTarget(to) {\n return this.transports.hasOwnProperty(to)\n },\n\n hasContentFor(to) {\n if (!this.transports[to]) {\n return false\n }\n return this.getContentFor(to).length > 0\n },\n\n getSourceFor(to) {\n return this.transports[to] && this.transports[to][0].from\n },\n\n getContentFor(to) {\n const transports = this.transports[to]\n if (!transports) {\n return undefined\n }\n return combinePassengers(transports)\n },\n\n getTransportIndex({ to, from }) {\n for (const i in this.transports[to]) {\n if (this.transports[to][i].from === from) {\n return i\n }\n }\n return -1\n },\n },\n})\n\nconst wormhole = new Wormhole(transports)\nexport default wormhole\n","var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/\n\nmodule.exports = function mergeJSXProps (objs) {\n return objs.reduce(function (a, b) {\n var aa, bb, key, nestedKey, temp\n for (key in b) {\n aa = a[key]\n bb = b[key]\n if (aa && nestRE.test(key)) {\n // normalize class\n if (key === 'class') {\n if (typeof aa === 'string') {\n temp = aa\n a[key] = aa = {}\n aa[temp] = true\n }\n if (typeof bb === 'string') {\n temp = bb\n b[key] = bb = {}\n bb[temp] = true\n }\n }\n if (key === 'on' || key === 'nativeOn' || key === 'hook') {\n // merge functions\n for (nestedKey in bb) {\n aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])\n }\n } else if (Array.isArray(aa)) {\n a[key] = aa.concat(bb)\n } else if (Array.isArray(bb)) {\n a[key] = [aa].concat(bb)\n } else {\n for (nestedKey in bb) {\n aa[nestedKey] = bb[nestedKey]\n }\n }\n } else {\n a[key] = b[key]\n }\n }\n return a\n }, {})\n}\n\nfunction mergeFn (a, b) {\n return function () {\n a && a.apply(this, arguments)\n b && b.apply(this, arguments)\n }\n}\n","// import { transports } from './wormhole'\nimport { combinePassengers } from '../utils'\nimport wormhole from './wormhole'\n\nexport default {\n abstract: false,\n name: 'portalTarget',\n props: {\n attributes: { type: Object, default: () => ({}) },\n multiple: { type: Boolean, default: false },\n name: { type: String, required: true },\n slim: { type: Boolean, default: false },\n slotProps: { type: Object, default: () => ({}) },\n tag: { type: String, default: 'div' },\n transition: { type: [Boolean, String, Object], default: false },\n transitionEvents: { type: Object, default: () => ({}) },\n },\n data() {\n return {\n transports: wormhole.transports,\n firstRender: true,\n }\n },\n created() {\n if (!this.transports[this.name]) {\n this.$set(this.transports, this.name, [])\n }\n },\n mounted() {\n this.unwatch = this.$watch('ownTransports', this.emitChange)\n this.$nextTick(() => {\n if (this.transition) {\n // only when we have a transition, because it causes a re-render\n this.firstRender = false\n }\n })\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n updated() {\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n beforeDestroy() {\n this.unwatch()\n },\n\n computed: {\n ownTransports() {\n const transports = this.transports[this.name] || []\n if (this.multiple) {\n return transports\n }\n return transports.length === 0 ? [] : [transports[transports.length - 1]]\n },\n passengers() {\n return combinePassengers(this.ownTransports, this.slotProps)\n },\n hasAttributes() {\n return Object.keys(this.attributes).length > 0\n },\n withTransition() {\n return !!this.transition\n },\n transitionData() {\n const t = this.transition\n const data = {}\n\n // During first render, we render a dumb transition without any classes, events and a fake name\n // We have to do this to emulate the normal behaviour of transitions without `appear`\n // because in Portals, transitions can behave as if appear was defined under certain conditions.\n if (\n this.firstRender &&\n (typeof this.transition === 'object' && !this.transition.appear)\n ) {\n data.props = { name: '__notranstition__portal-vue__' }\n return data\n }\n\n if (typeof t === 'string') {\n data.props = { name: t }\n } else if (typeof t === 'object') {\n data.props = t\n }\n if (this.renderSlim) {\n data.props.tag = this.tag\n }\n data.on = this.transitionEvents\n\n return data\n },\n transportedClasses() {\n return this.ownTransports\n .map(transport => transport.class)\n .reduce((array, subarray) => array.concat(subarray), [])\n //.filter((string, index, array) => array.indexOf(string) === index)\n },\n },\n\n methods: {\n emitChange(newTransports, oldTransports) {\n if (this.multiple) {\n this.$emit('change', [...newTransports], [...oldTransports])\n } else {\n const newTransport =\n newTransports.length === 0 ? undefined : newTransports[0]\n const oldTransport =\n oldTransports.length === 0 ? undefined : oldTransports[0]\n this.$emit('change', { ...newTransport }, { ...oldTransport })\n }\n },\n // can't be a computed prop because it has to \"react\" to $slot changes.\n children() {\n return this.passengers.length !== 0\n ? this.passengers\n : this.$slots.default || []\n },\n noWrapper() {\n const noWrapper = !this.hasAttributes && this.slim\n if (noWrapper && this.children().length > 1) {\n console.warn(\n '[portal-vue]: PortalTarget with `slim` option received more than one child element.'\n )\n }\n return noWrapper\n },\n },\n render(h) {\n this.$options.abstract = true\n const noWrapper = this.noWrapper()\n const children = this.children()\n const TransitionType = noWrapper ? 'transition' : 'transition-group'\n const Tag = this.tag\n\n if (this.withTransition) {\n return (\n \n {children}\n \n )\n }\n\n // Solves a bug where Vue would sometimes duplicate elements upon changing multiple or disabled\n const wrapperKey = this.ownTransports.length\n\n return noWrapper ? (\n children[0]\n ) : (\n \n {children}\n \n )\n },\n}\n","import Vue from 'vue'\nimport wormhole from './wormhole'\nimport Target from './portal-target'\nimport { extractAttributes } from '../utils'\n\nconst inBrowser = typeof window !== 'undefined'\n\nlet pid = 1\n\nexport default {\n abstract: false,\n name: 'portal',\n props: {\n /* global HTMLElement */\n disabled: { type: Boolean, default: false },\n name: { type: String, default: () => String(pid++) },\n order: { type: Number, default: 0 },\n slim: { type: Boolean, default: false },\n slotProps: { type: Object, default: () => ({}) },\n tag: { type: [String], default: 'DIV' },\n targetEl: { type: inBrowser ? [String, HTMLElement] : String },\n targetClass: { type: String },\n to: {\n type: String,\n default: () => String(Math.round(Math.random() * 10000000)),\n },\n },\n\n mounted() {\n if (this.targetEl) {\n this.mountToTarget()\n }\n if (!this.disabled) {\n this.sendUpdate()\n }\n // Reset hack to make child components skip the portal when defining their $parent\n // was set to true during render when we render something locally.\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n\n updated() {\n if (this.disabled) {\n this.clear()\n } else {\n this.sendUpdate()\n }\n // Reset hack to make child components skip the portal when defining their $parent\n // was set to true during render when we render something locally.\n if (this.$options.abstract) {\n this.$options.abstract = false\n }\n },\n\n beforeDestroy() {\n this.clear()\n if (this.mountedComp) {\n this.mountedComp.$destroy()\n }\n },\n watch: {\n to(newValue, oldValue) {\n oldValue && oldValue !== newValue && this.clear(oldValue)\n this.sendUpdate()\n },\n targetEl(newValue, oldValue) {\n if (newValue) {\n this.mountToTarget()\n }\n },\n },\n\n methods: {\n normalizedSlots() {\n return this.$scopedSlots.default\n ? [this.$scopedSlots.default]\n : this.$slots.default\n },\n sendUpdate() {\n const slotContent = this.normalizedSlots()\n\n if (slotContent) {\n wormhole.open({\n from: this.name,\n to: this.to,\n passengers: [...slotContent],\n class: this.targetClass && this.targetClass.split(' '),\n order: this.order,\n })\n } else {\n this.clear()\n }\n },\n\n clear(target) {\n wormhole.close({\n from: this.name,\n to: target || this.to,\n })\n },\n\n mountToTarget() {\n let el\n const target = this.targetEl\n\n if (typeof target === 'string') {\n el = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n el = target\n } else {\n console.warn(\n '[vue-portal]: value of targetEl must be of type String or HTMLElement'\n )\n return\n }\n\n if (el) {\n const newTarget = new Vue({\n ...Target,\n parent: this,\n propsData: {\n name: this.to,\n tag: el.tagName,\n attributes: extractAttributes(el),\n },\n })\n newTarget.$mount(el)\n this.mountedComp = newTarget\n } else {\n console.warn(\n '[vue-portal]: The specified targetEl ' + target + ' was not found'\n )\n }\n },\n normalizeChildren(children) {\n return typeof children === 'function'\n ? children(this.slotProps)\n : children\n },\n },\n\n render(h) {\n const children = this.$slots.default || this.$scopedSlots.default || []\n const Tag = this.tag\n if (children.length && this.disabled) {\n // hack to make child components skip the portal when defining their $parent\n this.$options.abstract = true\n return children.length <= 1 && this.slim ? (\n children[0]\n ) : (\n {this.normalizeChildren(children)}\n )\n } else {\n return (\n \n )\n // h(this.tag, { class: { 'v-portal': true }, style: { display: 'none' }, key: 'v-portal-placeholder' })\n }\n },\n}\n","import Portal from './components/portal.js'\nimport PortalTarget from './components/portal-target.js'\nimport Wormhole from './components/wormhole.js'\n\nfunction install(Vue, opts = {}) {\n Vue.component(opts.portalName || 'Portal', Portal)\n Vue.component(opts.portalTargetName || 'PortalTarget', PortalTarget)\n}\nif (typeof window !== 'undefined' && window.Vue) {\n window.Vue.use({ install: install })\n}\n\nexport default {\n install,\n Portal,\n PortalTarget,\n Wormhole,\n}\n"],"names":["extractAttributes","el","map","hasAttributes","attributes","attrs","i","length","attr","value","name","klass","style","class","data","freeze","item","Array","isArray","Object","combinePassengers","transports","slotProps","reduce","passengers","transport","newPassengers","concat","Wormhole","Vue","extend","to","from","keys","indexOf","set","currentIndex","getTransportIndex","newTransports","slice","push","sort","a","b","order","force","index","splice","hasOwnProperty","getContentFor","undefined","wormhole","type","default","Boolean","String","required","$set","unwatch","$watch","emitChange","$nextTick","transition","firstRender","$options","abstract","multiple","ownTransports","t","babelHelpers.typeof","appear","props","renderSlim","tag","on","transitionEvents","array","subarray","oldTransports","$emit","newTransport","oldTransport","$slots","noWrapper","slim","children","warn","h","TransitionType","Tag","withTransition","transitionData","wrapperKey","transportedClasses","join","inBrowser","window","pid","Number","HTMLElement","Math","round","random","targetEl","mountToTarget","disabled","sendUpdate","clear","mountedComp","$destroy","newValue","oldValue","$scopedSlots","slotContent","normalizedSlots","open","targetClass","split","target","close","document","querySelector","newTarget","Target","tagName","$mount","normalizeChildren","install","opts","component","portalName","Portal","portalTargetName","PortalTarget","use"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,iBAAT,CAA2BC,EAA3B,EAA+B;MAC9BC,MAAMD,GAAGE,aAAH,KAAqBF,GAAGG,UAAxB,GAAqC,EAAjD;MACMC,QAAQ,EAAd;OACK,IAAIC,IAAI,CAAb,EAAgBA,IAAIJ,IAAIK,MAAxB,EAAgCD,GAAhC,EAAqC;QAC7BE,OAAON,IAAII,CAAJ,CAAb;QACIE,KAAKC,KAAT,EAAgB;YACRD,KAAKE,IAAX,IAAmBF,KAAKC,KAAL,KAAe,EAAf,GAAoB,IAApB,GAA2BD,KAAKC,KAAnD;;;MAGAE,cAAJ;MAAWC,cAAX;MACIP,MAAMQ,KAAV,EAAiB;YACPR,MAAMQ,KAAd;WACOR,MAAMQ,KAAb;;MAEER,MAAMO,KAAV,EAAiB;YACPP,MAAMO,KAAd;WACOP,MAAMO,KAAb;;MAEIE,OAAO;gBAAA;WAEJH,KAFI;;GAAb;SAKOG,IAAP;;;AAGF,AAAO,SAASC,MAAT,CAAgBC,IAAhB,EAAsB;MACvBC,MAAMC,OAAN,CAAcF,IAAd,KAAuB,QAAOA,IAAP,yCAAOA,IAAP,OAAgB,QAA3C,EAAqD;WAC5CG,OAAOJ,MAAP,CAAcC,IAAd,CAAP;;SAEKA,IAAP;;;AAGF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AQO;aAEH,EAAC,GAAD;iBACS,UADT;eAES,eAFT;aAGO;QAJT;;;;CAjJN;;ACLA,SAAS0C,OAAT,CAAiBlG,MAAjB,EAAiC;MAAXmG,IAAW,uEAAJ,EAAI;;SAC3BC,SAAJ,CAAcD,KAAKE,UAAL,IAAmB,QAAjC,EAA2CC,MAA3C;SACIF,SAAJ,CAAcD,KAAKI,gBAAL,IAAyB,cAAvC,EAAuDC,YAAvD;;AAEF,IAAI,OAAOrC,MAAP,KAAkB,WAAlB,IAAiCA,OAAOnE,GAA5C,EAAiD;SACxCA,GAAP,CAAWyG,GAAX,CAAe,EAAEP,SAASA,OAAX,EAAf;;;AAGF,YAAe;kBAAA;gBAAA;4BAAA;;CAAf;;;;;;;;"} \ No newline at end of file diff --git a/dist/portal-vue.min.js b/dist/portal-vue.min.js index aa0779c..001ad0a 100644 --- a/dist/portal-vue.min.js +++ b/dist/portal-vue.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.PortalVue=e(t.Vue)}(this,function(t){"use strict";function e(t){for(var e=t.hasAttributes()?t.attributes:[],n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return t.reduce(function(t,n){var r=n.passengers[0];return r="function"==typeof r?r(e):n.passengers,t.concat(r)},[])}function s(t,e){return function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.component(e.portalName||"portal",y),t.component(e.portalTargetName||"portalTarget",d)}t=t&&t.hasOwnProperty("default")?t.default:t;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]&&arguments[1],n=t.to,r=t.from;if(n&&r&&this.transports[n])if(e)this.transports[n]=[];else{var s=this.getTransportIndex(t);if(s>=0){var o=this.transports[n].slice(0);o.splice(s,1),this.transports[n]=o}}},hasTarget:function(t){return this.transports.hasOwnProperty(t)},hasContentFor:function(t){return!!this.transports[t]&&this.getContentFor(t).length>0},getSourceFor:function(t){return this.transports[t]&&this.transports[t][0].from},getContentFor:function(t){var e=this.transports[t];if(e)return r(e)},getTransportIndex:function(t){var e=t.to,n=t.from;for(var r in this.transports[e])if(this.transports[e][r].from===n)return r;return-1}}}),h=new p(l),c=/^(attrs|props|on|nativeOn|class|style|hook)$/,f=function(t){return t.reduce(function(t,e){var n,r,o,i,a;for(o in e)if(n=t[o],r=e[o],n&&c.test(o))if("class"===o&&("string"==typeof n&&(a=n,t[o]=n={},n[a]=!0),"string"==typeof r&&(a=r,e[o]=r={},r[a]=!0)),"on"===o||"nativeOn"===o||"hook"===o)for(i in r)n[i]=s(n[i],r[i]);else if(Array.isArray(n))t[o]=n.concat(r);else if(Array.isArray(r))t[o]=[n].concat(r);else for(i in r)n[i]=r[i];else t[o]=e[o];return t},{})},d={abstract:!1,name:"portalTarget",props:{attributes:{type:Object,default:function(){return{}}},multiple:{type:Boolean,default:!1},name:{type:String,required:!0},slim:{type:Boolean,default:!1},slotProps:{type:Object,default:function(){return{}}},tag:{type:String,default:"div"},transition:{type:[Boolean,String,Object],default:!1},transitionEvents:{type:Object,default:function(){return{}}}},data:function(){return{transports:h.transports,firstRender:!0}},created:function(){this.transports[this.name]||this.$set(this.transports,this.name,[])},mounted:function(){var t=this;this.unwatch=this.$watch("ownTransports",this.emitChange),this.$nextTick(function(){t.transition&&(t.firstRender=!1)}),this.$options.abstract&&(this.$options.abstract=!1)},updated:function(){this.$options.abstract&&(this.$options.abstract=!1)},beforeDestroy:function(){this.unwatch()},computed:{ownTransports:function(){var t=this.transports[this.name]||[];return this.multiple?t:0===t.length?[]:[t[t.length-1]]},passengers:function(){return r(this.ownTransports,this.slotProps)},hasAttributes:function(){return Object.keys(this.attributes).length>0},withTransition:function(){return!!this.transition},transitionData:function(){var t=this.transition,e={};return this.firstRender&&"object"===i(this.transition)&&!this.transition.appear?(e.props={name:"__notranstition__portal-vue__"},e):("string"==typeof t?e.props={name:t}:"object"===(void 0===t?"undefined":i(t))&&(e.props=t),this.renderSlim&&(e.props.tag=this.tag),e.on=this.transitionEvents,e)},transportedClasses:function(){return this.ownTransports.map(function(t){return t.class}).reduce(function(t,e){return t.concat(e)},[])}},methods:{emitChange:function(t,e){if(this.multiple)this.$emit("change",[].concat(u(t)),[].concat(u(e)));else{var n=0===t.length?void 0:t[0],r=0===e.length?void 0:e[0];this.$emit("change",a({},n),a({},r))}},children:function(){return 0!==this.passengers.length?this.passengers:this.$slots.default||[]},noWrapper:function(){var t=!this.hasAttributes&&this.slim;return t&&this.children().length>1&&console.warn("[portal-vue]: PortalTarget with `slim` option received more than one child element."),t}},render:function(t){this.$options.abstract=!0;var e=this.noWrapper(),n=this.children(),r=e?"transition":"transition-group",s=this.tag;if(this.withTransition)return t(r,f([this.transitionData,{class:"vue-portal-target"}]),[n]);var o=this.ownTransports.length;return e?n[0]:t(s,f([{class:"vue-portal-target "+this.transportedClasses.join(" ")},this.attributes,{key:o}]),[n])}},g="undefined"!=typeof window,m=1,y={abstract:!1,name:"portal",props:{disabled:{type:Boolean,default:!1},name:{type:String,default:function(){return String(m++)}},order:{type:Number,default:0},slim:{type:Boolean,default:!1},slotProps:{type:Object,default:function(){return{}}},tag:{type:[String],default:"DIV"},targetEl:{type:g?[String,HTMLElement]:String},targetClass:{type:String},to:{type:String,default:function(){return String(Math.round(1e7*Math.random()))}}},mounted:function(){this.targetEl&&this.mountToTarget(),this.disabled||this.sendUpdate(),this.$options.abstract&&(this.$options.abstract=!1)},updated:function(){this.disabled?this.clear():this.sendUpdate(),this.$options.abstract&&(this.$options.abstract=!1)},beforeDestroy:function(){this.clear(),this.mountedComp&&this.mountedComp.$destroy()},watch:{to:function(t,e){e&&e!==t&&this.clear(e),this.sendUpdate()},targetEl:function(t,e){t&&this.mountToTarget()}},methods:{normalizedSlots:function(){return this.$scopedSlots.default?[this.$scopedSlots.default]:this.$slots.default},sendUpdate:function(){var t=this.normalizedSlots();t?h.open({from:this.name,to:this.to,passengers:[].concat(u(t)),class:this.targetClass&&this.targetClass.split(" "),order:this.order}):this.clear()},clear:function(t){h.close({from:this.name,to:t||this.to})},mountToTarget:function(){var n=void 0,r=this.targetEl;if("string"==typeof r)n=document.querySelector(r);else{if(!(r instanceof HTMLElement))return void console.warn("[vue-portal]: value of targetEl must be of type String or HTMLElement");n=r}if(n){var s=new t(a({},d,{parent:this,propsData:{name:this.to,tag:n.tagName,attributes:e(n)}}));s.$mount(n),this.mountedComp=s}else console.warn("[vue-portal]: The specified targetEl "+r+" was not found")},normalizeChildren:function(t){return"function"==typeof t?t(this.slotProps):t}},render:function(t){var e=this.$slots.default||this.$scopedSlots.default||[],n=this.tag;return e.length&&this.disabled?(this.$options.abstract=!0,e.length<=1&&this.slim?e[0]:t(n,[this.normalizeChildren(e)])):t(n,{class:"v-portal",style:"display: none",key:"v-portal-placeholder"})}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use({install:o}),{install:o,Portal:y,PortalTarget:d,Wormhole:h}}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.PortalVue=e(t.Vue)}(this,function(t){"use strict";function e(t){for(var e=t.hasAttributes()?t.attributes:[],n={},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return t.reduce(function(t,n){var r=n.passengers[0];return r="function"==typeof r?r(e):n.passengers,t.concat(r)},[])}function s(t,e){return function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.component(e.portalName||"Portal",y),t.component(e.portalTargetName||"PortalTarget",d)}t=t&&t.hasOwnProperty("default")?t.default:t;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]&&arguments[1],n=t.to,r=t.from;if(n&&r&&this.transports[n])if(e)this.transports[n]=[];else{var s=this.getTransportIndex(t);if(s>=0){var o=this.transports[n].slice(0);o.splice(s,1),this.transports[n]=o}}},hasTarget:function(t){return this.transports.hasOwnProperty(t)},hasContentFor:function(t){return!!this.transports[t]&&this.getContentFor(t).length>0},getSourceFor:function(t){return this.transports[t]&&this.transports[t][0].from},getContentFor:function(t){var e=this.transports[t];if(e)return r(e)},getTransportIndex:function(t){var e=t.to,n=t.from;for(var r in this.transports[e])if(this.transports[e][r].from===n)return r;return-1}}}),p=new h(l),c=/^(attrs|props|on|nativeOn|class|style|hook)$/,f=function(t){return t.reduce(function(t,e){var n,r,o,i,a;for(o in e)if(n=t[o],r=e[o],n&&c.test(o))if("class"===o&&("string"==typeof n&&(a=n,t[o]=n={},n[a]=!0),"string"==typeof r&&(a=r,e[o]=r={},r[a]=!0)),"on"===o||"nativeOn"===o||"hook"===o)for(i in r)n[i]=s(n[i],r[i]);else if(Array.isArray(n))t[o]=n.concat(r);else if(Array.isArray(r))t[o]=[n].concat(r);else for(i in r)n[i]=r[i];else t[o]=e[o];return t},{})},d={abstract:!1,name:"portalTarget",props:{attributes:{type:Object,default:function(){return{}}},multiple:{type:Boolean,default:!1},name:{type:String,required:!0},slim:{type:Boolean,default:!1},slotProps:{type:Object,default:function(){return{}}},tag:{type:String,default:"div"},transition:{type:[Boolean,String,Object],default:!1},transitionEvents:{type:Object,default:function(){return{}}}},data:function(){return{transports:p.transports,firstRender:!0}},created:function(){this.transports[this.name]||this.$set(this.transports,this.name,[])},mounted:function(){var t=this;this.unwatch=this.$watch("ownTransports",this.emitChange),this.$nextTick(function(){t.transition&&(t.firstRender=!1)}),this.$options.abstract&&(this.$options.abstract=!1)},updated:function(){this.$options.abstract&&(this.$options.abstract=!1)},beforeDestroy:function(){this.unwatch()},computed:{ownTransports:function(){var t=this.transports[this.name]||[];return this.multiple?t:0===t.length?[]:[t[t.length-1]]},passengers:function(){return r(this.ownTransports,this.slotProps)},hasAttributes:function(){return Object.keys(this.attributes).length>0},withTransition:function(){return!!this.transition},transitionData:function(){var t=this.transition,e={};return this.firstRender&&"object"===i(this.transition)&&!this.transition.appear?(e.props={name:"__notranstition__portal-vue__"},e):("string"==typeof t?e.props={name:t}:"object"===(void 0===t?"undefined":i(t))&&(e.props=t),this.renderSlim&&(e.props.tag=this.tag),e.on=this.transitionEvents,e)},transportedClasses:function(){return this.ownTransports.map(function(t){return t.class}).reduce(function(t,e){return t.concat(e)},[])}},methods:{emitChange:function(t,e){if(this.multiple)this.$emit("change",[].concat(u(t)),[].concat(u(e)));else{var n=0===t.length?void 0:t[0],r=0===e.length?void 0:e[0];this.$emit("change",a({},n),a({},r))}},children:function(){return 0!==this.passengers.length?this.passengers:this.$slots.default||[]},noWrapper:function(){var t=!this.hasAttributes&&this.slim;return t&&this.children().length>1&&console.warn("[portal-vue]: PortalTarget with `slim` option received more than one child element."),t}},render:function(t){this.$options.abstract=!0;var e=this.noWrapper(),n=this.children(),r=e?"transition":"transition-group",s=this.tag;if(this.withTransition)return t(r,f([this.transitionData,{class:"vue-portal-target"}]),[n]);var o=this.ownTransports.length;return e?n[0]:t(s,f([{class:"vue-portal-target "+this.transportedClasses.join(" ")},this.attributes,{key:o}]),[n])}},g="undefined"!=typeof window,m=1,y={abstract:!1,name:"portal",props:{disabled:{type:Boolean,default:!1},name:{type:String,default:function(){return String(m++)}},order:{type:Number,default:0},slim:{type:Boolean,default:!1},slotProps:{type:Object,default:function(){return{}}},tag:{type:[String],default:"DIV"},targetEl:{type:g?[String,HTMLElement]:String},targetClass:{type:String},to:{type:String,default:function(){return String(Math.round(1e7*Math.random()))}}},mounted:function(){this.targetEl&&this.mountToTarget(),this.disabled||this.sendUpdate(),this.$options.abstract&&(this.$options.abstract=!1)},updated:function(){this.disabled?this.clear():this.sendUpdate(),this.$options.abstract&&(this.$options.abstract=!1)},beforeDestroy:function(){this.clear(),this.mountedComp&&this.mountedComp.$destroy()},watch:{to:function(t,e){e&&e!==t&&this.clear(e),this.sendUpdate()},targetEl:function(t,e){t&&this.mountToTarget()}},methods:{normalizedSlots:function(){return this.$scopedSlots.default?[this.$scopedSlots.default]:this.$slots.default},sendUpdate:function(){var t=this.normalizedSlots();t?p.open({from:this.name,to:this.to,passengers:[].concat(u(t)),class:this.targetClass&&this.targetClass.split(" "),order:this.order}):this.clear()},clear:function(t){p.close({from:this.name,to:t||this.to})},mountToTarget:function(){var n=void 0,r=this.targetEl;if("string"==typeof r)n=document.querySelector(r);else{if(!(r instanceof HTMLElement))return void console.warn("[vue-portal]: value of targetEl must be of type String or HTMLElement");n=r}if(n){var s=new t(a({},d,{parent:this,propsData:{name:this.to,tag:n.tagName,attributes:e(n)}}));s.$mount(n),this.mountedComp=s}else console.warn("[vue-portal]: The specified targetEl "+r+" was not found")},normalizeChildren:function(t){return"function"==typeof t?t(this.slotProps):t}},render:function(t){var e=this.$slots.default||this.$scopedSlots.default||[],n=this.tag;return e.length&&this.disabled?(this.$options.abstract=!0,e.length<=1&&this.slim?e[0]:t(n,[this.normalizeChildren(e)])):t(n,{class:"v-portal",style:"display: none",key:"v-portal-placeholder"})}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use({install:o}),{install:o,Portal:y,PortalTarget:d,Wormhole:p}}); diff --git a/src/index.js b/src/index.js index 3e38e79..070b176 100644 --- a/src/index.js +++ b/src/index.js @@ -3,8 +3,8 @@ import PortalTarget from './components/portal-target.js' import Wormhole from './components/wormhole.js' function install(Vue, opts = {}) { - Vue.component(opts.portalName || 'portal', Portal) - Vue.component(opts.portalTargetName || 'portalTarget', PortalTarget) + Vue.component(opts.portalName || 'Portal', Portal) + Vue.component(opts.portalTargetName || 'PortalTarget', PortalTarget) } if (typeof window !== 'undefined' && window.Vue) { window.Vue.use({ install: install })