Socket
Socket
Sign inDemoInstall

@uppy/provider-views

Package Overview
Dependencies
Maintainers
5
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/provider-views - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

23

lib/Browser.js

@@ -15,11 +15,17 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var Browser = function Browser(props) {
var filteredFolders = props.folders;
var filteredFiles = props.files;
var currentSelection = props.currentSelection,
folders = props.folders,
files = props.files,
uppyFiles = props.uppyFiles,
filterItems = props.filterItems,
filterInput = props.filterInput;
var filteredFolders = folders;
var filteredFiles = files;
if (props.filterInput !== '') {
filteredFolders = props.filterItems(props.folders);
filteredFiles = props.filterItems(props.files);
if (filterInput !== '') {
filteredFolders = filterItems(folders);
filteredFiles = filterItems(files);
}
var selected = props.currentSelection.length;
var selected = currentSelection.length;
return h("div", {

@@ -47,3 +53,6 @@ class: classNames('uppy-ProviderBrowser', "uppy-ProviderBrowser-viewType--" + props.viewType)

i18n: props.i18n,
viewType: props.viewType
viewType: props.viewType,
validateRestrictions: props.validateRestrictions,
uppyFiles: uppyFiles,
currentSelection: currentSelection
}), selected > 0 && h(FooterActions, _extends({

@@ -50,0 +59,0 @@ selected: selected

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var _require = require('preact'),
h = _require.h,
Component = _require.Component;

@@ -6,0 +5,0 @@

@@ -7,3 +7,4 @@ var _require = require('preact'),

return h("li", {
class: props.className
class: props.className,
title: props.isDisabled ? props.restrictionReason : null
}, h("div", {

@@ -24,4 +25,5 @@ "aria-hidden": true,

"aria-disabled": props.isDisabled,
disabled: props.isDisabled,
"data-uppy-super-focusable": true
}, props.itemIconEl, props.showTitles && props.title));
};

@@ -36,3 +36,4 @@ var _require = require('preact'),

return h("li", {
class: props.className
class: props.className,
title: props.isDisabled ? props.restrictionReason : null
}, h("button", {

@@ -48,2 +49,3 @@ type: "button",

"aria-disabled": props.isDisabled,
disabled: props.isDisabled,
"data-uppy-super-focusable": true

@@ -53,4 +55,6 @@ }), props.type === 'file' ? // label for a checkbox

for: props.id,
className: "uppy-u-reset uppy-ProviderBrowserItem-inner"
}, props.itemIconEl, props.showTitles && props.title) : // button to open a folder
class: "uppy-u-reset uppy-ProviderBrowserItem-inner"
}, h("div", {
class: "uppy-ProviderBrowserItem-iconWrap"
}, props.itemIconEl), props.showTitles && props.title) : // button to open a folder
h("button", {

@@ -63,3 +67,5 @@ type: "button",

})
}, props.itemIconEl, props.showTitles && h("span", null, props.title)));
}, h("div", {
class: "uppy-ProviderBrowserItem-iconWrap"
}, props.itemIconEl), props.showTitles && h("span", null, props.title)));
};

@@ -19,2 +19,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

}, {
'uppy-ProviderBrowserItem--disabled': props.isDisabled
}, {
'uppy-ProviderBrowserItem--noPreview': itemIconString === 'video'

@@ -21,0 +23,0 @@ });

@@ -6,2 +6,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var remoteFileObjToLocal = require('@uppy/utils/lib/remoteFileObjToLocal');
var Item = require('./Item/index');

@@ -51,7 +53,11 @@

}), props.files.map(function (file) {
return Item(_extends({}, getSharedProps(file, props), {
var validateRestrictions = props.validateRestrictions(remoteFileObjToLocal(file), [].concat(props.uppyFiles, props.currentSelection));
var sharedProps = getSharedProps(file, props);
var restrictionReason = validateRestrictions.reason;
return Item(_extends({}, sharedProps, {
type: 'file',
isDisabled: false
isDisabled: !validateRestrictions.result && !sharedProps.isChecked,
restrictionReason: restrictionReason
}));
})));
};

@@ -651,3 +651,5 @@ var _class, _temp;

pluginIcon: this.plugin.icon,
i18n: this.plugin.uppy.i18n
i18n: this.plugin.uppy.i18n,
uppyFiles: this.plugin.uppy.getFiles(),
validateRestrictions: this.plugin.uppy.validateRestrictions
});

@@ -661,2 +663,2 @@

return ProviderView;
}(), _class.VERSION = "1.8.0", _temp);
}(), _class.VERSION = "1.9.0", _temp);

@@ -279,3 +279,5 @@ var _class, _temp;

pluginIcon: this.plugin.icon,
i18n: this.plugin.uppy.i18n
i18n: this.plugin.uppy.i18n,
uppyFiles: this.plugin.uppy.getFiles(),
validateRestrictions: this.plugin.uppy.validateRestrictions
});

@@ -289,2 +291,2 @@

return ProviderView;
}(), _class.VERSION = "1.8.0", _temp);
}(), _class.VERSION = "1.9.0", _temp);

@@ -0,1 +1,3 @@

var remoteFileObjToLocal = require('@uppy/utils/lib/remoteFileObjToLocal');
module.exports = /*#__PURE__*/function () {

@@ -33,2 +35,4 @@ function SharedHandler(plugin) {

_proto.toggleCheckbox = function toggleCheckbox(e, file) {
var _this = this;
e.stopPropagation();

@@ -55,4 +59,19 @@ e.preventDefault();

_currentSelection = items.slice(currentIndex, prevIndex + 1);
}
} // Check restrictions on each file in currentSelection,
// reduce it to only contain files that pass restrictions
_currentSelection = _currentSelection.reduce(function (reducedCurrentSelection, item) {
var uppy = _this.plugin.uppy;
var validatedRestrictions = uppy.validateRestrictions(remoteFileObjToLocal(item), [].concat(uppy.getFiles(), reducedCurrentSelection));
if (!validatedRestrictions.result) {
uppy.info({
message: validatedRestrictions.reason
}, 'error', uppy.opts.infoTimeout);
return reducedCurrentSelection;
}
return [].concat(reducedCurrentSelection, [item]);
});
this.plugin.setPluginState({

@@ -94,6 +113,6 @@ currentSelection: _currentSelection

_proto.loaderWrapper = function loaderWrapper(promise, then, catch_) {
var _this = this;
var _this2 = this;
promise.then(function (result) {
_this.plugin.setPluginState({
_this2.plugin.setPluginState({
loading: false

@@ -104,3 +123,3 @@ });

}).catch(function (err) {
_this.plugin.setPluginState({
_this2.plugin.setPluginState({
loading: false

@@ -107,0 +126,0 @@ });

{
"name": "@uppy/provider-views",
"description": "View library for Uppy remote provider plugins.",
"version": "1.8.0",
"version": "1.9.0",
"license": "MIT",

@@ -22,3 +22,3 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/utils": "^3.2.4",
"@uppy/utils": "^3.2.5",
"classnames": "^2.2.6",

@@ -30,3 +30,3 @@ "preact": "8.2.9"

},
"gitHead": "84f7b4d37daa4c1dc98138a169189412af2ae498"
"gitHead": "3ff9ab042f3d22c8efd528de91b4179b0cc4b909"
}

@@ -8,11 +8,20 @@ const classNames = require('classnames')

const Browser = (props) => {
let filteredFolders = props.folders
let filteredFiles = props.files
const {
currentSelection,
folders,
files,
uppyFiles,
filterItems,
filterInput
} = props
if (props.filterInput !== '') {
filteredFolders = props.filterItems(props.folders)
filteredFiles = props.filterItems(props.files)
let filteredFolders = folders
let filteredFiles = files
if (filterInput !== '') {
filteredFolders = filterItems(folders)
filteredFiles = filterItems(files)
}
const selected = props.currentSelection.length
const selected = currentSelection.length

@@ -44,2 +53,5 @@ return (

viewType={props.viewType}
validateRestrictions={props.validateRestrictions}
uppyFiles={uppyFiles}
currentSelection={currentSelection}
/>

@@ -46,0 +58,0 @@ {selected > 0 && <FooterActions selected={selected} {...props} />}

@@ -1,2 +0,2 @@

const { h, Component } = require('preact')
const { Component } = require('preact')

@@ -3,0 +3,0 @@ module.exports = class CloseWrapper extends Component {

@@ -6,3 +6,3 @@ const { h } = require('preact')

return (
<li class={props.className}>
<li class={props.className} title={props.isDisabled ? props.restrictionReason : null}>
<div aria-hidden class={`uppy-ProviderBrowserItem-fakeCheckbox ${props.isChecked ? 'uppy-ProviderBrowserItem-fakeCheckbox--is-checked' : ''}`} />

@@ -13,3 +13,2 @@ <button

onclick={props.toggleCheckbox}
role="option"

@@ -19,2 +18,3 @@ aria-label={props.isChecked ? props.i18n('unselectFileNamed', { name: props.title }) : props.i18n('selectFileNamed', { name: props.title })}

aria-disabled={props.isDisabled}
disabled={props.isDisabled}
data-uppy-super-focusable

@@ -21,0 +21,0 @@ >

@@ -27,3 +27,3 @@ const { h } = require('preact')

return (
<li class={props.className}>
<li class={props.className} title={props.isDisabled ? props.restrictionReason : null}>
<button

@@ -39,2 +39,3 @@ type="button"

aria-disabled={props.isDisabled}
disabled={props.isDisabled}
data-uppy-super-focusable

@@ -45,4 +46,6 @@ />

// label for a checkbox
<label for={props.id} className="uppy-u-reset uppy-ProviderBrowserItem-inner">
{props.itemIconEl}
<label for={props.id} class="uppy-u-reset uppy-ProviderBrowserItem-inner">
<div class="uppy-ProviderBrowserItem-iconWrap">
{props.itemIconEl}
</div>
{props.showTitles && props.title}

@@ -58,3 +61,5 @@ </label>

>
{props.itemIconEl}
<div class="uppy-ProviderBrowserItem-iconWrap">
{props.itemIconEl}
</div>
{props.showTitles && <span>{props.title}</span>}

@@ -61,0 +66,0 @@ </button>

@@ -13,2 +13,3 @@ const { h } = require('preact')

{ 'uppy-ProviderBrowserItem--selected': props.isChecked },
{ 'uppy-ProviderBrowserItem--disabled': props.isDisabled },
{ 'uppy-ProviderBrowserItem--noPreview': itemIconString === 'video' }

@@ -15,0 +16,0 @@ )

const { h } = require('preact')
const remoteFileObjToLocal = require('@uppy/utils/lib/remoteFileObjToLocal')
const Item = require('./Item/index')

@@ -30,4 +31,4 @@

>
{props.folders.map(folder =>
Item({
{props.folders.map(folder => {
return Item({
...getSharedProps(folder, props),

@@ -38,10 +39,18 @@ type: 'folder',

})
)}
{props.files.map(file =>
Item({
...getSharedProps(file, props),
})}
{props.files.map(file => {
const validateRestrictions = props.validateRestrictions(
remoteFileObjToLocal(file),
[...props.uppyFiles, ...props.currentSelection]
)
const sharedProps = getSharedProps(file, props)
const restrictionReason = validateRestrictions.reason
return Item({
...sharedProps,
type: 'file',
isDisabled: false
isDisabled: !validateRestrictions.result && !sharedProps.isChecked,
restrictionReason: restrictionReason
})
)}
})}
</ul>

@@ -48,0 +57,0 @@ </div>

@@ -546,3 +546,5 @@ const { h } = require('preact')

pluginIcon: this.plugin.icon,
i18n: this.plugin.uppy.i18n
i18n: this.plugin.uppy.i18n,
uppyFiles: this.plugin.uppy.getFiles(),
validateRestrictions: this.plugin.uppy.validateRestrictions
})

@@ -549,0 +551,0 @@

@@ -238,3 +238,5 @@ const { h } = require('preact')

pluginIcon: this.plugin.icon,
i18n: this.plugin.uppy.i18n
i18n: this.plugin.uppy.i18n,
uppyFiles: this.plugin.uppy.getFiles(),
validateRestrictions: this.plugin.uppy.validateRestrictions
})

@@ -241,0 +243,0 @@

@@ -0,1 +1,3 @@

const remoteFileObjToLocal = require('@uppy/utils/lib/remoteFileObjToLocal')
module.exports = class SharedHandler {

@@ -45,2 +47,16 @@ constructor (plugin) {

}
// Check restrictions on each file in currentSelection,
// reduce it to only contain files that pass restrictions
currentSelection = currentSelection.reduce((reducedCurrentSelection, item) => {
const uppy = this.plugin.uppy
const validatedRestrictions = uppy.validateRestrictions(
remoteFileObjToLocal(item),
[...uppy.getFiles(), ...reducedCurrentSelection]
)
if (!validatedRestrictions.result) {
uppy.info({ message: validatedRestrictions.reason }, 'error', uppy.opts.infoTimeout)
return reducedCurrentSelection
}
return [...reducedCurrentSelection, item]
})
this.plugin.setPluginState({ currentSelection })

@@ -47,0 +63,0 @@ return

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc