Socket
Socket
Sign inDemoInstall

@uppy/provider-views

Package Overview
Dependencies
Maintainers
6
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 2.0.0-alpha.0 to 2.0.0

2

lib/Browser.js

@@ -48,4 +48,2 @@ "use strict";

files: filteredFiles,
sortByTitle: props.sortByTitle,
sortByDate: props.sortByDate,
isChecked: props.isChecked,

@@ -52,0 +50,0 @@ handleFolderClick: props.getNextFolder,

6

lib/FooterActions.js

@@ -12,3 +12,4 @@ "use strict";

className: "uppy-u-reset uppy-c-btn uppy-c-btn-primary",
onClick: props.done
onClick: props.done,
type: "button"
}, props.i18n('selectX', {

@@ -18,4 +19,5 @@ smart_count: props.selected

className: "uppy-u-reset uppy-c-btn uppy-c-btn-link",
onClick: props.cancel
onClick: props.cancel,
type: "button"
}, props.i18n('cancel')));
};

@@ -66,5 +66,6 @@ "use strict";

return h("img", {
src: props.itemIconString
src: props.itemIconString,
alt: props.alt
});
}
};
"use strict";
const {
h,
Component
h
} = require('preact');
class AuthView extends Component {
render() {
const pluginNameComponent = h("span", {
className: "uppy-Provider-authTitleName"
}, this.props.pluginName, h("br", null));
return h("div", {
className: "uppy-Provider-auth"
}, h("div", {
className: "uppy-Provider-authIcon"
}, this.props.pluginIcon()), h("div", {
className: "uppy-Provider-authTitle"
}, this.props.i18nArray('authenticateWithTitle', {
pluginName: pluginNameComponent
})), h("button", {
type: "button",
className: "uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn",
onClick: this.props.handleAuth,
"data-uppy-super-focusable": true
}, this.props.i18nArray('authenticateWith', {
pluginName: this.props.pluginName
})));
}
function AuthView(props) {
const pluginNameComponent = h("span", {
className: "uppy-Provider-authTitleName"
}, props.pluginName, h("br", null));
return h("div", {
className: "uppy-Provider-auth"
}, h("div", {
className: "uppy-Provider-authIcon"
}, props.pluginIcon()), h("div", {
className: "uppy-Provider-authTitle"
}, props.i18nArray('authenticateWithTitle', {
pluginName: pluginNameComponent
})), h("button", {
type: "button",
className: "uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn",
onClick: props.handleAuth,
"data-uppy-super-focusable": true
}, props.i18nArray('authenticateWith', {
pluginName: props.pluginName
})));
}
module.exports = AuthView;
"use strict";
var _class, _temp;
var _class, _isHandlingScroll, _sharedHandler, _updateFilesAndFolders, _isOriginAllowed, _temp;
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
var id = 0;
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
const {

@@ -13,4 +19,2 @@ h

const findIndex = require('@uppy/utils/lib/findIndex');
const isPreviewSupported = require('@uppy/utils/lib/isPreviewSupported');

@@ -31,2 +35,3 @@

function getOrigin() {
// eslint-disable-next-line no-restricted-globals
return location.origin;

@@ -39,3 +44,3 @@ }

module.exports = (_temp = _class = class ProviderView {
module.exports = (_temp = (_isHandlingScroll = /*#__PURE__*/_classPrivateFieldLooseKey("isHandlingScroll"), _sharedHandler = /*#__PURE__*/_classPrivateFieldLooseKey("sharedHandler"), _updateFilesAndFolders = /*#__PURE__*/_classPrivateFieldLooseKey("updateFilesAndFolders"), _isOriginAllowed = /*#__PURE__*/_classPrivateFieldLooseKey("isOriginAllowed"), _class = class ProviderView {
/**

@@ -46,5 +51,19 @@ * @param {object} plugin instance of the plugin

constructor(plugin, opts) {
Object.defineProperty(this, _isOriginAllowed, {
value: _isOriginAllowed2
});
Object.defineProperty(this, _updateFilesAndFolders, {
value: _updateFilesAndFolders2
});
Object.defineProperty(this, _isHandlingScroll, {
writable: true,
value: void 0
});
Object.defineProperty(this, _sharedHandler, {
writable: true,
value: void 0
});
this.plugin = plugin;
this.provider = opts.provider;
this._sharedHandler = new SharedHandler(plugin); // set default options
_classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler] = new SharedHandler(plugin); // set default options

@@ -69,4 +88,2 @@ const defaultOptions = {

this.handleAuth = this.handleAuth.bind(this);
this.sortByTitle = this.sortByTitle.bind(this);
this.sortByDate = this.sortByDate.bind(this);
this.handleError = this.handleError.bind(this);

@@ -95,16 +112,2 @@ this.handleScroll = this.handleScroll.bind(this);

_updateFilesAndFolders(res, files, folders) {
this.nextPagePath = res.nextPagePath;
res.items.forEach(item => {
if (item.isFolder) {
folders.push(item);
} else {
files.push(item);
}
});
this.plugin.setPluginState({
folders,
files
});
}
/**

@@ -114,4 +117,2 @@ * Called only the first time the provider view is rendered.

*/
preFirstRender() {

@@ -132,3 +133,3 @@ this.plugin.setPluginState({

getFolder(id, name) {
return this._sharedHandler.loaderWrapper(this.provider.list(id), res => {
return _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].loaderWrapper(this.provider.list(id), res => {
const folders = [];

@@ -138,3 +139,3 @@ const files = [];

const state = this.plugin.getPluginState();
const index = findIndex(state.directories, dir => id === dir.id);
const index = state.directories.findIndex(dir => id === dir.id);

@@ -152,3 +153,3 @@ if (index !== -1) {

this._updateFilesAndFolders(res, files, folders);
_classPrivateFieldLooseBase(this, _updateFilesAndFolders)[_updateFilesAndFolders](res, files, folders);

@@ -244,94 +245,2 @@ this.plugin.setPluginState({

}
sortByTitle() {
const state = { ...this.plugin.getPluginState()
};
const {
files,
folders,
sorting
} = state;
const sortedFiles = files.sort((fileA, fileB) => {
if (sorting === 'titleDescending') {
return fileB.name.localeCompare(fileA.name);
}
return fileA.name.localeCompare(fileB.name);
});
const sortedFolders = folders.sort((folderA, folderB) => {
if (sorting === 'titleDescending') {
return folderB.name.localeCompare(folderA.name);
}
return folderA.name.localeCompare(folderB.name);
});
this.plugin.setPluginState({ ...state,
files: sortedFiles,
folders: sortedFolders,
sorting: sorting === 'titleDescending' ? 'titleAscending' : 'titleDescending'
});
}
sortByDate() {
const state = { ...this.plugin.getPluginState()
};
const {
files,
folders,
sorting
} = state;
const sortedFiles = files.sort((fileA, fileB) => {
const a = new Date(fileA.modifiedDate);
const b = new Date(fileB.modifiedDate);
if (sorting === 'dateDescending') {
return a > b ? -1 : a < b ? 1 : 0;
}
return a > b ? 1 : a < b ? -1 : 0;
});
const sortedFolders = folders.sort((folderA, folderB) => {
const a = new Date(folderA.modifiedDate);
const b = new Date(folderB.modifiedDate);
if (sorting === 'dateDescending') {
return a > b ? -1 : a < b ? 1 : 0;
}
return a > b ? 1 : a < b ? -1 : 0;
});
this.plugin.setPluginState({ ...state,
files: sortedFiles,
folders: sortedFolders,
sorting: sorting === 'dateDescending' ? 'dateAscending' : 'dateDescending'
});
}
sortBySize() {
const state = { ...this.plugin.getPluginState()
};
const {
files,
sorting
} = state; // check that plugin supports file sizes
if (!files.length || !this.plugin.getItemData(files[0]).size) {
return;
}
const sortedFiles = files.sort((fileA, fileB) => {
const a = fileA.size;
const b = fileB.size;
if (sorting === 'sizeDescending') {
return a > b ? -1 : a < b ? 1 : 0;
}
return a > b ? 1 : a < b ? -1 : 0;
});
this.plugin.setPluginState({ ...state,
files: sortedFiles,
sorting: sorting === 'sizeDescending' ? 'sizeAscending' : 'sizeDescending'
});
}
/**

@@ -438,3 +347,3 @@ * Adds all files found inside of specified folder.

const handleToken = e => {
if (!this._isOriginAllowed(e.origin, this.plugin.opts.companionAllowedHosts) || e.source !== authWindow) {
if (!_classPrivateFieldLooseBase(this, _isOriginAllowed)[_isOriginAllowed](e.origin, this.plugin.opts.companionAllowedHosts) || e.source !== authWindow) {
this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.companionAllowedHosts}`);

@@ -462,18 +371,2 @@ return;

_isOriginAllowed(origin, allowedOrigin) {
const getRegex = value => {
if (typeof value === 'string') {
return new RegExp(`^${value}$`);
}
if (value instanceof RegExp) {
return value;
}
};
const patterns = Array.isArray(allowedOrigin) ? allowedOrigin.map(getRegex) : [getRegex(allowedOrigin)];
return patterns.filter(pattern => pattern != null) // loose comparison to catch undefined
.some(pattern => pattern.test(origin) || pattern.test(`${origin}/`)); // allowing for trailing '/'
}
handleError(error) {

@@ -500,3 +393,3 @@ const {

if (scrollPos < 50 && path && !this._isHandlingScroll) {
if (scrollPos < 50 && path && !_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll]) {
this.provider.list(path).then(res => {

@@ -508,8 +401,8 @@ const {

this._updateFilesAndFolders(res, files, folders);
_classPrivateFieldLooseBase(this, _updateFilesAndFolders)[_updateFilesAndFolders](res, files, folders);
}).catch(this.handleError).then(() => {
this._isHandlingScroll = false;
_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll] = false;
}); // always called
this._isHandlingScroll = true;
_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll] = true;
}

@@ -552,3 +445,3 @@ }

this._sharedHandler.loaderWrapper(Promise.all(promises), () => {
_classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].loaderWrapper(Promise.all(promises), () => {
this.clearSelection();

@@ -619,9 +512,7 @@ }, () => {});

getFolder: this.getFolder,
filterItems: this._sharedHandler.filterItems,
filterItems: _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].filterItems,
filterQuery: this.filterQuery,
sortByTitle: this.sortByTitle,
sortByDate: this.sortByDate,
logout: this.logout,
isChecked: this._sharedHandler.isChecked,
toggleCheckbox: this._sharedHandler.toggleCheckbox,
isChecked: _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].isChecked,
toggleCheckbox: _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].toggleCheckbox,
handleScroll: this.handleScroll,

@@ -647,2 +538,33 @@ listAllFiles: this.listAllFiles,

}, _class.VERSION = "2.0.0-alpha.0", _temp);
}), _class.VERSION = "2.0.0", _temp);
function _updateFilesAndFolders2(res, files, folders) {
this.nextPagePath = res.nextPagePath;
res.items.forEach(item => {
if (item.isFolder) {
folders.push(item);
} else {
files.push(item);
}
});
this.plugin.setPluginState({
folders,
files
});
}
function _isOriginAllowed2(origin, allowedOrigin) {
const getRegex = value => {
if (typeof value === 'string') {
return new RegExp(`^${value}$`);
}
if (value instanceof RegExp) {
return value;
}
};
const patterns = Array.isArray(allowedOrigin) ? allowedOrigin.map(getRegex) : [getRegex(allowedOrigin)];
return patterns.filter(pattern => pattern != null) // loose comparison to catch undefined
.some(pattern => pattern.test(origin) || pattern.test(`${origin}/`)); // allowing for trailing '/'
}
"use strict";
var _class, _temp;
var _class, _isHandlingScroll, _searchTerm, _sharedHandler, _updateFilesAndInputMode, _temp;
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
var id = 0;
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
const {

@@ -31,3 +37,3 @@ h

module.exports = (_temp = _class = class ProviderView {
module.exports = (_temp = (_isHandlingScroll = /*#__PURE__*/_classPrivateFieldLooseKey("isHandlingScroll"), _searchTerm = /*#__PURE__*/_classPrivateFieldLooseKey("searchTerm"), _sharedHandler = /*#__PURE__*/_classPrivateFieldLooseKey("sharedHandler"), _updateFilesAndInputMode = /*#__PURE__*/_classPrivateFieldLooseKey("updateFilesAndInputMode"), _class = class ProviderView {
/**

@@ -38,5 +44,20 @@ * @param {object} plugin instance of the plugin

constructor(plugin, opts) {
Object.defineProperty(this, _updateFilesAndInputMode, {
value: _updateFilesAndInputMode2
});
Object.defineProperty(this, _isHandlingScroll, {
writable: true,
value: void 0
});
Object.defineProperty(this, _searchTerm, {
writable: true,
value: void 0
});
Object.defineProperty(this, _sharedHandler, {
writable: true,
value: void 0
});
this.plugin = plugin;
this.provider = opts.provider;
this._sharedHandler = new SharedHandler(plugin); // set default options
_classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler] = new SharedHandler(plugin); // set default options

@@ -80,13 +101,2 @@ const defaultOptions = {

_updateFilesAndInputMode(res, files) {
this.nextPageQuery = res.nextPageQuery;
this._searchTerm = res.searchedFor;
res.items.forEach(item => {
files.push(item);
});
this.plugin.setPluginState({
isInputMode: false,
files
});
}
/**

@@ -96,4 +106,2 @@ * Called only the first time the provider view is rendered.

*/
preFirstRender() {

@@ -107,3 +115,3 @@ this.plugin.setPluginState({

search(query) {
if (query && query === this._searchTerm) {
if (query && query === _classPrivateFieldLooseBase(this, _searchTerm)[_searchTerm]) {
// no need to search again as this is the same as the previous search

@@ -116,4 +124,4 @@ this.plugin.setPluginState({

return this._sharedHandler.loaderWrapper(this.provider.search(query), res => {
this._updateFilesAndInputMode(res, []);
return _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].loaderWrapper(this.provider.search(query), res => {
_classPrivateFieldLooseBase(this, _updateFilesAndInputMode)[_updateFilesAndInputMode](res, []);
}, this.handleError);

@@ -193,4 +201,4 @@ }

if (scrollPos < 50 && query && !this._isHandlingScroll) {
this.provider.search(this._searchTerm, query).then(res => {
if (scrollPos < 50 && query && !_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll]) {
this.provider.search(_classPrivateFieldLooseBase(this, _searchTerm)[_searchTerm], query).then(res => {
const {

@@ -200,8 +208,8 @@ files

this._updateFilesAndInputMode(res, files);
_classPrivateFieldLooseBase(this, _updateFilesAndInputMode)[_updateFilesAndInputMode](res, files);
}).catch(this.handleError).then(() => {
this._isHandlingScroll = false;
_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll] = false;
}); // always called
this._isHandlingScroll = true;
_classPrivateFieldLooseBase(this, _isHandlingScroll)[_isHandlingScroll] = true;
}

@@ -216,3 +224,3 @@ }

this._sharedHandler.loaderWrapper(Promise.all(promises), () => {
_classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].loaderWrapper(Promise.all(promises), () => {
this.clearSelection();

@@ -267,4 +275,4 @@ }, () => {});

const browserProps = { ...this.plugin.getPluginState(),
isChecked: this._sharedHandler.isChecked,
toggleCheckbox: this._sharedHandler.toggleCheckbox,
isChecked: _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].isChecked,
toggleCheckbox: _classPrivateFieldLooseBase(this, _sharedHandler)[_sharedHandler].toggleCheckbox,
handleScroll: this.handleScroll,

@@ -292,2 +300,14 @@ done: this.donePicking,

}, _class.VERSION = "2.0.0-alpha.0", _temp);
}), _class.VERSION = "2.0.0", _temp);
function _updateFilesAndInputMode2(res, files) {
this.nextPageQuery = res.nextPageQuery;
_classPrivateFieldLooseBase(this, _searchTerm)[_searchTerm] = res.searchedFor;
res.items.forEach(item => {
files.push(item);
});
this.plugin.setPluginState({
isInputMode: false,
files
});
}
{
"name": "@uppy/provider-views",
"description": "View library for Uppy remote provider plugins.",
"version": "2.0.0-alpha.0",
"version": "2.0.0",
"license": "MIT",

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

"dependencies": {
"@uppy/utils": "^4.0.0-alpha.0",
"@uppy/utils": "^4.0.0",
"classnames": "^2.2.6",

@@ -30,3 +30,3 @@ "preact": "^10.5.13"

},
"gitHead": "113b627dd0ef5aa5d198dc309dda05da2117dfe5"
"gitHead": "ab771cbe1cd87affd87c97bc983b19058e2e72bd"
}

@@ -42,4 +42,2 @@ const classNames = require('classnames')

files={filteredFiles}
sortByTitle={props.sortByTitle}
sortByDate={props.sortByDate}
isChecked={props.isChecked}

@@ -46,0 +44,0 @@ handleFolderClick={props.getNextFolder}

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

<div className="uppy-ProviderBrowser-footer">
<button className="uppy-u-reset uppy-c-btn uppy-c-btn-primary" onClick={props.done}>
<button className="uppy-u-reset uppy-c-btn uppy-c-btn-primary" onClick={props.done} type="button">
{props.i18n('selectX', {

@@ -12,3 +12,3 @@ smart_count: props.selected,

</button>
<button className="uppy-u-reset uppy-c-btn uppy-c-btn-link" onClick={props.cancel}>
<button className="uppy-u-reset uppy-c-btn uppy-c-btn-link" onClick={props.cancel} type="button">
{props.i18n('cancel')}

@@ -15,0 +15,0 @@ </button>

@@ -39,4 +39,4 @@ const { h } = require('preact')

default:
return <img src={props.itemIconString} />
return <img src={props.itemIconString} alt={props.alt} />
}
}

@@ -1,30 +0,28 @@

const { h, Component } = require('preact')
const { h } = require('preact')
class AuthView extends Component {
render () {
const pluginNameComponent = (
<span className="uppy-Provider-authTitleName">
{this.props.pluginName}
<br />
</span>
)
return (
<div className="uppy-Provider-auth">
<div className="uppy-Provider-authIcon">{this.props.pluginIcon()}</div>
<div className="uppy-Provider-authTitle">
{this.props.i18nArray('authenticateWithTitle', { pluginName: pluginNameComponent })}
</div>
<button
type="button"
className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn"
onClick={this.props.handleAuth}
data-uppy-super-focusable
>
{this.props.i18nArray('authenticateWith', { pluginName: this.props.pluginName })}
</button>
function AuthView (props) {
const pluginNameComponent = (
<span className="uppy-Provider-authTitleName">
{props.pluginName}
<br />
</span>
)
return (
<div className="uppy-Provider-auth">
<div className="uppy-Provider-authIcon">{props.pluginIcon()}</div>
<div className="uppy-Provider-authTitle">
{props.i18nArray('authenticateWithTitle', { pluginName: pluginNameComponent })}
</div>
)
}
<button
type="button"
className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn"
onClick={props.handleAuth}
data-uppy-super-focusable
>
{props.i18nArray('authenticateWith', { pluginName: props.pluginName })}
</button>
</div>
)
}
module.exports = AuthView
const { h } = require('preact')
const generateFileID = require('@uppy/utils/lib/generateFileID')
const getFileType = require('@uppy/utils/lib/getFileType')
const findIndex = require('@uppy/utils/lib/findIndex')
const isPreviewSupported = require('@uppy/utils/lib/isPreviewSupported')

@@ -14,2 +13,3 @@ const AuthView = require('./AuthView')

function getOrigin () {
// eslint-disable-next-line no-restricted-globals
return location.origin

@@ -24,2 +24,6 @@ }

#isHandlingScroll
#sharedHandler
/**

@@ -32,3 +36,3 @@ * @param {object} plugin instance of the plugin

this.provider = opts.provider
this._sharedHandler = new SharedHandler(plugin)
this.#sharedHandler = new SharedHandler(plugin)

@@ -54,4 +58,2 @@ // set default options

this.handleAuth = this.handleAuth.bind(this)
this.sortByTitle = this.sortByTitle.bind(this)
this.sortByDate = this.sortByDate.bind(this)
this.handleError = this.handleError.bind(this)

@@ -84,3 +86,3 @@ this.handleScroll = this.handleScroll.bind(this)

_updateFilesAndFolders (res, files, folders) {
#updateFilesAndFolders (res, files, folders) {
this.nextPagePath = res.nextPagePath

@@ -114,3 +116,3 @@ res.items.forEach((item) => {

getFolder (id, name) {
return this._sharedHandler.loaderWrapper(
return this.#sharedHandler.loaderWrapper(
this.provider.list(id),

@@ -123,3 +125,3 @@ (res) => {

const state = this.plugin.getPluginState()
const index = findIndex(state.directories, (dir) => id === dir.id)
const index = state.directories.findIndex((dir) => id === dir.id)

@@ -133,3 +135,3 @@ if (index !== -1) {

this.username = res.username || this.username
this._updateFilesAndFolders(res, files, folders)
this.#updateFilesAndFolders(res, files, folders)
this.plugin.setPluginState({ directories: updatedDirectories })

@@ -220,87 +222,2 @@ },

sortByTitle () {
const state = { ...this.plugin.getPluginState() }
const { files, folders, sorting } = state
const sortedFiles = files.sort((fileA, fileB) => {
if (sorting === 'titleDescending') {
return fileB.name.localeCompare(fileA.name)
}
return fileA.name.localeCompare(fileB.name)
})
const sortedFolders = folders.sort((folderA, folderB) => {
if (sorting === 'titleDescending') {
return folderB.name.localeCompare(folderA.name)
}
return folderA.name.localeCompare(folderB.name)
})
this.plugin.setPluginState({
...state,
files: sortedFiles,
folders: sortedFolders,
sorting: (sorting === 'titleDescending') ? 'titleAscending' : 'titleDescending',
})
}
sortByDate () {
const state = { ...this.plugin.getPluginState() }
const { files, folders, sorting } = state
const sortedFiles = files.sort((fileA, fileB) => {
const a = new Date(fileA.modifiedDate)
const b = new Date(fileB.modifiedDate)
if (sorting === 'dateDescending') {
return a > b ? -1 : a < b ? 1 : 0
}
return a > b ? 1 : a < b ? -1 : 0
})
const sortedFolders = folders.sort((folderA, folderB) => {
const a = new Date(folderA.modifiedDate)
const b = new Date(folderB.modifiedDate)
if (sorting === 'dateDescending') {
return a > b ? -1 : a < b ? 1 : 0
}
return a > b ? 1 : a < b ? -1 : 0
})
this.plugin.setPluginState({
...state,
files: sortedFiles,
folders: sortedFolders,
sorting: (sorting === 'dateDescending') ? 'dateAscending' : 'dateDescending',
})
}
sortBySize () {
const state = { ...this.plugin.getPluginState() }
const { files, sorting } = state
// check that plugin supports file sizes
if (!files.length || !this.plugin.getItemData(files[0]).size) {
return
}
const sortedFiles = files.sort((fileA, fileB) => {
const a = fileA.size
const b = fileB.size
if (sorting === 'sizeDescending') {
return a > b ? -1 : a < b ? 1 : 0
}
return a > b ? 1 : a < b ? -1 : 0
})
this.plugin.setPluginState({
...state,
files: sortedFiles,
sorting: (sorting === 'sizeDescending') ? 'sizeAscending' : 'sizeDescending',
})
}
/**

@@ -391,3 +308,3 @@ * Adds all files found inside of specified folder.

const handleToken = (e) => {
if (!this._isOriginAllowed(e.origin, this.plugin.opts.companionAllowedHosts) || e.source !== authWindow) {
if (!this.#isOriginAllowed(e.origin, this.plugin.opts.companionAllowedHosts) || e.source !== authWindow) {
this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.companionAllowedHosts}`)

@@ -414,3 +331,3 @@ return

_isOriginAllowed (origin, allowedOrigin) {
#isOriginAllowed (origin, allowedOrigin) {
const getRegex = (value) => {

@@ -444,11 +361,11 @@ if (typeof value === 'string') {

if (scrollPos < 50 && path && !this._isHandlingScroll) {
if (scrollPos < 50 && path && !this.#isHandlingScroll) {
this.provider.list(path)
.then((res) => {
const { files, folders } = this.plugin.getPluginState()
this._updateFilesAndFolders(res, files, folders)
this.#updateFilesAndFolders(res, files, folders)
}).catch(this.handleError)
.then(() => { this._isHandlingScroll = false }) // always called
.then(() => { this.#isHandlingScroll = false }) // always called
this._isHandlingScroll = true
this.#isHandlingScroll = true
}

@@ -488,3 +405,3 @@ }

this._sharedHandler.loaderWrapper(Promise.all(promises), () => {
this.#sharedHandler.loaderWrapper(Promise.all(promises), () => {
this.clearSelection()

@@ -552,9 +469,7 @@ }, () => {})

getFolder: this.getFolder,
filterItems: this._sharedHandler.filterItems,
filterItems: this.#sharedHandler.filterItems,
filterQuery: this.filterQuery,
sortByTitle: this.sortByTitle,
sortByDate: this.sortByDate,
logout: this.logout,
isChecked: this._sharedHandler.isChecked,
toggleCheckbox: this._sharedHandler.toggleCheckbox,
isChecked: this.#sharedHandler.isChecked,
toggleCheckbox: this.#sharedHandler.toggleCheckbox,
handleScroll: this.handleScroll,

@@ -561,0 +476,0 @@ listAllFiles: this.listAllFiles,

@@ -18,2 +18,8 @@ const { h } = require('preact')

#isHandlingScroll
#searchTerm
#sharedHandler
/**

@@ -26,3 +32,3 @@ * @param {object} plugin instance of the plugin

this.provider = opts.provider
this._sharedHandler = new SharedHandler(plugin)
this.#sharedHandler = new SharedHandler(plugin)

@@ -71,5 +77,5 @@ // set default options

_updateFilesAndInputMode (res, files) {
#updateFilesAndInputMode (res, files) {
this.nextPageQuery = res.nextPageQuery
this._searchTerm = res.searchedFor
this.#searchTerm = res.searchedFor
res.items.forEach((item) => { files.push(item) })

@@ -89,3 +95,3 @@ this.plugin.setPluginState({ isInputMode: false, files })

search (query) {
if (query && query === this._searchTerm) {
if (query && query === this.#searchTerm) {
// no need to search again as this is the same as the previous search

@@ -96,6 +102,6 @@ this.plugin.setPluginState({ isInputMode: false })

return this._sharedHandler.loaderWrapper(
return this.#sharedHandler.loaderWrapper(
this.provider.search(query),
(res) => {
this._updateFilesAndInputMode(res, [])
this.#updateFilesAndInputMode(res, [])
},

@@ -167,11 +173,11 @@ this.handleError

if (scrollPos < 50 && query && !this._isHandlingScroll) {
this.provider.search(this._searchTerm, query)
if (scrollPos < 50 && query && !this.#isHandlingScroll) {
this.provider.search(this.#searchTerm, query)
.then((res) => {
const { files } = this.plugin.getPluginState()
this._updateFilesAndInputMode(res, files)
this.#updateFilesAndInputMode(res, files)
}).catch(this.handleError)
.then(() => { this._isHandlingScroll = false }) // always called
.then(() => { this.#isHandlingScroll = false }) // always called
this._isHandlingScroll = true
this.#isHandlingScroll = true
}

@@ -184,3 +190,3 @@ }

this._sharedHandler.loaderWrapper(Promise.all(promises), () => {
this.#sharedHandler.loaderWrapper(Promise.all(promises), () => {
this.clearSelection()

@@ -231,4 +237,4 @@ }, () => {})

...this.plugin.getPluginState(),
isChecked: this._sharedHandler.isChecked,
toggleCheckbox: this._sharedHandler.toggleCheckbox,
isChecked: this.#sharedHandler.isChecked,
toggleCheckbox: this.#sharedHandler.toggleCheckbox,
handleScroll: this.handleScroll,

@@ -235,0 +241,0 @@ done: this.donePicking,

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