filepond-plugin-file-validate-size
Advanced tools
Comparing version 2.2.3 to 2.2.4
/*! | ||
* FilePondPluginFileValidateSize 2.2.3 | ||
* FilePondPluginFileValidateSize 2.2.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -10,153 +10,141 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
const plugin = ({ addFilter, utils }) => { | ||
// get quick reference to Type utils | ||
const { Type, replaceInString, toNaturalFileSize } = utils; | ||
// get quick reference to Type utils | ||
const { Type, replaceInString, toNaturalFileSize } = utils; | ||
// filtering if an item is allowed in hopper | ||
addFilter('ALLOW_HOPPER_ITEM', (file, { query }) => { | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return true; | ||
} | ||
const sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
return false; | ||
} | ||
const sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
return false; | ||
} | ||
return true; | ||
}); | ||
// called for each file that is loaded | ||
// right before it is set to the item state | ||
// should return a promise | ||
addFilter( | ||
'LOAD_FILE', | ||
(file, { query }) => | ||
new Promise((resolve, reject) => { | ||
// if not allowed, all fine, exit | ||
// filtering if an item is allowed in hopper | ||
addFilter('ALLOW_HOPPER_ITEM', (file, { query }) => { | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return resolve(file); | ||
return true; | ||
} | ||
// check if file should be filtered | ||
const fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
// reject or resolve based on file size | ||
const sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMax, | ||
'.', | ||
root.query('GET_FILE_SIZE_BASE') | ||
) | ||
}) | ||
} | ||
}); | ||
return; | ||
return false; | ||
} | ||
// reject or resolve based on file size | ||
const sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMin, | ||
'.', | ||
root.query('GET_FILE_SIZE_BASE') | ||
) | ||
}) | ||
} | ||
}); | ||
return; | ||
return false; | ||
} | ||
// returns the current option value | ||
const totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE'); | ||
if (totalSizeMax !== null) { | ||
// get the current total file size | ||
const currentTotalSize = query('GET_ACTIVE_ITEMS').reduce( | ||
(total, item) => { | ||
return total + item.fileSize; | ||
}, | ||
0 | ||
); | ||
return true; | ||
}); | ||
// get the size of the new file | ||
if (currentTotalSize > totalSizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_TOTAL_FILE_SIZE'), { | ||
filesize: toNaturalFileSize(totalSizeMax) | ||
}) | ||
} | ||
}); | ||
return; | ||
} | ||
} | ||
// called for each file that is loaded | ||
// right before it is set to the item state | ||
// should return a promise | ||
addFilter( | ||
'LOAD_FILE', | ||
(file, { query }) => | ||
new Promise((resolve, reject) => { | ||
// if not allowed, all fine, exit | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return resolve(file); | ||
} | ||
// file is fine, let's pass it back | ||
resolve(file); | ||
}) | ||
); | ||
// check if file should be filtered | ||
const fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
return { | ||
options: { | ||
// Enable or disable file type validation | ||
allowFileSizeValidation: [true, Type.BOOLEAN], | ||
// reject or resolve based on file size | ||
const sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMax, | ||
'.', | ||
query('GET_FILE_SIZE_BASE') | ||
), | ||
}), | ||
}, | ||
}); | ||
return; | ||
} | ||
// Max individual file size in bytes | ||
maxFileSize: [null, Type.INT], | ||
// reject or resolve based on file size | ||
const sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMin, | ||
'.', | ||
query('GET_FILE_SIZE_BASE') | ||
), | ||
}), | ||
}, | ||
}); | ||
return; | ||
} | ||
// Min individual file size in bytes | ||
minFileSize: [null, Type.INT], | ||
// returns the current option value | ||
const totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE'); | ||
if (totalSizeMax !== null) { | ||
// get the current total file size | ||
const currentTotalSize = query('GET_ACTIVE_ITEMS').reduce((total, item) => { | ||
return total + item.fileSize; | ||
}, 0); | ||
// Max total file size in bytes | ||
maxTotalFileSize: [null, Type.INT], | ||
// get the size of the new file | ||
if (currentTotalSize > totalSizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_TOTAL_FILE_SIZE'), { | ||
filesize: toNaturalFileSize(totalSizeMax), | ||
}), | ||
}, | ||
}); | ||
return; | ||
} | ||
} | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
// file is fine, let's pass it back | ||
resolve(file); | ||
}) | ||
); | ||
// error labels | ||
labelMinFileSizeExceeded: ['File is too small', Type.STRING], | ||
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING], | ||
return { | ||
options: { | ||
// Enable or disable file type validation | ||
allowFileSizeValidation: [true, Type.BOOLEAN], | ||
labelMaxFileSizeExceeded: ['File is too large', Type.STRING], | ||
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING], | ||
// Max individual file size in bytes | ||
maxFileSize: [null, Type.INT], | ||
labelMaxTotalFileSizeExceeded: [ | ||
'Maximum total size exceeded', | ||
Type.STRING | ||
], | ||
labelMaxTotalFileSize: [ | ||
'Maximum total file size is {filesize}', | ||
Type.STRING | ||
] | ||
} | ||
}; | ||
// Min individual file size in bytes | ||
minFileSize: [null, Type.INT], | ||
// Max total file size in bytes | ||
maxTotalFileSize: [null, Type.INT], | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
// error labels | ||
labelMinFileSizeExceeded: ['File is too small', Type.STRING], | ||
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING], | ||
labelMaxFileSizeExceeded: ['File is too large', Type.STRING], | ||
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING], | ||
labelMaxTotalFileSizeExceeded: ['Maximum total size exceeded', Type.STRING], | ||
labelMaxTotalFileSize: ['Maximum total file size is {filesize}', Type.STRING], | ||
}, | ||
}; | ||
}; | ||
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags | ||
const isBrowser = | ||
typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
if (isBrowser) { | ||
document.dispatchEvent( | ||
new CustomEvent('FilePond:pluginloaded', { detail: plugin }) | ||
); | ||
document.dispatchEvent(new CustomEvent('FilePond:pluginloaded', { detail: plugin })); | ||
} | ||
export default plugin; |
/*! | ||
* FilePondPluginFileValidateSize 2.2.3 | ||
* FilePondPluginFileValidateSize 2.2.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
const e=({addFilter:e,utils:i})=>{const{Type:E,replaceInString:l,toNaturalFileSize:_}=i;return e("ALLOW_HOPPER_ITEM",(e,{query:i})=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;const E=i("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;const l=i("GET_MIN_FILE_SIZE");return!(null!==l&&e.size<=l)}),e("LOAD_FILE",(e,{query:i})=>new Promise((E,I)=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return E(e);const t=i("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return E(e);const n=i("GET_MAX_FILE_SIZE");if(null!==n&&e.size>=n)return void I({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(n,".",root.query("GET_FILE_SIZE_BASE"))})}});const L=i("GET_MIN_FILE_SIZE");if(null!==L&&e.size<=L)return void I({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(L,".",root.query("GET_FILE_SIZE_BASE"))})}});const T=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==T){if(i("GET_ACTIVE_ITEMS").reduce((e,i)=>e+i.fileSize,0)>T)return void I({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(T)})}})}E(e)})),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],fileValidateSizeFilter:[null,E.FUNCTION],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e}));export default e; | ||
const e=({addFilter:e,utils:i})=>{const{Type:E,replaceInString:l,toNaturalFileSize:_}=i;return e("ALLOW_HOPPER_ITEM",(e,{query:i})=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;const E=i("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;const l=i("GET_MIN_FILE_SIZE");return!(null!==l&&e.size<=l)}),e("LOAD_FILE",(e,{query:i})=>new Promise((E,I)=>{if(!i("GET_ALLOW_FILE_SIZE_VALIDATION"))return E(e);const t=i("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return E(e);const n=i("GET_MAX_FILE_SIZE");if(null!==n&&e.size>=n)return void I({status:{main:i("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_FILE_SIZE"),{filesize:_(n,".",i("GET_FILE_SIZE_BASE"))})}});const L=i("GET_MIN_FILE_SIZE");if(null!==L&&e.size<=L)return void I({status:{main:i("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MIN_FILE_SIZE"),{filesize:_(L,".",i("GET_FILE_SIZE_BASE"))})}});const T=i("GET_MAX_TOTAL_FILE_SIZE");if(null!==T){if(i("GET_ACTIVE_ITEMS").reduce((e,i)=>e+i.fileSize,0)>T)return void I({status:{main:i("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:l(i("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:_(T)})}})}E(e)})),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],fileValidateSizeFilter:[null,E.FUNCTION],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e}));export default e; |
/*! | ||
* FilePondPluginFileValidateSize 2.2.3 | ||
* FilePondPluginFileValidateSize 2.2.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -10,174 +10,158 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
(function(global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' | ||
? (module.exports = factory()) | ||
: typeof define === 'function' && define.amd | ||
? define(factory) | ||
: ((global = global || self), | ||
(global.FilePondPluginFileValidateSize = factory())); | ||
typeof exports === 'object' && typeof module !== 'undefined' | ||
? (module.exports = factory()) | ||
: typeof define === 'function' && define.amd | ||
? define(factory) | ||
: ((global = global || self), (global.FilePondPluginFileValidateSize = factory())); | ||
})(this, function() { | ||
'use strict'; | ||
'use strict'; | ||
var plugin = function plugin(_ref) { | ||
var addFilter = _ref.addFilter, | ||
utils = _ref.utils; | ||
// get quick reference to Type utils | ||
var Type = utils.Type, | ||
replaceInString = utils.replaceInString, | ||
toNaturalFileSize = utils.toNaturalFileSize; | ||
var plugin = function plugin(_ref) { | ||
var addFilter = _ref.addFilter, | ||
utils = _ref.utils; | ||
// get quick reference to Type utils | ||
var Type = utils.Type, | ||
replaceInString = utils.replaceInString, | ||
toNaturalFileSize = utils.toNaturalFileSize; | ||
// filtering if an item is allowed in hopper | ||
addFilter('ALLOW_HOPPER_ITEM', function(file, _ref2) { | ||
var query = _ref2.query; | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return true; | ||
} | ||
// filtering if an item is allowed in hopper | ||
addFilter('ALLOW_HOPPER_ITEM', function(file, _ref2) { | ||
var query = _ref2.query; | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return true; | ||
} | ||
var sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
return false; | ||
} | ||
var sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
return false; | ||
} | ||
var sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
return false; | ||
} | ||
var sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
return false; | ||
} | ||
return true; | ||
}); | ||
return true; | ||
}); | ||
// called for each file that is loaded | ||
// right before it is set to the item state | ||
// should return a promise | ||
addFilter('LOAD_FILE', function(file, _ref3) { | ||
var query = _ref3.query; | ||
return new Promise(function(resolve, reject) { | ||
// if not allowed, all fine, exit | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return resolve(file); | ||
} | ||
// called for each file that is loaded | ||
// right before it is set to the item state | ||
// should return a promise | ||
addFilter('LOAD_FILE', function(file, _ref3) { | ||
var query = _ref3.query; | ||
return new Promise(function(resolve, reject) { | ||
// if not allowed, all fine, exit | ||
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) { | ||
return resolve(file); | ||
} | ||
// check if file should be filtered | ||
var fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
// check if file should be filtered | ||
var fileFilter = query('GET_FILE_VALIDATE_SIZE_FILTER'); | ||
if (fileFilter && !fileFilter(file)) { | ||
return resolve(file); | ||
} | ||
// reject or resolve based on file size | ||
var sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMax, | ||
'.', | ||
root.query('GET_FILE_SIZE_BASE') | ||
) | ||
}) | ||
} | ||
}); | ||
// reject or resolve based on file size | ||
var sizeMax = query('GET_MAX_FILE_SIZE'); | ||
if (sizeMax !== null && file.size >= sizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMax, | ||
'.', | ||
query('GET_FILE_SIZE_BASE') | ||
), | ||
}), | ||
}, | ||
}); | ||
return; | ||
} | ||
return; | ||
} | ||
// reject or resolve based on file size | ||
var sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMin, | ||
'.', | ||
root.query('GET_FILE_SIZE_BASE') | ||
) | ||
}) | ||
} | ||
}); | ||
// reject or resolve based on file size | ||
var sizeMin = query('GET_MIN_FILE_SIZE'); | ||
if (sizeMin !== null && file.size <= sizeMin) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MIN_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MIN_FILE_SIZE'), { | ||
filesize: toNaturalFileSize( | ||
sizeMin, | ||
'.', | ||
query('GET_FILE_SIZE_BASE') | ||
), | ||
}), | ||
}, | ||
}); | ||
return; | ||
} | ||
return; | ||
} | ||
// returns the current option value | ||
var totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE'); | ||
if (totalSizeMax !== null) { | ||
// get the current total file size | ||
var currentTotalSize = query('GET_ACTIVE_ITEMS').reduce(function( | ||
total, | ||
item | ||
) { | ||
return total + item.fileSize; | ||
}, | ||
0); | ||
// returns the current option value | ||
var totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE'); | ||
if (totalSizeMax !== null) { | ||
// get the current total file size | ||
var currentTotalSize = query('GET_ACTIVE_ITEMS').reduce(function(total, item) { | ||
return total + item.fileSize; | ||
}, 0); | ||
// get the size of the new file | ||
if (currentTotalSize > totalSizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED'), | ||
// get the size of the new file | ||
if (currentTotalSize > totalSizeMax) { | ||
reject({ | ||
status: { | ||
main: query('GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED'), | ||
sub: replaceInString(query('GET_LABEL_MAX_TOTAL_FILE_SIZE'), { | ||
filesize: toNaturalFileSize(totalSizeMax), | ||
}), | ||
}, | ||
}); | ||
sub: replaceInString(query('GET_LABEL_MAX_TOTAL_FILE_SIZE'), { | ||
filesize: toNaturalFileSize(totalSizeMax) | ||
}) | ||
} | ||
return; | ||
} | ||
} | ||
// file is fine, let's pass it back | ||
resolve(file); | ||
}); | ||
}); | ||
return; | ||
} | ||
} | ||
return { | ||
options: { | ||
// Enable or disable file type validation | ||
allowFileSizeValidation: [true, Type.BOOLEAN], | ||
// file is fine, let's pass it back | ||
resolve(file); | ||
}); | ||
}); | ||
// Max individual file size in bytes | ||
maxFileSize: [null, Type.INT], | ||
return { | ||
options: { | ||
// Enable or disable file type validation | ||
allowFileSizeValidation: [true, Type.BOOLEAN], | ||
// Min individual file size in bytes | ||
minFileSize: [null, Type.INT], | ||
// Max individual file size in bytes | ||
maxFileSize: [null, Type.INT], | ||
// Max total file size in bytes | ||
maxTotalFileSize: [null, Type.INT], | ||
// Min individual file size in bytes | ||
minFileSize: [null, Type.INT], | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
// Max total file size in bytes | ||
maxTotalFileSize: [null, Type.INT], | ||
// error labels | ||
labelMinFileSizeExceeded: ['File is too small', Type.STRING], | ||
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING], | ||
// Filter the files that need to be validated for size | ||
fileValidateSizeFilter: [null, Type.FUNCTION], | ||
labelMaxFileSizeExceeded: ['File is too large', Type.STRING], | ||
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING], | ||
// error labels | ||
labelMinFileSizeExceeded: ['File is too small', Type.STRING], | ||
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING], | ||
labelMaxFileSizeExceeded: ['File is too large', Type.STRING], | ||
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING], | ||
labelMaxTotalFileSizeExceeded: [ | ||
'Maximum total size exceeded', | ||
Type.STRING | ||
], | ||
labelMaxTotalFileSize: [ | ||
'Maximum total file size is {filesize}', | ||
Type.STRING | ||
] | ||
} | ||
labelMaxTotalFileSizeExceeded: ['Maximum total size exceeded', Type.STRING], | ||
labelMaxTotalFileSize: ['Maximum total file size is {filesize}', Type.STRING], | ||
}, | ||
}; | ||
}; | ||
}; | ||
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags | ||
var isBrowser = | ||
typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
if (isBrowser) { | ||
document.dispatchEvent( | ||
new CustomEvent('FilePond:pluginloaded', { detail: plugin }) | ||
); | ||
} | ||
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags | ||
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
if (isBrowser) { | ||
document.dispatchEvent(new CustomEvent('FilePond:pluginloaded', { detail: plugin })); | ||
} | ||
return plugin; | ||
return plugin; | ||
}); |
/*! | ||
* FilePondPluginFileValidateSize 2.2.3 | ||
* FilePondPluginFileValidateSize 2.2.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e=e||self).FilePondPluginFileValidateSize=i()}(this,function(){"use strict";var e=function(e){var i=e.addFilter,l=e.utils,E=l.Type,_=l.replaceInString,n=l.toNaturalFileSize;return i("ALLOW_HOPPER_ITEM",function(e,i){var l=i.query;if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var E=l("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;var _=l("GET_MIN_FILE_SIZE");return!(null!==_&&e.size<=_)}),i("LOAD_FILE",function(e,i){var l=i.query;return new Promise(function(i,E){if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return i(e);var t=l("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return i(e);var I=l("GET_MAX_FILE_SIZE");if(null!==I&&e.size>=I)E({status:{main:l("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MAX_FILE_SIZE"),{filesize:n(I,".",root.query("GET_FILE_SIZE_BASE"))})}});else{var u=l("GET_MIN_FILE_SIZE");if(null!==u&&e.size<=u)E({status:{main:l("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MIN_FILE_SIZE"),{filesize:n(u,".",root.query("GET_FILE_SIZE_BASE"))})}});else{var a=l("GET_MAX_TOTAL_FILE_SIZE");if(null!==a)if(l("GET_ACTIVE_ITEMS").reduce(function(e,i){return e+i.fileSize},0)>a)return void E({status:{main:l("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:n(a)})}});i(e)}}})}),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],fileValidateSizeFilter:[null,E.FUNCTION],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e=e||self).FilePondPluginFileValidateSize=i()}(this,function(){"use strict";var e=function(e){var i=e.addFilter,l=e.utils,E=l.Type,_=l.replaceInString,n=l.toNaturalFileSize;return i("ALLOW_HOPPER_ITEM",function(e,i){var l=i.query;if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var E=l("GET_MAX_FILE_SIZE");if(null!==E&&e.size>=E)return!1;var _=l("GET_MIN_FILE_SIZE");return!(null!==_&&e.size<=_)}),i("LOAD_FILE",function(e,i){var l=i.query;return new Promise(function(i,E){if(!l("GET_ALLOW_FILE_SIZE_VALIDATION"))return i(e);var t=l("GET_FILE_VALIDATE_SIZE_FILTER");if(t&&!t(e))return i(e);var I=l("GET_MAX_FILE_SIZE");if(null!==I&&e.size>=I)E({status:{main:l("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MAX_FILE_SIZE"),{filesize:n(I,".",l("GET_FILE_SIZE_BASE"))})}});else{var a=l("GET_MIN_FILE_SIZE");if(null!==a&&e.size<=a)E({status:{main:l("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MIN_FILE_SIZE"),{filesize:n(a,".",l("GET_FILE_SIZE_BASE"))})}});else{var u=l("GET_MAX_TOTAL_FILE_SIZE");if(null!==u)if(l("GET_ACTIVE_ITEMS").reduce(function(e,i){return e+i.fileSize},0)>u)return void E({status:{main:l("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:_(l("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:n(u)})}});i(e)}}})}),{options:{allowFileSizeValidation:[!0,E.BOOLEAN],maxFileSize:[null,E.INT],minFileSize:[null,E.INT],maxTotalFileSize:[null,E.INT],fileValidateSizeFilter:[null,E.FUNCTION],labelMinFileSizeExceeded:["File is too small",E.STRING],labelMinFileSize:["Minimum file size is {filesize}",E.STRING],labelMaxFileSizeExceeded:["File is too large",E.STRING],labelMaxFileSize:["Maximum file size is {filesize}",E.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",E.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",E.STRING]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); |
{ | ||
"name": "filepond-plugin-file-validate-size", | ||
"version": "2.2.3", | ||
"description": "File Size Validation Plugin for FilePond", | ||
"license": "MIT", | ||
"author": { | ||
"name": "PQINA", | ||
"url": "https://pqina.nl/" | ||
}, | ||
"homepage": "https://pqina.nl/filepond/", | ||
"repository": "pqina/filepond-plugin-file-validate-size", | ||
"main": "dist/filepond-plugin-file-validate-size.js", | ||
"browser": "dist/filepond-plugin-file-validate-size.js", | ||
"module": "dist/filepond-plugin-file-validate-size.esm.js", | ||
"browserslist": [ | ||
"last 1 version and not Explorer 10", | ||
"Explorer 11", | ||
"iOS >= 9", | ||
"Android >= 4.4" | ||
], | ||
"files": [ | ||
"dist", | ||
"types/*.d.ts" | ||
], | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"start": "npx rollup -c -w", | ||
"build": "npx rollup -c" | ||
}, | ||
"peerDependencies": { | ||
"filepond": ">=3.1.2 <5.x" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.0", | ||
"@babel/preset-env": "^7.4.2", | ||
"rollup": "^1.7.0", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-license": "^0.8.1", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-prettier": "^0.6.0", | ||
"rollup-plugin-terser": "^4.0.4" | ||
} | ||
"name": "filepond-plugin-file-validate-size", | ||
"version": "2.2.4", | ||
"description": "File Size Validation Plugin for FilePond", | ||
"license": "MIT", | ||
"author": { | ||
"name": "PQINA", | ||
"url": "https://pqina.nl/" | ||
}, | ||
"homepage": "https://pqina.nl/filepond/", | ||
"repository": "pqina/filepond-plugin-file-validate-size", | ||
"main": "dist/filepond-plugin-file-validate-size.js", | ||
"browser": "dist/filepond-plugin-file-validate-size.js", | ||
"module": "dist/filepond-plugin-file-validate-size.esm.js", | ||
"browserslist": [ | ||
"last 1 version and not Explorer 10", | ||
"Explorer 11", | ||
"iOS >= 9", | ||
"Android >= 4.4" | ||
], | ||
"files": [ | ||
"dist", | ||
"types/*.d.ts" | ||
], | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"start": "npx rollup -c -w", | ||
"build": "npx rollup -c" | ||
}, | ||
"peerDependencies": { | ||
"filepond": ">=3.1.2 <5.x" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.0", | ||
"@babel/preset-env": "^7.4.2", | ||
"rollup": "^1.7.0", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-license": "^0.8.1", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-prettier": "^0.6.0", | ||
"rollup-plugin-terser": "^4.0.4" | ||
} | ||
} |
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
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
20025
312