vue-filepond
Advanced tools
Comparing version 2.0.1 to 2.1.0
/*! | ||
* vue-filepond v2.0.1 | ||
* vue-filepond v2.1.0 | ||
* A handy FilePond adapter component for Vue | ||
@@ -57,2 +57,17 @@ * | ||
// all active instances | ||
const instances = []; | ||
// global options | ||
let globalOptions = {}; | ||
export const setOptions = (options) => { | ||
globalOptions = Object.assign( | ||
globalOptions, | ||
options | ||
); | ||
instances.forEach(instance => { | ||
instance.setOptions(globalOptions); | ||
}); | ||
}; | ||
export default (...plugins) => { | ||
@@ -133,5 +148,10 @@ | ||
this._element, | ||
Object.assign(options, attrs, this.$options.propsData) | ||
Object.assign( | ||
globalOptions, | ||
options, | ||
attrs, | ||
this.$options.propsData | ||
) | ||
); | ||
// Copy instance method references to component instance | ||
@@ -143,2 +163,6 @@ Object.keys(this._pond) | ||
}); | ||
// Add to instances so we can apply global options when used | ||
instances.push(this._pond); | ||
}, | ||
@@ -153,3 +177,11 @@ | ||
// bye bye pond | ||
this._pond.destroy(); | ||
// remove from instances | ||
const index = instances.findIndex(this._pond); | ||
if (index >= 0) { | ||
instances.splice(index, 1); | ||
} | ||
} | ||
@@ -156,0 +188,0 @@ }); |
/*! | ||
* vue-filepond v2.0.1 | ||
* vue-filepond v2.1.0 | ||
* A handy FilePond adapter component for Vue | ||
@@ -16,2 +16,3 @@ * | ||
}); | ||
exports.setOptions = undefined; | ||
@@ -53,2 +54,14 @@ var _vue = require('vue'); | ||
// all active instances | ||
var instances = []; | ||
// global options | ||
var globalOptions = {}; | ||
var setOptions = exports.setOptions = function setOptions(options) { | ||
globalOptions = Object.assign(globalOptions, options); | ||
instances.forEach(function (instance) { | ||
instance.setOptions(globalOptions); | ||
}); | ||
}; | ||
exports.default = function () { | ||
@@ -136,3 +149,3 @@ | ||
// Create our pond | ||
this._pond = (0, _filepond.create)(this._element, Object.assign(options, attrs, this.$options.propsData)); | ||
this._pond = (0, _filepond.create)(this._element, Object.assign(globalOptions, options, attrs, this.$options.propsData)); | ||
@@ -145,2 +158,5 @@ // Copy instance method references to component instance | ||
}); | ||
// Add to instances so we can apply global options when used | ||
instances.push(this._pond); | ||
}, | ||
@@ -156,3 +172,10 @@ | ||
// bye bye pond | ||
this._pond.destroy(); | ||
// remove from instances | ||
var index = instances.findIndex(this._pond); | ||
if (index >= 0) { | ||
instances.splice(index, 1); | ||
} | ||
} | ||
@@ -159,0 +182,0 @@ }); |
/*! | ||
* vue-filepond v2.0.1 | ||
* vue-filepond v2.1.0 | ||
* A handy FilePond adapter component for Vue | ||
@@ -10,2 +10,2 @@ * | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _vue=require("vue"),_vue2=_interopRequireDefault(_vue),_filepond=require("filepond");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var filteredComponentMethods=["setOptions","on","off","onOnce","appendTo","insertAfter","insertBefore","isAttachedTo","replaceElement","restoreElement","destroy"],isSupported=(0,_filepond.supported)(),getNativeConstructorFromType=function(type){return{string:String,boolean:Boolean,array:Array,function:Function,int:Number,serverapi:Object}[type]},props={},events=[],watch={};exports.default=function(){_filepond.registerPlugin.apply(void 0,arguments),events.length=0;var _loop=function(prop){if(/^on/.test(prop))return events.push(prop),"continue";props[prop]=[String,getNativeConstructorFromType(_filepond.OptionTypes[prop])],watch[prop]=function(value){this._pond[prop]=value}};for(var prop in _filepond.OptionTypes)_loop(prop);return _vue2.default.component("FilePond",{name:"FilePond",props:props,watch:watch,render:function(h){return h("div",{class:{"filepond--wrapper":!0}},[h("input",{attrs:{id:this.id,name:this.name,type:"file",class:this.className,required:this.required,multiple:this.allowMultiple,accept:this.acceptedFileTypes,capture:this.captureMethod}})])},mounted:function(){var _this=this;if(isSupported){this._element=this.$el.querySelector("input");var options=events.reduce(function(obj,value){return obj[value]=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];_this.$emit.apply(_this,[value.substr(2)].concat(args))},obj},{}),attrs=Object.assign({},this.$attrs);this._pond=(0,_filepond.create)(this._element,Object.assign(options,attrs,this.$options.propsData)),Object.keys(this._pond).filter(function(key){return!filteredComponentMethods.includes(key)}).forEach(function(key){_this[key]=_this._pond[key]})}},beforeDestroy:function(){this._pond&&this._pond.destroy()}})}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setOptions=void 0;var _vue=require("vue"),_vue2=_interopRequireDefault(_vue),_filepond=require("filepond");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var filteredComponentMethods=["setOptions","on","off","onOnce","appendTo","insertAfter","insertBefore","isAttachedTo","replaceElement","restoreElement","destroy"],isSupported=(0,_filepond.supported)(),getNativeConstructorFromType=function(type){return{string:String,boolean:Boolean,array:Array,function:Function,int:Number,serverapi:Object}[type]},props={},events=[],watch={},instances=[],globalOptions={},setOptions=exports.setOptions=function(options){globalOptions=Object.assign(globalOptions,options),instances.forEach(function(instance){instance.setOptions(globalOptions)})};exports.default=function(){_filepond.registerPlugin.apply(void 0,arguments),events.length=0;var _loop=function(prop){if(/^on/.test(prop))return events.push(prop),"continue";props[prop]=[String,getNativeConstructorFromType(_filepond.OptionTypes[prop])],watch[prop]=function(value){this._pond[prop]=value}};for(var prop in _filepond.OptionTypes)_loop(prop);return _vue2.default.component("FilePond",{name:"FilePond",props:props,watch:watch,render:function(h){return h("div",{class:{"filepond--wrapper":!0}},[h("input",{attrs:{id:this.id,name:this.name,type:"file",class:this.className,required:this.required,multiple:this.allowMultiple,accept:this.acceptedFileTypes,capture:this.captureMethod}})])},mounted:function(){var _this=this;if(isSupported){this._element=this.$el.querySelector("input");var options=events.reduce(function(obj,value){return obj[value]=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];_this.$emit.apply(_this,[value.substr(2)].concat(args))},obj},{}),attrs=Object.assign({},this.$attrs);this._pond=(0,_filepond.create)(this._element,Object.assign(globalOptions,options,attrs,this.$options.propsData)),Object.keys(this._pond).filter(function(key){return!filteredComponentMethods.includes(key)}).forEach(function(key){_this[key]=_this._pond[key]}),instances.push(this._pond)}},beforeDestroy:function(){if(this._pond){this._pond.destroy();var index=instances.findIndex(this._pond);0<=index&&instances.splice(index,1)}}})}; |
@@ -47,2 +47,17 @@ import Vue from 'vue'; | ||
// all active instances | ||
const instances = []; | ||
// global options | ||
let globalOptions = {}; | ||
export const setOptions = (options) => { | ||
globalOptions = Object.assign( | ||
globalOptions, | ||
options | ||
); | ||
instances.forEach(instance => { | ||
instance.setOptions(globalOptions); | ||
}); | ||
}; | ||
export default (...plugins) => { | ||
@@ -123,5 +138,10 @@ | ||
this._element, | ||
Object.assign(options, attrs, this.$options.propsData) | ||
Object.assign( | ||
globalOptions, | ||
options, | ||
attrs, | ||
this.$options.propsData | ||
) | ||
); | ||
// Copy instance method references to component instance | ||
@@ -133,2 +153,6 @@ Object.keys(this._pond) | ||
}); | ||
// Add to instances so we can apply global options when used | ||
instances.push(this._pond); | ||
}, | ||
@@ -143,3 +167,11 @@ | ||
// bye bye pond | ||
this._pond.destroy(); | ||
// remove from instances | ||
const index = instances.findIndex(this._pond); | ||
if (index >= 0) { | ||
instances.splice(index, 1); | ||
} | ||
} | ||
@@ -146,0 +178,0 @@ }); |
{ | ||
"name": "vue-filepond", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "A handy FilePond adapter component for Vue", | ||
@@ -5,0 +5,0 @@ "homepage": "https://pqina.nl/filepond", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
22231
460