@scaleflex/widget-provider-views 4.4.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/style.css +787 -0
- package/dist/style.min.css +1 -0
- package/lib/components/AuthView.js +35 -0
- package/lib/components/AuthView.styled.js +21 -0
- package/lib/components/Browser.js +58 -0
- package/lib/components/FolderImportProgress/FolderImportProgress.styled.js +50 -0
- package/lib/components/FolderImportProgress/index.js +50 -0
- package/lib/components/Items/AssetsSection/AssetsSectionTableHeader.js +41 -0
- package/lib/components/Items/AssetsSection/AssetsSectionTableRow.js +147 -0
- package/lib/components/Items/AssetsSection/index.js +65 -0
- package/lib/components/Items/FoldersSection/FoldersSectionTableHeader.js +41 -0
- package/lib/components/Items/FoldersSection/FoldersSectionTableRow.js +102 -0
- package/lib/components/Items/FoldersSection/index.js +64 -0
- package/lib/components/Items/Items.styled.js +156 -0
- package/lib/components/Items/List.js +96 -0
- package/lib/components/Items/index.js +172 -0
- package/lib/components/SearchProviderView/FooterActions.js +25 -0
- package/lib/components/SearchProviderView/SearchFilterInput.js +76 -0
- package/lib/components/SearchProviderView/SearchProviderBrowser.js +74 -0
- package/lib/components/SearchProviderView/SearchProviderBrowser.styled.js +65 -0
- package/lib/components/SearchProviderView/SearchProviderView.js +248 -0
- package/lib/components/SearchProviderView/index.js +1 -0
- package/lib/context/index.js +2 -0
- package/lib/hooks/useBrowserContext.js +5 -0
- package/lib/utils/View.js +219 -0
- package/lib/utils/remoteFileObjToLocal.js +13 -0
- package/package.json +5 -5
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
6
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
11
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import getFileType from '@scaleflex/widget-utils/lib/getFileType';
|
|
16
|
+
import isPreviewSupported from '@scaleflex/widget-utils/lib/isPreviewSupported';
|
|
17
|
+
import remoteFileObjToLocal from './remoteFileObjToLocal';
|
|
18
|
+
var View = /*#__PURE__*/function () {
|
|
19
|
+
function View(plugin, opts) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
_classCallCheck(this, View);
|
|
22
|
+
_defineProperty(this, "filterItems", function (items) {
|
|
23
|
+
var state = _this.plugin.getPluginCommonState();
|
|
24
|
+
if (!state.filterInput || state.filterInput === '') {
|
|
25
|
+
return items;
|
|
26
|
+
}
|
|
27
|
+
return items.filter(function (folder) {
|
|
28
|
+
return folder.name.toLowerCase().indexOf(state.filterInput.toLowerCase()) !== -1;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
_defineProperty(this, "recordShiftKeyPress", function (e) {
|
|
32
|
+
_this.isShiftKeyPressed = e.shiftKey;
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Toggles file/folder checkbox to on/off state while updating files list.
|
|
36
|
+
*
|
|
37
|
+
* Note that some extra complexity comes from supporting shift+click to
|
|
38
|
+
* toggle multiple checkboxes at once, which is done by getting all files
|
|
39
|
+
* in between last checked file and current one.
|
|
40
|
+
*/
|
|
41
|
+
_defineProperty(this, "toggleCheckbox", function (e, file) {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
e.currentTarget.focus();
|
|
45
|
+
// Shift-clicking selects a single consecutive list of items
|
|
46
|
+
// starting at the previous click and deselects everything else.
|
|
47
|
+
if (_this.lastCheckbox && _this.isShiftKeyPressed) {
|
|
48
|
+
var _this$plugin$getPlugi = _this.plugin.getPluginCommonState(),
|
|
49
|
+
folders = _this$plugin$getPlugi.folders,
|
|
50
|
+
files = _this$plugin$getPlugi.files;
|
|
51
|
+
var items = _this.filterItems(folders.concat(files));
|
|
52
|
+
var prevIndex = items.indexOf(_this.lastCheckbox);
|
|
53
|
+
var currentIndex = items.indexOf(file);
|
|
54
|
+
var _currentSelection = prevIndex < currentIndex ? items.slice(prevIndex, currentIndex + 1) : items.slice(currentIndex, prevIndex + 1);
|
|
55
|
+
var reducedCurrentSelection = [];
|
|
56
|
+
if (_this.plugin.filerobot.isFileRestrictedToGetAdded(_currentSelection, file)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Check restrictions on each file in currentSelection,
|
|
61
|
+
// reduce it to only contain files that pass restrictions
|
|
62
|
+
var _iterator = _createForOfIteratorHelper(_currentSelection),
|
|
63
|
+
_step;
|
|
64
|
+
try {
|
|
65
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var item = _step.value;
|
|
67
|
+
var filerobot = _this.plugin.filerobot;
|
|
68
|
+
var restrictionError = filerobot.checkUserPermissions(remoteFileObjToLocal(item), [].concat(_toConsumableArray(filerobot.getUploadsArray()), reducedCurrentSelection));
|
|
69
|
+
if (!restrictionError) {
|
|
70
|
+
reducedCurrentSelection.push(item);
|
|
71
|
+
} else {
|
|
72
|
+
filerobot.info({
|
|
73
|
+
message: restrictionError.message
|
|
74
|
+
}, 'error', filerobot.opts.infoTimeout);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
_iterator.e(err);
|
|
79
|
+
} finally {
|
|
80
|
+
_iterator.f();
|
|
81
|
+
}
|
|
82
|
+
_this.plugin.setPluginCommonState({
|
|
83
|
+
currentSelection: reducedCurrentSelection
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
_this.lastCheckbox = file;
|
|
88
|
+
var _this$plugin$getPlugi2 = _this.plugin.getPluginCommonState(),
|
|
89
|
+
currentSelection = _this$plugin$getPlugi2.currentSelection;
|
|
90
|
+
if (_this.isChecked(file)) {
|
|
91
|
+
_this.plugin.setPluginCommonState({
|
|
92
|
+
currentSelection: currentSelection.filter(function (item) {
|
|
93
|
+
return item.id !== file.id;
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
if (_this.plugin.filerobot.isFileRestrictedToGetAdded(currentSelection, file)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
_this.plugin.setPluginCommonState({
|
|
101
|
+
currentSelection: currentSelection.concat([file])
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
_defineProperty(this, "isChecked", function (file) {
|
|
106
|
+
var _this$plugin$getPlugi3 = _this.plugin.getPluginCommonState(),
|
|
107
|
+
currentSelection = _this$plugin$getPlugi3.currentSelection;
|
|
108
|
+
// comparing id instead of the file object, because the reference to the object
|
|
109
|
+
// changes when we switch folders, and the file list is updated
|
|
110
|
+
return currentSelection.some(function (item) {
|
|
111
|
+
return item.id === file.id;
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
this.plugin = plugin;
|
|
115
|
+
this.provider = opts.provider;
|
|
116
|
+
this.isHandlingScroll = false;
|
|
117
|
+
this.preFirstRender = this.preFirstRender.bind(this);
|
|
118
|
+
this.handleError = this.handleError.bind(this);
|
|
119
|
+
this.clearSelection = this.clearSelection.bind(this);
|
|
120
|
+
this.cancelPicking = this.cancelPicking.bind(this);
|
|
121
|
+
}
|
|
122
|
+
return _createClass(View, [{
|
|
123
|
+
key: "preFirstRender",
|
|
124
|
+
value: function preFirstRender() {
|
|
125
|
+
this.plugin.setPluginCommonState({
|
|
126
|
+
didFirstRender: true,
|
|
127
|
+
hideActionButtons: true
|
|
128
|
+
});
|
|
129
|
+
this.plugin.onFirstRender();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// eslint-disable-next-line class-methods-use-this
|
|
133
|
+
}, {
|
|
134
|
+
key: "shouldHandleScroll",
|
|
135
|
+
value: function shouldHandleScroll(event) {
|
|
136
|
+
var _event$target = event.target,
|
|
137
|
+
scrollHeight = _event$target.scrollHeight,
|
|
138
|
+
scrollTop = _event$target.scrollTop,
|
|
139
|
+
offsetHeight = _event$target.offsetHeight;
|
|
140
|
+
var scrollPosition = scrollHeight - (scrollTop + offsetHeight);
|
|
141
|
+
return scrollPosition < 50 && !this.isHandlingScroll;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "clearSelection",
|
|
145
|
+
value: function clearSelection() {
|
|
146
|
+
this.plugin.setPluginCommonState({
|
|
147
|
+
currentSelection: [],
|
|
148
|
+
filterInput: ''
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "cancelPicking",
|
|
153
|
+
value: function cancelPicking() {
|
|
154
|
+
this.clearSelection();
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "handleError",
|
|
158
|
+
value: function handleError(error) {
|
|
159
|
+
var filerobot = this.plugin.filerobot;
|
|
160
|
+
var message = filerobot.i18n('providerViewCompanionError');
|
|
161
|
+
filerobot.log(error.toString());
|
|
162
|
+
if (error.isAuthError) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
filerobot.info({
|
|
166
|
+
message: message,
|
|
167
|
+
details: error.toString()
|
|
168
|
+
}, 'error', 5000);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// todo document what is a "tagFile" or get rid of this concept
|
|
172
|
+
}, {
|
|
173
|
+
key: "getTagFile",
|
|
174
|
+
value: function getTagFile(file) {
|
|
175
|
+
var tagFile = {
|
|
176
|
+
id: file.id,
|
|
177
|
+
source: this.plugin.id,
|
|
178
|
+
data: file,
|
|
179
|
+
name: file.name || file.id,
|
|
180
|
+
type: file.mimeType,
|
|
181
|
+
isRemote: true,
|
|
182
|
+
meta: {},
|
|
183
|
+
body: {
|
|
184
|
+
fileId: file.id
|
|
185
|
+
},
|
|
186
|
+
remote: {
|
|
187
|
+
companionUrl: this.plugin.provider.companionUrl,
|
|
188
|
+
url: "".concat(this.provider.fileUrl(file.requestPath)),
|
|
189
|
+
body: {
|
|
190
|
+
fileId: file.id
|
|
191
|
+
},
|
|
192
|
+
providerOptions: this.provider.opts,
|
|
193
|
+
providerName: this.provider.name,
|
|
194
|
+
provider: this.provider.provider
|
|
195
|
+
},
|
|
196
|
+
preview: file.preview || file.thumbnail || file.icon || file.url
|
|
197
|
+
};
|
|
198
|
+
var fileType = getFileType(tagFile);
|
|
199
|
+
|
|
200
|
+
// TODO Should we just always use the thumbnail URL if it exists?
|
|
201
|
+
if (fileType && isPreviewSupported(fileType)) {
|
|
202
|
+
tagFile.preview = file.thumbnail;
|
|
203
|
+
}
|
|
204
|
+
if (file.author) {
|
|
205
|
+
if (file.author.name != null) tagFile.meta.authorName = String(file.author.name);
|
|
206
|
+
if (file.author.url) tagFile.meta.authorUrl = file.author.url;
|
|
207
|
+
}
|
|
208
|
+
return tagFile;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "setLoading",
|
|
212
|
+
value: function setLoading(loading) {
|
|
213
|
+
this.plugin.setPluginCommonState({
|
|
214
|
+
loading: loading
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}]);
|
|
218
|
+
}();
|
|
219
|
+
export { View as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import getFileNameAndExtension from '@scaleflex/widget-utils/lib/getFileNameAndExtension';
|
|
8
|
+
export default function remoteFileObjToLocal(file) {
|
|
9
|
+
return _objectSpread(_objectSpread({}, file), {}, {
|
|
10
|
+
type: file.mimeType,
|
|
11
|
+
extension: file.name ? getFileNameAndExtension(file.name, file.type).extension : null
|
|
12
|
+
});
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/widget-provider-views",
|
|
3
3
|
"description": "View library for Scaleflex remote provider plugins.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"style": "dist/style.min.css",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@scaleflex/icons": "^3.0.0-beta.11",
|
|
19
19
|
"@scaleflex/ui": "^3.0.0-beta.11",
|
|
20
|
-
"@scaleflex/widget-common": "^4.
|
|
21
|
-
"@scaleflex/widget-icons": "^4.
|
|
22
|
-
"@scaleflex/widget-utils": "^4.
|
|
20
|
+
"@scaleflex/widget-common": "^4.5.1",
|
|
21
|
+
"@scaleflex/widget-icons": "^4.5.1",
|
|
22
|
+
"@scaleflex/widget-utils": "^4.5.1",
|
|
23
23
|
"classnames": "^2.2.6",
|
|
24
24
|
"use-context-selector": "^1.3.9"
|
|
25
25
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"react": ">=19.0.0",
|
|
33
33
|
"react-dom": ">=19.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "b211f9961ad30d3eaa01138f34e190ad5d38fb91"
|
|
36
36
|
}
|